示例#1
0
if ($dh = opendir($dir)) {
    while (($file = readdir($dh)) !== false) {
        $filepath = $dir . '/' . $file;
        if (is_dir($filepath)) {
            //echo "filename: $file : filetype: " . filetype($dir.'/'.$file) . "\n";
            $modfile = $filepath . '/mod.xml';
            if (file_exists($modfile)) {
                $mods[$file] = $modfile;
            }
        }
    }
    closedir($dh);
}
// find all modules
foreach ($mods as $mod => $modfile) {
    installModule($mod, $modfile);
}
function installModule($mod, $modfile)
{
    $xml = simplexml_load_file($modfile);
    $db = Openbiz::$app->getDBConnection();
    // write mod info in module table
    $modName = $xml['Name'];
    $modDesc = $xml['Description'];
    echo "****************************\n";
    echo " Install Module {$modName} \n";
    echo "****************************\n";
    $sql = "SELECT * from module where name='{$modName}'";
    try {
        $rs = $db->fetchAll($sql);
    } catch (Exception $e) {
示例#2
0
/**
 * Runs a named stage of the installation.
 *
 * @param $stage The named stage of installation.
 */
function installStage($stage)
{
    global $editions, $dbConfig, $dbKeys, $dateFields, $enabledModules, $dbo, $config, $confMap, $response, $silent, $stageLabels, $write, $nonFreeTables, $editionHierarchy;
    switch ($stage) {
        case 'validate':
            if ($config['dummy_data'] == 1 && $config['adminUsername'] != 'admin') {
                addValidationError('adminUsername', 'Cannot change administrator username if installing with sample data.');
            } else {
                if (empty($config['adminUsername'])) {
                    addValidationError('adminUsername', 'Admin username cannot be blank.');
                } elseif (is_int(strpos($config['adminUsername'], "'"))) {
                    addValidationError('adminUsername', 'Admin username cannot contain apostrophes');
                } elseif (preg_match('/^\\d+$/', $config['adminUsername'])) {
                    addValidationError('adminUsername', 'Admin username must contain at least one non-numeric character.');
                } elseif (!preg_match('/^\\w+$/', $config['adminUsername'])) {
                    addValidationError('adminUsername', 'Admin username may contain only alphanumeric characters and underscores.');
                }
            }
            if (empty($config['adminEmail']) || !preg_match('/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}$/i', $config['adminEmail'])) {
                addValidationError('adminEmail', 'Please enter a valid email address.');
            }
            if ($config['adminPass'] == '') {
                addValidationError('adminPass', 'Admin password cannot be blank.');
            }
            if (!$silent && !isset($_POST['adminPass2'])) {
                addValidationError('adminPass2', 'Please confirm the admin password.');
            } else {
                if (!$silent && $config['adminPass'] != $_POST['adminPass2']) {
                    addValidationError('adminPass2', 'Admin passwords did not match.');
                }
            }
            if (!empty($response['errors'])) {
                if (!$silent) {
                    RIP(installer_t('Please correct the following errors:'));
                } else {
                    outputErrors();
                }
            }
            break;
        case 'module':
            if (isset($_GET['module'])) {
                // Install only a named module
                installModule($_GET['module']);
            } else {
                // Install all modules:
                foreach ($enabledModules as $module) {
                    installModule($module, $silent);
                }
            }
            break;
        case 'config':
            // Configure with initial data and write files
            // Generate config file content:
            $gii = 1;
            if ($gii == '1') {
                $gii = "array(\n\t'class'=>'system.gii.GiiModule',\n\t'password'=>'" . str_replace("'", "\\'", $config['adminPass']) . "', \n\t/* If the following is removed, Gii defaults to localhost only. Edit carefully to taste: */\n\t 'ipFilters'=>false,\n)";
            } else {
                $gii = "array(\n\t'class'=>'system.gii.GiiModule',\n\t'password'=>'password',\n\t/* If the following is removed, Gii defaults to localhost only. Edit carefully to taste: */\n\t 'ipFilters'=>array('127.0.0.1', '::1'),\n)";
            }
            $X2Config = "<?php\n";
            foreach (array('appName', 'email', 'host', 'user', 'pass', 'dbname', 'version') as $confKey) {
                $X2Config .= "\${$confKey} = " . var_export($config[$confMap[$confKey]], 1) . ";\n";
            }
            $X2Config .= "\$buildDate = {$config['buildDate']};\n\$updaterVersion = '{$config['updaterVersion']}';\n";
            $X2Config .= empty($config['language']) ? '$language=null;' : "\$language='{$config['language']}';\n?>";
            // Save config values to be inserted in the database:
            $config['time'] = time();
            foreach ($dbKeys as $property) {
                $dbConfig['{' . $property . '}'] = $config[$property];
            }
            $contents = file_get_contents('webConfig.php');
            $contents = preg_replace('/\\$url\\s*=\\s*\'\'/', "\$url=" . var_export($config['baseUrl'] . $config['baseUri'], 1), $contents);
            $contents = preg_replace('/\\$user\\s*=\\s*\'\'/', "\$user="******"\$userKey=" . var_export($config['adminUserKey'], 1), $contents);
            file_put_contents('webConfig.php', $contents);
            if ($config['test_db']) {
                $filename = implode(DIRECTORY_SEPARATOR, array(__DIR__, 'protected', 'config', 'X2Config-test.php'));
                if (!empty($config['test_url'])) {
                    $defaultConfig = file_get_contents(implode(DIRECTORY_SEPARATOR, array(__DIR__, 'protected', 'tests', 'WebTestConfig_example.php')));
                    $webTestConfigFile = implode(DIRECTORY_SEPARATOR, array(__DIR__, 'protected', 'tests', 'WebTestConfig.php'));
                    $webTestUrl = rtrim($config['test_url'], '/') . '/';
                    $webTestRoot = rtrim(preg_replace('#index-test\\.php/?$#', '', trim($config['test_url'])), '/') . '/';
                    $testConstants = array('TEST_BASE_URL' => var_export($webTestUrl, 1), 'TEST_WEBROOT_URL' => var_export($webTestRoot, 1));
                    $webTestConfig = $defaultConfig;
                    foreach ($testConstants as $name => $value) {
                        $webTestConfig = preg_replace("/^defined\\('{$name}'\\) or define\\('{$name}'\\s*,.*\$/m", "defined('{$name}') or define('{$name}',{$value});", $webTestConfig);
                    }
                    file_put_contents($webTestConfigFile, $webTestConfig);
                }
            } else {
                $filename = implode(DIRECTORY_SEPARATOR, array(__DIR__, 'protected', 'config', 'X2Config.php'));
            }
            $handle = fopen($filename, 'w') or RIP(installer_tr('Could not create configuration file: {filename}.', array('{filename}' => $filename)));
            // Write core application configuration:
            fwrite($handle, $X2Config);
            fclose($handle);
            // Create an encryption key for credential storage:
            if (extension_loaded('openssl') && extension_loaded('mcrypt')) {
                $encryption = new EncryptUtil('protected/config/encryption.key', 'protected/config/encryption.iv');
                $encryption->saveNew();
            }
            $dbConfig['{adminPass}'] = md5($config['adminPass']);
            $dbConfig['{adminUserKey}'] = $config['adminUserKey'];
            try {
                foreach (array('', '-pro', '-pla') as $suffix) {
                    $sqlPath = "protected/data/config{$suffix}.sql";
                    $sqlFile = realpath($sqlPath);
                    if ($sqlFile) {
                        $sql = explode('/*&*/', strtr(file_get_contents($sqlFile), $dbConfig));
                        foreach ($sql as $sqlLine) {
                            $installConf = $dbo->prepare($sqlLine);
                            if (!$installConf->execute()) {
                                RIP(installer_t('Error applying initial configuration') . ': ' . implode(',', $installConf->errorInfo()));
                            }
                        }
                    } else {
                        if ($suffix == '') {
                            // Minimum requirement
                            RIP(installer_t('Could not find database configuration script') . " {$sqlPath}");
                        }
                    }
                }
            } catch (PDOException $e) {
                die($e->getMessage());
            }
            //			saveCrontab();
            break;
        case 'finalize':
            /**
             * Look for additional initialization files and perform final tasks
             */
            foreach ($editions as $ed) {
                // Add editional prefixes as necessary
                if (file_exists("initialize_{$ed}.php")) {
                    include "initialize_{$ed}.php";
                }
            }
            break;
        default:
            // Look for a named SQL file and run it:
            $stagePath = "protected/data/{$stage}.sql";
            if ($stage == 'dummy_data') {
                $stageLabels['dummy_data'] = sprintf($stageLabels['dummy_data'], $config['dummy_data'] ? 'insert' : 'delete');
            }
            if ((bool) (int) $config['dummy_data'] || $stage != 'dummy_data') {
                if ($sqlFile = realpath($stagePath)) {
                    $sql = explode('/*&*/', file_get_contents($sqlFile));
                    foreach ($sql as $sqlLine) {
                        $statement = $dbo->prepare($sqlLine);
                        try {
                            if (!$statement->execute()) {
                                RIP(installer_tr('Could not {stage}. SQL statement "{sql}" from {file} failed', array('{stage}' => $stageLabels[$stage], '{sql}' => substr(trim($sqlLine), 0, 50) . (strlen(trim($sqlLine)) > 50 ? '...' : ''), '{file}' => $sqlFile)) . '; ' . implode(',', $statement->errorInfo()));
                            }
                        } catch (PDOException $e) {
                            RIP(installer_tr("Could not {stage}", array('{stage}' => $stageLabels[$stage])) . '; ' . $e->getMessage());
                        }
                    }
                    // Hunt for init SQL files associated with other editions:
                    foreach ($editions as $ed) {
                        if ($sqlFile = realpath("protected/data/{$stage}-{$ed}.sql")) {
                            $sql = explode('/*&*/', file_get_contents($sqlFile));
                            foreach ($sql as $sqlLine) {
                                $statement = $dbo->prepare($sqlLine);
                                try {
                                    if (!$statement->execute()) {
                                        RIP(installer_tr('Could not {stage}. SQL statement "{sql}" from {file} failed', array('{stage}' => $stageLabels[$stage], '{sql}' => substr(trim($sqlLine), 0, 50) . (strlen($sqlLine) > 50 ? '...' : ''), '{file}' => $sqlFile)) . '; ' . implode(',', $statement->errorInfo()));
                                    }
                                } catch (PDOException $e) {
                                    RIP(installer_tr("Could not {stage}", array('{stage}' => $stageLabels[$stage])) . '; ' . $e->getMessage());
                                }
                            }
                        }
                    }
                    if ($stage == 'dummy_data') {
                        // Need to update the timestamp fields on all the sample data that has been inserted.
                        $dateGen = @file_get_contents(realpath("protected/data/dummy_data_date")) or RIP("Sample data generation date not set.");
                        $time = time();
                        $time2 = $time * 2;
                        $timeDiff = $time - (int) trim($dateGen);
                        foreach ($dateFields as $table => $fields) {
                            $tableEdition = 'opensource';
                            foreach ($editions as $ed) {
                                if (in_array($table, $nonFreeTables[$ed])) {
                                    $tableEdition = $ed;
                                    break;
                                }
                            }
                            if (!(bool) $editionHierarchy[$config['edition']][$tableEdition]) {
                                // Table not "contained" in the current edition
                                continue;
                            }
                            foreach ($fields as $field) {
                                try {
                                    $dbo->exec("UPDATE `{$table}` SET `{$field}`=`{$field}`+{$timeDiff} WHERE `{$field}` IS NOT NULL AND `{$field}`!=0 AND `{$field}`!=''");
                                } catch (Exception $e) {
                                    // Ignore it and move on; table/column doesn't exist.
                                    continue;
                                }
                            }
                            // Fix timestamps that are in the future.
                            /*
                             $ordered = array('lastUpdated','createDate');
                             if(count(array_intersect($ordered,$fields)) == count($ordered)) {
                             $affected = 0;
                             foreach($ordered as $field) {
                             $affected += $dbo->exec("UPDATE `$table` SET `$field`=$time2-`$field` WHERE `$field` > $time");
                             }
                             if($affected)
                             $dbo->exec("UPDATE `$table` set `lastUpdated`=`createDate`,`createDate`=`lastUpdated` WHERE `createDate` > `lastUpdated`");
                             }
                            */
                        }
                    }
                } else {
                    RIP(installer_t("Could not find installation stage database script") . " {$stagePath}");
                }
            } else {
                // This is the dummy data stage, and we need to clear out all unneeded files.
                // However, we should leave the files alone if this is a testing database reinstall.
                $stageLabels[$stage] = sprintf($stageLabels[$stage], 'remove');
                if (($paths = @(require_once realpath('protected/data/dummy_data_files.php'))) && !$config['test_db']) {
                    foreach ($paths as $pathClear) {
                        if ($path = realpath($pathClear)) {
                            FileUtil::rrmdir($path, '/\\.htaccess$/');
                        }
                    }
                }
            }
            break;
    }
    if (in_array($stage, array_keys($stageLabels)) && $stage != 'finalize' && !($stage == 'validate' && $silent)) {
        ResponseUtil::respond(installer_tr("Completed: {stage}", array('{stage}' => $stageLabels[$stage])));
    }
}
示例#3
0
function handleModuleManagement()
{
    global $sourceFolder;
    if (isset($_POST['btn_install'])) {
        $uploadId = processUploaded("Module");
        if ($uploadId != -1) {
            return installModule($uploadId, "Module");
        }
    } else {
        if (isset($_POST['btn_uninstall'])) {
            if (!isset($_POST['Module']) || $_POST['Module'] == "") {
                return "";
            }
            if ($_POST['Module'] == 'article') {
                displayerror("Article module can't be deleted for the home page itself is a article");
                return "";
            }
            $toDelete = escape($_POST['Module']);
            $query = "SELECT `page_id` FROM `" . MYSQL_DATABASE_PREFIX . "pages` WHERE `page_module` = '{$toDelete}' LIMIT 10";
            $result = mysql_query($query) or displayerror(mysql_error());
            if (mysql_num_rows($result) == 0 || isset($_POST['confirm'])) {
                if (deleteModule($toDelete)) {
                    displayinfo("Module " . safe_html($_POST['Module']) . " uninstalled!");
                    return "";
                } else {
                    displayerror("Module uninstallation failed!");
                    return "";
                }
            }
            if (isset($_POST['confirm'])) {
                $query = "DELETE FROM `" . MYSQL_DATABASE_PREFIX . "pages` WHERE `page_module` = '" . $toDelete . "'";
                mysql_query($query) or displayerror(mysql_error());
            }
            $pageList = "";
            while ($row = mysql_fetch_assoc($result)) {
                $pageList .= "/home" . getPagePath($row['page_id']) . "<br>";
            }
            $modulename = safe_html($_POST['Module']);
            $ret = <<<RET
<fieldset>
<legend>{$ICONS['Modules Management']['small']}Module Management</legend>
Some of the page of type {$modulename} are:<br>
{$pageList}
<div class='cms-error'>These pages will be removed and cant be recovered, If you proceed deleting the module.</div>
<form method=POST action='./+admin&subaction=module&subsubaction=uninstall'>
<input type=hidden value='{$modulename}' name='Module' />
<input type=submit value='Delete module' name='btn_uninstall' />
<input type=hidden value='confirm' name='confirm' />
</form>
</fieldset>
RET;
            return $ret;
        } else {
            if (isset($_GET['subsubaction']) && $_GET['subsubaction'] == 'finalize') {
                return finalizeInstallation(escape($_POST['id']), "Module");
            } else {
                if (isset($_GET['subsubaction']) && $_GET['subsubaction'] == 'cancel') {
                    $uploadId = escape($_POST['id']);
                    $result = mysql_fetch_assoc(mysql_query("SELECT * FROM `" . MYSQL_DATABASE_PREFIX . "tempuploads` WHERE `id` = '{$uploadId}'"));
                    if ($result != NULL) {
                        $zipFile = $result['filePath'];
                        $temp = explode(";", $result['info']);
                        $extractedPath = $temp[0];
                        $moduleActualPath = $temp[1];
                        $moduleName = $temp[2];
                    }
                    delDir($extractedPath);
                    unlink($zipFile);
                    mysql_query("DELETE FROM `" . MYSQL_DATABASE_PREFIX . "tempuploads` WHERE `id` = '{$uploadId}'") or displayerror(mysql_error());
                    return "";
                }
            }
        }
    }
}
示例#4
0
/**
* @copyright Copyright (C) 2009 Joobi Limited All rights reserved.
* @license This file is released under the GPL license (http://www.gnu.org/licenses )
* @link http://www.ijoobi.com
*/
function com_install()
{
    @ini_set('max_execution_time', 0);
    @ini_set('memory_limit', '128M');
    if (defined('JPATH_ROOT') and class_exists('JFactory')) {
        // joomla 15
        define('ACA_JPATH_ROOT', JPATH_ROOT);
    } else {
        define('ACA_JPATH_ROOT', $GLOBALS['mosConfig_absolute_path']);
    }
    //endif
    require_once ACA_JPATH_ROOT . '/components/com_acajoom/defines.php';
    require_once WPATH_ADMIN . 'config.acajoom.php';
    require_once WPATH_ADMIN . 'admin.acajoom.html.php';
    require_once WPATH_CLASS . 'class.acajoom.php';
    $update = new wupdate();
    $xf = new xonfig();
    $return = '';
    if (ACA_CMSTYPE) {
        $database =& JFactory::getDBO();
    } else {
        global $database;
    }
    //endif
    if (!is_writable(ACA_JPATH_ROOT_NO_ADMIN . $acajoomConfigFile['upload_url'])) {
        @chmod(ACA_JPATH_ROOT_NO_ADMIN . $acajoomConfigFile['upload_url'], 0777);
    }
    $query[] = "UPDATE #__components\n\t  SET admin_menu_img='../administrator/components/com_acajoom/images/acajoom_icon.png'\n\t  WHERE admin_menu_link='option=com_acajoom'";
    $query[] = "UPDATE #__components\n\t  SET admin_menu_img='../includes/js/ThemeOffice/edit.png',\n\t  name='" . _ACA_MENU_LIST . "',\n\t  admin_menu_alt='" . _ACA_MENU_LIST . "'\n\t  WHERE admin_menu_link='option=com_acajoom&act=list'";
    $query[] = "UPDATE #__components\n\t  SET admin_menu_img='../includes/js/ThemeOffice/users_add.png' ,\n\t  name='" . _ACA_MENU_SUBSCRIBERS . "',\n\t  admin_menu_alt='" . _ACA_MENU_SUBSCRIBERS . "'\n\t  WHERE admin_menu_link='option=com_acajoom&act=subscribers'";
    $query[] = "UPDATE #__components\n\t  SET admin_menu_img='../includes/js/ThemeOffice/messaging_inbox.png' ,\n\t  name='" . _ACA_MENU_NEWSLETTERS . "',\n\t  admin_menu_alt='" . _ACA_MENU_NEWSLETTERS . "'\n\t  WHERE admin_menu_link='option=com_acajoom&act=mailing&listype=1'";
    $query[] = "UPDATE #__components\n\t  SET admin_menu_img='../includes/js/ThemeOffice/messaging_config.png' ,\n\t  name='" . _ACA_MENU_AUTOS . "',\n\t  admin_menu_alt='" . _ACA_MENU_AUTOS . "'\n\t  WHERE admin_menu_link='option=com_acajoom&act=mailing&listype=2'";
    $query[] = "UPDATE #__components\n\t  SET admin_menu_img='../includes/js/ThemeOffice/query.png' ,\n\t   name='" . _ACA_MENU_STATS . "',\n\t   admin_menu_alt='" . _ACA_MENU_STATS . "'\n\t  WHERE admin_menu_link='option=com_acajoom&act=statistics'";
    $query[] = "UPDATE #__components\n\t  SET admin_menu_img='../includes/js/ThemeOffice/menus.png' ,\n\t   name='" . _ACA_MENU_CONF . "',\n\t   admin_menu_alt='" . _ACA_MENU_CONF . "'\n\t  WHERE admin_menu_link='option=com_acajoom&act=configuration'";
    $query[] = "UPDATE #__components\n\t  SET admin_menu_img='../includes/js/ThemeOffice/restore.png' ,\n\t  name='" . _ACA_MENU_UPDATE . "',\n\t  admin_menu_alt='" . _ACA_MENU_UPDATE . "'\n\t  WHERE admin_menu_link='option=com_acajoom&act=update'";
    $query[] = "UPDATE #__components\n\t  SET admin_menu_img='../includes/js/ThemeOffice/credits.png' ,\n\t  name='" . _ACA_MENU_ABOUT . "',\n\t  admin_menu_alt='" . _ACA_MENU_ABOUT . "'\n\t  WHERE admin_menu_link='option=com_acajoom&act=about'";
    $q = " SELECT `text` FROM `#__acajoom_xonfig` WHERE `akey` = 'version' ";
    $database->setQuery($q);
    $vers = $database->loadResult();
    $err = $database->getErrorMsg();
    if (!empty($err)) {
        $q = " SELECT `text` FROM `#__acajoom_xonfig` WHERE `key` = 'version' ";
        $database->setQuery($q);
        $vers = $database->loadResult();
        if (!empty($vers) and $update->checkVersion($vers, '1.0.6')) {
            ### UPDATE database if before 1.0.7
            $query[] = "ALTER TABLE `#__acajoom_mailings` CHANGE `images` `images` TEXT NOT NULL ";
            $query[] = "ALTER TABLE `#__acajoom_lists` ADD `footer` TINYINT( 1 ) NOT NULL DEFAULT '1' ";
            $query[] = "ALTER TABLE `#__acajoom_lists` ADD `notify_id` INT( 10 ) NOT NULL DEFAULT '0' ";
            $query[] = "ALTER TABLE `#__acajoom_xonfig` DROP INDEX `key` ";
            $query[] = "ALTER TABLE `#__acajoom_xonfig` CHANGE `key` `akey` VARCHAR( 32 ) NOT NULL ";
            $query[] = "ALTER TABLE `#__acajoom_xonfig` CHANGE `value` `value` INT( 11 ) NOT NULL ";
            $query[] = "ALTER TABLE `#__acajoom_stats_global` DROP `listid`  ";
            $query[] = "ALTER TABLE `#__acajoom_stats_global` DROP INDEX `listid` ";
            $query[] = "ALTER TABLE `#__acajoom_stats_global` ADD PRIMARY KEY ( `mailing_id` ) ";
            $query[] = "ALTER TABLE `#__acajoom_stats_details` DROP `listid` ";
            $query[] = "ALTER TABLE `#__acajoom_stats_details` DROP INDEX `listid` ";
            $query[] = "ALTER TABLE `#__acajoom_stats_details` ADD PRIMARY KEY ( `mailing_id` , `subscriber_id` ) ";
            ### 1.0.9
            $query[] = " ALTER TABLE `#__acajoom_mailings` CHANGE `fromname` `fromname` VARCHAR( 64 ) NOT NULL  ";
            $query[] = " ALTER TABLE `#__acajoom_lists` CHANGE `sendername` `sendername` VARCHAR( 64 ) NOT NULL  ";
        }
    }
    if (empty($err) and !empty($vers) and $update->checkVersion($vers, '1.0.8')) {
        $query[] = " ALTER TABLE `#__acajoom_mailings` CHANGE `fromname` `fromname` VARCHAR( 64 ) NOT NULL  ";
        $query[] = " ALTER TABLE `#__acajoom_lists` CHANGE `sendername` `sendername` VARCHAR( 64 ) NOT NULL  ";
        ### upgrade path for new versions
        $xf->insert('wait_for_user', '0', 0);
        $xf->insert('report_site', 'http://www.ijoobi.com', 0);
        $xf->insert('use_sef', '0', 0);
        $xf->insert('send_error', '1', 0);
        $xf->insert('report_error', '1', 0);
        $xf->insert('wait_for_user', '0', 0);
        $xf->insert('show_archive', '1', 0);
        $xf->insert('update_notification', '1', 0);
        $xf->update('send_log_address', '@ijoobi.com');
        $xf->update('update_url', 'http://www.ijoobi.com/update/');
    }
    if (empty($err) and !empty($vers) and $update->checkVersion($vers, '1.1.0')) {
        $query[] = "ALTER TABLE `#__acajoom_lists` ADD `notification` INT( 10 ) NOT NULL DEFAULT '0' ";
        $xf->update('listname1', '_ACA_NEWSLETTER');
        $xf->update('listnames1', '_ACA_MENU_NEWSLETTERS');
    }
    if (empty($err) and !empty($vers) and $update->checkVersion($vers, '1.1.4')) {
        $xf->insert('last_sub_update', '', 0);
        $xf->insert('level', '1', 0);
    }
    if (empty($err) and !empty($vers) and $update->checkVersion($vers, '1.3.0')) {
        $xf->insert('show_author', '0', 0);
    }
    if (empty($err) and !empty($vers) and $update->checkVersion($vers, '1.5.5')) {
        $xf->insert('addEmailRedLink', '0', 0);
    }
    if (empty($err) and !empty($vers) and $update->checkVersion($vers, '1.5.5')) {
        $query[] = " ALTER TABLE `#__acajoom_subscribers` ADD INDEX `subscribe_date` ( `subscribe_date` )   ";
        $query[] = " ALTER TABLE `#__acajoom_queue` CHANGE `subscriber_id` `subscriber_id` INT( 11 ) DEFAULT '0' NOT NULL  ";
    }
    if (empty($err) and !empty($vers) and $update->checkVersion($vers, '1.6.4')) {
        $xf->insert('show_jcalpro', '0', 0);
        $xf->insert('redirectconfirm', '', 0);
        $xf->insert('itemidAca', '99', 0);
    }
    if (empty($err) and !empty($vers) and $update->checkVersion($vers, '3.2.0')) {
        $xf->insert('fullcheck', '0', 0);
    }
    $query2 = "SHOW COLUMNS FROM `#__acajoom_lists` ";
    $database->setQuery($query2);
    $columns = $database->loadResultArray();
    if (!in_array('cat_id', $columns)) {
        $query[] = "ALTER TABLE `#__acajoom_lists` CHANGE `choose_time` `cat_id` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0'";
    }
    if (!in_array('next_date', $columns)) {
        $query[] = "ALTER TABLE `#__acajoom_lists` ADD `next_date` INT( 11 ) NOT NULL AFTER `notify_id` ";
    }
    if (!in_array('start_date', $columns)) {
        $query[] = "ALTER TABLE `#__acajoom_lists` ADD `start_date` DATE NOT NULL AFTER `next_date`";
    }
    $query[] = 'UPDATE `#__acajoom_lists` SET `acc_level` = 24 WHERE `acc_level` = 0';
    foreach ($acajoomConfigFile as $key => $val) {
        if (!isset($GLOBALS[ACA . $key])) {
            $xf->insert($key, $val, 0);
        }
    }
    if (!empty($vers) and $update->checkVersion($vers, '1.2.2')) {
        $query[] = "UPDATE `#__acajoom_lists` SET `acc_id` = '29' WHERE `acc_id` = '25' ";
    }
    if (empty($err) and !empty($vers) and $update->checkVersion($vers, '3.0.0')) {
        $xf->insert('disabletooltip', '0', 0);
        $xf->insert('minisendmail', '0', 0);
    }
    $query[] = "ALTER TABLE `#__acajoom_lists` CHANGE `cat_id` `cat_id` VARCHAR( 250 ) NOT NULL DEFAULT ''";
    if (empty($err) and !empty($vers) and $update->checkVersion($vers, '3.2.3')) {
        $xf->insert('embed_images', '0', 0);
        $xf->insert('clean_stats', '90', 0);
        $xf->insert('word_wrap', '0', 0);
        $query[] = "UPDATE `#__acajoom_lists` SET `cat_id`  = CONCAT(`cat_id`,':',`notify_id`), `notify_id`= 0 WHERE `list_type` = 7 AND `notify_id` > 0";
    }
    //Query to quickly synchronise all your subscribers during the install!
    $query[] = "INSERT IGNORE INTO `#__acajoom_subscribers` ( `user_id` , `name` , `email` , `receive_html` , `confirmed` , `blacklist` , `subscribe_date` )" . "SELECT U.id, U.name, U.email, '1', '1', U.block , U.registerDate from `#__users` as U;";
    if (!defined('WADMIN')) {
        define('WADMIN', 'administrator' . DS . 'components' . DS . 'com_acajoom' . DS);
    }
    if (!defined('WFRONT')) {
        define('WFRONT', 'components' . DS . 'com_acajoom' . DS);
    }
    $file[] = 'templates';
    $file[] = 'templates/default';
    $file[] = 'templates/index.html';
    $file[] = 'templates/default/default.html';
    $file[] = 'templates/default/tpl0_abovefooter.jpg';
    $file[] = 'templates/default/tpl0_powered_by.gif';
    $file[] = 'templates/default/tpl0_spacer.gif';
    $file[] = 'templates/default/tpl0_top_header.jpg';
    $file[] = 'templates/default/tpl0_underban.jpg';
    $file[] = 'templates/default/index.html';
    foreach ($file as $key5 => $ins) {
        if (!file_exists(ACA_JPATH_ROOT . DS . WFRONT . $ins) && file_exists(ACA_JPATH_ROOT . DS . WADMIN . $ins)) {
            @rename(ACA_JPATH_ROOT . DS . WADMIN . $ins, ACA_JPATH_ROOT . DS . WFRONT . $ins);
        }
    }
    $size = sizeof($query);
    for ($index = 0; $index < $size; $index++) {
        $database->setQuery($query[$index]);
        $database->query();
    }
    if (empty($vers)) {
        $xf->filetoDatabase($acajoomConfigFile);
    }
    $return .= setupMaiOptions($acajoomConfigFile);
    $return .= installBots();
    $return .= installModule();
    if (acajoom::checkCB()) {
        $return .= installPlugin();
    }
    subscribers::updateSubscribers(true, true);
    require_once WPATH_ADMIN . 'version.php';
    $xf->update('component', $localVersion['component']);
    $xf->update('type', $localVersion['type']);
    $xf->update('version', $localVersion['version']);
    $xf->update('level', $localVersion['level']);
    $message = acajoom::printM('noimage', _ACA_THANKYOU);
    backHTML::_header(_ACA_MENU_INSTALL, 'install.png', $message, '', '');
    if ($acajoomConfigFile['type'] == 'PRO') {
        backHTML::about();
    } elseif ($acajoomConfigFile['type'] == 'Plus') {
        backHTML::installPRO();
    } else {
        backHTML::installPlus();
    }
    $link = 'index2.php?option=com_acajoom&act=start';
    echo '<table style="width: 100%; text-align: left; margin-left: auto; margin-right: auto;" border="0" cellpadding="0" cellspacing="0"><tbody><tr>' . '<td style=" width: 140px;">&nbsp;</td><td style="text-align: center; vertical-align: middle; width: 140px;"><div id="cpanel">';
    backHTML::quickiconButton($link, 'inbox.png', _ACA_GET_STARTED, false, 'admin');
    echo '</div><td></td></td></tr></tbody></table>' . '<div style="clear:both;"></div>';
    echo '<br/><br/><br/><br/>';
    echo '<a href="http://www.ijoobi.com/index.php?option=com_content&view=article&id=7871:installation-errors&catid=29:acajoom&Itemid=72" target="_blank">If you have any error during the install process, please refer to our documentation at http://www.ijoobi.com/index.php?option=com_content&view=article&id=7871:installation-errors&catid=29:acajoom&Itemid=72</a>';
    echo '<br/><br/>';
    echo $return;
    return $return;
}
示例#5
0
function updateModule($name, $version, $md5, $size)
{
    $modules = getLocalList();
    foreach ($modules as $module) {
        $module = explode("|", $module);
        if ($module[0] == $name) {
            $localVersion = $module[1];
            $localDest = $module[2];
        }
    }
    removeModule($name, $localVersion, $localDest);
    installModule($name, $version, $localDest, $md5, $size);
}
示例#6
0
function handleTemplateManagement()
{
    global $sourceFolder;
    if (isset($_POST['btn_install'])) {
        $uploadId = processUploaded("Template");
        if ($uploadId != -1) {
            return installModule($uploadId, "Template");
        }
    } else {
        if (isset($_POST['btn_uninstall'])) {
            $query = "SELECT `value` FROM `" . MYSQL_DATABASE_PREFIX . "global` WHERE attribute= 'default_template'";
            $res = mysql_query($query);
            $row1 = array();
            $row1 = mysql_fetch_row($res);
            if (!isset($_POST['Template']) || $_POST['Template'] == "") {
                return "";
            }
            $toDelete = escape($_POST['Template']);
            $query = "SELECT * FROM `" . MYSQL_DATABASE_PREFIX . "templates` WHERE `template_name` = '" . $toDelete . "'";
            $query2 = "SELECT `page_id` FROM `" . MYSQL_DATABASE_PREFIX . "pages` WHERE `page_template` = '{$toDelete}' LIMIT 10";
            $result2 = mysql_query($query2) or displayerror(mysql_error());
            if ($row1[0] == $toDelete) {
                displayerror("The default template cannot be deleted! If you want to delete this template, first change the default template from 'Global Settings'.");
                return "";
            }
            if (mysql_num_rows($result2) == 0 || isset($_POST['confirm'])) {
                if ($row = mysql_fetch_array(mysql_query($query))) {
                    $query = "DELETE FROM `" . MYSQL_DATABASE_PREFIX . "templates` WHERE `template_name` = '" . $toDelete . "'";
                    mysql_query($query);
                    $query = "UPDATE `" . MYSQL_DATABASE_PREFIX . "pages` SET `page_template` = '" . $row1[0] . "' WHERE `page_template` = '" . $toDelete . "'";
                    mysql_query($query) or displayerror(mysql_error());
                    $templateDir = $sourceFolder . "/templates/" . $toDelete . "/";
                    if (file_exists($templateDir)) {
                        delDir($templateDir);
                    }
                    displayinfo("Template " . safe_html($_POST['Template']) . " uninstalled!");
                    return "";
                } else {
                    displayerror("Template uninstallation failed!");
                    return "";
                }
            }
            $pageList = "";
            while ($row = mysql_fetch_assoc($result2)) {
                $pageList .= "/home" . getPagePath($row['page_id']) . "<br>";
            }
            $templatename = safe_html($_POST['Template']);
            $ret = <<<RET
<fieldset>
<legend>{$ICONS['Templates Management']['small']}Template Management</legend>
Some of the page with {$templatename} template are:<br>
{$pageList}
<div class='cms-error'>The templates of these pages will be reset to default template if you proceed deleting the template.</div>
<form method=POST action='./+admin&subaction=template&subsubaction=uninstall'>
<input type=hidden value='{$templatename}' name='Template' />
<input type=submit value='Delete template' name='btn_uninstall' />
<input type=hidden value='confirm' name='confirm' />
</form>
</fieldset>
RET;
            return $ret;
        }
    }
    /*
    	this finalize and cancel subsubactions are vulnerabilities, any one can vary $_POST['path'] and make cms to delete itself.
    	so template installation is also merged with module and widget installation,
    	but some extra features specific to template installation(ie ignoring missing template variables and changing template name)
    	are missing in that installation, these will remain commented for reference till those features are implemented the other way
    	else if(isset($_GET['subsubaction']) && $_GET['subsubaction'] == 'finalize') 
    	{		
    	
    		$issues = "";
    		$ret = reportIssues(escape($_POST['path']),$issues);
    		if($ret[0] == 1) 
    		{
    			displayerror("Your template is still not compatible with Pragyan CMS. Please fix the reported issues during installation.");
    			delDir(escape($_POST['del']));
    			unlink(escape($_POST['file']));
    			return "";
    		}
    			
    		$templates=getAvailableTemplates();
    		$flag=false;
    		foreach ($templates as $template) 
    			if($template==$_POST['template'])
    			{
    				$flag=true;
    				break;
    			}
    		if($_POST['template']=="common" || $flag || file_exists($sourceFolder . "/templates/" . escape($_POST['template']) . "/")) 
    		{
    			displayerror("Template Installation failed : A folder by the template name already exists.");
    			$templatePath=safe_html($_POST['del']);
    			$str=safe_html($_POST['file']);
    			$ret=<<<RET
    			<form method=POST action='./+admin&subaction=canceltemplate'>
    			Please click the following button to start a fresh installation : 
    			<input type=hidden name='path' value='{$templatePath}'>
    			<input type=hidden name='file' value='{$str}'>
    			<input type=submit value="Fresh Installation">
    			</form>
    RET;
    			return $ret;
    			
    		}
    		rename(escape($_POST['path']), $sourceFolder . "/templates/" . escape($_POST['template']) . "/");
    		delDir(escape($_POST['del']));
    		unlink(escape($_POST['file']));
    		mysql_query("INSERT INTO `" . MYSQL_DATABASE_PREFIX . "templates` VALUES('" . escape($_POST['template']) . "')");
    		displayinfo("Template installation complete");
    		return "";
    		
    	} 
    	else if(isset($_GET['subsubaction']) && $_GET['subsubaction'] == 'cancel') 
    	{
    		delDir(escape($_POST['path']));
    		unlink(escape($_POST['file']));
    		return "";
    	}*/
}
示例#7
0
/**
 * Handles the global widget administration interface.
 * @param $pageId Id of the current page
 * @return HTML code of the widget admin page
 */
function handleWidgetAdmin($pageId)
{
    global $ICONS, $urlRequestRoot, $cmsFolder, $moduleFolder, $sourceFolder, $widgetFolder;
    $html = "";
    if (isset($_GET['subsubaction'])) {
        if ($_GET['subsubaction'] == "installwidget") {
            require_once "{$sourceFolder}/module.lib.php";
            $uploadId = processUploaded("Widget");
            if ($uploadId != -1) {
                $ret = installModule($uploadId, "Widget");
                if ($ret != "") {
                    return $ret;
                }
            }
        }
    }
    if (isset($_GET["deletewidget"])) {
        $widgetId = escape($_GET['deletewidget']);
        if (is_numeric($widgetId)) {
            $widget = mysql_fetch_assoc(mysql_query("SELECT * FROM `" . MYSQL_DATABASE_PREFIX . "widgetsinfo` WHERE `widget_id` = '{$widgetId}'"));
            $error = false;
            $deletelist = array("widgets", "widgetsinfo", "widgetsconfiginfo", "widgetsconfig", "widgetsdata");
            $rowCount = 0;
            foreach ($deletelist as $deleteitem) {
                $query = "DELETE FROM `" . MYSQL_DATABASE_PREFIX . $deleteitem . "` WHERE `widget_id` = '{$widgetId}'";
                mysql_query($query) or die($query . "<br><br>" . mysql_error());
                $ans = mysql_fetch_row(mysql_query("SELECT COUNT(*) FROM `" . MYSQL_DATABASE_PREFIX . $deleteitem . "` WHERE `widget_id` = '{$widgetId}'"));
                $rowCount += $ans[0];
            }
            if (is_dir("{$sourceFolder}/{$widgetFolder}/{$widget['widget_foldername']}")) {
                if (!delDir("{$sourceFolder}/{$widgetFolder}/{$widget['widget_foldername']}")) {
                    $error = true;
                }
            }
            if ($rowCount != 0 || $error) {
                displayerror("There was some error in deleting widget {$widget['widget_name']}");
            } else {
                displayinfo("{$widget['widget_name']} successfully deleted.");
            }
        }
    }
    if (isset($_GET['widgetid'])) {
        $widgetid = escape($_GET['widgetid']);
        $query = "SELECT `widget_name` AS 'name', `widget_classname` AS 'classname', `widget_foldername` AS 'foldername' FROM `" . MYSQL_DATABASE_PREFIX . "widgetsinfo` WHERE `widget_id`='{$widgetid}'";
        $res = mysql_query($query);
        if (mysql_num_rows($res) == 0) {
            displayerror("Required widget is not registered with Pragyan CMS properly.");
            return false;
        }
        $row = mysql_fetch_array($res);
        global $widgetFolder;
        $classname = $row['classname'];
        require_once "{$widgetFolder}/{$row['foldername']}/widget.class.php";
        ///Initializing as global instance.
        $widget = new $classname($widgetid, -1, $pageId);
        if (!$widget instanceof widgetFramework) {
            displayerror("The widget {$row['name']} doesn't extends widgetFramework class");
            return false;
        }
        if (!$widget->validInstall()) {
            if (!$widget->installWidget()) {
                displayerror("{$row['name']} widget is not installed properly.");
                return false;
            }
            $widget->loadWidget();
        }
        /// POST variables are processed inside this function
        if (isset($_GET['subsubaction']) && $_GET['subsubaction'] == "globalconf") {
            updateWidgetConf($widgetid, -1, TRUE);
        }
        $widgetinfo = getWidgetInfo($widgetid);
        $widgetglobalconfigs = getWidgetGlobalConfigInfo($widgetid);
        $containsFileUploadFields = false;
        $formElements = getConfigFormAsArray($widgetglobalconfigs, $containsFileUploadFields, -1, TRUE);
        $jsPath = "{$urlRequestRoot}/{$cmsFolder}/templates/common/scripts/formValidator.js";
        //validation.js
        $calpath = "{$urlRequestRoot}/{$cmsFolder}/{$moduleFolder}/form/calendar";
        $jsPathMooTools = "{$urlRequestRoot}/{$cmsFolder}/templates/common/scripts/mootools-1.11-allCompressed.js";
        $html = '<link rel="stylesheet" type="text/css" media="all" href="' . $calpath . '/calendar.css" title="Aqua" />' . '<script type="text/javascript" src="' . $calpath . '/calendar.js"></script>';
        $html .= '<div class="registrationform"><form class="fValidator-form" name="widgetglobalsettings" action="./+admin&subaction=widgets&subsubaction=globalconf&widgetid=' . $widgetid . '" method="post"';
        if ($containsFileUploadFields) {
            $html .= ' enctype="multipart/form-data"';
        }
        $html .= '>';
        $html .= "<table width=100%><tr><th colspan=2>Widget : {$widgetinfo['name']}</th></tr>";
        $html .= "<tr><td>Description : </td><td> {$widgetinfo['description']}</td></tr>";
        //Uncomment when support for retrieving instances is there
        /*$html.="<tr><td>Instances : </td><td>";
        		$instances=getWidgetInstances($widgetid);
        		if(count($instances)>0) $html.="<ol>";
        		else $html.="None"; 
        		foreach($instances as $instance)
        		{
        			$html.="<li><a href='$urlRequestRoot/{$instance['url']}/+settings&subaction=widgets'>".
        					"{$instance['name']} [{instance['url']}]</li>";
        		}
        		if(count($instances)>0) $html.="</ol>";
        		$html.="</td></tr>";
        		*/
        $html .= "<tr>" . join($formElements, "</tr>\n<tr>") . "</tr>";
        $html .= "</table><input name='update_global_settings' type='submit' value='Update'/>" . "<input type='reset' value='Reset'/>";
        $html .= "</form><br/>";
    }
    $widgetsarr = getAllWidgetsInfo();
    $html .= "<fieldset><legend>{$ICONS['Widgets']['small']}Available Widgets</legend>";
    $html .= "<table width=100%><tr><th colspan=4>Available Widgets<br/><i>Mouse over for description and Click for configuration</i></th></tr>\n\t<tr><th>Name</th><th>Version</th><th>Author</th><th>Actions</th></tr>";
    foreach ($widgetsarr as $widget) {
        $html .= "<tr><td><a title='" . $widget['description'] . "' href='./+admin&subaction=widgets&widgetid=" . $widget['id'] . "'>" . $widget['name'] . "</a></td><td>{$widget['version']}</td><td>{$widget['author']}</td><td><a href='./+admin&subaction=widgets&widgetid={$widget['id']}'>{$ICONS['Edit']['small']}</a><a href='./+admin&subaction=widgets&deletewidget={$widget['id']}'>{$ICONS['Delete']['small']}</a></td></tr>";
    }
    $html .= <<<HTML
<tr><td>Install new widget:</td><td colspan=3>
<form method='POST' action='./+admin&subaction=widgets&subsubaction=installwidget' enctype="multipart/form-data">
<input type='file' name='file' id='file'><input type='submit' name='btn_install' value='Upload'>
</form>
</td></tr></table></fieldset>
HTML;
    return $html;
}
            break;
        case $lang["edit_link"]:
            editLink($id);
            break;
        case $lang["delete_link"]:
            deleteLink($id);
            break;
        case $lang["delete_user"]:
            deleteUser($id);
            break;
        case $lang["delete_event"]:
            deleteEvent($id);
            break;
        case $lang["add_profile"]:
            addProfile();
            break;
        case $lang["update modules"]:
            updateModules();
            break;
        case "approve":
            approve($id);
            break;
        case "install_module":
            installModule($dir, $file);
            break;
        default:
            header("Location: index.php");
            break;
    }
    mysql_close($link);
}
示例#9
0
$gitHubRepoUrl = 'https://github.com/uwol/vcms/tree/master';
$modulesRelativeDirectoryPath = 'modules';
$engineUpdateScript = 'vendor/vcms/install/update.php';
$tempRelativeDirectoryPath = 'temp';
$tempAbsoluteDirectoryPath = $libFilesystem->getAbsolutePath($tempRelativeDirectoryPath);
echo '<h1>Module</h1>';
echo '<div class="alert alert-info" role="alert">';
/*
* actions
*/
$libFilesystem->deleteDirectory($tempRelativeDirectoryPath);
@mkdir($tempAbsoluteDirectoryPath);
if (isset($_REQUEST['modul']) && $_REQUEST['modul'] != '' && $_REQUEST['modul'] != 'engine') {
    $module = $_REQUEST['modul'];
    if ($_REQUEST['aktion'] == 'installModule' && $module != '') {
        installModule($module);
    } elseif ($_REQUEST['aktion'] == 'uninstallModule' && $module != '') {
        uninstallModule($module);
    }
}
if (isset($_REQUEST['aktion']) && $_REQUEST['aktion'] == 'updateEngine') {
    updateEngine();
}
$libCronjobs->executeJobs();
echo 'Lade Paketinformationen aus dem Repository.';
echo '</div>';
$manifestUrl = 'http://' . $repoHostname . '/manifest.json?id=' . $libGlobal->getSiteUrlAuthority() . '&version=' . $libGlobal->version;
$modules = getModules($manifestUrl);
/*
* output
*/
示例#10
0
         include_once 'functions/parseAll.func.php';
         parseAll();
     }
     header('Location:?event=showModules');
     exit;
 case 'parseAll':
     // start ModuleHandler
     global $ModuleHandler;
     $ModuleHandler = new ts_ModuleHandler();
     include_once 'functions/parseAll.func.php';
     parseAll();
     header('Location:?event=showModules');
     exit;
 case 'installModule':
     include_once 'functions/installModule.func.php';
     installModule();
     header('Location:?event=showModules');
     exit;
 case 'updateModule':
     include_once 'functions/updateModule.func.php';
     updateModule();
     header('Location:?event=showModules');
     exit;
 case 'uninstallModule':
     include_once 'functions/uninstallModule.func.php';
     uninstallModule();
     header('Location:?event=showModules');
     exit;
 case 'deleteModule':
     include_once 'functions/deleteModule.func.php';
     deleteModule();
