Changeset 2315
- Timestamp:
- 12/19/10 10:31:41 (17 months ago)
- Location:
- branches/1.5
- Files:
-
- 1 added
- 1 removed
- 7 modified
-
Hotaru.php (modified) (27 diffs)
-
content/admin_themes/admin_default/admin_sidebar.php (modified) (1 diff)
-
content/admin_themes/admin_default/theme_settings.php (modified) (1 diff)
-
functions/funcs.files.php (deleted)
-
libs/AdminPages.php (modified) (4 diffs)
-
libs/Debug.php (modified) (1 diff)
-
libs/FileSystem.php (added)
-
libs/PluginSettings.php (modified) (2 diffs)
-
libs/SystemInfo.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/1.5/Hotaru.php
r2313 r2315 286 286 } 287 287 288 289 /* ************************************************************* 290 * 291 * PAGE HANDLING FUNCTIONS 292 * 293 * *********************************************************** */ 294 288 ############################# 289 ## PAGE HANDLING FUNCTIONS ## 290 ############################# 291 295 292 /** 296 293 * Set the homepage (and set page name) … … 433 430 434 431 435 /* ************************************************************* 436 * 437 * BREADCRUMB FUNCTIONS 438 * 439 * *********************************************************** */ 440 432 ########################## 433 ## BREADCRUMB FUNCTIONS ## 434 ########################## 441 435 442 436 /** … … 463 457 } 464 458 465 466 /* ************************************************************* 467 * 468 * USERAUTH FUNCTIONS / USERBASE FUNCTIONS 469 * 470 * *********************************************************** */ 471 459 ################################### 460 ## USERAUTH / USERBASE FUNCTIONS ## 461 ################################### 462 472 463 /* UserBase & UserAuth functions should be called directly if you want to 473 464 retain the user object being used. E.g. … … 638 629 } 639 630 640 641 /* ************************************************************* 642 * 643 * USERINFO FUNCTIONS 644 * 645 * *********************************************************** */ 646 631 ######################## 632 ## USERINFO FUNCTIONS ## 633 ######################## 647 634 648 635 /** … … 810 797 } 811 798 812 813 /* ************************************************************* 814 * 815 * PLUGIN FUNCTIONS 816 * 817 * *********************************************************** */ 818 819 799 ####################### 800 ## PLUGIN FUNCTIONS ## 801 ####################### 802 820 803 /** 821 804 * Look for and run actions at a given plugin hook … … 965 948 } 966 949 967 968 /* ************************************************************* 969 * 970 * PLUGIN SETTINGS FUNCTIONS 971 * 972 * *********************************************************** */ 973 950 ############################### 951 ## PLUGIN SETTINGS FUNCTIONS ## 952 ############################### 974 953 975 954 /** … … 1027 1006 { 1028 1007 $pluginSettings = new PluginSettings(); 1029 $this->pluginSettings = $pluginSettings->getAllPluginSettings($this); 1030 return $this->pluginSettings; 1008 return $pluginSettings->getAllPluginSettings($this); 1031 1009 } 1032 1010 … … 1059 1037 } 1060 1038 1061 1062 /* ************************************************************* 1063 * 1064 * THEME SETTINGS FUNCTIONS 1065 * 1066 * *********************************************************** */ 1039 ############################## 1040 ## THEME SETTINGS FUNCTIONS ## 1041 ############################## 1067 1042 1068 1043 /** … … 1107 1082 } 1108 1083 1109 1110 /* ************************************************************* 1111 * 1112 * INCLUDE CSS & JAVASCRIPT FUNCTIONS 1113 * 1114 * *********************************************************** */ 1115 1084 ######################################## 1085 ## INCLUDE CSS & JAVASCRIPT FUNCTIONS ## 1086 ######################################## 1116 1087 1117 1088 /** … … 1143 1114 * @param $filename - optional js file without an extension 1144 1115 */ 1145 public function includeJs($folder = '', $filename = '')1146 {1147 $folder = (empty($folder)) ? $this->plugin->folder : $folder;1148 return $this->includes->includeFile('js', $folder, $filename, $this->isAdmin);1149 }1116 public function includeJs($folder = '', $filename = '') 1117 { 1118 $folder = (empty($folder)) ? $this->plugin->folder : $folder; 1119 return $this->includes->includeFile('js', $folder, $filename, $this->isAdmin); 1120 } 1150 1121 1151 1122 … … 1156 1127 * @param $folder - optional pluin folder 1157 1128 */ 1158 public function includeOnceCss($files = array(), $folder = '')1159 {1160 $folder = (empty($folder)) ? $this->plugin->folder: $folder;1161 $files = (is_array($files)) ? $files : array($files);1162 return $this->includes->includeFileOnce($files, 'css', $folder);1163 }1129 public function includeOnceCss($files = array(), $folder = '') 1130 { 1131 $folder = (empty($folder)) ? $this->plugin->folder : $folder; 1132 $files = (is_array($files)) ? $files : array($files); 1133 return $this->includes->includeFileOnce($files, 'css', $folder); 1134 } 1164 1135 1165 1136 … … 1170 1141 * @param $folder - optional pluin folder 1171 1142 */ 1172 public function includeOnceJs($files = array(), $folder = '') 1173 { 1174 $folder = (empty($folder)) ? $this->plugin->folder: $folder; 1175 $files = (is_array($files)) ? $files : array($files); 1176 return $this->includes->includeFileOnce($files, 'js', $folder); 1177 } 1178 1179 1180 /* ************************************************************* 1181 * 1182 * MESSAGE FUNCTIONS (success/error messages) 1183 * 1184 * *********************************************************** */ 1143 public function includeOnceJs($files = array(), $folder = '') 1144 { 1145 $folder = (empty($folder)) ? $this->plugin->folder : $folder; 1146 $files = (is_array($files)) ? $files : array($files); 1147 return $this->includes->includeFileOnce($files, 'js', $folder); 1148 } 1149 1150 ################################################ 1151 ## MESSAGE FUNCTIONS (success/error messages) ## 1152 ################################################ 1185 1153 1186 1154 … … 1207 1175 } 1208 1176 1209 1210 /* ************************************************************* 1211 * 1212 * ANNOUNCEMENT FUNCTIONS 1213 * 1214 * *********************************************************** */ 1215 1177 ############################ 1178 ## ANNOUNCEMENT FUNCTIONS ## 1179 ############################ 1216 1180 1217 1181 /** … … 1231 1195 } 1232 1196 1233 1234 /* ************************************************************* 1235 * 1236 * DEBUG FUNCTIONS 1237 * 1238 * *********************************************************** */ 1239 1197 ##################### 1198 ## DEBUG FUNCTIONS ## 1199 ##################### 1240 1200 1241 1201 /** 1242 1202 * Shows number of database queries and the time it takes for a page to load 1203 * 1204 * @todo Replace all $h->showQueriesAndTime() with Debug::showQueriesAndTime($h) in the themes before releasing 1.5 1243 1205 */ 1244 1206 public function showQueriesAndTime() … … 1247 1209 } 1248 1210 1249 /** 1250 * Log performance and errors 1251 * 1252 * @param string $type "speed", "error", etc. 1253 */ 1254 public function log($type = 'error', $string = '') 1255 { 1256 Debug::log($type, $string); 1257 } 1258 1259 /** 1260 * Generate a system report 1261 * 1262 * @param string $type "log" or "object" 1263 */ 1264 public function generateReport($type = 'log') 1265 { 1266 return Debug::generateReport($this, $type); 1267 } 1268 1269 1270 /* ************************************************************* 1271 * 1272 * RSS FEED FUNCTIONS 1273 * 1274 * *********************************************************** */ 1275 1211 ######################## 1212 ## RSS FEED FUNCTIONS ## 1213 ######################## 1276 1214 1277 1215 /** … … 1305 1243 } 1306 1244 1307 1308 /* ************************************************************* 1309 * 1310 * ADMIN FUNCTIONS 1311 * 1312 * *********************************************************** */ 1313 1245 ##################### 1246 ## ADMIN FUNCTIONS ## 1247 ##################### 1314 1248 1315 1249 /** … … 1344 1278 } 1345 1279 1346 1347 /* ************************************************************* 1348 * 1349 * MAINTENANCE FUNCTIONS 1350 * 1351 * *********************************************************** */ 1352 1280 ########################### 1281 ## MAINTENANCE FUNCTIONS ## 1282 ########################### 1353 1283 1354 1284 /** … … 1359 1289 public function checkAccess() 1360 1290 { 1361 if (SITE_OPEN == 'true') { return true; } // site is open, go back and continue 1362 1363 // site closed, but user has admin access so go back and continue as normal 1364 if ($this->currentUser->getPermission('can_access_admin') == 'yes') { return true; } 1365 1366 if ($this->pageName == 'admin_login') { return true; } 1291 // site is open, go back and continue 1292 if ((SITE_OPEN == 'true') 1293 // site closed, but user has admin access so go back and continue as normal 1294 || ($this->currentUser->getPermission('can_access_admin') == 'yes') 1295 || ($this->pageName == 'admin_login') ) 1296 { 1297 return true; 1298 } 1367 1299 1368 1300 $maintenance = new Maintenance(); … … 1384 1316 1385 1317 /** 1386 * Optimize all database tables1387 */1388 public function optimizeTables()1389 {1390 $maintenance = new Maintenance();1391 $maintenance->optimizeTables($this);1392 }1393 1394 1395 /**1396 * Empty plugin database table1397 *1398 * @param string $table_name - table to empty1399 * @param string $msg - show "emptied" message or not1400 */1401 public function emptyTable($table_name = '', $msg = true)1402 {1403 $maintenance = new Maintenance();1404 $maintenance->emptyTable($this, $table_name, $msg);1405 }1406 1407 1408 /**1409 * Delete plugin database table1410 *1411 * @param string $table_name - table to drop1412 * @param string $msg - show "dropped" message or not1413 */1414 public function dropTable($table_name = '', $msg = true)1415 {1416 $maintenance = new Maintenance();1417 $maintenance->dropTable($this, $table_name, $msg);1418 }1419 1420 1421 /**1422 * Remove plugin settings1423 *1424 * @param string $folder - plugin folder name1425 * @param bool $msg - show "Removed" message or not1426 */1427 public function removeSettings($folder = '', $msg = true)1428 {1429 $maintenance = new Maintenance();1430 $maintenance->removeSettings($this, $folder, $msg);1431 }1432 1433 1434 /**1435 * Deletes rows from pluginsettings that match a given setting or plugin1436 *1437 * @param string $setting name of the setting to remove1438 * @param string $folder name of plugin folder1439 */1440 public function deleteSettings($setting = '', $folder = '')1441 {1442 $maintenance = new Maintenance();1443 $maintenance->deleteSettings($this, $setting, $folder);1444 }1445 1446 1447 /**1448 * Delete all files in the specified directory except placeholder.txt1449 *1450 * @param string $dir - path to the cache folder1451 * @return bool1452 */1453 public function deleteFiles($dir = '')1454 {1455 $maintenance = new Maintenance();1456 return $maintenance->deleteFiles($dir);1457 }1458 1459 1460 /**1461 1318 * Calls the delete_files function, then displays a message. 1462 1319 * … … 1470 1327 } 1471 1328 1472 1473 /** 1474 * Get all files in the specified directory except placeholder.txt 1475 * 1476 * @param string $dir - path to the folder 1477 * @param array $exclude - array of file/folder names to exclude 1478 * @return array 1479 */ 1480 public function getFiles($dir = '', $exclude = array()) 1481 { 1482 $maintenance = new Maintenance(); 1483 return $maintenance->getFiles($dir, $exclude); 1484 } 1485 1486 1487 /** 1488 * System Report is under Debug Functions 1489 */ 1490 1491 1492 /* ************************************************************* 1493 * 1494 * CACHING FUNCTIONS (Note: "clearCache" is in Maintenance above) 1495 * 1496 * *********************************************************** */ 1497 1329 #################################################################### 1330 ## CACHING FUNCTIONS (Note: "clearCache" is in Maintenance above) ## 1331 #################################################################### 1498 1332 1499 1333 /** … … 1535 1369 } 1536 1370 1537 1538 /* ************************************************************* 1539 * 1540 * BLOCKED FUNCTIONS (i.e. Admin's Blocked list) 1541 * 1542 * *********************************************************** */ 1543 1371 ################################################### 1372 ## BLOCKED FUNCTIONS (i.e. Admin's Blocked list) ## 1373 ################################################### 1374 1544 1375 /** 1545 1376 * Check if a value is blocked from registration and post submission) … … 1571 1402 } 1572 1403 1573 1574 /* ************************************************************* 1575 * 1576 * LANGUAGE FUNCTIONS 1577 * 1578 * *********************************************************** */ 1579 1404 ######################## 1405 ## LANGUAGE FUNCTIONS ## 1406 ######################## 1580 1407 1581 1408 /** … … 1609 1436 } 1610 1437 1611 1612 /* ************************************************************* 1613 * 1614 * CSRF FUNCTIONS 1615 * 1616 * *********************************************************** */ 1617 1438 #################### 1439 ## CSRF FUNCTIONS ## 1440 #################### 1618 1441 1619 1442 /** … … 1631 1454 } 1632 1455 1633 1634 /* ************************************************************* 1635 * 1636 * POST FUNCTIONS 1637 * 1638 * *********************************************************** */ 1639 1640 1456 #################### 1457 ## POST FUNCTIONS ## 1458 #################### 1459 1641 1460 /** 1642 1461 * Get all the parameters for the current post … … 1816 1635 } 1817 1636 1818 1819 /* ************************************************************* 1820 * 1821 * AVATAR FUNCTIONS 1822 * 1823 * *********************************************************** */ 1824 1637 ###################### 1638 ## AVATAR FUNCTIONS ## 1639 ###################### 1825 1640 1826 1641 /** … … 1870 1685 } 1871 1686 1872 1873 /* ************************************************************* 1874 * 1875 * CATEGORY FUNCTIONS 1876 * 1877 * *********************************************************** */ 1687 ######################## 1688 ## CATEGORY FUNCTIONS ## 1689 ######################## 1878 1690 1879 1691 /** … … 2008 1820 } 2009 1821 2010 2011 /* ************************************************************* 2012 * 2013 * WIDGET FUNCTIONS 2014 * 2015 * *********************************************************** */ 1822 ###################### 1823 ## WIDGET FUNCTIONS ## 1824 ###################### 2016 1825 2017 1826 /** -
branches/1.5/content/admin_themes/admin_default/admin_sidebar.php
r2160 r2315 59 59 <ul id="theme_settings_list"> 60 60 <?php 61 $themes = $h->getFiles(THEMES, array('404error.php'));61 $themes = FileSystem::listFiles(THEMES, array('404error.php'), FALSE); 62 62 if ($themes) { 63 63 $themes = sksort($themes, $subkey="name", $type="char", true); -
branches/1.5/content/admin_themes/admin_default/theme_settings.php
r2154 r2315 78 78 <ul id="plugin_settings_list"> 79 79 <?php 80 $themes = $h->getFiles(THEMES, array('404error.php'));80 $themes = FileSystem::listFiles(THEMES, array('404error.php'), FALSE); 81 81 if ($themes) { 82 82 $themes = sksort($themes, $subkey="name", $type="char", true); -
branches/1.5/libs/AdminPages.php
r2313 r2315 186 186 $theme = strtolower($h->cage->post->testAlnumLines('theme')."/"); 187 187 $this->adminSettingUpdate($h, 'THEME', $theme); 188 $h->deleteFiles(CACHE.'css_js_cache'); // clear the CSS/JS cache188 FileSystem::deleteFiles(CACHE.'css_js_cache'); // clear the CSS/JS cache 189 189 $json_array = array('activate' => 'true', 'message' => $h->lang["admin_settings_theme_activate_success"], 'color' => 'green'); 190 190 … … 329 329 break; 330 330 case 'remove_settings': 331 $h->removeSettings($h->cage->get->testAlnumLines('settings')); 331 $plugin_settings = new PluginSettings(); 332 if($plugin_settings->removeSettings($h, $h->cage->get->testAlnumLines('settings'))){ 333 $h->message = $h->lang['admin_maintenance_settings_removed']; 334 $h->messageType = 'green'; 335 } 332 336 break; 333 337 case 'system_report': 334 $h->generateReport();338 Debug::generateReport($h); 335 339 break; 336 340 case 'email_report': 337 $h->generateReport('email');341 Debug::generateReport($h, 'email'); 338 342 break; 339 343 case 'delete_debugs': 340 344 $h->clearCache('debug_logs'); 341 $h->vars['debug_files'] = $h->getFiles(CACHE.'debug_logs');345 $h->vars['debug_files'] = FileSystem::listFiles(CACHE.'debug_logs'); 342 346 break; 343 347 } 344 348 345 349 // get list of debug logs 346 $h->vars['debug_files'] = $h->getFiles(CACHE.'debug_logs');350 $h->vars['debug_files'] = FileSystem::listFiles(CACHE.'debug_logs'); 347 351 } 348 352 … … 354 358 public function listPluginSettings($h) 355 359 { 356 $sql = "SELECT DISTINCT plugin_folder FROM ".TABLE_PLUGINSETTINGS; 357 $results = $h->db->get_results($h->db->prepare($sql)); 360 $results = $h->db->get_results("SELECT DISTINCT plugin_folder FROM ".TABLE_PLUGINSETTINGS); 358 361 359 362 if (!$results) { … … 364 367 365 368 foreach ($results as $item) { 366 array_push($plugin_settings, $item->plugin_folder);369 $plugin_settings[] = $item->plugin_folder; 367 370 } 368 371 -
branches/1.5/libs/Debug.php
r2298 r2315 40 40 echo $h->lang['main_hotaru_db_queries'].$h->db->num_queries." | "; 41 41 echo $h->lang['main_hotaru_page_load_time'].timer_stop(1).$h->lang['main_times_secs']." | "; 42 echo $h->lang['main_hotaru_memory_usage']. display_filesize(memory_get_usage())." | ";42 echo $h->lang['main_hotaru_memory_usage'].FileSystem::display_filesize(memory_get_usage())." | "; 43 43 echo $h->lang['main_hotaru_php_version'].phpversion()." | "; 44 44 echo $h->lang['main_hotaru_mysql_version'].$mysql_version." | "; -
branches/1.5/libs/PluginSettings.php
r1662 r2315 114 114 public function getAllPluginSettings($h) 115 115 { 116 $sql = "SELECT plugin_folder, plugin_setting, plugin_value FROM " . TABLE_PLUGINSETTINGS; 117 $results = $h->db->get_results($h->db->prepare($sql)); 118 if ($results) { return $results; } else { return false; } 116 $results = $h->db->get_results("SELECT plugin_folder, plugin_setting, plugin_value FROM ".TABLE_PLUGINSETTINGS); 117 $h->pluginSettings = $results; 118 if ($results) { 119 return $results; 120 } 121 return FALSE; 119 122 } 120 123 … … 167 170 $h->db->query("OPTIMIZE TABLE " . TABLE_PLUGINSETTINGS); 168 171 } 172 173 /** 174 * Remove plugin settings 175 * 176 * @param string $folder - plugin folder name 177 * @param bool $msg - show "Removed" message or not 178 */ 179 public function removeSettings($h, $folder, $msg = true) 180 { 181 if (!$folder) { 182 $folder = $h->plugin->folder; 183 } 184 185 $sql = "DELETE FROM ".TABLE_PLUGINSETTINGS." WHERE plugin_folder = %s"; 186 $h->db->get_results($h->db->prepare($sql, $folder)); 187 return TRUE; 188 } 189 169 190 } 170 ?> -
branches/1.5/libs/SystemInfo.php
r2255 r2315 38 38 'format' => $format, 39 39 'method' => 'hotaru.systemFeedback.add', 40 'args' => serialize( $h->generateReport("object"))40 'args' => serialize(Debug::generateReport($h, "object")) 41 41 )); 42 42