Example #1
0
		`created` datetime NOT NULL,
		`source` varchar(255) NOT NULL,
		`thumb` varchar(255) NOT NULL,
		`image` varchar(255) NOT NULL,
		`title` text NOT NULL,
		PRIMARY KEY  (`id`)
	) ENGINE=MyISAM CHARSET=utf8', 'CREATE TABLE `' . ASAPH_TABLE_USERS . '` (
		`id` int(11) NOT NULL auto_increment,
		`name` varchar(255) NOT NULL,
		`pass` char(32) NOT NULL,
		`loginId` char(32) NOT NULL,
		PRIMARY KEY  (`id`)
	) ENGINE=MyISAM CHARSET=utf8');
$requirements = array('File Access' => array('Data directory is writeable' => array('message' => 'Make sure PHP has the necessary priviliges (chmod) to write to the <code>data/</code> directory.', 'value' => @is_writeable(ASAPH_PATH . 'data'))), 'Database' => array('Connection established' => array('message' => 'Check your database settings in <code>lib/asaph_config.class.php</code>', 'value' => @mysql_connect(Asaph_Config::$db['host'], Asaph_Config::$db['user'], Asaph_Config::$db['password'])), 'MySQL Version >= 4.0' => array('value' => version_compare(@mysql_get_server_info(), '4.0') != -1), 'Database exists' => array('message' => 'The database Asaph will be installed in must already exist. The installer will not attempt to create it.', 'value' => @mysql_select_db(Asaph_Config::$db['database']))), 'PHP' => array('cURL or URL fopen wrappers enabled' => array('message' => 'Asaph needs <code>cURL</code> or <code>allow_url_fopen</code> to be enabled to copy images from other sites.', 'value' => is_callable('curl_init') || iniEnabled('allow_url_fopen')), 'GD library installed' => array('message' => 'The GD library (PHP extension) is needed to manipulate images.', 'value' => is_callable('gd_info'))));
$suggestedPath = preg_replace('#admin/install.php$#i', '', $_SERVER['SCRIPT_NAME']);
$recommendations = array('Asaph Config' => array('Correct hostname set' => array('message' => 'Make sure your <code>Asaph_Config::$domain</code> setting is correct. Environment variables ' . 'indicate a value of &quot;<code>' . $_SERVER['HTTP_HOST'] . '</code>&quot;. If ' . '<code>Asaph_Config::$domain</code> is not correctly set, you won\'t be able to use the bookmarklet.', 'value' => $_SERVER['HTTP_HOST'] == Asaph_Config::$domain), 'Correct path set' => array('message' => 'Make sure your <code>Asaph_Config::$absolutePath</code> setting is correct. Environment variables ' . 'indicate a value of &quot;<code>' . htmlspecialchars($suggestedPath) . '</code>&quot;. If ' . '<code>Asaph_Config::$absolutePath</code> is not correctly set, you won\'t be able to use the bookmarklet.', 'value' => $suggestedPath == Asaph_Config::$absolutePath)), 'PHP Settings' => array('Safe Mode deactivated' => array('message' => 'It is strongly recommended to disable <code>safe_mode</code>. If safe_mode is on, you\'re very likely to ' . 'encounter problems when posting images. You might want to ask Google about ' . '&quot;<a href="http://www.google.com/search?q=safe_mode+mkdir">safe_mode mkdir</a>&quot; and ' . '&quot;<a href="http://www.google.com/search?q=chmod+setuid">chmod setuid</a>&quot;.', 'value' => !iniEnabled('safe_mode')), 'Magic Quotes deactivated' => array('message' => 'If <code>magic_quotes_gpc</code> is enabled, Asaph will have to do some extra work to revert this ' . 'stupid behaviour. Turn it off!', 'value' => !iniEnabled('magic_quotes_gpc')), 'Register Globals deactivated' => array('message' => 'Though there is no known problem with Asaph and the <code>register_globals</code> option, it is ' . 'generally a good idea to turn it off.', 'value' => !iniEnabled('register_globals')), 'Memory limit >= 4M' => array('message' => 'If your <code>memory_limit</code> setting is too low, you might experience problems when posting ' . 'large images. For instance, PHP needs about 6mb of RAM to create a thumbnail from a 1600x1280 image.', 'value' => humanToBytes(ini_get('memory_limit')) > humanToBytes('4M'))));
$requirementsMet = true;
foreach (array_keys($requirements) as $i) {
    foreach (array_keys($requirements[$i]) as $j) {
        if (empty($requirements[$i][$j]['value'])) {
            $requirementsMet = false;
        }
    }
}
function humanToBytes($s)
{
    $s = trim($s);
    $last = strtolower($s[strlen($s) - 1]);
    switch ($last) {
        case 'g':
            $s *= 1024;
Example #2
0
function uploadMaxSize()
{
    // Not allowed to upload files?
    if (ini_get('file_uploads') != 1) {
        return 0;
    }
    // Upload maximum file size
    $upload = humanToBytes(ini_get('upload_max_filesize'));
    // POST maximum size
    $post = humanToBytes(ini_get('post_max_size'));
    // Return the lowest value
    if ($upload <= $post) {
        return $upload;
    }
    return $post;
}