Changeset 2233 for trunk

Show
Ignore:
Timestamp:
11/19/10 15:04:13 (18 months ago)
Author:
nick_ramsay
Message:

[Trunk] Updating with 1.4.2. files.

Location:
trunk
Files:
2 removed
32 modified
1 copied

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/Hotaru.php

    r2134 r2233  
    2626class Hotaru 
    2727{ 
    28         protected $version              = "1.4.1";  // Hotaru CMS version 
     28        protected $version              = "1.4.2";  // Hotaru CMS version 
    2929        protected $isDebug              = false;    // show db queries and page loading time 
    3030        protected $isAdmin              = false;    // flag to tell if we are in Admin or not 
     
    7373                // define shorthand paths 
    7474                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); 
    8587                } 
    8688 
     
    14891491        { 
    14901492                $maintenance = new Maintenance(); 
    1491                 $maintenance->deleteFiles($dir); 
     1493                return $maintenance->deleteFiles($dir); 
    14921494        } 
    14931495         
  • trunk/READ_ME.txt

    r2134 r2233  
    11HOTARU CMS 
    2 Version: 1.4.1 
    3 Released: August 14th 2010 
     2========== 
     3Version: 1.4.2 
     4Released: Nov. 20th, 2010 
    45 
    5 INSTALLATION 
     6Installation 
    67------------ 
    78 
    8 Please visit http://hotarudocs.com/Getting_Started#Installing_and_Upgrading for the most up-to-date version of these instructions. 
     9Please visit http://docs.hotarucms.org/Getting_Started#Installing_and_Upgrading for 
     10the most up-to-date version of these instructions. 
    911 
    1012Instructions last updated: Mar 8th 2010 
    1113 
    1214Requirements 
     15------------ 
    1316 
    14 Hotaru CMS has been tested using PHP 5.2.5 ~ 5.3.2 and MySQL 5.0~.  
     17Hotaru CMS has been tested using PHP 5.2.5 ~ 5.3.2 and MySQL 5.0~. 
    1518 
    1619Upgrading 
     20--------- 
    1721 
    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. 
    2631 
    2732First-time Installation 
     33----------------------- 
    2834 
    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. 
    3846 
    3947Setting up your site 
     48-------------------- 
    4049 
    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. 
    4858 
    4959 
    5060Friendly URLS 
     61------------- 
    5162 
    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. 
     63If you want to use friendly urls, rename `htaccess_default` to `.htaccess`, and 
     64edit it according to the instructions within the htaccess file. Then go 
     65to **Admin -> Settings** and change the **Friendly URLs** setting to true. 
    5366 
    5467Troubleshooting 
     68--------------- 
    5569 
    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. 
     70If you're having trouble installing Hotaru, please post your questions with as 
     71much detail as possible in the forums at http://hotarucms.org. Thanks. 
  • trunk/content/admin_language.php

    r2134 r2233  
    103103$lang["admin_theme_plugins_order_down"] = "Move down"; 
    104104$lang["admin_theme_plugins_details"] = "Details"; 
    105 $lang["admin_theme_plugins_update_available"] = "Update available"; 
    106105$lang["admin_theme_plugins_requires"] = "Requires"; 
    107106$lang["admin_theme_plugins_description"] = "Description"; 
     
    114113$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>."; 
    115114$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 
    117116$lang["admin_theme_plugins_deactivate_all"] = "Turn OFF all plugins"; 
    118117$lang["admin_theme_plugins_activate_all"] = "Turn ON (upgrade) all plugins"; 
     
    263262 
    264263/* 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>."; 
    266265 
    267266/* 404 */ 
  • trunk/content/admin_themes/admin_default/admin_header.php

    r2134 r2233  
    8787                        </a> 
    8888                    </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 
    9790                    <div class="admin-menu-item"> 
    98                         <a href="http://hotarudocs.com"> 
     91                        <a href="http://docs.hotarucms.org"> 
    9992                            <div class="admin-menu-item-icon"> 
    10093                                <img src="<?php echo SITEURL; ?>content/admin_themes/admin_default/images/docs_icon.png" /> 
     
    10598                        <?php if ($h->currentUser->loggedIn) { ?> 
    10699                            <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'); ?>"> 
    108101                                    <div class="admin-menu-item-icon"> 
    109102                                        <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  
    5454                <li>Hotaru CMS <?php echo $h->version; ?></li> 
    5555 
    56                 <?php 
    57  
    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  
    6856                <?php $h->pluginHook('admin_theme_main_stats_post_version'); ?> 
    6957                <?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  
    5656            <?php echo $h->lang["admin_theme_plugins_details"]; ?> 
    5757            &nbsp;&nbsp; 
    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             &nbsp;&nbsp; 
    6158            <img src='<?php echo SITEURL; ?>content/admin_themes/<?php echo ADMIN_THEME; ?>images/uninstall_16.png' alt=""> 
    6259            <?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                          &nbsp;&nbsp; 
    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  
    8160        </span> 
    8261</td></tr> 
     
    9675        $alt = 0; 
    9776        if (!$the_plugins) { $the_plugins = array(); } 
    98         foreach ($the_plugins as $plug) {            
     77        foreach ($the_plugins as $plug) { 
    9978                $alt++; 
    10079                $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 
    10381                echo "<tr class='table_tr table_row_" . $alt % 2 . "'>\n"; 
    10482                echo "<td class='table_active'>" . $plug['active'] . "</td>\n"; 
     
    132110                } 
    133111 
    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>"; } 
    135112                echo "</td>"; 
    136113                echo "<td class='table_description_close'><a class='table_hide_details' href='#'>"; 
     
    195172                $alt++; 
    196173                $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 
    199175                echo "<tr id='table_tr' class='table_row_" . $alt % 2 . "'>\n"; 
    200176                echo "<td class='table_uninstalled_plugin'>" . $plug['name'] . " " . $plug['version'] . "<br />\n"; 
     
    220196                        echo $h->lang["admin_theme_plugins_readmetxt"] . "</a>";                         
    221197                } 
    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 
    223199                echo "</td>\n"; 
    224200                echo "<td class='table_description_close'><a class='table_hide_details' href='#'>"; 
     
    241217<div id="plugin_management_notice" class="info_box gray_box" style="margin-top: 2.0em";> 
    242218        <p class="info_header"><?php echo $h->lang["admin_theme_plugins_guide"]; ?></p> 
    243         <?php $h->pluginHook('plugins_guide_top'); ?> 
    244219        &raquo; <?php echo $h->lang["admin_theme_plugins_guide1"]; ?><br /> 
    245220        &raquo; <?php echo $h->lang["admin_theme_plugins_guide2"]; ?><br /> 
    246221        &raquo; <?php echo $h->lang["admin_theme_plugins_guide3"]; ?><br /> 
    247222        &raquo; <?php echo $h->lang["admin_theme_plugins_guide4"]; ?><br /> 
    248         <?php $h->pluginHook('plugins_guide_bottom'); ?> 
    249223</div> 
    250  
    251  
    252  
    253 <?php $h->pluginHook('plugins_bottom'); ?> 
    254  
    255  
    256 <?php 
    257  
    258  
    259 ?> 
  • trunk/content/admin_themes/admin_default/settings.php

    r2134 r2233  
    5151                { 
    5252                        if ($ls->settings_show == 'N') { continue; } // skip this row 
    53                         if ($ls->settings_name == 'MULTI_SITE' && SITEID !=1) { continue; } // skip this row 
    5453                 
    5554                        // replace underscores with spaces and make the first character of the setting name uppercase. 
  • trunk/content/themes/default/header.php

    r2134 r2233  
    4040                        // plugin hook 
    4141                        $result = $h->pluginHook('header_meta'); 
    42                         if (!isset($result) || !is_array($result)) { ?> 
     42                        if (!$result) { ?> 
    4343                                <meta name="description" content="<?php echo $h->lang['header_meta_description']; ?>" /> 
    4444                                <meta name="keywords" content="<?php echo $h->lang['header_meta_keywords']; ?>" /> 
  • trunk/content/themes/default/settings.php

    r2080 r2233  
    3232  
    3333// Default settings: 
    34 $defaults['tagline'] = "Social Bookmarking"; 
     34$defaults['tagline'] = "Possibly the greatest site on the Internet."; 
    3535  
    3636// Get settings from database if they exist... 
  • trunk/hotaru_settings_default.php

    r1896 r2233  
    33 
    44// Paths 
    5 define('BASEURL', "http://example.com/");               // e.g. http://example.com/ (needs trailing cache) 
     5define('BASEURL', "http://example.com/");               // e.g. http://example.com/ (needs trailing slash) 
    66 
    77// Database details 
  • trunk/install/index.php

    r2080 r2233  
    4747    "ADMIN" => "/../admin/", 
    4848    "INSTALL" => "/", 
    49     "CACHE" => "/../cache/1/", 
     49    "CACHE" => "/../cache/", 
    5050    "LIBS" => "/../libs/", 
    5151    "EXTENSIONS" => "/../libs/extensions/", 
     
    102102                } else { 
    103103                        $db = init_database(); 
    104                         database_creation();        // Creates the database tables 
     104                        database_creation($h);        // Creates the database tables 
    105105                } 
    106106                break; 
     
    225225        global $db; 
    226226        global $h; 
    227         global $cage; 
    228         global $settings_file_exists; 
     227        global $cage; 
     228        global $settings_file_exists; 
    229229 
    230230        //$h  = new Hotaru(); // overwrites current global with fully initialized Hotaru object 
     
    470470 * Step 2 of installation - Creates database tables 
    471471 */ 
    472 function database_creation() 
     472function database_creation($h) 
    473473{ 
    474474        global $lang; 
     
    575575        // Make sure that the cache folders have been created before we call $h for the first time 
    576576        // 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 folder 
     577        $dirs = array('debug_logs/' , 'db_cache/', 'css_js_cache/', 'html_cache/', 'rss_cache/', 'lang_cache/');  
    578578 
    579579        foreach ($dirs as $dir) { 
     
    594594 
    595595        // 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"; 
    597597 
    598598        $error = 0; 
     
    749749         
    750750        $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);  
    767756        } 
    768757 
     
    773762 
    774763        // 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"; 
    777765        echo "<div class='install_content'>" . $lang['install_step4_installation_delete'] . "</div>\n"; 
    778766 
     
    784772            $php_module_not_found = false; 
    785773 
    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 
    790780                /* No longer required: 'bcmath' => 'http://php.net/manual/en/book.bc.php' */ 
    791781 
     
    811801        } 
    812802 
    813         if ($folder_deleted == 0) { 
    814             // Confirm delete and continue install 
    815             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  
    827803        echo "<br/><div class='install_content'>" . $lang['install_step4_installation_go_play'] . "</div><br/><br/>\n"; 
    828804 
     
    853829        $systeminfo = new SystemInfo(); 
    854830        $systeminfo->hotaru_feedback($h); 
    855  
    856         //refresh database to get all recent plugin versions 
    857         $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 //      } 
    870831 
    871832        echo "<br/>" . $lang['upgrade_step3_instructions'] . "<br/><br/>\n"; 
  • trunk/install/install-upgrade.php

    r2134 r2233  
    378378        if ($old_version == "1.1.2") { 
    379379 
    380                 // System Feedback 
    381                 $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  
    388380                // Remove ON from constant names 
    389381                $sql = "UPDATE " . TABLE_SETTINGS . " SET settings_name = %s WHERE settings_name = %s"; 
     
    533525                } 
    534526 
    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: 
    548586                $tables = array( 
    549587                        'blocked'=>'blocked','categories'=>'category', 
     
    554592                ); 
    555593 
    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"; 
    561600                                $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 
    572604                        $sql = "SHOW INDEX FROM `" . DB_PREFIX . $table . "` WHERE KEY_NAME = '" . $column . "_siteid'"; 
    573605                        $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; 
    576608                                $h->db->query($sql); 
    577609                        } 
    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 
    713689        } 
    714690 
     
    718694} 
    719695 
    720  
    721  
    722  
    723 //      // loop through all sites to insert this setting into each one's SETTING TABLE 
    724 //      $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  
    743696?> 
  • trunk/install/install_functions.php

    r1896 r2233  
    135135 */ 
    136136function delTree($dir) { 
    137     $files = glob( $dir . '*', GLOB_MARK ); 
    138     foreach( $files as $file ){ 
    139         if( is_dir( $file ) ) 
    140             delTree( $file ); 
    141         else 
    142             unlink( $file ); 
    143     } 
    144137 
    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 ); 
    146148} 
  • trunk/install/install_language.php

    r2080 r2233  
    4848$lang["install_next"] = "Next"; 
    4949$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>."; 
    5151 
    5252/* Install Step 1 */ 
     
    139139$lang["install_step4"] = "Step 4/4: Completion"; 
    140140$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 
    145143$lang["install_step4_form_check_php"] = "Check PHP Setup"; 
    146144$lang["install_step4_form_check_php_warning"] = "Note: Your server is missing the PHP module: "; 
  • trunk/install/install_tables.php

    r2080 r2233  
    5252                        `blocked_updatedts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 
    5353                        `blocked_updateby` int(20) NOT NULL DEFAULT 0, 
    54                         `blocked_siteid` int(20) NOT NULL DEFAULT 1, 
    55                         INDEX (`blocked_siteid`), 
    5654                        INDEX  (`blocked_type`) 
    5755                ) ENGINE=" . DB_ENGINE . " DEFAULT CHARSET=" . DB_CHARSET . " COLLATE=" . DB_COLLATE . " COMMENT='Blocked IPs, users, emails, etc';"; 
     
    7573                        `category_order` int(11) NOT NULL DEFAULT '0', 
    7674                        `category_desc` text NULL, 
    77                         `category_keywords` varchar(255) NOT NULL, 
     75                        `category_keywords` varchar(255) NULL, 
    7876                        `category_updatedts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,  
    7977                        `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`) 
    8379                ) ENGINE=" . DB_ENGINE . " DEFAULT CHARSET=" . DB_CHARSET . " COLLATE=" . DB_COLLATE . " COMMENT='Categories';"; 
    8480                echo $lang['install_step2_creating_table'] . ": '" . DB_PREFIX . $table_name . "'...<br />\n"; 
     
    10197                        `comment_user_id` int(20) NOT NULL DEFAULT '0', 
    10298                        `comment_parent` int(20) DEFAULT '0', 
    103                         `comment_date` timestamp NOT NULL, 
     99                        `comment_date` timestamp NULL, 
    104100                        `comment_status` varchar(32) NOT NULL DEFAULT 'approved', 
    105                         `comment_content` text NOT NULL, 
     101                        `comment_content` text NULL, 
    106102                        `comment_votes_up` smallint(11) NOT NULL DEFAULT '0', 
    107103                        `comment_votes_down` smallint(11) NOT NULL DEFAULT '0', 
    108104                        `comment_subscribe` tinyint(1) NOT NULL DEFAULT '0', 
    109105                        `comment_updateby` int(20) NOT NULL DEFAULT 0, 
    110                         `comment_siteid` int(20) NOT NULL DEFAULT 1, 
    111                         INDEX (`comment_siteid`), 
    112106                        FULLTEXT (`comment_content`), 
    113107                        INDEX  (`comment_archived`), 
     
    131125                        `cvote_user_id` int(11) NOT NULL DEFAULT '0', 
    132126                        `cvote_user_ip` varchar(32) NOT NULL DEFAULT '0', 
    133                         `cvote_date` timestamp NOT NULL, 
     127                        `cvote_date` timestamp NULL, 
    134128                        `cvote_rating` smallint(11) NOT NULL DEFAULT '0', 
    135129                        `cvote_reason` tinyint(3) NOT NULL DEFAULT 0, 
     
    166160                        `message_from` int(20) NOT NULL DEFAULT 0, 
    167161                        `message_to` int(20) NOT NULL DEFAULT 0, 
    168                         `message_date` timestamp NOT NULL, 
     162                        `message_date` timestamp NULL, 
    169163                        `message_subject` varchar(255) NOT NULL DEFAULT '', 
    170164                        `message_content` text NULL, 
     
    185179                $sql = "CREATE TABLE `" . DB_PREFIX . $table_name . "` ( 
    186180                        `miscdata_id` int(20) NOT NULL AUTO_INCREMENT PRIMARY KEY, 
    187                         `miscdata_key` varchar(64) NOT NULL, 
    188                         `miscdata_value` text NOT NULL DEFAULT '', 
    189                         `miscdata_default` text NOT NULL DEFAULT '', 
     181                        `miscdata_key` varchar(64) NULL, 
     182                        `miscdata_value` text NULL, 
     183                        `miscdata_default` text NULL, 
    190184                        `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 
    194186                ) ENGINE=" . DB_ENGINE . " DEFAULT CHARSET=" . DB_CHARSET . " COLLATE=" . DB_COLLATE . " COMMENT='Miscellaneous Data';"; 
    195187                echo $lang['install_step2_creating_table'] . ": '" . DB_PREFIX . $table_name . "'...<br />\n"; 
     
    241233                        `plugin_updateby` int(20) NOT NULL DEFAULT 0, 
    242234                        `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`) 
    246236                ) ENGINE=" . DB_ENGINE . " DEFAULT CHARSET=" . DB_CHARSET . " COLLATE=" . DB_COLLATE . " COMMENT='Application Plugins';"; 
    247237                echo $lang['install_step2_creating_table'] . ": '" . DB_PREFIX . $table_name . "'...<br />\n"; 
     
    258248                        `plugin_updatedts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 
    259249                        `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`) 
    263251                ) ENGINE=" . DB_ENGINE . " DEFAULT CHARSET=" . DB_CHARSET . " COLLATE=" . DB_COLLATE . " COMMENT='Plugins Hooks';"; 
    264252                echo $lang['install_step2_creating_table'] . ": '" . DB_PREFIX . $table_name . "'...<br />\n"; 
     
    271259                $sql = "CREATE TABLE `" . DB_PREFIX . $table_name . "` ( 
    272260                        `psetting_id` int(20) NOT NULL AUTO_INCREMENT PRIMARY KEY, 
    273                         `plugin_folder` varchar(64) NOT NULL, 
     261                        `plugin_folder` varchar(64) NULL, 
    274262                        `plugin_setting` varchar(64) NULL, 
    275263                        `plugin_value` text NULL, 
    276264                        `plugin_updatedts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 
    277265                        `plugin_updateby` int(20) NOT NULL DEFAULT 0, 
    278                         `plugin_siteid` int(20) NOT NULL DEFAULT 1, 
    279                         INDEX (`plugin_siteid`), 
    280266                        INDEX  (`plugin_folder`) 
    281267                ) ENGINE=" . DB_ENGINE . " DEFAULT CHARSET=" . DB_CHARSET . " COLLATE=" . DB_COLLATE . " COMMENT='Plugins Settings';"; 
     
    294280                        `post_updatedts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,  
    295281                        `post_author` int(20) NOT NULL DEFAULT 0, 
    296                         `post_date` timestamp NOT NULL, 
    297                         `post_pub_date` timestamp NOT NULL, 
     282                        `post_date` timestamp NULL, 
     283                        `post_pub_date` timestamp NULL, 
    298284                        `post_status` varchar(32) NOT NULL DEFAULT 'processing', 
    299285                        `post_type` varchar(32) NULL, 
     
    310296                        `post_subscribe` tinyint(1) NOT NULL DEFAULT '0', 
    311297                        `post_updateby` int(20) NOT NULL DEFAULT 0, 
    312                         `post_siteid` int(20) NOT NULL DEFAULT 1, 
    313                         INDEX (`post_siteid`), 
    314298                        FULLTEXT (`post_title`, `post_domain`, `post_url`, `post_content`, `post_tags`), 
    315299                        INDEX  (`post_archived`), 
     
    351335                        `vote_user_id` int(11) NOT NULL DEFAULT '0', 
    352336                        `vote_user_ip` varchar(32) NOT NULL DEFAULT '0', 
    353                         `vote_date` timestamp NOT NULL, 
     337                        `vote_date` timestamp NULL, 
    354338                        `vote_type` varchar(32) NULL, 
    355339                        `vote_rating` smallint(11) NOT NULL DEFAULT '0', 
     
    362346        }  
    363347 
    364  
    365         // RELATES TABLE 
    366  
    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          
    385348        // SETTINGS TABLE 
    386349         
     
    388351                $sql = "CREATE TABLE `" . DB_PREFIX . $table_name . "` ( 
    389352                        `settings_id` int(20) NOT NULL AUTO_INCREMENT PRIMARY KEY, 
    390                         `settings_name` varchar(64) NOT NULL, 
    391                         `settings_value` text NOT NULL DEFAULT '', 
    392                         `settings_default` text NOT NULL DEFAULT '', 
    393                         `settings_note` text NOT NULL DEFAULT '', 
     353                        `settings_name` varchar(64) NULL, 
     354                        `settings_value` text NULL, 
     355                        `settings_default` text NULL, 
     356                        `settings_note` text NULL, 
    394357                        `settings_show` enum('Y','N') NOT NULL DEFAULT 'Y', 
    395358                        `settings_updatedts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 
    396359                        `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`) 
    400361                ) ENGINE=" . DB_ENGINE . " DEFAULT CHARSET=" . DB_CHARSET . " COLLATE=" . DB_COLLATE . " COMMENT='Application Settings';"; 
    401362                echo $lang['install_step2_creating_table'] . ": '" . DB_PREFIX . $table_name . "'...<br />\n"; 
     
    479440                $sql = "INSERT INTO " . DB_PREFIX . $table_name . " (settings_name, settings_value, settings_default, settings_note) VALUES (%s, %s, %s, %s)"; 
    480441                $db->query($db->prepare($sql, 'SMTP_PASSWORD', '', '', '')); 
    481                  
    482                 // Sys Feedback 
    483                 $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 Sites 
    487                 $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')); 
    489442 
    490443                echo $lang['install_step2_adding_data'] . ": '" . DB_PREFIX . $table_name . "'...<br />\n"; 
    491444 
    492445        } 
    493          
    494          
    495         // SITE TABLE - for multiple sites 
    496  
    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 0 
    504                 ) 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          
    509446         
    510447        // TAGS TABLE - tags 
     
    516453                        `tags_archived` enum('Y','N') NOT NULL DEFAULT 'N', 
    517454                        `tags_updatedts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,  
    518                         `tags_date` timestamp NOT NULL, 
     455                        `tags_date` timestamp NULL, 
    519456                        `tags_word` varchar(64) NOT NULL DEFAULT '', 
    520457                        `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`), 
    524459                        INDEX  (`tags_archived`) 
    525460                ) ENGINE=" . DB_ENGINE . " DEFAULT CHARSET=" . DB_CHARSET . " COLLATE=" . DB_COLLATE . " COMMENT='Post Tags';"; 
     
    549484        if ($table_name == "tokens") { 
    550485                $sql = "CREATE TABLE `" . DB_PREFIX . $table_name . "` ( 
    551                         `token_sid` varchar(32) NOT NULL, 
    552                         `token_key` CHAR(32) NOT NULL, 
     486                        `token_sid` varchar(32) NULL, 
     487                        `token_key` CHAR(32) NULL, 
    553488                        `token_stamp` INT(11) NOT NULL default '0', 
    554489                        `token_action` varchar(64), 
     
    566501                        `user_id` int(20) NOT NULL AUTO_INCREMENT PRIMARY KEY, 
    567502                        `user_updatedts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 
    568                         `user_username` varchar(32) NOT NULL, 
     503                        `user_username` varchar(32) NULL, 
    569504                        `user_role` varchar(32) NOT NULL DEFAULT 'member', 
    570                         `user_date` timestamp NOT NULL, 
     505                        `user_date` timestamp NULL, 
    571506                        `user_password` varchar(64) NOT NULL DEFAULT '', 
    572507                        `user_password_conf` varchar(128) NULL, 
     
    574509                        `user_email_valid` tinyint(3) NOT NULL DEFAULT 0, 
    575510                        `user_email_conf` varchar(128) NULL, 
    576                         `user_permissions` text NOT NULL DEFAULT '', 
     511                        `user_permissions` text NULL, 
    577512                        `user_ip` varchar(32) NOT NULL DEFAULT '0', 
    578513                        `user_lastlogin` timestamp NULL, 
    579514                        `user_lastvisit` timestamp NULL, 
    580515                        `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`), 
    584517                        KEY `user_email` (`user_email`)                  
    585518                ) ENGINE=" . DB_ENGINE . " DEFAULT CHARSET=" . DB_CHARSET . " COLLATE=" . DB_COLLATE . " COMMENT='Users and Roles';"; 
     
    622555                        `useract_key2` varchar(255) NULL, 
    623556                        `useract_value2` text NULL, 
    624                         `useract_date` timestamp NOT NULL, 
     557                        `useract_date` timestamp NULL, 
    625558                        `useract_updateby` int(20) NOT NULL DEFAULT 0,  
    626559                        INDEX  (`useract_userid`) 
     
    641574                        `widget_function` varchar(255) NULL,  
    642575                        `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 
    646577                ) ENGINE=" . DB_ENGINE . " DEFAULT CHARSET=" . DB_CHARSET . " COLLATE=" . DB_COLLATE . " COMMENT='Widgets';"; 
    647578                echo $lang['install_step2_creating_table'] . ": '" . DB_PREFIX . $table_name . "'...<br />\n"; 
  • trunk/libs/AdminPages.php

    r2134 r2233  
    226226        { 
    227227                $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"; } 
    229228                $results = $db->get_results($db->prepare($sql)); 
    230229                if ($results) { return $results; } else { return false; } 
  • trunk/libs/Announcements.php

    r2080 r2233  
    8888                $announcements = array(); 
    8989 
    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']); 
    103101                } 
    104102                 
  • trunk/libs/Debug.php

    r2134 r2233  
    123123        { 
    124124                $sysinfo = new SystemInfo(); 
    125                 $sysinfo->plugin_version_getAll($h); 
    126          
     125 
    127126                $report = $sysinfo->getSystemData($h); 
    128127                 
  • trunk/libs/EmailFunctions.php

    r2134 r2233  
    6363                if (!$this->to) { $this->to = SITE_NAME . ' <' . SITE_EMAIL . '>'; } 
    6464                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).'?='; 
    6568                 
    6669                if (SMTP == 'true') 
  • trunk/libs/IncludeCssJs.php

    r2080 r2233  
    383383                 
    384384                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"; 
    386386                } 
    387387                 
    388388                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"; 
    390390                } 
    391391                 
  • trunk/libs/Initialize.php

    r2080 r2233  
    3636        public function __construct($h) 
    3737        { 
    38  
    3938                // session to be used by CSRF, etc. 
    4039                if (!isset($_SESSION['HotaruCMS'])) { 
    41                         session_start(); 
     40                        @session_start(); 
    4241                        $_SESSION['HotaruCMS'] = time(); 
    4342                } 
     
    4544                // The order here is important! 
    4645                $this->setDefaultTimezone(); 
    47                 $this->setTableConstants();                              
     46                $this->setTableConstants(); 
     47 
     48                $this->MakeCacheFolders(); 
    4849 
    4950                $this->getFiles(); 
     
    5152                $this->db = $this->initDatabase(); 
    5253 
    53                 $this->getCurrentSiteID(); 
    5454                $this->errorReporting(); 
    5555 
     
    100100                 
    101101                // 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 
    103105                        $fh = fopen($filename, 'w') or die("Sorry, I can't open cache/debug_logs/error_log.php"); 
    104106                        fwrite($fh, "<?php die(); ?>\r\n"); 
     
    132134                        "TABLE_POSTVOTES"=>"postvotes", 
    133135                        "TABLE_SETTINGS"=>"settings", 
    134                         "TABLE_SITE"=>"site", 
    135136                        "TABLE_TAGS"=>"tags", 
    136137                        "TABLE_TEMPDATA"=>"tempdata", 
     
    147148                } 
    148149        } 
    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 TRUE 
    156                 $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 sanitizeTags 
    162                     $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_tables 
    177                         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 folder 
    207  
    208                     foreach ($dirs as $dir) { 
    209                         if (!is_dir(CACHE . $dir)) { 
    210                             mkdir(CACHE . $dir); 
    211                         } 
    212                     } 
    213                      
    214                 } 
    215  
    216                 return false; 
    217         } 
    218150 
    219151        /** 
     
    247179                require_once(FUNCTIONS . 'funcs.times.php'); 
    248180                require_once(FUNCTIONS . 'funcs.files.php'); 
     181                require_once(FUNCTIONS . 'funcs.http.php');  
    249182        } 
    250183         
     
    290223        /** 
    291224         * Returns all site settings 
    292          * @param <int> $siteid 
    293225         *  
    294226         * @return <bool> 
     
    304236                { 
    305237                        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); 
    307239                        } 
    308240                } 
     
    312244         
    313245         
     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 
    314271        /** 
    315272         * Set up database cache 
     
    322279                $this->db->cache_timeout = DB_CACHE_DURATION; // Note: this is hours 
    323280                $this->db->cache_dir = CACHE . 'db_cache'; 
     281 
    324282                if (DB_CACHE == "true") { 
    325283                        $this->db->use_disk_cache = true; 
     
    359317        public function setUpJsConstants() 
    360318        { 
     319                if (!defined('SITEURL')) { define("SITEURL", BASEURL); } 
     320 
    361321                // Start timer if debugging 
    362322                $global_js_var = "jQuery('document').ready(function($) {BASE = '" . BASE . "'; BASEURL = '". SITEURL ."'; SITEURL = '". SITEURL ."'; ADMIN_THEME = '" . ADMIN_THEME . "'; THEME = '" . THEME . "';});"; 
    363323                $JsConstantsFile = "css_js_cache/JavascriptConstants.js"; 
    364324         
    365                 if (!file_exists(CACHE . $JsConstantsFile)) { 
     325                if (!file_exists(CACHE . $JsConstantsFile))  
     326                { 
     327                        // write the JavascriptConstants file 
    366328                        $JsConstantsPath = CACHE . $JsConstantsFile; 
    367329                        $JsConstantsfh = fopen($JsConstantsPath, 'w') or die ("Can't open file");        
  • trunk/libs/InspektExtras.php

    r1896 r2233  
    168168                 
    169169                // 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                /* 
    171172                require_once(BASE . 'Hotaru.php'); 
    172173                $h = new Hotaru(); 
     
    178179                        } 
    179180                } 
     181                */ 
    180182                 
    181183                require_once(EXTENSIONS . 'htmLawed/htmLawed.php'); 
  • trunk/libs/Language.php

    r2134 r2233  
    273273                $cache = CACHE.'lang_cache/'; 
    274274                $file = $cache."language.php"; 
     275 
     276                // write the file 
    275277                $fh = fopen($file, 'w+') or die("Sorry, I can't open ".$file); 
    276278                if( flock($fh, LOCK_EX) ) { // do an exclusive lock 
  • trunk/libs/PageHandling.php

    r2080 r2233  
    185185        { 
    186186                // if the title is already set... 
    187                 if ($h->pageTitle != "") 
     187                if ($h->pageTitle) 
    188188                { 
    189189                        // replace [delimiter] text with the specified delimiter: 
     
    355355                                         
    356356                                        // 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) { 
    358358                                                $url .= $h->getCatSafeName($h->post->category) . '/'; 
    359359                                        } 
  • trunk/libs/PluginManagement.php

    r2134 r2233  
    428428                $h->clearCache('lang_cache', false); 
    429429                 
    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); 
    432432                 
    433433                $h->messages[$h->lang["admin_plugins_uninstall_all_done"]] = 'green'; 
     
    523523        public function sortPluginHooks($h) 
    524524        { 
    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)); 
    533527                 
    534528                // 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)); 
    536530                 
    537531                $values = ''; 
     
    554548                } 
    555549        } 
    556          
    557550 
    558         /** 
    559          * Get all pluginhooks, truncate the table and refill it, therefore refreshing phook_ids 
    560          */ 
    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 $sql 
    572                  
    573                 // Add plugin hooks back into the hooks table 
    574                 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 comma 
    585                         $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         } 
    589551         
    590552        /** 
     
    608570        } 
    609571 
    610          
    611         /** 
    612          * Update Plugins 
    613          * 
    614          * @param <type> $h 
    615          */ 
    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 ftpsettings 
    629                 $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 curl 
    638                 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                 // unzip 
    652                 //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 file 
    664                     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 resource 
    680                 $ch = curl_init(); 
    681  
    682                 // set URL and other appropriate options 
    683                 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 PHP 
    689                 curl_setopt($ch, CURLOPT_TIMEOUT, 30); # and also for CURL 
    690  
    691                 //don't fetch the actual page, you only want to check the connection is ok 
    692                 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 resource 
    707                 $ch = curl_init(); 
    708  
    709                 // set URL and other appropriate options 
    710                 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 PHP 
    716                 curl_setopt($ch, CURLOPT_TIMEOUT, 300); # and also for CURL 
    717  
    718                 //don't fetch the actual page, you only want to check the connection is ok 
    719                 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 above 
    728                         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 log 
    778                     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 ok 
    783                 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 log 
    800 //                  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 ok 
    805                 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 body 
    821                 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 do 
    842                 // 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         } 
    892572 
    893573        /** 
  • trunk/libs/SystemInfo.php

    r2134 r2233  
    2525 */ 
    2626class SystemInfo 
    27 {        
    28          
     27{ 
    2928        /** 
    3029         * Calls external site to provide system info feedback report 
     
    3534        { 
    3635                $report = $h->generateReport("object"); 
    37  
     36                 
    3837                $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) 
    4342                ); 
    44  
     43                 
    4544                $info = $this->sendApiRequest($h, $query_vals, 'http://api.hotarucms.org/index.php?page=api'); 
    4645                 
    4746                return true; 
    48         } 
    49  
    50  
    51         /** 
    52          * Calls external site to get latest available hotaru version number 
    53          * 
    54          * @return string versionnumber 
    55          */ 
    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 record 
    73                         $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 number 
    88          * 
    89          * @return bool true 
    90          */ 
    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 panel 
    103                     $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> $search 
    124          */ 
    125         public function pluginSearch($h, $search) 
    126         { 
    127                 $query_vals = array( 
    128                     'api_key' => '', 
    129                     'format' => 'json', 
    130                     'method' => 'hotaru.plugin.search', 
    131                     'args' => $search 
    132                 ); 
    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' => $number 
    149                 ); 
    150  
    151                  $result = $this->sendApiRequest($h, $query_vals, 'http://hotaruplugins.com/index.php?page=api'); 
    152  
    153                  return $result; 
    15447        } 
    15548 
     
    16356        public function sendApiRequest($h, $query_vals, $url) 
    16457        { 
    165                 // Generate the POST string 
     58                // Generate the POST string  
    16659                $ret = ''; 
    16760                foreach($query_vals as $key => $value) { 
    168                     $ret .= $key.'='.urlencode($value).'&'; 
     61                        $ret .= $key.'='.urlencode($value).'&'; 
    16962                } 
    17063 
    17164                $ret = rtrim($ret, '&'); 
    172  
     65                 
    17366                $ch = curl_init($url); 
    17467                curl_setopt($ch, CURLOPT_HEADER, 0); 
     
    17770                $response = curl_exec($ch); 
    17871                curl_close ($ch); 
    179  
     72                 
    18073                return json_decode($response, true); 
    18174        } 
    182          
    183          
     75 
     76 
    18477        /** 
    18578         * Get system data 
     
    357250                        foreach ($report['hotaru_plugins'] as $key => $value) { 
    358251                                $output .= $value['order'] . ". " . $key . " v." . $value['version'] . " "; 
    359                                 $output .= " (" . $value['plugin_latestversion']  .") "; 
    360252                                if ($value['enabled']) { $output .= "[enabled] \n"; } else { $output .= "[disabled] \n"; }                               
    361253                        } 
    362254                } 
    363                 $output .= "\n(Number in brackets above denotes latest versions available at HotaruCMS.org)\n"; 
    364255                 
    365256                $output .= "\n"; 
     
    441332                return $output; 
    442333        } 
     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; } 
    443338} 
    444339?> 
  • trunk/libs/Trackback.php

    r2080 r2233  
    6666         * Adapted from Pligg.com and SocialWebCMS.com 
    6767         */ 
    68         public function detectTrackback($h) 
     68        private function detectTrackback($h) 
    6969        { 
    70                 include_once(EXTENSIONS . 'SWCMS/HotaruHttpRequest.php'); 
    71                  
    7270                // Fetch the content of the original url... 
    7371                $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) : ''; 
    8273                $trackback = ''; 
    83                  
     74 
    8475                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]); 
    8979                } elseif (preg_match('/<a[^>]+rel="trackback"[^>]*>/i', $content, $matches)) { 
    9080                        if (preg_match('/href="([^"]+)"/i', $matches[0], $matches2)) { 
    9181                                $trackback = trim($matches2[1]); 
    9282                        } 
    93                  
    9483                } elseif (preg_match('/<a[^>]+href=[^>]+>trackback<\/a>/i', $content, $matches)) { 
    9584                        if (preg_match('/href="([^"]+)"/i', $matches[0], $matches2)) { 
     
    9786                        } 
    9887                } elseif (preg_match('/http:([^ ]+)trackback.php([^<|^ ]+)/i', $content, $matches)) { 
    99                                 $trackback = trim($matches[1]); 
    100                  
     88                        $trackback = trim($matches[1]); 
    10189                } elseif (preg_match('/trackback:ping="([^"]+)"/', $content, $matches)) { 
    102                                 $trackback = trim($matches[1]); 
     90                        $trackback = trim($matches[1]); 
    10391                } 
    104                  
     92 
    10593                return $trackback; 
    10694        } 
  • trunk/libs/UserAuth.php

    r2134 r2233  
    118118                { 
    119119                        // 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/passowrd check! 
     120                        // let's hope the plugin did its own authentication because we've skipped the usual username/password check! 
    121121                        $result = true; 
    122122                }  
     
    158158         
    159159        /** 
    160          * Update last login 
     160         * Update last login timeand update user ip 
    161161         * 
    162162         * @return bool 
     
    164164        public function updateUserLastLogin($h) 
    165165        { 
    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)); 
    169171                        return true; 
    170172                } else { 
  • trunk/libs/Widget.php

    r1896 r2233  
    142142                $widgets_settings = $h->getSerializedSettings('widgets');  
    143143                 
    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 
    146147                         
    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];  
    154154                        } 
    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; 
    161160        } 
    162161         
  • trunk/libs/extensions/SWCMS/HotaruHttpRequest.php

    r1896 r2233  
    1616 * 
    1717 **************************************************************************************************** */ 
     18 
     19// @todo Remove SWCMS folder once Stop Spam is updated to use the  
     20// functions merged and moved to `functions/funcs.http.php`.  
    1821 
    1922class HotaruHttpRequest 
  • trunk/libs/extensions/ezSQL/mysql/ez_sql_mysql.php

    r2080 r2233  
    215215                $this->selectDB($this->dbname); 
    216216            } 
    217  
    218                 // Decide whether need for multisite siteid string to be added to query 
    219                 if (defined('MULTI_SITE') && MULTI_SITE == 'true' && !strpos($query, '_siteid')) {  
    220                         $query = $this->whereMultiSite($query); 
    221                 } else { 
    222                     // print "missing query" . $query . '<br/>'; 
    223                 } 
    224217 
    225218            // Perform the query via std mysql_query function.. 
     
    380373            return false; 
    381374        } 
    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 up 
    398             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; 
    535375        } 
    536     } 
    537  
    538376?>