Example #1
0
/**
 * funtion for installing a module from a git repo name
 * @param array     $options array ('repo' => 'git::repo')
 * @param string    $type (module, profile or template)
 */
function cos_git_install($options, $type = 'module')
{
    $module_name = git::getModulenameFromRepo($options['repo']);
    if (!$module_name) {
        common::abort('Install command need a valid repo name');
    }
    $options['module'] = $module_name;
    cos_git_clone($options, $type);
    if ($type == 'module') {
        $str = install_module($options, true);
        common::echoMessage($str);
        return;
    }
    if ($type == 'template') {
        $str = install_template($options, true);
        common::echoMessage($str);
        return;
    }
}
function exec_ogp_module()
{
    global $db;
    global $view;
    print "<h2>" . get_lang_f('installing_module', $_REQUEST['module']) . "</h2>";
    require_once 'modules/modulemanager/module_handling.php';
    $install_retval = -99;
    if (isset($_REQUEST['module'])) {
        $install_retval = install_module($db, $_REQUEST['module']);
    }
    if ($install_retval > 0) {
        print_success(get_lang_f("successfully_installed_module", $_REQUEST['module']));
    } else {
        if ($install_retval == 0) {
            print_success(get_lang_f("module_already_installed", $_REQUEST['module']));
        } else {
            print_failure(get_lang_f("failed_to_install_module", $_REQUEST['module']));
        }
    }
    $view->refresh("?m=modulemanager");
}
function deactivate_module($module)
{
    if (!is_module_installed($module)) {
        if (!install_module($module)) {
            return false;
        } else {
            //modules that weren't installed go to deactivated state by default in install_module
            return true;
        }
    }
    $sql = "UPDATE " . db_prefix("modules") . " SET active=0 WHERE modulename='{$module}'";
    db_query($sql);
    invalidatedatacache("inject-{$module}");
    massinvalidate("moduleprepare");
    if (db_affected_rows() <= 0) {
        return false;
    } else {
        return true;
    }
}
 case "uninstall":
     output("`3Uninstalling `#{$modulename}`3: ");
     if (uninstall_module($modulename)) {
         output("`@OK!`0`n");
     } else {
         output("`\$Failed!`0`n");
     }
     break;
 case "install":
     output("`3Installing `#{$modulename}`3: ");
     if (install_module($modulename)) {
         output("`@OK!`0`n");
     } else {
         output("`\$Failed!`0`n");
     }
     install_module($modulename);
     break;
 case "activate":
     output("`3Activating `#{$modulename}`3: ");
     if (activate_module($modulename)) {
         output("`@OK!`0`n");
     } else {
         output("`\$Failed!`0`n");
     }
     break;
 case "deactivate":
     output("`3Deactivating `#{$modulename}`3: ");
     if (deactivate_module($modulename)) {
         output("`@OK!`0`n");
     } else {
         output("`\$Failed!`0`n");
Example #5
0
function upgrade_chat_to_19()
{
    global $includePath;
    // activate new module to replace the old one
    $tool = 'CLCHAT_19';
    switch ($step = get_upgrade_status($tool)) {
        case 1:
            // install new chat
            if (!file_exists($includePath . '/../../module/CLCHAT')) {
                log_message('New Chat module not found : keep the old one !');
                $step = set_upgrade_status($tool, 0);
                return $step;
            }
            list($backLog, $moduleId) = install_module($includePath . '/../../module/CLCHAT', true);
            log_message($backLog->output());
            if ($moduleId) {
                list($backLog, $success) = activate_module_in_platform($moduleId);
                log_message($backLog->output());
            } else {
                return $step;
            }
            if ($success) {
                $step = set_upgrade_status($tool, $step + 1);
            } else {
                return $step;
            }
        case 2:
            // remove old chat
            $moduleId = get_module_data('CLCHT', 'id');
            if ($moduleId) {
                list($backLog, $success) = uninstall_module($moduleId);
                log_message($backLog->output());
            } else {
                $success = true;
            }
            if ($success) {
                $step = set_upgrade_status($tool, $step + 1);
            } else {
                return $step;
            }
        default:
            $step = set_upgrade_status($tool, 0);
            return $step;
    }
    return false;
}
/** main entry point for update wizard (called from /program/main_admin.php)
 *
 * This routine takes care of executing update routines for both the core
 * program and modules, themes, etc. It is called automagically whenever
 * the core program version in the database is different from the version
 * in the file {@lnk version.php} (see also {@link main_admin()}).
 *
 * It can also be called manually via 'job=update'. When no specific
 * task is specified, this routine shows the overview of versions for
 * core, modules, themes, etc. Whenever a component is NOT up to date,
 * an [Update] button is displayed. If a component IS up to date, we
 * simply display the word 'OK'. This implies that when everything is up
 * to date, the overview simply displays a list of OK's and the user
 * is 'free to go'.
 *
 * The actual updates for modules, themes, etc. is done via the various
 * subsystems themselves, e.g. by calling htmlpage_upgrade() in the file
 * /program/modules/htmlpage/htmlpage_install.php. The updates for the
 * core program are actually performed from this file right here, see
 * {@link update_core_2010120800()} below for an example.
 *
 * Note that we give a core update high priority: if the core
 * is not up to date, nothing will work, except updating the core.
 *
 * @param object &$output collects the html output
 * @return void results are returned as output in $output
 */
function job_update(&$output)
{
    global $CFG, $WAS_SCRIPT_NAME, $USER;
    $output->set_helptopic('update');
    $task = get_parameter_string('task', TASK_UPDATE_OVERVIEW);
    if ($task == TASK_UPDATE_OVERVIEW) {
        update_show_overview($output);
    } elseif ($task == TASK_UPDATE_CORE) {
        update_core($output);
        update_show_overview($output);
    } elseif (intval($CFG->version) != intval(WAS_VERSION)) {
        $output->add_message(t('update_core_warnning_core_goes_first', 'admin'));
        update_show_overview($output);
    } else {
        $key = get_parameter_string('key', '');
        switch ($task) {
            case TASK_INSTALL_LANGUAGE:
                install_language($output, $key);
                update_show_overview($output);
                break;
            case TASK_UPDATE_LANGUAGE:
                update_language($output, $key);
                update_show_overview($output);
                break;
            case TASK_INSTALL_MODULE:
                install_module($output, $key);
                update_show_overview($output);
                break;
            case TASK_UPDATE_MODULE:
                update_module($output, $key);
                update_show_overview($output);
                break;
            case TASK_INSTALL_THEME:
                install_theme($output, $key);
                update_show_overview($output);
                break;
            case TASK_UPDATE_THEME:
                update_theme($output, $key);
                update_show_overview($output);
                break;
            default:
                $s = utf8_strlen($task) <= 50 ? $task : utf8_substr($task, 0, 44) . ' (...)';
                $message = t('task_unknown', 'admin', array('{TASK}' => htmlspecialchars($s)));
                $output->add_message($message);
                logger('tools: unknown task: ' . htmlspecialchars($s));
                update_show_overview($output);
                break;
        }
    }
}
$theOp = $op;
if (is_array($module)) {
    $modules = $module;
} else {
    if ($module) {
        $modules = array($module);
    } else {
        $modules = array();
    }
}
reset($modules);
while (list($key, $module) = each($modules)) {
    $op = $theOp;
    output("`2Performing `^%s`2 on `%%s`0`n", translate_inline($op), $module);
    if ($op == "install") {
        if (install_module($module)) {
        } else {
            httpset('cat', '');
        }
        $op = "";
        httpset('op', "");
    } elseif ($op == "uninstall") {
        if (uninstall_module($module)) {
        } else {
            output("Unable to inject module.  Module not uninstalled.`n");
        }
        $op = "";
        httpset('op', "");
    } elseif ($op == "activate") {
        activate_module($module);
        $op = "";
Example #8
0
        $msg = "<font color=red><b>Unable to upload. Return Code: " . $_FILES["file"]["error"] . "</b></font>";
        echo '
	<fieldset style="width:400px"><legend><b>Upload your file</b></legend>
	' . $msg . '
	<form enctype="multipart/form-data" action="Modules.php?modname=Tools/Update.php&action=install" method="POST">';
        //echo '<input type="hidden" name="MAX_FILE_SIZE" value="100000" /> ';
        echo 'Select the update zip file to upload: <input name="file" type="file" /><br /><br>
	<input type="submit" value="Upgrade Application" class=btn_large />
	</form>
	</fieldset>
';
    } else {
        move_uploaded_file($_FILES["file"]["tmp_name"], $target_path . "/" . $_FILES["file"]["name"]);
        echo "<b>Copied file " . $_FILES["file"]["name"] . " to temporary  dir</b><br>";
        $filename = $target_path . "/" . $_FILES["file"]["name"];
        unzip_install($filename, $target_path);
        unlink($filename);
        install_module($target_path, 'update.php');
    }
} else {
    echo '
<fieldset style="width:400px"><legend><b>Upload your file</b></legend>
' . $msg . '
<form enctype="multipart/form-data" action="Modules.php?modname=Tools/Update.php&action=install" method="POST">';
    //echo '<input type="hidden" name="MAX_FILE_SIZE" value="100000" /> ';
    echo 'Select the update zip file to upload: <input name="file" type="file" /><br /><br>
<input type="submit" value="Upgrade Application" class=btn_large />
</form>
</fieldset>
';
}
Example #9
0
/**
 * 
 * @param type $options 
 */
function upgrade_from_profile_web($options)
{
    // use profile object
    $pro = new profile();
    $pro->setProfileInfo($options['profile']);
    // install modules
    foreach ($pro->profileModules as $key => $val) {
        $val['version'] = $val['module_version'];
        $val['module'] = $val['module_name'];
        $module = new moduleinstaller();
        $res = $module->setInstallInfo($val);
        //if (!$res) continue;
        if ($module->isInstalled($val['module_name'])) {
            upgrade_module($val);
        } else {
            install_module($val);
        }
    }
    // install templates
    foreach ($pro->profileTemplates as $key => $val) {
        // no need to do anything
        // we use web install and sources
        // are downloaded.
    }
}
Example #10
0
$remove_remarks($sql_query);
$sql_query = split_sql_file($sql_query, $delimiter);
foreach ($sql_query as $sql) {
    $db->sql_query($sql);
}
unset($sql_query);
foreach ($config_items as $name => $value) {
    set_config($name, $value);
}
foreach ($config_items_dyn as $name => $value) {
    set_config($name, $value, true);
}
$acl = new auth_admin();
$acl->acl_add_option($permissions);
$error = array();
install_module('acp', 'acp_shoutbox', $error, 'ACP_CAT_DOT_MODS');
add_log('admin', 'LOG_AS_INSTALLED', VERSION);
trigger_error('MOD_INSTALLED');
function generate_sql(&$lineg, $dbms)
{
    global $phpbb_root_path, $phpEx;
    $dbms_type_map = array('mysql_41' => array('INT:' => 'int(%d)', 'BINT' => 'bigint(20)', 'UINT' => 'mediumint(8) UNSIGNED', 'UINT:' => 'int(%d) UNSIGNED', 'TINT:' => 'tinyint(%d)', 'USINT' => 'smallint(4) UNSIGNED', 'BOOL' => 'tinyint(1) UNSIGNED', 'VCHAR' => 'varchar(255)', 'VCHAR:' => 'varchar(%d)', 'CHAR:' => 'char(%d)', 'XSTEXT' => 'text', 'XSTEXT_UNI' => 'varchar(100)', 'STEXT' => 'text', 'STEXT_UNI' => 'varchar(255)', 'TEXT' => 'text', 'TEXT_UNI' => 'text', 'MTEXT' => 'mediumtext', 'MTEXT_UNI' => 'mediumtext', 'TIMESTAMP' => 'int(11) UNSIGNED', 'DECIMAL' => 'decimal(5,2)', 'DECIMAL:' => 'decimal(%d,2)', 'PDECIMAL' => 'decimal(6,3)', 'PDECIMAL:' => 'decimal(%d,3)', 'VCHAR_UNI' => 'varchar(255)', 'VCHAR_UNI:' => 'varchar(%d)', 'VCHAR_CI' => 'varchar(255)', 'VARBINARY' => 'varbinary(255)'), 'mysql_40' => array('INT:' => 'int(%d)', 'BINT' => 'bigint(20)', 'UINT' => 'mediumint(8) UNSIGNED', 'UINT:' => 'int(%d) UNSIGNED', 'TINT:' => 'tinyint(%d)', 'USINT' => 'smallint(4) UNSIGNED', 'BOOL' => 'tinyint(1) UNSIGNED', 'VCHAR' => 'varbinary(255)', 'VCHAR:' => 'varbinary(%d)', 'CHAR:' => 'binary(%d)', 'XSTEXT' => 'blob', 'XSTEXT_UNI' => 'blob', 'STEXT' => 'blob', 'STEXT_UNI' => 'blob', 'TEXT' => 'blob', 'TEXT_UNI' => 'blob', 'MTEXT' => 'mediumblob', 'MTEXT_UNI' => 'mediumblob', 'TIMESTAMP' => 'int(11) UNSIGNED', 'DECIMAL' => 'decimal(5,2)', 'DECIMAL:' => 'decimal(%d,2)', 'PDECIMAL' => 'decimal(6,3)', 'PDECIMAL:' => 'decimal(%d,3)', 'VCHAR_UNI' => 'blob', 'VCHAR_UNI:' => array('varbinary(%d)', 'limit' => array('mult', 3, 255, 'blob')), 'VCHAR_CI' => 'blob', 'VARBINARY' => 'varbinary(255)'), 'firebird' => array('INT:' => 'INTEGER', 'BINT' => 'DOUBLE PRECISION', 'UINT' => 'INTEGER', 'UINT:' => 'INTEGER', 'TINT:' => 'INTEGER', 'USINT' => 'INTEGER', 'BOOL' => 'INTEGER', 'VCHAR' => 'VARCHAR(255) CHARACTER SET NONE', 'VCHAR:' => 'VARCHAR(%d) CHARACTER SET NONE', 'CHAR:' => 'CHAR(%d) CHARACTER SET NONE', 'XSTEXT' => 'BLOB SUB_TYPE TEXT CHARACTER SET NONE', 'STEXT' => 'BLOB SUB_TYPE TEXT CHARACTER SET NONE', 'TEXT' => 'BLOB SUB_TYPE TEXT CHARACTER SET NONE', 'MTEXT' => 'BLOB SUB_TYPE TEXT CHARACTER SET NONE', 'XSTEXT_UNI' => 'VARCHAR(100) CHARACTER SET UTF8', 'STEXT_UNI' => 'VARCHAR(255) CHARACTER SET UTF8', 'TEXT_UNI' => 'BLOB SUB_TYPE TEXT CHARACTER SET UTF8', 'MTEXT_UNI' => 'BLOB SUB_TYPE TEXT CHARACTER SET UTF8', 'TIMESTAMP' => 'INTEGER', 'DECIMAL' => 'DOUBLE PRECISION', 'DECIMAL:' => 'DOUBLE PRECISION', 'PDECIMAL' => 'DOUBLE PRECISION', 'PDECIMAL:' => 'DOUBLE PRECISION', 'VCHAR_UNI' => 'VARCHAR(255) CHARACTER SET UTF8', 'VCHAR_UNI:' => 'VARCHAR(%d) CHARACTER SET UTF8', 'VCHAR_CI' => 'VARCHAR(255) CHARACTER SET UTF8', 'VARBINARY' => 'CHAR(255) CHARACTER SET NONE'), 'mssql' => array('INT:' => '[int]', 'BINT' => '[float]', 'UINT' => '[int]', 'UINT:' => '[int]', 'TINT:' => '[int]', 'USINT' => '[int]', 'BOOL' => '[int]', 'VCHAR' => '[varchar] (255)', 'VCHAR:' => '[varchar] (%d)', 'CHAR:' => '[char] (%d)', 'XSTEXT' => '[varchar] (1000)', 'STEXT' => '[varchar] (3000)', 'TEXT' => '[varchar] (8000)', 'MTEXT' => '[text]', 'XSTEXT_UNI' => '[varchar] (100)', 'STEXT_UNI' => '[varchar] (255)', 'TEXT_UNI' => '[varchar] (4000)', 'MTEXT_UNI' => '[text]', 'TIMESTAMP' => '[int]', 'DECIMAL' => '[float]', 'DECIMAL:' => '[float]', 'PDECIMAL' => '[float]', 'PDECIMAL:' => '[float]', 'VCHAR_UNI' => '[varchar] (255)', 'VCHAR_UNI:' => '[varchar] (%d)', 'VCHAR_CI' => '[varchar] (255)', 'VARBINARY' => '[varchar] (255)'), 'oracle' => array('INT:' => 'number(%d)', 'BINT' => 'number(20)', 'UINT' => 'number(8)', 'UINT:' => 'number(%d)', 'TINT:' => 'number(%d)', 'USINT' => 'number(4)', 'BOOL' => 'number(1)', 'VCHAR' => 'varchar2(255)', 'VCHAR:' => 'varchar2(%d)', 'CHAR:' => 'char(%d)', 'XSTEXT' => 'varchar2(1000)', 'STEXT' => 'varchar2(3000)', 'TEXT' => 'clob', 'MTEXT' => 'clob', 'XSTEXT_UNI' => 'varchar2(300)', 'STEXT_UNI' => 'varchar2(765)', 'TEXT_UNI' => 'clob', 'MTEXT_UNI' => 'clob', 'TIMESTAMP' => 'number(11)', 'DECIMAL' => 'number(5, 2)', 'DECIMAL:' => 'number(%d, 2)', 'PDECIMAL' => 'number(6, 3)', 'PDECIMAL:' => 'number(%d, 3)', 'VCHAR_UNI' => 'varchar2(765)', 'VCHAR_UNI:' => array('varchar2(%d)', 'limit' => array('mult', 3, 765, 'clob')), 'VCHAR_CI' => 'varchar2(255)', 'VARBINARY' => 'raw(255)'), 'sqlite' => array('INT:' => 'int(%d)', 'BINT' => 'bigint(20)', 'UINT' => 'INTEGER UNSIGNED', 'UINT:' => 'INTEGER UNSIGNED', 'TINT:' => 'tinyint(%d)', 'USINT' => 'INTEGER UNSIGNED', 'BOOL' => 'INTEGER UNSIGNED', 'VCHAR' => 'varchar(255)', 'VCHAR:' => 'varchar(%d)', 'CHAR:' => 'char(%d)', 'XSTEXT' => 'text(65535)', 'STEXT' => 'text(65535)', 'TEXT' => 'text(65535)', 'MTEXT' => 'mediumtext(16777215)', 'XSTEXT_UNI' => 'text(65535)', 'STEXT_UNI' => 'text(65535)', 'TEXT_UNI' => 'text(65535)', 'MTEXT_UNI' => 'mediumtext(16777215)', 'TIMESTAMP' => 'INTEGER UNSIGNED', 'DECIMAL' => 'decimal(5,2)', 'DECIMAL:' => 'decimal(%d,2)', 'PDECIMAL' => 'decimal(6,3)', 'PDECIMAL:' => 'decimal(%d,3)', 'VCHAR_UNI' => 'varchar(255)', 'VCHAR_UNI:' => 'varchar(%d)', 'VCHAR_CI' => 'varchar(255)', 'VARBINARY' => 'blob'), 'postgres' => array('INT:' => 'INT4', 'BINT' => 'INT8', 'UINT' => 'INT4', 'UINT:' => 'INT4', 'USINT' => 'INT2', 'BOOL' => 'INT2', 'TINT:' => 'INT2', 'VCHAR' => 'varchar(255)', 'VCHAR:' => 'varchar(%d)', 'CHAR:' => 'char(%d)', 'XSTEXT' => 'varchar(1000)', 'STEXT' => 'varchar(3000)', 'TEXT' => 'varchar(8000)', 'MTEXT' => 'TEXT', 'XSTEXT_UNI' => 'varchar(100)', 'STEXT_UNI' => 'varchar(255)', 'TEXT_UNI' => 'varchar(4000)', 'MTEXT_UNI' => 'TEXT', 'TIMESTAMP' => 'INT4', 'DECIMAL' => 'decimal(5,2)', 'DECIMAL:' => 'decimal(%d,2)', 'PDECIMAL' => 'decimal(6,3)', 'PDECIMAL:' => 'decimal(%d,3)', 'VCHAR_UNI' => 'varchar(255)', 'VCHAR_UNI:' => 'varchar(%d)', 'VCHAR_CI' => 'varchar_ci', 'VARBINARY' => 'bytea'));
    // A list of types being unsigned for better reference in some db's
    $unsigned_types = array('UINT', 'UINT:', 'USINT', 'BOOL', 'TIMESTAMP');
    $supported_dbms = array('firebird', 'mssql', 'mysql_40', 'mysql_41', 'oracle', 'postgres', 'sqlite');
    $schema_data = get_schema();
    if ($dbms == 'mysqli' || $dbms == 'mysql4') {
        $dbms = 'mysql_41';
    } else {
        if ($dbms == 'mysql') {
            $dbms = 'mysql_40';
Example #11
0
                 $success = false;
             }
         }
     } else {
         $summary = get_lang('Module installation failed');
         $details = get_lang('Missing module directory');
         $dialogBox->error(Backlog_Reporter::report($summary, $details));
     }
     break;
 case 'exLocalInstall':
     if (isset($_REQUEST['moduleDir'])) {
         $moduleDir = str_replace('../', '', $_REQUEST['moduleDir']);
         $moduleRepositorySys = get_path('rootSys') . 'module/';
         $modulePath = $moduleRepositorySys . $moduleDir . '/';
         if (file_exists($modulePath)) {
             list($backlog, $module_id) = install_module($modulePath, true);
             $details = $backlog->output();
             if (false !== $module_id) {
                 $moduleInfo = get_module_info($module_id);
                 $typeReq = $moduleInfo['type'];
                 $dialogBox->success(get_lang('Module installation succeeded'));
             } else {
                 $summary = get_lang('Module installation failed');
                 $dialogBox->error(Backlog_Reporter::report($summary, $details));
             }
         } else {
             $summary = get_lang('Module installation failed');
             $details = get_lang('Module directory not found');
             $dialogBox->error(Backlog_Reporter::report($summary, $details));
         }
     } else {
Example #12
0
function install_video_cache($aspid = false)
{
    $unix = new unix();
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    if ($aspid) {
        $pid = $unix->get_pid_from_file($pidfile);
        if ($unix->process_exists($pid, basename(__FILE__))) {
            $time = $unix->PROCCESS_TIME_MIN($pid);
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: Already Artica task running PID {$pid} since {$time}mn\n";
            }
            return;
        }
    }
    @file_put_contents($pidfile, getmypid());
    $modules["setuptools"] = true;
    $modules["iniparse"] = true;
    $modules["netifaces"] = true;
    $modules["cloghandler"] = true;
    $unix = new unix();
    $python = $unix->find_program("python");
    CHECK_DATABASE();
    build_progress("Checking modules", 15);
    while (list($modulename, $line) = each($modules)) {
        build_progress("Checking modules {$modulename}", 20);
        if (!python_verify_modules($modulename)) {
            if (!install_module($modulename)) {
                if ($GLOBALS["OUTPUT"]) {
                    echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} [!!] {$modulename} failed\n";
                }
                build_progress("Installing module {$modulename} failed", 110);
                return false;
            } else {
                if ($GLOBALS["OUTPUT"]) {
                    echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} [OK] {$modulename} INSTALLED\n";
                }
            }
        } else {
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} [OK] {$modulename}\n";
            }
        }
    }
    $files = videocache_files();
    $INSTALLED = true;
    while (list($modulename, $filepath) = each($files)) {
        if (!is_file($filepath)) {
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} [!!] " . basename($filepath) . " no such file\n";
            }
            $INSTALLED = false;
            break;
        }
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} [OK] " . basename($filepath) . " \n";
        }
    }
    if (!$INSTALLED) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} Installing VideoCache\n";
        }
        if (!install_video_cache_python()) {
            build_progress("Installing videocache package failed", 110);
            return false;
        }
        $files = videocache_files();
        while (list($modulename, $filepath) = each($files)) {
            if (!is_file($filepath)) {
                if ($GLOBALS["OUTPUT"]) {
                    echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} [!!] " . basename($filepath) . " no such file\n";
                }
                return false;
            }
        }
    }
    $chattr = $unix->find_program("chattr");
    shell_exec("{$chattr} +i -R /usr/share/videocache");
    $tables["video_files"] = true;
    $tables["video_queue"] = true;
    $tables["youtube_cpns"] = true;
    $tablesz = true;
    build_progress("Installing Tables", 40);
    while (list($tablename, $line) = each($tables)) {
        if (!TABLE_EXISTS($tablename, "videocache")) {
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} missing table {$tablename}\n";
            }
            $tablesz = false;
        }
    }
    if (!$tablesz) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} upgrading videocache\n";
        }
        shell_exec("{$python} /usr/share/videocache/vc-update >/dev/null 2>&1");
        reset($tables);
        $GLOBALS["VIDEOCACHE_TABLES"] = array();
        $tablesz = true;
        while (list($tablename, $line) = each($tables)) {
            if (!TABLE_EXISTS($tablename, "videocache")) {
                if ($GLOBALS["OUTPUT"]) {
                    echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} missing table {$tablename}\n";
                }
                $tablesz = false;
                break;
            }
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} `{$tablename}` OK\n";
            }
        }
    }
    if (!$tablesz) {
        build_progress("Installing Tables failed", 110);
        return false;
    }
    build_progress("Installing Tables success", 45);
    return true;
    // /artica-postfix/bin/install/squid/videocache.tar.gz
}
/**
 * Automatically process sql, adding config values,
 * adding modules, performing schema changes
 *
 * @param array $install_ary
 * @param array $error
 */
