Fixed bug with missing directory separator and added .htaccess files to lib & cfg directories. If those are not present, the application will create them for you.

pull/17/head
Simon Rupf 12 years ago
parent ba90d0cae2
commit 23487ce779

@ -0,0 +1,2 @@
Allow from none
Deny from all

@ -0,0 +1,2 @@
Allow from none
Deny from all

@ -69,7 +69,17 @@ class traffic_limiter
*/
public static function canPass($ip)
{
if (!is_dir(self::$_path)) mkdir(self::$_path, 0705, true);
// Create storage directory if it does not exist.
if (!is_dir(self::$_path)) mkdir(self::$_path, 0705);
// Create .htaccess file if it does not exist.
if (!is_file(self::$_path . '/.htaccess'))
{
file_put_contents(
self::$_path . '/.htaccess',
'Allow from none' . PHP_EOL .
'Deny from all'. PHP_EOL
);
}
$file = self::$_path . '/traffic_limiter.php';
if (!is_file($file))
{

@ -95,6 +95,15 @@ class zerobin
*/
private function _init()
{
foreach (array('cfg', 'lib') as $dir)
{
if (!is_file(PATH . $dir . '/.htaccess')) file_put_contents(
PATH . $dir . '/.htaccess',
'Allow from none' . PHP_EOL .
'Deny from all'. PHP_EOL
);
}
$this->_conf = parse_ini_file(PATH . 'cfg/conf.ini');
$this->_model = $this->_conf['model'];
}

@ -60,15 +60,16 @@ class zerobin_data
*/
public static function getInstance($options)
{
// if given update the data directory
if (
is_array($options) &&
array_key_exists('dir', $options)
) self::$_dir = $options['dir'] . '/';
// if needed initialize the singleton
if(null === self::$_instance) {
self::$_instance = new self;
self::_init();
}
if (
is_array($options) &&
array_key_exists('dir', $options)
) self::$_dir = $options['dir'];
return self::$_instance;
}
@ -232,12 +233,11 @@ class zerobin_data
*/
private static function _init()
{
if (defined('PATH')) self::$_dir = PATH . self::$_dir;
// Create storage directory if it does not exist.
if (!is_dir(self::$_dir))
if (!is_dir(self::$_dir)) mkdir(self::$_dir, 0705);
// Create .htaccess file if it does not exist.
if (!is_file(self::$_dir . '.htaccess'))
{
mkdir(self::$_dir, 0705);
file_put_contents(
self::$_dir . '.htaccess',
'Allow from none' . PHP_EOL .

Loading…
Cancel
Save