Changeset 5465 for extensions/Random_Header
- Timestamp:
- Mar 30, 2010, 12:19:14 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/Random_Header/main.inc.php
r4538 r5465 1 <?php1 <?php 2 2 /* 3 3 Plugin Name: Random Header 4 Version: 2.0. b4 Version: 2.0.c 5 5 Description: Random Header allow you to show in the header a random picture from the choosen categorie, as a normal image, or as a background 6 6 Plugin URI: http://phpwebgallery.net/ext/extension_view.php?eid=188 … … 12 12 DEFINE('RH_VERSION','v2.0.b'); 13 13 define('RH_PATH' , PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/'); 14 15 function get_file_contents($url, $totalTries = 5) 16 { 17 $Tries = 0; 18 do 19 { 20 if ($Tries > 0) sleep(1); # Wait for a sec before retrieving again 21 $contents = @file_get_contents($url); 22 $Tries++; 23 } while ($Tries <= $totalTries && $contents === FALSE); 24 if ($contents == "") $contents = FALSE; 25 return $contents; 26 } 27 14 28 class RandomHeader 15 29 { 16 30 var $rh_config; 17 function load_config() 31 32 function load_config() 18 33 { 19 $x = @file_get_contents( dirname(__FILE__).'/data.dat' ); 34 $x = get_file_contents( dirname(__FILE__).'/data.dat' ); 35 20 36 if ($x!==false) 21 37 $this->rh_config = unserialize($x); 22 38 23 39 foreach (str_replace(" ", "_", get_pwg_themes()) as $pwg_template) { 24 40 if (empty($this->rh_config[$pwg_template]['selected_cat'])) { 25 41 26 42 $this->rh_config[$pwg_template]['selected_cat'] = '0'; 27 43 $this->rh_config[$pwg_template]['active_on_picture']='off'; … … 29 45 $this->rh_config[$pwg_template]['img_css']=''; 30 46 $this->rh_config[$pwg_template]['mode_background']='off'; 31 $this->rh_config[$pwg_template]['concat_before'] ='off' ; 32 $this->rh_config[$pwg_template]['concat_after'] ='off' ; 47 $this->rh_config[$pwg_template]['concat_before'] ='off' ; 48 $this->rh_config[$pwg_template]['concat_after'] ='off' ; 33 49 34 50 $this->save_config(); 35 51 } 36 52 } 37 53 38 54 } 39 55 function save_config() … … 60 76 $usertheme=str_replace(" ", "_", $user['template'].'/'.$user['theme'] ); 61 77 if ( !defined('IN_ADMIN') && isset($page['body_id']) && ($page['body_id']!='thePicturePage' || $this->rh_config[$usertheme]['active_on_picture']=='on') ) { 62 78 63 79 $result = pwg_query('SELECT '.IMAGES_TABLE.'.path FROM '.IMAGES_TABLE.' , '.IMAGE_CATEGORY_TABLE.' WHERE '.IMAGES_TABLE.'.`id` = '.IMAGE_CATEGORY_TABLE.'.`image_id` AND '.IMAGE_CATEGORY_TABLE.'.category_id = ' . $this->rh_config[$usertheme]['selected_cat'] . ' ORDER BY RAND() LIMIT 0,1'); 64 80 if (mysql_num_rows($result) > 0) { 65 81 $toto = mysql_fetch_row($result); 66 82 67 83 if ($this->rh_config[$usertheme]['mode_background']=='on') { 68 $template->append('head_elements','<style type="text/css">#theHeader{background: url('.$toto[0].') no-repeat;'. $this->rh_config[$usertheme]['head_css'] .'}</style>');84 $template->append('head_elements','<style>#theHeader{background: url('.$toto[0].') no-repeat;'. $this->rh_config[$usertheme]['head_css'] .'}</style>'); 69 85 } 70 86 else { 71 if ($this->rh_config[$usertheme]['img_css']!='' || $this->rh_config[$usertheme]['head_css']!='') 72 $template->append('head_elements','<style type="text/css">#theHeader{'. $this->rh_config[$usertheme]['head_css'] .'}#theHeader #RandomImage{'. $this->rh_config[$usertheme]['img_css'] .'}</style>');73 $page['page_banner'] = ($this->rh_config[$usertheme]['concat_before']=='on') ? $conf['page_banner'] : ''; 87 if ($this->rh_config[$usertheme]['img_css']!='' || $this->rh_config[$usertheme]['head_css']!='') 88 $template->append('head_elements','<style>#theHeader{'. $this->rh_config[$usertheme]['head_css'] .'}#theHeader #RandomImage{'. $this->rh_config[$usertheme]['img_css'] .'}</style>'); 89 $page['page_banner'] = ($this->rh_config[$usertheme]['concat_before']=='on') ? $conf['page_banner'] : ''; 74 90 $page['page_banner'].= '<img id="RandomImage" src="'.$toto[0].'">'; 75 $page['page_banner'].= ($this->rh_config[$usertheme]['concat_after']=='on') ? $conf['page_banner'] : ''; 91 $page['page_banner'].= ($this->rh_config[$usertheme]['concat_after']=='on') ? $conf['page_banner'] : ''; 76 92 } 77 93 }
Note: See TracChangeset
for help on using the changeset viewer.