Remove reliance on Tz\import (YEEESS)
Showing
6 changed files
with
299 additions
and
135 deletions
com/HybridGallery/.gitignore
0 → 100644
| 1 | vendor/ | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
com/HybridGallery/composer.json
0 → 100644
com/HybridGallery/composer.lock
0 → 100644
| 1 | { | ||
| 2 | "_readme": [ | ||
| 3 | "This file locks the dependencies of your project to a known state", | ||
| 4 | "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", | ||
| 5 | "This file is @generated automatically" | ||
| 6 | ], | ||
| 7 | "hash": "48a711bf2a9a641edb17c3599ffc1477", | ||
| 8 | "packages": [ | ||
| 9 | { | ||
| 10 | "name": "zendframework/zendframework1", | ||
| 11 | "version": "1.12.7", | ||
| 12 | "source": { | ||
| 13 | "type": "git", | ||
| 14 | "url": "https://github.com/zendframework/zf1.git", | ||
| 15 | "reference": "bf3e8b557a5cef1b3f3c99636f8cdd93f884812a" | ||
| 16 | }, | ||
| 17 | "dist": { | ||
| 18 | "type": "zip", | ||
| 19 | "url": "https://api.github.com/repos/zendframework/zf1/zipball/bf3e8b557a5cef1b3f3c99636f8cdd93f884812a", | ||
| 20 | "reference": "bf3e8b557a5cef1b3f3c99636f8cdd93f884812a", | ||
| 21 | "shasum": "" | ||
| 22 | }, | ||
| 23 | "require": { | ||
| 24 | "php": ">=5.2.11" | ||
| 25 | }, | ||
| 26 | "require-dev": { | ||
| 27 | "phpunit/dbunit": "1.3.*", | ||
| 28 | "phpunit/phpunit": "3.7.*" | ||
| 29 | }, | ||
| 30 | "type": "library", | ||
| 31 | "extra": { | ||
| 32 | "branch-alias": { | ||
| 33 | "dev-master": "1.12.x-dev" | ||
| 34 | } | ||
| 35 | }, | ||
| 36 | "autoload": { | ||
| 37 | "psr-0": { | ||
| 38 | "Zend_": "library/" | ||
| 39 | } | ||
| 40 | }, | ||
| 41 | "notification-url": "https://packagist.org/downloads/", | ||
| 42 | "include-path": [ | ||
| 43 | "library/" | ||
| 44 | ], | ||
| 45 | "license": [ | ||
| 46 | "BSD-3-Clause" | ||
| 47 | ], | ||
| 48 | "description": "Zend Framework 1", | ||
| 49 | "homepage": "http://framework.zend.com/", | ||
| 50 | "keywords": [ | ||
| 51 | "ZF1", | ||
| 52 | "framework" | ||
| 53 | ], | ||
| 54 | "time": "2014-06-12 16:20:25" | ||
| 55 | } | ||
| 56 | ], | ||
| 57 | "packages-dev": [ | ||
| 58 | |||
| 59 | ], | ||
| 60 | "aliases": [ | ||
| 61 | |||
| 62 | ], | ||
| 63 | "minimum-stability": "stable", | ||
| 64 | "stability-flags": [ | ||
| 65 | |||
| 66 | ], | ||
| 67 | "platform": [ | ||
| 68 | |||
| 69 | ], | ||
| 70 | "platform-dev": [ | ||
| 71 | |||
| 72 | ] | ||
| 73 | } |
| ... | @@ -2,28 +2,30 @@ | ... | @@ -2,28 +2,30 @@ |
| 2 | //namespace Tz\WordPress\Tools\HybridGallery; | 2 | //namespace Tz\WordPress\Tools\HybridGallery; |
| 3 | 3 | ||
| 4 | error_reporting(E_ALL ^ E_DEPRECATED); | 4 | error_reporting(E_ALL ^ E_DEPRECATED); |
| 5 | //use Tz\WordPress\Tools; | ||
| 6 | 5 | ||
| 6 | require_once __DIR__.'/../../../../../wp-config.php'; | ||
| 7 | require_once __DIR__.'/../vendor/autoload.php'; | ||
| 7 | 8 | ||
| 8 | 9 | /** | |
| 9 | require_once("../../../../../wp-config.php"); | 10 | * @param $d |
| 10 | 11 | * @param bool $die | |
| 11 | Tz\import('Zend', '1.9'); | 12 | */ |
| 12 | require_once 'Zend/Loader.php'; | 13 | function trace($d, $die = false) |
| 13 | Zend_Loader::loadClass('Zend_Gdata_HttpClient'); | 14 | { |
| 14 | Zend_Loader::loadClass('Zend_Gdata_YouTube'); | ||
| 15 | Zend_Loader::loadClass('Zend_Gdata_ClientLogin'); | ||
| 16 | |||
| 17 | function trace($d,$die = false) { | ||
| 18 | print "<pre>"; | 15 | print "<pre>"; |
| 19 | print_r($d); | 16 | print_r($d); |
| 20 | print "</pre>"; | 17 | print "</pre>"; |
| 21 | if($die) { die('-- end of trace --'); } | 18 | if ($die) { |
| 19 | die('-- end of trace --'); | ||
| 20 | } | ||
| 22 | } | 21 | } |
| 23 | 22 | ||
| 24 | class Forms { | 23 | /** |
| 25 | 24 | * Class Forms | |
| 26 | protected $postdata = array(); | 25 | */ |
| 26 | class Forms | ||
| 27 | { | ||
| 28 | protected $postdata = []; | ||
| 27 | protected $form = null; | 29 | protected $form = null; |
| 28 | protected $post_type = 'gallery'; | 30 | protected $post_type = 'gallery'; |
| 29 | protected $gallery = ''; | 31 | protected $gallery = ''; |
| ... | @@ -31,16 +33,29 @@ class Forms { | ... | @@ -31,16 +33,29 @@ class Forms { |
| 31 | protected $settings; | 33 | protected $settings; |
| 32 | protected $requires_approval = "no"; | 34 | protected $requires_approval = "no"; |
| 33 | 35 | ||
| 34 | public function __construct($db,$user) { | 36 | /** |
| 37 | * @param $db | ||
| 38 | * @param $user | ||
| 39 | */ | ||
| 40 | public function __construct($db, $user) | ||
| 41 | { | ||
| 35 | $this->db = $db; | 42 | $this->db = $db; |
| 36 | $this->user = $user; | 43 | $this->user = $user; |
| 37 | } | 44 | } |
| 38 | 45 | ||
| 39 | public function set_form($form_type) { | 46 | /** |
| 47 | * @param $form_type | ||
| 48 | */ | ||
| 49 | public function set_form($form_type) | ||
| 50 | { | ||
| 40 | $this->form = $form_type; | 51 | $this->form = $form_type; |
| 41 | } | 52 | } |
| 42 | 53 | ||
| 43 | public function set_data($data = array()) { | 54 | /** |
| 55 | * @param array $data | ||
| 56 | */ | ||
| 57 | public function set_data($data = []) | ||
| 58 | { | ||
| 44 | if (count($data) > 0) { | 59 | if (count($data) > 0) { |
| 45 | // remove unecessary indexes. | 60 | // remove unecessary indexes. |
| 46 | unset($data['approval']); | 61 | unset($data['approval']); |
| ... | @@ -51,78 +66,32 @@ class Forms { | ... | @@ -51,78 +66,32 @@ class Forms { |
| 51 | } | 66 | } |
| 52 | } | 67 | } |
| 53 | 68 | ||
| 54 | public function set_approval($a) { | 69 | /** |
| 70 | * @param $a | ||
| 71 | */ | ||
| 72 | public function set_approval($a) | ||
| 73 | { | ||
| 55 | $this->requires_approval = $a; | 74 | $this->requires_approval = $a; |
| 56 | } | 75 | } |
| 57 | 76 | ||
| 58 | protected function getRealIpAddr() { | 77 | /** |
| 59 | if (!empty($_SERVER['HTTP_CLIENT_IP'])) //check ip from share internet | 78 | * @param $post_type |
| 60 | { | 79 | */ |
| 61 | $ip=$_SERVER['HTTP_CLIENT_IP']; | 80 | public function set_post_type($post_type) |
| 62 | } | ||
| 63 | elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to check ip is pass from proxy | ||
| 64 | { | 81 | { |
| 65 | $ip=$_SERVER['HTTP_X_FORWARDED_FOR']; | ||
| 66 | } | ||
| 67 | else | ||
| 68 | { | ||
| 69 | $ip=$_SERVER['REMOTE_ADDR']; | ||
| 70 | } | ||
| 71 | return $ip; | ||
| 72 | } | ||
| 73 | |||
| 74 | public function set_gallery($gallery) { | ||
| 75 | $this->gallery = $gallery; | ||
| 76 | } | ||
| 77 | |||
| 78 | public function set_post_type($post_type) { | ||
| 79 | $this->post_type = $post_type; | 82 | $this->post_type = $post_type; |
| 80 | } | 83 | } |
| 81 | 84 | ||
| 82 | public function set_settings($setting) { | 85 | /** |
| 83 | $this->settings[] = $settings; | 86 | * @param $setting |
| 84 | } | 87 | */ |
| 85 | 88 | public function set_settings($setting) | |
| 86 | protected function extractYouTubeVideoID($link = "") { | 89 | { |
| 87 | $parsed = @parse_url($link); | 90 | $this->settings[] = $setting; |
| 88 | if($parsed) { | ||
| 89 | if(isset($parsed['query'])) { | ||
| 90 | $querystring = $parsed['query']; | ||
| 91 | @parse_str($querystring, $output); | ||
| 92 | if( isset($output['v']) && strlen($output['v']) > 1 ) { | ||
| 93 | return $output['v']; | ||
| 94 | } else { | ||
| 95 | return false; | ||
| 96 | } | ||
| 97 | } else { | ||
| 98 | return false; | ||
| 99 | } | ||
| 100 | } else { | ||
| 101 | return false; | ||
| 102 | } | ||
| 103 | } | ||
| 104 | |||
| 105 | protected function url_exists($url='') { | ||
| 106 | // Version 4.x supported | ||
| 107 | $handle = curl_init($url); | ||
| 108 | if (false === $handle) { | ||
| 109 | return false; | ||
| 110 | } | ||
| 111 | curl_setopt($handle, CURLOPT_HEADER, false); | ||
| 112 | curl_setopt($handle, CURLOPT_FAILONERROR, true); // this works | ||
| 113 | curl_setopt($handle, CURLOPT_HTTPHEADER, Array("User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.15) Gecko/20080623 Firefox/2.0.0.15") ); // request as if Firefox | ||
| 114 | curl_setopt($handle, CURLOPT_NOBODY, true); | ||
| 115 | curl_setopt($handle, CURLOPT_RETURNTRANSFER, false); | ||
| 116 | $connectable = curl_exec($handle); | ||
| 117 | curl_close($handle); | ||
| 118 | return $connectable; | ||
| 119 | } | 91 | } |
| 120 | 92 | ||
| 121 | 93 | public function create_entry() | |
| 122 | 94 | { | |
| 123 | public function create_entry() { | ||
| 124 | |||
| 125 | |||
| 126 | $gallery = $this->get_gallery($this->gallery); | 95 | $gallery = $this->get_gallery($this->gallery); |
| 127 | 96 | ||
| 128 | $post = new hgPost(); | 97 | $post = new hgPost(); |
| ... | @@ -136,68 +105,82 @@ class Forms { | ... | @@ -136,68 +105,82 @@ class Forms { |
| 136 | $post->post_status = ($this->settings['image-approval'] == 'yes') ? 'pending' : 'publish'; | 105 | $post->post_status = ($this->settings['image-approval'] == 'yes') ? 'pending' : 'publish'; |
| 137 | 106 | ||
| 138 | // verified the link. | 107 | // verified the link. |
| 139 | if(isset($this->postdata['imageLinked']) && $this->postdata['imageLinked'] != "") { | 108 | if (isset($this->postdata['imageLinked']) && $this->postdata['imageLinked'] != "") { |
| 140 | if (!$this->url_exists($this->postdata['imageLinked'])) { | 109 | if (!$this->url_exists($this->postdata['imageLinked'])) { |
| 141 | die(json_encode(array('status'=>'error','details'=>"I'm sorry. We tried to find that image, but couldn't."))); | 110 | die(json_encode( |
| 111 | ['status' => 'error', 'details' => "I'm sorry. We tried to find that image, but couldn't."] | ||
| 112 | )); | ||
| 142 | } | 113 | } |
| 143 | } | 114 | } |
| 144 | 115 | ||
| 145 | $status = "verified"; | 116 | $status = "verified"; |
| 146 | 117 | ||
| 147 | $meta = array( | 118 | $meta = [ |
| 148 | 'gallery_type' => 'image' | 119 | 'gallery_type' => 'image', |
| 149 | , 'source' => (isset($this->postdata['imageLinked']) && $this->postdata['imageLinked'] != "") ? "linked" : "uploaded" | 120 | 'source' => (isset($this->postdata['imageLinked']) && $this->postdata['imageLinked'] != "") |
| 150 | , 'link' => (isset($this->postdata['imageLinked']) && $this->postdata['imageLinked'] != "") ? $this->postdata['imageLinked'] : $this->postdata['uploaded_image_filename'] | 121 | ? "linked" : "uploaded", |
| 151 | , 'views' => 0 | 122 | 'link' => (isset($this->postdata['imageLinked']) && $this->postdata['imageLinked'] != "") |
| 152 | , 'thumbnail' => '' | 123 | ? $this->postdata['imageLinked'] : $this->postdata['uploaded_image_filename'], |
| 153 | , 'tags' => '' | 124 | 'views' => 0, |
| 154 | , 'status' => $status | 125 | 'thumbnail' => '', |
| 155 | ); | 126 | 'tags' => '', |
| 156 | 127 | 'status' => $status | |
| 157 | if ($meta['source']=="uploaded") { | 128 | ]; |
| 129 | |||
| 130 | if ($meta['source'] == "uploaded") { | ||
| 158 | $post->post_status = "pending"; | 131 | $post->post_status = "pending"; |
| 159 | } | 132 | } |
| 160 | 133 | ||
| 161 | //$wpdb = $this->db; | 134 | //$wpdb = $this->db; |
| 162 | 135 | ||
| 163 | 136 | ||
| 164 | |||
| 165 | $post_id = wp_insert_post($post); | 137 | $post_id = wp_insert_post($post); |
| 166 | if($post_id < 1) { | 138 | if ($post_id < 1) { |
| 167 | die(json_encode(array('status'=>'error','details'=>"Could not create gallery post"))); | 139 | die(json_encode(['status' => 'error', 'details' => "Could not create gallery post"])); |
| 168 | } | 140 | } |
| 169 | 141 | ||
| 170 | $this->db->query("INSERT INTO `".$this->db->prefix."term_relationships` (`object_id`,`term_taxonomy_id`) VALUES ($post_id,".$gallery['term_id'].")"); | 142 | $this->db->query( |
| 171 | $this->db->query("UPDATE `".$this->db->prefix."term_taxonomy` SET `count`=(count+1) WHERE term_id=".$gallery['term_id']." LIMIT 1"); | 143 | "INSERT INTO `".$this->db->prefix."term_relationships` (`object_id`,`term_taxonomy_id`) VALUES ($post_id," |
| 144 | .$gallery['term_id'].")" | ||
| 145 | ); | ||
| 146 | $this->db->query( | ||
| 147 | "UPDATE `".$this->db->prefix."term_taxonomy` SET `count`=(count+1) WHERE term_id=".$gallery['term_id'] | ||
| 148 | ." LIMIT 1" | ||
| 149 | ); | ||
| 172 | 150 | ||
| 173 | add_post_meta($post_id,'_gallery_item_details',$meta); | 151 | add_post_meta($post_id, '_gallery_item_details', $meta); |
| 174 | 152 | ||
| 175 | die(json_encode(array('status'=>'success','details'=>"Thank you for sharing!"))); | 153 | die(json_encode(['status' => 'success', 'details' => "Thank you for sharing!"])); |
| 176 | 154 | ||
| 177 | 155 | ||
| 178 | } else { | 156 | } else { |
| 179 | $post->post_status = ($this->settings['video-approval'] == 'yes') ? 'pending' : 'publish'; | 157 | $post->post_status = ($this->settings['video-approval'] == 'yes') ? 'pending' : 'publish'; |
| 180 | 158 | ||
| 181 | if ( isset($this->postdata['videoLinked']) && $this->postdata['videoLinked'] != "") { | 159 | if (isset($this->postdata['videoLinked']) && $this->postdata['videoLinked'] != "") { |
| 182 | 160 | ||
| 183 | $videoID = $this->extractYouTubeVideoID($this->postdata['videoLinked']); | 161 | $videoID = $this->extractYouTubeVideoID($this->postdata['videoLinked']); |
| 184 | 162 | ||
| 185 | if($videoID) { | 163 | if ($videoID) { |
| 186 | // go out and grab the video data.... | 164 | // go out and grab the video data.... |
| 187 | $TzYouTubeConn = new Zend_Gdata_YouTube(); | 165 | $TzYouTubeConn = new Zend_Gdata_YouTube(); |
| 188 | $TzYouTubeConn->setMajorProtocolVersion(2); | 166 | $TzYouTubeConn->setMajorProtocolVersion(2); |
| 189 | try { | 167 | try { |
| 190 | $e = $TzYouTubeConn->getVideoEntry($videoID); | 168 | $e = $TzYouTubeConn->getVideoEntry($videoID); |
| 191 | $thumbnail = "http://i.ytimg.com/vi/".$videoID."/0.jpg"; | 169 | $thumbnail = "http://i.ytimg.com/vi/".$videoID."/0.jpg"; |
| 192 | $post->post_title = htmlspecialchars( mysql_real_escape_string($e->getVideoTitle()) ); | 170 | $post->post_title = htmlspecialchars(mysql_real_escape_string($e->getVideoTitle())); |
| 193 | $post->post_content = htmlspecialchars( mysql_real_escape_string($e->getVideoDescription() ) ); | 171 | $post->post_content = htmlspecialchars(mysql_real_escape_string($e->getVideoDescription())); |
| 194 | $status = "verified"; | 172 | $status = "verified"; |
| 195 | $msg = "Thank you for sharing."; | 173 | $msg = "Thank you for sharing."; |
| 196 | } catch (Exception $error) { | 174 | } catch (Exception $error) { |
| 197 | die(json_encode(array('status'=>'error','details'=>"I'm sorry. The video could not be verified with YouTube."))); | 175 | die(json_encode( |
| 176 | [ | ||
| 177 | 'status' => 'error', | ||
| 178 | 'details' => "I'm sorry. The video could not be verified with YouTube." | ||
| 179 | ] | ||
| 180 | )); | ||
| 198 | } | 181 | } |
| 199 | } else { | 182 | } else { |
| 200 | die(json_encode(array('status'=>'error','details'=>"That YouTube video url is invalid."))); | 183 | die(json_encode(['status' => 'error', 'details' => "That YouTube video url is invalid."])); |
| 201 | } | 184 | } |
| 202 | 185 | ||
| 203 | } else { | 186 | } else { |
| ... | @@ -209,44 +192,145 @@ class Forms { | ... | @@ -209,44 +192,145 @@ class Forms { |
| 209 | } | 192 | } |
| 210 | 193 | ||
| 211 | 194 | ||
| 212 | $meta = array( | 195 | $meta = [ |
| 213 | 'gallery_type' => 'video' | 196 | 'gallery_type' => 'video', |
| 214 | , 'source' => (isset($this->postdata['videoLinked']) && $this->postdata['videoLinked'] != "") ? "linked" : "uploaded" | 197 | 'source' => (isset($this->postdata['videoLinked']) && $this->postdata['videoLinked'] != "") |
| 215 | , 'link' => (isset($this->postdata['videoLinked']) && $this->postdata['videoLinked'] != "") ? $this->postdata['videoLinked'] : $this->postdata['uploaded_video_filename'] | 198 | ? "linked" : "uploaded", |
| 216 | , 'views' => 0 | 199 | 'link' => (isset($this->postdata['videoLinked']) && $this->postdata['videoLinked'] != "") |
| 217 | , 'thumbnail' => $thumbnail | 200 | ? $this->postdata['videoLinked'] : $this->postdata['uploaded_video_filename'], |
| 218 | , 'tags' => '' | 201 | 'views' => 0, |
| 219 | , 'status' => $status | 202 | 'thumbnail' => $thumbnail, |
| 220 | ); | 203 | 'tags' => '', |
| 204 | 'status' => $status | ||
| 205 | ]; | ||
| 221 | 206 | ||
| 222 | $post_id = wp_insert_post($post); | 207 | $post_id = wp_insert_post($post); |
| 223 | $this->db->query("INSERT INTO `".$this->db->prefix."term_relationships` (`object_id`,`term_taxonomy_id`) VALUES ($post_id,".$gallery['term_id'].")"); | 208 | $this->db->query( |
| 224 | $this->db->query("UPDATE `".$this->db->prefix."term_taxonomy` SET `count`=(count+1) WHERE term_id=".$gallery['term_id']." LIMIT 1"); | 209 | "INSERT INTO `".$this->db->prefix."term_relationships` (`object_id`,`term_taxonomy_id`) VALUES ($post_id," |
| 210 | .$gallery['term_id'].")" | ||
| 211 | ); | ||
| 212 | $this->db->query( | ||
| 213 | "UPDATE `".$this->db->prefix."term_taxonomy` SET `count`=(count+1) WHERE term_id=".$gallery['term_id'] | ||
| 214 | ." LIMIT 1" | ||
| 215 | ); | ||
| 225 | 216 | ||
| 226 | add_post_meta($post_id,'_gallery_item_details',$meta); | 217 | add_post_meta($post_id, '_gallery_item_details', $meta); |
| 227 | die(json_encode(array('status'=>'success','details'=>$msg))); | 218 | die(json_encode(['status' => 'success', 'details' => $msg])); |
| 219 | } | ||
| 228 | } | 220 | } |
| 229 | 221 | ||
| 222 | /** | ||
| 223 | * @param string $slug | ||
| 224 | * | ||
| 225 | * @return mixed | ||
| 226 | */ | ||
| 227 | public function get_gallery($slug = '') | ||
| 228 | { | ||
| 229 | $result = $this->db->get_row( | ||
| 230 | "SELECT t.term_id,t.name, tt.description FROM `".$this->db->prefix."terms` AS t, `".$this->db->prefix | ||
| 231 | ."term_taxonomy` as tt WHERE tt.term_id=t.term_id AND t.slug='$slug' LIMIT 1", | ||
| 232 | 'ARRAY_A' | ||
| 233 | ); | ||
| 230 | 234 | ||
| 235 | return $result; | ||
| 236 | } | ||
| 231 | 237 | ||
| 238 | /** | ||
| 239 | * @param $gallery | ||
| 240 | */ | ||
| 241 | public function set_gallery($gallery) | ||
| 242 | { | ||
| 243 | $this->gallery = $gallery; | ||
| 232 | } | 244 | } |
| 233 | 245 | ||
| 234 | public function get_gallery($slug = '') { | 246 | protected function getRealIpAddr() |
| 235 | $result = $this->db->get_row("SELECT t.term_id,t.name, tt.description FROM `".$this->db->prefix."terms` AS t, `".$this->db->prefix."term_taxonomy` as tt WHERE tt.term_id=t.term_id AND t.slug='$slug' LIMIT 1",'ARRAY_A'); | 247 | { |
| 236 | return $result; | 248 | if (!empty($_SERVER['HTTP_CLIENT_IP'])) //check ip from share internet |
| 249 | { | ||
| 250 | $ip = $_SERVER['HTTP_CLIENT_IP']; | ||
| 251 | } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to check ip is pass from proxy | ||
| 252 | { | ||
| 253 | $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; | ||
| 254 | } else { | ||
| 255 | $ip = $_SERVER['REMOTE_ADDR']; | ||
| 256 | } | ||
| 257 | |||
| 258 | return $ip; | ||
| 259 | } | ||
| 260 | |||
| 261 | /** | ||
| 262 | * @param string $link | ||
| 263 | * | ||
| 264 | * @return bool | ||
| 265 | */ | ||
| 266 | protected function extractYouTubeVideoID($link = "") | ||
| 267 | { | ||
| 268 | $parsed = @parse_url($link); | ||
| 269 | if ($parsed) { | ||
| 270 | if (isset($parsed['query'])) { | ||
| 271 | $querystring = $parsed['query']; | ||
| 272 | @parse_str($querystring, $output); | ||
| 273 | if (isset($output['v']) && strlen($output['v']) > 1) { | ||
| 274 | return $output['v']; | ||
| 275 | } else { | ||
| 276 | return false; | ||
| 277 | } | ||
| 278 | } else { | ||
| 279 | return false; | ||
| 280 | } | ||
| 281 | } else { | ||
| 282 | return false; | ||
| 283 | } | ||
| 237 | } | 284 | } |
| 238 | 285 | ||
| 239 | protected function _sanitize_data($data = array()) { | 286 | /** |
| 240 | $tempdata = array(); | 287 | * @param string $url |
| 241 | foreach($data as $option => $value) { | 288 | * |
| 289 | * @return mixed | ||
| 290 | */ | ||
| 291 | protected function url_exists($url = '') | ||
| 292 | { | ||
| 293 | // Version 4.x supported | ||
| 294 | $handle = curl_init($url); | ||
| 295 | if (false === $handle) { | ||
| 296 | return false; | ||
| 297 | } | ||
| 298 | curl_setopt($handle, CURLOPT_HEADER, false); | ||
| 299 | curl_setopt($handle, CURLOPT_FAILONERROR, true); // this works | ||
| 300 | curl_setopt( | ||
| 301 | $handle, | ||
| 302 | CURLOPT_HTTPHEADER, | ||
| 303 | ["User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.15) Gecko/20080623 Firefox/2.0.0.15"] | ||
| 304 | ); // request as if Firefox | ||
| 305 | curl_setopt($handle, CURLOPT_NOBODY, true); | ||
| 306 | curl_setopt($handle, CURLOPT_RETURNTRANSFER, false); | ||
| 307 | $connectable = curl_exec($handle); | ||
| 308 | curl_close($handle); | ||
| 309 | |||
| 310 | return $connectable; | ||
| 311 | } | ||
| 312 | |||
| 313 | /** | ||
| 314 | * @param array $data | ||
| 315 | * | ||
| 316 | * @return array | ||
| 317 | */ | ||
| 318 | protected function _sanitize_data($data = []) | ||
| 319 | { | ||
| 320 | $tempdata = []; | ||
| 321 | foreach ($data as $option => $value) { | ||
| 242 | $tempdata[$option] = mysql_escape_string($value); | 322 | $tempdata[$option] = mysql_escape_string($value); |
| 243 | } | 323 | } |
| 324 | |||
| 244 | return $tempdata; | 325 | return $tempdata; |
| 245 | } | 326 | } |
| 246 | |||
| 247 | } | 327 | } |
| 248 | 328 | ||
| 249 | class hgPost { | 329 | /** |
| 330 | * Class hgPost | ||
| 331 | */ | ||
| 332 | class hgPost | ||
| 333 | { | ||
| 250 | var $post_title = ''; | 334 | var $post_title = ''; |
| 251 | var $post_content = ''; | 335 | var $post_content = ''; |
| 252 | var $post_status = 'publish'; | 336 | var $post_status = 'publish'; |
| ... | @@ -257,7 +341,7 @@ class hgPost { | ... | @@ -257,7 +341,7 @@ class hgPost { |
| 257 | $current_user = null; | 341 | $current_user = null; |
| 258 | get_currentuserinfo(); | 342 | get_currentuserinfo(); |
| 259 | 343 | ||
| 260 | $form = new Forms($wpdb,$current_user); | 344 | $form = new Forms($wpdb, $current_user); |
| 261 | 345 | ||
| 262 | $form->set_form($_POST['form_type']); | 346 | $form->set_form($_POST['form_type']); |
| 263 | $form->set_gallery($_POST['gallery']); | 347 | $form->set_gallery($_POST['gallery']); |
| ... | @@ -265,5 +349,3 @@ $form->set_data($_POST); | ... | @@ -265,5 +349,3 @@ $form->set_data($_POST); |
| 265 | $form->set_post_type('gallery'); | 349 | $form->set_post_type('gallery'); |
| 266 | $form->set_approval($_POST['approval']); | 350 | $form->set_approval($_POST['approval']); |
| 267 | $form->create_entry(); | 351 | $form->create_entry(); |
| 268 | |||
| 269 | ?> | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -7,8 +7,6 @@ const CAPABILITY = 'edit_user_details'; | ... | @@ -7,8 +7,6 @@ const CAPABILITY = 'edit_user_details'; |
| 7 | const HTML_NS = 'tzud-'; | 7 | const HTML_NS = 'tzud-'; |
| 8 | 8 | ||
| 9 | call_user_func(function() { | 9 | call_user_func(function() { |
| 10 | Tz\import('Tz', 'trunk'); | ||
| 11 | |||
| 12 | $role = get_role('administrator'); | 10 | $role = get_role('administrator'); |
| 13 | $role->add_cap(CAPABILITY); | 11 | $role->add_cap(CAPABILITY); |
| 14 | 12 | ... | ... |
-
Please register or sign in to post a comment