Example #1
0
/**
 * check_install
 * This checks folders + permissions, .php files and settings.
 */
function check_install()
{
    global $config, $install_errors;
    // Error friendly messages
    $requirements_error = array('There is a problem regarding server requirements. This means that Chevereto can\'t run because of the following:', 'Please notice that this issue is because your server setup. If you want to run Chevereto please contact your hosting company or system admin regarding this report.');
    $folder_error = array('There is a problem regarding folders. This means that Chevereto can\'t run because one or more folders required doesn\'t exists. The missing folders are:', 'Please double-check your current setup for the missing files.');
    $admin_folder_error = array('There is a problem regarding the admin folder and Chevereto won\'t run because the admin folder doesn\'t exists.', 'Please double-check <code>$config[\'admin_folder\']</code> in the <code>includes/config.php</code> file.');
    $htaccess = 'In some operating systems this files are hidden, therefore you can\'t upload them. You need to <a href="http://www.google.com/search?q=show+hidden+htaccess" target="_blank">show this file</a> and then upload it.';
    $htaccess_error = array('Some <code>.htaccess</code> file(s) doesn\'t exists and the system can\'t create this files.', $htaccess);
    $root_htaccess_error = array('The <code>.htaccess</code> file doesn\'t exists in the Chevereto root directory. This file must be uploaded to run Chevereto.', $htaccess);
    $file_error = array(str_replace('folders', 'files', $folder_error[0]), str_replace('folders', 'files', $folder_error[1]));
    $permission_error = array('There is a problem regarding permissions. This means that Chevereto can\'t upload files because of the following:', 'Chevereto needs a way to write in this folders. You can do this by doing <a href="http://www.google.com/search?q=chmod+777" target="_blank">chmod 0777</a> on the above folders or use <a href="http://www.suphp.org/" target="_blank">suPHP</a> or <a href="http://httpd.apache.org/docs/current/suexec.html" target="_blank">suEXEC</a> on your server setup.');
    $config_error = array('There is a problem regarding your config setup. This means that Chevereto won\'t run because the config is not valid:', 'Please double-check your settings in the <code>includes/config.php</code> file.');
    $definitions_error = array('Please take note that you must edit the <code>definitions.php</code> file the first time that you install Chevereto.', 'Please double-check your definitions in the <code>includes/definitions.php</code> file.');
    $theme_error = array('There is a problem regarding your current theme. This means that Chevereto won\'t run because <code>' . $config['theme'] . '</code> theme has missing files:', 'Please double-check the theme hierarchy.');
    $theme_data_error = array('There is a problem regarding your current theme data. This means that Chevereto won\'t run because <code>' . $config['theme'] . '</code> theme has not valid theme data in <code>style.css</code> header comments:', 'Please double-check the <code>style.css</code> header comments and refer to the <a href="http://chevereto.com/docs#themes">theme documentation</a> page.');
    $virtual_folder_error = array('There is a problem regarding your virtual folders setup:', 'Either you set different values for virtual folders in <code>includes/config.php</code> or you delete this directories.');
    // Check for the server requirements
    if (!check_requirements()) {
        chevereto_die($install_errors, 'System error', $requirements_error);
    }
    // Check for the image folders
    $image_folders = array(__CHV_PATH_IMAGES__);
    if (!check_files_folders($image_folders, 'Directory')) {
        chevereto_die($install_errors, 'Folder error', $folder_error);
    }
    if (!check_permissions($image_folders)) {
        chevereto_die($install_errors, 'Permissions error', $permission_error);
    }
    // Check for virtual folders
    $virtual_folders = array(sanitize_path($config['virtual_folder_image']), sanitize_path($config['virtual_folder_uploaded']));
    foreach ($virtual_folders as $folder) {
        if (file_exists(__CHV_ROOT_DIR__ . $folder)) {
            $install_errors[] = 'The directory <code>' . __CHV_RELATIVE_ROOT__ . $folder . '</code> must not exists';
        }
    }
    if (count($install_errors) > 0) {
        chevereto_die($install_errors, 'Virtual folders error', $virtual_folder_error);
    }
    // Check for upload.php
    if (!file_exists(__CHV_ROOT_DIR__ . 'upload.php')) {
        chevereto_die('Can\'t find <code>upload.php</code>', 'Missing upload.php', $file_error);
    }
    // Check for the root .htaccess file
    if (!file_exists(__CHV_ROOT_DIR__ . '.htaccess')) {
        chevereto_die('', '.htaccess error', $root_htaccess_error);
    }
    // Admin folder
    if (!check_value($config["admin_folder"])) {
        $config["admin_folder"] = "admin";
    }
    if (!file_exists(__CHV_PATH_ADMIN__)) {
        chevereto_die('', 'Admin folder doesn\'t exists', $admin_folder_error);
    }
    // Check for the other .htaccess files
    $htaccess_files = array(__CHV_PATH_IMAGES__, __CHV_PATH_INCLUDES__, __CHV_PATH_ADMIN_INCLUDES__);
    foreach ($htaccess_files as $dir) {
        if (!file_exists($dir . '.htaccess')) {
            switch ($dir) {
                case __CHV_PATH_IMAGES__:
                    $rules = 'static';
                    break;
                case __CHV_PATH_INCLUDES__:
                case __CHV_PATH_ADMIN_INCLUDES__:
                    $rules = 'deny';
                    break;
            }
            if (!htaccess($rules, $dir)) {
                $install_errors[] = 'Can\'t create <code>' . $dir . '.htaccess</code> file. Please upload the <code>.htaccess</code> file to the target dir';
            }
        }
    }
    if (count($install_errors) > 0) {
        chevereto_die($install_errors, '.htaccess error', $htaccess_error);
    }
    // Files check
    $include_files = array('chevereto.php', 'uploader.php', 'shorturl.php', 'definitions.php', 'template.functions.php');
    $classes_files = array('class.handler.php', 'class.db.php', 'class.upload.php', 'class.filelist.php', 'class.imageresize.php', 'class.imageconvert.php', 'class.minify.php', 'class.shorturl.php');
    $system_files = array('login.php', 'error.php', 'style.css', 'img/chevereto.png', 'img/logo.png', 'img/ico-warn.png', 'img/background.png', 'img/bkg-content.png');
    $system_files_minify = array('style.css');
    $system_files = array_merge_minified($system_files, $system_files_minify);
    $system_js_files = array('uploadify.swf', 'ZeroClipboard.swf', 'pref.php');
    $system_js_files_minify = array('jquery.js', 'chevereto.js', 'functions.js', 'jquery.uploadify-3.1_chevereto.js');
    $system_js_files = array_merge_minified($system_js_files, $system_js_files_minify);
    // Admin files
    $admin_classes_files = array('class.adminhandler.php', 'class.manage.php');
    $admin_system_files = array('header.php', 'filemanager.php');
    $admin_system_files_minify = array('style.css', 'js/admin.js');
    $admin_system_files = array_merge_minified($admin_system_files, $admin_system_files_minify);
    foreach ($include_files as $key => $value) {
        $include_files[$key] = __CHV_PATH_INCLUDES__ . $value;
    }
    foreach ($classes_files as $key => $value) {
        $classes_files[$key] = __CHV_PATH_CLASSES__ . $value;
    }
    foreach ($system_files as $key => $value) {
        $system_files[$key] = __CHV_PATH_SYSTEM__ . $value;
    }
    foreach ($system_js_files as $key => $value) {
        $system_js_files[$key] = __CHV_PATH_SYSTEM_JS__ . $value;
    }
    foreach ($admin_classes_files as $key => $value) {
        $admin_classes_files[$key] = __CHV_PATH_ADMIN_CLASSES__ . $value;
    }
    foreach ($admin_system_files as $key => $value) {
        $admin_system_files[$key] = __CHV_PATH_ADMIN_SYSTEM__ . $value;
    }
    /*** The complete file check array ***/
    $check_files = array('Includes' => $include_files, 'Classes' => $classes_files, 'System Files' => array_merge($system_files, $system_js_files), 'Admin .htaccess' => array(__CHV_PATH_ADMIN_INCLUDES__ . '.htaccess'), 'Admin Classes' => $admin_classes_files, 'Admin System' => $admin_system_files);
    foreach ($check_files as $key => $value) {
        check_files_folders($value, 'File');
    }
    if (count($install_errors) > 0) {
        chevereto_die($install_errors, 'Setup error', $file_error);
    }
    if (!check_config()) {
        chevereto_die($install_errors, 'Config error', $config_error);
    }
    if (!check_definitions()) {
        chevereto_die($install_errors, 'Please change definitions.php', $definitions_error);
    }
    if (!check_theme()) {
        chevereto_die($install_errors, 'Theme error', $theme_error);
    }
    if (!check_theme_data()) {
        chevereto_die($install_errors, 'Theme data error', $theme_data_error);
    }
}
Example #2
0
} else {
    $mysqlrun = 0;
}
if ($xamppaccess) {
    if (preg_match('/^[a-zA-Z0-9@*#]{3,15}$/', $xamppuser)) {
        $xamppereg = "ok";
    } else {
        $xamppereg = "notok";
    }
    if (preg_match('/^[a-zA-Z0-9@*#]{3,15}$/', $xampppasswd)) {
        $xampperegpass = "******";
    } else {
        $xampperegpass = "******";
    }
    if ($xamppereg == "ok" && $xampperegpass == "ok") {
        htaccess($xamppuser, $xampppasswd);
    }
}
if ($changing) {
    if (preg_match('/^[a-zA-Z0-9@*#]{3,15}$/', $mypasswd)) {
        $mysqlpasswdereg = "ok";
    } else {
        $mysqlpasswdereg = "notok";
    }
    if (preg_match('/^[a-zA-Z0-9@*#]{3,15}$/', $mypasswdrepeat)) {
        $remysqlpasswdereg = "ok";
    } else {
        $remysqlpasswdereg = "notok";
    }
    if ($mysqlpasswdereg == "ok" && $remysqlpasswdereg == "ok") {
    }
Example #3
0
 public function __construct()
 {
     $message = $this->testTheEnvironment();
     if (is__writable("./") && !file_exists(".htaccess")) {
         file_put_contents(".htaccess", htaccess());
     }
     $this->generateSiteUrl();
     if (!empty($message)) {
         printHeader();
         echo $message;
         echo "</body>";
         echo "</html>";
     } elseif ($this->runForm()) {
         unlink(__FILE__);
         header("Location:" . $this->siteUrl . "add/post");
         exit;
     } else {
         $updater = new Updater();
         $version = $updater->getInfos();
         printHeader($version);
         printForm();
         echo "</body>";
         echo "</html>";
     }
 }
Example #4
0
<?php

include_once 'common.php';
#log
error_log(getDatetime() . " action->" . phpSelfname() . "\n", "3", getPath() . "console.log");
#check session
$user = !empty($_SESSION['user']) ? $_SESSION['user'] : header("Location:" . htaccess('admin/core/login.php?t=timeout'));
#main
include_once getTPL();
Example #5
0
 manage the PHP settings that apply to the
<?php 
echo APP_NAME;
?>
 application (it won't affect your other applications) by
configuring your web server to use the .htaccess files that come with
<?php 
echo APP_NAME;
?>
.  This will ensure that the settings for <?php 
echo APP_NAME;
?>
(detailed below) are set up for optimal, reliable performance.</p>

<?php 
echo htaccess();
?>

<?php 
$kturl = KTUtil::kt_url();
?>

<h2>General KnowledgeTree</h2>

<table>
<tbody>
<tr>
<th width=400>KnowledgeTree Server Directory</td>
<td><?php 
echo KT_DIR;
?>
Example #6
0
/**
 * 更新伪静态规则
 */
function m__update_url()
{
    htaccess();
    iis_httpd_ini();
    nginx();
    die('{"code":"0","msg":"更新伪静态规则成功"}');
}
Example #7
0
function m__edit()
{
    global $url_re_obj, $logs_obj;
    check_level("A0301");
    $post = $_POST;
    //解码数据
    foreach ($post as $key => $val) {
        $post[$key] = urldecode($val);
    }
    if (!is_numeric($post['url_id'])) {
        die('{"code":"210","msg":"规则节点ID必须是数字"}');
    }
    if (empty($post['url_title'])) {
        die('{"code":"220","msg":"规则节点名称不能为空"}');
    }
    if (!preg_match('~^[A-Za-z][A-Za-z]*[a-z0-9_]*$~', $post['url_title'])) {
        die('{"code":"230","msg":"规则节点名称必须以字母开头,只允许字母、下划线"}');
    }
    if (empty($post['url_true'])) {
        die('{"code":"230","msg":"动态地址规则不能为空"}');
    }
    if (empty($post['url_rule'])) {
        die('{"code":"230","msg":"伪静态地址规则不能为空"}');
    }
    if ($post['url_id'] > 0) {
        // 编辑
        $res = $url_re_obj->update($post, $post['url_id']);
        //更新缓存
        //$c -> update_url_config();
        //$c -> update_cate();
        //生成伪静态文件(.htaccess)
        //htaccess();
        //iis_httpd_ini();
        $logs_obj->insert("更新伪静态成功");
        if ($res) {
            die('{"code":"0","msg":"更新规则成功"}');
        }
        die('{"code":"240","msg":"更新规则失败"}');
    } else {
        // 添加
        //判断节点是否存在
        /*$rs=$dbm->query("select * from ".TB_PREFIX . "url_rewrite where url_title='{$_POST['url_title']}'");
          if(count($rs['list'])>0) die('{"code":"100","msg":"'.$_POST['url_title'].'节点名称不能重复"}');
          unset($_POST['url_id']);
          $res = $dbm -> single_insert(TB_PREFIX . "url_rewrite", $_POST);*/
        //更新缓存
        $c->update_url_config();
        $c->update_cate();
        //生成伪静态文件(.htaccess)
        htaccess();
        iis_httpd_ini();
        if (empty($res['error']) && $res['autoid'] > 0) {
            die('{"code":"0","msg":"添加规则成功"}');
        }
        die('{"code":"250","msg":"添加规则失败,请核对重试"}');
    }
}
Example #8
0
    }
    if (!$maintenance) {
        $doctitle = 'Can\'t set the maintenance mode';
        $content = '<h1>The update Script can set the maintenance mode</h1>
		<p>Please try again in a few moments. This is caused for this SQL error: <code>' . $dB->error . '</code>';
    }
} else {
    $imageCount = imageCount();
    if (isset($_GET['completed'])) {
        if ($imageCount == 0) {
            $doctitle = 'Update completed';
            $content = '<h1>Your website is now running Chevereto 2.5!</h1>
				<p>You have successfully update your old image files to the new 2.5 version. Now you can manage this files on the <a href="' . __CHV_BASE_URL__ . 'admin">File Manager</a>.</p>';
            $htaccess_rules = "RewriteRule ^" . __CHV_FOLDER_IMAGES__ . "/([a-zA-Z0-9_-]+\\.)(jpg|png|gif)\$ " . __CHV_FOLDER_IMAGES__ . "/old/\$1\$2 [L] #legacy images" . "\n" . "RewriteRule ^" . __CHV_FOLDER_IMAGES__ . "/thumbs/([a-zA-Z0-9_-]+\\.)(jpg|png|gif)\$ " . __CHV_FOLDER_IMAGES__ . "/old/\$1th.\$2 [L] #legacy thumbs";
            $htaccess_before = "RewriteRule ^api\$ api.php [L]";
            $htaccess = htaccess($htaccess_rules, __CHV_ROOT_DIR__, $htaccess_before);
            if ($htaccess) {
                $htaccess_code = file_get_contents(__CHV_ROOT_DIR__ . '.htaccess');
                $content .= '<h1>.htaccess rules updated</h1>
					<p>Your root <code>.htaccess</code> file has been updated. The new rules are listed below:</p>
					<p><code style="display: block;">' . nl2br($htaccess_code) . '</code></p>
					<p style="color: red;">Please do not remove the new rules as these enable the old image links to work.</p>';
            } else {
                $htaccess_fgc = file_get_contents(__CHV_ROOT_DIR__ . '.htaccess');
                $htaccess_code = str_replace($htaccess_before, $htaccess_rules . "\n" . $htaccess_before, $htaccess_fgc);
                $content .= '<h1>You need to edit the .htaccess root file</h1>
					<p>To preserve your old URLs, please replace your whole root <code>.htaccess</code> file with this:<p>
					<p><code style="display: block;">' . nl2br($htaccess_code) . '</code></p>';
            }
            $maintenance = $dB->query("UPDATE chv_options SET option_value=? WHERE option_key='maintenance'", 0);
            if (!$maintenance) {