Last login value, minor update for array to [, smarty include core
When logged in, the last loggedin time is stored in the edit_user table, additional to the normal logging. More array() to [] conversion in config files, etc Javascript: add math.round Basic Class: Fix key length array mapping to more efficiont loop run DB/IO: some name fixes in get key function description/comments SmartyExtended: add CORE CSS/JS file include if exists. Follows after MAIN and BEFORE page and special
This commit is contained in:
@@ -31,6 +31,7 @@ CREATE TABLE edit_user (
|
||||
email VARCHAR,
|
||||
protected SMALLINT NOT NULL DEFAULT 0,
|
||||
admin SMALLINT NOT NULL DEFAULT 0,
|
||||
last_login TIMESTAMP WITHOUT TIME ZONE,
|
||||
login_error_count INT DEFAULT 0,
|
||||
login_error_date_last TIMESTAMP WITHOUT TIME ZONE,
|
||||
login_error_date_first TIMESTAMP WITHOUT TIME ZONE,
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
*********************************************************************/
|
||||
|
||||
// please be VERY carefull only to change the right side
|
||||
$DB_CONFIG = array(
|
||||
'test' => array(
|
||||
$DB_CONFIG = [
|
||||
'test' => [
|
||||
'db_name' => 'gullevek',
|
||||
'db_user' => 'gullevek',
|
||||
'db_pass' => 'gullevek',
|
||||
@@ -19,7 +19,7 @@ $DB_CONFIG = array(
|
||||
'db_type' => 'pgsql',
|
||||
'db_encoding' => '',
|
||||
'db_ssl' => 'disable' // allow, disable, require, prefer
|
||||
)
|
||||
);
|
||||
]
|
||||
];
|
||||
|
||||
// __END__
|
||||
|
||||
@@ -21,9 +21,9 @@
|
||||
// );
|
||||
|
||||
// each host has a different db_host
|
||||
$SITE_CONFIG = array(
|
||||
$SITE_CONFIG = [
|
||||
// development host
|
||||
'soba.tokyo.tequila.jp' => array(
|
||||
'soba.tokyo.tequila.jp' => [
|
||||
// db config selection
|
||||
'db_host' => 'test',
|
||||
// other db connections
|
||||
@@ -37,8 +37,8 @@ $SITE_CONFIG = array(
|
||||
'site_lang' => 'en_utf8',
|
||||
// enable/disable login override
|
||||
'login_enabled' => true
|
||||
),
|
||||
],
|
||||
// 'other.host.com' => $__LOCAL_CONFIG
|
||||
);
|
||||
];
|
||||
|
||||
// __END__
|
||||
|
||||
@@ -185,7 +185,7 @@ if (file_exists(BASE.CONFIGS.'config.host.php')) {
|
||||
require BASE.CONFIGS.'config.host.php';
|
||||
}
|
||||
if (!isset($SITE_CONFIG)) {
|
||||
$SITE_CONFIG = array();
|
||||
$SITE_CONFIG = [];
|
||||
}
|
||||
/************* DB ACCESS *****************/
|
||||
if (file_exists(BASE.CONFIGS.'config.db.php')) {
|
||||
@@ -238,7 +238,7 @@ if ((array_key_exists('HTTPS', $_SERVER) && !empty($_SERVER['HTTPS']) && $_SERVE
|
||||
}
|
||||
// define the db config set name, the db config and the db schema
|
||||
define('DB_CONFIG_NAME', $SITE_CONFIG[HOST_NAME]['db_host']);
|
||||
define('DB_CONFIG', isset($DB_CONFIG[DB_CONFIG_NAME]) ? $DB_CONFIG[DB_CONFIG_NAME] : array());
|
||||
define('DB_CONFIG', isset($DB_CONFIG[DB_CONFIG_NAME]) ? $DB_CONFIG[DB_CONFIG_NAME] : []);
|
||||
// define('DB_CONFIG_TARGET', SITE_CONFIG[$HOST_NAME]['db_host_target']);
|
||||
// define('DB_CONFIG_OTHER', SITE_CONFIG[$HOST_NAME]['db_host_other']);
|
||||
// override for login and global schemas
|
||||
|
||||
@@ -11,11 +11,11 @@
|
||||
|
||||
/************* CONVERT *******************/
|
||||
// this only needed if the external thumbnail create is used
|
||||
$paths = array(
|
||||
$paths = [
|
||||
'/bin',
|
||||
'/usr/bin',
|
||||
'/usr/local/bin'
|
||||
);
|
||||
];
|
||||
// find convert
|
||||
foreach ($paths as $path) {
|
||||
if (file_exists($path.DS.'convert') && is_file($path.DS.'convert')) {
|
||||
|
||||
@@ -10,12 +10,12 @@
|
||||
|
||||
// File and Folder paths
|
||||
// ID is TARGET (first array element)
|
||||
/*$PATHS = array(
|
||||
'test' => array(
|
||||
/*$PATHS = [
|
||||
'test' => [
|
||||
'csv_path' => '',
|
||||
'perl_bin' => '',
|
||||
'other_url' => '',
|
||||
)
|
||||
)*/
|
||||
]
|
||||
]*/
|
||||
|
||||
// __END__
|
||||
|
||||
@@ -22,7 +22,7 @@ if (!defined('DS')) {
|
||||
exit('Base config unloadable');
|
||||
}
|
||||
// find trigger name "admin/" or "frontend/" in the getcwd() folder
|
||||
foreach (array('admin', 'frontend') as $folder) {
|
||||
foreach (['admin', 'frontend'] as $folder) {
|
||||
if (strstr(getcwd(), DS.$folder)) {
|
||||
define('CONTENT_PATH', $folder.DS);
|
||||
break;
|
||||
|
||||
@@ -154,8 +154,8 @@ function __(string)
|
||||
* simple sprintf formater for replace
|
||||
* usage: "{0} is cool, {1} is not".format("Alpha", "Beta");
|
||||
* First, checks if it isn't implemented yet.
|
||||
* @param {String} !String.prototype.format string with elements to be replaced
|
||||
* @return {String} Formated string
|
||||
* @param {String} String.prototype.format string with elements to be replaced
|
||||
* @return {String} Formated string
|
||||
*/
|
||||
if (!String.prototype.format) {
|
||||
String.prototype.format = function()
|
||||
@@ -171,6 +171,18 @@ if (!String.prototype.format) {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* round to digits (float)
|
||||
* @param {Float} Number.prototype.round Float type number to round
|
||||
* @param {Number} prec Precision to round to
|
||||
* @return {Float} Rounded number
|
||||
*/
|
||||
if (Number.prototype.round) {
|
||||
Number.prototype.round = function (prec) {
|
||||
return Math.round(this * Math.pow(10, prec)) / Math.pow(10, prec);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* formats flat number 123456 to 123,456
|
||||
* @param {Number} x number to be formated
|
||||
@@ -630,7 +642,7 @@ function showActionIndicator(loc)
|
||||
|
||||
/**
|
||||
* hide action indicator, if it is visiable
|
||||
* If the global variable GL_OB_S is > 10 then
|
||||
* If the global variable GL_OB_S is > GL_OB_BASE then
|
||||
* the overlayBox is not hidden but the zIndex
|
||||
* is set to this value
|
||||
* @param {String} loc ID string, only used for console log
|
||||
@@ -954,7 +966,7 @@ function phfo(tree)
|
||||
function phfa(list)
|
||||
{
|
||||
var content = [];
|
||||
for (i = 0; i < list.length; i ++) {
|
||||
for (var i = 0; i < list.length; i ++) {
|
||||
content.push(phfo(list[i]));
|
||||
}
|
||||
return content.join('');
|
||||
|
||||
@@ -976,15 +976,11 @@ class Basic
|
||||
$use_key_length = $this->key_length;
|
||||
}
|
||||
|
||||
return join(
|
||||
'',
|
||||
array_map(
|
||||
function () {
|
||||
return $this->key_range[rand(0, $this->one_key_length - 1)];
|
||||
},
|
||||
range(1, $use_key_length)
|
||||
)
|
||||
);
|
||||
$pieces = [];
|
||||
for ($i = 1; $i <= $use_key_length; $i ++) {
|
||||
$pieces[] = $this->key_range[random_int(0, $this->one_key_length - 1)];
|
||||
}
|
||||
return join('', $pieces);
|
||||
}
|
||||
|
||||
// ****** RANDOM KEY GEN ******
|
||||
|
||||
@@ -1201,6 +1201,10 @@ class IO extends \CoreLibs\Basic
|
||||
$this->db_functions->__dbResultType($assoc_only)
|
||||
)
|
||||
);
|
||||
// if returned is NOT an array, abort to false
|
||||
if (!is_array($return)) {
|
||||
$return = false;
|
||||
}
|
||||
}
|
||||
// check if cached call or reset call ...
|
||||
if (!$return && !$reset) {
|
||||
@@ -2076,11 +2080,11 @@ class IO extends \CoreLibs\Basic
|
||||
* old call for getInserReturnExt
|
||||
* @param string|null $key See above
|
||||
* @return array|string|null See above
|
||||
* @deprecated use getInsertReturnExt($key = null) instead
|
||||
* @deprecated use getReturningExt($key = null) instead
|
||||
*/
|
||||
public function getInsertReturn($key = null)
|
||||
{
|
||||
trigger_error('Method '.__METHOD__.' is deprecated, use getInsertReturnExt($key = null)', E_USER_DEPRECATED);
|
||||
trigger_error('Method '.__METHOD__.' is deprecated, use getReturningExt($key = null)', E_USER_DEPRECATED);
|
||||
return $this->getReturningExt($key);
|
||||
}
|
||||
|
||||
|
||||
@@ -67,6 +67,11 @@ class SmartyExtend extends SmartyBC
|
||||
public $JS_TEMPLATE_NAME;
|
||||
public $CSS_TEMPLATE_NAME;
|
||||
public $TEMPLATE_TRANSLATE;
|
||||
// core group
|
||||
public $JS_CORE_TEMPLATE_NAME;
|
||||
public $CSS_CORE_TEMPLATE_NAME;
|
||||
public $JS_CORE_INCLUDE;
|
||||
public $CSS_CORE_INCLUDE;
|
||||
// local names
|
||||
public $JS_SPECIAL_TEMPLATE_NAME = '';
|
||||
public $CSS_SPECIAL_TEMPLATE_NAME = '';
|
||||
@@ -147,6 +152,55 @@ class SmartyExtend extends SmartyBC
|
||||
$this->lang_dir = BASE.INCLUDES.LANG.CONTENT_PATH;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
private function setSmartCoreIncludeCssJs(): void
|
||||
{
|
||||
// core CS
|
||||
$this->CSS_CORE_INCLUDE = '';
|
||||
if (file_exists($this->CSS.$this->CSS_CORE_TEMPLATE_NAME) &&
|
||||
is_file($this->CSS.$this->CSS_CORE_TEMPLATE_NAME)
|
||||
) {
|
||||
$this->CSS_CORE_INCLUDE = $this->CSS.$this->CSS_CORE_TEMPLATE_NAME;
|
||||
}
|
||||
// core JS
|
||||
$this->JS_CORE_INCLUDE = '';
|
||||
if (file_exists($this->JAVASCRIPT.$this->JS_CORE_TEMPLATE_NAME) &&
|
||||
is_file($this->JAVASCRIPT.$this->JS_CORE_TEMPLATE_NAME)
|
||||
) {
|
||||
$this->JS_CORE_INCLUDE = $this->JAVASCRIPT.$this->JS_CORE_TEMPLATE_NAME;
|
||||
}
|
||||
// additional per page Javascript include
|
||||
$this->JS_INCLUDE = '';
|
||||
if (file_exists($this->JAVASCRIPT.$this->JS_TEMPLATE_NAME) &&
|
||||
is_file($this->JAVASCRIPT.$this->JS_TEMPLATE_NAME)
|
||||
) {
|
||||
$this->JS_INCLUDE = $this->JAVASCRIPT.$this->JS_TEMPLATE_NAME;
|
||||
}
|
||||
// per page css file
|
||||
$this->CSS_INCLUDE = '';
|
||||
if (file_exists($this->CSS.$this->CSS_TEMPLATE_NAME) &&
|
||||
is_file($this->CSS.$this->CSS_TEMPLATE_NAME)
|
||||
) {
|
||||
$this->CSS_INCLUDE = $this->CSS.$this->CSS_TEMPLATE_NAME;
|
||||
}
|
||||
// optional CSS file
|
||||
$this->CSS_SPECIAL_INCLUDE = '';
|
||||
if (file_exists($this->CSS.$this->CSS_SPECIAL_TEMPLATE_NAME) &&
|
||||
is_file($this->CSS.$this->CSS_SPECIAL_TEMPLATE_NAME)
|
||||
) {
|
||||
$this->CSS_SPECIAL_INCLUDE = $this->CSS.$this->CSS_SPECIAL_TEMPLATE_NAME;
|
||||
}
|
||||
// optional JS file
|
||||
$this->JS_SPECIAL_INCLUDE = '';
|
||||
if (file_exists($this->JAVASCRIPT.$this->JS_SPECIAL_TEMPLATE_NAME) &&
|
||||
is_file($this->JAVASCRIPT.$this->JS_SPECIAL_TEMPLATE_NAME)
|
||||
) {
|
||||
$this->JS_SPECIAL_INCLUDE = $this->JAVASCRIPT.$this->JS_SPECIAL_TEMPLATE_NAME;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* sets all internal paths and names that need to be passed on to the smarty template
|
||||
@@ -196,34 +250,8 @@ class SmartyExtend extends SmartyBC
|
||||
$this->COMPILE_ID .= '_'.$this->TEMPLATE_NAME;
|
||||
$this->CACHE_ID .= '_'.$this->TEMPLATE_NAME;
|
||||
}
|
||||
// additional per page Javascript include
|
||||
$this->JS_INCLUDE = '';
|
||||
if (file_exists($this->JAVASCRIPT.$this->JS_TEMPLATE_NAME) &&
|
||||
is_file($this->JAVASCRIPT.$this->JS_TEMPLATE_NAME)
|
||||
) {
|
||||
$this->JS_INCLUDE = $this->JAVASCRIPT.$this->JS_TEMPLATE_NAME;
|
||||
}
|
||||
// per page css file
|
||||
$this->CSS_INCLUDE = '';
|
||||
if (file_exists($this->CSS.$this->CSS_TEMPLATE_NAME) &&
|
||||
is_file($this->CSS.$this->CSS_TEMPLATE_NAME)
|
||||
) {
|
||||
$this->CSS_INCLUDE = $this->CSS.$this->CSS_TEMPLATE_NAME;
|
||||
}
|
||||
// optional CSS file
|
||||
$this->CSS_SPECIAL_INCLUDE = '';
|
||||
if (file_exists($this->CSS.$this->CSS_SPECIAL_TEMPLATE_NAME) &&
|
||||
is_file($this->CSS.$this->CSS_SPECIAL_TEMPLATE_NAME)
|
||||
) {
|
||||
$this->CSS_SPECIAL_INCLUDE = $this->CSS.$this->CSS_SPECIAL_TEMPLATE_NAME;
|
||||
}
|
||||
// optional JS file
|
||||
$this->JS_SPECIAL_INCLUDE = '';
|
||||
if (file_exists($this->JAVASCRIPT.$this->JS_SPECIAL_TEMPLATE_NAME) &&
|
||||
is_file($this->JAVASCRIPT.$this->JS_SPECIAL_TEMPLATE_NAME)
|
||||
) {
|
||||
$this->JS_SPECIAL_INCLUDE = $this->JAVASCRIPT.$this->JS_SPECIAL_TEMPLATE_NAME;
|
||||
}
|
||||
// set all the additional CSS/JS parths
|
||||
$this->setSmartCoreIncludeCssJs();
|
||||
// check if template names exist
|
||||
if (!$this->MASTER_TEMPLATE_NAME) {
|
||||
exit('MASTER TEMPLATE is not set');
|
||||
@@ -294,36 +322,12 @@ class SmartyExtend extends SmartyBC
|
||||
// jquery and prototype should not be used together
|
||||
$this->HEADER['USE_JQUERY'] = $this->USE_JQUERY;
|
||||
|
||||
// additional per page Javascript include
|
||||
$this->JS_INCLUDE = '';
|
||||
if (file_exists($this->JAVASCRIPT.$this->JS_TEMPLATE_NAME) &&
|
||||
is_file($this->JAVASCRIPT.$this->JS_TEMPLATE_NAME)
|
||||
) {
|
||||
$this->JS_INCLUDE = $this->JAVASCRIPT.$this->JS_TEMPLATE_NAME;
|
||||
}
|
||||
// per page css file
|
||||
$this->CSS_INCLUDE = '';
|
||||
if (file_exists($this->CSS.$this->CSS_TEMPLATE_NAME) &&
|
||||
is_file($this->CSS.$this->CSS_TEMPLATE_NAME)
|
||||
) {
|
||||
$this->CSS_INCLUDE = $this->CSS.$this->CSS_TEMPLATE_NAME;
|
||||
}
|
||||
// optional CSS file
|
||||
$this->CSS_SPECIAL_INCLUDE = '';
|
||||
if (file_exists($this->CSS.$this->CSS_SPECIAL_TEMPLATE_NAME) &&
|
||||
is_file($this->CSS.$this->CSS_SPECIAL_TEMPLATE_NAME)
|
||||
) {
|
||||
$this->CSS_SPECIAL_INCLUDE = $this->CSS.$this->CSS_SPECIAL_TEMPLATE_NAME;
|
||||
}
|
||||
// optional JS file
|
||||
$this->JS_SPECIAL_INCLUDE = '';
|
||||
if (file_exists($this->JAVASCRIPT.$this->JS_SPECIAL_TEMPLATE_NAME) &&
|
||||
is_file($this->JAVASCRIPT.$this->JS_SPECIAL_TEMPLATE_NAME)
|
||||
) {
|
||||
$this->JS_SPECIAL_INCLUDE = $this->JAVASCRIPT.$this->JS_SPECIAL_TEMPLATE_NAME;
|
||||
}
|
||||
// set all the additional CSS/JS parths
|
||||
$this->setSmartCoreIncludeCssJs();
|
||||
|
||||
// the actual include files for javascript (per page)
|
||||
$this->HEADER['JS_CORE_INCLUDE'] = $this->JS_CORE_INCLUDE;
|
||||
$this->HEADER['CSS_CORE_INCLUDE'] = $this->CSS_CORE_INCLUDE;
|
||||
$this->HEADER['JS_INCLUDE'] = $this->JS_INCLUDE;
|
||||
$this->HEADER['CSS_INCLUDE'] = $this->CSS_INCLUDE;
|
||||
$this->HEADER['CSS_SPECIAL_INCLUDE'] = $this->CSS_SPECIAL_INCLUDE;
|
||||
|
||||
Reference in New Issue
Block a user