Example #1
0
function finish_installation($password)
{
    require_once LIB_PATH . 'osclass/model/Admin.php';
    require_once LIB_PATH . 'osclass/model/Category.php';
    require_once LIB_PATH . 'osclass/model/Item.php';
    require_once LIB_PATH . 'osclass/helpers/hPlugins.php';
    require_once LIB_PATH . 'osclass/compatibility.php';
    require_once LIB_PATH . 'osclass/plugins.php';
    $data = array();
    $mAdmin = new Admin();
    $mPreference = Preference::newInstance();
    $mPreference->insert(array('s_section' => 'osclass', 's_name' => 'osclass_installed', 's_value' => '1', 'e_type' => 'BOOLEAN'));
    // update categories
    $mCategories = new Category();
    if (Params::getParam('submit') != '') {
        $categories = Params::getParam('categories');
        if (is_array($categories)) {
            foreach ($categories as $category_id) {
                $mCategories->update(array('b_enabled' => '1'), array('pk_i_id' => $category_id));
            }
        }
    }
    $aCategoriesToDelete = $mCategories->listWhere("a.b_enabled = 0");
    foreach ($aCategoriesToDelete as $aCategory) {
        $mCategories->deleteByPrimaryKey($aCategory['pk_i_id']);
    }
    $admin = $mAdmin->findByPrimaryKey(1);
    $data['s_email'] = $admin['s_email'];
    $data['admin_user'] = $admin['s_username'];
    $data['password'] = $password;
    return $data;
}
function finish_installation()
{
    require_once LIB_PATH . 'osclass/helpers/hSecurity.php';
    require_once LIB_PATH . 'osclass/model/Admin.php';
    require_once LIB_PATH . 'osclass/model/Preference.php';
    require_once LIB_PATH . 'osclass/model/Category.php';
    require_once LIB_PATH . 'osclass/model/Item.php';
    require_once LIB_PATH . 'osclass/core/Params.php';
    require_once LIB_PATH . 'osclass/compatibility.php';
    require_once LIB_PATH . 'osclass/utils.php';
    $data = array();
    $password = osc_genRandomPassword();
    $mAdmin = new Admin();
    $admin_user = '******';
    $admin = $mAdmin->update(array('s_password' => sha1($password)), array('s_username' => $admin_user));
    $mPreference = Preference::newInstance();
    $mPreference->insert(array('s_section' => 'osclass', 's_name' => 'osclass_installed', 's_value' => '1', 'e_type' => 'BOOLEAN'));
    // update categories
    $mCategories = new Category();
    if (Params::getParam('submit') != '') {
        $categories = Params::getParam('categories');
        if (is_array($categories)) {
            foreach ($categories as $category_id) {
                $mCategories->update(array('b_enabled' => '1'), array('pk_i_id' => $category_id));
            }
        }
    }
    $aCategoriesToDelete = $mCategories->listWhere("a.b_enabled = 0");
    foreach ($aCategoriesToDelete as $aCategory) {
        $mCategories->deleteByPrimaryKey($aCategory['pk_i_id']);
    }
    $admin = $mAdmin->findByPrimaryKey(1);
    $data['s_email'] = $admin['s_email'];
    $data['admin_user'] = $admin_user;
    $data['password'] = $password;
    $body = 'Welcome ' . $mPreference->get('pageTitle') . ',<br/><br/>';
    $body .= 'Your OSClass installation at ' . WEB_PATH . ' is up and running. You can access to the administration panel with this data access:<br/>';
    $body .= '<ul>';
    $body .= '<li>username: '******'</li>';
    $body .= '<li>password: '******'</li>';
    $body .= '</ul>';
    $body .= 'Regards,<br/>';
    $body .= 'The <a href=\'http://osclass.org/\'>OSClass</a> team';
    $sitename = strtolower($_SERVER['SERVER_NAME']);
    if (substr($sitename, 0, 4) == 'www.') {
        $sitename = substr($sitename, 4);
    }
    require_once LIB_PATH . 'phpmailer/class.phpmailer.php';
    $mail = new PHPMailer();
    $mail->CharSet = "utf-8";
    $mail->Host = "localhost";
    $mail->From = 'osclass@' . $sitename;
    $mail->FromName = 'OSClass';
    $mail->Subject = 'OSClass successfully installed!';
    $mail->AddAddress($admin['s_email'], 'OSClass administrator');
    $mail->Body = $body;
    $mail->AltBody = $body;
    if (!$mail->Send()) {
        echo $mail->ErrorInfo;
    }
    return $data;
}