[10264] | 1 | <?php |
---|
| 2 | /* ----------------------------------------------------------------------------- |
---|
| 3 | Plugin : AStat.2 |
---|
| 4 | Author : Grum |
---|
| 5 | email : grum@piwigo.org |
---|
| 6 | website : http://photos.grum.fr |
---|
| 7 | |
---|
| 8 | << May the Little SpaceFrog be with you ! >> |
---|
| 9 | ------------------------------------------------------------------------------ |
---|
| 10 | See main.inc.php for release information |
---|
| 11 | |
---|
| 12 | AStat_install classe => manage install process |
---|
| 13 | |
---|
| 14 | --------------------------------------------------------------------------- */ |
---|
| 15 | |
---|
| 16 | if (!defined('PHPWG_ROOT_PATH')) { die('Hacking attempt!'); } |
---|
| 17 | |
---|
| 18 | include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/CommonPlugin.class.inc.php'); |
---|
| 19 | include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCCss.class.inc.php'); |
---|
| 20 | |
---|
| 21 | |
---|
| 22 | class AStat_root extends CommonPlugin |
---|
| 23 | { |
---|
| 24 | protected $css; //the css object |
---|
| 25 | |
---|
| 26 | public function __construct($prefixeTable, $filelocation) |
---|
| 27 | { |
---|
| 28 | global $conf; |
---|
| 29 | |
---|
| 30 | $this->setPluginName("AStat.2"); |
---|
| 31 | $this->setPluginNameFiles("astat"); |
---|
| 32 | parent::__construct($prefixeTable, $filelocation); |
---|
| 33 | $this->css = new GPCCss(PHPWG_ROOT_PATH.PWG_LOCAL_DIR.'css/'.$this->getPluginNameFiles().".css"); |
---|
| 34 | } |
---|
| 35 | |
---|
| 36 | public function __destruct() |
---|
| 37 | { |
---|
| 38 | unset($this->css); |
---|
| 39 | parent::__destruct(); |
---|
| 40 | } |
---|
| 41 | |
---|
| 42 | |
---|
| 43 | |
---|
| 44 | /* |
---|
| 45 | initialization of config properties |
---|
| 46 | */ |
---|
| 47 | function initConfig() |
---|
| 48 | { |
---|
| 49 | $this->config=array( |
---|
| 50 | 'AStat_BarColor_Pages' => '6666ff', |
---|
| 51 | 'AStat_BarColor_Img' => '66ff66', |
---|
| 52 | 'AStat_BarColor_IP' => 'ff6666', |
---|
| 53 | 'AStat_MouseOverColor' => '303030', |
---|
| 54 | 'AStat_NpIPPerPages' => '25', |
---|
| 55 | 'AStat_NpCatPerPages' => '50', |
---|
| 56 | 'AStat_MaxBarWidth' => '400', |
---|
| 57 | 'AStat_default_period' => 'global', //global, all, year, month, day |
---|
| 58 | 'AStat_ShowThumbCat' => 'true', |
---|
| 59 | 'AStat_DefaultSortCat' => 'page', //page, picture, nbpicture |
---|
| 60 | 'AStat_ShowThumbImg' => 'true', |
---|
| 61 | 'AStat_DefaultSortImg' => 'picture', //picture, catname |
---|
| 62 | 'AStat_NbImgPerPages' => '100', |
---|
| 63 | 'AStat_BarColor_Cat' => 'fff966', |
---|
| 64 | 'AStat_DefaultSortIP' => 'page', //page, ip, picture |
---|
| 65 | 'AStat_SeeTimeRequests' => 'false', |
---|
| 66 | 'AStat_BlackListedIP' => '', // ip blacklisted (separator : ",") |
---|
| 67 | 'AStat_UseBlackList' => 'false' // if false, blacklist usage is disabled, if "invert" then result are inverted |
---|
| 68 | ); |
---|
| 69 | |
---|
| 70 | } |
---|
| 71 | |
---|
| 72 | /* |
---|
| 73 | surchage of CommonPlugin->saveConfig function |
---|
| 74 | */ |
---|
| 75 | function loadConfig() |
---|
| 76 | { |
---|
| 77 | parent::loadConfig(); |
---|
| 78 | if(!$this->css->fileExists()) |
---|
| 79 | { |
---|
| 80 | $this->css->makeCSS($this->generate_CSS()); |
---|
| 81 | } |
---|
| 82 | } |
---|
| 83 | |
---|
| 84 | /* |
---|
| 85 | surchage of CommonPlugin->saveConfig function |
---|
| 86 | */ |
---|
| 87 | function saveConfig() |
---|
| 88 | { |
---|
| 89 | if(parent::saveConfig()) |
---|
| 90 | { |
---|
| 91 | $this->css->makeCSS($this->generate_CSS()); |
---|
| 92 | return(true); |
---|
| 93 | } |
---|
| 94 | return(false); |
---|
| 95 | } |
---|
| 96 | |
---|
| 97 | /* |
---|
| 98 | generate the css code |
---|
| 99 | */ |
---|
| 100 | function generate_CSS() |
---|
| 101 | { |
---|
| 102 | $text = ".AStatBar1, .AStatBar2, .AStatBar3, .AStatBar4, .AStatBarX { |
---|
| 103 | border:0px; |
---|
| 104 | height:8px; |
---|
| 105 | display: block; |
---|
| 106 | margin:0px; |
---|
| 107 | padding:0px; |
---|
| 108 | left:0; |
---|
| 109 | position:relative; |
---|
| 110 | } |
---|
| 111 | .MiniSquare1, .MiniSquare2, .MiniSquare3, .MiniSquare4 { |
---|
| 112 | border:0px; |
---|
| 113 | height:8px; |
---|
| 114 | width:8px; |
---|
| 115 | margin:0px; |
---|
| 116 | padding:0px; |
---|
| 117 | } |
---|
| 118 | .AStatBar1 { background-color:#".$this->config['AStat_BarColor_Pages']."; top:5px; } |
---|
| 119 | .AStatBar2 { background-color:#".$this->config['AStat_BarColor_Img']."; top:-3px; } |
---|
| 120 | .AStatBar3 { background-color:#".$this->config['AStat_BarColor_IP']."; top:-3px;} |
---|
| 121 | .AStatBar4 { background-color:#".$this->config['AStat_BarColor_Cat']."; top:-3px;} |
---|
| 122 | .AStatBarX { background-color:transparent; top:-3px; height:1px; } |
---|
| 123 | .MiniSquare1 { color:#".$this->config['AStat_BarColor_Pages']."; } |
---|
| 124 | .MiniSquare2 { color:#".$this->config['AStat_BarColor_Img']."; } |
---|
| 125 | .MiniSquare3 { color:#".$this->config['AStat_BarColor_IP']."; } |
---|
| 126 | .MiniSquare4 { color:#".$this->config['AStat_BarColor_Cat']."; } |
---|
| 127 | .StatTableRow:hover { background-color:#".$this->config['AStat_MouseOverColor']."; } |
---|
| 128 | .formtable, .formtable P { text-align:left; display:block; } |
---|
| 129 | .formtable tr { vertical-align:top; } |
---|
| 130 | .window_thumb { |
---|
| 131 | position:absolute; |
---|
| 132 | border: none; |
---|
| 133 | background: none; |
---|
| 134 | left:0; |
---|
| 135 | top:0; |
---|
| 136 | margin:0px; |
---|
| 137 | padding:0px; |
---|
| 138 | z-index:100; |
---|
| 139 | overflow:hidden; |
---|
| 140 | visibility:hidden; } |
---|
| 141 | .img_thumb { |
---|
| 142 | border: solid 3px #ffffff; |
---|
| 143 | background: #000000; |
---|
| 144 | margin:0px; |
---|
| 145 | padding:0px; } |
---|
| 146 | .time_request { |
---|
| 147 | font-size:83%; |
---|
| 148 | text-align:right; } |
---|
| 149 | .invisible { visibility:hidden; display:none; } |
---|
| 150 | .littlefont { font-size:90%; } |
---|
| 151 | table.littlefont th { padding:3px; } |
---|
| 152 | table.littlefont td { padding:0px;padding-left:3px;padding-right:3px; } |
---|
| 153 | #iplist { visibility:hidden; position:absolute; width:200px; z-index:1000; } |
---|
| 154 | .iipsellistitem { float:right; } |
---|
| 155 | #iipsellist { width:100%; font-family:monospace; } |
---|
| 156 | "; |
---|
| 157 | |
---|
| 158 | return($text); |
---|
| 159 | } |
---|
| 160 | |
---|
| 161 | /* --------------------------------------------------------------------------- |
---|
| 162 | Function needed for plugin activation |
---|
| 163 | --------------------------------------------------------------------------- */ |
---|
| 164 | |
---|
| 165 | /* |
---|
| 166 | get 'section' enumeration from HISTORY_TABLE |
---|
| 167 | */ |
---|
| 168 | function get_section_enum($add) |
---|
| 169 | { |
---|
| 170 | $returned=array('', false); |
---|
| 171 | $sql = 'SHOW COLUMNS FROM '.HISTORY_TABLE.' LIKE "section"'; |
---|
| 172 | $result=pwg_query($sql); |
---|
| 173 | if($result) |
---|
| 174 | { |
---|
| 175 | $row = pwg_db_fetch_assoc($result); |
---|
| 176 | $list=substr($row['Type'], 5, strlen($row['Type'])-6); |
---|
| 177 | $returned[0]=explode(',', $list); |
---|
| 178 | if((strpos($list, "'$add'")===false)&&($add!='')) |
---|
| 179 | { array_push($returned[0], "'$add'"); } |
---|
| 180 | else |
---|
| 181 | { $returned[1]=true; } |
---|
| 182 | return($returned); |
---|
| 183 | } |
---|
| 184 | } |
---|
| 185 | |
---|
| 186 | function alter_history_section_enum($section) |
---|
| 187 | { |
---|
| 188 | $sections=$this->get_section_enum('deleted_cat'); |
---|
| 189 | if(!$sections[1]) |
---|
| 190 | { |
---|
| 191 | $enums=implode(',', $sections[0]); |
---|
| 192 | $sql="ALTER TABLE ".HISTORY_TABLE." |
---|
| 193 | CHANGE `section` `section` |
---|
| 194 | ENUM (".$enums.") ;"; |
---|
| 195 | $result=pwg_query($sql); |
---|
| 196 | if(!$result) |
---|
| 197 | { |
---|
| 198 | return(false); |
---|
| 199 | } |
---|
| 200 | } |
---|
| 201 | return(true); |
---|
| 202 | } |
---|
| 203 | |
---|
| 204 | |
---|
| 205 | } // astat_root class |
---|
| 206 | |
---|
| 207 | |
---|
| 208 | |
---|
| 209 | ?> |
---|