Changeset 17661 for extensions
- Timestamp:
- Aug 29, 2012, 6:00:39 PM (12 years ago)
- Location:
- extensions/gvideo
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/gvideo/include/functions.inc.php
r17488 r17661 239 239 curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept-language: en")); 240 240 curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)'); 241 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); 242 curl_setopt($ch, CURLOPT_MAXREDIRS, 1); 241 if (!ini_get('safe_mode')) 242 { 243 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); 244 curl_setopt($ch, CURLOPT_MAXREDIRS, 1); 245 } 243 246 if (strpos($src, 'https://') !== false) 244 247 { -
extensions/gvideo/main.inc.php
r17626 r17661 13 13 global $prefixeTable; 14 14 15 define('GVIDEO_PATH', PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/'); 16 define('GVIDEO_ADMIN', get_root_url() . 'admin.php?page=plugin-' . basename(dirname(__FILE__))); 17 define('GVIDEO_TABLE', $prefixeTable.'image_video'); 15 define('GVIDEO_PATH', PHPWG_PLUGINS_PATH . 'gvideo/'); 16 define('GVIDEO_ADMIN', get_root_url() . 'admin.php?page=plugin-gvideo'); 17 define('GVIDEO_TABLE', $prefixeTable.'image_video'); 18 define('GVIDEO_VERSION', '2.4.c'); 18 19 19 include(GVIDEO_PATH . 'include/gvideo.inc.php');20 20 21 add_event_handler('init', 'gvideo_init'); 21 22 add_event_handler('render_element_content', 'gvideo_element_content', EVENT_HANDLER_PRIORITY_NEUTRAL-10, 2); 22 23 … … 26 27 add_event_handler('get_admin_plugin_menu_links', 'gvideo_admin_menu'); 27 28 add_event_handler('tabsheet_before_select','gvideo_tab', EVENT_HANDLER_PRIORITY_NEUTRAL+10, 2); 28 add_event_handler('init', 'gvideo_init'); 29 } 30 31 include_once(GVIDEO_PATH . 'include/gvideo.inc.php'); 32 33 34 /** 35 * update & load language 36 */ 37 function gvideo_init() 38 { 39 global $pwg_loaded_plugins; 29 40 30 function gvideo_init() 41 if ( 42 $pwg_loaded_plugins['gvideo']['version'] == 'auto' or 43 version_compare($pwg_loaded_plugins['gvideo']['version'], GVIDEO_VERSION, '<') 44 ) 31 45 { 32 load_language('plugin.lang', GVIDEO_PATH); 33 } 34 35 function gvideo_admin_menu($menu) 36 { 37 array_push($menu, array( 38 'NAME' => 'Embedded Videos', 39 'URL' => GVIDEO_ADMIN, 40 )); 41 return $menu; 46 include_once(GVIDEO_PATH . 'include/install.inc.php'); 47 gvideo_install(); 48 49 if ($pwg_loaded_plugins['gvideo']['version'] != 'auto') 50 { 51 $query = ' 52 UPDATE '. PLUGINS_TABLE .' 53 SET version = "'. GVIDEO_VERSION .'" 54 WHERE id = "gvideo"'; 55 pwg_query($query); 56 57 $pwg_loaded_plugins['gvideo']['version'] = GVIDEO_VERSION; 58 59 if (defined('IN_ADMIN')) 60 { 61 $_SESSION['page_infos'][] = 'Embedded Videos updated to version '. GVIDEO_VERSION; 62 } 63 } 42 64 } 43 65 44 function gvideo_tab($sheets, $id) 45 { 46 if ($id != 'photo') return $sheets; 47 48 $query = ' 66 load_language('plugin.lang', GVIDEO_PATH); 67 } 68 69 /** 70 * admin plugins menu 71 */ 72 function gvideo_admin_menu($menu) 73 { 74 array_push($menu, array( 75 'NAME' => 'Embedded Videos', 76 'URL' => GVIDEO_ADMIN, 77 )); 78 return $menu; 79 } 80 81 /** 82 * special tabs 83 */ 84 function gvideo_tab($sheets, $id) 85 { 86 if ($id != 'photo') return $sheets; 87 88 $query = ' 49 89 SELECT * 50 90 FROM '.GVIDEO_TABLE.' 51 91 WHERE picture_id = '.$_GET['image_id'].' 52 92 ;'; 53 $result = pwg_query($query); 93 $result = pwg_query($query); 94 95 if (!pwg_db_num_rows($result)) return $sheets; 54 96 55 if (!pwg_db_num_rows($result)) return $sheets; 56 57 global $gvideo; 58 $gvideo = pwg_db_fetch_assoc($result); 59 60 $sheets['gvideo'] = array( 61 'caption' => l10n('Video properties'), 62 'url' => GVIDEO_ADMIN.'-photo&image_id='.$_GET['image_id'], 63 ); 64 unset($sheets['coi'], $sheets['update']); 65 66 return $sheets; 67 } 97 global $gvideo; 98 $gvideo = pwg_db_fetch_assoc($result); 99 100 $sheets['gvideo'] = array( 101 'caption' => l10n('Video properties'), 102 'url' => GVIDEO_ADMIN.'-photo&image_id='.$_GET['image_id'], 103 ); 104 unset($sheets['coi'], $sheets['update']); 105 106 return $sheets; 68 107 } 69 108 -
extensions/gvideo/maintain.inc.php
r17490 r17661 2 2 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 3 3 4 global $prefixeTable; 5 6 define('gvideo_path', PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/'); 7 define('gvideo_table', $prefixeTable.'image_video'); 8 9 define( 10 'gvideo_default_config', 11 serialize(array( 12 'autoplay' => 0, 13 'width' => 640, 14 'height' => 360, 15 'vimeo' => array( 16 'title' => 1, 17 'portrait' => 1, 18 'byline' => 1, 19 'color' => '00adef', 20 ), 21 'dailymotion' => array( 22 'logo' => 1, 23 'title' => 1, 24 'color' => 'F7FFFD', 25 ), 26 'youtube' => array(), 27 'wat' => array(), 28 'wideo' => array(), 29 'videobb' => array(), 30 )) 31 ); 4 include_once(PHPWG_PLUGINS_PATH . 'gvideo/include/install.inc.php'); 32 5 33 6 /* install */ 34 7 function plugin_install() 35 8 { 36 g lobal $conf;9 gvideo_install(); 37 10 38 conf_update_param('gvideo', gvideo_default_config); 39 40 $query = ' 41 CREATE TABLE IF NOT EXISTS `'.gvideo_table.'` ( 42 `picture_id` mediumint(8) NOT NULL, 43 `url` varchar(255) DEFAULT NULL, 44 `type` varchar(64) NOT NULL, 45 `video_id` varchar(64) NOT NULL, 46 `width` smallint(9) DEFAULT NULL, 47 `height` smallint(9) DEFAULT NULL, 48 `autoplay` tinyint(1) DEFAULT NULL 49 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 50 ;'; 51 pwg_query($query); 52 53 pwg_query('ALTER TABLE `' . IMAGES_TABLE . '` ADD `is_gvideo` TINYINT(1) NOT NULL DEFAULT 0;'); 54 55 if (isset($conf['PY_GVideo'])) 56 { 57 pwg_query('DELETE FROM `'. CONFIG_TABLE .'` WHERE param = "PY_GVideo" LIMIT 1;'); 58 unset($conf['PY_GVideo']); 59 60 gvideo_update_24(); 61 } 11 define('gvideo_installed', true); 62 12 } 63 13 … … 65 15 function plugin_activate() 66 16 { 67 global $conf; 68 69 if (isset($conf['PY_GVideo'])) 17 if (!defined('gvideo_installed')) 70 18 { 71 plugin_install(); 72 } 73 else 74 { 75 if (!isset($conf['gvideo'])) 76 { 77 conf_update_param('gvideo', gvideo_default_config); 78 } 79 80 $result = pwg_query('SHOW COLUMNS FROM '.gvideo_table.' LIKE "url";'); 81 if (!pwg_db_num_rows($result)) 82 { 83 pwg_query('ALTER TABLE '.gvideo_table.' ADD `url` VARCHAR(255) DEFAULT NULL;'); 84 } 85 86 $result = pwg_query('SHOW COLUMNS FROM '.IMAGES_TABLE.' LIKE "is_gvideo";'); 87 if (!pwg_db_num_rows($result)) 88 { 89 pwg_query('ALTER TABLE `' . IMAGES_TABLE . '` ADD `is_gvideo` TINYINT(1) NOT NULL DEFAULT 0;'); 90 91 $query = ' 92 UPDATE '.IMAGES_TABLE.' 93 SET is_gvideo = 1 94 WHERE id IN( 95 SELECT picture_id FROM '.gvideo_table.' 96 ) 97 ;'; 98 pwg_query($query); 99 } 19 gvideo_install(); 100 20 } 101 21 } … … 103 23 /* uninstall */ 104 24 function plugin_uninstall() 105 { 25 { 26 global $prefixeTable; 27 106 28 pwg_query('DELETE FROM `'. CONFIG_TABLE .'` WHERE param = "gvideo" LIMIT 1;'); 107 pwg_query('DROP TABLE `'. gvideo_table.'`;');29 pwg_query('DROP TABLE `'.$prefixeTable.'image_video`;'); 108 30 pwg_query('ALTER TABLE `' . IMAGES_TABLE . '` DROP `is_gvideo`;'); 109 31 } 110 32 111 112 /**113 * update from 2.3 to 2.4114 */115 function gvideo_update_24()116 {117 global $conf;118 119 // search existing videos120 $query = '121 SELECT *122 FROM '.IMAGES_TABLE.'123 WHERE124 file LIKE "%.gvideo"125 OR file LIKE "%.dm"126 OR file LIKE "%.ytube"127 OR file LIKE "%.wideo"128 OR file LIKE "%.vimeo"129 OR file LIKE "%.wat"130 ;';131 $result = pwg_query($query);132 133 if (!pwg_db_num_rows($result))134 {135 return;136 }137 138 if (!isset($conf['prefix_thumbnail']))139 {140 $conf['prefix_thumbnail'] = 'TN-';141 }142 143 if (!isset($conf['dir_thumbnail']))144 {145 $conf['dir_thumbnail'] = 'thumbnail';146 }147 148 set_time_limit(600);149 include_once(gvideo_path . '/include/functions.inc.php');150 include_once(PHPWG_ROOT_PATH . 'admin/include/functions_upload.inc.php');151 152 $videos_inserts = array();153 $images_updates = array();154 $images_delete = array();155 156 while ($img = pwg_db_fetch_assoc($result))157 {158 $file_content = file_get_contents($img['path']);159 list($file['id'], $file['height'], $file['width'], ) = explode('/', $file_content);160 $file['type'] = get_extension($img['path']);161 162 switch ($file['type'])163 {164 case 'vimeo':165 $video = array(166 'type' => 'vimeo',167 'url' => 'http://vimeo.com/'.$file['id'],168 );169 break;170 case 'dm':171 $video = array(172 'type' => 'dailymotion',173 'url' => 'http://dailymotion.com/video/'.$file['id'],174 );175 break;176 case 'ytube':177 $video = array(178 'type' => 'youtube',179 'url' => 'http://youtube.com/watch?v='.$file['id'],180 );181 break;182 case 'wideo':183 $video = array(184 'type' => 'wideo',185 'url' => 'http://wideo.fr/video/'.$file['id'].'.html',186 );187 break;188 case 'wat':189 $video = array(190 'type' => 'wat',191 'url' => null,192 );193 break;194 case 'gvideo': // closed195 default:196 array_push($images_delete, $img['id']);197 continue;198 }199 200 $real_path = str_replace($img['file'], null, str_replace('././', './', $img['path']));201 202 // get existing thumbnail203 $thumb = $real_path.$conf['dir_thumbnail'].'/'.$conf['prefix_thumbnail'].get_filename_wo_extension($img['file']).'.*';204 $thumb = glob($thumb);205 if (!empty($thumb))206 {207 $thumb_name = $video['type'].'-'.$file['id'].'-'.uniqid().'.'.get_extension($thumb[0]);208 $thumb_source = $conf['data_location'].$thumb_name;209 copy($thumb[0], $thumb_source);210 }211 else212 {213 $thumb_name = $video['type'].'-'.$file['id'].'-'.uniqid().'.jpg';214 $thumb_source = $conf['data_location'].$thumb_name;215 copy(gvideo_path.'mimetypes/'.$video['type'].'.jpg', $thumb_source);216 add_film_frame($thumb_source);217 }218 219 // update element220 $image_id = add_uploaded_file($thumb_source, $thumb_name, null, null, $img['id']);221 222 // update path and rename the file223 $img['new_path'] = $real_path.$thumb_name;224 rename($img['path'], $img['new_path']);225 array_push($images_updates, array(226 'id' => $img['id'],227 'path' => $img['new_path'],228 'is_gvideo' => 1,229 ));230 231 if (empty($file['width'])) $file['width'] = '';232 if (empty($file['height'])) $file['height'] = '';233 234 // register video235 array_push($videos_inserts, array(236 'picture_id' => $image_id,237 'url' => $video['url'],238 'type' => $video['type'],239 'video_id' => $file['id'],240 'width' => $file['width'],241 'height' => $file['height'],242 'autoplay' => '',243 ));244 245 unset($thumb_source, $thumb_name, $file, $video, $url);246 }247 248 // delete obsolete elements249 delete_elements($images_delete);250 251 // registers videos252 mass_inserts(253 gvideo_table,254 array('picture_id', 'url', 'type', 'video_id', 'width', 'height', 'autoplay'),255 $videos_inserts256 );257 258 // update images259 mass_updates(260 IMAGES_TABLE,261 array('primary'=>array('id'), 'update'=>array('path', 'is_gvideo')),262 $images_updates263 );264 }265 266 33 ?>
Note: See TracChangeset
for help on using the changeset viewer.