public static function performChecks()
 {
     $result = CheckResult::OK;
     foreach (self::$checks as $check) {
         if ($check instanceof Check) {
             $check->performCheck();
             if ($check->result == CheckResult::FAIL) {
                 $result = CheckResult::FAIL;
             } else {
                 if ($check->result == CheckResult::POOR && $result != CheckResult::FAIL) {
                     $result = CheckResult::POOR;
                 }
             }
         }
     }
     foreach (self::$extensions as $check) {
         if ($check instanceof Check) {
             $check->performCheck();
         }
     }
     self::$result = $result;
     return $result;
 }
예제 #2
0
<?php

final class PHPCheck extends Check
{
    public function __construct()
    {
        $this->caption = 'PHP Version';
    }
    public function performCheck()
    {
        if (version_compare(PHP_VERSION, '5.3.2', '<')) {
            $this->message = '<p>Your PHP Version (' . PHP_VERSION . ') is too old. You must update at least to PHP 5.3.2.</p>';
            $this->result = CheckResult::FAIL;
        } elseif (version_compare(PHP_VERSION, '5.4.0', '<')) {
            $this->message = '<p>Your PHP Version (' . PHP_VERSION . ') is old but you can keep it. You should update to PHP 5.4.0 or higher.</p>';
            $this->result = CheckResult::OK;
        } elseif (version_compare(PHP_VERSION, '5.4.0', '>=')) {
            $this->message = '<p>Your running PHP Version: ' . PHP_VERSION . '.</p>';
            $this->result = CheckResult::OK;
        }
    }
}
ConfigurationChecks::addCheck(new PHPCheck());
예제 #3
0
<?php

final class ConfigCheck extends Check
{
    public function __construct()
    {
        $this->caption = 'Configuration file';
    }
    public function performCheck()
    {
        if (!file_exists(SYSTEM_ROOT . '/system/config.php')) {
            $this->message = '<p>Please move</p><code>' . SYSTEM_ROOT . '/system/config.php.sample</code><p>to</p><code>' . SYSTEM_ROOT . '/system/config.php</code><p>and prepare it with your data</p>';
            $this->result = CheckResult::FAIL;
        } else {
            $this->result = CheckResult::OK;
        }
    }
}
ConfigurationChecks::addCheck(new ConfigCheck());
예제 #4
0
                    $this->result = CheckResult::OK;
                } else {
                    if (!@chmod(SYSTEM_ROOT . '/uploads', 0600)) {
                        // Try to make directory writeable
                        $this->message = '<p>Please make the folder</p><code>' . SYSTEM_ROOT . '/uploads</code><p>writable.</p>';
                        $this->result = CheckResult::FAIL;
                    } else {
                        $this->result = CheckResult::OK;
                    }
                }
            } else {
                $this->message = '<p>Please create the folder</p><code>' . SYSTEM_ROOT . '/uploads</code><p>and make it writable.</p>';
                $this->result = CheckResult::FAIL;
            }
        } else {
            // Check permissions
            if (is_writeable($dir)) {
                $this->result = CheckResult::OK;
            } else {
                if (!@chmod(SYSTEM_ROOT . '/uploads', 0600)) {
                    $this->result = '<p>Please make the folder</p><code>' . SYSTEM_ROOT . '/uploads</code><p>writable.</p>';
                    $this->result = CheckResult::FAIL;
                } else {
                    $this->result = CheckResult::OK;
                }
            }
        }
    }
}
ConfigurationChecks::addCheck(new UploadDirCheck());
예제 #5
0
            $this->result = CheckResult::FAIL;
            $this->message = '<p>Please specify a database name</p>';
            return;
        }
        try {
            $db = new Database('mysql:host=' . DATABASE_HOST, DATABASE_USER, DATABASE_PASS);
            // Does the database already exist?
            $sql = $db->prepare('SHOW DATABASES LIKE \'' . DATABASE_NAME . '\'');
            $sql->execute();
            if ($sql->rowCount() == 0) {
                $this->result = CheckResult::FAIL;
                $this->message = '<p>Database ' . DATABASE_NAME . ' is not available</p>';
            } else {
                $this->result = CheckResult::OK;
                $this->message = '<p>Database connection works fine.</p>';
            }
        } catch (PDOException $e) {
            $this->result = CheckResult::FAIL;
            $this->message = '<p>Connection Error to MySQL. Host: ' . DATABASE_HOST . ' User: '******'') {
                // empty() does not seem to work with constants -.-
                $this->message .= ' used Password: NO (Password is empty).';
            } else {
                $this->message .= ' used Password: YES.';
            }
            $this->message .= '</p>';
        }
    }
}
ConfigurationChecks::addCheck(new DatabaseCheck());
예제 #6
0
 public static function createUser(Smarty $smarty)
 {
     if (ConfigurationChecks::getResult() != CheckResult::OK) {
         header('Location: index.php');
         exit;
     }
     try {
         $db = new Database('mysql:dbname=' . DATABASE_NAME . ';host=' . DATABASE_HOST, DATABASE_USER, DATABASE_PASS);
         // Test if all tables where created properly
         $sql = $db->prepare('SHOW TABLES');
         $sql->execute();
         if ($sql->rowCount() == 0) {
             header('Location: index.php?action=tables');
             exit;
         }
         $errorUsername = '';
         $errorPassword = '';
         $username = Utils::getPOST('username', '');
         $password = Utils::getPOST('password', '');
         if (Utils::getPOST('submit', false) != false) {
             if (empty($username)) {
                 $errorUsername = '******';
             } else {
                 if (empty($password)) {
                     $errorPassword = '******';
                 } else {
                     $sql = $db->prepare('INSERT INTO users (username, password, salt, last_login, lang, admin) VALUES (:username, :password, :salt, :lastlogin, :language, :admin)');
                     $salt = Utils::createPasswordSalt();
                     $sql->execute(array(':username' => $username, ':password' => Utils::createPasswordHash($password, $salt), ':salt' => $salt, ':lastlogin' => time(), ':admin' => '1', ':language' => LANGUAGE));
                     unset($salt);
                     header('Location: index.php?action=success');
                     exit;
                 }
             }
         }
         $smarty->assign('heading', 'Create user account');
         $smarty->assign('username', $username);
         $smarty->assign('errorUsername', $errorUsername);
         $smarty->assign('errorPassword', $errorPassword);
         $smarty->assign('curStep', 3);
         $smarty->display('form.tpl');
     } catch (PDOException $e) {
         $smarty->assign('heading', 'Database tables');
         $smarty->assign('error', $e->getMessage());
         $smarty->assign('url', 'index.php?action=user');
         $smarty->assign('curStep', 3);
         $smarty->display('error.tpl');
     }
 }
