Changeset 3697 for extensions/gvideo/admin
- Timestamp:
- Jul 29, 2009, 9:15:06 PM (15 years ago)
- Location:
- extensions/gvideo/admin
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/gvideo/admin/add_page.php
r3609 r3697 3 3 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 4 4 5 $video_types = array('google', 'youtube', 'dailymotion', 'wideo', 'vimeo' );5 $video_types = array('google', 'youtube', 'dailymotion', 'wideo', 'vimeo', 'wat'); 6 6 7 7 function get_video_infos($url, $type) … … 68 68 return $video; 69 69 70 case "wat": 71 if (fetchRemote($url, $source)) 72 { 73 @preg_match('#link rel="video_src" href="http://www.wat.tv/swf2/(.*?)"#i', $source, $id); 74 if (empty($id[1])) return false; 75 $video['id'] = $id[1]; 76 $video['ext'] = 'wat'; 77 if ($_POST['thumbnail'] == 'thumb_from_server') 78 { 79 @preg_match('#link rel="image_src" href="(.*?)"#', $source, $matches); 80 $video['thumb_url'] = @str_replace('120x90', '320x240', $matches[1]); 81 } 82 return $video; 83 } 84 70 85 default: 71 86 return false; 72 }73 }74 75 /* MUST BE REMOVED WITH PIWIGO 2.0.0 */76 if (!function_exists('fetchRemote'))77 {78 function fetchRemote($src, &$dest, $user_agent='Piwigo', $step=0)79 {80 // After 3 redirections, return false81 if ($step > 3) return false;82 83 // Initialize $dest84 is_resource($dest) or $dest = '';85 86 // Try curl to read remote file87 if (function_exists('curl_init'))88 {89 $ch = @curl_init();90 @curl_setopt($ch, CURLOPT_URL, $src);91 @curl_setopt($ch, CURLOPT_HEADER, 1);92 @curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);93 @curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);94 $content = @curl_exec($ch);95 $header_length = @curl_getinfo($ch, CURLINFO_HEADER_SIZE);96 $status = @curl_getinfo($ch, CURLINFO_HTTP_CODE);97 @curl_close($ch);98 if ($content !== false and $status >= 200 and $status < 400)99 {100 if (preg_match('/Location:\s+?(.+)/', substr($content, 0, $header_length), $m))101 {102 return fetchRemote($m[1], $dest, $user_agent, $step+1);103 }104 $content = substr($content, $header_length);105 is_resource($dest) ? @fwrite($dest, $content) : $dest = $content;106 return true;107 }108 }109 110 // Try file_get_contents to read remote file111 if (ini_get('allow_url_fopen'))112 {113 $content = @file_get_contents($src);114 if ($content !== false)115 {116 is_resource($dest) ? @fwrite($dest, $content) : $dest = $content;117 return true;118 }119 }120 121 // Try fsockopen to read remote file122 $src = parse_url($src);123 $host = $src['host'];124 $path = isset($src['path']) ? $src['path'] : '/';125 $path .= isset($src['query']) ? '?'.$src['query'] : '';126 127 if (($s = @fsockopen($host,80,$errno,$errstr,5)) === false)128 {129 return false;130 }131 132 fwrite($s,133 "GET ".$path." HTTP/1.0\r\n"134 ."Host: ".$host."\r\n"135 ."User-Agent: ".$user_agent."\r\n"136 ."Accept: */*\r\n"137 ."\r\n"138 );139 140 $i = 0;141 $in_content = false;142 while (!feof($s))143 {144 $line = fgets($s);145 146 if (rtrim($line,"\r\n") == '' && !$in_content)147 {148 $in_content = true;149 $i++;150 continue;151 }152 if ($i == 0)153 {154 if (!preg_match('/HTTP\/(\\d\\.\\d)\\s*(\\d+)\\s*(.*)/',rtrim($line,"\r\n"), $m))155 {156 fclose($s);157 return false;158 }159 $status = (integer) $m[2];160 if ($status < 200 || $status >= 400)161 {162 fclose($s);163 return false;164 }165 }166 if (!$in_content)167 {168 if (preg_match('/Location:\s+?(.+)$/',rtrim($line,"\r\n"),$m))169 {170 fclose($s);171 return fetchRemote(trim($m[1]),$dest,$user_agent,$step+1);172 }173 $i++;174 continue;175 }176 is_resource($dest) ? @fwrite($dest, $line) : $dest .= $line;177 $i++;178 }179 fclose($s);180 return true;181 87 } 182 88 } -
extensions/gvideo/admin/config.php
r3609 r3697 30 30 $_POST['pywaie_vimeo_h'], 31 31 $_POST['pywaie_vimeo_w'], 32 $_POST['pywaie_vimeo_autoplay']) 32 $_POST['pywaie_vimeo_autoplay']), 33 'wat' => array( 34 $_POST['pywaie_wat_h'], 35 $_POST['pywaie_wat_w'], 36 $_POST['pywaie_wat_autoplay']) 33 37 ); 34 38 … … 54 58 'PYWAIE_WIDEO_W' => $params['wideo'][1], 55 59 'PYWAIE_VIMEO_H' => $params['vimeo'][0], 56 'PYWAIE_VIMEO_W' => $params['vimeo'][1])); 60 'PYWAIE_VIMEO_W' => $params['vimeo'][1], 61 'PYWAIE_WAT_H' => $params['wat'][0], 62 'PYWAIE_WAT_W' => $params['wat'][1])); 57 63 58 64 if ($params['gvideo'][2] == 'true') … … 96 102 $template->assign(array('PYWAIE_VIMEO_AUTOPLAY_FALSE' => 'checked="checked"')); 97 103 } 104 if ($params['wat'][2] == 'true') 105 { 106 $template->assign(array('PYWAIE_WAT_AUTOPLAY_TRUE' => 'checked="checked"')); 107 } 108 else 109 { 110 $template->assign(array('PYWAIE_WAT_AUTOPLAY_FALSE' => 'checked="checked"')); 111 } 98 112 99 113 $template->set_filenames(array('plugin_admin_content' => dirname(__FILE__) . '/config.tpl')); -
extensions/gvideo/admin/config.tpl
r3609 r3697 134 134 </table> 135 135 </fieldset> </td> 136 </table> 136 137 <td><fieldset> 138 <legend>Wat</legend> 139 <table> 140 <tr> 141 <td>{'py_width'|@translate}</td> 142 <td> 143 <input type="text" size="3" maxlength="3" value="{$PYWAIE_WAT_W}" name="pywaie_wat_w" /></td> 144 </tr> 145 <tr> 146 <td>{'py_height'|@translate}</td> 147 <td> 148 <input type="text" size="3" maxlength="3" value="{$PYWAIE_WAT_H}" name="pywaie_wat_h" /></td> 149 </tr> 150 <tr> 151 <td>{'py_autostart'|@translate}</td> 152 <td> 153 <input type="radio" value="true" name="pywaie_wat_autoplay" {$PYWAIE_WAT_AUTOPLAY_TRUE} /> 154 On 155 <input type="radio" value="false" name="pywaie_wat_autoplay" {$PYWAIE_WAT_AUTOPLAY_FALSE} /> 156 Off </td> 157 </tr> 158 </table> 159 </fieldset> </td> 160 161 </table> 137 162 <div align="center"> 138 163 <input class="submit" type="submit" value="{'Submit'|@translate}" name="submit" /></div>
Note: See TracChangeset
for help on using the changeset viewer.