Warning: Undefined array key "ADMINMAX_DEV" in /home/knjizara/www.manager.hr/app/config/_config.class.php on line 10
Warning: Undefined property: CFG::$web_hidden in /home/knjizara/www.manager.hr/app/config/_config.class.php on line 46
define('ENGINE_NAME', 'AdminMax');
define('ENGINE_VERSION1', 'V');
define('ENGINE_VERSION2', '5.90');
/**********************************************************************
*** Copyright (c) 2005. by Internet Softver d.o.o. Zagreb, Croatia ***
*** Author: Hrvoje Hladnik, hrgan@softver.net ***
*** E-mail: softver@softver.net WWW: http://www.softver.net/ ***
**********************************************************************/
class Core
{
function format_error($msg)
{
return $this->format_message($msg, 1);
}
function format_message($msg, $is_error = 0)
{
global $CFG;
if (!$CFG->app_name)
$CFG->app_name = ENGINE_NAME;
if (!$CFG->app_ver)
$CFG->app_ver = ENGINE_VERSION2;
$color = $is_error ? '#FF0000' : '#0000FF';
$prefix = $is_error ? 'ERROR' : 'NOTICE';
return "\n{$CFG->app_name} {$CFG->app_ver}
\n{$prefix} [".get_class($this)."]: $msg
\n";
}
// SPECH = convert html's numeric SPEcial CHaracters info real chars
function spech($str)
{
return preg_replace('/\&\#([0-9]+)\;/me', "chr('\\1')", strtr ($str, array_flip (get_html_translation_table (HTML_ENTITIES))));
}
function str2html($str)
{
return htmlspecialchars($str, ENT_QUOTES);
}
function remove_html($str)
{
return preg_replace('/(\&[a-zA-Z0-9\#]+;)/s','',strip_tags(trim($str)));
}
// Ovo funkciji se moze zada cijela putanja sa vise nepostojecih foldera koje treba stvoriti
function create_dirs($dir, $perm = 0)
{
global $CFG;
if (file_exists($dir))
return;
if (!$perm)
$perm = $CFG->dir_permission;
$dirs = preg_split('/[\\/\\\\]+/',$dir);
$path = $CFG->os == 1 ? $dirs[0] : '';
unset($dirs[0]);
foreach($dirs AS $d)
{
$path .= '/'.$d;
if (!file_exists($path))
{
if (@mkdir($path, $perm))
{
if ($CFG->os == 2) @chmod($path, $perm);
}
}
}
}
function deleteDir($tmp)
{
if (is_dir($tmp))
{
if ($handle = @opendir($tmp))
{
while($filename = readdir($handle))
{
if ($filename != "." && $filename != "..")
{
$this->deleteDir($tmp.'/'.$filename);
}
}
closedir($handle);
@rmdir($tmp);
}
}
else
{
@unlink($tmp);
}
}
/* (15.01.2005) Method for dynamic loading and instancing "Second Stage Objects" */
function new_class($dir, $class)
{
$class_file = $dir.'/'.strtolower($class).'.class.php';
if (file_exists($class_file))
{
require_once($class_file);
return new $class;
}
else
die($this->format_error("Class '{$class}' ({$class_file}) does not exists!"));
}
/* (17.06.2005) Getter for icon by file extension. This one does not check if extension's icon exists
on file system like another method used in HTML/Forms class does. */
function get_file_icon($file, $dir = '')
{
$file_ext = strtolower(substr(strrchr($file,'.'),1)).'.gif';
if ($dir && !file_exists($dir.'/'.$file_ext))
$file_ext = 'file.gif';
return $file_ext;
}
}
?>
/*
Display pages for templates
USAGE:
$TPL->assign('NAVI', Paginator::getPagesNavigation3($p, 1, Paginator::getNumOfPages("posts where blog_id='{$this->parent->blog_id}'", $APP->set['show_max_posts']), 10, 2));
$TPL->assign('NAVI_URL',$APP->url_current.'&menu='.implode(',',$this->parent->menu).'&go=');
2.2005. - Prepravljeni su kljucevi od $arr: go_fast_prev i go_fast_next
*/
class Paginator
{
function get_sql_limit($page_selected, $max_per_page, $add_counter = 0)
{
return (($page_selected - 1 + $add_counter) * $max_per_page).','.$max_per_page;
}
function get_sql_limit_postgre($page_selected,$max_per_page, $add_counter = 0)
{
return (($page_selected - 1 + $add_counter) * $max_per_page);
}
function getNumOfPages($sql_from, $max_recs_per_page, $add_counter = 0)
{
global $DB;
$stat = $DB->OneQuery("select count(*) AS counter from {$sql_from}");
return ceil(($stat['counter'] + $add_counter) / $max_recs_per_page );
}
function getPagesNavigation3($group_selected, $group_start, $group_end, $max_per_view = 10, $border_gap = 2)
{
if ($group_start < $group_end)
{
$max_per_view--;
$group_start2 = $group_selected + $border_gap - $max_per_view;
$group_start2 = $group_start2 + $max_per_view > $group_end ? $group_end - $max_per_view : $group_start2;
$group_start2 = $group_start2 < $group_start ? $group_start : $group_start2;
$group_end2 = $group_start2 + $max_per_view;
$group_end2 = $group_end2 > $group_end ? $group_end : $group_end2;
// $html .= "\n".($group_selected > $group_start ? "$first" : $first).$div1;
$arr[]['go_first'] = $group_selected > $group_start ? $group_start : 0;
// $html .= "\n".($group_selected > $group_start+$max_per_view-1 ? "$fastprev" : $fastprev).$div1;
$arr[]['go_fast_prev'] = $group_selected > $group_start+$max_per_view ? $group_selected-$max_per_view-1 : 0;
// $html .= "\n".($group_selected > $group_start ? "$prev" : $prev).$div1;
$arr[]['go_prev'] = $group_selected > $group_start ? $group_selected-1 : 0;
$arr[]['go_more_prev'] = $group_start2 > $group_start ? 1 : 0;
// $html .= $group_start2 > $group_start ? '...'.$div1 : '';
for ($i = $group_start2; $i <= $group_end2; $i++)
// $html .= ($i != $group_selected ? "$i" : "$i" ).$div1;
$arr[] = array( 'id' => $i,
'selected' => $i == $group_selected ? 1 : 0,
'is_first' => $i == $group_start2 ? 1 : 0,
'is_last' => $i == $group_end2 ? 1 : 0,
);
$t = $group_end2 - $group_start2 + 2;
$arr[]['go_more_next'] = $group_end2 < $group_end ? 1 : 0;
// $html .= $group_end2 < $group_end ? '...'.$div1 : '';
// $html .= "\n".($group_selected < $group_end ? "$next" : $next).$div1;
$arr[]['go_next'] = $group_selected < $group_end ? $group_selected+1 : 0;
// $html .= "\n".($group_selected < $group_end-$max_per_view+1 ? "$fastnext" : $fastnext).$div1;
$arr[]['go_fast_next'] = $group_selected < $group_end-$max_per_view ? $group_selected+$max_per_view+1 : 0;
// $html .= "\n".($group_selected < $group_end ? "$last" : $last);
$arr[]['go_last'] = $group_selected < $group_end ? $group_end : 0;
return $arr;
}
}
}
?>
// ******************************************************
// *** AdminMax V - DataBase Module ***
// *** Copyright (c) 2005. by Internet Softver d.o.o. ***
// *** www.softver.net info@softver.net ***
// ******************************************************
include_once('adodb_lite/adodb.inc.php');
class DB extends Core
{
var $rows;
var $insert_id;
var $query_num = 0;
// SQL Date/Time Format
var $df = 'Y-m-d';
var $tf = 'H:i:s';
var $dtf = 'Y-m-d H:i:s';
var $sql_df = '%d.%m.%Y.';
var $sql_tf = '%H:%i';
var $dtf_cro = 'd.m.Y. H:i:s';
var $host;
var $user;
var $pass;
var $database;
var $ADODB;
function DB()
{
global $CFG;
$this->ADODB = &ADONewConnection($CFG->database_type ? $CFG->database_type : 'mysql');
$this->ADODB->SetFetchMode(ADODB_FETCH_ASSOC);
// $this->ADODB->debug = true;
// da ne ucitava nepotrebne module u adodb.lite
// $this->now = str_replace('\'', '',$this->ADODB->DBTimeStamp(time()));
// koristi ovo, jer dodje na isto :)
$this->now = date($this->dtf);
$this->_t_level = 0; // za pracenje transakcija
}
function Open($host, $user, $pass)
{
$this->host = $host;
$this->user = $user;
$this->pass = $pass;
}
function Close()
{
$this->ADODB->Close();
//@mysql_close();
}
function Database($base)
{
$this->ADODB->Connect($this->host, $this->user, $this->pass, $base) or $this->SqlError(NULL,'Uh! Could not select database.');
//@mysql_select_db($base) or $this->SqlError(NULL,'Uh! Could not select database.');
}
function Query($query, $HALT_ON_ERROR = true)
{
$pattern = "/^(\bselect\b[ 0-z'._,()<>%=*\-]+)\blimit\b[\s]+([0-9]+)[ ]*,[ ]*([0-9]+)$/i";
$matches = array();
$limit = preg_match($pattern, $query, $matches);
if($limit)
{
$result = $this->ADODB->SelectLimit($matches[1], $matches[3], $matches[2]);
}
else
{
$result = $this->ADODB->Execute($query);
}
$this->rows = $this->ADODB->Affected_Rows();
$this->insert_id = $this->ADODB->Insert_ID();
$this->query_num++;
$error_msg = substr($this->ADODB->ErrorMsg(),0,7) == 'ERROR:' ? substr($this->ADODB->ErrorMsg(),7) : $this->ADODB->ErrorMsg();
return $result ? $result : ( $HALT_ON_ERROR ? $this->SqlError($query, $error_msg) : 0);
}
function Fetch($result)
{
return $result ? $result->GetAll() : 0;
}
function OneQuery($query)
{
return $this->ADODB->GetRow($query);
}
function showOneQuery($query)
{
echo ''.$query.'
';
return $this->OneQuery($query);
}
function MultiQuery($query)
{
$r = $this->Query($query);
//print_r('multiquery: '.$r);
return $r ? $this->Fetch($r) : array();
}
function SqlError($query, $msg)
{
die($this->format_error("$msg
".($query ? ' SQL query: '.$this->str2html($query).'' : '')));
}
// Old compatibility mode (dont remove!)
function updateRecord($data, $tab, $tabid, $delete = NULL)
{
$key[$tabid] = $data[$tabid];
unset($data[$tabid]);
$r = $this->manage_record($tab, $key, $data);
$this->{$tabid} = $key[$tabid] ? $key[$tabid] : $this->new_id;
return $r;
}
// :MAT|2007-11-14: Dodano polje $check_false_values kao 5. argument koje dozvoljava da vrijednost
// pod nekim kljucem budu '0', 0, null ili opcenito false i uzete kao takve u obzir kod delete ili update
var $manage_record_after_post = 1;
function manage_record($table, $key, $data, $delete = 0, $check_false_values = 0)
{
if ($delete || $data)
{
if ($key)
{
foreach($key as $f => $v)
{
if (!$check_false_values)
{
if ($v) $sql_keys[] = "{$f}=".$this->prepare_value($v, $this->manage_record_after_post);
else $new_data = 1;
}
else
if (isset($v)) $sql_keys[] = "{$f}=".$this->prepare_value($v, $this->manage_record_after_post);
else $new_data = 1;
}
}
else
$new_data = 1;
if ($delete)
{
$this->Query("delete from {$table} where ".implode(' AND ',$sql_keys));
return 2;
}
else
{
if($new_data) $sql_data = $this->_prepare_data2($data);
else $sql_data = $this->_prepare_data($data);
if (is_array($sql_data))
{
$sql_cmd = $new_data ? 'insert into' : 'update';
$sql_cmd2 = $new_data ? '' : 'set';
$sql_where = $new_data ? '' : 'where '.implode(' AND ',$sql_keys);
$sql_fields = $new_data ? '('.implode(', ', $sql_data['keys']).') VALUES ('.implode(', ', $sql_data['vals']).')' : implode(', ', $sql_data);
$this->Query("{$sql_cmd} {$table} {$sql_cmd2} {$sql_fields} {$sql_where}");
$this->new_id = $new_data ? $this->insert_id : NULL;
return 1;
}
else
return 0;
}
}
else
return 0;
}
function replace_record($table, $key, $data)
{
if (!$data)
return 0;
$sql_key = $this->_prepare_data($key);
$sql_data = $this->_prepare_data($data);
if (is_array($sql_data))
{
$this->Query("replace {$table} set ".implode(', ', array_merge($sql_data,$sql_key)));
return 1;
}
else
{
$this->Query("delete from {$table} where ".implode(' && ', $sql_key));
return 2;
}
}
function _prepare_data($data)
{
foreach($data AS $k => $d)
// When converting, 1st = remove slashes (only after POST); 2nd = replace HTML chars with real one; 3rd = addslashes;
if ($d !== NULL)
$sql_data[] = $k.'='.$this->prepare_value($d, $this->manage_record_after_post);
return $sql_data;
}
function _prepare_data2($data)
{
foreach($data AS $k => $d)
{
// When converting, 1st = remove slashes (only after POST); 2nd = replace HTML chars with real one; 3rd = addslashes;
if ($d !== NULL)
{
$sql_data['keys'][] = $k;
$sql_data['vals'][] = ''.$this->prepare_value($d, $this->manage_record_after_post);
}
}
return $sql_data;
}
function prepare_value($s, $check_for_slashes = 1)
{
// ovo dolje vra�a strig pripreljem za spremanje u bazu,
// za svaku bazu specificno, sa vec dodanim navodnicima oko stringa
return $this->ADODB->QMagic((strnatcmp(PHP_VERSION, '4.3.0') >= 0) ? html_entity_decode($s, ENT_QUOTES) : strtr(preg_replace('~([0-9]+);~e', 'chr(\\1)', preg_replace('~([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $s)), array_flip(get_html_translation_table(HTML_ENTITIES))));
}
function str($s)
{
// return ini_get('magic_quotes_gpc') ? $s : addslashes($s);
// komentar isti kao i u gornjoj funkciji ($this->prepare_value())
// substr() je potreban zato �to funkcija qstr() dodaje '' (jednostruke navodnike) oko stringa
// a to se 'rucno' dodaje u drugim funkcijama, pa ovdje treba maknuti :)
return substr($this->ADODB->QMagic($s), 1, -1);
}
function updateRelations($one_id, $one, $many_id, $many, $tbl)
{
$this->Query("delete from $tbl where $one_id = '$one'");
if ($many)
{
foreach ($many AS $dio)
{
$this->Query("insert into $tbl set $one_id='$one', $many_id='$dio'");
}
}
}
function startTransaction()
{
return $this->ADODB->StartTrans();
}
function endTransaction($all = false)
{
return $this->ADODB->CompleteTrans();
}
function hasFailedTrans()
{
return $this->ADODB->HasFailedTrans();
}
// kraj class MySQL
}
?>
Fatal error: Uncaught Error: Class "DB" not found in /home/knjizara/www.manager.hr/app/loader.php:18
Stack trace:
#0 /home/knjizara/www.manager.hr/index.php(8): require()
#1 {main}
thrown in /home/knjizara/www.manager.hr/app/loader.php on line 18