function process_install($install_ary, &$error)
{
    global $db;
    static $db_tools = false;
    if (!$db_tools) {
        if (!class_exists('phpbb_db_tools')) {
            global $phpbb_root_path, $phpEx;
            include $phpbb_root_path . 'includes/db/db_tools.' . $phpEx;
        }
        // create the db_tools object
        $db_tools = new phpbb_db_tools($db);
    }
    // initialisation
    foreach (array('sql', 'config', 'modules', 'schema_changes') as $key) {
        if (!isset($install_ary[$key])) {
            $install_ary[$key] = array();
        }
    }
    // queries
    foreach ($install_ary['sql'] as $sql) {
        $db->sql_query($sql);
    }
    // config entries
    foreach ($install_ary['config'] as $config_name => $config_value) {
        set_config($config_name, $config_value);
    }
    // modules
    foreach ($install_ary['modules'] as $module_class => $modules) {
        foreach ($modules as $module) {
            install_module($module_class, $module, $error);
        }
    }
    foreach ($install_ary['schema_changes'] as $type => $changes) {
        switch ($type) {
            case 'sql_column_add':
            case 'sql_column_change':
            case 'sql_column_remove':
            case 'sql_create_index':
            case 'sql_create_primary_key':
            case 'sql_create_unique_index':
            case 'sql_index_drop':
                foreach ($changes as $change_data) {
                    call_user_func_array(array($db_tools, $type), $change_data);
                }
                break;
        }
    }
}
Example #14
0
function install()
{
    $step = isset($_REQUEST['step']) ? $_REQUEST['step'] : "0";
    if ($step == "0") {
        $locale_files = makefilelist("lang/", ".|..|.svn", true, "folders");
        $counter = 0;
        $columns = 3;
        $width = round(100 / $columns);
        echo "<div id=\"install-title\" style=\"margin-top:-4px;\">" . get_lang('install_lang') . "</div>";
        echo "<table class='lang' style=\"margin-bottom:10px;\">\n<tr>";
        for ($i = 0; $i < count($locale_files); $i++) {
            if ($counter != 0 && $counter % $columns == 0) {
                echo "</tr>\n<tr>\n";
            }
            echo "<td style='width:" . $width . "%' >";
            if ($locale_files[$i] == $_SESSION['users_lang']) {
                echo "<li><b>" . $locale_files[$i] . "</b></li>";
            } else {
                echo "<li><a href='?localeset=" . $locale_files[$i] . "'>" . $locale_files[$i] . "</a></li>";
            }
            echo "</td>\n";
            $counter++;
        }
        echo "</tr>\n</table>\n";
        echo "<div id=\"install-title\">" . get_lang('install_welcome') . "</div>";
        echo "<h3>" . get_lang('file_permission_check') . ":</h3>";
        $failed = false;
        echo "<table class='install'>\n";
        // config.inc.php is checked seperately because we need to check first if the file
        // exists or not.
        $value = 'includes/config.inc.php';
        if (!is_file($value)) {
            @($control = fopen($value, "w+"));
            if ($control == false) {
                echo "<tr><td>" . $value . "</td><td><span class='failure'>" . get_lang('create_an_empty_file') . "</span></td></tr>";
                $failed = true;
            }
        } else {
            if (!is_writable($value)) {
                echo "<tr><td>" . $value . "</td><td><span class='failure'>" . get_lang('write_permission_required') . "</span></td></tr>";
                $failed = true;
            } else {
                echo "<tr><td>" . $value . "</td><td><span class='success'>" . get_lang('OK') . "</span></td></tr>";
            }
        }
        // Check if the folder "modules/TS3Admin/templates_c" is writable
        $value = 'modules/TS3Admin/templates_c';
        if (!is_writable($value)) {
            echo "<tr><td>" . $value . "</td><td><span class='failure'>" . get_lang('write_permission_required') . "</span></td></tr>";
            $failed = true;
        } else {
            echo "<tr><td>" . $value . "</td><td><span class='success'>" . get_lang('OK') . "</span></td></tr>";
        }
        echo "</table>";
        echo "<h3>" . get_lang('php_version_check') . "</h3>\n";
        echo "<table class='install'>";
        echo "<tr><td>PHP Version >= " . REQUIRED_PHP_VERSION . "</td><td>";
        if (version_compare(PHP_VERSION, REQUIRED_PHP_VERSION, ">=")) {
            echo "<span class='success'>" . PHP_VERSION . "</span>";
        } else {
            echo "<span class='failure'>" . PHP_VERSION . "</span>";
            $failed = true;
        }
        echo "</td></tr></table>";
        /* TODO: how to check if pear is enabled or not? */
        $properties_to_check = array(array("name" => "PHP XML-RPC module", "type" => "f", "value" => "xmlrpc_server_create"), array("name" => "PHP Curl module", "type" => "f", "value" => "curl_init"), array("name" => "PHP XML Reader", "type" => "c", "value" => "XMLReader"), array("name" => "PHP JSON Extension", "type" => "f", "value" => "json_decode"), array("name" => "PHP mbstring Extension", "type" => "x", "value" => "mbstring"));
        echo "<h3>" . get_lang('checking_required_modules') . "</h3>\n<table class='install'>";
        foreach ($properties_to_check as $propertie) {
            if ($propertie['type'] === "f" && function_exists($propertie['value']) || $propertie['type'] === "c" && class_exists($propertie['value']) || $propertie['type'] === "x" && extension_loaded($propertie['value'])) {
                echo "<tr><td>" . $propertie['name'] . "</td>\n                        <td><span class='success'>" . get_lang('found') . "</span></td></tr>";
            } else {
                echo "<tr><td>" . $propertie['name'] . "</td>\n                        <td><span class='failure'>" . get_lang('not_found') . "</span></td></tr>";
                $failed = true;
            }
        }
        echo "<tr><td>Pear XXTEA</td><td>";
        $xxtea_found = false;
        $pear_found = false;
        // Lets search for XXTEA pear module from include path.
        $include_paths = explode(PATH_SEPARATOR, get_include_path());
        foreach ($include_paths as $include_path) {
            if (file_exists($include_path . "/" . "Crypt/XXTEA.php")) {
                $xxtea_found = true;
            }
            // Pear always includes System.php file that should be found from the include path.
            if (file_exists($include_path . "/" . "System.php")) {
                $pear_found = true;
            }
        }
        if ($xxtea_found) {
            print_success(get_lang('found'));
        } else {
            print_failure(get_lang('not_found'));
            echo "<p class='info'>" . get_lang('pear_xxtea_info') . "</p>";
            $failed = true;
        }
        echo "</td></tr>";
        echo "<tr><td>Pear</td><td>";
        if ($pear_found) {
            print_success(get_lang('found'));
        } else {
            print_failure(get_lang('not_found'));
            $failed = true;
        }
        echo "</td></tr>";
        echo "<tr><td>file_get_contents()</td><td>";
        if (is_function_available('file_get_contents')) {
            print_success(get_lang('found'));
        } else {
            print_failure(get_lang('not_found'));
            $failed = true;
        }
        echo "</td></tr>";
        echo "<tr><td>allow_url_fopen=on</td><td>";
        if (is_function_available('allow_url_fopen')) {
            print_success(get_lang('found'));
        } else {
            print_failure(get_lang('not_found'));
            $failed = true;
        }
        echo "</td></tr>";
        echo "</table>\n";
        if ($failed) {
            echo "<p><a href='?'>" . get_lang('refresh') . "</a></p>\n";
        } else {
            echo "<p><a href='?step=1'>" . get_lang('next') . "</a></p>\n";
        }
        echo "</td></tr></table>\n";
    } else {
        if ($step == "1") {
            echo "<table class='install'><tr><td>\n";
            if (is_readable('includes/config.inc.php')) {
                require_once "includes/config.inc.php";
            }
            echo "<form name='setup' method='post' action='?step=2'>";
            echo "<table class='install'>\n";
            echo "<tr><td colspan='2'><div id=\"install-title\" style=\"margin-left:-21px; margin-top:-7px;\">" . get_lang('database_settings') . "</div></td></tr>\n            <tr><td>" . get_lang('database_type') . ":</td><td>MySQL</td></tr>\n            <tr><td>" . get_lang('database_hostname') . ":</td>\n            <td><input type='text' value='";
            echo isset($db_host) ? $db_host : "localhost";
            echo "' name='db_host' class='textbox' /></td></tr>\n            <tr><td>" . get_lang('database_username') . ":</td>\n            <td><input type='text' value='";
            echo isset($db_user) ? $db_user : "";
            echo "' name='db_user' class='textbox' /></td></tr>\n            <tr><td>" . get_lang('database_password') . ":</td>\n            <td><input type='password' value='";
            echo isset($db_pass) ? $db_pass : "";
            echo "' name='db_pass' class='textbox' /></td></tr>\n            <tr><td>" . get_lang('database_name') . ":</td>\n            <td><input type='text' value='";
            echo isset($db_name) ? $db_name : "";
            echo "' name='db_name' class='textbox' /></td></tr>";
            echo "<tr><td>" . get_lang('database_prefix') . ":</td>\n            <td><input type='text' value='";
            echo isset($table_prefix) ? $table_prefix : "ogp_";
            echo "' name='table_prefix' class='textbox' /></td></tr>";
            echo "</table>\n\n            <p><input type='submit' name='next' value='" . get_lang('next') . "' class='button' /></p></form>";
            echo "<p><a href='?step=0'>" . get_lang('back') . "</a></p>";
            echo "</td></tr></table>\n";
        } else {
            if ($step == "2") {
                echo "<table class='install'><tr><td>\n";
                if (isset($_POST['db_host'])) {
                    $db_host = stripinput($_POST['db_host']);
                    $db_user = stripinput($_POST['db_user']);
                    $db_pass = stripinput($_POST['db_pass']);
                    $db_name = stripinput($_POST['db_name']);
                    $table_prefix = stripinput($_POST['table_prefix']);
                    $db_type = "mysql";
                    $config = "<?php\n" . "###############################################\n" . "# Site configuration\n" . "###############################################\n" . "\$db_host=\"" . $db_host . "\";\n" . "\$db_user=\"" . $db_user . "\";\n" . "\$db_pass=\"" . $db_pass . "\";\n" . "\$db_name=\"" . $db_name . "\";\n" . "\$table_prefix=\"" . $table_prefix . "\";\n" . "\$db_type=\"" . $db_type . "\";\n" . "?>";
                    $temp = @fopen("includes/config.inc.php", "w");
                    if (!@fwrite($temp, $config)) {
                        print_failure(get_lang('unable_to_write_config'));
                        echo "<p><a href='?step=0'>" . get_lang('back') . "</a></p>";
                        fclose($temp);
                        return;
                    }
                    fclose($temp);
                }
                require_once "includes/config.inc.php";
                $db = createDatabaseConnection($db_type, $db_host, $db_user, $db_pass, $db_name, $table_prefix);
                $error_text = "";
                if (get_db_error_text($db, $error_text)) {
                    print_failure($error_text);
                    echo "<p><a href='?step=1'>" . get_lang('back') . "</a></p>";
                    return;
                }
                $fail = false;
                // These belong to module manager, but they need to be created before other modules can be "installed".
                $result = $db->query("DROP TABLE IF EXISTS " . $table_prefix . "modules");
                $result = $db->query("CREATE TABLE IF NOT EXISTS `" . $table_prefix . "modules` (\n            `id` smallint(5) unsigned NOT NULL auto_increment,\n            `title` varchar(100) NOT NULL default '',\n            `folder` varchar(100) NOT NULL default '',\n            `version` varchar(10) NOT NULL default '0',\n            `db_version` int(10) NOT NULL default '0',\n            PRIMARY KEY  (`id`),\n        UNIQUE KEY `folder` (`folder`)\n    ) ENGINE=MyISAM  DEFAULT CHARSET=latin1;");
                $result = $db->query("DROP TABLE IF EXISTS " . $table_prefix . "module_menus");
                $result = $db->query("CREATE TABLE IF NOT EXISTS `" . $table_prefix . "module_menus` (\n            `module_id` int(11) NOT NULL COMMENT 'This references to modules.id',\n            `subpage` varchar(64) NOT NULL default '',\n            `group` varchar(32) NOT NULL,\n            `menu_name` varchar(128) NOT NULL,\n\t\t\t`pos` INT UNSIGNED NOT NULL,\n            PRIMARY KEY  (`module_id`,`subpage`,`group`)\n        ) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
                if (!$result) {
                    $fail = true;
                }
                // Install modules.
                require_once "modules/modulemanager/module_handling.php";
                @add_lang_module('modulemanager');
                $modules = list_available_modules();
                foreach ($modules as $module) {
                    $fail = $fail || install_module($db, $module, FALSE) < 0;
                }
                if ($fail) {
                    print_failure(get_lang('database_setup_failure'));
                    echo "<p><a href='?step=1'>" . get_lang('back') . "</a></p>";
                    echo "<p>" . get_lang('unable_to_resolve') . " <a href='http://www.opengamepanel.org/'>http://www.opengamepanel.org</a></p>";
                    return;
                }
                print_success(get_lang('config_written'));
                print_success(get_lang('database_created'));
                echo "<form name='setup' method='post' action='?'>\n\n            <input type='hidden' name='step' value='3' />";
                echo "<table class='install'>\n";
                echo "<tr><td colspan='2'><div id=\"install-title\" style=\"margin-left:-21px;\">" . get_lang('admin_login_details') . "</div>";
                echo "<p>" . get_lang('admin_login_details_info') . "</p></td></tr>";
                echo "<tr><td>" . get_lang('username') . ":</td><td><input type='text' name='username' maxlength='30' class='textbox' /></td></tr>";
                echo "<tr><td>" . get_lang('password') . ":</td><td><input type='password' name='password1' maxlength='20' class='textbox' /></td></tr>";
                echo "<tr><td>" . get_lang('repeat_password') . ":</td><td><input type='password' name='password2' maxlength='20' class='textbox' /></td></tr>";
                echo "<tr><td>" . get_lang('email') . ":</td><td><input type='text' name='email' maxlength='100' class='textbox' /></td></tr>";
                echo "</table>\n";
                echo "<p><input type='submit' name='next' value='" . get_lang('next') . "' class='button' /></p></form>\n";
                echo "<p><a href='?step=1'>" . get_lang('back') . "</a></p>";
                echo "</td></tr></table>\n";
            } else {
                if ($step == "3") {
                    echo "<table class='install'><tr><td>\n";
                    require_once "includes/config.inc.php";
                    $db = createDatabaseConnection($db_type, $db_host, $db_user, $db_pass, $db_name, $table_prefix);
                    $error = "";
                    $username = stripinput($_POST['username']);
                    $password1 = stripinput($_POST['password1']);
                    $password2 = stripinput($_POST['password2']);
                    $email = stripinput($_POST['email']);
                    if (!preg_match("/^[-0-9A-Z_@\\s]+\$/i", $username)) {
                        print_failure(get_lang('invalid_username'));
                        echo "<p><a href='?step=2'>" . get_lang('back') . "</a></p>";
                        return;
                    }
                    // TODO: replace with a constant
                    if (strlen($password1) < 6) {
                        print_failure(get_lang_f('password_too_short', 6));
                        echo "<p><a href='?step=2'>" . get_lang('back') . "</a></p>";
                        return;
                    }
                    if (!preg_match("/^[0-9A-Z@]{6,20}\$/i", $password1)) {
                        print_failure(get_lang('password_contains_invalid_characters'));
                        echo "<p><a href='?step=2'>" . get_lang('back') . "</a></p>";
                        return;
                    }
                    if ($password1 != $password2) {
                        print_failure(get_lang('password_mismatch'));
                        echo "<p><a href='?step=2'>" . get_lang('back') . "</a></p>";
                        return;
                    }
                    if (!preg_match("/^[-0-9A-Z_\\.]{1,50}@([-0-9A-Z_\\.]+\\.){1,50}([0-9A-Z]){2,4}\$/i", $email)) {
                        print_failure(get_lang('invalid_email_address'));
                        echo "<p><a href='?step=2'>" . get_lang('back') . "</a></p>";
                        return;
                    }
                    //detect nighly builds, if not its SVN
                    if (file_exists("version.txt")) {
                        $file = "version.txt";
                        $contents = file($file);
                        $nversion = implode($contents);
                        $nversion2 = substr($nversion, 60);
                        $nversion2 = trim($nversion2);
                        $site_settings = array("title" => "Open Game Panel", "slogan" => "" . get_lang('slogan') . "", "ogp_version" => "{$nversion2}", "version_type" => "SVN", "theme" => "Revolution", "welcome_title" => "1", "welcome_title_message" => "<h0>" . get_lang('welcome_title_message') . "</h0>", "page_auto_refresh" => "1");
                        unlink('version.txt');
                    } else {
                        $site_settings = array("title" => "Open Game Panel", "slogan" => "" . get_lang('slogan') . "", "ogp_version" => "0", "version_type" => "SVN", "theme" => "Revolution", "welcome_title" => "1", "welcome_title_message" => "<h0>" . get_lang('welcome_title_message') . "</h0>", "page_auto_refresh" => "1");
                    }
                    $result = $db->setSettings($site_settings);
                    $result = $db->addUser($username, $password1, "admin", $email);
                    print_success(get_lang('setup_complete'));
                    echo "<p class='note'>" . get_lang('remove_install_and_secure_config') . "</p>";
                    echo "<p class='note'><a href='index.php'>" . get_lang('go_to_panel') . "</a></p>";
                    echo "</td></tr></table>\n";
                    echo "</div>\n";
                }
            }
        }
    }
}
Example #15
0
		<div id="page-bgtop">
			<div id="page-bgbtm">
				<div id="content">
                		<h3 class="title">Install New Module:</h3>
<table width="100%" border="0">
	<tr>
		<td><?php 
if (count($_FILES['module']) > 0) {
    $target_path = "../modules/";
    $target_path = $target_path . basename($_FILES['module']['name']);
    if (move_uploaded_file($_FILES['module']['tmp_name'], $target_path)) {
    } else {
        echo "<br/>There was an error uploading the file, please try again!";
    }
    //unzip and copy to module folder
    install_module($target_path);
    /*$zip = zip_open ( "../modules/" . basename ( $_FILES ['module'] ['name'] ) );
    		if ($zip) {
    			while ( $zip_entry = zip_read ( $zip ) ) {
    				
    				var_dump($zip_entry);
    				$fp = fopen ( "../modules/" . zip_entry_name ( $zip_entry ), "w" );
    				if (zip_entry_open ( $zip, $zip_entry, "r" )) {
    					$buf = zip_entry_read ( $zip_entry, zip_entry_filesize ( $zip_entry ) );
    					fwrite ( $fp, "$buf" );
    					zip_entry_close ( $zip_entry );
    					fclose ( $fp );
    				}
    			}
    			zip_close ( $zip );
    		} else {