- Timestamp:
- 11/19/10 15:04:13 (18 months ago)
- Location:
- trunk
- Files:
-
- 2 removed
- 32 modified
- 1 copied
-
. (modified) (1 prop)
-
Hotaru.php (modified) (3 diffs)
-
READ_ME.txt (modified) (1 diff)
-
content/admin_language.php (modified) (3 diffs)
-
content/admin_themes/admin_default/admin_header.php (modified) (2 diffs)
-
content/admin_themes/admin_default/admin_home.php (modified) (1 diff)
-
content/admin_themes/admin_default/plugin_management.php (modified) (6 diffs)
-
content/admin_themes/admin_default/settings.php (modified) (1 diff)
-
content/themes/default/header.php (modified) (1 diff)
-
content/themes/default/settings.php (modified) (1 diff)
-
functions/funcs.http.php (copied) (copied from branches/1.4/functions/funcs.http.php)
-
hotaru_settings_default.php (modified) (1 diff)
-
install/index.php (modified) (11 diffs)
-
install/install-upgrade.php (modified) (4 diffs)
-
install/install_functions.php (modified) (1 diff)
-
install/install_language.php (modified) (2 diffs)
-
install/install_tables.php (modified) (21 diffs)
-
libs/AdminPages.php (modified) (1 diff)
-
libs/Announcements.php (modified) (1 diff)
-
libs/Debug.php (modified) (1 diff)
-
libs/EmailFunctions.php (modified) (1 diff)
-
libs/IncludeCssJs.php (modified) (1 diff)
-
libs/Initialize.php (modified) (12 diffs)
-
libs/InspektExtras.php (modified) (2 diffs)
-
libs/Language.php (modified) (1 diff)
-
libs/PageHandling.php (modified) (2 diffs)
-
libs/PluginManagement.php (modified) (4 diffs)
-
libs/SystemInfo.php (modified) (6 diffs)
-
libs/Trackback.php (modified) (2 diffs)
-
libs/UserAuth.php (modified) (3 diffs)
-
libs/Widget.php (modified) (1 diff)
-
libs/extensions/Inspekt/Inspekt/Inspekt_CageTest.php (deleted)
-
libs/extensions/SWCMS/HotaruHttpRequest.php (modified) (1 diff)
-
libs/extensions/ezSQL/mysql/ez_sql_mysql.php (modified) (2 diffs)
-
libs/extensions/pclZip (deleted)
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/1.4 merged: 2206-2231
- Property svn:mergeinfo changed
-
trunk/Hotaru.php
r2134 r2233 26 26 class Hotaru 27 27 { 28 protected $version = "1.4. 1"; // Hotaru CMS version28 protected $version = "1.4.2"; // 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 … … 73 73 // define shorthand paths 74 74 if (!defined('BASE')) { 75 define("BASE", dirname(__FILE__). '/'); 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/'); 75 define("BASE", dirname(__FILE__). '/'); 76 define("CACHE", dirname(__FILE__).'/cache/'); 77 define("ADMIN", dirname(__FILE__).'/admin/'); 78 define("INSTALL", dirname(__FILE__).'/install/'); 79 define("LIBS", dirname(__FILE__).'/libs/'); 80 define("EXTENSIONS", dirname(__FILE__).'/libs/extensions/'); 81 define("FUNCTIONS", dirname(__FILE__).'/functions/'); 82 define("CONTENT", dirname(__FILE__).'/content/'); 83 define("THEMES", dirname(__FILE__).'/content/themes/'); 84 define("PLUGINS", dirname(__FILE__).'/content/plugins/'); 85 define("ADMIN_THEMES", dirname(__FILE__).'/content/admin_themes/'); 86 define("SITEURL", BASEURL); 85 87 } 86 88 … … 1489 1491 { 1490 1492 $maintenance = new Maintenance(); 1491 $maintenance->deleteFiles($dir);1493 return $maintenance->deleteFiles($dir); 1492 1494 } 1493 1495 -
trunk/READ_ME.txt
r2134 r2233 1 1 HOTARU CMS 2 Version: 1.4.1 3 Released: August 14th 2010 2 ========== 3 Version: 1.4.2 4 Released: Nov. 20th, 2010 4 5 5 I NSTALLATION6 Installation 6 7 ------------ 7 8 8 Please visit http://hotarudocs.com/Getting_Started#Installing_and_Upgrading for the most up-to-date version of these instructions. 9 Please visit http://docs.hotarucms.org/Getting_Started#Installing_and_Upgrading for 10 the most up-to-date version of these instructions. 9 11 10 12 Instructions last updated: Mar 8th 2010 11 13 12 14 Requirements 15 ------------ 13 16 14 Hotaru CMS has been tested using PHP 5.2.5 ~ 5.3.2 and MySQL 5.0~. 17 Hotaru CMS has been tested using PHP 5.2.5 ~ 5.3.2 and MySQL 5.0~. 15 18 16 19 Upgrading 20 --------- 17 21 18 1. Backup your database. 19 2. Download the latest version of Hotaru CMS. 20 3. Turn off all your plugins. 21 4. Overwrite ALL the old files. If you've made any customizations, read this first: http://hotarudocs.com/File_Organization 22 5. Go to /install/upgrade.php and follow the steps 23 6. Turn your plugins back on 24 7. Reactivate your widgets 25 8. When finished, delete the install folder. 22 1. Backup your database. 23 2. Download the latest version of Hotaru CMS. 24 3. Turn off all your plugins. 25 4. Overwrite ALL the old files. If you've made any customizations, read this 26 first: http://docs.hotarucms.org/File_Organization 27 5. Go to /install/upgrade.php and follow the steps 28 6. Turn your plugins back on 29 7. Reactivate your widgets 30 8. When finished, delete the install folder. 26 31 27 32 First-time Installation 33 ----------------------- 28 34 29 1. Download the latest version of Hotaru CMS. 30 2. Create a database called "hotaru" in phpMyAdmin (or equivalent). 31 3. Rename /hotaru_settings_default.php to /hotaru_settings.php. 32 4. Open /hotaru_settings.php and edit the top section with your database details and path to Hotaru, e.g. http://example.com/ 33 5. Upload the contents of the "hotaru" folder to your server. 34 6. Files should have permissions set to 644 and folders should be set to 755, except... 35 7. Set /cache and its sub-folders to 777 36 8. Go to /install/install.php and follow the steps 37 9. When finished, delete the install folder. 35 1. Download the latest version of Hotaru CMS. 36 2. Create a database called `hotaru` in phpMyAdmin (or equivalent). 37 3. Rename `/hotaru_settings_default.php` to `/hotaru_settings.php`. 38 4. Open `/hotaru_settings.php` and edit the top section with your database 39 details and path to Hotaru, e.g. http://example.com/ 40 5. Upload the contents of the `hotaru` folder to your server. 41 6. Files should have permissions set to 644 and folders should be set to 755, 42 except... 43 7. Set `/cache` and its sub-folders to 777 44 8. Go to `/install/install.php` and follow the steps 45 9. When finished, delete the install folder. 38 46 39 47 Setting up your site 48 -------------------- 40 49 41 1. Log into Admin and go to Admin -> Settings 42 2. Change the settings as appropriate, but leave DB_CACHE off for now. 43 3. Download plugins from the Plugin Downloads forum, unzip and upload them to the /content/plugins/ directory. 44 4. Go to Admin -> Plugin Management and install the plugins one by one. 45 5. Edit settings for each plugin listed in the sidebar under Plugin Settings. 46 6. Click the site title/banner to view your changes. 47 7. When finished, return to Admin -> Settings and set DB_CACHE to true. 50 1. Log into Admin and go to **Admin -> Settings** 51 2. Change the settings as appropriate, but leave `DB_CACHE` off for now. 52 3. Download plugins from the Plugin Downloads forum, unzip and upload them to 53 the `/content/plugins/` directory. 54 4. Go to **Admin -> Plugin Management** and install the plugins one by one. 55 5. Edit settings for each plugin listed in the sidebar under Plugin Settings. 56 6. Click the site title/banner to view your changes. 57 7. When finished, return to **Admin -> Settings** and set `DB_CACHE` to true. 48 58 49 59 50 60 Friendly URLS 61 ------------- 51 62 52 If you want to use friendly urls, rename htaccess_default to .htaccess, and edit it according to the instructions within the htaccess file. Then go to Admin -> Settings and change the "friendly urls" setting to true. 63 If you want to use friendly urls, rename `htaccess_default` to `.htaccess`, and 64 edit it according to the instructions within the htaccess file. Then go 65 to **Admin -> Settings** and change the **Friendly URLs** setting to true. 53 66 54 67 Troubleshooting 68 --------------- 55 69 56 If you're having trouble installing Hotaru, please post your questions with as much detail as possible in the forums at http://hotarucms.org. Thanks. 70 If you're having trouble installing Hotaru, please post your questions with as 71 much detail as possible in the forums at http://hotarucms.org. Thanks. -
trunk/content/admin_language.php
r2134 r2233 103 103 $lang["admin_theme_plugins_order_down"] = "Move down"; 104 104 $lang["admin_theme_plugins_details"] = "Details"; 105 $lang["admin_theme_plugins_update_available"] = "Update available";106 105 $lang["admin_theme_plugins_requires"] = "Requires"; 107 106 $lang["admin_theme_plugins_description"] = "Description"; … … 114 113 $lang["admin_theme_plugins_guide3"] = "Uninstalling a plugin will delete it from the <i>plugins</i> and <i>pluginhooks</i> tables, but not <i>pluginsettings</i>."; 115 114 $lang["admin_theme_plugins_guide4"] = "Any other database entries created by the plugin will not be removed."; 116 $lang["admin_theme_plugins_guide5"] = "If <i>SYS_UPDATES</i> is enabled in Settings, click \"Update\" to check if plugin updates are available."; 115 117 116 $lang["admin_theme_plugins_deactivate_all"] = "Turn OFF all plugins"; 118 117 $lang["admin_theme_plugins_activate_all"] = "Turn ON (upgrade) all plugins"; … … 263 262 264 263 /* footer */ 265 $lang["admin_theme_footer_having_trouble_vist_forums"] = "Having trouble? Read the <a href='http:// hotarudocs.com'>Documentation</a> or ask for help in the <a href='http://forums.hotarucms.org'>Forums</a>.";264 $lang["admin_theme_footer_having_trouble_vist_forums"] = "Having trouble? Read the <a href='http://docs.hotarucms.org'>Documentation</a> or ask for help in the <a href='http://forums.hotarucms.org'>Forums</a>."; 266 265 267 266 /* 404 */ -
trunk/content/admin_themes/admin_default/admin_header.php
r2134 r2233 87 87 </a> 88 88 </div> 89 <!-- <div onmouseout="javascript:$(this).removeClass('admin-menu-item-active');" onmouseover="javascript:$(this).addClass('admin-menu-item-active');" class="admin-menu-item"> 90 <a href="http://hotaruplugins.com"> 91 <div class="admin-menu-item-icon"> 92 <img src="/images/icons/plugins.png"> 93 </div> 94 <div class="admin-menu-item-text">Plugins</div> 95 </a> 96 </div>--> 89 97 90 <div class="admin-menu-item"> 98 <a href="http:// hotarudocs.com">91 <a href="http://docs.hotarucms.org"> 99 92 <div class="admin-menu-item-icon"> 100 93 <img src="<?php echo SITEURL; ?>content/admin_themes/admin_default/images/docs_icon.png" /> … … 105 98 <?php if ($h->currentUser->loggedIn) { ?> 106 99 <div class="admin-menu-item"> 107 <a href="<?php echo $h->url(array('page'=>'admin_logout') ); ?>">100 <a href="<?php echo $h->url(array('page'=>'admin_logout'), 'admin'); ?>"> 108 101 <div class="admin-menu-item-icon"> 109 102 <img src="<?php echo SITEURL; ?>content/admin_themes/admin_default/images/logout_icon.png" /> -
trunk/content/admin_themes/admin_default/admin_home.php
r2080 r2233 54 54 <li>Hotaru CMS <?php echo $h->version; ?></li> 55 55 56 <?php57 58 $sql = "SELECT miscdata_value as latest_version FROM " . TABLE_MISCDATA ." WHERE miscdata_key = %s";59 $query = $h->db->get_row($h->db->prepare($sql, 'hotaru_latest_version'));60 if ($query) {61 $hotaru_latest_version = $query->latest_version;62 if (version_compare($hotaru_latest_version, $h->version) > 0) {63 echo "<li><a href='http://hotarucms.org/forumdisplay.php?23-Download-Hotaru-CMS'>" . $h->lang['admin_theme_version_update_to'] . $hotaru_latest_version . "</a></li>";64 }65 }66 ?>67 68 56 <?php $h->pluginHook('admin_theme_main_stats_post_version'); ?> 69 57 <?php $h->pluginHook('admin_theme_main_stats', 'users', array('users' => array('all', 'admin', 'supermod', 'moderator', 'member', 'undermod', 'pending', 'banned', 'killspammed'))); ?> -
trunk/content/admin_themes/admin_default/plugin_management.php
r2134 r2233 56 56 <?php echo $h->lang["admin_theme_plugins_details"]; ?> 57 57 58 <img src='<?php echo SITEURL; ?>content/admin_themes/<?php echo ADMIN_THEME; ?>images/info_green_16.png' alt="">59 <?php echo $h->lang["admin_theme_plugins_update_available"]; ?>60 61 58 <img src='<?php echo SITEURL; ?>content/admin_themes/<?php echo ADMIN_THEME; ?>images/uninstall_16.png' alt=""> 62 59 <?php echo $h->lang["admin_theme_plugins_uninstall"]; ?> 63 64 65 <?php if (SYS_UPDATES == "true") { ?>66 <div class="plugin_management_right">67 <!--68 <a href="<?php echo SITEURL ?>admin_index.php?page=plugin_search">69 <img src='<?php echo SITEURL; ?>content/admin_themes/<?php echo ADMIN_THEME; ?>images/search.png' alt="">70 <?php echo $h->lang["admin_theme_search"]; ?>71 </a>72 -->73 74 <a href="<?php echo SITEURL ?>admin_index.php?page=plugin_management&action=version_check">75 <img src='<?php echo SITEURL; ?>content/admin_themes/<?php echo ADMIN_THEME; ?>images/update_16.png' alt="">76 <?php echo $h->lang["admin_theme_check_latest_plugin_versions"]; ?>77 </a>78 </div>79 <?php } ?>80 81 60 </span> 82 61 </td></tr> … … 96 75 $alt = 0; 97 76 if (!$the_plugins) { $the_plugins = array(); } 98 foreach ($the_plugins as $plug) { 77 foreach ($the_plugins as $plug) { 99 78 $alt++; 100 79 $info_icon = 'info_16.png'; 101 $update = false; 102 if (isset($plug['latestversion'])) { if ($plug['latestversion'] > $plug['version']) {$update=true; $info_icon = 'info_green_16.png'; }} 80 103 81 echo "<tr class='table_tr table_row_" . $alt % 2 . "'>\n"; 104 82 echo "<td class='table_active'>" . $plug['active'] . "</td>\n"; … … 132 110 } 133 111 134 if ($update) { echo "<br/><a href='" . SITEURL . "admin_index.php?page=plugin_management&action=update&plugin=". $plug['folder'] . "&version=" . $plug['latestversion'] . "' title=''>Update this plugin</a>"; }135 112 echo "</td>"; 136 113 echo "<td class='table_description_close'><a class='table_hide_details' href='#'>"; … … 195 172 $alt++; 196 173 $info_icon = 'info_16.png'; 197 $update = false; 198 if (isset($plug['latestversion'])) { if ($plug['latestversion'] > $plug['version']) {$update = true; $info_icon = 'info_green_16.png'; }} 174 199 175 echo "<tr id='table_tr' class='table_row_" . $alt % 2 . "'>\n"; 200 176 echo "<td class='table_uninstalled_plugin'>" . $plug['name'] . " " . $plug['version'] . "<br />\n"; … … 220 196 echo $h->lang["admin_theme_plugins_readmetxt"] . "</a>"; 221 197 } 222 if ($update) echo "<br/><a href='" . SITEURL . "admin_index.php?page=plugin_management&action=update&plugin=". $plug['folder'] . "&version=" . $plug['latestversion'] . "' title=''>Update this plugin</a>"; 198 223 199 echo "</td>\n"; 224 200 echo "<td class='table_description_close'><a class='table_hide_details' href='#'>"; … … 241 217 <div id="plugin_management_notice" class="info_box gray_box" style="margin-top: 2.0em";> 242 218 <p class="info_header"><?php echo $h->lang["admin_theme_plugins_guide"]; ?></p> 243 <?php $h->pluginHook('plugins_guide_top'); ?>244 219 » <?php echo $h->lang["admin_theme_plugins_guide1"]; ?><br /> 245 220 » <?php echo $h->lang["admin_theme_plugins_guide2"]; ?><br /> 246 221 » <?php echo $h->lang["admin_theme_plugins_guide3"]; ?><br /> 247 222 » <?php echo $h->lang["admin_theme_plugins_guide4"]; ?><br /> 248 <?php $h->pluginHook('plugins_guide_bottom'); ?>249 223 </div> 250 251 252 253 <?php $h->pluginHook('plugins_bottom'); ?>254 255 256 <?php257 258 259 ?> -
trunk/content/admin_themes/admin_default/settings.php
r2134 r2233 51 51 { 52 52 if ($ls->settings_show == 'N') { continue; } // skip this row 53 if ($ls->settings_name == 'MULTI_SITE' && SITEID !=1) { continue; } // skip this row54 53 55 54 // replace underscores with spaces and make the first character of the setting name uppercase. -
trunk/content/themes/default/header.php
r2134 r2233 40 40 // plugin hook 41 41 $result = $h->pluginHook('header_meta'); 42 if (! isset($result) || !is_array($result)) { ?>42 if (!$result) { ?> 43 43 <meta name="description" content="<?php echo $h->lang['header_meta_description']; ?>" /> 44 44 <meta name="keywords" content="<?php echo $h->lang['header_meta_keywords']; ?>" /> -
trunk/content/themes/default/settings.php
r2080 r2233 32 32 33 33 // Default settings: 34 $defaults['tagline'] = " Social Bookmarking";34 $defaults['tagline'] = "Possibly the greatest site on the Internet."; 35 35 36 36 // Get settings from database if they exist... -
trunk/hotaru_settings_default.php
r1896 r2233 3 3 4 4 // Paths 5 define('BASEURL', "http://example.com/"); // e.g. http://example.com/ (needs trailing cache)5 define('BASEURL', "http://example.com/"); // e.g. http://example.com/ (needs trailing slash) 6 6 7 7 // Database details -
trunk/install/index.php
r2080 r2233 47 47 "ADMIN" => "/../admin/", 48 48 "INSTALL" => "/", 49 "CACHE" => "/../cache/ 1/",49 "CACHE" => "/../cache/", 50 50 "LIBS" => "/../libs/", 51 51 "EXTENSIONS" => "/../libs/extensions/", … … 102 102 } else { 103 103 $db = init_database(); 104 database_creation( ); // Creates the database tables104 database_creation($h); // Creates the database tables 105 105 } 106 106 break; … … 225 225 global $db; 226 226 global $h; 227 global $cage;228 global $settings_file_exists;227 global $cage; 228 global $settings_file_exists; 229 229 230 230 //$h = new Hotaru(); // overwrites current global with fully initialized Hotaru object … … 470 470 * Step 2 of installation - Creates database tables 471 471 */ 472 function database_creation( )472 function database_creation($h) 473 473 { 474 474 global $lang; … … 575 575 // Make sure that the cache folders have been created before we call $h for the first time 576 576 // Since we have defined CACHE in install script, the normal Initialize script will think folders are already present 577 $dirs = array(' ', 'debug_logs/' , 'db_cache/', 'css_js_cache/', 'html_cache/', 'rss_cache/', 'lang_cache/'); // first array item is needed to create the SITEID base folder577 $dirs = array('debug_logs/' , 'db_cache/', 'css_js_cache/', 'html_cache/', 'rss_cache/', 'lang_cache/'); 578 578 579 579 foreach ($dirs as $dir) { … … 594 594 595 595 // Step content 596 echo "<div class='install_content'>" . $lang['install_step3_instructions'] . ":<br /> \n";596 echo "<div class='install_content'>" . $lang['install_step3_instructions'] . ":<br /><br />\n"; 597 597 598 598 $error = 0; … … 749 749 750 750 $phpinfo = $cage->post->getAlpha('phpinfo'); // delete install folder. 751 $delete = $cage->post->getAlpha('delete'); // delete install folder. 752 753 $folder_deleted = 0; 754 755 if ($delete) { 756 // try to delete the folder 757 //$folder_deleted = delTree('install'); 758 $folder_deleted = 2; 759 // if was deleted then redirect to baseurl 760 if ($folder_deleted == 1) header("Location: /index.php" ); 761 } 762 763 if (!$delete && !$phpinfo) { 764 //send feedback report 765 $systeminfo = new SystemInfo(); 766 $systeminfo->hotaru_feedback($h); 751 752 if (!$phpinfo) { 753 //send feedback report 754 $systeminfo = new SystemInfo(); 755 $systeminfo->hotaru_feedback($h); 767 756 } 768 757 … … 773 762 774 763 // Step content 775 776 if ($folder_deleted == 0) echo "<div class='install_content'>" . $lang['install_step4_installation_complete'] . "</div>\n"; 764 echo "<div class='install_content'>" . $lang['install_step4_installation_complete'] . "</div>\n"; 777 765 echo "<div class='install_content'>" . $lang['install_step4_installation_delete'] . "</div>\n"; 778 766 … … 784 772 $php_module_not_found = false; 785 773 786 $required = array('mysql'=>'http://php.net/manual/en/book.mysql.php', 787 'filter'=>'http://php.net/manual/en/book.filter.php', 788 'mbstring'=>'http://www.php.net/manual/en/book.mbstring.php'); 789 774 $required = array( 775 'mysql'=>'http://php.net/manual/en/book.mysql.php', 776 'filter'=>'http://php.net/manual/en/book.filter.php', 777 'curl'=>'http://php.net/manual/en/book.curl.php', 778 'mbstring'=>'http://www.php.net/manual/en/book.mbstring.php'); 779 790 780 /* No longer required: 'bcmath' => 'http://php.net/manual/en/book.bc.php' */ 791 781 … … 811 801 } 812 802 813 if ($folder_deleted == 0) {814 // Confirm delete and continue install815 echo "<div class='install_content'>" . $lang['install_step4_installation_delete_folder'] . "</div>\n";816 echo "<form name='install_admin_reg_form' action='index.php?step=4' method='post'>\n";817 echo "<input type='hidden' name='delete' value='folder' />";818 echo "<input type='hidden' name='step' value='4' />";819 820 echo "<input class='update button' type='submit' value='" . $lang['install_step4_form_delete_folder'] . "' />";821 echo "</div></form>\n";822 } else {823 echo "<br/><img src='../content/admin_themes/admin_default/images/delete.png' style='float:left; margin-left:12px;'>";824 echo "<div class='install_content'><span style='color: red;'>" . $lang['install_step1_warning'] . "</span>: " . $lang['install_step4_installation_delete_failed'] . "</div>\n";825 }826 827 803 echo "<br/><div class='install_content'>" . $lang['install_step4_installation_go_play'] . "</div><br/><br/>\n"; 828 804 … … 853 829 $systeminfo = new SystemInfo(); 854 830 $systeminfo->hotaru_feedback($h); 855 856 //refresh database to get all recent plugin versions857 $systeminfo->plugin_version_getAll($h);858 859 // $plugins = $h->allPluginDetails;860 //861 // foreach ($plugins as $plugin) {862 // if (key($plugin) != 'hooks') {863 // if ($plugin->plugin_latestversion > $plugin->plugin_version) {864 // echo "<b>" . $plugin->plugin_name . "</b> requires an update to <span class='red'>version " . $plugin->plugin_latestversion . "</span><br/>";865 // } else {866 // echo "<b>" . $plugin->plugin_name . "</b> is up to date at version " . $plugin->plugin_version . " <br/>";867 // }868 // }869 // }870 831 871 832 echo "<br/>" . $lang['upgrade_step3_instructions'] . "<br/><br/>\n"; -
trunk/install/install-upgrade.php
r2134 r2233 378 378 if ($old_version == "1.1.2") { 379 379 380 // System Feedback381 $sql = "SELECT settings_name FROM " . TABLE_SETTINGS . " WHERE settings_name = %s";382 $result = $h->db->get_var($h->db->prepare($sql, 'SYS_FEEDBACK'));383 if(!$result) {384 $sql = "INSERT INTO " . TABLE_SETTINGS . " (settings_name, settings_value, settings_default, settings_note) VALUES (%s, %s, %s, %s)";385 $h->db->query($h->db->prepare($sql, 'SYS_FEEDBACK', 'true', 'true', 'Send system report'));386 }387 388 380 // Remove ON from constant names 389 381 $sql = "UPDATE " . TABLE_SETTINGS . " SET settings_name = %s WHERE settings_name = %s"; … … 533 525 } 534 526 535 // SITE TABLE - for multiple sites 536 if (!$exists = $h->db->table_exists('site')) { 537 $sql = "CREATE TABLE `" . DB_PREFIX . "site` ( 538 `site_id` int(20) NOT NULL AUTO_INCREMENT PRIMARY KEY, 539 `site_adminuser_id` varchar(64) NULL, 540 `site_url` varchar(128) NOT NULL DEFAULT '', 541 `site_updatedts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 542 `site_updateby` int(20) NOT NULL DEFAULT 0 543 ) ENGINE=" . DB_ENGINE . " DEFAULT CHARSET=" . DB_CHARSET . " COLLATE=" . DB_COLLATE . " COMMENT='Site Table';"; 544 $h->db->query($sql); 545 } 546 547 //Add site_id column and index to each table 527 // reorder the admin settings 528 $desired_order = array('SITE_OPEN', 'SITE_NAME', 'THEME', 'ADMIN_THEME', 'DEBUG', 'FRIENDLY_URLS', 'DB_CACHE', 'DB_CACHE_DURATION', 'CSS_JS_CACHE', 'HTML_CACHE', 'LANG_CACHE', 'RSS_CACHE', 'RSS_CACHE_DURATION', 'SITE_EMAIL', 'SMTP', 'SMTP_HOST', 'SMTP_PORT', 'SMTP_USERNAME', 'SMTP_PASSWORD'); 529 $sql = "SELECT * FROM " . TABLE_SETTINGS; 530 $results = $h->db->get_results($sql); 531 $h->db->query("TRUNCATE TABLE " . TABLE_SETTINGS); 532 533 if ($results) { 534 $i = 0; 535 while (!empty($desired_order)) { 536 foreach ($results as $row) { 537 if (count($desired_order) == 0) { break; } 538 if ($row->settings_name == $desired_order[0]) { 539 $sql = "INSERT INTO " . TABLE_SETTINGS . " (settings_name, settings_value, settings_default, settings_note, settings_show) VALUES(%s, %s, %s, %s, %s)"; 540 $h->db->query($h->db->prepare($sql, $row->settings_name, $row->settings_value, $row->settings_default, $row->settings_note, $row->settings_show)); 541 array_shift($desired_order); 542 } 543 $i++; 544 if ($i > 10000) { break; } // got stuck in a loop 545 } 546 } 547 } 548 549 // update "old version" for next set of upgrades 550 $old_version = "1.3.0"; 551 } 552 553 // 1.3.0 to 1.4.0 554 if ($old_version == "1.3.0") { 555 556 // Drop token_id column from the tokens table 557 if ($h->db->column_exists('tokens', 'token_id')) { 558 $h->db->query("ALTER TABLE " . DB_PREFIX . "tokens DROP token_id"); 559 } 560 561 // update "old version" for next set of upgrades 562 $old_version = "1.4.0"; 563 } 564 565 // 1.4.0 to 1.4.1 566 if ($old_version == "1.4.0") { 567 // update "old version" for next set of upgrades 568 $old_version = "1.4.1"; 569 } 570 571 // 1.4.1 to 1.4.2 572 if ($old_version == "1.4.1") { 573 574 // Change post_title column from `post_title` varchar(255) NULL, to `post_title` text NULL, 575 $exists = $h->db->column_exists('posts', 'post_title'); 576 if ($exists) { 577 $sql = "ALTER TABLE " . TABLE_POSTS . " MODIFY post_title text NULL"; 578 $h->db->query($h->db->prepare($sql)); 579 } 580 581 // remove multi-site option from settings 582 $sql = "DELETE FROM " . TABLE_SETTINGS . " WHERE settings_name = %s"; 583 $h->db->query($h->db->prepare($sql, 'MULTI_SITE')); 584 585 //tables to remove site_id from: 548 586 $tables = array( 549 587 'blocked'=>'blocked','categories'=>'category', … … 554 592 ); 555 593 556 foreach ($tables as $table => $column) { 557 558 if (!$exists = $h->db->column_exists($table, $column . '_siteid')) { 559 // Create a column for index first 560 $sql = "ALTER TABLE " . DB_PREFIX . $table . " ADD " . $column . "_siteid INT NOT NULL DEFAULT 1"; 594 // Remove site_id columns 595 foreach ($tables as $table => $column) 596 { 597 if ($exists = $h->db->column_exists($table, $column . '_siteid')) { 598 // Remove column 599 $sql = "ALTER TABLE " . DB_PREFIX . $table . " DROP " . $column . "_siteid"; 561 600 $h->db->query($sql); 562 } else { 563 // fix to make sure siteid=0 columns are changed to siteid=1 564 $sql = "ALTER TABLE " . DB_PREFIX . $table . " MODIFY " . $column . "_siteid INT NOT NULL DEFAULT 1"; 565 $h->db->query($sql); 566 567 $sql = "UPDATE " . DB_PREFIX . $table . " SET " . $column . "_siteid=1 WHERE " . $column . "_siteid=0"; 568 $h->db->query($sql); 569 } 570 571 601 } 602 603 // Remove site_id indices 572 604 $sql = "SHOW INDEX FROM `" . DB_PREFIX . $table . "` WHERE KEY_NAME = '" . $column . "_siteid'"; 573 605 $result = $h->db->query($sql); 574 if ( !$result) {575 $sql = " ALTER TABLE `" . DB_PREFIX . $table . "` ADD INDEX (" . $column . "_siteid)";606 if ($result) { 607 $sql = "DROP INDEX " . $column . "_siteid ON " . DB_PREFIX . $table; 576 608 $h->db->query($sql); 577 609 } 578 579 // Unique Keys 580 /* 581 * 582 */ 583 if ($exists = $h->db->column_exists('categories', 'category_siteid')) { 584 $sql = "ALTER TABLE `" . TABLE_CATEGORIES . "` DROP KEY `key`"; 585 $h->db->query($sql); 586 $sql = "ALTER TABLE `" . TABLE_CATEGORIES . "` ADD UNIQUE KEY `key` (`category_name`, `category_siteid`)"; 587 $h->db->query($sql); 588 } 589 if ($exists = $h->db->column_exists('plugins', 'plugin_siteid')) { 590 $sql = "ALTER TABLE `" . TABLE_PLUGINS . "` DROP KEY `key`"; 591 $h->db->query($sql); 592 $sql = "ALTER TABLE `" . TABLE_PLUGINS . "` ADD UNIQUE KEY `key` (`plugin_folder`, `plugin_siteid`)"; 593 $h->db->query($sql); 594 } 595 if ($exists = $h->db->column_exists('settings', 'settings_siteid')) { 596 $sql = "ALTER TABLE `" . TABLE_SETTINGS . "` DROP KEY `key`"; 597 $h->db->query($sql); 598 $sql = "ALTER TABLE `" . TABLE_SETTINGS . "` ADD UNIQUE KEY `key` (`settings_name`, `settings_siteid`)"; 599 $h->db->query($sql); 600 } 601 if ($exists = $h->db->column_exists('tags', 'tags_siteid')) { 602 $sql = "ALTER TABLE `" . TABLE_TAGS . "` DROP KEY `key`"; 603 $h->db->query($sql); 604 $sql = "ALTER TABLE `" . TABLE_TAGS . "` ADD UNIQUE KEY `key` (`tags_post_id`, `tags_word`, `tags_siteid`)"; 605 $h->db->query($sql); 606 } 607 if ($exists = $h->db->column_exists('users', 'user_siteid')) { 608 $sql = "ALTER TABLE `" . TABLE_USERS . "` DROP KEY `key`"; 609 $h->db->query($sql); 610 $sql = "ALTER TABLE `" . TABLE_USERS . "` ADD UNIQUE KEY `key` (`user_username`, `user_siteid`)"; 611 $h->db->query($sql); 612 } 613 } 614 615 616 // reorder the admin settings 617 $desired_order = array('SITE_OPEN', 'SITE_NAME', 'THEME', 'ADMIN_THEME', 'DEBUG', 'FRIENDLY_URLS', 'DB_CACHE', 'DB_CACHE_DURATION', 'CSS_JS_CACHE', 'HTML_CACHE', 'LANG_CACHE', 'RSS_CACHE', 'RSS_CACHE_DURATION', 'SITE_EMAIL', 'SMTP', 'SMTP_HOST', 'SMTP_PORT', 'SMTP_USERNAME', 'SMTP_PASSWORD', 'SYS_FEEDBACK'); 618 $sql = "SELECT * FROM " . TABLE_SETTINGS; 619 $results = $h->db->get_results($sql); 620 $h->db->query("TRUNCATE TABLE " . TABLE_SETTINGS); 621 622 if ($results) { 623 $i = 0; 624 while (!empty($desired_order)) { 625 foreach ($results as $row) { 626 if (count($desired_order) == 0) { break; } 627 if ($row->settings_name == $desired_order[0]) { 628 $sql = "INSERT INTO " . TABLE_SETTINGS . " (settings_name, settings_value, settings_default, settings_note, settings_show, settings_siteid) VALUES(%s, %s, %s, %s, %s, %d)"; 629 $h->db->query($h->db->prepare($sql, $row->settings_name, $row->settings_value, $row->settings_default, $row->settings_note, $row->settings_show, $row->settings_siteid)); 630 array_shift($desired_order); 631 } 632 $i++; 633 if ($i > 10000) { break; } // got stuck in a loop 634 } 635 } 636 } 637 638 // update "old version" for next set of upgrades 639 $old_version = "1.3.0"; 640 } 641 642 // 1.3.0 to 1.4.0 643 if ($old_version == "1.3.0") { 644 645 // Version Info Auto Update 646 $sql = "UPDATE " . TABLE_SETTINGS . " SET settings_note = %s, settings_name = %s WHERE settings_name = %s"; 647 $h->db->query($h->db->prepare($sql, 'Hotaru updates', 'SYS_UPDATES', 'SYS_FEEDBACK')); 648 649 // RELATES TABLE 650 if (!$exists = $h->db->table_exists('relates')) { 651 //echo "table doesn't exist. Stopping before creation."; exit; 652 $sql = "CREATE TABLE `" . DB_PREFIX . "relates` ( 653 `relates_id` int(20) NOT NULL AUTO_INCREMENT PRIMARY KEY, 654 `relates_user_id` int(20) NOT NULL default '0', 655 `relates_post_id` int(20) NOT NULL default '0', 656 `relates_type` varchar(64) default '', 657 `relates_updatedts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 658 INDEX (`relates_user_id`), 659 INDEX (`relates_post_id`), 660 INDEX (`relates_type`) 661 ) ENGINE=" . DB_ENGINE . " DEFAULT CHARSET=" . DB_CHARSET . " COLLATE=" . DB_COLLATE . " COMMENT='Relates';"; 662 $h->db->query($sql); 663 } 664 665 // Version Info Auto Update 666 $sql = "UPDATE " . TABLE_SETTINGS . " SET settings_note = %s, settings_name = %s WHERE settings_name = %s"; 667 $h->db->query($h->db->prepare($sql, 'Hotaru updates', 'SYS_UPDATES', 'SYS_FEEDBACK')); 668 669 // MULTI_SITE for SETTINGS table for siteid=1 only (admin) 670 $sql = "SELECT settings_siteid FROM " . TABLE_SETTINGS . " WHERE settings_name = %s AND settings_siteid = %d"; 671 $result = $h->db->get_var($h->db->prepare($sql, 'MULTI_SITE', 1)); 672 673 if (!$result) { 674 $sql = "INSERT INTO " . TABLE_SETTINGS . " (settings_name, settings_value, settings_default, settings_note) VALUES (%s, %s, %s, %s)"; 675 $h->db->query($h->db->prepare($sql, 'MULTI_SITE', 'false', 'false', 'Multiple sites')); 676 } 677 678 // Add siteid to pluginhooks table 679 if (!$exists = $h->db->column_exists('pluginhooks', 'pluginhooks_siteid')) { 680 // Create a column for index first 681 $sql = "ALTER TABLE " . TABLE_PLUGINHOOKS . " ADD pluginhooks_siteid INT NOT NULL DEFAULT 1"; 682 $h->db->query($sql); 683 } 684 685 // Add index for siteid on pluginhooks table 686 $sql = "SHOW INDEX FROM `" . TABLE_PLUGINHOOKS . "` WHERE KEY_NAME = 'pluginhooks_siteid'"; 687 $result = $h->db->query($sql); 688 if (!$result) { 689 $sql = "ALTER TABLE `" . TABLE_PLUGINHOOKS . "` ADD INDEX (pluginhooks_siteid)"; 690 $h->db->query($sql); 691 } 692 693 // Change post_title column from `post_title` varchar(255) NULL, to `post_title` text NULL, 694 $exists = $h->db->column_exists('posts', 'post_title'); 695 if (!$exists) { 696 $sql = "ALTER TABLE " . TABLE_POSTS . " MODIFY post_title text NULL"; 697 $h->db->query($h->db->prepare($sql)); 698 } 699 700 // Drop token_id column from the tokens table 701 if ($h->db->column_exists('tokens', 'token_id')) { 702 $h->db->query("ALTER TABLE " . DB_PREFIX . "tokens DROP token_id"); 703 } 704 705 // update "old version" for next set of upgrades 706 $old_version = "1.4.0"; 707 } 708 709 // 1.3.0 to 1.4.0 710 if ($old_version == "1.4.0") { 711 // update "old version" for next set of upgrades 712 $old_version = "1.4.1"; 610 } 611 612 // Drop unique site_id keys 613 $sql = "ALTER TABLE `" . TABLE_CATEGORIES . "` DROP INDEX `key`"; 614 $h->db->query($sql); 615 $sql = "ALTER TABLE `" . TABLE_CATEGORIES . "` ADD UNIQUE KEY `key` (`category_name`)"; 616 $h->db->query($sql); 617 618 $sql = "ALTER TABLE `" . TABLE_PLUGINS . "` DROP INDEX `key`"; 619 $h->db->query($sql); 620 $sql = "ALTER TABLE `" . TABLE_PLUGINS . "` ADD UNIQUE KEY `key` (`plugin_folder`)"; 621 $h->db->query($sql); 622 623 $sql = "ALTER TABLE `" . TABLE_SETTINGS . "` DROP INDEX `key`"; 624 $h->db->query($sql); 625 $sql = "ALTER TABLE `" . TABLE_SETTINGS . "` ADD UNIQUE KEY `key` (`settings_name`)"; 626 $h->db->query($sql); 627 628 $sql = "ALTER TABLE `" . TABLE_TAGS . "` DROP INDEX `key`"; 629 $h->db->query($sql); 630 $sql = "ALTER TABLE `" . TABLE_TAGS . "` ADD UNIQUE KEY `key` (`tags_post_id`, `tags_word`)"; 631 $h->db->query($sql); 632 633 $sql = "ALTER TABLE `" . TABLE_USERS . "` DROP INDEX `key`"; 634 $h->db->query($sql); 635 $sql = "ALTER TABLE `" . TABLE_USERS . "` ADD UNIQUE KEY `key` (`user_username`)"; 636 $h->db->query($sql); 637 638 // Drop Site table 639 $sql = 'DROP TABLE IF EXISTS `' . DB_PREFIX . 'site`;'; 640 $h->db->query($sql); 641 642 // Drop Relates table 643 $sql = 'DROP TABLE IF EXISTS `' . DB_PREFIX . 'relates`;'; 644 $h->db->query($sql); 645 646 // remove the "1" cache folder if permissions allow, otherwise error messages supressed. 647 if (is_dir(CACHE . '1')) 648 { 649 if (is_dir(CACHE . '1/db_cache')) { 650 $h->deleteFiles(CACHE . '1/db_cache'); 651 @rmdir(CACHE . '1/db_cache'); 652 } 653 654 if (is_dir(CACHE . '1/css_js_cache')) { 655 $h->deleteFiles(CACHE . '1/css_js_cache'); 656 @rmdir(CACHE . '1/css_js_cache'); 657 } 658 659 if (is_dir(CACHE . '1/rss_cache')) { 660 $h->deleteFiles(CACHE . '1/rss_cache'); 661 @rmdir(CACHE . '1/rss_cache'); 662 } 663 664 if (is_dir(CACHE . '1/lang_cache')) { 665 $h->deleteFiles(CACHE . '1/lang_cache'); 666 @rmdir(CACHE . '1/lang_cache'); 667 } 668 669 if (is_dir(CACHE . '1/html_cache')) { 670 $h->deleteFiles(CACHE . '1/html_cache'); 671 @rmdir(CACHE . '1/html_cache'); 672 } 673 674 if (is_dir(CACHE . '1/debug_logs')) { 675 $h->deleteFiles(CACHE . '1/debug_logs'); 676 @rmdir(CACHE . '1/debug_logs'); 677 } 678 679 if (file_exists(CACHE . '1/smartloader_cache.php')) { 680 @unlink(CACHE . '1/smartloader_cache.php'); 681 } 682 683 @rmdir(CACHE . '1'); 684 } 685 686 // update "old version" for next set of upgrades 687 $old_version = "1.4.2"; 688 713 689 } 714 690 … … 718 694 } 719 695 720 721 722 723 // // loop through all sites to insert this setting into each one's SETTING TABLE724 // $sql = "SELECT site_id FROM " . TABLE_SITE;725 // $sites = $h->db->get_results($h->db->prepare($sql));726 //727 // $sql = "SELECT settings_siteid FROM " . TABLE_SETTINGS . " WHERE settings_name = %s";728 // $result = $h->db->get_results($h->db->prepare($sql, 'MULTI_SITE'), ARRAY_N);729 // if (!$result) { $result = array(); }730 // //var_dump($result);731 // if ($sites) {732 // foreach ($sites as $site) {733 // if (in_array($site->site_id, $result)) {734 // $sql = "UPDATE " . TABLE_SETTINGS . " SET settings_value = %s WHERE settings_name = %s";735 // $h->db->query($h->db->prepare($sql, '', ''));736 // } else {737 // $sql = "INSERT INTO " . TABLE_SETTINGS . " (settings_name, settings_value, settings_default, settings_note) VALUES (%s, %s, %s, %s)";738 // $h->db->query($h->db->prepare($sql, '', '', '', ''));739 // }740 // }741 // }742 743 696 ?> -
trunk/install/install_functions.php
r1896 r2233 135 135 */ 136 136 function delTree($dir) { 137 $files = glob( $dir . '*', GLOB_MARK );138 foreach( $files as $file ){139 if( is_dir( $file ) )140 delTree( $file );141 else142 unlink( $file );143 }144 137 145 if (is_dir($dir)) return rmdir( $dir ); 138 $files = glob( $dir . '*', GLOB_MARK ); 139 140 foreach( $files as $file ){ 141 if( is_dir( $file ) ) 142 delTree( $file ); 143 else 144 @unlink( $file ); 145 } 146 147 if (is_dir($dir)) return @rmdir( $dir ); 146 148 } -
trunk/install/install_language.php
r2080 r2233 48 48 $lang["install_next"] = "Next"; 49 49 $lang["install_back"] = "Back"; 50 $lang["install_trouble"] = "Having trouble? Read the <a href='http:// hotarudocs.com'>Documentation</a> or ask for help in the <a href='http://hotarucms.org/forum.php'>Forums</a>.";50 $lang["install_trouble"] = "Having trouble? Read the <a href='http://docs.hotarucms.org'>Documentation</a> or ask for help in the <a href='http://hotarucms.org/forum.php'>Forums</a>."; 51 51 52 52 /* Install Step 1 */ … … 139 139 $lang["install_step4"] = "Step 4/4: Completion"; 140 140 $lang["install_step4_installation_complete"] = "Installation has been successfully completed."; 141 $lang["install_step4_installation_delete"] = "You <b>must</b> delete the install folder or someone else could run the install script and wipe everything!"; 142 $lang["install_step4_installation_delete_folder"] = "Shall we try and delete the 'install' folder for you?"; 143 $lang["install_step4_form_delete_folder"] = "Delete Folder"; 144 $lang["install_step4_installation_delete_failed"] = "We were not able to delete the install folder. Please delete it manually."; 141 $lang["install_step4_installation_delete"] = "<span style='color: red;'><b>WARNING:</b> You <b>must</b> delete the install folder or someone else could run the install script and wipe everything!</span>"; 142 145 143 $lang["install_step4_form_check_php"] = "Check PHP Setup"; 146 144 $lang["install_step4_form_check_php_warning"] = "Note: Your server is missing the PHP module: "; -
trunk/install/install_tables.php
r2080 r2233 52 52 `blocked_updatedts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 53 53 `blocked_updateby` int(20) NOT NULL DEFAULT 0, 54 `blocked_siteid` int(20) NOT NULL DEFAULT 1,55 INDEX (`blocked_siteid`),56 54 INDEX (`blocked_type`) 57 55 ) ENGINE=" . DB_ENGINE . " DEFAULT CHARSET=" . DB_CHARSET . " COLLATE=" . DB_COLLATE . " COMMENT='Blocked IPs, users, emails, etc';"; … … 75 73 `category_order` int(11) NOT NULL DEFAULT '0', 76 74 `category_desc` text NULL, 77 `category_keywords` varchar(255) N OT NULL,75 `category_keywords` varchar(255) NULL, 78 76 `category_updatedts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 79 77 `category_updateby` int(20) NOT NULL DEFAULT 0, 80 `category_siteid` int(20) NOT NULL DEFAULT 1, 81 INDEX (`category_siteid`), 82 UNIQUE KEY `key` (`category_name`, `category_siteid`) 78 UNIQUE KEY `key` (`category_name`) 83 79 ) ENGINE=" . DB_ENGINE . " DEFAULT CHARSET=" . DB_CHARSET . " COLLATE=" . DB_COLLATE . " COMMENT='Categories';"; 84 80 echo $lang['install_step2_creating_table'] . ": '" . DB_PREFIX . $table_name . "'...<br />\n"; … … 101 97 `comment_user_id` int(20) NOT NULL DEFAULT '0', 102 98 `comment_parent` int(20) DEFAULT '0', 103 `comment_date` timestamp N OT NULL,99 `comment_date` timestamp NULL, 104 100 `comment_status` varchar(32) NOT NULL DEFAULT 'approved', 105 `comment_content` text N OT NULL,101 `comment_content` text NULL, 106 102 `comment_votes_up` smallint(11) NOT NULL DEFAULT '0', 107 103 `comment_votes_down` smallint(11) NOT NULL DEFAULT '0', 108 104 `comment_subscribe` tinyint(1) NOT NULL DEFAULT '0', 109 105 `comment_updateby` int(20) NOT NULL DEFAULT 0, 110 `comment_siteid` int(20) NOT NULL DEFAULT 1,111 INDEX (`comment_siteid`),112 106 FULLTEXT (`comment_content`), 113 107 INDEX (`comment_archived`), … … 131 125 `cvote_user_id` int(11) NOT NULL DEFAULT '0', 132 126 `cvote_user_ip` varchar(32) NOT NULL DEFAULT '0', 133 `cvote_date` timestamp N OT NULL,127 `cvote_date` timestamp NULL, 134 128 `cvote_rating` smallint(11) NOT NULL DEFAULT '0', 135 129 `cvote_reason` tinyint(3) NOT NULL DEFAULT 0, … … 166 160 `message_from` int(20) NOT NULL DEFAULT 0, 167 161 `message_to` int(20) NOT NULL DEFAULT 0, 168 `message_date` timestamp N OT NULL,162 `message_date` timestamp NULL, 169 163 `message_subject` varchar(255) NOT NULL DEFAULT '', 170 164 `message_content` text NULL, … … 185 179 $sql = "CREATE TABLE `" . DB_PREFIX . $table_name . "` ( 186 180 `miscdata_id` int(20) NOT NULL AUTO_INCREMENT PRIMARY KEY, 187 `miscdata_key` varchar(64) N OT NULL,188 `miscdata_value` text N OT NULL DEFAULT '',189 `miscdata_default` text N OT NULL DEFAULT '',181 `miscdata_key` varchar(64) NULL, 182 `miscdata_value` text NULL, 183 `miscdata_default` text NULL, 190 184 `miscdata_updatedts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 191 `miscdata_updateby` int(20) NOT NULL DEFAULT 0, 192 `miscdata_siteid` int(20) NOT NULL DEFAULT 1, 193 INDEX (`miscdata_siteid`) 185 `miscdata_updateby` int(20) NOT NULL DEFAULT 0 194 186 ) ENGINE=" . DB_ENGINE . " DEFAULT CHARSET=" . DB_CHARSET . " COLLATE=" . DB_COLLATE . " COMMENT='Miscellaneous Data';"; 195 187 echo $lang['install_step2_creating_table'] . ": '" . DB_PREFIX . $table_name . "'...<br />\n"; … … 241 233 `plugin_updateby` int(20) NOT NULL DEFAULT 0, 242 234 `plugin_latestversion` varchar(8) NOT NULL DEFAULT '0.0', 243 `plugin_siteid` int(20) NOT NULL DEFAULT 1, 244 INDEX (`plugin_siteid`), 245 UNIQUE KEY `key` (`plugin_folder`, `plugin_siteid`) 235 UNIQUE KEY `key` (`plugin_folder`) 246 236 ) ENGINE=" . DB_ENGINE . " DEFAULT CHARSET=" . DB_CHARSET . " COLLATE=" . DB_COLLATE . " COMMENT='Application Plugins';"; 247 237 echo $lang['install_step2_creating_table'] . ": '" . DB_PREFIX . $table_name . "'...<br />\n"; … … 258 248 `plugin_updatedts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 259 249 `plugin_updateby` int(20) NOT NULL DEFAULT 0, 260 `pluginhooks_siteid` int(20) NOT NULL DEFAULT 1, 261 INDEX (`plugin_folder`), 262 INDEX (`pluginhooks_siteid`) 250 INDEX (`plugin_folder`) 263 251 ) ENGINE=" . DB_ENGINE . " DEFAULT CHARSET=" . DB_CHARSET . " COLLATE=" . DB_COLLATE . " COMMENT='Plugins Hooks';"; 264 252 echo $lang['install_step2_creating_table'] . ": '" . DB_PREFIX . $table_name . "'...<br />\n"; … … 271 259 $sql = "CREATE TABLE `" . DB_PREFIX . $table_name . "` ( 272 260 `psetting_id` int(20) NOT NULL AUTO_INCREMENT PRIMARY KEY, 273 `plugin_folder` varchar(64) N OT NULL,261 `plugin_folder` varchar(64) NULL, 274 262 `plugin_setting` varchar(64) NULL, 275 263 `plugin_value` text NULL, 276 264 `plugin_updatedts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 277 265 `plugin_updateby` int(20) NOT NULL DEFAULT 0, 278 `plugin_siteid` int(20) NOT NULL DEFAULT 1,279 INDEX (`plugin_siteid`),280 266 INDEX (`plugin_folder`) 281 267 ) ENGINE=" . DB_ENGINE . " DEFAULT CHARSET=" . DB_CHARSET . " COLLATE=" . DB_COLLATE . " COMMENT='Plugins Settings';"; … … 294 280 `post_updatedts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 295 281 `post_author` int(20) NOT NULL DEFAULT 0, 296 `post_date` timestamp N OT NULL,297 `post_pub_date` timestamp N OT NULL,282 `post_date` timestamp NULL, 283 `post_pub_date` timestamp NULL, 298 284 `post_status` varchar(32) NOT NULL DEFAULT 'processing', 299 285 `post_type` varchar(32) NULL, … … 310 296 `post_subscribe` tinyint(1) NOT NULL DEFAULT '0', 311 297 `post_updateby` int(20) NOT NULL DEFAULT 0, 312 `post_siteid` int(20) NOT NULL DEFAULT 1,313 INDEX (`post_siteid`),314 298 FULLTEXT (`post_title`, `post_domain`, `post_url`, `post_content`, `post_tags`), 315 299 INDEX (`post_archived`), … … 351 335 `vote_user_id` int(11) NOT NULL DEFAULT '0', 352 336 `vote_user_ip` varchar(32) NOT NULL DEFAULT '0', 353 `vote_date` timestamp N OT NULL,337 `vote_date` timestamp NULL, 354 338 `vote_type` varchar(32) NULL, 355 339 `vote_rating` smallint(11) NOT NULL DEFAULT '0', … … 362 346 } 363 347 364 365 // RELATES TABLE366 367 if ($table_name == "relates") {368 //echo "table doesn't exist. Stopping before creation."; exit;369 $sql = "CREATE TABLE `" . DB_PREFIX . $table_name . "` (370 `relates_id` int(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,371 `relates_user_id` int(20) NOT NULL default '0',372 `relates_post_id` int(20) NOT NULL default '0',373 `relates_type` varchar(64) default '',374 `relates_updatedts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,375 INDEX (`relates_user_id`),376 INDEX (`relates_post_id`),377 INDEX (`relates_type`)378 ) ENGINE=" . DB_ENGINE . " DEFAULT CHARSET=" . DB_CHARSET . " COLLATE=" . DB_COLLATE . " COMMENT='Relates';";379 echo $lang['install_step2_creating_table'] . ": '" . DB_PREFIX . $table_name . "'...<br />\n";380 $db->query($sql);381 }382 383 384 385 348 // SETTINGS TABLE 386 349 … … 388 351 $sql = "CREATE TABLE `" . DB_PREFIX . $table_name . "` ( 389 352 `settings_id` int(20) NOT NULL AUTO_INCREMENT PRIMARY KEY, 390 `settings_name` varchar(64) N OT NULL,391 `settings_value` text N OT NULL DEFAULT '',392 `settings_default` text N OT NULL DEFAULT '',393 `settings_note` text N OT NULL DEFAULT '',353 `settings_name` varchar(64) NULL, 354 `settings_value` text NULL, 355 `settings_default` text NULL, 356 `settings_note` text NULL, 394 357 `settings_show` enum('Y','N') NOT NULL DEFAULT 'Y', 395 358 `settings_updatedts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 396 359 `settings_updateby` int(20) NOT NULL DEFAULT 0, 397 `settings_siteid` int(20) NOT NULL DEFAULT 1, 398 UNIQUE KEY `key` (`settings_name`, `settings_siteid`), 399 INDEX (`settings_siteid`) 360 UNIQUE KEY `key` (`settings_name`) 400 361 ) ENGINE=" . DB_ENGINE . " DEFAULT CHARSET=" . DB_CHARSET . " COLLATE=" . DB_COLLATE . " COMMENT='Application Settings';"; 401 362 echo $lang['install_step2_creating_table'] . ": '" . DB_PREFIX . $table_name . "'...<br />\n"; … … 479 440 $sql = "INSERT INTO " . DB_PREFIX . $table_name . " (settings_name, settings_value, settings_default, settings_note) VALUES (%s, %s, %s, %s)"; 480 441 $db->query($db->prepare($sql, 'SMTP_PASSWORD', '', '', '')); 481 482 // Sys Feedback483 $sql = "INSERT INTO " . DB_PREFIX . $table_name . " (settings_name, settings_value, settings_default, settings_note) VALUES (%s, %s, %s, %s)";484 $db->query($db->prepare($sql, 'SYS_UPDATES', 'true', 'true', 'Hotaru updates'));485 486 // Multiple Sites487 $sql = "INSERT INTO " . DB_PREFIX . $table_name . " (settings_name, settings_value, settings_default, settings_note) VALUES (%s, %s, %s, %s)";488 $db->query($db->prepare($sql, 'MULTI_SITE', 'false', 'false', 'Multiple sites'));489 442 490 443 echo $lang['install_step2_adding_data'] . ": '" . DB_PREFIX . $table_name . "'...<br />\n"; 491 444 492 445 } 493 494 495 // SITE TABLE - for multiple sites496 497 if ($table_name == "site") {498 $sql = "CREATE TABLE `" . DB_PREFIX . $table_name . "` (499 `site_id` int(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,500 `site_adminuser_id` varchar(64) NULL,501 `site_url` varchar(128) NOT NULL DEFAULT '',502 `site_updatedts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,503 `site_updateby` int(20) NOT NULL DEFAULT 0504 ) ENGINE=" . DB_ENGINE . " DEFAULT CHARSET=" . DB_CHARSET . " COLLATE=" . DB_COLLATE . " COMMENT='Site Table';";505 echo $lang['install_step2_creating_table'] . ": '" . DB_PREFIX . $table_name . "'...<br />\n";506 $db->query($sql);507 }508 509 446 510 447 // TAGS TABLE - tags … … 516 453 `tags_archived` enum('Y','N') NOT NULL DEFAULT 'N', 517 454 `tags_updatedts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 518 `tags_date` timestamp N OT NULL,455 `tags_date` timestamp NULL, 519 456 `tags_word` varchar(64) NOT NULL DEFAULT '', 520 457 `tags_updateby` int(20) NOT NULL DEFAULT 0, 521 `tags_siteid` int(20) NOT NULL DEFAULT 1, 522 INDEX (`tags_siteid`), 523 UNIQUE KEY `tags_post_id` (`tags_post_id`,`tags_word`,`tags_siteid`), 458 UNIQUE KEY `tags_post_id` (`tags_post_id`,`tags_word`), 524 459 INDEX (`tags_archived`) 525 460 ) ENGINE=" . DB_ENGINE . " DEFAULT CHARSET=" . DB_CHARSET . " COLLATE=" . DB_COLLATE . " COMMENT='Post Tags';"; … … 549 484 if ($table_name == "tokens") { 550 485 $sql = "CREATE TABLE `" . DB_PREFIX . $table_name . "` ( 551 `token_sid` varchar(32) N OT NULL,552 `token_key` CHAR(32) N OT NULL,486 `token_sid` varchar(32) NULL, 487 `token_key` CHAR(32) NULL, 553 488 `token_stamp` INT(11) NOT NULL default '0', 554 489 `token_action` varchar(64), … … 566 501 `user_id` int(20) NOT NULL AUTO_INCREMENT PRIMARY KEY, 567 502 `user_updatedts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 568 `user_username` varchar(32) N OT NULL,503 `user_username` varchar(32) NULL, 569 504 `user_role` varchar(32) NOT NULL DEFAULT 'member', 570 `user_date` timestamp N OT NULL,505 `user_date` timestamp NULL, 571 506 `user_password` varchar(64) NOT NULL DEFAULT '', 572 507 `user_password_conf` varchar(128) NULL, … … 574 509 `user_email_valid` tinyint(3) NOT NULL DEFAULT 0, 575 510 `user_email_conf` varchar(128) NULL, 576 `user_permissions` text N OT NULL DEFAULT '',511 `user_permissions` text NULL, 577 512 `user_ip` varchar(32) NOT NULL DEFAULT '0', 578 513 `user_lastlogin` timestamp NULL, 579 514 `user_lastvisit` timestamp NULL, 580 515 `user_updateby` int(20) NOT NULL DEFAULT 0, 581 `user_siteid` int(20) NOT NULL DEFAULT 1, 582 INDEX (`user_siteid`), 583 UNIQUE KEY `key` (`user_username`, `user_siteid`), 516 UNIQUE KEY `key` (`user_username`), 584 517 KEY `user_email` (`user_email`) 585 518 ) ENGINE=" . DB_ENGINE . " DEFAULT CHARSET=" . DB_CHARSET . " COLLATE=" . DB_COLLATE . " COMMENT='Users and Roles';"; … … 622 555 `useract_key2` varchar(255) NULL, 623 556 `useract_value2` text NULL, 624 `useract_date` timestamp N OT NULL,557 `useract_date` timestamp NULL, 625 558 `useract_updateby` int(20) NOT NULL DEFAULT 0, 626 559 INDEX (`useract_userid`) … … 641 574 `widget_function` varchar(255) NULL, 642 575 `widget_args` varchar(255) NULL, 643 `widget_updateby` int(20) NOT NULL DEFAULT 0, 644 `widget_siteid` int(20) NOT NULL DEFAULT 1, 645 INDEX (`widget_siteid`) 576 `widget_updateby` int(20) NOT NULL DEFAULT 0 646 577 ) ENGINE=" . DB_ENGINE . " DEFAULT CHARSET=" . DB_CHARSET . " COLLATE=" . DB_COLLATE . " COMMENT='Widgets';"; 647 578 echo $lang['install_step2_creating_table'] . ": '" . DB_PREFIX . $table_name . "'...<br />\n"; -
trunk/libs/AdminPages.php
r2134 r2233 226 226 { 227 227 $sql = "SELECT settings_name, settings_value, settings_default, settings_note, settings_show FROM " . TABLE_SETTINGS; 228 if (MULTI_SITE == 'false') { $sql = $sql . " WHERE settings_siteid = 1"; }229 228 $results = $db->get_results($db->prepare($sql)); 230 229 if ($results) { return $results; } else { return false; } -
trunk/libs/Announcements.php
r2080 r2233 88 88 $announcements = array(); 89 89 90 if (SITEID == 1) { 91 // Check if install file has been deleted 92 $filename = INSTALL . 'install.php'; 93 if (file_exists($filename)) { 94 array_push($announcements, $h->lang['admin_announcement_delete_install']); 95 } 96 97 // Check if install file has not been run 98 $sql = "SELECT miscdata_value FROM " . TABLE_MISCDATA . " WHERE miscdata_key = %s"; 99 $hotaru_version = $h->db->get_var($h->db->prepare($sql, 'hotaru_version')); 100 if (version_compare($h->version, $hotaru_version, '>')) { 101 array_push($announcements, $h->lang['admin_announcement_run_install']); 102 } 90 // Check if install file has been deleted 91 $filename = INSTALL . 'install.php'; 92 if (file_exists($filename)) { 93 array_push($announcements, $h->lang['admin_announcement_delete_install']); 94 } 95 96 // Check if install file has not been run 97 $sql = "SELECT miscdata_value FROM " . TABLE_MISCDATA . " WHERE miscdata_key = %s"; 98 $hotaru_version = $h->db->get_var($h->db->prepare($sql, 'hotaru_version')); 99 if (version_compare($h->version, $hotaru_version, '>')) { 100 array_push($announcements, $h->lang['admin_announcement_run_install']); 103 101 } 104 102 -
trunk/libs/Debug.php
r2134 r2233 123 123 { 124 124 $sysinfo = new SystemInfo(); 125 $sysinfo->plugin_version_getAll($h); 126 125 127 126 $report = $sysinfo->getSystemData($h); 128 127 -
trunk/libs/EmailFunctions.php
r2134 r2233 63 63 if (!$this->to) { $this->to = SITE_NAME . ' <' . SITE_EMAIL . '>'; } 64 64 if (!$this->from) { $this->from = SITE_NAME . ' <' . SITE_EMAIL . '>'; } 65 66 // Fixing the subject for non-ASCII characters: 67 $this->subject = '=?UTF-8?B?'.base64_encode($this->subject).'?='; 65 68 66 69 if (SMTP == 'true') -
trunk/libs/IncludeCssJs.php
r2080 r2233 383 383 384 384 if ($version_js > 0) { 385 echo "<script type='text/javascript' src='" . SITEURL . "cache/ " . SITEID . "/css_js_cache/" . $prefix . "js_" . $version_js . ".js'></script>\n";385 echo "<script type='text/javascript' src='" . SITEURL . "cache/css_js_cache/" . $prefix . "js_" . $version_js . ".js'></script>\n"; 386 386 } 387 387 388 388 if ($version_css > 0) { 389 echo "<link rel='stylesheet' href='" . SITEURL . "cache/ " . SITEID . "/css_js_cache/" . $prefix . "css_" . $version_css . ".css' type='text/css' />\n";389 echo "<link rel='stylesheet' href='" . SITEURL . "cache/css_js_cache/" . $prefix . "css_" . $version_css . ".css' type='text/css' />\n"; 390 390 } 391 391 -
trunk/libs/Initialize.php
r2080 r2233 36 36 public function __construct($h) 37 37 { 38 39 38 // session to be used by CSRF, etc. 40 39 if (!isset($_SESSION['HotaruCMS'])) { 41 session_start();40 @session_start(); 42 41 $_SESSION['HotaruCMS'] = time(); 43 42 } … … 45 44 // The order here is important! 46 45 $this->setDefaultTimezone(); 47 $this->setTableConstants(); 46 $this->setTableConstants(); 47 48 $this->MakeCacheFolders(); 48 49 49 50 $this->getFiles(); … … 51 52 $this->db = $this->initDatabase(); 52 53 53 $this->getCurrentSiteID();54 54 $this->errorReporting(); 55 55 … … 100 100 101 101 // If doesn't exist, create a new file with die() at the top 102 if (!file_exists($filename)) { 102 if (!file_exists($filename)) 103 { 104 // write the error log 103 105 $fh = fopen($filename, 'w') or die("Sorry, I can't open cache/debug_logs/error_log.php"); 104 106 fwrite($fh, "<?php die(); ?>\r\n"); … … 132 134 "TABLE_POSTVOTES"=>"postvotes", 133 135 "TABLE_SETTINGS"=>"settings", 134 "TABLE_SITE"=>"site",135 136 "TABLE_TAGS"=>"tags", 136 137 "TABLE_TEMPDATA"=>"tempdata", … … 147 148 } 148 149 } 149 150 /**151 * Sets the current SiteID if multiple sites.152 */153 public function getCurrentSiteID()154 {155 // read settings for default siteid=1 first to check whether MULTISITE is TRUE156 $sql = "SELECT settings_value FROM " . TABLE_SETTINGS . " WHERE settings_name = %s AND settings_siteid = %d";157 $multi_site = $this->db->get_var($this->db->prepare($sql, 'MULTI_SITE', 1));158 if (!defined('MULTI_SITE')) { define ('MULTI_SITE', $multi_site); }159 160 if (MULTI_SITE == 'true') {161 $url = $this->cage->server->getRaw('HTTP_HOST'); // wanted to use sanitizeTags162 $sql = "SELECT site_id, site_adminuser_id FROM " . TABLE_SITE . " WHERE site_url = %s";163 $settings = $this->db->get_row($this->db->prepare($sql, $url));164 165 if ($settings) {166 $siteid = $settings->site_id;167 $siteurl = "http://" . $url . "/";168 } else {169 $siteid = 1;170 $siteurl = BASEURL;171 }172 173 174 if (!defined('MS_TABLES')) {175 $ms_tables = array();176 //get $h->$ms_tables177 foreach ( $this->db->get_col("SHOW TABLES",0) as $table_name )178 {179 $sql = "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.Columns where TABLE_NAME = %s AND RIGHT(COLUMN_NAME,7) = %s";180 $columns = $this->db->get_row($this->db->prepare($sql, $table_name, '_siteid'));181 //var_dump($columns);182 $array1 = explode(DB_PREFIX, $table_name);183 $tablename = $array1[1];184 if ($columns) {185 $array2 = explode('_siteid', $columns->COLUMN_NAME);186 $ms_tables[$tablename] = $array2[0];187 }188 }189 //define('MS_TABLES','return ' . var_export($ms_tables, 1) . ';');190 define('MS_TABLES',serialize($ms_tables));191 }192 193 194 } else {195 $siteid = 1;196 $siteurl = BASEURL;197 }198 199 if (!defined('SITEID')) { define('SITEID', $siteid); }200 if (!defined('SITEURL')) { define("SITEURL", $siteurl); }201 202 if (!defined('CACHE')) {203 204 define("CACHE", BASE . "cache/" . $siteid . "/");205 206 $dirs = array('', 'debug_logs/' , 'db_cache/', 'css_js_cache/', 'html_cache/', 'rss_cache/', 'lang_cache/'); // first array item is needed to create the SITEID base folder207 208 foreach ($dirs as $dir) {209 if (!is_dir(CACHE . $dir)) {210 mkdir(CACHE . $dir);211 }212 }213 214 }215 216 return false;217 }218 150 219 151 /** … … 247 179 require_once(FUNCTIONS . 'funcs.times.php'); 248 180 require_once(FUNCTIONS . 'funcs.files.php'); 181 require_once(FUNCTIONS . 'funcs.http.php'); 249 182 } 250 183 … … 290 223 /** 291 224 * Returns all site settings 292 * @param <int> $siteid293 225 * 294 226 * @return <bool> … … 304 236 { 305 237 if (!defined($setting->settings_name)) { 306 if ($setting->settings_name != 'MULTI_SITE') { define($setting->settings_name, $setting->settings_value); }238 define($setting->settings_name, $setting->settings_value); 307 239 } 308 240 } … … 312 244 313 245 246 /** 247 * Make cache folders if they don't already exist 248 */ 249 public function MakeCacheFolders() 250 { 251 // create a debug_logs folder if one doesn't exist. 252 if (!is_dir(CACHE . 'debug_logs')) { mkdir(CACHE . 'debug_logs'); } 253 254 // create a db_cache folder if one doesn't exist. 255 if (!is_dir(CACHE . 'db_cache')) { mkdir(CACHE . 'db_cache'); } 256 257 // create a css_js_cache folder if one doesn't exist. 258 if (!is_dir(CACHE . 'css_js_cache')) { mkdir(CACHE . 'css_js_cache'); } 259 260 // create a lang_cache folder if one doesn't exist. 261 if (!is_dir(CACHE . 'lang_cache')) { mkdir(CACHE . 'lang_cache'); } 262 263 // create an rss_cache folder if one doesn't exist. 264 if (!is_dir(CACHE . 'rss_cache')) { mkdir(CACHE . 'rss_cache'); } 265 266 // create an html_cache folder if one doesn't exist. 267 if (!is_dir(CACHE . 'html_cache')) { mkdir(CACHE . 'html_cache'); } 268 } 269 270 314 271 /** 315 272 * Set up database cache … … 322 279 $this->db->cache_timeout = DB_CACHE_DURATION; // Note: this is hours 323 280 $this->db->cache_dir = CACHE . 'db_cache'; 281 324 282 if (DB_CACHE == "true") { 325 283 $this->db->use_disk_cache = true; … … 359 317 public function setUpJsConstants() 360 318 { 319 if (!defined('SITEURL')) { define("SITEURL", BASEURL); } 320 361 321 // Start timer if debugging 362 322 $global_js_var = "jQuery('document').ready(function($) {BASE = '" . BASE . "'; BASEURL = '". SITEURL ."'; SITEURL = '". SITEURL ."'; ADMIN_THEME = '" . ADMIN_THEME . "'; THEME = '" . THEME . "';});"; 363 323 $JsConstantsFile = "css_js_cache/JavascriptConstants.js"; 364 324 365 if (!file_exists(CACHE . $JsConstantsFile)) { 325 if (!file_exists(CACHE . $JsConstantsFile)) 326 { 327 // write the JavascriptConstants file 366 328 $JsConstantsPath = CACHE . $JsConstantsFile; 367 329 $JsConstantsfh = fopen($JsConstantsPath, 'w') or die ("Can't open file"); -
trunk/libs/InspektExtras.php
r1896 r2233 168 168 169 169 // Allow plugins to alter the value of $config/ 170 // Plugins should return an array, e.g. array('safe' => 1); 170 // Plugins should return an array, e.g. array('safe' => 1); 171 /* 171 172 require_once(BASE . 'Hotaru.php'); 172 173 $h = new Hotaru(); … … 178 179 } 179 180 } 181 */ 180 182 181 183 require_once(EXTENSIONS . 'htmLawed/htmLawed.php'); -
trunk/libs/Language.php
r2134 r2233 273 273 $cache = CACHE.'lang_cache/'; 274 274 $file = $cache."language.php"; 275 276 // write the file 275 277 $fh = fopen($file, 'w+') or die("Sorry, I can't open ".$file); 276 278 if( flock($fh, LOCK_EX) ) { // do an exclusive lock -
trunk/libs/PageHandling.php
r2080 r2233 185 185 { 186 186 // if the title is already set... 187 if ($h->pageTitle != "")187 if ($h->pageTitle) 188 188 { 189 189 // replace [delimiter] text with the specified delimiter: … … 355 355 356 356 // if we're using categories and the category is not "all"... 357 if ($h->isActive('categories') && $h->post->category !=1) {357 if ($h->isActive('categories') && $h->post->category > 1) { 358 358 $url .= $h->getCatSafeName($h->post->category) . '/'; 359 359 } -
trunk/libs/PluginManagement.php
r2134 r2233 428 428 $h->clearCache('lang_cache', false); 429 429 430 $h->db->query(" DELETE FROM" . TABLE_PLUGINS);431 $h->db->query(" DELETE FROM" . TABLE_PLUGINHOOKS);430 $h->db->query("TRUNCATE TABLE " . TABLE_PLUGINS); 431 $h->db->query("TRUNCATE TABLE " . TABLE_PLUGINHOOKS); 432 432 433 433 $h->messages[$h->lang["admin_plugins_uninstall_all_done"]] = 'green'; … … 523 523 public function sortPluginHooks($h) 524 524 { 525 $sql = "SELECT p.plugin_folder, p.plugin_order, p.plugin_id, h.* FROM " . TABLE_PLUGINHOOKS . " h LEFT OUTER JOIN " . TABLE_PLUGINS. " p ON h.plugin_folder= p.plugin_folder AND p.plugin_siteid = %d WHERE h.pluginhooks_siteid = %d ORDER BY p.plugin_order ASC"; 526 $rows = $h->db->get_results($h->db->prepare($sql, SITEID, SITEID)); 527 528 // check if we need to truncate the table because the phook_id is dangerously big 529 if ($rows[0]->phook_id > 999999999999999) { //15 digits although the column is int(20) 530 $this->rebuildPluginHooksTable($h); 531 return true; 532 } 525 $sql = "SELECT p.plugin_folder, p.plugin_order, p.plugin_id, h.* FROM " . TABLE_PLUGINHOOKS . " h, " . TABLE_PLUGINS . " p WHERE p.plugin_folder = h.plugin_folder ORDER BY p.plugin_order ASC"; 526 $rows = $h->db->get_results($h->db->prepare($sql)); 533 527 534 528 // Remove all hooks for this site 535 $h->db->query($h->db->prepare(" DELETE FROM" . TABLE_PLUGINHOOKS));529 $h->db->query($h->db->prepare("TRUNCATE TABLE " . TABLE_PLUGINHOOKS)); 536 530 537 531 $values = ''; … … 554 548 } 555 549 } 556 557 550 558 /**559 * Get all pluginhooks, truncate the table and refill it, therefore refreshing phook_ids560 */561 public function rebuildPluginHooksTable($h)562 {563 $sql = "SELECT p.plugin_folder, p.plugin_order, p.plugin_id, h.* FROM " . TABLE_PLUGINHOOKS . " h LEFT OUTER JOIN " . TABLE_PLUGINS. " p ON h.plugin_folder = p.plugin_folder AND p.plugin_siteid = h.pluginhooks_siteid ORDER BY p.plugin_order ASC";564 $rows = $h->db->get_results($h->db->prepare($sql));565 566 // Drop and recreate the pluginhooks table, i.e. empty it.567 $h->db->query($h->db->prepare("TRUNCATE TABLE " . TABLE_PLUGINHOOKS));568 569 $values = '';570 $pvalues = array();571 $pvalues[0] = "temp"; // will be filled with $sql572 573 // Add plugin hooks back into the hooks table574 if ($rows) {575 foreach ($rows as $row)576 {577 $values .= "(%s, %s, %d, %d), ";578 array_push($pvalues, $row->plugin_folder);579 array_push($pvalues, $row->plugin_hook);580 array_push($pvalues, $h->currentUser->id);581 array_push($pvalues, $row->pluginhooks_siteid);582 }583 584 $values = rstrtrim($values, ", "); // strip off trailing comma585 $pvalues[0] = "INSERT INTO " . TABLE_PLUGINHOOKS . " (plugin_folder, plugin_hook, plugin_updateby, pluginhooks_siteid) VALUES " . $values;586 $h->db->query($h->db->prepare($pvalues));587 }588 }589 551 590 552 /** … … 608 570 } 609 571 610 611 /**612 * Update Plugins613 *614 * @param <type> $h615 */616 public function update($h)617 {618 $url = "http://hotaruplugins.com/zip/";619 $folder = $h->plugin->folder;620 $version= $h->cage->get->getHtmLawed('version');621 $findfolder = str_replace('_', '-', $folder);622 $version = str_replace('.', '-', $version);623 $copydir = PLUGINS . $folder . "/";624 $file = $findfolder . "-" . $version . ".zip";625 //print "findfolder: ". $findfolder . '<br/>';626 //print "$file: ". $file . '<br/>';627 628 // get ftpsettings629 $ftpserver = "api.hotarucms.org";630 $ftppath = "/public_html/api/content/";631 $ftpuser = "hotarorg";632 $ftppass = "pJp!AQ8&Y<Ge";633 634 635 $ftp_url = "ftp://" . $ftpuser . ":" . stripslashes($ftppass) . "@" . $ftpserver . $ftppath . $folder . "/" ;636 637 // check that we can access the remote plugin repo site via curl638 if ($this->fileCheckCurlConnection($url, $file) == 200) {639 if ($write = is_writeable($copydir)) {640 //print "we can use PHP<br/>";641 $this->filePhpWrite($h, $url, $file, $findfolder, $copydir);642 } else {643 //print "we will use FTP<br/>";644 $this->fileFtpWrite($h, $url, $ftp_url, $file, $findfolder, $copydir);645 }646 } else {647 $h->messages[$h->lang['admin_theme_filecopy_permission_error']] = 'red';648 //$h->messages[$file . $h->lang['admin_theme_fileexist_error']] = 'red';649 }650 651 // unzip652 //print "checking if file exists " . PLUGINS . $folder . '/' . $file . '<br/>';653 if (file_exists( PLUGINS . $folder . '/' . $file)) {654 //print "starting the unzip<br/>";655 if (!$write) { $this->fileFtpChmod($h, $ftp_url, $folder, '777'); }656 657 658 // Should we rename old files first and then bring in new ?659 660 661 $this->fileUnzip($h, $file, $copydir);662 if (!$write) { $this->fileFtpChmod($h, $ftp_url, $folder, '755'); }663 // delete zip file664 if ($write) {665 //print "we can use PHP<br/>";666 $this->filePhpDelete($h, $file, $copydir);667 } else {668 //print "we will use FTP<br/>";669 $this->fileFtpDelete($h, $ftp_url, $file, $copydir);670 }671 } else {672 $h->messages[$h->lang['admin_theme_filecopy_error'] . $file] = 'red';673 }674 }675 676 677 public function fileCheckCurlConnection($url, $file)678 {679 // create a new CURL resource680 $ch = curl_init();681 682 // set URL and other appropriate options683 curl_setopt($ch, CURLOPT_URL, $url . $file);684 curl_setopt($ch, CURLOPT_HEADER, false);685 curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);686 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);687 688 set_time_limit(30); # 30 seconds for PHP689 curl_setopt($ch, CURLOPT_TIMEOUT, 30); # and also for CURL690 691 //don't fetch the actual page, you only want to check the connection is ok692 curl_setopt($ch, CURLOPT_NOBODY, true);693 694 $zipfile = curl_exec($ch);695 $statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);696 curl_close($ch);697 698 //print 'checking directory is accesible: ' . $statusCode . '<br/>';699 700 return $statusCode;701 }702 703 704 public function filePhpWrite($h, $url, $file, $findfolder, $copydir )705 {706 // create a new CURL resource707 $ch = curl_init();708 709 // set URL and other appropriate options710 curl_setopt($ch, CURLOPT_URL, $url . $file);711 curl_setopt($ch, CURLOPT_HEADER, false);712 curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);713 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);714 715 set_time_limit(300); # 5 minutes for PHP716 curl_setopt($ch, CURLOPT_TIMEOUT, 300); # and also for CURL717 718 //don't fetch the actual page, you only want to check the connection is ok719 curl_setopt($ch, CURLOPT_NOBODY, true);720 721 $zipfile = curl_exec($ch);722 $statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);723 724 if ($statusCode == 200) {725 726 if (is_writeable($copydir)) {727 //reset this from above728 curl_setopt($ch, CURLOPT_NOBODY, false);729 $outfile = @fopen($copydir . $file, 'wb');730 curl_setopt($ch, CURLOPT_FILE, $outfile);731 $handle =base64_encode(curl_exec ($ch));732 fclose($outfile);733 if ($handle) {734 $h->messages[$file . $h->lang['admin_theme_filecopy_success']] = 'green';735 }736 } else {737 $h->messages[$h->lang['admin_theme_filecopy_error'] . $file] = 'red';738 }739 } else {740 $h->messages[$h->lang['admin_theme_fileexist_error'] . $file] = 'red';741 }742 curl_close($ch);743 }744 745 public function fileUnzip($h, $file, $copydir)746 {747 $h->messages[$file . $h->lang['admin_theme_filecopy_success']] = 'green';748 749 require_once(EXTENSIONS . 'pclZip/pclzip.lib.php');750 $archive = new PclZip($copydir . $file);751 752 if (($v_result_list = $archive->extract(PCLZIP_OPT_PATH, PLUGINS)) == 0) {753 $h->messages[$h->lang['admin_theme_unzip_error'] . $file] = 'red';754 } else {755 $h->messages[$file . $h->lang['admin_theme_unzip_success']] = 'green';756 }757 }758 759 public function filePhpDelete($h, $file, $copydir)760 {761 @chmod($copydir . $file,666);762 $deleted = @unlink($copydir . $file);763 if (!$deleted) {764 $h->messages[$file . $h->lang['admin_theme_zipdelete_error']] = 'yellow';765 }766 }767 768 public function fileFtpChmod($h, $ftp_url, $folder, $permission)769 {// print "start chmod for " . $ftp_url;770 $ch = curl_init();771 curl_setopt($ch, CURLOPT_URL, $ftp_url);772 curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);773 curl_setopt($ch, CURLOPT_POSTQUOTE, array("CHMOD " . $permission . ' ' . $folder));774 775 curl_exec($ch);776 if ($error = curl_error($ch)) {777 // write this to error log778 echo "<br/>Error: $error<br />\n";779 }780 $statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);781 782 // 250 comes from FTP error code saying action completed ok783 if (!$statusCode == 250) {784 print "problem";785 }786 787 curl_close($ch);788 }789 790 public function fileFtpDelete($h, $ftp_url, $file, $copydir)791 {792 $ch = curl_init();793 curl_setopt($ch, CURLOPT_URL, $ftp_url . 'plugins/');794 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);795 curl_setopt($ch, CURLOPT_POSTQUOTE, array("DELE " . $file));796 797 curl_exec($ch);798 // if ($error = curl_error($ch)) {799 // // write this to error log800 // echo "<br/>Error: $error<br />\n";801 // }802 $statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);803 804 // 250 comes from FTP error code saying action completed ok805 if (!$statusCode == 250) {806 $h->messages[$file . $h->lang['admin_theme_zipdelete_error']] = 'yellow';807 }808 809 curl_close($ch);810 }811 812 public function fileFtpWrite($h, $url, $ftp_url, $file, $folder, $copydir)813 {814 $BUFF="";815 $ch = curl_init();816 817 print "Checking FTP at " . $url . " to get file " . $file. "<br/>";818 819 curl_setopt($ch, CURLOPT_URL, $url . $file);820 // Set callback function for body821 curl_setopt($ch, CURLOPT_WRITEFUNCTION, array($this, 'read_body'));822 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);823 824 curl_exec($ch);825 $statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);826 827 if ($error = curl_error($ch)) {828 $h->messages[$h->lang['admin_theme_filecopy_permission_error']] = 'red';829 echo "Error: $error<br />\n";830 }831 832 print "<br/><br/>Trying to upload to: " .$ftp_url . 'plugins/' . $file;833 834 curl_setopt($ch, CURLOPT_URL, $ftp_url . 'plugins/' .$file);835 curl_setopt($ch, CURLOPT_UPLOAD, 1);836 #curl_setopt($ch, CURLOPT_INFILE, 0);837 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);838 #curl_setopt($ch, CURLOPT_VERBOSE, 1);839 curl_setopt ($ch, CURLOPT_READFUNCTION, array($this, 'write_function'));840 841 // set size of the image, which isn't _mandatory_ but helps libcurl to do842 // extra error checking on the upload.843 #curl_setopt($ch, CURLOPT_INFILESIZE, filesize($localfile));844 845 curl_exec($ch);846 $statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);847 848 if ($error = curl_error($ch)) {849 $h->messages[$h->lang['admin_theme_filecopy_permission_error']] = 'red';850 echo "Error: $error<br />\n";851 }852 853 curl_close($ch);854 855 return $error;856 }857 858 public function write_function($handle, $fd, $length)859 {860 global $BUF;861 $l = strlen($BUF);862 if ( $l > $length ) {863 $part = substr($BUF, 0, $length);864 $BUF = substr($BUF, $length);865 } else {866 $part = $BUF;867 $BUF = "";868 }869 870 echo "<br/>Sent $l bytes<br/>\n";871 return $part;872 }873 874 public function read_body($ch, $string)875 {876 global $BUF;877 $length = strlen($string);878 echo "Received $length bytes<br />\n";879 $BUF=$BUF.$string;880 return $length;881 }882 883 884 public function versionCheck($h)885 {886 $systeminfo = New SystemInfo();887 $result = $systeminfo->plugin_version_getAll($h);888 if ($result) {889 $h->messages[$h->lang['admin_theme_version_check_completed']] = 'green';890 }891 }892 572 893 573 /** -
trunk/libs/SystemInfo.php
r2134 r2233 25 25 */ 26 26 class SystemInfo 27 { 28 27 { 29 28 /** 30 29 * Calls external site to provide system info feedback report … … 35 34 { 36 35 $report = $h->generateReport("object"); 37 36 38 37 $query_vals = array( 39 'api_key' => '',40 'format' => $format,41 'method' => 'hotaru.systemFeedback.add',42 'args' => serialize($report)38 'api_key' => '', 39 'format' => $format, 40 'method' => 'hotaru.systemFeedback.add', 41 'args' => serialize($report) 43 42 ); 44 43 45 44 $info = $this->sendApiRequest($h, $query_vals, 'http://api.hotarucms.org/index.php?page=api'); 46 45 47 46 return true; 48 }49 50 51 /**52 * Calls external site to get latest available hotaru version number53 *54 * @return string versionnumber55 */56 public function hotaru_version($h)57 {58 $query_vals = array(59 'api_key' => '',60 'format' => 'json',61 'method' => 'hotaru.version.get'62 );63 64 $info = $this->sendApiRequest($h, $query_vals, 'http://hotaruplugins.com/index.php?page=api');65 66 // save the updated version number to the local db so we can display it on the admin panel until it gets updated.67 if (isset($info['version'])) {68 $sql = "SELECT miscdata_id FROM " . TABLE_MISCDATA ." WHERE miscdata_key = %s";69 $query = $h->db->get_row($h->db->prepare($sql, 'hotaru_latest_version'));70 71 if ($query) {72 // update existing db record73 $sql = "UPDATE " . TABLE_MISCDATA . " SET miscdata_value = %s WHERE miscdata_key = %s";74 $h->db->query($h->db->prepare($sql, $info['version'], 'hotaru_latest_version'));75 } else {76 $sql = "INSERT INTO " . TABLE_MISCDATA . " (miscdata_value, miscdata_key) VALUES (%s, %s)";77 $h->db->query($h->db->prepare($sql, $info['version'], 'hotaru_latest_version'));78 }79 return $info['version'];80 }81 82 return 0;83 84 }85 86 /**87 * Calls external site to get latest available hotaru version number88 *89 * @return bool true90 */91 public function plugin_version_getAll($h)92 {93 $query_vals = array(94 'api_key' => '',95 'format' => 'json',96 'method' => 'hotaru.plugin.version.getAll'97 );98 99 $info = $this->sendApiRequest($h, $query_vals, 'http://hotaruplugins.com/index.php?page=api');100 101 if ($info) {102 // save the updated version numbers to the local db so we can display it on the plugin management panel103 $sql = "SELECT plugin_id, plugin_name, plugin_latestversion FROM " . TABLE_PLUGINS;104 $plugins = $h->db->get_results($h->db->prepare($sql));105 106 if ($plugins) {107 foreach ($plugins as $plugin) {108 if (array_key_exists($plugin->plugin_name, $info)) {109 $sql = "UPDATE " . TABLE_PLUGINS . " SET plugin_latestversion = %s WHERE (plugin_id = %d)";110 $h->db->query($h->db->prepare($sql, $info[$plugin->plugin_name], $plugin->plugin_id));111 //print $plugin->plugin_name . ' ' . $info[$plugin->plugin_name] . '<br/>';112 }113 }114 }115 }116 117 return true;118 }119 120 121 /**122 *123 * @param <type> $search124 */125 public function pluginSearch($h, $search)126 {127 $query_vals = array(128 'api_key' => '',129 'format' => 'json',130 'method' => 'hotaru.plugin.search',131 'args' => $search132 );133 134 $plugins = $this->sendApiRequest($h, $query_vals, 'http://hotaruplugins.com/index.php?page=api');135 136 return $plugins;137 }138 139 /**140 *141 */142 public function pluginTagCloud($h, $number = 20)143 {144 $query_vals = array(145 'api_key' => '',146 'format' => 'json',147 'method' => 'hotaru.plugin.tagcloud',148 'args' => $number149 );150 151 $result = $this->sendApiRequest($h, $query_vals, 'http://hotaruplugins.com/index.php?page=api');152 153 return $result;154 47 } 155 48 … … 163 56 public function sendApiRequest($h, $query_vals, $url) 164 57 { 165 // Generate the POST string 58 // Generate the POST string 166 59 $ret = ''; 167 60 foreach($query_vals as $key => $value) { 168 $ret .= $key.'='.urlencode($value).'&';61 $ret .= $key.'='.urlencode($value).'&'; 169 62 } 170 63 171 64 $ret = rtrim($ret, '&'); 172 65 173 66 $ch = curl_init($url); 174 67 curl_setopt($ch, CURLOPT_HEADER, 0); … … 177 70 $response = curl_exec($ch); 178 71 curl_close ($ch); 179 72 180 73 return json_decode($response, true); 181 74 } 182 183 75 76 184 77 /** 185 78 * Get system data … … 357 250 foreach ($report['hotaru_plugins'] as $key => $value) { 358 251 $output .= $value['order'] . ". " . $key . " v." . $value['version'] . " "; 359 $output .= " (" . $value['plugin_latestversion'] .") ";360 252 if ($value['enabled']) { $output .= "[enabled] \n"; } else { $output .= "[disabled] \n"; } 361 253 } 362 254 } 363 $output .= "\n(Number in brackets above denotes latest versions available at HotaruCMS.org)\n";364 255 365 256 $output .= "\n"; … … 441 332 return $output; 442 333 } 334 335 /* These can be removed after the Cron plugin is updated to no longer use them */ 336 public function hotaru_version() { return false; } 337 public function plugin_version_getAll() { return false; } 443 338 } 444 339 ?> -
trunk/libs/Trackback.php
r2080 r2233 66 66 * Adapted from Pligg.com and SocialWebCMS.com 67 67 */ 68 p ublicfunction detectTrackback($h)68 private function detectTrackback($h) 69 69 { 70 include_once(EXTENSIONS . 'SWCMS/HotaruHttpRequest.php');71 72 70 // Fetch the content of the original url... 73 71 $url = $h->post->origUrl; 74 75 if ($url != 'http://' && $url != ''){ 76 $r = new HotaruHttpRequest($url); 77 $content = $r->DownloadToString(); 78 } else { 79 $content = ''; 80 } 81 72 $content = ($url != 'http://' && $url != '') ? hotaru_http_request($url) : ''; 82 73 $trackback = ''; 83 74 84 75 if (preg_match('/trackback:ping="([^"]+)"/i', $content, $matches) || 85 preg_match('/trackback:ping +rdf:resource="([^>]+)"/i', $content, $matches) || 86 preg_match('/<trackback:ping>([^<>]+)/i', $content, $matches)) { 87 $trackback = trim($matches[1]); 88 76 preg_match('/trackback:ping +rdf:resource="([^>]+)"/i', $content, $matches) || 77 preg_match('/<trackback:ping>([^<>]+)/i', $content, $matches)) { 78 $trackback = trim($matches[1]); 89 79 } elseif (preg_match('/<a[^>]+rel="trackback"[^>]*>/i', $content, $matches)) { 90 80 if (preg_match('/href="([^"]+)"/i', $matches[0], $matches2)) { 91 81 $trackback = trim($matches2[1]); 92 82 } 93 94 83 } elseif (preg_match('/<a[^>]+href=[^>]+>trackback<\/a>/i', $content, $matches)) { 95 84 if (preg_match('/href="([^"]+)"/i', $matches[0], $matches2)) { … … 97 86 } 98 87 } elseif (preg_match('/http:([^ ]+)trackback.php([^<|^ ]+)/i', $content, $matches)) { 99 $trackback = trim($matches[1]); 100 88 $trackback = trim($matches[1]); 101 89 } elseif (preg_match('/trackback:ping="([^"]+)"/', $content, $matches)) { 102 $trackback = trim($matches[1]);90 $trackback = trim($matches[1]); 103 91 } 104 92 105 93 return $trackback; 106 94 } -
trunk/libs/UserAuth.php
r2134 r2233 118 118 { 119 119 // a positive result was returned from the plugin(s) 120 // let's hope the plugin did its own authentication because we've skipped the usual username/pass owrd check!120 // let's hope the plugin did its own authentication because we've skipped the usual username/password check! 121 121 $result = true; 122 122 } … … 158 158 159 159 /** 160 * Update last login 160 * Update last login timeand update user ip 161 161 * 162 162 * @return bool … … 164 164 public function updateUserLastLogin($h) 165 165 { 166 if ($this->id != 0) { 167 $sql = "UPDATE " . TABLE_USERS . " SET user_lastlogin = CURRENT_TIMESTAMP WHERE user_id = %d"; 168 $h->db->query($h->db->prepare($sql, $this->id)); 166 if ($this->id != 0) 167 { 168 $ip = $h->cage->server->testIp('REMOTE_ADDR'); 169 $sql = "UPDATE " . TABLE_USERS . " SET user_lastlogin = CURRENT_TIMESTAMP, user_ip = %s WHERE user_id = %d"; 170 $h->db->query($h->db->prepare($sql, $ip, $this->id)); 169 171 return true; 170 172 } else { -
trunk/libs/Widget.php
r1896 r2233 142 142 $widgets_settings = $h->getSerializedSettings('widgets'); 143 143 144 if ($widgets_settings['widgets']) { 145 $widgets = $widgets_settings['widgets']; // associative array 144 if (!$widgets_settings['widgets']) { return false; } 145 146 $widgets = $widgets_settings['widgets']; // associative array 146 147 147 // return an individual widget 148 if ($widget_name && isset($widgets[$widget_name])) { 149 if (!$h->isActive($widgets[$widget_name]['plugin'])) { 150 return false; 151 } else { 152 return $widgets[$widget_name]; 153 } 148 // return an individual widget 149 if ($widget_name && isset($widgets[$widget_name])) { 150 if (!$h->isActive($widgets[$widget_name]['plugin'])) { 151 return false; 152 } else { 153 return $widgets[$widget_name]; 154 154 } 155 156 $widgets = $this->orderWidgets($widgets); // sorts plugins by "order" 157 158 return $widgets; 159 } 160 return false; 155 } 156 157 $widgets = $this->orderWidgets($widgets); // sorts plugins by "order" 158 159 return $widgets; 161 160 } 162 161 -
trunk/libs/extensions/SWCMS/HotaruHttpRequest.php
r1896 r2233 16 16 * 17 17 **************************************************************************************************** */ 18 19 // @todo Remove SWCMS folder once Stop Spam is updated to use the 20 // functions merged and moved to `functions/funcs.http.php`. 18 21 19 22 class HotaruHttpRequest -
trunk/libs/extensions/ezSQL/mysql/ez_sql_mysql.php
r2080 r2233 215 215 $this->selectDB($this->dbname); 216 216 } 217 218 // Decide whether need for multisite siteid string to be added to query219 if (defined('MULTI_SITE') && MULTI_SITE == 'true' && !strpos($query, '_siteid')) {220 $query = $this->whereMultiSite($query);221 } else {222 // print "missing query" . $query . '<br/>';223 }224 217 225 218 // Perform the query via std mysql_query function.. … … 380 373 return false; 381 374 } 382 383 384 function whereMultisite($query)385 {386 $siteidtables = array('blocked'=>'blocked', 'posts'=>'post', 'comments'=>'comment', 'categories'=>'category', 'users'=>'user',387 'plugins'=>'plugin', 'pluginsettings'=>'plugin', 'tags'=>'tags', 'settings'=>'settings', 'miscdata'=>'miscdata',388 'widgets'=>'widget', 'pluginhooks'=>'pluginhooks');389 390 //$const = eval(MS_TABLES);391 $const = unserialize(MS_TABLES);392 if ($const) { $siteidtables = $const;} else { }393 394 $before ="before: " . $query . "<br/><br/>";395 $after = "no";396 397 // Note, must be case sensitive to avoid text being inserted as from and then being picked up398 if (strpos($query, ' FROM ') !== false) {399 $array = explode('FROM ',$query);400 401 if ($array[0] != 'SHOW COLUMNS ') {402 403 if (!isset($array[1])) { var_dump($array); }404 $array2 = explode(' ', $array[1]);405 if ($array2[0] == '') { $table = $array2[1]; } else { $table = $array2[0]; }406 407 $array3 = explode(DB_PREFIX , $table);408 409 $tablename = $array3[1];410 $tablename = str_replace(',', '', $tablename);411 412 if (array_key_exists($tablename, $siteidtables)) {413 if (stripos($query, $table)) {414 if (stripos($query, 'WHERE') !== false) {415 $array = explode('WHERE ', $query);416 $query = $array[0] . ' WHERE ' . $siteidtables[$tablename] . '_siteid = ' . SITEID . " AND " . $array[1];417 } else {418 $array = $array = explode('FROM ' . $table ,$query);419 $query = $array[0] . ' FROM ' . $table . ' WHERE ' . $siteidtables[$tablename] . '_siteid = ' . SITEID . $array[1];420 }421 422 $after = "<span style='color:red; font-weight:bold;'>AFTER</span>: " . $query . "<br/><br/>";423 }424 }425 }426 }427 428 429 if (stripos($query, 'UPDATE ') !== false) {430 $pattern = '/^UPDATE(.*?)\SET/';431 preg_match($pattern, $query, $matches);432 if ($matches) { $tablename = trim($matches[1]); } else {433 434 }435 $tablename = str_ireplace(DB_PREFIX, '', $tablename);436 437 if (array_key_exists($tablename, $siteidtables)) {438 if (stripos($query, 'WHERE') !== false) {439 $array = explode('WHERE ', $query);440 $query = $array[0] . ' WHERE ' . $siteidtables[$tablename] . '_siteid = ' . SITEID . " AND " . $array[1];441 } else {442 $query = $query . ' WHERE ' . $siteidtables[$tablename] . '_siteid = ' . SITEID;443 }444 445 $after = "<br/><span style='color:red; font-weight:bold;'>AFTER</span>: " . $query . "<br/><br/>";446 }447 }448 449 if (stripos($query, 'INSERT INTO ') !== false) {450 $pattern = '/^INSERT INTO(.*?)\SET/';451 preg_match($pattern, $query, $matches);452 if ($matches) { $tablename = trim($matches[1]); } else {453 $pattern = '/^INSERT INTO(.*?)\(/';454 preg_match($pattern, $query, $matches);455 if ($matches) { $tablename = trim($matches[1]); }456 }457 458 $tablename = str_ireplace(DB_PREFIX, '', $tablename);459 460 if (array_key_exists($tablename, $siteidtables)) {461 if (stripos($query, 'VALUES') !== false) {462 $array = explode('INTO ' . DB_PREFIX . $tablename . ' (', $query);463 $query = 'INSERT INTO ' . DB_PREFIX . $tablename . ' (' . $siteidtables[$tablename] . '_siteid, ' . $array[1];464 465 // $array = explode('VALUES', $query);466 // $values = $array[1];467 // $pattern = '/\(.*?\)/';468 // preg_match_all($pattern, $values, $matches);469 470 $array = explode('VALUES', $query);471 if (!$array[1]) { print 'no 2nd part of array'; $array = explode('VALUES(', $query);}472 $right_side = str_replace("(", "(" . SITEID . ",", $array[1]);473 $query = $array[0] . " VALUES " . $right_side;474 }475 else {476 $array = explode('SET ', $query);477 $query = $array[0] . " SET " . $siteidtables[$tablename] . "_siteid = " . SITEID . ", " . $array[1];478 }479 480 $after = "<br/><span style='color:red; font-weight:bold;'>AFTER</span>: " . $query . "<br/><br/>";481 }482 }483 484 if (stripos($query, 'REPLACE INTO ') !== false) {485 $pattern = '/^REPLACE INTO(.*?)\(/';486 preg_match($pattern, $query, $matches);487 if ($matches) { $tablename = trim($matches[1]); }488 489 $tablename = str_ireplace(DB_PREFIX, '', $tablename);490 491 if (array_key_exists($tablename, $siteidtables)) {492 if (stripos($query, 'VALUES') !== false) {493 $array = explode('INTO ' . DB_PREFIX . $tablename . ' (', $query);494 $query = 'REPLACE INTO ' . DB_PREFIX . $tablename . ' (' . $siteidtables[$tablename] . '_siteid, ' . $array[1];495 $array = explode('VALUES (', $query);496 $query = $array[0] . ' VALUES (' . SITEID . ", " . $array[1];497 }498 }499 500 $after = "<br/><span style='color:red; font-weight:bold;'>AFTER</span>: " . $query . "<br/><br/>";501 }502 503 // if (stripos($query, 'DELETE') !== false) {504 //print ">>>>>>DELETE>>>>>>>>" . $tablename . '<<<<<<<<<<<<<<<<<<br/>';505 // print $before;506 //507 // if (array_key_exists($tablename, $siteidtables)) {508 // if (stripos($query, $table)) {509 // print $query;510 // if (stripos($query, 'WHERE') !== false) {511 // print "here";512 // $array = explode('WHERE ', $query);513 // $query = $array[0] . ' WHERE ' . $siteidtables[$tablename] . '_siteid = ' . SITEID . " AND " . $array[1];514 // } else {515 // print "next";516 // $array = explode('FROM ' . $table ,$query);517 // $query = $array[0] . ' FROM ' . $table . ' WHERE ' . $siteidtables[$tablename] . '_siteid = ' . SITEID . $array[1];518 // }519 //520 // $after = "<span style='color:red; font-weight:bold;'>AFTER</span>: " . $query . "<br/><br/>";521 //print $after;522 // }523 // }524 // }525 526 if (stripos($query, 'TRUNCATE') !== false) {527 528 }529 530 531 //if ($after == 'no') { print $before; }532 // print $before;533 // print $after;534 return $query;535 375 } 536 }537 538 376 ?>