예제 #7
0
<?php

final class SmartyDirCheck extends Check
{
    public function __construct()
    {
        $this->caption = 'Smarty template_c folder is writable';
    }
    public function performCheck()
    {
        $dir = SYSTEM_ROOT . '/classes/smarty/templates_c/';
        if (!is_writable($dir)) {
            die("<html><body>It's required to make " . $dir . " writeable!<br />On Linux try <code>chmod 777 " . $dir . "</code><br />Don't worry! After this, installation get's much more prettier!</body></html>");
        }
        $this->result = CheckResult::OK;
    }
}
ConfigurationChecks::addCheck(new SmartyDirCheck());
예제 #8
0
<?php

final class RARCheck extends Check
{
    public function __construct()
    {
        $this->caption = 'RAR';
    }
    public function performCheck()
    {
        if (extension_loaded('rar') && class_exists('RarArchive')) {
            $this->result = CheckResult::OK;
        } else {
            $this->result = CheckResult::POOR;
            $this->message = '<p>RarArchive is not installed. Please install RarArchive for the full experience.</p>On Linux run</p><code>pecl -v install rar</code><p>to install RarArchive. You might add</p><code>extension=rar.so</code><p>to your <code class="inline">php.ini</code> file.</p>';
        }
    }
}
ConfigurationChecks::addCheck(new RARCheck(), true);
예제 #9
0
<?php

final class MaxPOSTSize extends Check
{
    const MIN_VALUE = 52428800;
    // 50 MB
    public function __construct()
    {
        $this->caption = 'Max. HTTP POST size';
    }
    public function performCheck()
    {
        $value = Utils::parseInteger(ini_get('post_max_size'));
        if ($value < self::MIN_VALUE && $value != 0) {
            $this->result = CheckResult::POOR;
            $this->message = '<p>An max HTTP post size of ' . ini_get('post_max_size') . ' (' . Utils::formatBytes($value) . ') is too small for a file hoster. It MUST be greater or equal to <code class="inline">upload_max_filesize</code>. Change <code class="inline">post_max_size</code> in your <code>php.ini</code>. ' . Utils::formatBytes(self::MIN_VALUE) . ' or more are recommend.</p>';
        } else {
            if ($value == 0) {
                $this->result = CheckResult::OK;
                $this->message = '<p>You don\'t set a limit</p>';
                $this->message .= '<p>Change <code class="inline">post_max_size</code> in your <cody>php.ini</code> to modify this value.</p>';
            } else {
                $this->result = CheckResult::OK;
                $this->message = '<p>Your current value: ' . ini_get('post_max_size') . ' (' . Utils::formatBytes($value) . ')</p>';
                $this->message .= '<p>Change <code class="inline">post_max_size</code> in your <cody>php.ini</code> to modify this value.</p>';
            }
        }
    }
}
ConfigurationChecks::addCheck(new MaxPOSTSize());
예제 #10
0
<?php

final class ImagickCheck extends Check
{
    public function __construct()
    {
        $this->caption = 'Imagick';
    }
    public function performCheck()
    {
        if (extension_loaded('imagick') && class_exists('Imagick')) {
            $this->result = CheckResult::OK;
        } else {
            $this->result = CheckResult::POOR;
            $this->message = '<p>Imagick is not installed. Please install Imagick for the full experience.</p><p>On Ubuntu run</p><code>sudo apt-get update &#38;&#38; sudo apt-get install imagemagick libmagickwand-dev libmagickcore4 libmagickwand4 php5-imagick</code><p>to install Imagick.</p>';
        }
    }
}
ConfigurationChecks::addCheck(new ImagickCheck(), true);