Skip to content

Commit

Permalink
Fix for PHP 5.2 support.
Browse files Browse the repository at this point in the history
  • Loading branch information
Elias-Black committed Aug 7, 2017
1 parent 0f4a7fc commit 2cee1f5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
29 changes: 20 additions & 9 deletions cms/_classes/db.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
class DB
{

const DB_PASSWORD_PATH = __DIR__ . '/../_db/password.php';
const DB_PRIVATE_PATH = __DIR__ . '/../_db/private.php';
const DB_PUBLIC_PATH = __DIR__ . '/../_db/public.php';

const SECURE_TEXT = '<?php die; ?>';
const SECURE_LENGTH = 13;

Expand All @@ -20,7 +16,7 @@ class DB
public static function getPrivateContent($safe_replace = false)
{

$content = file_get_contents(self::DB_PRIVATE_PATH);
$content = file_get_contents(self::getPrivateDBPath());

$content = unserialize( substr($content, self::SECURE_LENGTH) );

Expand All @@ -45,7 +41,7 @@ public static function updateContent($content)
public static function getPassword()
{

$content = file_get_contents(self::DB_PASSWORD_PATH);
$content = file_get_contents(self::getPasswordDBPath());

return substr($content, self::SECURE_LENGTH);

Expand All @@ -56,20 +52,35 @@ public static function updatePassword($password)

$content = self::SECURE_TEXT . $password;

file_put_contents( self::DB_PASSWORD_PATH, $content );
file_put_contents( self::getPasswordDBPath(), $content );

}



/* PRIVATE API */

private static function getPasswordDBPath()
{
return dirname(__FILE__) . '/../_db/password.php';
}

private static function getPrivateDBPath()
{
return dirname(__FILE__) . '/../_db/private.php';
}

private static function getPublicDBPath()
{
return dirname(__FILE__) . '/../_db/public.php';
}

private static function updatePrivateContent($content)
{

$content = self::SECURE_TEXT . serialize($content);

file_put_contents( self::DB_PRIVATE_PATH, $content );
file_put_contents( self::getPrivateDBPath(), $content );

}

Expand All @@ -78,7 +89,7 @@ private static function updatePublicContent($content)

$result = self::getFieldsOutput($content);

file_put_contents( self::DB_PUBLIC_PATH, serialize($result) );
file_put_contents( self::getPublicDBPath(), serialize($result) );

}

Expand Down
9 changes: 6 additions & 3 deletions cms/_classes/utils.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
class Utils
{

const TEMPLATE_FOLDER = __DIR__ . '/../_templates/';

const SITE_FOLDER = '/';


Expand All @@ -24,7 +22,7 @@ public static function redirect($url)
public static function render($template, $vars)
{

$template = self::TEMPLATE_FOLDER . $template;
$template = self::getTemplateFolder() . $template;

ob_start();
include($template);
Expand Down Expand Up @@ -90,6 +88,11 @@ public static function getLink($relative_link = '')
return self::SITE_FOLDER . $relative_link;
}

private static function getTemplateFolder()
{
return dirname(__FILE__) . '/../_templates/';
}

}

?>

0 comments on commit 2cee1f5

Please sign in to comment.