- Timestamp:
- 11/26/10 16:02:20 (18 months ago)
- Files:
-
- 1 modified
-
branches/1.5/Hotaru.php (modified) (181 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/1.5/Hotaru.php
r2237 r2260 5 5 * PHP version 5 6 6 * 7 * LICENSE: Hotaru CMS is free software: you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License as 9 * published by the Free Software Foundation, either version 3 of 10 * the License, or (at your option) any later version. 11 * 12 * Hotaru CMS is distributed in the hope that it will be useful, but WITHOUT 13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 * FITNESS FOR A PARTICULAR PURPOSE. 15 * 16 * You should have received a copy of the GNU General Public License along 7 * LICENSE: Hotaru CMS is free software: you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License as 9 * published by the Free Software Foundation, either version 3 of 10 * the License, or (at your option) any later version. 11 * 12 * Hotaru CMS is distributed in the hope that it will be useful, but WITHOUT 13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 * FITNESS FOR A PARTICULAR PURPOSE. 15 * 16 * You should have received a copy of the GNU General Public License along 17 17 * with Hotaru CMS. If not, see http://www.gnu.org/licenses/. 18 * 18 * 19 19 * @category Content Management System 20 20 * @package HotaruCMS … … 26 26 class Hotaru 27 27 { 28 protected $version = "1.5 "; // Hotaru CMS version28 protected $version = "1.5.0"; // Hotaru CMS version 29 29 protected $isDebug = false; // show db queries and page loading time 30 30 protected $isAdmin = false; // flag to tell if we are in Admin or not … … 32 32 protected $csrfToken = ''; // token for CSRF 33 33 protected $lang = array(); // stores language file content 34 34 35 35 // objects 36 36 protected $db; // database object … … 42 42 protected $comment; // Comment object 43 43 protected $includes; // for CSS/JavaScript includes 44 protected $debug; // Debug object45 44 protected $pageHandling; // PageHandling object 46 45 47 46 // page info 48 47 protected $home = ''; // name for front page … … 56 55 protected $pluginSettings = array(); // contains all settings for all plugins 57 56 protected $allPluginDetails = array(); // contains details of all plugins 58 57 59 58 // messages 60 59 protected $message = ''; // message to display 61 60 protected $messageType = 'green'; // green or red, color of message box 62 61 protected $messages = array(); // for multiple messages 63 62 64 63 // miscellaneous 65 protected $vars = array(); // multi-purpose 66 64 protected $vars = array(); // multi-purpose 65 67 66 /** 68 67 * CONSTRUCTOR - Initialize 69 68 */ 70 69 public function __construct($start = '') 71 { 70 { 72 71 // define shorthand paths 73 72 if (!defined('BASE')) { 74 define( "BASE", dirname(__FILE__).'/');75 define( "CACHE", dirname(__FILE__).'/cache/');76 define( "ADMIN", dirname(__FILE__).'/admin/');77 define( "INSTALL", dirname(__FILE__).'/install/');78 define( "LIBS", dirname(__FILE__).'/libs/');79 define( "EXTENSIONS", dirname(__FILE__).'/libs/extensions/');80 define( "FUNCTIONS", dirname(__FILE__).'/functions/');81 define( "CONTENT", dirname(__FILE__).'/content/');82 define( "THEMES", dirname(__FILE__).'/content/themes/');83 define( "PLUGINS", dirname(__FILE__).'/content/plugins/');84 define( "ADMIN_THEMES", dirname(__FILE__).'/content/admin_themes/');85 define( "SITEURL", BASEURL);73 define('BASE', dirname(__FILE__).'/'); 74 define('CACHE', dirname(__FILE__).'/cache/'); 75 define('ADMIN', dirname(__FILE__).'/admin/'); 76 define('INSTALL', dirname(__FILE__).'/install/'); 77 define('LIBS', dirname(__FILE__).'/libs/'); 78 define('EXTENSIONS', dirname(__FILE__).'/libs/extensions/'); 79 define('FUNCTIONS', dirname(__FILE__).'/functions/'); 80 define('CONTENT', dirname(__FILE__).'/content/'); 81 define('THEMES', dirname(__FILE__).'/content/themes/'); 82 define('PLUGINS', dirname(__FILE__).'/content/plugins/'); 83 define('ADMIN_THEMES', dirname(__FILE__).'/content/admin_themes/'); 84 define('SITEURL', BASEURL); 86 85 } 87 86 … … 90 89 // initialize Hotaru 91 90 if (!$start) { 92 91 93 92 $init = new Initialize($this); 94 93 95 94 $this->db = $init->db; // database object 96 95 $this->cage = $init->cage; // Inspekt cage 97 $this->isDebug = $init->isDebug; // set debug 96 $this->isDebug = $init->isDebug; // set debug 98 97 $this->currentUser = new UserAuth(); // the current user 99 98 $this->plugin = new Plugin(); // instantiate Plugin object … … 101 100 $this->includes = new IncludeCssJs(); // instantiate Includes object 102 101 $this->pageHandling = new PageHandling(); // instantiate PageHandling object 103 $this->debug = new Debug(); // instantiate Debug object 104 102 105 103 $this->csrf('set'); // set a csrfToken 106 104 $this->db->setHotaru($this); // pass $h object to EzSQL for error reporting 107 105 } 108 106 } 109 110 107 108 111 109 /* ************************************************************* 112 110 * … … 124 122 $lang = new Language(); 125 123 $this->lang = $lang->includeLanguagePack($this->lang, 'main'); 126 124 127 125 $this->getPageName(); // fills $h->pageName 128 126 129 127 switch ($entrance) { 130 128 case 'admin': 131 129 $this->isAdmin = true; 132 $this->lang = $lang->includeLanguagePack($this->lang, 'admin'); 130 $this->lang = $lang->includeLanguagePack($this->lang, 'admin'); 133 131 $admin = new AdminAuth(); // new Admin object 134 132 $this->checkCookie(); // check cookie reads user details … … 144 142 $this->displayTemplate('index'); // displays the index page 145 143 } 146 144 147 145 $lang->writeLanguageCache($this); 148 146 149 147 exit; 150 148 } 151 152 149 150 153 151 /* ************************************************************* 154 152 * … … 156 154 * 157 155 * *********************************************************** */ 158 159 156 157 160 158 /** 161 159 * Access modifier to set protected properties … … 165 163 $this->$var = $val; 166 164 } 167 168 165 166 169 167 /** 170 168 * Access modifier to get protected properties … … 182 180 * 183 181 * *********************************************************** */ 184 185 182 183 186 184 /** 187 185 * Include language file if available … … 191 189 $this->includeLanguage($this->plugin->folder); 192 190 } 193 194 191 192 195 193 /** 196 194 * Include All CSS and JavaScript files for this plugin … … 199 197 { 200 198 if ($this->isAdmin) { return false; } 201 199 202 200 // include a files that match the name of the plugin folder: 203 201 $this->includeJs($this->plugin->folder); // folder name, filename 204 202 $this->includeCss($this->plugin->folder); 205 203 } 206 207 204 205 208 206 /** 209 207 * Include All CSS and JavaScript files for this plugin in Admin … … 212 210 { 213 211 if (!$this->isAdmin) { return false; } 214 212 215 213 // include a files that match the name of the plugin folder: 216 214 $this->includeJs($this->plugin->folder); // folder name, filename 217 215 $this->includeCss($this->plugin->folder); 218 216 } 219 220 217 218 221 219 /** 222 220 * Include code as a template before the closing </body> tag … … 226 224 $this->displayTemplate($this->plugin->folder . '_footer', $this->plugin->folder); 227 225 } 228 226 229 227 230 228 /** … … 238 236 return $vars; 239 237 } 240 241 238 239 242 240 /** 243 241 * Display Admin settings page … … 251 249 // The class must have a method called "settings". 252 250 if (($this->cage->get->testAlnumLines('plugin') != $this->plugin->folder) 253 && ($this->cage->post->testAlnumLines('plugin') != $this->plugin->folder)) 254 { 255 return false; 251 && ($this->cage->post->testAlnumLines('plugin') != $this->plugin->folder)) 252 { 253 return false; 256 254 } 257 255 258 256 if (file_exists(PLUGINS . $this->plugin->folder . '/' . $this->plugin->folder . '_settings.php')) { 259 257 include_once(PLUGINS . $this->plugin->folder . '/' . $this->plugin->folder . '_settings.php'); 260 258 261 259 $settings_class = make_name($this->plugin->folder, '_') . 'Settings'; // e.g. CategoriesSettings 262 260 $settings_class = str_replace(' ', '', $settings_class); // strip spaces 263 261 $settings_object = new $settings_class(); 264 $settings_object->settings($this); // call the settings function 262 $settings_object->settings($this); // call the settings function 265 263 } 266 264 else { … … 270 268 return true; 271 269 } 272 273 270 271 274 272 /* ************************************************************* 275 273 * … … 298 296 return $this->pageHandling->isHome($this); 299 297 } 300 301 298 299 302 300 /** 303 301 * Determine the title tags for the header … … 310 308 return $this->pageHandling->getTitle($this, $delimiter, $raw); 311 309 } 312 313 310 311 314 312 /** 315 313 * Includes a template to display … … 323 321 $this->pageHandling->displayTemplate($this, $page, $plugin, $include_once); 324 322 } 325 326 323 324 327 325 /** 328 326 * Checks if current page (in url or form) matches the page parameter … … 334 332 return $this->pageHandling->isPage($this, $page); 335 333 } 336 337 338 /** 339 * Check to see if the Admin settings page we are looking at 334 335 336 /** 337 * Check to see if the Admin settings page we are looking at 340 338 * matches the plugin passed to this function. 341 339 * … … 343 341 * @return bool 344 342 * 345 * Notes: This is used in "admin_header_include" so we only include the css, 343 * Notes: This is used in "admin_header_include" so we only include the css, 346 344 * javascript etc. for the plugin we're trying to change settings for. 347 * Usage: $h->isSettingsPage('submit') returns true if 345 * Usage: $h->isSettingsPage('submit') returns true if 348 346 * page=plugin_settings and plugin=submit in the url. 349 347 */ … … 353 351 } 354 352 355 353 356 354 /** 357 355 * Gets the current page name … … 362 360 return $this->pageName; 363 361 } 364 365 362 363 366 364 /** 367 365 * Converts a friendly url into a standard one … … 370 368 * return string $standard_url 371 369 */ 372 public function friendlyToStandardUrl($friendly_url) 370 public function friendlyToStandardUrl($friendly_url) 373 371 { 374 372 return $this->pageHandling->friendlyToStandardUrl($this, $friendly_url); 375 373 } 376 377 374 375 378 376 /** 379 377 * Generate either default or friendly urls 380 378 * 381 * @param array $parameters an array of pairs, e.g. 'page' => 'about' 379 * @param array $parameters an array of pairs, e.g. 'page' => 'about' 382 380 * @param string $head either 'index' or 'admin' 383 381 * @return string … … 387 385 return $this->pageHandling->url($this, $parameters, $head); 388 386 } 389 390 387 388 391 389 /** 392 390 * Pagination with query and row count (better for large sets of data) … … 403 401 return $paginator->pagination($this, $query, $total_items, $items_per_page, $cache_table); 404 402 } 405 403 406 404 407 405 /** … … 417 415 return $paginator->paginationFull($this, $data, $items_per_page); 418 416 } 419 420 417 418 421 419 /** 422 420 * Return page numbers bar … … 429 427 return $paginator->pageBar($this); 430 428 } 431 429 432 430 433 431 /* ************************************************************* … … 436 434 * 437 435 * *********************************************************** */ 438 439 436 437 440 438 /** 441 439 * Build breadcrumbs … … 446 444 return $breadcrumbs->buildBreadcrumbs($this); 447 445 } 448 449 446 447 450 448 /** 451 449 * prepares the RSS link found in breadcrumbs … … 454 452 * @param array $vars - array of key -> value pairs 455 453 * @return string 456 */ 454 */ 457 455 public function rssBreadcrumbsLink($status = '', $vars = array()) 458 456 { … … 460 458 return $breadcrumbs->rssBreadcrumbsLink($this, $status, $vars); 461 459 } 462 463 460 461 464 462 /* ************************************************************* 465 463 * … … 467 465 * 468 466 * *********************************************************** */ 469 470 /* UserBase & UserAuth functions should be called directly if you want to 467 468 /* UserBase & UserAuth functions should be called directly if you want to 471 469 retain the user object being used. E.g. 472 470 473 471 $user = new UserAuth(); 474 472 $user->getUserBasic($h); 475 473 $user->updateUserBasic($h); 476 474 */ 477 478 475 476 479 477 /** 480 478 * check cookie and log in … … 486 484 $this->currentUser->checkCookie($this); 487 485 } 488 489 486 487 490 488 /** 491 489 * Get basic user details 492 490 * 493 * @param int $userid 491 * @param int $userid 494 492 * @param string $username 495 493 * @param bool $no_cache - set true to disable caching of SQl results … … 503 501 return $userbase->getUserBasic($this, $userid, $username, $no_cache); 504 502 } 505 506 503 504 507 505 /** 508 506 * Get full user details (i.e. permissions and settings, too) 509 507 * 510 * @param int $userid 508 * @param int $userid 511 509 * @param string $username 512 510 * @param bool $no_cache - set true to disable caching of SQl results … … 520 518 return $userbase->getUser($this, $userid, $username, $no_cache); 521 519 } 522 523 520 521 524 522 /** 525 523 * Default permissions … … 530 528 * @return array $perms 531 529 */ 532 public function getDefaultPermissions($role = '', $defaults = 'site', $options_only = false) 530 public function getDefaultPermissions($role = '', $defaults = 'site', $options_only = false) 533 531 { 534 532 $userbase = new UserBase(); 535 533 return $userbase->getDefaultPermissions($this, $role, $defaults, $options_only); 536 534 } 537 538 535 536 539 537 /** 540 538 * Update Default permissions 541 539 * 542 540 * @param array $new_perms from a plugin's install function 543 * @param string $defaults - either "site", "base" or "both" 541 * @param string $defaults - either "site", "base" or "both" 544 542 * @param bool $remove - false if adding perms, true if deleting them 545 543 */ 546 public function updateDefaultPermissions($new_perms = array(), $defaults = 'both', $remove = false) 544 public function updateDefaultPermissions($new_perms = array(), $defaults = 'both', $remove = false) 547 545 { 548 546 $userbase = new UserBase(); 549 547 return $userbase->updateDefaultPermissions($this, $new_perms, $defaults, $remove); 550 548 } 551 552 549 550 553 551 /** 554 552 * Get the default user settings … … 562 560 return $userbase->getDefaultSettings($this, $type); 563 561 } 564 565 562 563 566 564 /** 567 565 * Update the default user settings 568 566 * 569 * @param array $settings 567 * @param array $settings 570 568 * @param string $type either 'site' or 'base' (base for the originals) 571 569 * @return array … … 576 574 return $userbase->updateDefaultSettings($this, $settings, $type); 577 575 } 578 579 576 577 580 578 /** 581 579 * Get a user's profile or settings data … … 588 586 return $userbase->getProfileSettingsData($this, $type, $userid, $check_exists_only); 589 587 } 590 591 588 589 592 590 /** 593 591 * Physically delete a user … … 596 594 * @param int $user_id (optional) 597 595 */ 598 public function deleteUser($user_id = 0) 596 public function deleteUser($user_id = 0) 599 597 { 600 598 $userbase = new UserBase(); … … 608 606 * @param int $user_id (optional) 609 607 */ 610 public function updateUserLastVisit($user_id = 0) 608 public function updateUserLastVisit($user_id = 0) 611 609 { 612 610 return $this->currentUser->updateUserLastVisit($this, $user_id); 613 611 } 614 612 615 613 616 614 /** … … 620 618 * @return array|false 621 619 */ 622 public function getRoles($type = 'all') 620 public function getRoles($type = 'all') 623 621 { 624 622 return $this->currentUser->getRoles($this, $type); … … 631 629 * @return array|false 632 630 */ 633 public function getUniqueRoles() 631 public function getUniqueRoles() 634 632 { 635 633 return $this->getRoles(); 636 634 } 637 635 638 636 639 637 /* ************************************************************* 640 638 * … … 642 640 * 643 641 * *********************************************************** */ 644 645 642 643 646 644 /** 647 645 * Get the username for a given user id … … 655 653 return $userInfo->getUserNameFromId($this, $id); 656 654 } 657 658 655 656 659 657 /** 660 658 * Get the user id for a given username … … 668 666 return $userInfo->getUserIdFromName($this, $username); 669 667 } 670 671 668 669 672 670 /** 673 671 * Get the email from user id … … 681 679 return $userInfo->getEmailFromId($this, $userid); 682 680 } 683 684 681 682 685 683 /** 686 684 * Get the user id from email … … 694 692 return $userInfo->getUserIdFromEmail($this, $email); 695 693 } 696 697 694 695 698 696 /** 699 697 * Checks if the user has an 'admin' role … … 706 704 return $userInfo->isAdmin($this->db, $username); 707 705 } 708 709 706 707 710 708 /** 711 709 * Check if a user exists 712 710 * 713 * @param int $userid 711 * @param int $userid 714 712 * @param string $username 715 713 * @return int … … 722 720 return $userInfo->userExists($this->db, $id, $username, $email); 723 721 } 724 725 722 723 726 724 /** 727 725 * Check if an username exists in the database (used in forgotten password) … … 737 735 return $userInfo->nameExists($this, $username, $role, $exclude); 738 736 } 739 740 737 738 741 739 /** 742 740 * Check if an email exists in the database (used in forgotten password) … … 752 750 return $userInfo->emailExists($this, $email, $role, $exclude); 753 751 } 754 755 752 753 756 754 /** 757 755 * Get all users with permission to (access admin) … … 766 764 return $userInfo->getMods($this, $permission, $value); 767 765 } 768 769 766 767 770 768 /** 771 769 * Get the ids and names of all users or those with a specified role, sorted alphabetically … … 779 777 return $userInfo->userIdNameList($this, $role); 780 778 } 781 782 779 780 783 781 /** 784 782 * Get full details of all users or batches of users, sorted alphabetically … … 794 792 return $userInfo->userListFull($this, $id_array, $start, $range); 795 793 } 796 797 794 795 798 796 /** 799 797 * Get settings for all users 800 798 * 801 * @param int $userid - optional user id 799 * @param int $userid - optional user id 802 800 * @return array 803 801 */ … … 808 806 } 809 807 810 808 811 809 /* ************************************************************* 812 810 * … … 814 812 * 815 813 * *********************************************************** */ 816 817 814 815 818 816 /** 819 817 * Look for and run actions at a given plugin hook … … 830 828 return $pluginFunctions->pluginHook($this, $hook, $folder, $parameters, $exclude); 831 829 } 832 833 830 831 834 832 /** 835 833 * Get a single plugin's details for Hotaru … … 843 841 return $pluginFunctions->readPlugin($this, $folder); 844 842 } 845 846 843 844 847 845 /** 848 846 * Get a single property from a specified plugin … … 857 855 return $pluginFunctions->getPluginProperty($this, $property, $folder, $field); 858 856 } 859 860 857 858 861 859 /** 862 860 * Get number of active plugins … … 869 867 return $pluginFunctions->numActivePlugins($this->db); 870 868 } 871 872 869 870 873 871 /** 874 872 * Get version number of plugin if active … … 881 879 return $this->getPluginProperty('plugin_version', $folder); 882 880 } 883 884 881 882 885 883 /** 886 884 * Get a plugin's actual name from its folder name … … 893 891 return $this->getPluginProperty('plugin_name', $folder); 894 892 } 895 896 893 894 897 895 /** 898 896 * Get a plugin's folder from its class name … … 906 904 $this->plugin->folder = $pluginFunctions->getPluginFolderFromClass($this, $class); 907 905 } 908 909 906 907 910 908 /** 911 909 * Get a plugin's class from its folder name … … 918 916 return $this->getPluginProperty('plugin_class', $folder); 919 917 } 920 921 918 919 922 920 /** 923 921 * Determines if a plugin "type" is enabled, if not, plugin "folder" … … 934 932 return $result; 935 933 } 936 937 934 935 938 936 /** 939 937 * Determines if a specific plugin is installed … … 948 946 return $result; 949 947 } 950 951 948 949 952 950 /** 953 951 * Determines if a plugin has a settings page or not … … 969 967 * 970 968 * *********************************************************** */ 971 972 969 970 973 971 /** 974 972 * Get the value for a given plugin and setting … … 986 984 return $pluginSettings->getSetting($this, $setting, $folder); 987 985 } 988 989 986 987 990 988 /** 991 989 * Get an array of settings for a given plugin … … 1001 999 return $pluginSettings->getSettingsArray($this, $folder); 1002 1000 } 1003 1004 1001 1002 1005 1003 /** 1006 1004 * Get and unserialize serialized settings … … 1015 1013 return $pluginSettings->getSerializedSettings($this, $folder, $settings_name); 1016 1014 } 1017 1018 1015 1016 1019 1017 /** 1020 1018 * Get and store all plugin settings in $h->pluginSettings … … 1028 1026 return $this->pluginSettings; 1029 1027 } 1030 1031 1028 1029 1032 1030 /** 1033 1031 * Determine if a plugin setting already exists … … 1042 1040 return $pluginSettings->isSetting($this, $setting, $folder); 1043 1041 } 1044 1045 1042 1043 1046 1044 /** 1047 1045 * Update a plugin setting … … 1075 1073 return $themeSettings->readThemeMeta($this, $theme); 1076 1074 } 1077 1078 1075 1076 1079 1077 /** 1080 1078 * Get and unserialize serialized settings … … 1089 1087 return $themeSettings->getThemeSettings($this, $theme, $return); 1090 1088 } 1091 1092 1089 1090 1093 1091 /** 1094 1092 * Update theme settings … … 1097 1095 * @param string $theme theme folder name 1098 1096 * @param string $column 'value', 'default' or 'both' 1099 1097 1100 1098 */ 1101 1099 public function updateThemeSettings($settings = array(), $theme = '', $column = 'value') … … 1111 1109 * 1112 1110 * *********************************************************** */ 1113 1111 1114 1112 1115 1113 /** … … 1120 1118 $this->includes->includeCombined($this, $this->isAdmin); 1121 1119 } 1122 1123 1120 1121 1124 1122 /** 1125 1123 * Build an array of css files to combine … … 1133 1131 return $this->includes->includeFile('css', $folder, $filename,$this->isAdmin); 1134 1132 } 1135 1136 1133 1134 1137 1135 /** 1138 1136 * Build an array of JavaScript files to combine … … 1146 1144 return $this->includes->includeFile('js', $folder, $filename,$this->isAdmin); 1147 1145 } 1148 1149 1146 1147 1150 1148 /** 1151 1149 * Include individual CSS files, not merged into the CSS archive … … 1160 1158 return $this->includes->includeFileOnce($files, 'css', $folder); 1161 1159 } 1162 1163 1160 1161 1164 1162 /** 1165 1163 * Include individual JavaScript files, not merged into the JavaScript archive … … 1174 1172 return $this->includes->includeFileOnce($files, 'js', $folder); 1175 1173 } 1176 1177 1174 1175 1178 1176 /* ************************************************************* 1179 1177 * … … 1181 1179 * 1182 1180 * *********************************************************** */ 1183 1184 1181 1182 1185 1183 /** 1186 1184 * Display a SINGLE success or failure message … … 1194 1192 $messages->showMessage($this, $msg, $msg_type); 1195 1193 } 1196 1197 1194 1195 1198 1196 /** 1199 1197 * Displays ALL success or failure messages … … 1204 1202 $messages->showMessages($this); 1205 1203 } 1206 1207 1204 1205 1208 1206 /* ************************************************************* 1209 1207 * … … 1211 1209 * 1212 1210 * *********************************************************** */ 1213 1214 1211 1212 1215 1213 /** 1216 1214 * Displays an announcement at the top of the screen … … 1219 1217 * @return array 1220 1218 */ 1221 public function checkAnnouncements($announcement = '') 1219 public function checkAnnouncements($announcement = '') 1222 1220 { 1223 1221 $announce = new Announcements(); … … 1228 1226 } 1229 1227 } 1230 1231 1228 1229 1232 1230 /* ************************************************************* 1233 1231 * … … 1235 1233 * 1236 1234 * *********************************************************** */ 1237 1238 1235 1236 1239 1237 /** 1240 1238 * Shows number of database queries and the time it takes for a page to load … … 1244 1242 Debug::showQueriesAndTime($this); 1245 1243 } 1246 1244 1247 1245 /** 1248 1246 * Log performance and errors … … 1254 1252 Debug::log($type, $string); 1255 1253 } 1256 1254 1257 1255 /** 1258 1256 * Generate a system report … … 1265 1263 } 1266 1264 1267 1265 1268 1266 /* ************************************************************* 1269 1267 * … … 1271 1269 * 1272 1270 * *********************************************************** */ 1273 1274 1271 1272 1275 1273 /** 1276 1274 * Includes the SimplePie RSS file and sets the cache … … 1287 1285 return $feeds->newSimplePie($feed, $cache, $cache_duration); 1288 1286 } 1289 1290 1287 1288 1291 1289 /** 1292 1290 * Display Hotaru forums feed on Admin front page … … 1316 1314 $feeds->rss($this, $title, $link, $description, $items); 1317 1315 } 1318 1319 1316 1317 1320 1318 /* ************************************************************* 1321 1319 * … … 1323 1321 * 1324 1322 * *********************************************************** */ 1325 1326 1323 1324 1327 1325 /** 1328 1326 * Admin Pages … … 1333 1331 $admin->pages($this, $page); 1334 1332 } 1335 1336 1333 1334 1337 1335 /** 1338 1336 * Admin login/logout … … 1345 1343 return ($action == 'login') ? $admin->adminLogin($this) : $admin->adminLogout($this); 1346 1344 } 1347 1348 1345 1346 1349 1347 /** 1350 1348 * Admin login form … … 1355 1353 $admin->adminLoginForm($this); 1356 1354 } 1357 1358 1355 1356 1359 1357 /* ************************************************************* 1360 1358 * … … 1362 1360 * 1363 1361 * *********************************************************** */ 1364 1365 1362 1363 1366 1364 /** 1367 1365 * Check if site is open or closed. Exit if closed … … 1372 1370 { 1373 1371 if (SITE_OPEN == 'true') { return true; } // site is open, go back and continue 1374 1372 1375 1373 // site closed, but user has admin access so go back and continue as normal 1376 1374 if ($this->currentUser->getPermission('can_access_admin') == 'yes') { return true; } 1377 1375 1378 1376 if ($this->pageName == 'admin_login') { return true; } 1379 1377 1380 1378 $maintenance = new Maintenance(); 1381 1379 return $maintenance->siteClosed($this, $this->lang); // displays "Site Closed for Maintenance" 1382 1380 } 1383 1384 1381 1382 1385 1383 /** 1386 1384 * Open or close the site for maintenance … … 1393 1391 $maintenance->openCloseSite($this, $switch); 1394 1392 } 1395 1396 1393 1394 1397 1395 /** 1398 1396 * Optimize all database tables … … 1403 1401 $maintenance->optimizeTables($this); 1404 1402 } 1405 1406 1403 1404 1407 1405 /** 1408 1406 * Empty plugin database table … … 1416 1414 $maintenance->emptyTable($this, $table_name, $msg); 1417 1415 } 1418 1419 1416 1417 1420 1418 /** 1421 1419 * Delete plugin database table … … 1429 1427 $maintenance->dropTable($this, $table_name, $msg); 1430 1428 } 1431 1432 1429 1430 1433 1431 /** 1434 1432 * Remove plugin settings … … 1442 1440 $maintenance->removeSettings($this, $folder, $msg); 1443 1441 } 1444 1445 1442 1443 1446 1444 /** 1447 1445 * Deletes rows from pluginsettings that match a given setting or plugin … … 1455 1453 $maintenance->deleteSettings($this, $setting, $folder); 1456 1454 } 1457 1458 1455 1456 1459 1457 /** 1460 1458 * Delete all files in the specified directory except placeholder.txt … … 1462 1460 * @param string $dir - path to the cache folder 1463 1461 * @return bool 1464 */ 1462 */ 1465 1463 public function deleteFiles($dir = '') 1466 1464 { … … 1468 1466 return $maintenance->deleteFiles($dir); 1469 1467 } 1470 1471 1468 1469 1472 1470 /** 1473 1471 * Calls the delete_files function, then displays a message. … … 1481 1479 return $maintenance->clearCache($this, $folder, $msg); 1482 1480 } 1483 1484 1481 1482 1485 1483 /** 1486 1484 * Get all files in the specified directory except placeholder.txt … … 1489 1487 * @param array $exclude - array of file/folder names to exclude 1490 1488 * @return array 1491 */ 1489 */ 1492 1490 public function getFiles($dir = '', $exclude = array()) 1493 1491 { … … 1495 1493 return $maintenance->getFiles($dir, $exclude); 1496 1494 } 1497 1498 1499 /** 1495 1496 1497 /** 1500 1498 * System Report is under Debug Functions 1501 1499 */ 1502 1503 1500 1501 1504 1502 /* ************************************************************* 1505 1503 * … … 1507 1505 * 1508 1506 * *********************************************************** */ 1509 1510 1507 1508 1511 1509 /** 1512 1510 * Hotaru CMS Smart Caching 1513 1511 * 1514 * This function does one query on the database to get the last updated time for a 1512 * This function does one query on the database to get the last updated time for a 1515 1513 * specified table. If that time is more recent than the $timeout length (e.g. 10 minutes), 1516 * the database will be used. If there hasn't been an update, any cached results from the 1514 * the database will be used. If there hasn't been an update, any cached results from the 1517 1515 * last 10 minutes will be used. 1518 1516 * … … 1529 1527 return $caching->smartCache($this, $switch, $table, $timeout, $html_sql, $label); 1530 1528 } 1531 1532 1529 1530 1533 1531 /** 1534 1532 * Cache HTML without checking for database updates … … 1546 1544 return $caching->cacheHTML($this, $timeout, $html, $label); 1547 1545 } 1548 1549 1546 1547 1550 1548 /* ************************************************************* 1551 1549 * … … 1553 1551 * 1554 1552 * *********************************************************** */ 1555 1553 1556 1554 /** 1557 1555 * Check if a value is blocked from registration and post submission) … … 1567 1565 return $blocked->isBlocked($this->db, $type, $value, $operator); 1568 1566 } 1569 1570 1567 1568 1571 1569 /** 1572 * Add or update blocked items 1570 * Add or update blocked items 1573 1571 * 1574 1572 * @param string $type - e.g. url, email, ip … … 1605 1603 $language->includeLanguage($this, $folder, $filename); 1606 1604 } 1607 1608 1605 1606 1609 1607 /** 1610 1608 * Include a language file for a theme … … 1614 1612 * Note: the language file should be in a plugin folder named 'languages'. 1615 1613 * '_language.php' is appended automatically to the folder of file name. 1616 */ 1614 */ 1617 1615 public function includeThemeLanguage($filename = 'main') 1618 1616 { … … 1620 1618 $language->includeThemeLanguage($this, $filename); 1621 1619 } 1622 1623 1620 1621 1624 1622 /* ************************************************************* 1625 1623 * … … 1642 1640 return $csrf->csrfInit($this, $type, $script, $life); 1643 1641 } 1644 1645 1642 1643 1646 1644 /* ************************************************************* 1647 1645 * … … 1657 1655 * @param array $post_row - a post already fetched from the db, just needs reading 1658 1656 * @return bool 1659 */ 1657 */ 1660 1658 public function readPost($post_id = 0, $post_row = NULL) 1661 1659 { 1662 1660 return $this->post->readPost($this, $post_id, $post_row); 1663 1661 } 1664 1665 1662 1663 1666 1664 /** 1667 1665 * Gets a single post from the database … … 1669 1667 * @param int $post_id - post id of the post to get 1670 1668 * @return array|false 1671 */ 1669 */ 1672 1670 public function getPost($post_id = 0) 1673 1671 { 1674 1672 return $this->post->getPost($this, $post_id); 1675 1673 } 1676 1677 1674 1675 1678 1676 /** 1679 1677 * Add a post to the database … … 1685 1683 return $this->post->addPost($this); 1686 1684 } 1687 1688 1685 1686 1689 1687 /** 1690 1688 * Update a post in the database 1691 1689 * 1692 1690 * @return true 1693 */ 1691 */ 1694 1692 public function updatePost() 1695 1693 { 1696 1694 $this->post->updatePost($this); 1697 1695 } 1698 1699 1700 /** 1701 * Physically delete a post from the database 1696 1697 1698 /** 1699 * Physically delete a post from the database 1702 1700 * 1703 1701 * There's a plugin hook in here to delete their parts, e.g. votes, coments, tags, etc. 1704 */ 1702 */ 1705 1703 public function deletePost() 1706 1704 { 1707 1705 $this->post->deletePost($this); 1708 1706 } 1709 1710 1707 1708 1711 1709 /** 1712 1710 * Physically delete all posts by a specified user … … 1715 1713 * @return bool 1716 1714 */ 1717 public function deletePosts($user_id = 0) 1715 public function deletePosts($user_id = 0) 1718 1716 { 1719 1717 return $this->post->deletePosts($this, $user_id); 1720 1718 } 1721 1722 1719 1720 1723 1721 /** 1724 1722 * Delete posts with "processing" status that are older than 30 minutes … … 1729 1727 $this->post->deleteProcessingPosts($this); 1730 1728 } 1731 1732 1729 1730 1733 1731 /** 1734 1732 * Update a post's status … … 1737 1735 * @param int $post_id (optional) 1738 1736 * @return true 1739 */ 1737 */ 1740 1738 public function changePostStatus($status = "processing", $post_id = 0) 1741 1739 { 1742 1740 return $this->post->changePostStatus($this, $status, $post_id); 1743 1741 } 1744 1745 1742 1743 1746 1744 /** 1747 1745 * Count how many approved posts a user has had … … 1749 1747 * @param int $userid (optional) 1750 1748 * @param int $post_type (optional) 1751 * @return int 1749 * @return int 1752 1750 */ 1753 1751 public function postsApproved($userid = 0, $post_type = 'news') … … 1755 1753 return $this->post->postsApproved($this, $userid, $post_type); 1756 1754 } 1757 1758 1755 1756 1759 1757 /** 1760 1758 * Count posts in the last X hours/minutes for this user … … 1764 1762 * @param int $user_id (optional) 1765 1763 * @param int $post_type (optional) 1766 * @return int 1764 * @return int 1767 1765 */ 1768 1766 public function countPosts($hours = 0, $minutes = 0, $user_id = 0, $post_type = 'news') … … 1770 1768 return $this->post->countPosts($this, $hours, $minutes, $user_id, $post_type); 1771 1769 } 1772 1773 1770 1771 1774 1772 /** 1775 1773 * Checks for existence of a url 1776 1774 * 1777 1775 * @return array|false - array containing existing post 1778 */ 1776 */ 1779 1777 public function urlExists($url = '') 1780 1778 { 1781 1779 return $this->post->urlExists($this, $url); 1782 1780 } 1783 1784 1781 1782 1785 1783 /** 1786 1784 * Checks for existence of a title … … 1793 1791 return $this->post->titleExists($this, $title); 1794 1792 } 1795 1796 1793 1794 1797 1795 /** 1798 1796 * Checks for existence of a post with given post_url … … 1805 1803 return $this->post->isPostUrl($this, $post_url); 1806 1804 } 1807 1808 1805 1806 1809 1807 /** 1810 1808 * Get Unique Post Statuses … … 1812 1810 * @return array|false 1813 1811 */ 1814 public function getUniqueStatuses() 1812 public function getUniqueStatuses() 1815 1813 { 1816 1814 return $this->post->getUniqueStatuses($this); 1817 1815 } 1818 1819 1816 1817 1820 1818 /** 1821 1819 * Prepares and calls functions to send a trackback … … 1827 1825 return $trackback->sendTrackback($this); 1828 1826 } 1829 1830 1827 1828 1831 1829 /* ************************************************************* 1832 1830 * … … 1834 1832 * 1835 1833 * *********************************************************** */ 1836 1834 1837 1835 1838 1836 /** … … 1848 1846 return $this->avatar = new Avatar($this, $user_id, $size, $rating); 1849 1847 } 1850 1851 1848 1849 1852 1850 /** 1853 1851 * get the plain avatar with no surrounding HTML div … … 1859 1857 return $this->avatar->getAvatar($this); 1860 1858 } 1861 1862 1859 1860 1863 1861 /** 1864 1862 * option to display the avatar linked to ther user's profile … … 1870 1868 return $this->avatar->linkAvatar($this); 1871 1869 } 1872 1873 1870 1871 1874 1872 /** 1875 1873 * option to display the profile-linked avatar wrapped in a div … … 1881 1879 return $this->avatar->wrapAvatar($this); 1882 1880 } 1883 1884 1881 1882 1885 1883 /* ************************************************************* 1886 1884 * … … 1900 1898 return $category->getCatId($this, $cat_safe_name); 1901 1899 } 1902 1903 1900 1901 1904 1902 /** 1905 1903 * Returns the category name for a given category id or safe name. … … 1914 1912 return $category->getCatName($this, $cat_id, $cat_safe_name); 1915 1913 } 1916 1917 1918 /** 1919 * Returns the category safe name for a given category id 1914 1915 1916 /** 1917 * Returns the category safe name for a given category id 1920 1918 * 1921 1919 * @param int $cat_id … … 1927 1925 return $category->getCatSafeName($this, $cat_id); 1928 1926 } 1929 1930 1927 1928 1931 1929 /** 1932 1930 * Returns parent id … … 1940 1938 return $category->getCatParent($this, $cat_id); 1941 1939 } 1942 1943 1940 1941 1944 1942 /** 1945 1943 * Returns child ids … … 1953 1951 return $category->getCatChildren($this, $cat_parent_id); 1954 1952 } 1955 1953 1956 1954 /** 1957 1955 * Returns Category list ids … … 1965 1963 return $category->getCategories($this, $args); 1966 1964 } 1967 1968 1965 1966 1969 1967 /** 1970 1968 * Returns meta description and keywords for the category (if available) … … 2039 2037 return $comment->countComments($this, $digits_only, $no_comments_text); 2040 2038 } 2041 2042 2039 2040 2043 2041 /** 2044 2042 * Count all user comments … … 2052 2050 return $comment->countUserComments($this, $user_id); 2053 2051 } 2054 2055 2052 2053 2056 2054 /** 2057 2055 * Physically delete all comments by a specified user (and responses) … … 2060 2058 * @return bool 2061 2059 */ 2062 public function deleteComments($user_id) 2060 public function deleteComments($user_id) 2063 2061 { 2064 2062 $comment = new Comment(); 2065 2063 return $comment->deleteComments($this, $user_id); 2066 2064 } 2067 2068 2065 2066 2069 2067 /** 2070 2068 * Get comment from database … … 2078 2076 return $comment->getComment($this, $comment_id); 2079 2077 } 2080 2081 2078 2079 2082 2080 /** 2083 2081 * Read comment … … 2090 2088 return $comment->readComment($this, $comment_row); 2091 2089 } 2092 2093 2090 2091 2094 2092 /* ************************************************************* 2095 2093 * … … 2110 2108 $widget->addWidget($this, $plugin, $function, $args); 2111 2109 } 2112 2110 2113 2111 2114 2112 /** 2115 2113 * Get widgets from widgets_settings array 2116 2114 * 2117 * USAGE: foreach ($widgets as $widget=>$details) 2118 * { echo "Name: " . $widget; echo $details['order']; echo $details['args']; } 2119 * 2115 * USAGE: foreach ($widgets as $widget=>$details) 2116 * { echo "Name: " . $widget; echo $details['order']; echo $details['args']; } 2117 * 2120 2118 * @param $widget_name - optional for a single widget 2121 2119 * @return array - of widgets … … 2126 2124 return $widget->getArrayWidgets($this, $widget_name); 2127 2125 } 2128 2129 2126 2127 2130 2128 /** 2131 2129 * Delete a widget from the widget db table … … 2139 2137 $widget->deleteWidget($this, $function, $plugin); 2140 2138 } 2141 2142 2139 2140 2143 2141 /** 2144 2142 * Get plugin name from widget function name … … 2151 2149 return $widget->getPluginFromFunction($this, $function); 2152 2150 } 2153 2154 2151 2152 2155 2153 /* ************************************************************* 2156 2154 * … … 2158 2156 * 2159 2157 * *********************************************************** */ 2160 2158 2161 2159 /** 2162 2160 * Send emails … … 2173 2171 return EmailFunctions::email($to, $subject, $body, $from, $headers); 2174 2172 } 2175 2176 2173 2174 2177 2175 /* ************************************************************* 2178 2176 * … … 2192 2190 return $friends->countFriends($this, $user_id, 'follower'); 2193 2191 } 2194 2195 2192 2193 2196 2194 /** 2197 2195 * count following … … 2205 2203 return $friends->countFriends($this, $user_id, 'following'); 2206 2204 } 2207 2208 2205 2206 2209 2207 /** 2210 2208 * get followers … … 2219 2217 return $friends->getFriends($this, $user_id, 'follower', $return); 2220 2218 } 2221 2222 2219 2220 2223 2221 /** 2224 2222 * get people this user is following … … 2233 2231 return $friends->getFriends($this, $user_id, 'following', $return); 2234 2232 } 2235 2236 2233 2234 2237 2235 /** 2238 2236 * Is current user being followed by user X? … … 2246 2244 return $friends->checkFriends($this, $user_id, 'follower'); 2247 2245 } 2248 2249 2246 2247 2250 2248 /** 2251 2249 * Is current user following user X? … … 2259 2257 return $friends->checkFriends($this, $user_id, 'following'); 2260 2258 } 2261 2262 2259 2260 2263 2261 /** 2264 2262 * Follow / become a fan of user X … … 2272 2270 return $friends->updateFriends($this, $user_id, 'follow'); 2273 2271 } 2274 2275 2272 2273 2276 2274 /** 2277 2275 * Unfollow / stop being a fan of user X … … 2285 2283 return $friends->updateFriends($this, $user_id, 'unfollow'); 2286 2284 } 2287 2288 2285 2286 2289 2287 /* ************************************************************* 2290 2288 * … … 2292 2290 * 2293 2291 * *********************************************************** */ 2294 2295 2292 2293 2296 2294 /** 2297 2295 * Get the latest site activity … … 2307 2305 return $activity->getLatestActivity($this, $limit, $userid, $type); 2308 2306 } 2309 2310 2307 2308 2311 2309 /** 2312 2310 * Check if an action already exists … … 2320 2318 return $activity->activityExists($this, $args); 2321 2319 } 2322 2323 2320 2321 2324 2322 /** 2325 2323 * Insert new activity … … 2332 2330 return $activity->insertActivity($this, $args); 2333 2331 } 2334 2335 2332 2333 2336 2334 /** 2337 2335 * Update activity … … 2344 2342 return $activity->updateActivity($this, $args); 2345 2343 } 2346 2347 2344 2345 2348 2346 /** 2349 2347 * Remove activity … … 2356 2354 return $activity->removeActivity($this, $args); 2357 2355 } 2358 2359 2356 2357 2360 2358 /* ************************************************************* 2361 2359 * … … 2363 2361 * 2364 2362 * *********************************************************** */ 2365 2363 2366 2364 2367 2365 /** … … 2377 2375 return $pm->getMessages($this, $box, $type); 2378 2376 } 2379 2380 2377 2378 2381 2379 /** 2382 2380 * Get Message … … 2390 2388 return $pm->getMessage($this, $message_id); 2391 2389 } 2392 2393 2390 2391 2394 2392 /** 2395 2393 * Mark message as read … … 2402 2400 $pm->markRead($this, $message_id); 2403 2401 } 2404 2405 2402 2403 2406 2404 /** 2407 2405 * Delete Message … … 2416 2414 $pm->deleteMessage($this, $message_id, $box); 2417 2415 } 2418 2419 2416 2417 2420 2418 /** 2421 2419 * Send Message … … 2439 2437 * 2440 2438 * *********************************************************** */ 2441 2442 2443 /** 2444 * Get Individual Vote Rating 2439 2440 2441 /** 2442 * Get Individual Vote Rating 2445 2443 * 2446 2444 * @param int $post_id