Ejemplo n.º 1
0
 public function content()
 {
     global $dbh, $postvar, $getvar, $instance;
     $version_info = main::latest_version();
     $current_version = $version_info['THT'];
     $new_version_download = $version_info['THT_DL'];
     $running_version = $dbh->config('version');
     $install_check = $this->checkDir(INC . "../install/");
     $conf_check = $this->checkPerms(INC . "/conf.inc.php");
     if ($current_version == $running_version) {
         $updatemsg = "<span style='color:green'>Up-To-Date</span>";
         $upgrademsg = "";
     } else {
         $updatemsg = "<span style='color:red'>Upgrade Avaliable</span>";
         $upgrademsg = "<div class='warn'><img src='../themes/icons/error.png' alt='' /> There is a new version ({$current_version}) avaliable! <a href = '" . $new_version_download . "' target = '_blank'>Please download it here</a> and upgrade!</div>";
     }
     unset($current_version);
     unset($running_version);
     $stats['VERSION'] = $dbh->config('version');
     $stats['THEME'] = $dbh->config('theme');
     $stats['CENABLED'] = main::cleaninteger($dbh->config('cenabled'));
     $stats['SVID'] = main::cleaninteger($dbh->config('show_version_id'));
     $stats['SENABLED'] = main::cleaninteger($dbh->config('senabled'));
     $stats['DEFAULT'] = $dbh->config('default_page');
     $stats['EMETHOD'] = $dbh->config('emailmethod');
     $stats['SIGNENABLE'] = main::cleaninteger($dbh->config('general'));
     $stats['MULTI'] = main::cleaninteger($dbh->config('multiple'));
     $stats['UPDATE'] = $updatemsg;
     $stats['UPG_BOX'] = $upgrademsg;
     $stats_box = style::replaceVar('tpl/admin/home/stats.tpl', $stats);
     $content = '<strong>Welcome to your Admin Dashboard!</strong><br />Welcome to the dashboard of your Admin Control Panel. In this area you can do the tasks that you need to complete such as manage servers, create packages, manage users.<br />
             Here, you can also change the look and feel of your THT Installation. If you require any help, be sure to ask at the <a href="http://thehostingtool.com/forum" title="THT Community is the official stop for THT Support, THT Modules, Developer Center and more! Visit our growing community now!" class="tooltip">THT Community</a><br /><br />' . $stats_box . '<br />' . $install_check . $conf_check . '</div></div>';
     echo $content;
     if ($_POST) {
         $dbh->update("admin_notes", array("notes" => $postvar['admin_notes']), array("id", "=", "1"));
         main::errors("Settings Updated!");
         main::done();
     }
     $notes_data = $dbh->select("admin_notes", array("id", "=", "1"));
     $notepad_array['NOTEPAD'] = $notes_data['notes'];
     $content_notepad = style::replaceVar('tpl/admin/home/notepad.tpl', $notepad_array);
     echo '<br />';
     echo main::table('Admin Notepad', $content_notepad, 'auto', 'auto');
     $news = main::sub("<strong>Add the THT RSS Feed!</strong>", '<a href="http://thehostingtool.com/forum/syndication.php?fid=2" target="_blank" class="tooltip" title="Add the THT RSS Feed!"><img src="<URL>themes/icons/feed.png" /></a>');
     $rss_feed = @file_get_contents("http://thehostingtool.com/forum/syndication.php?fid=2&limit=3");
     if ($rss_feed !== false) {
         $xml = new SimpleXMLElement($rss_feed);
         foreach ($xml->channel->item as $item) {
             $newsitem_array['title'] = $item->title;
             $newsitem_array['author'] = "THT";
             $newsitem_array['link'] = $item->link;
             $newsitem_array['TIME'] = main::convertdate("n/d/Y", strtotime($item->pubDate));
             $newsitem_array['SUMMARY'] = $item->description;
             $news .= style::replaceVar('tpl/admin/home/news-item.tpl', $newsitem_array);
         }
     }
     echo "<br />";
     echo main::table('THT News & Updates', $news);
 }