示例#11
0
function com_install()
{
    global $database;
    global $_VERSION;
    require_once $GLOBALS['mosConfig_absolute_path'] . '/components/com_acajoom/defines.php';
    require_once WPATH_ADMIN . 'config.acajoom.php';
    require_once WPATH_ADMIN . 'admin.acajoom.html.php';
    require_once WPATH_CLASS . 'class.acajoom.php';
    $update = new wupdate();
    $xf = new xonfig();
    $return = '';
    if (!is_writable($GLOBALS['mosConfig_absolute_path'] . $acajoomConfigFile['upload_url'])) {
        @chmod($GLOBALS['mosConfig_absolute_path'] . $acajoomConfigFile['upload_url'], 0777);
    }
    $query[] = "UPDATE #__components\n\t  SET admin_menu_img='../administrator/components/com_acajoom/images/acajoom_icon.png'\n\t  WHERE admin_menu_link='option=com_acajoom'";
    $query[] = "UPDATE #__components\n\t  SET admin_menu_img='../includes/js/ThemeOffice/edit.png',\n\t  name='" . compa::encodeutf(_ACA_MENU_LIST) . "',\n\t  admin_menu_alt='" . _ACA_MENU_LIST . "'\n\t  WHERE admin_menu_link='option=com_acajoom&act=list'";
    $query[] = "UPDATE #__components\n\t  SET admin_menu_img='../includes/js/ThemeOffice/users_add.png' ,\n\t  name='" . compa::encodeutf(_ACA_MENU_SUBSCRIBERS) . "',\n\t  admin_menu_alt='" . _ACA_MENU_SUBSCRIBERS . "'\n\t  WHERE admin_menu_link='option=com_acajoom&act=subscribers'";
    $query[] = "UPDATE #__components\n\t  SET admin_menu_img='../includes/js/ThemeOffice/messaging_inbox.png' ,\n\t  name='" . compa::encodeutf(_ACA_MENU_NEWSLETTERS) . "',\n\t  admin_menu_alt='" . _ACA_MENU_NEWSLETTERS . "'\n\t  WHERE admin_menu_link='option=com_acajoom&act=mailing&listype=1'";
    $query[] = "UPDATE #__components\n\t  SET admin_menu_img='../includes/js/ThemeOffice/messaging_config.png' ,\n\t  name='" . compa::encodeutf(_ACA_MENU_AUTOS) . "',\n\t  admin_menu_alt='" . _ACA_MENU_AUTOS . "'\n\t  WHERE admin_menu_link='option=com_acajoom&act=mailing&listype=2'";
    $query[] = "UPDATE #__components\n\t  SET admin_menu_img='../includes/js/ThemeOffice/query.png' ,\n\t   name='" . compa::encodeutf(_ACA_MENU_STATS) . "',\n\t   admin_menu_alt='" . _ACA_MENU_STATS . "'\n\t  WHERE admin_menu_link='option=com_acajoom&act=statistics'";
    $query[] = "UPDATE #__components\n\t  SET admin_menu_img='../includes/js/ThemeOffice/menus.png' ,\n\t   name='" . compa::encodeutf(_ACA_MENU_CONF) . "',\n\t   admin_menu_alt='" . _ACA_MENU_CONF . "'\n\t  WHERE admin_menu_link='option=com_acajoom&act=configuration'";
    $query[] = "UPDATE #__components\n\t  SET admin_menu_img='../includes/js/ThemeOffice/restore.png' ,\n\t  name='" . compa::encodeutf(_ACA_MENU_UPDATE) . "',\n\t  admin_menu_alt='" . _ACA_MENU_UPDATE . "'\n\t  WHERE admin_menu_link='option=com_acajoom&act=update'";
    $query[] = "UPDATE #__components\n\t  SET admin_menu_img='../includes/js/ThemeOffice/credits.png' ,\n\t  name='" . compa::encodeutf(_ACA_MENU_ABOUT) . "',\n\t  admin_menu_alt='" . _ACA_MENU_ABOUT . "'\n\t  WHERE admin_menu_link='option=com_acajoom&act=about'";
    $q = " SELECT `text` FROM `#__acajoom_xonfig` WHERE `akey` = 'version' ";
    $database->setQuery($q);
    $vers = $database->loadResult();
    $err = $database->getErrorMsg();
    if (!empty($err)) {
        $q = " SELECT `text` FROM `#__acajoom_xonfig` WHERE `key` = 'version' ";
        $database->setQuery($q);
        $vers = $database->loadResult();
        if (!empty($vers) and $update->checkVersion($vers, '1.0.6')) {
            ### UPDATE database if before 1.0.7
            $query[] = "ALTER TABLE `#__acajoom_mailings` CHANGE `images` `images` TEXT NOT NULL ";
            $query[] = "ALTER TABLE `#__acajoom_lists` ADD `footer` TINYINT( 1 ) NOT NULL DEFAULT '1' ";
            $query[] = "ALTER TABLE `#__acajoom_lists` ADD `notify_id` INT( 10 ) NOT NULL DEFAULT '0' ";
            $query[] = "ALTER TABLE `#__acajoom_xonfig` DROP INDEX `key` ";
            $query[] = "ALTER TABLE `#__acajoom_xonfig` CHANGE `key` `akey` VARCHAR( 32 ) NOT NULL ";
            $query[] = "ALTER TABLE `#__acajoom_xonfig` CHANGE `value` `value` INT( 11 ) NOT NULL ";
            $query[] = "ALTER TABLE `#__acajoom_stats_global` DROP `listid`  ";
            $query[] = "ALTER TABLE `#__acajoom_stats_global` DROP INDEX `listid` ";
            $query[] = "ALTER TABLE `#__acajoom_stats_global` ADD PRIMARY KEY ( `mailing_id` ) ";
            $query[] = "ALTER TABLE `#__acajoom_stats_details` DROP `listid` ";
            $query[] = "ALTER TABLE `#__acajoom_stats_details` DROP INDEX `listid` ";
            $query[] = "ALTER TABLE `#__acajoom_stats_details` ADD PRIMARY KEY ( `mailing_id` , `subscriber_id` ) ";
            ### 1.0.9
            $query[] = " ALTER TABLE `#__acajoom_mailings` CHANGE `fromname` `fromname` VARCHAR( 64 ) NOT NULL  ";
            $query[] = " ALTER TABLE `#__acajoom_lists` CHANGE `sendername` `sendername` VARCHAR( 64 ) NOT NULL  ";
        }
    }
    if (empty($err) and !empty($vers) and $update->checkVersion($vers, '1.0.8')) {
        $query[] = " ALTER TABLE `#__acajoom_mailings` CHANGE `fromname` `fromname` VARCHAR( 64 ) NOT NULL  ";
        $query[] = " ALTER TABLE `#__acajoom_lists` CHANGE `sendername` `sendername` VARCHAR( 64 ) NOT NULL  ";
        ### upgrade path for new versions
        $xf->insert('wait_for_user', '0', 0);
        $xf->insert('report_site', 'http://www.acajoom.com', 0);
        $xf->insert('use_sef', '0', 0);
        $xf->insert('send_error', '1', 0);
        $xf->insert('report_error', '1', 0);
        $xf->insert('wait_for_user', '0', 0);
        $xf->insert('show_archive', '1', 0);
        $xf->insert('update_notification', '1', 0);
        $xf->update('send_log_address', '@acajoom.com');
        $xf->update('update_url', 'http://www.acajoom.com/update/');
    }
    if (empty($err) and !empty($vers) and $update->checkVersion($vers, '1.1.0')) {
        $query[] = "ALTER TABLE `#__acajoom_lists` ADD `notification` INT( 10 ) NOT NULL DEFAULT '0' ";
        $xf->update('listname1', '_ACA_NEWSLETTER');
        $xf->update('listnames1', '_ACA_MENU_NEWSLETTERS');
    }
    if (empty($err) and !empty($vers) and $update->checkVersion($vers, '1.1.4')) {
        $xf->insert('last_sub_update', '', 0);
        $xf->insert('level', '1', 0);
    }
    if (empty($err) and !empty($vers) and $update->checkVersion($vers, '1.3.0')) {
        $xf->insert('show_author', '0', 0);
    }
    if (empty($err) and !empty($vers) and $update->checkVersion($vers, '1.5.5')) {
        $xf->insert('addEmailRedLink', '0', 0);
    }
    if (empty($err) and !empty($vers) and $update->checkVersion($vers, '1.5.5')) {
        $query[] = " ALTER TABLE `#__acajoom_subscribers` ADD INDEX `subscribe_date` ( `subscribe_date` )   ";
        $query[] = " ALTER TABLE `#__acajoom_queue` CHANGE `subscriber_id` `subscriber_id` INT( 11 ) DEFAULT '0' NOT NULL  ";
    }
    if (empty($err) and !empty($vers) and $update->checkVersion($vers, '1.6.4')) {
        $xf->insert('show_jcalpro', '0', 0);
        $xf->insert('redirectconfirm', '', 0);
        $xf->insert('itemidAca', '99', 0);
    }
    $query2 = "SHOW COLUMNS FROM `#__acajoom_lists` ";
    $database->setQuery($query2);
    $columns = $database->loadResultArray();
    if (!in_array('cat_id', $columns)) {
        $query[] = "ALTER TABLE `#__acajoom_lists` CHANGE `choose_time` `cat_id` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0'";
    }
    if (!in_array('next_date', $columns)) {
        $query[] = "ALTER TABLE `#__acajoom_lists` ADD `next_date` INT( 11 ) NOT NULL AFTER `notify_id` ";
    }
    if (!in_array('start_date', $columns)) {
        $query[] = "ALTER TABLE `#__acajoom_lists` ADD `start_date` DATE NOT NULL AFTER `next_date`";
    }
    $query[] = 'UPDATE `#__acajoom_lists` SET `acc_level` = 24 WHERE `acc_level` = 0';
    foreach ($acajoomConfigFile as $key => $val) {
        if (!isset($GLOBALS[ACA . $key])) {
            $xf->insert($key, $val, 0);
        }
    }
    if (!empty($vers) and $update->checkVersion($vers, '1.2.2')) {
        $query[] = "UPDATE `#__acajoom_lists` SET `acc_id` = '29' WHERE `acc_id` = '25' ";
    }
    if (!defined('WADMIN')) {
        define('WADMIN', 'administrator' . DS . 'components' . DS . 'com_acajoom' . DS);
    }
    if (!defined('WFRONT')) {
        define('WFRONT', 'components' . DS . 'com_acajoom' . DS);
    }
    $file[] = 'templates';
    $file[] = 'templates/default';
    $file[] = 'templates/index.html';
    $file[] = 'templates/default/default.html';
    $file[] = 'templates/default/tpl0_abovefooter.jpg';
    $file[] = 'templates/default/tpl0_powered_by.gif';
    $file[] = 'templates/default/tpl0_spacer.gif';
    $file[] = 'templates/default/tpl0_top_header.jpg';
    $file[] = 'templates/default/tpl0_underban.jpg';
    $file[] = 'templates/default/index.html';
    foreach ($file as $key5 => $ins) {
        if (!file_exists($GLOBALS['mosConfig_absolute_path'] . DS . WFRONT . $ins) && file_exists($GLOBALS['mosConfig_absolute_path'] . DS . WADMIN . $ins)) {
            @rename($GLOBALS['mosConfig_absolute_path'] . DS . WADMIN . $ins, $GLOBALS['mosConfig_absolute_path'] . DS . WFRONT . $ins);
        }
    }
    $size = sizeof($query);
    for ($index = 0; $index < $size; $index++) {
        $database->setQuery($query[$index]);
        $database->query();
    }
    if (empty($vers)) {
        $xf->filetoDatabase($acajoomConfigFile);
    }
    $return .= setupMaiOptions($acajoomConfigFile);
    $return .= installBots();
    $return .= installModule();
    if (acajoom::checkCB()) {
        $return .= installPlugin();
    }
    subscribers::updateSubscribers(true, true);
    require_once WPATH_ADMIN . 'version.php';
    $xf->update('component', $localVersion['component']);
    $xf->update('type', $localVersion['type']);
    $xf->update('version', $localVersion['version']);
    $xf->update('level', $localVersion['level']);
    $message = acajoom::printM('noimage', _ACA_THANKYOU);
    backHTML::_header(_ACA_MENU_INSTALL, 'install.png', $message, '', '');
    if ($acajoomConfigFile['type'] == 'PRO') {
        backHTML::about();
    } elseif ($acajoomConfigFile['type'] == 'Plus') {
        backHTML::installPRO();
    } else {
        backHTML::installPlus();
    }
    $link = 'index2.php?option=com_acajoom&act=start';
    echo '<table style="width: 100%; text-align: left; margin-left: auto; margin-right: auto;" border="0" cellpadding="0" cellspacing="0"><tbody><tr>' . '<td style=" width: 140px;">&nbsp;</td><td style="text-align: center; vertical-align: middle; width: 140px;"><div id="cpanel">';
    backHTML::quickiconButton($link, 'inbox.png', _ACA_GET_STARTED, false, 'admin');
    echo '</div><td></td></td></tr></tbody></table>' . '<div style="clear:both;"></div>';
    echo '<br/><br/><br/><br/>';
    echo compa::encodeutf($return);
    return $return;
}