Ejemplo n.º 2
0
 public function install_mod($mod_dir)
 {
     global $dbh, $postvar, $getvar, $instance;
     if (self::is_mod_installed($mod_dir)) {
         echo "This module is already installed.  Please uninstall the module first before reinstalling it.";
         return;
     }
     $mod_dir_full = INC . "/automod/" . $mod_dir;
     $mod_xml_file = $mod_dir_full . "/install.xml";
     if (is_file($mod_xml_file)) {
         //Let's set some variables - First the basics.
         $module_data = self::get_mod_xml($mod_xml_file);
         $header_data = $module_data['header'];
         $actions_data = $module_data['action-group'];
         $author_data = $module_data['header']['author-group']['author'];
         //Values that every module should have.
         $mod_name = htmlentities($header_data['projname']);
         $mod_desc = htmlentities($header_data['description']);
         $mod_license = htmlentities($header_data['license']);
         $mod_version = htmlentities($header_data['mod-version']);
         $mod_author = htmlentities($author_data['realname']);
         $mod_homepage = str_replace("&amp;", "&", htmlspecialchars($author_data['homepage']));
         $mod_projectpage = str_replace("&amp;", "&", htmlspecialchars($author_data['projectpage']));
         $mod_support = htmlentities($author_data['support']);
         $mod_thtversion = htmlentities($author_data['thtversion']);
         //Values that many modules have
         $mod_sql = $actions_data['sql'];
         $mod_uninstallsql = $actions_data['uninstallsql'];
         //We should check this to see if the user can remove the database entries made by the module and notify them if the uninstall SQL info isn't available.
         $mod_after_install = $actions_data['diy-instructions'];
         $mod_edits = $actions_data['open'];
         //Versions
         $latest_versions = main::latest_version();
         $THT_version = $dbh->config("version");
         $mod_thtversion = str_replace("reworked", "Reworked", strtolower($mod_thtversion));
         //Let the games begin!  =)
         $warnings = array();
         //See if they are using a dynamic admin directory and if so, rename the admin directory before installing.
         if (ADMINDIR && ADMINDIR != 'admin') {
             @rename($mod_dir_full . "/root/admin", $mod_dir_full . "/root/" . ADMINDIR);
         }
         //THT version check
         if ($THT_version != $mod_thtversion) {
             $mod_thtversion_array = explode(" ", $mod_thtversion);
             $mod_thtversion_vers = $mod_thtversion_array[0];
             $standard_warn = "<br><br>The THT version installed is different from what this module was developed for.  The installation will be further checked, but the installer cannot guarantee that the module will work properly on your installation of THT.<br><br><b>THT Version Installed: </b>" . $THT_version . "<br><b>THT Version Suggested: </b>" . $mod_thtversion;
             $special_warning = "<br><br>The THT version installed may or may not be the same as the one this module is made for.  The one this module was designed for is a special version of THT.<br><br><b>THT Version Installed: </b>" . $THT_version . "<br><b>THT Version Suggested: </b>" . $mod_thtversion;
             if ($mod_thtversion_array[1]) {
                 $mod_thtversion_special = str_replace($mod_thtversion_vers . " ", "", $mod_thtversion);
                 if ($mod_thtversion_vers == $THT_version) {
                     if ($mod_thtversion != "Reworked") {
                         $warnings['version'] = $special_warning;
                     }
                 } else {
                     $warnings['version'] = $standard_warn;
                 }
             } else {
                 $warnings['version'] = $standard_warn;
             }
         }
         if (empty($latest_versions['THT_DL'])) {
             $latest_versions['THT_DL'] = "Download temporarily unavailable";
         }
         if ($warnings['version'] && $mod_thtversion == "1.3 Reworked") {
             //The mod was made for Reworked.  Let's add a shameless plug.  ;)  If there's a newer release available, it'll show them the link to that one instead.
             $warnings['version'] .= "<br><b>THT 1.3 Reworked can be downloaded at: </b><a href = '" . $latest_versions['THT_DL'] . "' target = '_blank'>" . $latest_versions['THT_DL'] . "</a>.";
         }
         //Are we using the latest THT?
         if ($latest_versions['THT'] != $THT_version && !empty($latest_versions)) {
             $recommendations = "<font color = '#FF7800'><b>RECOMMENDATION: </b></font>It's always a good idea to have the most up to date version of THT.  The latest stable version of THT is THT " . $latest_versions['THT'] . " and can be downloaded at <a href = '" . $latest_versions['THT_DL'] . "' target = '_blank'>" . $latest_versions['THT_DL'] . "</a>.<br>";
         } else {
             $recommendations = "<font color = '#779500'>Everything is up to date!</font>";
         }
         //If we have SQL, do we also have Uninstall SQL?
         if (!empty($mod_sql)) {
             if (empty($mod_uninstallsql)) {
                 $warnings['uninstall_sql'] = "<br><br>This module runs the following queries when it installs, but it does not have a way to remove them automatically.  Please make a note of these in case you decide to uninstall this module.  You'll be shown these same installation queries when you uninstall the module if you decide to.<br><br><b>SQL:</b><br><textarea cols = '87' rows = '10'>" . $mod_sql . "</textarea>";
                 //The last part makes <PRE> show properly on the page.
             }
         }
         //Now we need to check if the file modifications are possible on this installation of THT.  Let's do a test run and see if we can find everything it says to find.
         $file_errors = self::modify_files($mod_edits, true, false, $mod_dir);
         $warnings['fileerrors'] = $file_errors['fileerrors'];
         //The warnings are done now.  Now we print the results and offer them the ability confirm or reject the installation.
         //Let's see if any THT files will be overwritten by the installer so we can notify the user.
         $any_replaced_files = self::RecursiveCopy($mod_dir_full . "/root", "..", true);
         if (!empty($any_replaced_files)) {
             $any_replaced_files = str_replace("../", "", $any_replaced_files);
             $errors_list_array['ERRWARN'] = "WARNING";
             $errors_list_array['ERRCOLOR'] = "FF7800";
             $errors_list_array['TITLE'] = "Some THT files will be replaced";
             $errors_list_array['DESCRIPTION'] = "<br><hr noshade color = '#000000'><br><font color = '#FF7800'><b>WARNING: </b></font> While this might be perfectly fine, you should be aware that the following files will be overwritten by this module.  Please be sure to back up your website before you proceed with the installation.  AutoMod will rename the old files to FILENAME_old.EXT for your convienience.<br><br><b>Files to be overwritten with new content:</b><br><br>" . nl2br($any_replaced_files) . "<br>";
             $output .= style::replaceVar("tpl/automod/errors-list.tpl", $errors_list_array);
         }
         //Selection of errors that we collected while processing this mod
         $err_version = $warnings['version'];
         $err_uninstall_sql = $warnings['uninstall_sql'];
         $err_fileerrors = $warnings['fileerrors'];
         if ($err_version) {
             $mod_thtversion_color = "<font color = '#FF0055'>" . $THT_version . "</font>";
             $errors_list_array['ERRWARN'] = "WARNING";
             $errors_list_array['ERRCOLOR'] = "FF7800";
             $errors_list_array['TITLE'] = "Version Mismatch";
             $errors_list_array['DESCRIPTION'] = $err_version;
             $output .= style::replaceVar("tpl/automod/errors-list.tpl", $errors_list_array);
         } else {
             $mod_thtversion_color = "<font color = '#779500'>" . $THT_version . "</font>";
         }
         if ($err_uninstall_sql) {
             $errors_list_array['ERRWARN'] = "WARNING";
             $errors_list_array['ERRCOLOR'] = "FF7800";
             $errors_list_array['TITLE'] = "No SQL uninstaller";
             $errors_list_array['DESCRIPTION'] = $err_uninstall_sql;
             $output .= style::replaceVar("tpl/automod/errors-list.tpl", $errors_list_array);
         }
         if ($err_fileerrors) {
             $err_fileerrors = self::normalize_array($err_fileerrors);
             $file_errors_count = count($err_fileerrors);
             for ($i = 0; $i < $file_errors_count; $i++) {
                 $file_missing = $err_fileerrors[$i]['filename'];
                 if ($file_missing) {
                     $err_descrip .= "<br><br><hr noshade color = '#000000'><br><font color = '#FF0055'><b>Cannot find file: </b>" . $file_missing . "</font>";
                 }
                 $err_fileerrors_error = $err_fileerrors[$i]['errors'];
                 $err_fileerrors_error = self::normalize_array($err_fileerrors_error);
                 $err_fileerrors_error_count = count($err_fileerrors_error);
                 $theme_section = $err_fileerrors[$i]['themefile'];
                 if ($theme_section) {
                     unset($themereplace);
                     unset($themeaddafter);
                     unset($themeaddbefore);
                     $themefile = $theme_section['file'];
                     $themefind = $theme_section['themefind'];
                     $themereplace = $theme_section['themereplace'];
                     $themeaddafter = $theme_section['themeaddafter'];
                     $themeaddbefore = $theme_section['themeaddbefore'];
                     $base_text = "<br><br><b>In file: </b>" . $themefile . "<br><b>Find: </b><br><br><textarea cols = '87' rows = '10'>" . $themefind . "</textarea><br><br>";
                     if ($themereplace) {
                         $modification_text = $base_text . "<b>Replace it with: </b><br><br><textarea cols = '87' rows = '10'>" . $themereplace . "</textarea><br><hr noshade color = '#000000'>";
                     } elseif ($themeaddafter) {
                         $modification_text = $base_text . "<b>Add after it: </b><br><br><textarea cols = '87' rows = '10'>" . $themeaddafter . "</textarea><br><hr noshade color = '#000000'>";
                     } else {
                         $modification_text = $base_text . "<b>Add before it: </b><br><br><textarea cols = '87' rows = '10'>" . $themeaddbefore . "</textarea><br><hr noshade color = '#000000'>";
                     }
                 }
                 for ($n = 0; $n < $err_fileerrors_error_count; $n++) {
                     $err_descrip .= $err_fileerrors_error[$n];
                 }
             }
             if ($err_descrip) {
                 $errors_list_array['ERRWARN'] = "ERROR";
                 $errors_list_array['ERRCOLOR'] = "FF0000";
                 $errors_list_array['TITLE'] = "File modification";
                 $errors_list_array['DESCRIPTION'] = $err_descrip . "<br><br><hr noshade color = '#000000'>";
                 $output .= style::replaceVar("tpl/automod/errors-list.tpl", $errors_list_array);
             }
             if ($modification_text) {
                 $errors_list_array['ERRWARN'] = "WARNING";
                 $errors_list_array['ERRCOLOR'] = "FF7800";
                 $errors_list_array['TITLE'] = "Theme modification";
                 $errors_list_array['DESCRIPTION'] = "<hr noshade color = '#000000'><br><font color = '#FF0055'><b>Attention: </b>This module modifies a theme.  Below are the following modifications to the themes to help you manually modify any other themes you wish to use.</font>" . $modification_text;
                 $output .= style::replaceVar("tpl/automod/errors-list.tpl", $errors_list_array);
             }
         }
         if (empty($output)) {
             $output = "<font color = '#779500'>No errors found!</font>";
         }
         $pre_install_array['NAME'] = $mod_name;
         $pre_install_array['VERSION'] = $mod_thtversion_color;
         $pre_install_array['THTVERSION'] = $mod_thtversion;
         $pre_install_array['MODVERSION'] = $mod_version;
         $pre_install_array['LICENSE'] = $mod_license;
         $pre_install_array['AUTHOR'] = $mod_author;
         $pre_install_array['SUPPORT'] = $mod_support;
         $pre_install_array['AUTHLINK'] = $mod_homepage;
         $pre_install_array['PROJWEB'] = $mod_projectpage;
         $pre_install_array['RECOMMENDATIONS'] = $recommendations;
         $pre_install_array['DESCRIPTION'] = nl2br($mod_desc);
         $pre_install_array['DIY'] = $mod_after_install;
         $pre_install_array['ID'] = $mod_dir;
         $pre_install_array['PREINSTALLERRORS'] = $output;
         echo style::replaceVar("tpl/automod/pre-install.tpl", $pre_install_array);
     } else {
         echo "Cannot find the install.xml file.  Please make sure that " . $mod_xml_file . " exists.";
     }
 }