db = mysql_connect($host,$user,$pass,TRUE); mysql_select_db(empty($db)?$user:$db,$this->db); if (!empty($charset)) $this->query("SET NAMES '".$charset."'"); return $this->db; } function setLog($l=1){ $this->log=$l; } function setShow($s=1){ $this->show=$s; } function setBacktrace($b=1){ $this->backtrace=$b; } function startDebug(){//$s $this->debug=true;//$s; //print 'tralala'; // $this->start=explode(' ',microtime()); } function closeDebug(){ // print_r($this->logs); // $debug_id=$this->debug; $this->debug=false;//0; /* for ($i=0;$ilogs);$i++): $this->logs[$i]=pole2db($this->logs[$i]); $this->query('INSERT INTO log_06 VALUES (0,'.$debug_id.','.$this->logs[$i][2].','.$this->logs[$i][0].','.$this->logs[$i][1].')'); endfor;*/ } function logError($dotaz){ if ($this->show): print 'Script: '.$_SERVER['REQUEST_URI'].'
Query: '.$dotaz.'
Error number: '.mysql_errno($this->db).'
Error description: '.mysql_error($this->db).'
'; if ($this->backtrace): $raw=debug_backtrace(); $backtrace=array(); $output=""; $i=0; foreach($raw as $entry){ $output.="
File: ".$entry['file']." (Line: ".$entry['line'].")
"; $backtrace['file']=$entry['file']; $backtrace['line']=$entry['line']; $output.="Function: ".$entry['function']."
"; $backtrace['function']=$entry['function']; $output.="Args: ".implode(", ", $entry['args'])."
"; $backtrace['args']=$entry['args']; $final_backtrace[$i]=serialize($backtrace); $i++; } $final_backtrace=serialize($final_backtrace); print $output; // print_r($raw); endif; endif; if ($this->log) mysql_query("INSERT INTO log_02 VALUES(0,'".addslashes($_SERVER['REQUEST_URI'])."','".addslashes($dotaz)."','".mysql_errno($this->db)."','".addslashes(mysql_error($this->db))."','".$final_backtrace."',now())",$this->db); } function &query($dotaz){ if (empty($this->debug)): $res=mysql_query($dotaz,$this->db); else: global $debug; $start=microtime(true)*1000; $res=mysql_query($dotaz,$this->db); $end=microtime(true)*1000; // $start_time=(($start[0]-$this->start[0])*1000)+(($start[1]-$this->start[1])*1000); // $duration=(($end[0]-$start[0])*1000)+(($end[1]-$start[1])*1000); // $this->logs[]=array($start_time,$duration,$dotaz); $debug->debugSql($dotaz,$start,$end-$start); /* print 'Start: '.$start[0].' '.$start[1].' End: '.$end[0].' '.$end[1].' Query time: '.($end[1]-$start[1]).'sec, '; printf("%f",($end[0]-$start[0])*1000); print 'msec
';*/ // $this->query_cnt++; // $this->query_time+=$duration; endif; if (!$res) $this->logError($dotaz); return $res; } /* function &getTable($dotaz,$typ=0){ $tabulka=array(); $result=$this->query($dotaz); if ($typ==1): //asociativne pole while ($zaznam=mysql_fetch_assoc($result)) $tabulka[]=$zaznam; elseif ($typ==2): while ($zaznam=mysql_fetch_row($result)) $tabulka[]=$zaznam; else: while ($zaznam=mysql_fetch_array($result)) $tabulka[]=$zaznam; endif; return $tabulka; } */ function &getTable($dotaz,$assoc=true){ $tabulka=array(); $result=$this->query($dotaz); if ($assoc): //asociativne pole while ($zaznam=mysql_fetch_assoc($result)) $tabulka[]=$zaznam; else: while ($zaznam=mysql_fetch_row($result)) $tabulka[]=$zaznam; endif; return $tabulka; } /* function &getRow($dotaz,$typ=0){ $result=$this->query($dotaz); if ($typ==1) $zaznam=mysql_fetch_assoc($result); elseif ($typ==2) $zaznam=mysql_fetch_row($result); else $zaznam=mysql_fetch_array($result); return $zaznam; }*/ public function &getRow($dotaz,$assoc=true){ $result=$this->query($dotaz); $row=$assoc?mysql_fetch_assoc($result):mysql_fetch_row($result); return $row; } public function &getArray($dotaz,$ofset=0,$mode=0){ $tabulka=array(); $result=$this->query($dotaz); while ($zaznam=mysql_fetch_array($result)): if ($mode==1) $tabulka[$zaznam[$ofset]]=$zaznam[1]; elseif ($mode==2) $tabulka[]=$zaznam[0]; else $tabulka[$zaznam[$ofset]]=$zaznam; endwhile; return $tabulka; } function &getList($dotaz,$prazdny=''){ $res=''; $result=$this->query($dotaz); for ($i=0;$i0?', ':'')."'".addslashes(mysql_result($result,$i,0))."'"; $res=mysql_num_rows($result)?'('.$res.')':$prazdny; return $res; } function &getValue($dotaz){ $result=$this->query($dotaz.' LIMIT 1'); $res=mysql_num_rows($result)?mysql_result($result,0,0):''; return $res; } function getID(){ return mysql_insert_id($this->db); } function getInsertID(){ return mysql_insert_id($this->db); } function &setRow($tabulka,$zoznam,$pk){ $update=0; $polia=$this->getArray('SHOW fields FROM `'.$tabulka.'`',0,2); $sel='UPDATE `'.$tabulka.'` SET '; $c=''; for ($i=0;$i$pk): if (isset($zoznam[$polia[$i]]) and $polia[$i]<>$pk): $sel.=$c.'`'.$polia[$i].'`='.$zoznam[$polia[$i]]; $c=', '; $update=1; endif; endfor; $sel.=' WHERE `'.$pk.'`='.$zoznam[$pk]; // print 'Select: '.$sel; // $ok=1; $result=$update?$this->query($sel):1; return $result; } function &addRow($tabulka,$zoznam,$pk,$replace=false){ $polia=$this->getArray('SHOW fields FROM `'.$tabulka.'`',0,2); $sel=($replace?'REPLACE':'INSERT').' INTO `'.$tabulka.'` VALUES('; for ($i=0;$iquery($sel); return $res; } function moveUp($table,$value,$sk,$filter='',$pk='ID'){ $filter=empty($filter)?'':' AND ('.$filter.')'; $pod=$this->getRow("SELECT `$pk`, `$sk` FROM `$table` WHERE `$pk`='".$value."'".$filter,2); // print 'Pod sel:'."SELECT `$pk`, `$sk` FROM `$table` WHERE `$pk`='".$value."'".$filter.'
'; $nad=$this->getRow("SELECT `$pk`, `$sk` FROM `$table` WHERE `$sk`<'".$pod[1]."'".$filter." ORDER BY `$sk` DESC LIMIT 1"); // print 'Nad sel:'."SELECT `$pk`, `$sk` FROM `$table` WHERE `$sk`<'".$pod[1]."'".$filter." ORDER BY `$sk` DESC LIMIT 1".'
'; // print 'Nad ID: '.$nad[0].' Poradie: '.$nad[1].'
'; // print 'Pod ID: '.$pod[0].' Poradie: '.$pod[1].'
'; if ($nad[0] and $pod[0]): $this->query("UPDATE `$table` SET `$sk`='".$pod[1]."' WHERE `".$pk."`='".$nad[0]."'".$filter); $this->query("UPDATE `$table` SET `$sk`='".$nad[1]."' WHERE `".$pk."`='".$pod[0]."'".$filter); endif; // print 'Selecty:
'; // print "UPDATE $table SET $sk='".$pod[1]."' WHERE ".$pk."='".$nad[0]."'".$filter.'
'; // print "UPDATE $table SET $sk='".$nad[1]."' WHERE ".$pk."='".$pod[0]."'".$filter.'
'; } function moveDown($table,$value,$sk,$filter='',$pk='ID'){ $filter=empty($filter)?'':' AND ('.$filter.')'; $nad=$this->getRow("SELECT `$pk`, `$sk` FROM `$table` WHERE `$pk`='".$value."'".$filter); $pod=$this->getRow("SELECT `$pk`, `$sk` FROM `$table` WHERE `$sk`>'".$nad[1]."'".$filter." ORDER BY `$sk` LIMIT 1"); if ($nad[0] and $pod[0]): $this->query("UPDATE `$table` SET `$sk`='".$pod[1]."' WHERE `$pk`='".$nad[0]."'".$filter); $this->query("UPDATE `$table` SET `$sk`='".$nad[1]."' WHERE `$pk`='".$pod[0]."'".$filter); endif; } function ads($data,$q=false){ $qs=$q?"'":''; if (is_array($data)): foreach ($data as &$val) $val=$this->ads($val,$q); // $val=$qs.mysql_real_escape_string($val,$this->db).$qs; else: $data=$qs.mysql_real_escape_string($data,$this->db).$qs; endif; return $data; } } //mapovanie povodnych funkcii function getTable($dotaz,$assoc=true){ global $db; if($assoc==2): $assoc='false'; //print 'Depricated usage: '.$dotaz; endif; return $db->getTable($dotaz,$assoc); } function getRow($dotaz,$assoc=true){ global $db; if($assoc==2): $assoc='false'; //print 'Depricated usage: '.$dotaz; endif; return $db->getRow($dotaz,$assoc); } function getArray($dotaz,$ofset=0,$mode=0){ global $db; return $db->getArray($dotaz,$ofset,$mode); } function getList($dotaz,$prazdny=''){ global $db; return $db->getList($dotaz,$prazdny); } function getValue($dotaz){ global $db; return $db->getValue($dotaz); } function getInsertID(){ global $db; return $db->getID(); } function setRow($tabulka,$zoznam,$pk){ global $db; return $db->setRow($tabulka,$zoznam,$pk); } function addRow($tabulka,$zoznam,$pk,$replace=false){ global $db; return $db->addRow($tabulka,$zoznam,$pk,$replace); } function uni_query($dotaz){ global $db; return $db->query($dotaz); } function db_moveUp($table,$value,$sk,$filter='',$pk='ID'){ global $db; $db->moveUp($table,$value,$sk,$filter,$pk); } function db_moveDown($table,$value,$sk,$filter='',$pk='ID'){ global $db; $db->moveDown($table,$value,$sk,$filter,$pk); } function ads($data,$q=false){ global $db; return $db->ads($data,$q); } function adsq($data){ global $db; return $db->ads($data,true); } /*doplnujuce funkcie-------------------------------------------------------------------------------*/ function searchSel($text,$stlpce){ $text=urldecode($text); $text="%".uprav(urldecode($text))."%"; $searchsel=(count($stlpce)>1)?'(':''; for ($i=0;$i0)?' OR ':'')."(".$stlpce[$i]." LIKE '$text')"; endfor; $searchsel.=(count($stlpce)>1)?')':''; return $searchsel; } function pageLimit($stranka,$pocet){ if (!$stranka) $stranka=0; return " LIMIT ".($stranka*$pocet).', '.$pocet; } function getOrder($stlpce,$default,$vyb,$okrem){ $order=" ORDER BY "; if (isset($stlpce[floor(($vyb-1)/2)][2]) and $stlpce[floor(($vyb-1)/2)][2]): if (floor(($vyb-1)/2)==(($vyb-1)/2)) $order.=$stlpce[floor(($vyb-1)/2)][2]; else $order.=$stlpce[floor(($vyb-1)/2)][2]." DESC"; if ($okrem){ $order.= ", ".$okrem;}; else: if ($default) $order.=$default; else $order=''; endif; return $order; } ?>mode=$mode; if (php_sapi_name()=='cli'): $this->sid=rand(1,10000); else: session_start(); $this->sid=session_id(); //zistenie uzivatela zo session if (($mode<>1) or (!empty($_SESSION['mode']) and ($_SESSION['mode']==$mode))): $this->uid=empty($_SESSION['uid'])?0:$_SESSION['uid']; $this->wuid=empty($_SESSION['wuid'])?0:$_SESSION['wuid']; $this->grps=empty($_SESSION['grps'])?0:$_SESSION['grps']; $this->eid=empty($_SESSION['eid'])?0:$_SESSION['eid']; $this->user=empty($_SESSION['uid'])?array():getRow('SELECT * FROM usr WHERE ID='.$this->uid); else: $this->uid=0; $this->wuid=0; $this->grps="('')"; $this->eid=0; $this->user=array(); endif; $this->identity=new Identity($this->eid); endif; } /*------------------------USER MANAGEMENT-----------------------------------------------*/ public function setDefUser($uid,$wuid=0){ // print 'setDefUser'.$uid; /* $user=getRow('SELECT * FROM usr WHERE ID='.$uid); if ($user['role']==1): if (!$this->uid): $this->uid=$uid; $this->grps=getList('SELECT grp FROM usr_01 WHERE usr='.$this->uid,"('')"); $this->user=$user; endif; $this->wuid=(empty($this->wuid) and !empty($wuid))?$wuid:$this->wuid; endif; */ if ($this->uid==0): $this->setUser($uid,$wuid); endif; } public function setUser($uid=0,$wuid=0){ // print 'setUser'.$uid; if (!empty($uid)): $this->uid=$uid; $this->grps=getList('SELECT grp FROM usr_01 WHERE usr='.$this->uid,"('')"); $this->user=getRow('SELECT * FROM usr WHERE ID='.$this->uid); $_SESSION['uid']=$this->uid; $_SESSION['grps']=$this->grps; $_SESSION['mode']=$this->mode; endif; if (!empty($wuid)): $this->wuid=$wuid; $_SESSION['wuid']=$this->wuid; endif; //entity $this->eid=getValue('SELECT ID FROM entity WHERE '.($this->wuid?('type=3 AND fid='.$this->wuid):('type=2 AND fid='.$this->uid))); $_SESSION['eid']=$this->eid?$this->eid:0; $this->identity=new Identity($this->eid); $_SESSION['identity']=$this->identity; } public function resetUser(){ $this->uid=0; $this->wuid=0; $this->eid=0; $this->identity=new Identity(0); $_SESSION['uid']=0; $_SESSION['wuid']=0; $_SESSION['grps']=''; $_SESSION['eid']=0; } /*------------------------Helping functions-----------------------------------------------*/ function testModule($module,$usr=0){ // print 'SELECT module.ID FROM module LEFT JOIN usr_02 ON module.prava=usr_02.module WHERE module.kod='.adsq($module).' AND ((module.prava=\'\') OR usr_02.usr='.(empty($usr)?$this->uid:$usr).')'; // exit; return getValue('SELECT module.ID FROM module LEFT JOIN usr_02 ON module.prava=usr_02.module WHERE module.kod='.adsq($module).' AND ((module.prava=\'\') OR usr_02.usr='.(empty($usr)?$this->uid:$usr).')')?true:false; } /*------------------------SESSION VARIABLES-----------------------------------------------*/ public function setVar($name,$val){ $_SESSION['sm_'.$name]=$val; } public function setVars($zoznam){ foreach ($zoznam as $key => $value): $this->setVar($key,$value); endforeach; } public function getVar($name){ return isset($_SESSION['sm_'.$name])?$_SESSION['sm_'.$name]:''; } public function getVars($prefix=''){ $res=array(); foreach ($_SESSION as $key => $value): if (substr($key,0,3+strlen($prefix))=='sm_'.$prefix) $res[substr($key,3+strlen($prefix),strlen($key)-3-strlen($prefix))]=$value; endforeach; return $res; } public function clearVar($name){ unset($_SESSION['sm_'.$name]); } public function clearVars($prefix=''){ foreach ($_SESSION as $key => $value): if (substr($key,0,3+strlen($prefix))=='sm_'.$prefix) unset($_SESSION[$key]); endforeach; } public function emp($name){ return empty($_SESSION['sm_'.$name]); } public function notEmp($name){ return !empty($_SESSION['sm_'.$name]); } } ?>entity=$info; $this->parents=getArray('SELECT entity.ID, entity.type, entity.fid FROM entity, entity_01 WHERE entity_01.parent=entity.ID AND entity_01.ID='.$info['ID']);//$info['parents']?explode(',',$info['parents']):array(); if($info['type']==2): $this->uid=$this->entity['fid']; $this->wuid=0; elseif($info['type']==3): $this->wuid=$this->entity['fid']; foreach($this->parents as $parent) $this->uid=($parent['type']==2)?$parent['fid']:$this->uid; endif; $grps=array(); foreach($this->parents as $parent) if ($parent['type']==1) $grps[]=$parent['fid']; $this->grps="(".($grps?implode(',',$grps):"''").")"; endif; } public function exists() { return !is_null($this->entity); } public function getUser(){ return $this->uid; } public function getWebUser(){ return $this->wuid; } public function getGroups(){ return $this->grps; } public function checkParent($parent){ $res=false; if (is_numeric($parent)): //$res=in_array($parent, $this->parents); $res=isset($this->parents[$parent]); elseif (is_array($parent)): foreach($parent as $p): $res=$res or $this->checkParent($p); endforeach; else: if($parent): $parent=explode(',',$parent); foreach($parent as $p): $res=($res or $this->checkParent($p)); endforeach; endif; endif; return $res; } } ?>'.$nadpis.''; } function bFormCap($nadpis){ return '

'.$nadpis.'

'; } function bDesc($popiska, $fld_id=''){ return ''.$popiska.''; } function bField($meno,$hodnota,$trieda=1,$max='',$id='',$attr=''){ $res='"; return $res; } function bFile($meno,$trieda=1,$id='',$size=0,$alt=''){ $size=($size)?(' size="'.$size.'"'):''; $alt=($alt)?(' alt="'.$alt.'"'):''; $res=''; return $res; } function bText($meno,$hodnota,$trieda=1,$pocriad=5,$wrap='',$att='',$id=''){ $res=''.htmlspecialchars($hodnota).''; return $res; } function bCheck($meno,$checked,$hodnota=1,$id='', $other = ''){ $res=''; } function bList($meno,$zoznam,$default,$trieda=1,$other='',$id='',$multi=false){ if (!isset($zoznam[count($zoznam)-1][0])): //debug_print_backtrace(); endif; $default=($multi and !is_array($default))?explode(',',$default):$default; $res=''; for($i=0;$iisset($zoznam[$i-1][2])) or (isset($zoznam[$i][2]) and ($zoznam[$i][2]<>$zoznam[$i-1][2]))))): $res.=empty($zoznam[$i-1][2])?'':''; $res.=empty($zoznam[$i][2])?'':(''); endif; $res.= ''; $res.= ""; return $res; } function bOptionList($meno,$zoznam,$default,$id='',$other='', $class=''){ $res=''; for ($i=0;$i'; endfor; return $res; } /* Datum: 19.10.2003 Popis: funkcia vlozi tlacitko */ function bButton($name,$value,$style='',$other='',$id=''){ if (!$style) $style=0; return ''; } /* Datum: 19.10.2003 Popis: Funkcia prida do formulara pole pre heslo */ function bPass($meno,$hodnota,$trieda=1,$max='',$id=''){ $res='"") $res.=' maxlength="'.$max.'"'; $res.=" />"; return $res; } /* Datum: 19.10.2003 Popis: Funkcia prida do formulara poznamku */ function bNotice($poznamka){ return ''.$poznamka.''; } /* Datum: 3.3.2003 Popis: Funkcia prida do formulara tabulku */ function bTable($zoznam,$hlavicka='',$small='',$lang='sk',$id='',$sortable=0){ global $syscom; if ($zoznam): $res='
'; $res=''; if ($hlavicka && is_array($hlavicka)): $pocet=count($hlavicka); if (count($zoznam)): $res.=''; $res.=''; foreach($hlavicka as $col) $res.= ''; $res.=''; $res.=''; endif; endif; $res.=''; for($i=0;$i':''; for ($j=0;$j<((isset($pocet) and $pocet)?$pocet:count($zoznam[$i]));$j++): if ($j==0 and $sortable): $res.=''; else: $res.=''; endif; endfor; $res.=''; endfor; $res.=''; $res.='
'.$col.'
'.$zoznam[$i][$j].'
'; $res.='
'; else: $res=$syscom->lm('@frm-ziadne-zaznamy'); endif; return $res; } /* @Datum: 29.6.2005 @Popis: funkcia vlozi textove pole pre datum */ function bDate($meno,$hodnota,$trieda=1,$max="",$time=0,$id=''){ //echo "test"; global $syscom; if ($syscom->mode==2): $res='skin; $root=empty($syscom)?'/':'./'; $res='" ; endif; return $res; } /* Datum: 19.9.2004 Popis: Expoerimentalne - prida do formulara vyber dokumentu, dokument */ function bCMSDoc($meno, $hodnota, $nazov,$schema=0,$nadrad=0,$typ='',$id=''){ global $syscom; $skin=$syscom->skin; $linka=(($typ=='search')?'searchdoc':'seldoc'); $res=''; $res.=' Nájdi...'; return $res; } /* Datum: 19.9.2004 Popis: Expoerimentalne - prida do formulara vyber dokumentu, dokument */ function bCMSDocs($meno, $hodnota,$schema=0,$nadrad=0,$typ='',$id=''){ global $FW_SKIN,$syscom; $skin=empty($FW_SKIN)?$syscom->skin:$FW_SKIN; $res=''; $res.='
'; for ($i=0;$i'; $res.=' #'.$hodnota[$i][0].' '.$hodnota[$i][1].''; $res.=' Odstrániť'; $res.=' Odstrániť'; $res.='
'; endfor; $res.=''; // '.$nazov.' $linka=(($typ=='search')?'searchdoc':'seldoc'); //$res.='Nájdi...';/*width=270*/ //$res.=''; $res.='Nájdi...' ;/*width=270*/ /*
*/ return $res; } /* @Datum: 7.11.2005 @Popis: funkcia vlozi textove nazov suboru na disku */ function bDiskFile($meno,$hodnota,$trieda=1,$dir='',$id=''){ global $FW_SKIN,$syscom; $skin=empty($FW_SKIN)?$syscom->skin:$FW_SKIN; $res=' '; //$res.= ' //Vyber súbor...'; $res.='Vyber súbor...'; return $res; } ?> vplyv na getValues a setValues var $status=1; //1=editable,2=readonly,3=inactiv var $pov=0; function __construct($meno,$hodnota,$popiska,$aktiv,$pov=0){ $this->meno=$meno; $this->hodnota=$hodnota; $this->popiska=$popiska; $this->aktiv=$aktiv; $this->pov=$pov; } function setFrm($frm){ $this->frm=$frm; } function setId($id){ $this->id=$id; } function validate(){ return ''; } function getValue($db){ $res=isset($_REQUEST[$this->meno])?$_REQUEST[$this->meno]:''; if (get_magic_quotes_gpc()) $res=stripslashes($res); if ($db) $res="'".addslashes($res)."'"; return $res; } function setValue($val,$db){ $this->hodnota=$val; } function generate($mode){ } function getTemplate(){ $res=(empty($this->popiska)?('['.$this->meno.']['.$this->meno.',2]'):('['.$this->meno.',1]['.$this->meno.']['.$this->meno.',2]')); return ''.$res.''; } function setStatus($status){ $this->status=$status; } function getMessage($kod){ global $syscom; //return empty($this->hlaska[$kod][$this->lang])?$this->hlaska[$kod]['en']:$this->hlaska[$kod][$this->lang]; return $syscom->lm($kod); } } //TFrmField------------------------------------------------------------------------------------------ class TFrmField extends TFrmComp{ var $trieda; var $max; var $typ; var $typy; //konstanty regularnych vyrazov function __construct($popiska,$meno,$hodnota,$trieda,$max,$pov,$typ){ parent::__construct($meno,$hodnota,$popiska,1,$pov); $this->trieda=$trieda; $this->max=$max; $this->typ=$typ; $this->typy['int']=array('/^[0-9-]+$/','@frm-cele-cislo'); $this->typy['float']=array('/^[ 0-9-]+[\.,]*[ 0-9]*$/','@frm-cislo'); $this->typy['email']=array('/^( *)([0-9a-zA-Z\.\_-]+)@([0-9a-zA-Z\.\_-]+)\.([0-9a-zA-Z\_-]+)( *)$/','@frm-email'); $this->typy['emails']=array('/^( )*([0-9a-zA-Z\.\_-]+)@([0-9a-zA-Z\.\_-]+)\.([0-9a-zA-Z\_-]+)(,( ?)([0-9a-zA-Z\.\_-]+)@([0-9a-zA-Z\.\_-]+)\.([0-9a-zA-Z\_-]+))*( )*$/','@frm-emaily'); } function validate(){ $error=''; if (!$this->hodnota): //policko nie je vyplnene $error=$this->pov?'@frm-povinne':''; elseif($this->typ): if (isset($this->typy[$this->typ])) $error=preg_match($this->typy[$this->typ][0],$this->hodnota)?0:$this->typy[$this->typ][1]; elseif ($this->typ=='date') $error=testDatum($this->hodnota)?0:'@frm-datum'; elseif ($this->typ=='time') $error=testCas($this->hodnota)?0:'@frm-cas'; elseif ($this->typ=='datetime') $error=testDatumCas($this->hodnota)?0:'@frm-datum-cas'; else $error=preg_match($this->typ,$this->hodnota)?0:'@frm-format'; endif; return $error?$this->getMessage($error):''; } function getValue($db){ $res=getString($this->meno); //isset($_REQUEST[$this->meno])?$_REQUEST[$this->meno]:''; if (get_magic_quotes_gpc()) $res=stripslashes($res); if ($this->typ=='int') $res=str_replace(' ','',$res); elseif ($this->typ=='float') $res=str_replace(array(' ',','),array('','.'),str_replace(' ','',$res)); elseif ($this->typ=='email') $res=trim($res); elseif ($this->typ=='emails') $res=trim($res); elseif ($this->typ=='date') $res=trim($res); elseif ($this->typ=='time') $res=trim($res); elseif ($this->typ=='datetime') $res=trim($res); if ($db): if ($this->typ=='date') $res=testDatum($res); if ($this->typ=='time') $res=testCas($res); if ($this->typ=='datetime') $res=testDatumCas($res); $res="'".addslashes($res)."'"; endif; return $res; } function setValue($val,$db){ $this->hodnota=$val; if ($db): if ($this->typ=='date') $this->hodnota=mydate($this->hodnota); if ($this->typ=='time') $this->hodnota=mytime($this->hodnota); if ($this->typ=='datetime') $this->hodnota=mydatetime($this->hodnota); endif; } function generate($mode){//0=formular,1=readonly global $syscom; if ($this->typ=='date'): $this->trieda.=' scd_date'; $syscom->reqJsLib('/libs/js/frm/date.js'); elseif ($this->typ=='datetime'): $syscom->reqJsLib('/libs/js/frm/timepicker-addon.js'); $syscom->reqJsLib('/libs/js/frm/date.js'); $syscom->reqJsLib('/libs/js/frm/datetime.js'); $this->trieda.=' scd_datetime'; endif; return ($mode?htmlspecialchars($this->hodnota):bField($this->meno,$this->hodnota,$this->trieda,$this->max,$this->id)); } } //TFrmCaption---------------------------------------------------------------------------------------- class TFrmCaption extends TFrmComp{ var $style; function __construct($meno,$nadpis,$style){ parent::__construct($meno,$nadpis,'',0); $this->style=$style; } function generate($mode){//0=formular,1=readonly return bCaption($this->hodnota,$this->style); } function getTemplate(){ return '['.$this->meno.']'; } } //TFrmFormCap---------------------------------------------------------------------------------------- class TFrmFormCap extends TFrmComp{ function __construct($meno,$nadpis){ parent::__construct($meno,$nadpis,'',0); } function generate($mode){//0=formular,1=readonly return bFormCap($this->hodnota); } function getTemplate(){ return '['.$this->meno.']'; } } //TText------------------------------------------------------------------------------------------- class TFrmText extends TFrmComp{ var $trieda; var $pocriad; var $wrap; function __construct($popiska,$meno,$hodnota,$trieda,$pov,$pocriad,$wrap=''){ parent::__construct($meno,$hodnota,$popiska,1,$pov); $this->trieda=$trieda; $this->pocriad=$pocriad; $this->wrap=$wrap; } function validate(){ $error=''; if (!$this->hodnota): //policko nie je vyplnene $error=$this->pov?'@frm-povinne':''; endif; return $error?$this->getMessage($error):''; } function generate($mode){//0=formular,1=readonly return ($mode?nl2br(htmlspecialchars($this->hodnota)):bText($this->meno,$this->hodnota,$this->trieda,$this->pocriad,$this->wrap,'',$this->id)); } } //TCheck------------------------------------------------------------------------------------------ class TFrmCheck extends TFrmComp{ var $defvalue; function __construct($popiska,$meno,$checked,$hodnota,$pov=0){ parent::__construct($meno,$checked,$popiska,1,$pov); $this->defvalue=$hodnota; } function generate($mode){//0=formular,1=readonly $anonie['sk']=array('Nie','Áno'); $anonie['en']=array('No','Yes'); $anonie['de']=array('Nein','Ja'); $anonie['cz']=array('Ne','Ano'); $anonie['pl']=array('Nie','Tak'); $anonie['hu']=array('Nem','Igen'); return ($mode?$anonie[$this->lang][($this->hodnota?1:0)]:bCheck($this->meno,$this->hodnota,$this->defvalue,$this->id)); } function validate(){ $error=''; if (!$this->hodnota): //policko nie je vyplnene $error=$this->pov?'@frm-povinne':''; endif; return $error?$this->getMessage($error):''; } function getValue($db){ $res=isset($_REQUEST[$this->meno])?$_REQUEST[$this->meno]:0; if (get_magic_quotes_gpc()) $res=stripslashes($res); if ($db) $res="'".addslashes($res)."'"; return $res; } function setValue($val,$db){ $this->hodnota=($val?1:0); if ($val>1) $this->defvalue=$val; } } //THidden------------------------------------------------------------------------------------------ class TFrmHidden extends TFrmComp{ function __construct($meno,$hodnota){ parent::__construct($meno,$hodnota,'',1); } function generate($mode){//0=formular,1=readonly return bHidden($this->meno,$this->hodnota,$this->id); } function getTemplate(){ return '['.$this->meno.']'; } } //TList------------------------------------------------------------------------------------------ class TFrmList extends TFrmComp{ var $zoznam; var $trieda; var $multi; function __construct($popiska,$meno,$zoznam,$hodnota,$trieda,$pov=true,$multi=false){ parent::__construct($meno,$hodnota,$popiska,1,$pov); $this->zoznam=$zoznam; $this->trieda=$trieda; $this->multi=$multi; } function generate($mode){//0=formular,1=readonly if ($this->pov): $zoznam=$this->zoznam; else: $zoznam_[]=array('',' '); $zoznam=array_merge($zoznam_,$this->zoznam); endif; $res=''; if ($mode): $i=0; while ($ihodnota) $res=$zoznam[$i][1]; $i++; endwhile; else: $res=bList($this->meno,$zoznam,$this->hodnota,$this->trieda,'',$this->id,$this->multi); endif; return $res; } } //TButton------------------------------------------------------------------------------------------ class TFrmButton extends TFrmComp{ var $style; var $other; var $bg; function __construct($meno,$hodnota,$style,$other='',$bg=false){ parent::__construct($meno,$hodnota,'',0); $this->style=$style; $this->other=$other; $this->bg=$bg; } function generate($mode){//0=formular,1=readonly return bButton($this->meno,$this->hodnota,$this->style,$this->other,$this->id); } function getTemplate(){ return '
bg?'class="frmbutbg"':'class="frmbut"').'>['.$this->meno.']
'; } } //TButtons------------------------------------------------------------------------------------------ class TFrmButtons extends TFrmComp{ var $style; var $bg; function __construct($meno,$hodnota1,$hodnota2,$style='',$bg=false){ parent::__construct($meno,array($hodnota1,$hodnota2),'',0); $this->style=$style; $this->bg=$bg; } function generate($mode){//0=formular,1=readonly return bButton($this->meno.'_yes',$this->hodnota[0],$this->style,'').' '.bButton($this->meno.'_no',$this->hodnota[1],$this->style,''); } function getTemplate(){ return '
bg?'class="frmbutbg"':'class="frmbut"').'>['.$this->meno.']
'; } } //TButtons------------------------------------------------------------------------------------------ class TFrmDoubleButton extends TFrmComp{ var $style; var $bg; function __construct($meno,$hodnota1,$popiska1,$hodnota2,$popiska2,$style='',$bg=false){ parent::__construct($meno,$hodnota1.'|'.$hodnota2,$popiska1.'|'.$popiska2,0); $this->style=$style; $this->bg=$bg; } function generate($mode){//0=formular,1=readonly $hodnota=explode('|',$this->hodnota); $popiska=explode('|',$this->popiska); return bButton($hodnota[0],$popiska[0],$this->style,'').' '.bButton($hodnota[1],$popiska[1],$this->style,''); } function getTemplate(){ return '
bg?'class="frmbutbg"':'class="frmbut"').'>['.$this->meno.']
'; } } //TFrmPass------------------------------------------------------------------------------------------ class TFrmPass extends TFrmComp{ var $trieda; var $max; function __construct($popiska,$meno,$hodnota,$trieda=1,$max="",$pov=0){ parent::__construct($meno,$hodnota,$popiska,1,$pov); $this->trieda=$trieda; $this->max=$max; } function validate(){ $error=''; if (!$this->hodnota): //policko nie je vyplnene $error=$this->pov?'@frm-povinne':''; endif; return $error?$this->getMessage($error):''; } function generate($mode){//0=formular,1=readonly return ($mode?str_repeat('*',strlen($this->hodnota)):bPass($this->meno,$this->hodnota,$this->trieda,$this->max,$this->id)); } } //TNotice------------------------------------------------------------------------------------------ class TFrmNotice extends TFrmComp{ var $typ; function __construct($meno,$hodnota,$typ){ parent::__construct($meno,$hodnota,'',0); $this->typ=$typ; } function generate($mode){//0=formular,1=readonly return bNotice($this->hodnota); } function getTemplate(){ return ($this->typ==1)?('['.$this->meno.']'):('['.$this->meno.']'); } } //TInfoText------------------------------------------------------------------------------------------ class TFrmInfoText extends TFrmComp{ var $typ; function __construct($meno,$hodnota,$typ){ parent::__construct($meno,$hodnota,'',0); $this->typ=$typ; } function generate($mode){//0=formular,1=readonly return $this->hodnota; } function getTemplate(){ return ($this->typ==1)?('['.$this->meno.']'):('['.$this->meno.']'); } } class TFrmInfo extends TFrmComp{ function __construct($meno,$popiska,$hodnota){ parent::__construct($meno,$hodnota,$popiska,0); } function generate($mode){//0=formular,1=readonly return $this->hodnota; } } //TFrmOptionList------------------------------------------------------------------------------------------ class TFrmOptionList extends TFrmComp{ var $zoznam; function __construct($popiska,$meno,$zoznam,$hodnota){ parent::__construct($meno,$hodnota,$popiska,1); $this->zoznam=$zoznam; } function generate($mode){//0=formular,1=readonly $res=''; if ($mode): $i=0; while ($izoznam) and !$res): if ($this->zoznam[$i][0]==$this->hodnota) $res=$this->zoznam[$i][1]; $i++; endwhile; else: $res=bOptionList($this->meno,$this->zoznam,$this->hodnota,$this->id); endif; return $res; } } //TFrmFile------------------------------------------------------------------------------------------ class TFrmFile extends TFrmComp{ var $trieda; var $size; var $alt; function __construct($popiska,$meno,$trieda,$pov,$size,$alt){ parent::__construct($meno,'',$popiska,0,$pov); $this->trieda=$trieda; $this->size=$size; $this->alt=$alt; } function validate(){ $error=''; if (empty($_FILES[$this->meno]) or $_FILES[$this->meno]['error'] or empty($_FILES[$this->meno]['size'])): //policko nie je vyplnene// or !filesize($_FILES[$this->meno]['tmp_name']) $error=$this->pov?'@frm-povinne':''; endif; return $error?$this->getMessage($error):''; } function generate($mode){//0=formular,1=readonly return ($mode?'...':bFile($this->meno,$this->trieda,$this->id,$this->size,$this->alt)); } } //TFrmCheckArray------------------------------------------------------------------------------------------ class TFrmCheckArray extends TFrmComp{ var $zoznam; var $stlpce; function __construct($popiska,$meno,$zoznam,$checked,$stlpce=3){ if (empty($checked)): $checked=array(); elseif (!is_array($checked)): $checked=explode(',',$checked); endif; parent::__construct($meno,$checked,$popiska,1); $this->zoznam=$zoznam; $this->stlpce=empty($stlpce)?3:$stlpce; } function generate($mode){//0=formular,1=readonly $pom=array('',''); $res=''; $i=0; while ($izoznam)): $res.=''; for ($j=0;$j<$this->stlpce;$j++): $res.=''; $i++; endfor; $res.=''; endwhile; $res.='
'; if ($izoznam)) $res.=($mode?$pom[in_array($this->zoznam[$i][0],$this->hodnota)]:bCheck($this->meno.'[]',in_array($this->zoznam[$i][0],$this->hodnota),$this->zoznam[$i][0],$this->id.'_'.$i)).' '.$this->zoznam[$i][1].''; else $res.=' '; $res.='
'; return $res; } function setValue($val,$db){ if (empty($val)): $val=array(); elseif (!is_array($val)): $val=explode(',',$val); endif; $this->hodnota=$val; } function getValue($db){ $res=isset($_REQUEST[$this->meno])?$_REQUEST[$this->meno]:array(); return $db?adsq(implode(',',$res)):$res; } } //TFrmHTMLArea------------------------------------------------------------------------------------------- class TFrmHTMLArea extends TFrmComp{ var $trieda; var $pocriad; var $typ; function __construct($popiska,$meno,$hodnota,$trieda,$pov,$pocriad,$typ=''){ parent::__construct($meno,$hodnota,$popiska,1,$pov); $this->trieda=$trieda; $this->pocriad=$pocriad; $this->typ=empty($typ)?'basic':$typ; } function validate(){ $error=''; if (!$this->hodnota): //policko nie je vyplnene $error=$this->pov?'@frm-povinne':''; endif; return $error?$this->getMessage($error):''; } function generate($mode){//0=formular,1=readonly if ($mode): $res=$this->hodnota; else: $res=bText($this->meno,$this->hodnota,$this->trieda,$this->pocriad,'',' sc_html="'.$this->typ.'"',$this->id); endif; return $res; } } //TFrmTable------------------------------------------------------------------------------------------- class TFrmTable extends TFrmComp{ var $hlav; var $styl; var $sortable; function __construct($popiska,$meno,$hodnota,$hlavicka,$styl='',$sortable=0){ parent::__construct($meno,$hodnota,$popiska,0); $this->hlav=$hlavicka; $this->styl=$styl; $this->sortable=$sortable; } function generate($mode){//0=formular,1=readonly $res=bTable($this->hodnota,$this->hlav,$this->styl,$this->lang,$this->id, $this->sortable); return $res; } } //TFrmCMSDoc------------------------------------------------------------------------------------------ class TFrmCMSDoc extends TFrmComp{ var $nazov; var $schema; var $nadrad; var $typ; function __construct($popiska,$meno,$hodnota,$pov=0,$schema=0,$nadrad=0,$typ=''){ parent::__construct($meno,$hodnota,$popiska,1,$pov); $this->schema=$schema; $this->nadrad=$nadrad; $this->typ=$typ; } function validate(){ $error=''; if (!$this->hodnota): //policko nie je vyplnene $error=$this->pov?'@frm-povinne':''; endif; return $error?$this->getMessage($error):''; } /* function setValue($val,$db){ $this->hodnota=$val; if ($val): $nazov=getRow("SELECT nazov FROM art WHERE ID='".$val."'"); $this->nazov=$nazov[0]; endif; }*/ function getReadOnly(){ $res=''; if (!empty($this->hodnota)): $art=getRow("SELECT ID, nazov FROM art WHERE ID='".$this->hodnota."'"); $res=$art['ID'].' - '.$art['nazov']; endif; return $res; } function generate($mode){//0=formular,1=readonly global $session,$syscom; $syscom->reqJsLib('/libs/js/frm/arts.js'); if ($mode): return $this->getReadOnly(); else: $session->setVar('scd_'.$this->frm->id.'_'.$this->meno,array('nadrad'=>$this->nadrad,'artpro'=>$this->schema)); return bField($this->meno,$this->hodnota,'2 scd_arts','',$this->id,'size=1'); endif; } } //TFrmCMSDocs------------------------------------------------------------------------------------------ class TFrmCMSDocs extends TFrmComp{ var $nazov; var $schema; var $nadrad; var $typ; var $maxdocs; function __construct($popiska,$meno,$hodnota,$pov=0,$schema=0,$nadrad=0,$typ='',$maxdocs=0){ parent::__construct($meno,$hodnota,$popiska,1,$pov); $this->schema=$schema; $this->nadrad=$nadrad; $this->typ=$typ; $this->maxdocs=$maxdocs; /* if (empty($hodnota)): $this->hodnota=array(); else: $this->hodnota=getTable("SELECT ID, nazov FROM art WHERE ID IN (".$this->hodnota.")"); endif;*/ } function validate(){ $error=''; if (!$this->hodnota): //policko nie je vyplnene $error=$this->pov?'@frm-povinne':''; endif; return $error?$this->getMessage($error):''; } /* function setValue($val,$db){ if (empty($val)): $this->hodnota=array(); else: $this->hodnota=getTable("SELECT ID, nazov FROM art WHERE ID IN (".$val.")"); endif; }*/ /* function getValue($db){ $res=isset($_REQUEST[$this->meno])?$_REQUEST[$this->meno]:''; if (!empty($res)): $res=implode(',',$res); else: $res=''; endif; if ($db) $res="'".$res."'"; return $res; }*/ function getValue($db){ $res=isset($_REQUEST[$this->meno])?$_REQUEST[$this->meno]:''; $res=is_array($res)?implode(',',$res):$res; if ($db) $res=adsq($res); return $res; } function getReadOnly(){ $res=''; for($i=0;$ihodnota);$i++): $res.=(empty($res)?'':', ').('#'.$this->hodnota[$i]['ID'].' '.$this->hodnota[$i]['nazov']); endfor; return $res; } function generate($mode){//0=formular,1=readonly global $session,$syscom; $syscom->reqJsLib('/libs/js/frm/arts.js'); if ($mode): return $this->getReadOnly(); else: if ($this->typ=='combo'): $syscom->reqJsLib('/libs/js/frm/multiselect.js'); $syscom->reqCss('/libs/js/frm/multiselect.css'); $session->setVar('scd_'.$this->frm->id.'_'.$this->meno,array('nadrad'=>$this->nadrad,'artpro'=>$this->schema,'maxdocs'=>$this->maxdocs,'groups'=>false),true); $pars=$session->getVar('scd_'.$this->frm->id.'_'.$this->meno); return bField($this->meno,$this->hodnota,'2 scd_arts_combo','',$this->id); /* $syscom->reqJsLib('/libs/js/frm/multiselect.js'); $rek=1; $zoznam=getTable("SELECT DISTINCT art.ID, art.nazov FROM art, art_01 WHERE art.ID=art_01.art AND artpro='".$this->schema."' AND art_01.nadrad=".$this->nadrad.' AND '.getRightSel($session->uid,$session->grps).' AND art_01.typ'.(empty($rek)?'=1':' IN (1,2)').' ORDER BY nazov'); // return bList($this->meno,$zoznam,$this->hodnota,2,$this->id,true); return bList($this->meno,$zoznam,$this->hodnota,2,'',$this->id,true);*/ elseif($this->typ=='combo1'): $syscom->reqJsLib('/libs/js/frm/multiselect.js'); $syscom->reqCss('/libs/js/frm/multiselect.css'); $session->setVar('scd_'.$this->frm->id.'_'.$this->meno,array('nadrad'=>$this->nadrad,'artpro'=>$this->schema,'maxdocs'=>$this->maxdocs,'groups'=>true),true); $pars=$session->getVar('scd_'.$this->frm->id.'_'.$this->meno); return bField($this->meno,$this->hodnota,'2 scd_arts_combo1','',$this->id); else: // return bCMSDocs($this->meno,$this->hodnota,$this->schema,$this->nadrad,$this->typ,$this->id); // print_r($this->hodnota); $session->setVar('scd_'.$this->frm->id.'_'.$this->meno,array('nadrad'=>$this->nadrad,'artpro'=>$this->schema)); // print 'setting: '.'scd_'.$this->frm->id.'_'.$this->meno; return bField($this->meno,$this->hodnota,'2 scd_arts','',$this->id,'size='.$this->maxdocs); endif; endif; } } //TFrmCMSDiskFile------------------------------------------------------------------------------------------ class TFrmDiskFile extends TFrmComp{ var $nazov; var $trieda; var $dir; function __construct($popiska,$meno,$hodnota,$trieda,$pov=0,$dir=''){ parent::__construct($meno,$hodnota,$popiska,1,$pov); $this->trieda=$trieda; $this->hodnota=$hodnota; $this->dir=$dir; } function validate(){ $error=''; if (!$this->hodnota): //policko nie je vyplnene $error=$this->pov?'@frm-povinne':''; endif; return $error?$this->getMessage($error):''; } function generate($mode){//0=formular,1=readonly return ($mode?$this->hodnota:bDiskFile($this->meno,$this->hodnota,$this->trieda,$this->dir,$this->id)); } } //TFrmUser------------------------------------------------------------------------------------------ class TFrmUser extends TFrmComp{ var $nazov; var $trieda; var $zoznam; function __construct($popiska,$meno,$hodnota,$trieda,$pov=0,$rola='',$skupina=''){ parent::__construct($meno,$hodnota,$popiska,1,$pov); $this->trieda=$trieda; $this->hodnota=$hodnota; if (empty($skupina)): $this->zoznam=getTable("SELECT ID, CONCAT(priez,' ',meno) FROM usr WHERE stav=1".(empty($rola)?'':(' AND role IN('.$rola.')'))." ORDER BY priez, meno",false); else: $this->zoznam=getTable("SELECT usr.ID, CONCAT(usr.priez,' ',usr.meno) FROM usr, usr_01 WHERE usr.ID=usr_01.usr AND usr_01.grp=".$skupina." AND usr.stav=1".(empty($rola)?'':(' AND usr.role IN('.$rola.')'))." ORDER BY priez, meno",false); endif; } function generate($mode){//0=formular,1=readonly $res=''; if (!$this->pov): $zoznam_[]=array('',' '); $this->zoznam=array_merge($zoznam_,$this->zoznam); endif; if ($mode): $i=0; while ($izoznam) and !$res): if ($this->zoznam[$i][0]===$this->hodnota) $res=$this->zoznam[$i][1]; $i++; endwhile; else: $res=bList($this->meno,$this->zoznam,$this->hodnota,$this->trieda,$this->id); endif; return $res; } } //TFrmGroup------------------------------------------------------------------------------------------ class TFrmGroup extends TFrmComp{ var $nazov; var $trieda; var $zoznam; function __construct($popiska,$meno,$hodnota,$trieda,$pov=0){ parent::__construct($meno,$hodnota,$popiska,1,$pov); $this->trieda=$trieda; $this->hodnota=$hodnota; $this->zoznam=getTable("SELECT ID, nazov FROM grp ORDER BY nazov",false); if (empty($pov)): $zoznam_[]=array(0,' '); $this->zoznam=array_merge($zoznam_,$this->zoznam); endif; } function generate($mode){//0=formular,1=readonly $res=''; if ($mode): $i=0; while ($izoznam) and !$res): if ($this->zoznam[$i][0]===$this->hodnota) $res=$this->zoznam[$i][1]; $i++; endwhile; else: $res=bList($this->meno,$this->zoznam,$this->hodnota,$this->trieda,$this->id); endif; return $res; } } //TFrmCMSDocList------------------------------------------------------------------------------------ class TFrmCMSDocList extends TFrmComp{ var $nazov; var $trieda; var $zoznam; function __construct($popiska,$meno,$hodnota,$trieda=1,$pov=0,$schema=0,$nadrad=0,$rek=0){ global $session; parent::__construct($meno,$hodnota,$popiska,1,$pov); $this->trieda=$trieda; $this->zoznam=getTable("SELECT DISTINCT art.ID, art.nazov FROM art, art_01 WHERE art.ID=art_01.art AND artpro='".$schema."' AND art_01.nadrad=".$nadrad.' AND '.getRightSel($session->uid,$session->grps).' AND art_01.typ'.(empty($rek)?'=1':' IN (1,2)').' ORDER BY nazov',false); if (empty($pov)): $zoznam_[]=array(0,' '); $this->zoznam=array_merge($zoznam_,$this->zoznam); endif; } function generate($mode){//0=formular,1=readonly $res=''; if ($mode): $i=0; while ($izoznam) and !$res): if ($this->zoznam[$i][0]===$this->hodnota) $res=$this->zoznam[$i][1]; $i++; endwhile; else: $res=bList($this->meno,$this->zoznam,$this->hodnota,$this->trieda,'', $this->id); endif; return $res; } } //TFrmCheckArray------------------------------------------------------------------------------------------ class TFrmCMSCheckArray extends TFrmCheckArray{ function __construct($popiska,$meno,$zoznam,$checked,$stlpce=3){ $checked=empty($checked)?array():explode(',',$checked); parent::__construct($popiska,$meno,$zoznam,$checked,$stlpce); } function setValue($val,$db){ $this->hodnota=empty($val)?array():explode(',',$val); } function generate($mode){//0=formular,1=readonly $pom=array('',''); $res=''; $i=0; while ($izoznam)): $res.=''; for ($j=0;$j<$this->stlpce;$j++): $res.=''; $i++; endfor; $res.=''; endwhile; $res.='
'; if ($izoznam)) $res.=($mode?$pom[in_array($this->zoznam[$i][0],$this->hodnota)]:bCheck($this->meno.'[]',in_array($this->zoznam[$i][0],$this->hodnota),$this->zoznam[$i][0])).' '.$this->zoznam[$i][1]; else $res.=' '; $res.='
'; return $res; } function getValue($db){ $res=parent::getValue(0); $res=empty($db)?implode(',',$res):"'".implode(',',$res)."'"; return $res; } } //TList------------------------------------------------------------------------------------------ class TFrmCMSList extends TFrmComp{ var $cis; var $trieda; var $rel; function __construct($popiska,$meno,$cis,$hodnota,$trieda,$pov=1,$rel='',$zoradit=0){ parent::__construct($meno,$hodnota,$popiska,1,$pov); $this->cis=$cis; $this->trieda=$trieda; $this->rel=$rel; $this->zoradit=$zoradit; } function generate($mode){//0=formular,1=readonly if ($this->rel): $skup=getValue("SELECT skup FROM cms_cis_01 WHERE cis='".$this->cis."' AND ID='".$this->hodnota."'"); $zoznam=getTable("SELECT ID, nazov FROM cms_cis_01 WHERE cis='".$this->cis."' AND lang='".$this->lang."' AND skup='".$skup."' ORDER BY ".(empty($zoradit)?'poradie':'nazov'),false); else: $zoznam=getTable('SELECT ID, nazov FROM cms_cis_01 WHERE cis=\''.$this->cis.'\' AND lang=\''.$this->lang.'\' ORDER BY '.(empty($zoradit)?'poradie':'nazov'),false); //print_r($zoznam); endif; if (!$this->pov): $zoznam_[]=array(0,' '); $zoznam=array_merge($zoznam_,$zoznam); endif; $res=''; if ($mode): $i=0; while ($ihodnota) $res=$zoznam[$i][1]; $i++; endwhile; else: $res=bList($this->meno,$zoznam,$this->hodnota,$this->trieda,'',$this->id); endif; return $res; } } //TFrmEntity------------------------------------------------------------------------------------------ class TFrmEntity extends TFrmComp{ var $typ; function __construct($popiska,$meno,$hodnota,$pov=0,$typ=''){ parent::__construct($meno,$hodnota,$popiska,1,$pov); $this->typ=$typ; } function validate(){ $error=''; if (!$this->hodnota): //policko nie je vyplnene $error=$this->pov?'@frm-povinne':''; endif; return $error?$this->getMessage($error):''; } function getReadOnly(){ $res=''; foreach($this->getItems($this->hodnota) as $item): $res.=''.$item['name'].''; endforeach; return $res; } function getItems($values){ return getTable('SELECT ID,name,type FROM entity WHERE FIND_IN_SET(ID,'.adsq($values).')',1); } function generate($mode){//0=formular,1=readonly global $session,$syscom; $syscom->reqCss('/libs/js/entity/style.css'); if ($mode): return $this->getReadOnly(); else: $syscom->reqJsLib('/libs/js/entity/tokeninput.js'); $syscom->reqJsLib('/libs/js/entity/entity.js'); $session->setVar('frm_'.$this->frm->id.'_'.$this->meno,array('typ'=>$this->typ)); return bField($this->meno,$this->hodnota,'2 frm_entity','',$this->id,'size=1'); endif; } } ?>uid=$session->uid; $this->grps=$session->grps; $this->initialize(); } public function setArt($art){ $this->art=$art; } public function setData(&$data){ $this->data=&$data; } protected function loadEvents($def){ global $syscom; $this->def=$def; $syscom->reqLib('uni_event'); $this->event=new TEvent($this); $this->akcia=&$this->event->action; } protected function setNext($next){ $this->event->setNext($next); } protected function initialize(){//called after creating object } public function begin(){//called before starting batch on documents (is called one times) } public function end(){//called after finishing batch on documents (is called one times) } public function start(){//called befor running action on ducument } public function finish(){//called after finishing action on document } public function run(){//body of action if ($this->event): return $this->event->run($this->def); endif; } //document functions protected function getArt($ID){ global $syscom; return $syscom->getArt($ID); } protected function newArt($artpro,$nadrad=0){ global $syscom; return $syscom->newArt($artpro,empty($nadrad)?$this->art->basic['ID']:$nadrad); } //logging protected function addLog($mes){ $this->log.=$mes; } public function getLog(){ $mes=$this->log; $this->log=''; return $mes; } } ?>crlf=chr(10);//.chr(10);//"\r\n"; $this->html=''; $this->text=$set?$this->fixEOL($text):$this->fixEOL($text); $this->html_images = array(); $this->attachments = array(); //mime typy - skratky $this->image_types = array( 'gif' => 'image/gif', 'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'jpe' => 'image/jpeg', 'bmp' => 'image/bmp', 'png' => 'image/png', 'tif' => 'image/tiff', 'tiff' => 'image/tiff', 'swf' => 'application/x-shockwave-flash' ); } function setFrom($from){ $this->from=$from; //preg_match_all("/[\._a-zA-Z0-9-]+@[\._a-zA-Z0-9-]+/i",$from,$matches); //$this->from_email=$matches[0]; $this->from_email=$from; $this->headers.='From: '.$from.$this->crlf; } function setCc($cc){ $this->headers.='Cc: '.$cc.$this->crlf; } function setBcc($bcc){ $this->headers.='Bcc: '.$bcc.$this->crlf; } function setReplyTo($reply){ $this->headers.='Reply-to: '.$reply.$this->crlf; } function setHtml($text,$set=1,$header=1){ $head1=''; $head2=''; $this->html=$text; $this->html=$header?$head1.$this->html.$head2:$this->html; } function addHtmlImage($nazov,$data='',$typ='',$name=''){ $image['meno']=$name?$name:$nazov; $image['image']=$data?$data:$this->getFile($nazov); $image['typ']=$typ?$typ:substr($nazov,-3); $image['ID']=$this->getID(); $this->html_images[]=$image; return $image['ID']; } function addAtt($nazov,$data=''){ $att['meno']=$nazov; $att['data']=$data?$data:$this->getFile($nazov); $this->attachments[]=$att; } function addImageFromBody(){ preg_match_all('#src=["\']([^"\']+)["\'"]#', $this->html, $matches); preg_match_all('#href=["\']([^"\']+)["\'"]#', $this->html, $matches2); $matche= array_merge($matches[1],$matches2[1]) ; //print_r($matches); for($i=0;$iimageTypeLoad)){ $name=''; if(strrpos($matche[$i],'/')!== false){ $name = substr($matche[$i],strrpos($matche[$i],'/')+1); } $id = $this->addHtmlImage($matche[$i],'','',$name); $this->html = preg_replace("#".$matche[$i]."#","cid:".$id,$this->html); $this->text = preg_replace("#".$matche[$i]."#","cid:".$id,$this->text); echo " ".$id." "; } } echo $this->html; } function getFile($filename){ $return = ''; if ($fp = fopen($filename, 'rb')) { while (!feof($fp)) { $return .= fread($fp, 1024); } fclose($fp); return $return; } else { return false; } } function setImageTypes($types){ $this->image_types =$types; } function setImageTypesLoad($types){ $this->imageTypeLoad =$types; } function quotedprintableencode($input , $line_max = 76){ return quoted_printable_encode($input); } function base64encode($data){ return rtrim(chunk_split(base64_encode($data), 76, $this->crlf)); } function FixEOL($str) { $str = str_replace("\r\n", "\n", $str); $str = str_replace("\r", "\n", $str); $str = str_replace("\n", $this->crlf, $str); return $str; } function utfRem($ret){ $from="á,ä,č,ď,é,ě,ë,í,ľ,ň,ô,ó,ö,ŕ,ř,š,ť,ú,ů,ü,ý,ž,Á,Ä,Č,Ď,É,Ě,Ë,Í,Ľ,Ň,Ó,Ö,Ô,Ř,Ŕ,Š,Ť,Ú,Ů,Ü,Ý,Ž"; $to= "a,a,c,d,e,e,e,i,l,n,o,o,o,r,r,s,t,u,u,u,y,z,A,A,C,D,E,E,E,L,I,N,O,O,O,R,R,S,T,U,U,U,Y,Z"; return str_replace(explode(',',$from),explode(',',$to),$ret); } function getBoundry(){ return '------syscom_mail_part_'.md5(uniqid(rand()) . microtime()); } function getID(){ return md5(uniqid(rand()) . microtime()).'@'.(empty($_SERVER['SERVER_NAME'])?'syscom.sk':$_SERVER['SERVER_NAME']); } function getTextPart(){ $res= 'Content-Type: text/plain; '.$this->crlf; $res.=' charset="UTF-8"'.$this->crlf; $res.='Content-Transfer-Encoding: base64'.$this->crlf; return $res; } function getHTMLPart(){ $res= 'Content-Type: text/html; '.$this->crlf; $res.=' charset="UTF-8"'.$this->crlf; $res.='Content-Transfer-Encoding: base64'.$this->crlf; return $res; } function getImagePart($image,$typ,$meno,$ID){ echo $typ; $res= 'Content-Type: '.$this->image_types[$typ].'; '.$this->crlf; $res.=' name="'.$meno.'"'.$this->crlf; $res.='Content-Transfer-Encoding: base64'.$this->crlf; $res.='Content-ID: <'.$ID.'>'.$this->crlf; $res.=$this->crlf.$this->base64Encode($image).$this->crlf; return $res; } function getAttPart($data,$meno){ $res= 'Content-Type: application/octet-stream; '.$this->crlf; $res.=' name="'.$meno.'"'.$this->crlf; $res.='Content-Transfer-Encoding: base64'.$this->crlf; $res.='Content-Disposition: attachment; '.$this->crlf; $res.=' filename="'.$meno.'"'.$this->crlf; $res.=$this->crlf.$this->base64Encode($data).$this->crlf; return $res; } function getMultiPart($boundry,$parts){ $res=''; for ($i=0;$icrlf; $res.=$parts[$i]; endfor; $res.=$this->crlf.'--'.$boundry.'--'.$this->crlf.$this->crlf; return $res; } function getMultipartAlternative($boundry){ $res= 'Content-Type: multipart/alternative; '.$this->crlf; $res.= ' boundary="'.$boundry.'"'.$this->crlf; return $res; } function getMultipartRelated($boundry,$type){ $res= 'Content-Type: multipart/related; '.$this->crlf; $res.= ' type="'.$type.'"; '.$this->crlf; $res.= ' boundary="'.$boundry.'"'.$this->crlf; return $res; } function getMultipartMixed($boundry){ $res= 'Content-Type: multipart/mixed; '.$this->crlf; $res.= ' boundary="'.$boundry.'"'.$this->crlf; return $res; } function setLog(){ $this->log=1; } function clearLog($max=500){ $maily=getList("SELECT ID FROM mail_log ORDER BY crea DESC LIMIT $max, 10000"); if ($maily) uni_query("DELETE FROM mail_log WHERE ID IN $maily"); } function headerEncode($string, $split = true) { return (preg_match('/[^\x20-\x7E]/', $string))?mb_encode_mimeheader($string, "UTF-8", "Q"):$string; } function send($to,$predmet){ //$this->addImageFromBody(); $this->mes_header=$this->getTextPart($this->text); $this->mes_body=$this->base64encode($this->text).$this->crlf;//quotedPrintableEncode($this->text); $this->mes_type='text/plain'; if ($this->html): $boundry=$this->getBoundry(); if ($this->html_images): for ($i=0;$ihtml_images);$i++): $obr_name[]=$this->html_images[$i]['meno']; $obr_ID[]='cid:'.$this->html_images[$i]['ID']; endfor; $this->html=str_replace($obr_name,$obr_ID,$this->html); endif; //$this->addImageFromBody(); $this->mes_body=$this->getMultipart($boundry,array($this->mes_header.$this->crlf.$this->mes_body,$this->getHTMLPart().$this->crlf.$this->base64encode($this->html))); $this->mes_header=$this->getMultiPartAlternative($boundry); $this->mes_type='multipart/alternative'; //pridat img ztela //$this->addImageFromBody(); if ($this->html_images): unset($parts); $parts[]=$this->mes_header.$this->crlf.$this->mes_body; for ($i=0;$ihtml_images);$i++): $parts[]=$this->getImagePart($this->html_images[$i]['image'],$this->html_images[$i]['typ'],$this->html_images[$i]['meno'],$this->html_images[$i]['ID']); endfor; $boundry=$this->getBoundry(); $this->mes_body=$this->getMultipart($boundry,$parts); $this->mes_header=$this->getMultiPartRelated($boundry,$this->mes_type); $this->mes_type='multipart/related'; endif; endif; if ($this->attachments): unset($parts); $parts[]=$this->mes_header.$this->crlf.$this->mes_body; for ($i=0;$iattachments);$i++): $parts[]=$this->getAttPart($this->attachments[$i]['data'],$this->attachments[$i]['meno']); endfor; $boundry=$this->getBoundry(); $this->mes_body=$this->getMultipart($boundry,$parts); $this->mes_header=$this->getMultiPartMixed($boundry); $this->mes_type='multipart/mixed'; endif; //odoslanie $this->headers.='Message-ID: <'. md5(uniqid(rand()) . microtime()).'@'.(empty($_SERVER['SERVER_NAME'])?'syscom.sk':$_SERVER['SERVER_NAME']).'>'.$this->crlf; $this->headers.='MIME-Version: 1.0'.$this->crlf; $this->headers.=$this->mes_header; $this->headers.="X-Mailer: Syscom email library (www.syscom.sk)"; // if ($this->mes_type<>'text/plain') $this->headers.=$this->crlf.'This is a multi-part message in MIME format'; // print $this->headers.$this->crlf.$this->crlf.$this->mes_body; $to = $this->utfRem(is_array($to)?implode(', ', $to):$to); $predmet=$this->headerEncode($predmet); //imap // $server="mail.aglo.sk";$user="polan@aglo.sk";$pass="derrick"; // $conn = imap_open("\{$server/imap}INBOX", $user, $pass); // print_r(imap_errors()); // if ($conn) $res=mail($to,$predmet,$this->mes_body,$this->headers,'-f'.$this->from_email); // imap_close($conn); // $res=1; if ($res and $this->log) uni_query("INSERT INTO log_04 VALUES(0,'".addslashes($to)."','".addslashes($predmet)."','".addslashes($this->text)."','".addslashes($this->html)."','".addslashes($this->mes_body)."','".addslashes($this->headers)."',now())"); return $res; } } ?> pages=getArray('SELECT ID, domena FROM page',0,1); $this->host=isset($_SERVER['HTTP_HOST'])?$_SERVER['HTTP_HOST']:''; $this->scheme=empty($_SERVER['REQUEST_SCHEME'])?$this->scheme:$_SERVER['REQUEST_SCHEME']; } //helping functions----------------------------------------------------------- function str2link($ret){ $basic=array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','-','/','1','2','3','4','5','6','7','8','9','0'); $diakr=array(' - ',' ',' ',' ',' ','á','ä','č','ď','é','ě','í','ľ','ĺ','ł','ň','ó','ô','ŕ','ř','š','ť','ú','ů','ý','ž','ö','ü','Á','Ä','Č','Ď','É','Í','Ľ','Ĺ','Ň','Ó','Ô','Ŕ','Ř','Š','Ť','Ú','Ý','Ž','Ö','Ü',"'",'"','*','.','?','!','%',',','.','`','´','™','(',')',':','+','&','§','–','„','“'); $nahrada=array('-','-','-','-','-','a','a','c','d','e','e','i','l','l','l','n','o','o','r','r','s','t','u','u','y','z','oe','ue','a','a','c','d','e','i','l','l','n','o','o','r','r','s','t','u','y','z','o','u','','','','','','','','','','','','','','','','','-','','','',''); $res=str_replace($diakr,$nahrada,strtolower(trim($ret))); $res=str_replace(array('----','---','--'),array('-','-','-'),$res); $out=''; for($i=0;$istr2link($location); $test=getValue('SELECT art FROM location WHERE flag IN (1,3) AND (host='.adsq($host).' OR host=\'\') AND location='.adsq($location)); return $alias?empty($test):(((empty($test) and ($empty or !empty($location)))?'':($ID.(empty($lang)?'':'-'.$lang).'/')).$location); } function updateLocation(&$art){ if (!(($art->basic['seo_manual']&1)==1)): $langs=explode(',',$art->basic['lang']); $pages=explode(',',$art->basic['page']); foreach($pages as $page): for ($i=0;$ipages[$page])?'':$this->pages[$page]; if ($this->mode==1): $location=$this->index.'?ID='.$art->basic['ID'].((count($langs)==1)?'':'&l='.$langs[$i]); else: if ($art->artpro->basic['seo'] and ($this->mode==3) and ($temps=getArray("SELECT ID FROM template WHERE kod='".$art->artpro->basic['sablona1']."' AND typ=5 AND (lang='".$langs[$i]."' OR lang='') AND (verzia='link' OR verzia='link_".$page."')",0,2))): //using templates $data=$art->getValues(2,''); $data['nazov']=$art->basic['nazov']; foreach($temps as $temp): $temp=new TTemplate($temp); $location=$temp->generate($data); $host=empty($temp->info['par1'])?$host:$temp->generate($data,0,'par1'); $pars=$temp->info['par2']?explode('=',$temp->info['par2']):array('',''); $this->setLocation($art->basic['ID'],$location,$host,$langs[$i],$page,$pars[0],$pars[1],true,!empty($temp->info['par3'])); endforeach; else: //standard link if (count($langs)==1): $location=($this->mode==2?($art->basic['ID'].'/'):'').$this->remSlashes($art->getValue('nazov')); else: $location=$art->basic['ID'].'-'.$langs[$i].'/'.$this->remSlashes($art->getValue('nazov')); endif; $this->setLocation($art->basic['ID'],$location,$host,$langs[$i],$page); endif; endif; endfor; endforeach; endif; //removing expired locations uni_query("DELETE FROM location WHERE flag=2 AND chan + INTERVAL ".$this->expiration." DAY < now()"); } function setLocation($art,$location,$host,$lang,$page,$parn='',$parv=0,$empty=false,$prefix=false){ // print $parn.'|'.$parv; uni_query('UPDATE location SET flag=2, chan=now() WHERE flag=1 AND art='.$art.' AND lang='.adsq($lang)." AND (host='' OR host=".adsq($host).')'.($parn?(' AND parn='.adsq($parn).' AND parv='.adsq($parv)):'')); // print 'UPDATE location SET flag=2, chan=now() WHERE flag=1 AND art='.$art.' AND lang='.adsq($lang); // exit; $location=$this->validateLocation($location,$host,$art,$lang,false,$empty); uni_query('REPLACE INTO location VALUES('.adsq($host).','.adsq($location).','.$art.','.adsq($lang).','.adsq($parn).','.adsq($parv).',1,'.$page.','.($prefix?1:0).',now())'); } function addAlias($art,$location,$host,$lang,$page,$parn='',$parv=0){ if ($this->validateLocation($location,$host,$art,$lang)): uni_query('REPLACE INTO location VALUES('.adsq($host).','.adsq($location).','.$art.','.adsq($lang).','.adsq($parn).','.adsq($parv).',3,'.$page.','.($prefix?1:0).',now())'); return true; else: return false; endif; } function updateLocationManual($ID,$location,$host,$lang,$page){ $this->setLocation($ID,$location,$host,$lang,$page); } function removeLocation($ID){ uni_query('DELETE FROM location WHERE art='.$ID); } //location database queries------------------------------------------------- function getLocation($ID,$lang){ return getValue("SELECT location FROM location WHERE art=".$ID." AND flag=1 ORDER BY lang='".$lang."' DESC"); } function getHost($ID,$lang){ return getValue("SELECT host FROM location WHERE art=".$ID." AND flag=1 ORDER BY lang='".$lang."' DESC"); } function getLink($ID,$lang,$pars='',$mode=0,$pn='',$pv=''){//0 = first cache, then lookup, 1=just cache, 2=ignore deflink $pv=!$pn?'':($pv==-1?$this->parv:$pv);//parameter transfer // print 'Name: '.$pn.', '.$pv; if ($this->deflink and ($mode<>2)): return $this->deflink.'?ID='.$ID.($pars?'&'.$pars:'').($pv?('&'.$pn.'='.$pv):''); else: //searching in cache $location=empty($this->cache[$ID.'-'.$lang.$pv])?'':$this->cache[$ID.'-'.$lang.$pv]; if (empty($location) and ($mode<>1)): // print 'Database lookup...'; // $loc=getRow("SELECT host, location FROM location WHERE art=".adsq($ID)." AND flag=1 ORDER BY".($pv?(' parv='.$pv.' DESC,'):'')." host=".adsq($this->host)." DESC, lang=".adsq($lang)." DESC"); $loc=getRow('SELECT host, location FROM location WHERE art='.adsq($ID).' AND flag=1 ORDER BY parv='.adsq($pv).' DESC, host='.adsq($this->host).' DESC, lang='.adsq($lang).' DESC'); // print "SELECT host, location FROM location WHERE art=".adsq($ID)." AND flag=1 ORDER BY".($pv?(' parv='.$pv.' DESC,'):'')." host=".adsq($this->host)." DESC, lang=".adsq($lang)." DESC"; if (!empty($loc)): $location=(empty($loc['host'])?'':($this->scheme.'://'.$loc['host'])).'/'.$loc['location'].((empty($loc['location']) or ($this->mode==1))?'':'/'); $this->cache[$ID.'-'.$lang.$pv]=$location; endif; endif; //creating link from location if (empty($location)): return false; else: return $location.($pars?((($this->mode==1)?'&':'?').$pars):''); endif; endif; } function loadLinks($arts,$lang){ if (!empty($arts)): $arts=is_array($arts)?implode(',',$arts):$arts; $loc=getTable("SELECT art, lang, host, location FROM location WHERE art IN (".$arts.") AND parn='' ORDER BY host=".adsq($this->host)." ,lang='".$lang."' AND flag=1",1); for ($i=0;$icache[$loc[$i]['art'].'-'.$loc[$i]['lang']]=(empty($loc[$i]['host'])?'':($this->scheme.'://'.$loc[$i]['host'])).'/'.$loc[$i]['location'].((empty($loc[$i]['location']) or ($this->mode==1))?'':'/'); endfor; endif; } function getArt($location,$host='',&$flag){ $res=getRow('SELECT art, page, lang, flag, parn, parv FROM location WHERE (host='.adsq($host).' OR host=\'\') AND (location='.adsq($location).' OR (prefix=1 AND '.adsq($location).' LIKE CONCAT(location,\'%\'))) ORDER BY flag,location='.adsq($location).' DESC',1); $flag=empty($res['flag'])?0:$res['flag']; return $res; } //setting a getting functions--------------------------------------------------------- function setMode($mode,$index=''){ $this->mode=$mode; $this->index=empty($index)?$this->index:$index; } function setDefLink($deflink){ $this->deflink=$deflink; } function setHost($host){ $this->host=$host; } function setPars($parn,$parv){ $this->parn=$parn; $this->parv=$parv; } function getPageHost($page){ return isset($this->pages[$page])?$this->pages[$page]:''; } } ?> setSource($source,$type); } function setSource($source,$type){ $this->source=$source; $this->type=$type; } function exists(){ if ($this->type=='http'): return !empty($_FILES[$this->source]) and is_uploaded_file($_FILES[$this->source]['tmp_name']); else: return file_exists($this->source); endif; } function isImage(){ if (($this->type=='file') and $this->exists()) $info=getimagesize($this->source); return (!empty($info) and ($info[2]==1 or $info[2]==2 or $info[2]==3))?true:false; } function copy($path,$name='*',$extension='*',$activ=false){ $res=false; print($res); if ($this->exists()): $file=pathinfo($this->type=='http'?$_FILES[$this->source]['name']:$this->source); $subor=(($name<>'*')?$name:$file['filename']).(empty($extension)?'':('.'.(($extension<>'*')?$extension:$file['extension']))); if ($this->type=='http'): $res=move_uploaded_file($_FILES[$this->source]['tmp_name'],$path.$subor)?$subor:false; else: $res=copy($this->source,$path.$subor)?$subor:false; endif; if ($this->mask) chmod($path.$subor,$this->mask); if ($activ) $this->setSource($path.$subor,'file'); endif; return $res; } function getName($part=0){ $parts=array(PATHINFO_BASENAME,PATHINFO_EXTENSION,PATHINFO_FILENAME); $res=''; if ($this->exists()): $res=pathinfo($this->type=='http'?$_FILES[$this->source]['name']:$this->source,$parts[$part]); endif; return $res; } function getSize(){ $res=''; if ($this->exists()): $res=($this->type=='http')?$_FILES[$this->source]['size']:filesize($this->source); endif; return $res; } function getHash(){ return (($this->type=='file') and $this->exists())?md5_file($this->source):''; } function getContent(){ return (($this->type=='file') and $this->exists())?file_get_contents($this->source):''; } function del(){ if (($this->type=='file') and $this->exists()) unlink($this->source); } function imageTrans($trans,$comp=95){ global $syscom; if ($this->isImage()): $max=explode(',',$trans); $max_x=empty($max[0])?0:(integer)$max[0]; $max_y=empty($max[1])?0:(integer)$max[1]; $wat=empty($max[2])?0:(integer)$max[2]; $wat_info=empty($wat)?'':getRow("SELECT * FROM watermark WHERE ID='".$wat."'"); if ($max_x or $max_y or !empty($wat_info['ID'])): $obr= new TFoto($this->source); if ($max_x or $max_y): $obr->resize($max_x,$max_y); endif; if (!empty($wat_info['ID'])): $obr->addWaterMark($syscom->getRoot().'/'.$syscom->cfg['wat_path'].$wat_info['ID'].'.png',$wat_info['okraj'],$wat_info['align'],$wat_info['valign']); endif; $obr->write($this->source,$comp,$obr->typ); endif; endif; } public function imageEdit($params) { global $syscom; if (is_numeric($params)): $params=getRow('SELECT * FROM images_01 WHERE ID='.$params); endif; $img = new TFoto($this->source); if ($params['operacia']==TFoto::OPERATION_RESIZE): $img->resize($params['sirka'], $params['vyska']); elseif($params['operacia']==TFoto::OPERATION_CROP): $img->autoCrop($params['sirka'], $params['vyska'], $params['crop']); elseif($params['operacia']==TFoto::OPERATION_BOX): $img->box($params['sirka'], $params['vyska'], $params['pozadie']); endif; $watermark = $syscom->getRoot() . $syscom->cfg['wat_path'] . $params['wat']; if($params['wat'] and file_exists($watermark)): $img->addWaterMark($watermark, $params['okraj'], $params['align'], $params['valign']); endif; $img->write($this->source,95,2); } public function csv2array($src=0){ $file=($src?$src:$this->source); $content=file_get_contents($file); $encoding=(mb_detect_encoding($content, 'UTF-8', true)?1:0); $delims=array(',',';'); $max=0;$del=$delims[0]; foreach($delims as $delim): $count=substr_count($content,$delim); $del=($count>$max)?$delim:$del; $max=max($max,$count); endforeach; $res=array(); if (($handle = fopen($file,'r')) !== FALSE): $i=0; while (($data = fgetcsv($handle, 5000, $del)) !== FALSE) { foreach($data as $key=>$val): $res[$i][$key]=($encoding?$val:iconv('windows-1250','utf-8',$val)); endforeach; $i++; } endif; fclose($handle); return $res; } } ?>running=true; } public function stop(){ $this->running=false; } public function isRunning(){ return $this->running(); } private function addItem($ID,$item,$class){ if($this->running):// and !empty($item) $this->data[$class][$ID]=$item; endif; } private function getItem($class,$ID){ return ($this->running and isset($this->data[$class][$ID]))?$this->data[$class][$ID]:false; } private function getObject($class,$args){ $ID=md5(serialize($args)); $object=$this->getItem($class,$ID); if(!$object): $ref = new ReflectionClass($class); $object = $ref->newInstanceArgs($args); $this->addItem($ID,$object,$class); endif; return $object; } private function getQuery($class,$query,$type=1){ $ID=md5(serialize($query)); $item=$this->getItem($class,$ID); if($item===false): $item=($type==2)?getArray($query,0,2):getValue($query); $this->addItem($ID,$item,$class); endif; return $item; } public function getArtpro(){ return $this->getObject('TArtpro',func_get_args()); } public function getTemplate(){ return $this->getObject('TTemplate',func_get_args()); } public function getArt(){ return $this->getObject('TArt',func_get_args()); } public function getCode($cis,$lang,$ID){ return $this->getQuery('code','SELECT nazov FROM cms_cis_01 WHERE cis='.adsq($cis).' AND ID='.adsq($ID).' AND lang='.adsq($lang)); } public function getCodes($cis,$lang,$ID){ return $this->getQuery('codes','SELECT nazov FROM cms_cis_01 WHERE cis='.adsq($cis).' AND ID IN ('.$ID.') AND lang='.adsq($lang).' ORDER BY poradie',2); } } ?>counter = new TCounter(); if ($this->counter->banned) $this->show404(); $this->setMeta('generator','SysCom Content Management System (www.syscom.sk)'); $this->setMeta('viewport','width=device-width, initial-scale=1, maximum-scale=1'); } function loadInfo($pages){ global $session,$syscom; $this->info=getRow('SELECT * FROM page WHERE ID IN ('.(empty($pages)?0:$pages).') ORDER BY domena='.adsq($syscom->locator->host).' DESC, device='.$syscom->device.' DESC'); if (!empty($this->info['ID'])): $this->comps=unserialize($this->info['comps']); $session->setDefUser($this->info['usr']); //$this->title=$this->info['nadpis']; $this->setMeta('author',$this->info['author']); $this->includes=unserialize($this->info['includes']); //including includes if (!empty($this->includes)): foreach($this->includes as $item): if ($item[2]): if ($item[1]=='css'): $syscom->reqCss($item[0]); else: $syscom->reqJsLib($item[0]); endif; endif; endforeach; endif; if ($this->info['ready']): $syscom->addJsReady($this->info['ready']); endif; endif; } public function setMeta($name,$content){ $this->meta[$name]=$content; } public function setTitle($title){ $this->title=$title.$this->info['nadpis']; } public function setLang($lang){ $this->lang=(preg_match('/[a-z]{2}/',$lang))?$lang:$this->lang; } private function out($text){ $this->out.=($text."\n"); } protected function head(){ global $syscom; if ($this->info['head']): $this->out(''); $this->out(''); $this->out(''); $this->out(''); $this->out(''); $this->out(' '); $this->out(''); $this->out(''); foreach($this->meta as $name=>$content): if($content) $this->out(''); endforeach; //including style sheets foreach($syscom->css as $css) $this->out(''); $this->out(''.$this->title.''); $this->out($this->info['meta_head']); //including javascript libs foreach($syscom->jsLibs as $js) $this->out(''); //adding js document ready if (!empty($syscom->jsReady)): $this->out(''); endif; $this->out(''); endif; } protected function foot(){ $this->out(($this->info['head'])?'':''); } private function myEval($code){ ob_start(); eval('?>'.$code.' 404 Not Found

Not Found

The requested URL was not found on this server.

'; exit; } protected function showArt($ID,$lang='',$parn='',$parv='',$error=false){ global $syscom,$session; $_REQUEST['ID']=$ID; //$this->out('showArt: '.$ID.' | Error: '.($error?'true':'false').'
'); if ($parn): $syscom->locator->setPars($parn,$parv); $_REQUEST[$parn]=$parv; endif; //otvorenie dokuemntu $this->art=new Tart($ID,0,$lang); $this->loadInfo(getInt('pg')?getInt('pg'):$this->art->basic['page']); //$this->art->setAccess($session->uid, $session->grps); $this->art->setAccess($session->identity); if (!$this->art->status or !$this->art->testRead()): return $error?$this->show404():$this->showArt($syscom->cfg['error_page'],$lang,'','',true); endif; //presmerovanie if ($this->art->basic['redir']): //ak je nastavene presmerovanie header ('Location: '.$this->art->basic['redir']); exit; endif; //generating if ($error) header("HTTP/1.1 404 Not Found", true,404); $this->ID=$ID; $this->setLang($this->art->lang); $meta=getRow('SELECT * FROM art_05 WHERE art='.adsq($this->art->basic['ID']).' AND lang='.adsq($this->lang)); $this->setTitle($meta['title']); $this->setMeta('description',$meta['desc']); $this->setMeta('keywords',$meta['keys']); $this->setMeta('robots',$this->art->basic['seo_noindex']?'noindex, nofollow':''); $lm=getArray('SELECT lm.code, lm.term FROM lm WHERE lm.dict=4 AND lm.lang='.adsq($this->lang),0,1); //komponenty $data=array('ART_LANG'=>$this->lang,'ID'=>$this->art->basic['ID']);$comps=array(); if (!empty($this->comps)): foreach ($this->comps as $kod=>$conf): if (!class_exists('cmsComp'.$conf['kod'])) $syscom->reqComp('cmp_'.strtolower($conf['kod'])); $pars=multireplace($conf['pars'],$lm,':',':'); $pars=multireplace($pars,$data,'[',']'); $pars=multireplace($pars,$comps,'{','}'); $class=('cmsComp'.$conf['kod']); $cmp_obj = new $class($conf['kod'],$pars,$data,$session->identity,$this->art); $comps[$kod]=$cmp_obj->run(); $data[$kod]=&$comps[$kod]; endforeach; endif; $data['document']=$this->art->show($this->info['verzia']); $this->counter->setCounter($this->art->basic['ID']); //generovanie stranky $this->head(); $this->out(multireplace(multireplace(multireplace($this->myEval($this->info['body']),$data,'[',']'),$comps,'{','}'),$lm,':',':')); $this->foot(); } public function generate(){ global $syscom,$session; //cache test---------------- /* $syscom->reqLib('uni_cache'); $cache=new TCache(); $content=$cache->getPage($session->eid,'//'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); if (!($content===false)) return $content;*/ //-------------------------- $location=trim(parse_url($_SERVER['REQUEST_URI'],PHP_URL_PATH),'/'); $host=$_SERVER['HTTP_HOST']; $zaz=$syscom->locator->getArt($location,$host,$flag); if(!$zaz): $location?$this->showArt($syscom->cfg['error_page'],'','','',true):$this->showArt($syscom->reg['default_art']); else: if ($flag==1): $this->showArt($zaz['art'],$zaz['lang'],$zaz['parn'],$zaz['parv']); elseif (($flag==2) or ($flag==3)): $link=$syscom->locator->getLink($zaz['art'],$zaz['lang']); $pars=$_GET; unset($pars['ID']);unset($pars['l']);unset($pars['cms_location']); $pars=http_build_query($pars); header('Location: '.$link.(empty($pars)?'':('?'.$pars)),true,301); endif; endif; //cache test---------------- //$cache->addPage($session->eid,'//'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'],$this->out); //-------------------------- //debug mode if (!empty($syscom->cfg['debug_mode'])) $GLOBALS['debug']->end(); return $this->out; } } ?>info['host']=empty($_SERVER['HTTP_HOST'])?'':$_SERVER['HTTP_HOST']; $this->info['url']=empty($_SERVER['REQUEST_URI'])?'':$_SERVER['REQUEST_URI']; $this->info['page_from']=empty($_SERVER['HTTP_REFERER'])?'':$_SERVER['HTTP_REFERER']; $this->info['IP']=empty($_SERVER['REMOTE_ADDR'])?'':$_SERVER['REMOTE_ADDR']; $this->info['browser']=empty($_SERVER['HTTP_USER_AGENT'])?'':$_SERVER['HTTP_USER_AGENT']; //user type $this->info['typ']=getValue("SELECT typ FROM counter_06 WHERE typ IN (1,2,3) AND ('".addslashes($this->info['IP'])."' LIKE CONCAT(pat,'%') OR '".addslashes($this->info['browser'])."' LIKE CONCAT('%',pat,'%'))"); $this->info['typ']=empty($this->info['typ'])?1:$this->info['typ']; //banned user $this->banned=$this->info['typ']==3; $this->den=date("Y-m-d"); } private function setCounterSess($page,$art) { global $session; $platnost=2678400; //3600*24*31 = 31 dni $new_sess=0; $test=getRow('SELECT ID,sess FROM counter_05 WHERE IP='.adsq($this->info['IP']).' AND den='.adsq($this->den).' LIMIT 1'); //updating counter_01 - session log if ($session->emp('cnt_id') or ($session->getVar('cnt_den')<>$this->den)): //session este nie je registrovana $data=adsq($this->info); if ($this->info['typ']==1): //bezny uzivatel $clientInfo=adsq(parseClientInfo($this->info['page_from'],$this->info['browser'])); $result=uni_query('INSERT INTO counter_01 VALUES(0,'.$data['typ'].','.$data['host'].','.$data['url'].','.$data['page_from'].','.$data['IP'].','.adsq($session->sid).','.$data['browser'].',now(),'.adsq($page).','.$art.','.$clientInfo['host'].','.$clientInfo['key'].','.$clientInfo['browser'].')'); $cnt_id=mysql_insert_id(); $session->setVar('cnt_id',$cnt_id); $session->setVar('cnt_den',$this->den); $new_sess=1; else: //robot // $test=getRow("SELECT ID, sess FROM counter_05 WHERE session='".$this->info['IP']."' AND den='".$den."' ORDER BY ID DESC LIMIT 1"); if ($test['ID']): $cnt_id=$test['sess']; else: $result=uni_query("INSERT INTO counter_01 VALUES('0',".$data['typ'].",".$data['host'].",".$data['url'].",".$data['page_from'].",".$data['IP'].",'".addslashes($session->sid)."',".$data['browser'].",now(),'".$page."','".$art."','','','')"); $cnt_id=mysql_insert_id(); $new_sess=1; endif; endif; else: $cnt_id=$session->getVar('cnt_id'); endif; //updating counter_03 - daily preview uni_query("UPDATE counter_03 SET IP_count=IP_count+".(empty($test['ID'])?1:0).", sess_count=sess_count+".$new_sess.", page_count=page_count+1 WHERE typ='".$this->info['typ']."' AND host='".addslashes($this->info['host'])."' AND den='".$this->den."'"); if (!mysql_affected_rows()) uni_query("INSERT INTO counter_03 VALUES(0,'".$this->info['typ']."','".addslashes($this->info['host'])."','".$this->den."',1,1,1)"); //updating counter_05 - daily session and IP log if (empty($test['ID'])): uni_query("INSERT INTO counter_05 VALUES(0,'".$cnt_id."','".$this->den."','".$this->info['IP']."')"); endif; //removing old logs if (mod($cnt_id,500)==0): $cas=stamp2time(time()-$platnost); uni_query ("DELETE FROM counter_01 WHERE datum<'".$cas."'"); uni_query ("DELETE FROM counter_02 WHERE cas<'".$cas."'"); //uni_query ("DELETE FROM counter_05 WHERE den+ INTERVAL 120000 SECOND < now()"); uni_query ("DELETE FROM counter_05 WHERE den < now() - INTERVAL 120000 SECOND"); endif; return $cnt_id; } public function setCounter($page,$art=0){ global $page; $lang=empty($page->lang)?'--':$page->lang; $art=empty($page->art)?0:$page->art->basic['ID']; $sess=$this->setCounterSess($page->info['ID'],$art); //updating counter_02 - view log uni_query('INSERT INTO counter_02 VALUES(0,'.adsq($sess).','.$page->info['ID'].',now(),'.adsq($lang).','.$art.','.adsq($this->par).')'); uni_query("UPDATE counter_04 SET pocet=pocet+1 WHERE den='".$this->den."' AND host='".addslashes($this->info['host'])."' AND art='$art' AND typ='".$this->info['typ']."'"); if (!mysql_affected_rows()) uni_query("INSERT INTO counter_04 VALUES(0,'".$this->info['typ']."','".addslashes($this->info['host'])."','".$this->den."','$art',1)"); } public function setPar($par){ $this->par.=$par; } } ?>data=getRow('SELECT * FROM artpro WHERE ID='.intVal($ID)); if ($this->data): $this->polia=getArray('SELECT artpro_01.meno, artpro_01.*, artpro_02.aktiv FROM artpro_01, artpro_02 WHERE artpro_01.typ=artpro_02.ID AND artpro='.$this->data['ID'].' ORDER BY poradie'); $this->basic=&$this->data; endif; } public function exists(){ return !empty($this->data); } public function getField($name){ return isset($this->polia[$name])?$this->polia[$name]:null; } public function getFormTemplate($fld_list=''){ $res=''; if (empty($fld_list) or !empty($fld_list['nazov'])): $res='[nazov,1][nazov][nazov,2]'."\n"; endif; foreach($this->polia as $meno=>$p): $ameno='art_'.$meno; if (empty($fld_list) or !empty($fld_list[$meno])): $res.='['.$ameno.',1]['.$ameno.']['.$ameno.',2]'."\n"; endif; endforeach; return $res; } public function addForm(&$form,$verzia='',$fld_list=''){ $sabl= new TTemplate($this->data['sablona2'],$form->lang,2,$verzia); $sabl1=''; $form->addHidden('artpro',$this->data['ID']); $form->addHidden('nadrad',0); $form->addHidden('ID',0); if (empty($fld_list) or !empty($fld_list['nazov'])): $form->addComp(new TFrmField($this->data['popiska'].':','nazov','',1,255,1,'')); $sabl1.=$form->comp['nazov']->getTemplate(); endif; foreach($this->polia as $meno=>$p): $ameno='art_'.$meno; if (empty($fld_list) or !empty($fld_list[$meno])): if ($p['typ']==1): $form->addComp(new TFrmField($p['popiska'].':',$ameno,$p['def'],$p['styl'],$p['dlzka'],$p['pov'],'')); elseif ($p['typ']==2): $form->addComp(new TFrmField($p['popiska'].':',$ameno,$p['def'],$p['styl'],15,$p['pov'],'int')); elseif ($p['typ']==3): $form->addComp(new TFrmField($p['popiska'].':',$ameno,$p['def'],$p['styl'],15,$p['pov'],($p['par1']=='floattime')?'floattime':'float')); elseif ($p['typ']==4): $form->addComp(new TFrmField($p['popiska'].':',$ameno,$p['def'],$p['styl'],10,$p['pov'],'date')); elseif ($p['typ']==5): $form->addComp(new TFrmField($p['popiska'].':',$ameno,$p['def'],$p['styl'],5,$p['pov'],'time')); elseif ($p['typ']==6): $form->addComp(new TFrmField($p['popiska'].':',$ameno,$p['def'],$p['styl'],17,$p['pov'],'datetime')); elseif ($p['typ']==7): $form->addComp(new TFrmField($p['popiska'].':',$ameno,$p['def'],$p['styl'],$p['dlzka'],$p['pov'],'email')); elseif ($p['typ']==8): $form->addComp(new TFrmField($p['popiska'].':',$ameno,$p['def'],$p['styl'],$p['dlzka'],$p['pov'],'emails')); elseif ($p['typ']==9): $form->addComp(new TFrmText($p['popiska'].':',$ameno,$p['def'],$p['styl'],$p['pov'],$p['par1'])); elseif ($p['typ']==10): $form->addComp(new TFrmHTMLArea($p['popiska'].':',$ameno,$p['def'],$p['styl'],$p['pov'],$p['par1'],$p['par2'])); elseif ($p['typ']==11): $form->addComp(new TFrmFile($p['popiska'].':',$ameno,$p['styl'],$p['pov'],$p['par1'],$p['par3'])); $form->enctype='multipart/form-data'; elseif ($p['typ']==12): $form->addComp(new TFrmCheck($p['popiska'].':',$ameno,$p['def'],1,$p['pov'])); elseif ($p['typ']==13): $form->addComp(new TFrmCMSList($p['popiska'].':',$ameno,$p['par1'],$p['def'],$p['styl'],$p['pov'],$p['par2'],$p['par3'])); if (!empty($p['par2'])){ $form->refs[$ameno]='art_'.$p['par2'];}; elseif ($p['typ']==14): $form->addComp(new TFrmOptionList($p['popiska'].':',$ameno,getTable('SELECT ID, nazov FROM cms_cis_01 WHERE cis='.adsq($p['par1']).' AND lang='.adsq($form->lang).' ORDER BY '.(empty($p['par2'])?'poradie':'nazov'),false),$p['def'])); elseif ($p['typ']==15): if ($p['par1']==2): $form->addComp(new TFrmCaption($ameno,$p['popiska'],'')); elseif ($p['par1']==3): $form->addComp(new TFrmInfoText($ameno,$p['popiska'],0)); else: $form->addComp(new TFrmNotice($ameno,$p['popiska'],1)); endif; elseif ($p['typ']==17): $form->addComp(new TFrmField($p['popiska'].':',$ameno,$p['def'],$p['styl'],255,$p['pov'],'')); elseif ($p['typ']==18): $form->addComp(new TFrmCMSDoc($p['popiska'].':',$ameno,$p['def'],$p['pov'],$p['par2'],$p['par3'],$p['par4'])); elseif ($p['typ']==19): $form->addComp(new TFrmCMSDocs($p['popiska'].':',$ameno,$p['def'],$p['pov'],$p['par2'],$p['par3'],$p['par4'])); elseif ($p['typ']==20): $form->addComp(new TFrmDiskFile($p['popiska'].':',$ameno,$p['def'],$p['styl'],$p['pov'],$p['par1'])); elseif ($p['typ']==21): $form->addComp(new TFrmUser($p['popiska'].':',$ameno,$p['def'],$p['styl'],$p['pov'],'',$p['par1'])); elseif ($p['typ']==22): $form->addComp(new TFrmCMSCheckArray($p['popiska'].':',$ameno,getTable('SELECT ID, nazov FROM cms_cis_01 WHERE cis='.adsq($p['par1']).' AND lang='.adsq($form->lang).' ORDER BY poradie',false),$p['def'],$p['par4'])); elseif ($p['typ']==23): $form->addComp(new TFrmCMSDocList($p['popiska'].':',$ameno,$p['def'],$p['styl'],$p['pov'],$p['par2'],$p['par3'],1)); endif; $sabl1.=$form->comp[$ameno]->getTemplate(); endif; endforeach; $form->sabl.=(!empty($sabl->info['ID']))?$sabl->generate(array()):$sabl1; } public function setProfile(&$form,$profile){ $info=getRow('SELECT * FROM artpro_05 WHERE ID='.adsq($profile)); if ($info): $data=unserialize($info['conf']); //nazov if (isset($data['nazov_right'])): $form->setFieldStatus('nazov',$data['nazov_right']); endif; if (isset($data['nazov_pov'])): $form->setFieldPov('nazov',$data['nazov_pov']); endif; //polia foreach($this->polia as $meno=>$pole): if (isset($data[$meno.'_right'])): $form->setFieldStatus('art_'.$meno,$data[$meno.'_right']); endif; if (isset($data[$meno.'_pov'])): $form->setFieldPov('art_'.$meno,$data[$meno.'_pov']); endif; endforeach; //editovacia sablona $sabl=false; if ($info['temp']): $temp= new TTemplate($this->data['sablona2'],$form->lang,2,$info['temp']); if (!empty($temp->info['ID'])): $sabl.=$form->comp['ID']->getTemplate(); $sabl.=$form->comp['artpro']->getTemplate(); $sabl.=$form->comp['nadrad']->getTemplate(); $sabl.=$temp->generate(array()); endif; endif; $form->setTemplate($sabl); endif; } /* function getForm($nadpis=''){//depricated ---- pouzivat addForm $form = new TFrm; if ($nadpis) $form->addCaption($nadpis); $this->addForm($form,'sk'); return $form; } */ public function getTemplate($typ){ if ($typ==2): $res=$this->getFormTemplate(); else: $res='

[nazov]


'."\n"; $res.=''."\n"; foreach($this->polia as $meno=>$pole) $res.=($pole['aktiv'])?(''."\n"):''; $res.='
'.$pole['popiska'].':['.$meno.']
'; endif; return $res; } /*function getEditTemplate(){ }*/ public function pole2www($pole, $prefix_in='art_',$prefix_out='art_',$lang='sk',$path=''){ global $cfg,$syscom; $path=empty($path)?$cfg['att_path']:$path; $anonie['sk']=array('Nie','Áno'); $anonie['en']=array('No','Yes'); $anonie['de']=array('Nein','Ja'); $res['nazov']=$pole['nazov']; foreach($this->polia as $meno=>$p): $imeno=$prefix_in.$meno; $omeno=$prefix_out.$meno; if (isset($pole[$imeno])): if (($p['typ']==3) and ($p['par1']=='floattime')) $res[$omeno]=float2time($pole[$imeno]); elseif ($p['typ']==4) $res[$omeno]=mydate(testDatum($pole[$imeno])); elseif ($p['typ']==5) $res[$omeno]=mytime(testCas($pole[$imeno])); elseif ($p['typ']==6) $res[$omeno]=mydatetime(testDatumCas($pole[$imeno])); elseif ($p['typ']==9) $res[$omeno]=empty($p['par2'])?nl2br($pole[$imeno]):$pole[$imeno]; elseif ($p['typ']==12) $res[$omeno]=$anonie[$lang][empty($pole[$imeno])?0:1]; elseif ($p['typ']==13) $res[$omeno]=getValue('SELECT nazov FROM cms_cis_01 WHERE cis='.adsq($p['par1']).' AND ID='.intVal($pole[$imeno]).' AND lang='.adsq($lang)); elseif ($p['typ']==14) $res[$omeno]=getValue('SELECT nazov FROM cms_cis_01 WHERE cis='.adsq($p['par1']).' AND ID='.intVal($pole[$imeno]).' AND lang='.adsq($lang)); elseif ($p['typ']==18){ if (!empty($pole[$imeno])): //$doc= new TArt($pole[$imeno]); $doc= $syscom->storage->getArt($pole[$imeno]); $res[$omeno]=$doc->show(empty($p['par1'])?'':$p['par1'],$lang); endif; } elseif ($p['typ']==22){ $hod=getArray('SELECT nazov FROM cms_cis_01 WHERE cis='.adsq($p['par1']).' AND ID IN ('.(empty($pole[$imeno])?"''":$pole[$imeno]).') AND lang='.adsq($lang),0,2); $res[$omeno]=implode(', ',$hod); } else $res[$omeno]=$pole[$imeno]; endif; endforeach; return $res; } public function www2db($data, $prefix_in='art_',$prefix_out='art_',$lang='sk',$db=0){ $res['nazov']=$db?adsq($data['nazov']):$data['nazov']; foreach($this->polia as $meno=>$pole): if (isset($data[$prefix_in.$meno])): if ($pole['typ']==2) $res[$prefix_out.$meno]=str_replace(' ','',$data[$prefix_in.$meno]); elseif ($pole['typ']==3) $res[$prefix_out.$meno]=str_replace(array(' ',','),array('','.'),$data[$prefix_in.$meno]); elseif ($pole['typ']==4) $res[$prefix_out.$meno]=testDatum($data[$prefix_in.$meno]); elseif ($pole['typ']==5) $res[$prefix_out.$meno]=testCas($data[$prefix_in.$meno]); elseif ($pole['typ']==6) $res[$prefix_out.$meno]=testDatumCas($data[$prefix_in.$meno]); else $res[$prefix_out.$meno]=$data[$prefix_in.$meno]; $res[$prefix_out.$meno]=$db?adsq($res[$prefix_out.$meno]):$res[$prefix_out.$meno]; endif; endforeach; return $res; } public function uploadFiles(&$zaznam,$cesta,$ID){ foreach ($this->polia as $meno=>$pole): if ($pole['typ']==11): $file = new FileObject('art_'.$meno,'http'); $zaznam['art_'.$meno]=($file->exists())?$file->copy($cesta,$ID.'_'.$meno,'*',true):''; endif; endforeach; } //SEARCHING -------------------------------------------------------------- public function addSearchForm(&$frm,$lm,$temp='',$keyword=false,$hidden=array(),$pars=array()){ global $syscom; //laguage $sabl=''; $fields=array(); //keyword if ($keyword): $frm->addComp(new TFrmField($keyword,'search','',4,255,0,'')); $sabl.=$frm->comp['search']->getTemplate(); endif; //nazov if (($this->basic['krit']>1) and !in_array('nazov',$hidden)): $frm->addComp(new TFrmField($this->data['popiska'].':','nazov','',4,255,0,'')); $sabl.=$frm->comp['nazov']->getTemplate(); endif; //polia foreach($this->polia as $meno=>$p): $ameno='art_'.$meno; if (($p['krit']>1) and !in_array($meno,$hidden)): $fields[$meno]=1; if ($p['krit']==2 or $p['krit']==7)://Klucove slovo alebo fulltext if ($p['typ']==18): $frm->addComp(new TFrmCMSDoc($p['popiska'].':',$ameno,'',0,$p['par2'],$p['par3'],$p['par4'])); else: $frm->addComp(new TFrmField($p['popiska'].':',$ameno,'',$p['styl'],$p['dlzka'],0,'')); endif; $sabl.=$frm->comp[$ameno]->getTemplate(); elseif ($p['krit']==3)://Rozsah $frm->addComp(new TFrmField($p['popiska'].':',$ameno.'_od','',5,15,0,($p['typ']==4 || $p['typ']==6)?'date':'')); $frm->addComp(new TFrmField($p['popiska'].':',$ameno.'_do','',5,15,0,($p['typ']==4 || $p['typ']==6)?'date':'')); $sabl.='['.$ameno.'_od'.',1]'.$syscom->lm('Od').': ['.$ameno.'_od'.'] '.$syscom->lm('Do').': ['.$ameno.'_do'.']'; elseif ($p['krit']==4)://Roletka if ($p['typ']==12): //check Box $zoznam=array(array('1','Áno'),array('2','Nie')); $frm->addComp(new TFrmList($p['popiska'].':',$ameno,$zoznam,'',3,0)); $sabl.=$frm->comp[$ameno]->getTemplate(); elseif ($p['typ']==13): //combo alebo option list if (empty($fields[$p['par2']])) {$p['par2']='';}; $frm->addComp(new TFrmCMSList($p['popiska'].':',$ameno,$p['par1'],'0',$p['styl'],0,$p['par2'],$p['par3'])); if (!empty($p['par2'])){ $frm->refs[$ameno]='art_'.$p['par2'];}; $sabl.=$frm->comp[$ameno]->getTemplate(); elseif (($p['typ']==14) or ($p['typ']==22)): //combo alebo option list $frm->addComp(new TFrmList($p['popiska'].':',$ameno,getTable('SELECT ID, nazov'.(empty($p['par2'])?'':', skup').' FROM cms_cis_01 WHERE cis=\''.$p['par1'].'\' AND lang=\''.$frm->lang.'\' ORDER BY poradie'),'0',($p['typ']==14?3:$p['styl']),0)); if (!empty($p['par2'])){ $frm->refs[$ameno]='art_'.$p['par2'];}; $sabl.=$frm->comp[$ameno]->getTemplate(); elseif ($p['typ']==21): //uzivatel if (empty($p['par1'])): $zoznam=getTable('SELECT ID, CONCAT(priez,\' \',meno) FROM usr WHERE stav=1 ORDER BY priez, meno'); else: $zoznam=getTable('SELECT usr.ID, CONCAT(usr.priez,\' \',usr.meno) FROM usr, usr_01 WHERE usr.ID=usr_01.usr AND usr_01.grp='.$p['par1'].' AND usr.stav=1 ORDER BY priez, meno'); endif; $frm->addComp(new TFrmList($p['popiska'].':',$ameno,$zoznam,'0',$p['styl'],0)); $sabl.='['.$ameno.',1]['.$ameno.']'; elseif ($p['typ']==23): $frm->addComp(new TFrmCMSDocList($p['popiska'].':',$ameno,0,$p['styl'],0,$p['par2'],$p['par3'])); $sabl.=$frm->comp[$ameno]->getTemplate(); endif; elseif ($p['krit']==5): //vyber aktualnych hodnot if (($p['typ']==18) or $p['typ']==23): $zoznam=getTable('SELECT DISTINCT art.ID, art.nazov FROM art, art_o'.$this->data['ID']." AS dat WHERE art.ID=dat.art_".$meno." ORDER BY nazov",false); $frm->addComp(new TFrmList($p['popiska'].':',$ameno,$zoznam,'',4,0)); $sabl.='['.$ameno.',1]['.$ameno.']'; elseif ($p['typ']==1): $zoznam=getTable('SELECT DISTINCT '.$ameno.','.$ameno.' FROM art, art_o'.$this->data['ID'].' AS dat WHERE art.ID=dat.ID ORDER BY '.$ameno,false); $frm->addComp(new TFrmList($p['popiska'].':',$ameno,$zoznam,'',4,0)); $sabl.='['.$ameno.',1]['.$ameno.']'; endif; elseif($p['krit']==6): $frm->addComp(new TFrmCheckArray($p['popiska'].':',$ameno,getTable('SELECT ID, nazov FROM cms_cis_01 WHERE cis='.adsq($p['par1']).' AND lang='.adsq($frm->lang).' ORDER BY poradie',false),'',2,0)); $sabl.='['.$ameno.',1]['.$ameno.']'; endif; endif; endforeach; $frm->sabl.=empty($temp)?$sabl:$temp; //hidden pars foreach($pars as $par): if (isset($_REQUEST[$par])) $frm->addHidden($par,getString($par)); endforeach; } private function getValue($nazov,$typ=0){ if (($typ==0) or ($typ==1) or ($typ==3) or ($typ==7) or ($typ==8) or ($typ==9) or ($typ==10)): $val=getString($nazov); elseif (($typ==2) or ($typ==12) or ($typ==13) or ($typ==14) or ($typ==18) or ($typ==19) or ($typ==21) or ($typ==22) or ($typ==23)): $val=getInt($nazov); elseif ($typ==4): $val=testDatum(getString($nazov)); elseif ($typ==5): $val=testCas(getString($nazov)); elseif ($typ==6): $val=trim(substr(testDatumCas(getString($nazov)),0,10)); else: $val=getString($nazov) ; endif; return $val; } private function prepareFulltext($search){ $search=explode(' ',$search); $words=array(); foreach ($search as $s): if (trim($s)): $words[].='+'.trim($s); endif; endforeach; return implode(' ',$words); } private function addPod($nazov,$val,$spojka){ //criterial search if (!empty($val)): if ($spojka=='LIKE'): $this->pod[]=$nazov.' '.$spojka." '%".ads($val)."%'"; elseif ($spojka=='FIND_IN_SET'): $this->pod[]='FIND_IN_SET('.adsq($val).','.$nazov.')'; elseif ($spojka=='MULTIFIND_IN_SET'): $pod=array(); foreach($val as $item): $pod[]='FIND_IN_SET('.adsq($item).','.$nazov.')'; endforeach; $this->pod[]='('.implode(') OR (',$pod).')'; elseif ($spojka=='MATCH'): $this->pod[]='MATCH '.$nazov.' AGAINST ('.adsq($this->prepareFulltext($val)).' IN BOOLEAN MODE)'; elseif ($spojka=='BOOL'): $this->pod[]=$nazov.' = '.($val=='1'?1:0); else: $this->pod[]=$nazov.' '.$spojka.' '.adsq($val); endif; endif; //common search if (trim(getString('search'))): if ($spojka=='LIKE'): $this->search[]=$nazov.' '.$spojka." '%".ads(getString('search'))."%'"; elseif ($spojka=='MATCH'): $this->search[]='MATCH '.$nazov.' AGAINST ('.adsq($this->prepareFulltext(getString('search'))).' IN BOOLEAN MODE)'; endif; endif; } private function getPod(){ $search=empty($this->search)?'':('('.implode(') OR (',$this->search).')'); $pod=$this->pod; if ($search) $pod[]=$search; return empty($pod)?'':('('.implode(') AND (',$pod).')'); } public function getWhere(){ $this->pod=array(); $this->search=array(); if (($this->basic['krit']>1)): $this->addPod('nazov',$this->getValue('nazov',1),'LIKE'); endif; foreach($this->polia as $meno=>$pole): $ameno='art_'.$pole['meno']; if ($pole['krit']==2)://Klucove slovo if (($pole['typ']==1) or ($pole['typ']==7)or ($pole['typ']==8)or ($pole['typ']==9) or ($pole['typ']==10)): $this->addPod($ameno,$this->getValue($ameno,$pole['typ']),'LIKE'); else: $this->addPod($ameno,$this->getValue($ameno,$pole['typ']),'='); endif; elseif ($pole['krit']==3)://Rozsah if ($pole['typ']==6): $this->addPod('LEFT(art_'.$pole['meno'].',10)',$this->getValue($ameno.'_od',$pole['typ']),'>='); $this->addPod('LEFT(art_'.$pole['meno'].',10)',$this->getValue($ameno.'_do',$pole['typ']),'<='); else: $this->addPod($ameno,$this->getValue($ameno.'_od',$pole['typ']),'>='); $this->addPod($ameno,$this->getValue($ameno.'_do',$pole['typ']),'<='); endif; elseif (($pole['krit']==4) or ($pole['krit']==5))://Roletka if ($pole['typ']==12): //check Box $this->addPod($ameno,$this->getValue($ameno,$pole['typ']),'BOOL'); elseif ($pole['typ']==22): //zoznam check boxov $this->addPod($ameno,$this->getValue($ameno,$pole['typ']),'FIND_IN_SET'); else://if (($pole['typ']==13) or ($pole['typ']==14)): //combo alebo option list $this->addPod($ameno,$this->getValue($ameno,$pole['typ']),'='); endif; elseif ($pole['krit']==6 and getGlobal($ameno)): $this->addPod($ameno,getGlobal($ameno),'MULTIFIND_IN_SET'); elseif ($pole['krit']==7)://Klucove slovo $this->addPod($ameno,$this->getValue($ameno,$pole['typ']),'MATCH'); endif; endforeach; return $this->getPod(); } } ?> status=0; //print 'Usr:'.$usr.'
'; if(is_object($usr)): //pristupove prava $this->identity=$usr; $this->setUser($this->identity->getUser(),$this->identity->getGroups()); $this->wuid=$this->identity->getWebUser(); else: //pristupove prava $this->identity= new Identity(getValue('SELECT ID FROM entity WHERE type=2 AND fid='.$usr)); $this->setUser($usr,$grps); $this->wuid=$wusr; endif; if(is_numeric($ID)): //initializing basic data if (!empty($ID) and empty($artpro)): //loading document from db $this->basic=getrow("SELECT * FROM art WHERE ID='$ID'",1); if ($this->basic['ID']): $this->data=getrow("SELECT * FROM art_o".$this->basic['artpro']." WHERE ID='$ID'",1); $this->status=1; endif; elseif(!empty($ID) and !empty($artpro)): //creating document $this->status= $this->initDocument($ID, $artpro)?1:0; endif; elseif(is_array($ID)): $this->data=$ID; $this->basic=&$this->data; $this->status=1; elseif(is_object($ID)): $this->artpro=$ID; $this->status=$this->initDocument($lang,$this->artpro->basic['ID']); endif; //initializing computed data if ($this->status): $this->ID=$this->basic['ID']; $this->setRights($usr,$grps); $this->files_path=(empty($syscom)?$_SERVER['DOCUMENT_ROOT']:$syscom->reg['doc_root']).'/'.$cfg['att_path']; //$this->artpro= empty($this->artpro)?new TArtPro($this->basic['artpro']):$this->artpro; $this->artpro= empty($this->artpro)?$syscom->storage->getArtpro($this->basic['artpro']):$this->artpro; $this->polia= &$this->artpro->polia; $this->lang=substr($this->basic['lang'],0,2); $this->lang=(!empty($lang) and !(strpos($this->basic['lang'],$lang)===false))?$lang:$this->lang; $this->runAction($this->artpro->basic['akcia'.(empty($this->ID)?1:2)]); endif; // print 'Write '.$this->ID.': '.$this->right_write.'|'; } //Private functions--------------------------------------------------------------------------- function initDocument($nad,$artpro){//initializing new document - setting default variables $usr=getRow("SELECT ID, grp FROM usr WHERE ID=".$this->uid); $nadrad=new TArt($nad,$this->uid,$this->lang,$this->grps,0,$this->wuid); $artpro=getRow('SELECT ID, pub, pub_time, uright, gright, wuright, mask, default_usr, default_grp, default_pub, default_wusr FROM artpro WHERE ID='.$artpro); // print 'Nadradeny?: '.$nadrad->basic['ID']; // print 'Pridavanie nadradeny?: '.$nadrad->testAdd(); if ($nadrad->status and $nadrad->testAdd() and !empty($artpro['ID'])): //empty default values $this->basic=array('ID'=>0,'nadrad'=>0,'artpro'=>0,'sablona'=>'','lang'=>'','nazov'=>'','page'=>0, 'redir'=>'','radenie'=>'poradie','poradie'=>0,'links'=>'','files'=>'','comp'=>0,'comps'=>'','subartpro'=>0, 'usr'=>0,'grp'=>0,'pub'=>0,'uright'=>0,'gright'=>0,'pright'=>'0','time_from'=>'', 'version'=>0, 'time_to'=>'','chan_usr'=>0,'seo_link'=>'','seo_title'=>'','seo_desc'=>'','seo_keys'=>'','seo_manual'=>0,'crea'=>'','chan'=>''); $this->basic['nadrad']=$nadrad->basic['ID']; $this->basic['artpro']=$artpro['ID']; //linka a jaz. mutacia - dedi sa z nadradeneho $this->basic['lang']=$nadrad->basic['lang']; $this->basic['page']=$nadrad->basic['page']; //poradie $this->basic['poradie']=0; //zobrazenie //nastavenie vlastnikov a prav if (!empty ($artpro['default_usr'])){ $this->basic['usr']=$artpro['default_usr']; }else{ $this->basic['usr']=$usr['ID']; } $this->basic['chan_usr']=$usr['ID']; if ($artpro['mask']== 1 OR $artpro['mask']== 3){ if (!empty ($artpro['uright'])) { $this->basic['uright']=$artpro['uright'];} }else{ $this->basic['uright']="15"; } $this->basic['grp']=empty ($artpro['default_grp'])?$nadrad->basic['grp']:$artpro['default_grp']; $this->basic['gright']=($artpro['mask']== 2 OR $artpro['mask']== 3)?$artpro['gright']:$nadrad->basic['gright']; $this->basic['wuright']=(($artpro['mask']&4)==4)?$artpro['wuright']:$nadrad->basic['wuright']; $this->basic['wusr']=$this->wuid; // else: // $this->basic['grp']=$usr['grp']; // $this->basic['gright']=3; // endif; if (empty ($artpro['default_pub'])){ $this->basic['pub']=$nadrad->basic['pub']; }else{ $this->basic['pub']=$artpro['default_pub']; } $this->basic['pright']=$artpro['pub']; if ($this->basic['pright']==3): $this->basic['time_from']=stamp2time(time()); $this->basic['time_to']=stamp2time(time()+$artpro['pub_time']*3600); endif; //nastavenia $this->basic['crea']=stamp2time(time());//'now()'; $this->basic['chan']=stamp2time(time());//'now()'; //data return true; else: return false; endif; } function saveBasic(){ //saves common attributes setRow('art',pole2db($this->basic),'ID'); } function runAction($ID){ global $syscom; if($action=$syscom->getAction($ID)): $action->setArt($this); $action->run(); return $action->getLog(); endif; } function setNadradene($ID){ //zmazem vsetky odkazy na nadradene uni_query("DELETE FROM art_01 WHERE art=$ID"); //zistim nadradenu skupinu $nadrad=getrow("SELECT nadrad FROM art WHERE ID=$ID"); $nadrad=$nadrad["nadrad"]; //pridam odkaz na vsetky nadradene nadradenej skupiny $nadradene=gettable("SELECT nadrad FROM art_01 WHERE art='$nadrad' AND typ>0"); //vsetky nadradene skupiny nadradenej skupiny for ($i=0;$isetNadradene($ID); //zoberiem vsetky priame podradene skupiny a nastavim ich $podr=gettable("SELECT ID FROM art WHERE nadrad=$ID"); for ($i=0;$isetArt($podr[$i]["ID"]); endfor; } //Public functions---------------------------------------------------------------------------- //Content operations function documentFilter(){ //run filter on document fields a update it global $cfg; //uprava absolutnych liniek $this->data=preg_replace('#((http[s]{0,1}://){0,1}[a-z:A-Z0-9_\/.-]*)(\[|\%5B)([f|l|n|i|c|r]{0,2}[0-9]+)(\]|\%5D)([/]{0,1})#','[\\4]',$this->data); //uprava liniek na subory $this->data=preg_replace('#((http[s]{0,1}://){0,1}[a-z:A-Z0-9_\/.-]*/'.$cfg['file_path'].')([0-9]+)(_[a-zA-Z0-9_-]+)\.([a-zA-Z0-9_-]{1,4})#','[f\\3]',$this->data); //hladanie liniek a suborov pouzitych v dokumente $this->basic['links']=array(); $this->basic['files']=array(); if (!empty($this->data)): foreach ($this->data as $key => $value) { //linky preg_match_all('(\[\d*\])',$value,$najdene); $this->basic['links']=array_merge($this->basic['links'],$najdene[0]); //subory preg_match_all('(\[f\d*\])',$value,$najdene); $this->basic['files']=array_merge($this->basic['files'],$najdene[0]); } endif; $this->basic['links']=str_replace(array('[',']'),array('',''),implode(',',array_unique($this->basic['links']))); $this->basic['files']=str_replace(array('[',']','f'),array('','',''),implode(',',array_unique($this->basic['files']))); } function getValue($name){ return ($name=='nazov')?$this->basic['nazov']:(!isset($this->data['art_'.$name])?'':$this->data['art_'.$name]); } function setValue($name,$value,$write=false){ global $cfg; if ($this->testWrite()): $this->basic['chan']=stamp2time(time()); $this->basic['chan_usr']=$this->uid; if ($name=='nazov'): $this->basic['nazov']=$value; else: $this->data['art_'.$name]=$value; endif; if ($write and $this->ID): $this->documentFilter(); if ($name<>'nazov'): uni_query('UPDATE art_o'.$this->basic['artpro'].' SET art_'.$name."='".addslashes($this->data['art_'.$name])."' WHERE ID=".$this->ID); endif; $this->saveBasic(); $search = new TArtTools(); $search->searchIndex($this); /* $search = new TSearch(); $search->index($this->basic['ID'],$this->uid);*/ endif; endif; } public function getValues($db=0,$prefix='art_'){//0-bezna zobrazovacia forma (editovaci formular),1-prezapis do db,2-vystup na www global $cfg,$syscom; $anonie['sk']=array('Nie','Áno'); $anonie['en']=array('No','Yes'); $anonie['cz']=array('Ne','Ano'); $anonie['de']=array('Nein','Ja'); $anonie['pl']=array('Nie','Tak'); $anonie['hu']=array('Nem','Igen'); $anonie['fr']=array('Pas','Oui'); $res=$this->basic; if ($db==0 or $db==2): $res['crea']=mydatetime($res['crea']); $res['chan']=mydatetime($res['chan']); $res['time_from']=mydatetime($res['time_from']); $res['time_to']=mydatetime($res['time_to']); foreach($this->polia as $meno=>$p): $ameno='art_'.$meno; $pmeno=$prefix.$meno; if ($p['aktiv'] and isset($this->data[$ameno])): if (!isset($this->data[$ameno])) $this->data[$ameno]=''; if ($p['typ']==1 and $db==2) $res[$pmeno]=htmlspecialchars($this->data[$ameno]); elseif (($p['typ']==3) and ($p['par1']=='floattime')) $res[$pmeno]=float2time($this->data[$ameno]); elseif ($p['typ']==4) $res[$pmeno]=mydate($this->data[$ameno]); elseif ($p['typ']==5) $res[$pmeno]=mytime($this->data[$ameno]); elseif ($p['typ']==6) $res[$pmeno]=mydatetime($this->data[$ameno]); elseif ($p['typ']==9 and $db==2) $res[$pmeno]=empty($p['par2'])?nl2br($this->data[$ameno]):$this->data[$ameno]; elseif ($p['typ']==11 and $db==2) $res[$pmeno]=empty($this->data[$ameno])?'':'/'.$cfg['att_path'].$this->data[$ameno]; elseif ($p['typ']==12 and $db==2){ $res[$pmeno]=$anonie[$this->lang][$this->data[$ameno]]; $res[$pmeno.'_']=$this->data[$ameno];} elseif ($p['typ']==13 and $db==2) { //$res[$pmeno]=getValue('SELECT nazov FROM cms_cis_01 WHERE cis='.adsq($p['par1']).' AND ID='.adsq($this->data[$ameno]).' AND lang='.adsq($this->lang)); $res[$pmeno]=$syscom->storage->getCode($p['par1'],$this->lang,$this->data[$ameno]); $res[$pmeno.'_']=$this->data[$ameno];} elseif ($p['typ']==14 and $db==2){ //$res[$pmeno]=getValue('SELECT nazov FROM cms_cis_01 WHERE cis='.adsq($p['par1']).' AND ID='.adsq($this->data[$ameno]).' AND lang='.adsq($this->lang)); $res[$pmeno]=$syscom->storage->getCode($p['par1'],$this->lang,$this->data[$ameno]); $res[$pmeno.'_']=$this->data[$ameno];} elseif ($p['typ']==18 and $db==2){ $res[$pmeno.'_']=$this->data[$ameno]; } elseif ($p['typ']==19 and $db==2){ $res[$pmeno.'_']=$this->data[$ameno]; } elseif ($p['typ']==20 and $db==2) $res[$pmeno]=empty($this->data[$ameno])?'':'/'.$cfg['diskfile_path'].$p['par1'].'/'.$this->data[$ameno]; elseif ($p['typ']==21 and $db==2) {//uzivatel $hod=getRow("SELECT CONCAT(priez,' ',meno) FROM usr WHERE stav=1 AND ID='".$this->data[$ameno]."' ORDER BY priez, meno",false); $res[$pmeno]=$hod[0]; $res[$pmeno.'_']=$this->data[$ameno];} elseif ($p['typ']==22 and $db==2) {//checkarray // $hod=getArray('SELECT nazov FROM cms_cis_01 WHERE cis='.adsq($p['par1']).' AND ID IN ('.(empty($this->data[$ameno])?"''":$this->data[$ameno]).') AND lang='.adsq($this->lang).' ORDER BY poradie',0,2); $hod=$syscom->storage->getCodes($p['par1'],$this->lang,empty($this->data[$ameno])?"''":$this->data[$ameno]); $res[$pmeno.'_']=$this->data[$ameno]; $res[$pmeno]=(empty($hod)?'':$p['par3']).implode($p['par2'].$p['par3'],$hod); } elseif ($p['typ']==23 and $db==2){ $res[$pmeno]=getValue('SELECT nazov FROM art WHERE ID='.adsq($this->data[$ameno])); $res[$pmeno.'_']=$this->data[$ameno]; } else $res[$pmeno]=$this->data[$ameno]; endif; endforeach; //linky a dokumenty foreach($this->polia as $meno=>$p): $ameno='art_'.$meno; $pmeno=$prefix.$meno; if ($p['typ']==17 and $db==2): if (empty($this->data[$ameno])): $res[$pmeno]=empty($this->data['art_'.$p['par2']])?'':$this->data['art_'.$p['par2']]; else: $res[$pmeno]=''.(empty($this->data['art_'.$p['par1']])?$this->data[$ameno]:$res[$prefix.$p['par1']]).''; endif; endif; endforeach; else: $res = array_merge($this->basic,$this->data); endif; return $res; } function setValues($data){ if ($this->testWrite()): $this->basic['chan']=stamp2time(time()); $this->basic['chan_usr']=$this->uid; $this->basic['nazov']= isset($data['nazov'])?$data['nazov']:$this->basic['nazov']; foreach($this->polia as $meno=>$p): if ($p['aktiv'] and isset($data['art_'.$meno])): $this->data['art_'.$meno]=$data['art_'.$meno]; endif; endforeach; endif; } public function val(){ $args=func_get_args(); if((count($args)==1) and is_string($args[0])): return isset($this->basic[$args[0]])?$this->basic[$args[0]]:(isset($this->data['art_'.$args[0]])?$this->data['art_'.$args[0]]:''); elseif((count($args)==2) and is_string($args[1])): if(isset($this->basic[$args[0]])) $this->basic[$args[0]]=$args[1]; if(isset($this->data['art_'.$args[0]])) $this->data['art_'.$args[0]]=$args[1]; endif; } function save($quickSave=false){ global $syscom, $cfg; if (!$quickSave) $this->runAction($this->artpro->basic['akcia3']); $this->documentFilter(); if ($this->ID): //run backup here $tool=new TArtTools; // $tool->backup($this->ID, $this->uid,$cfg['version_count']); $tool->backup($this,$cfg['version_count']); $this->basic['version']=$this->basic['version']+1; setRow('art',pole2db($this->basic),'ID'); setRow('art_o'.$this->basic['artpro'],pole2db($this->data),'ID'); else: if ($syscom->reg['art_order']==1): uni_query('UPDATE art SET poradie=poradie+1 WHERE nadrad='.$this->basic['nadrad']); $this->basic['poradie']=1; else: $this->basic['poradie']=getValue('SELECT MAX(poradie) FROM art WHERE nadrad='.$this->basic['nadrad'])+1; endif; addRow('art',pole2db($this->basic),'ID'); $this->basic['ID']=getInsertID(); $this->ID=$this->basic['ID']; $this->data['ID']=$this->basic['ID']; addRow('art_o'.$this->basic['artpro'],pole2db($this->data),'ID'); $this->setArt($this->ID); endif; //attachments if (!empty($this->frmFiles)): $this->attachAtts($this->frmFiles); $this->frmFiles=''; endif; //nastavenie SEO $this->setSEO(); //indexovanie pre vyhladavanie $search = new TArtTools(); $search->searchIndex($this); /* print $this->getValue('nazov'); exit;*/ //SEO $syscom->locator->updateLocation($this); if (!$quickSave) $this->runAction($this->artpro->basic['akcia4']); } function show($verzia='www',$def_link='',$data1=array(),$temp='template'){//default prostredie www global $cfg,$session,$syscom; $this->runAction($this->artpro->basic['akcia5']); $edit=$cfg['art_edit_link']; $res=''; $verzia=empty($this->basic['sablona'])?$verzia:$this->basic['sablona']; if ($this->testRead()): //generovanie tela dokumentu //$template=new TTemplate($this->artpro->basic['sablona1'],$this->lang,1,$verzia,$this->identity); $template=$syscom->storage->getTemplate($this->artpro->basic['sablona1'],$this->lang,1,$verzia,$this->identity); $data=$this->getValues(2,''); $data['nazov']=htmlspecialchars($this->basic['nazov']); //nahradzovanie liniek if ($this->basic['links']): if ($def_link): $linky=explode(',',$this->basic['links']); for ($i=0;$ibasic['links']?$this->basic['links']:"''").")"); $syscom->locator->loadLinks($this->basic['links'],$this->lang); for ($i=0;$ilocator->getLink($linky[$i]['ID'],$this->lang); endfor; endif; endif; //nahradenie suborov if ($this->basic['files']): $files=getTable('SELECT ID, nazov, cesta FROM files WHERE type<>1 AND ID IN ('.($this->basic['files']?$this->basic['files']:"''").')'); for ($i=0;$ilang; foreach($this->polia as $meno=>$p): if ($p['typ']==18 or $p['typ']==23): $pos = strpos($template->info['template'], '['.$meno.']'); if (!empty($this->data['art_'.$meno]) and !($pos===false)): //$doc= new TArt($this->data['art_'.$meno],$this->uid,$this->lang,$this->grps); $doc= $syscom->storage->getArt($this->data['art_'.$meno],$this->identity,$this->lang); $docContext=(mb_substr($p['par1'],0,1)=='.')?($verzia.$p['par1']):$p['par1']; $data[$meno]=(is_object($doc) and $doc->testRead())?$doc->show(empty($docContext)?$verzia:$docContext,$def_link):''; else: $data[$meno]=''; endif; elseif ($p['typ']==19): $pos = strpos($template->info['template'], '['.$meno.']'); if (!empty($this->data['art_'.$meno]) and !($pos===false)): $docs=explode(',',$this->data['art_'.$meno]); $data[$meno]=''; $artData=array(); for ($j=0;$jstorage->getArt($docs[$j],$this->identity,$this->lang); //$doc= new TArt($docs[$j],$this->uid,$this->lang,$this->grps); $docContext=(!empty($p['par1']) and $p['par1']{0}=='.')?($verzia.$p['par1']):$p['par1']; $data[$meno].=(is_object($doc) and $doc->testRead())?$doc->show(empty($docContext)?'':$docContext,$def_link,$artData):''; endfor; else: $data[$meno]=''; endif; endif; endforeach; //komponenty $this->comps=unserialize($this->basic['comps']); if (!empty($this->comps)): foreach ($this->comps as $kod=>$conf): if (!class_exists('cmsComp'.$conf['kod'])): $syscom->reqComp('cmp_'.strtolower($conf['kod'])); endif; endforeach; endif; $cmp_data=array();$comps=array(); if (!empty($this->comps)): $cmp_data=$this->basic; $cmp_data['ART_EDIT_LINK']=$edit; $cmp_data['ART_DEF_LINK']=$def_link; $cmp_data['ART_LANG']=$this->lang; $cmp_data['ART_UID']=$this->uid; $cmp_data['ART_WUID']=empty($session->wuid)?0:$session->wuid; $cmp_data['ART_SABL']=$verzia; $cmp_data['ART_GRPS']=$this->grps; foreach ($this->comps as $kod=>$conf): $pars=multireplace($conf['pars'],$cmp_data,'[',']'); $pars=multireplace($pars,$comps,'{','}'); $class=('cmsComp'.$conf['kod']); $cmp_obj = new $class($conf['kod'],$pars,$cmp_data,$this->identity,$this); $comps[$kod]=$cmp_obj->run(); $cmp_data[$kod]=&$comps[$kod]; endforeach; endif; $data = multireplace($data,$comps,'{','}'); $data['ART_EDIT_LINK']=$edit; $data['ART_DEF_LINK']=$def_link; $data['ART_LANG']=$this->lang; $data['ART_UID']=$this->uid; $data['ART_WUID']=empty($session->wuid)?0:$session->wuid; $data['ART_GRPS']=$this->grps; $data['ART_SABL']=$verzia; // $tmp=$this->getLink($def_link); $data['ART_LINK']=$this->getLink();//$tmp['linka']; // $data['ART_LONG_LINKS']=$tmp['long_links']; $data['ART_EDIT']=($edit and $this->testWrite())?'':''; $data=empty($data1)?$data:array_merge($data,$data1); $res=$template->generate($data,$this,$temp); endif; return $res; $this->runAction($this->artpro->basic['akcia6']); } function add($zaznam,$frm){//tato funkcia je z dovodu spatnej kompatibility, neskor bude zrusena $art= new Tart($this->ID,$this->uid,$this->lang,$this->grps,$zaznam['artpro']); if ($art->status): //removing slashes foreach ($zaznam as $key => $value) { $value=$value{0}=="'"?substr($value,1,strlen($value)-2):$value; $value=stripslashes($value); $zaznam[$key]=$value; } $art->setValues($zaznam); $art->attachFrmFiles($frm); $art->save(); return $art->ID; else: return $art->status; endif; } function set($zaznam,$frm){ //tato funkcia je z dovodu spatnej kompatibility, neskor bude zrusena //removing slashes foreach ($zaznam as $key => $value) { $value=$value{0}=="'"?substr($value,1,strlen($value)-2):$value; $value=stripslashes($value); $zaznam[$key]=$value; } $this->setValues($zaznam); $this->attachFrmFiles($frm); $this->save(); } function setBasic($zaznam){//toto bude pravdepodobne zrusene if ($this->testWrite()): $zaznam['chan']='now()'; $zaznam['chan_usr']=$this->uid; setRow('art',$zaznam,'ID'); endif; } function del($rek=0){ global $syscom; $this->runAction($this->artpro->basic['akcia7']); //rekurzivne mazanie podradenych dokumentov $ok=1; if ($rek): $arts=getTable('SELECT ID FROM art WHERE nadrad='.$this->basic['ID']); for ($i=0;$iuid,'',$this->grps); $res1=$art->del(1); $ok=($ok and $res1); endfor; endif; //mazanie samotneho dokumentu $res=0; $test=getValue('SELECT ID FROM art WHERE nadrad='.$this->basic['ID']); // print 'idem mazaat...'; if ($this->testDelete() and $ok and empty($test)): // print 'mazem...'; uni_query("DELETE FROM art WHERE ID=".$this->basic['ID']); uni_query("DELETE FROM art_01 WHERE art=".$this->basic['ID']); if ($this->polia) uni_query("DELETE FROM art_o".$this->basic['artpro']." WHERE ID=".$this->basic['ID']); uni_query('DELETE FROM cms_art_sel WHERE art='.$this->basic['ID']); //vyhladavaci slovnik uni_query("DELETE FROM art_03 WHERE art=".$this->basic['ID']); //verzie uni_query("DELETE FROM art_04 WHERE art=".$this->basic['ID']); //location a seo uni_query("DELETE FROM location WHERE art=".$this->basic['ID']); uni_query("DELETE FROM art_05 WHERE art=".$this->basic['ID']); //odstranenie suborov $this->delFile(); $res=1; $syscom->locator->removeLocation($this->basic['ID']); endif; $this->runAction($this->artpro->basic['akcia8']); return $res; } function sel(){ global $session; if ($this->isSel()): uni_query('DELETE FROM cms_art_sel WHERE session='.adsq($session->sid).' AND art='.$this->basic['ID']); else: uni_query('INSERT INTO cms_art_sel VALUES(0,'.adsq($session->sid).','.$this->basic['ID'].')'); endif; } function attachFile($field,$source,$type='file'){ global $syscom; $res=false; $file = new FileObject($source,$type); $field = $this->artpro->getField($field); if (!empty($this->basic['ID']) and $this->testWrite() and $file->exists() and ($field['typ']==11)): $res=true; //metadata $data=array(); $data['ID']=0; $data['art']=$this->basic['ID']; $data['field']=adsq($field['meno']); $data['hash']=adsq($file->getHash()); $data['size']=adsq($file->getSize()); $data['poradie']=getValue('SELECT MAX(poradie) FROM art_06 WHERE art='.$this->basic['ID'].' AND field='.adsq($field['meno']))+1; $data['crea']='now()'; $data['chan']='now()'; addRow('art_06',$data,'ID'); $data['ID']=getInsertID(); //kopirovanie suboru $file->copy($syscom->getRoot().$syscom->cfg['att_path'],$data['ID'],strtolower($file->getName(1)),true); uni_query('UPDATE art_06 SET file='.adsq($data['ID'].'.'.strtolower($file->getName(1))).', ext='.adsq($file->getName(1)).' WHERE ID='.$data['ID']); //nahlad if ($file->isImage()): $file->copy($syscom->getRoot().'data/temp/','att_thumb','tmp',true); $file->imageTrans('128'); uni_query('UPDATE art_06 SET thumb='.adsq($file->getContent()).' WHERE ID='.$data['ID']); endif; //updating field $files=getArray('SELECT file FROM art_06 WHERE art='.$this->basic['ID'].' AND field='.adsq($field['meno']).' ORDER BY poradie',0,2); uni_query('UPDATE art_o'.$this->basic['artpro'].' SET art_'.$field['meno'].'='.adsq(implode(',',$files)).' WHERE ID='.$this->basic['ID']); endif; return $res; } public function delFile(){ global $syscom; $args=func_get_args(); if(empty($args))://deleting all atts foreach($this->artpro->polia as $field): if($field['typ']==11): $this->delFile($field['meno']); endif; endforeach; elseif((count($args)==1) and !is_numeric($args[0]))://deleting alla atts of field $atts=getArray('SELECT file FROM art_06 WHERE field='.adsq($args[0]).' AND art='.$this->val('ID'),0,2); foreach($atts as $att): $file=new FileObject($syscom->getRoot().'data/att/'.$att,'file'); $file->del(); endforeach; uni_query('DELETE FROM art_06 WHERE field='.adsq($args[0]).' AND art='.$this->val('ID')); $this->val($args[0],''); $this->save(true); endif; } public function attachFrmFiles($frm){ $this->frmFiles=$frm; } function attachAtts($frm){ global $syscom; $fields=getTable("SELECT * FROM att WHERE frm=".adsq($frm)); for ($i=0;$igetRoot().$syscom->cfg['att_path'].$att['file']); uni_query("DELETE FROM art_06 WHERE ID=".$att['ID']); endforeach; //synchronize actual files $atts=getTable("SELECT * FROM att_01 WHERE att=".$fields[$i]['ID']); foreach ($atts as $att): //updating file info $data=array(); $data['art']=$this->basic['ID']; $data['field']=adsq($fields[$i]['field']); $data['thumb']=adsq($att['thumb']); $data['hash']=adsq($att['hash']); $data['size']=adsq($att['size']); $data['ext']=adsq($att['ext']); $data['poradie']=$att['poradie']; if ($att['ref']): $data['ID']=$att['ref']; setRow('art_06',$data,'ID'); else: $data['ID']=0; $data['crea']='now()'; $data['chan']='now()'; addRow('art_06',$data,'ID'); $data['ID']=getInsertID(); endif; //moving file if ($att['name']): $file = new FileObject($syscom->getRoot().'data/temp/att_'.$att['ID'].'.tmp','file'); $newFileName=$data['ID']; $newFileExt=strtolower($att['ext']); $value[]=$newFileName.'.'.$newFileExt; $file->copy($syscom->getRoot().$syscom->cfg['att_path'],$newFileName,$newFileExt); $file->del(); uni_query('UPDATE art_06 SET file='.adsq($newFileName.'.'.$newFileExt).', name='.adsq($att['name']).', chan=now() WHERE ID='.$data['ID']); endif; endforeach; uni_query("DELETE FROM att_01 WHERE att=".$fields[$i]['ID']); // print_r(getArray("SELECT file FROM art_06 WHERE art=".$this->basic['ID'].' AND field='.adsq($fields[$i]['field']),0,2)); // exit; uni_query("UPDATE art_o".$this->basic['artpro']." SET art_".$fields[$i]['field'].'='.adsq(implode(',',getArray("SELECT file FROM art_06 WHERE art=".$this->basic['ID'].' AND field='.adsq($fields[$i]['field']).' ORDER BY poradie',0,2))).' WHERE ID='.$this->basic['ID']); endfor; uni_query("DELETE FROM att WHERE frm=".adsq($frm)); } public function presun($nadrad){ $test=getValue('SELECT art FROM art_01 WHERE art='.$nadrad.' AND nadrad='.$this->basic['ID']);//nesmie presuvat pod moj podradeny dokument if (empty($test)): $art_nad=new TArt($nadrad,$this->uid); if ($this->testDelete() and $art_nad->testAdd()): //zistim poradie $poradie=getRow('SELECT max(poradie) FROM art WHERE nadrad='.$art_nad->basic['ID']); uni_query('UPDATE art SET nadrad='.$art_nad->basic['ID'].', poradie='.($poradie[0]+1).' WHERE ID='.$this->basic['ID']); $this->basic['nadrad']=$art_nad->basic['ID']; $this->setArt($this->basic['ID']); endif; endif; } public function kopiruj($nadrad,$rek=0){ global $syscom; if (!$rek or !getValue('SELECT art FROM art_01 WHERE art='.$nadrad.' AND nadrad='.$this->basic['ID'])): //$artNad=new TArt($nadrad,$this->uid); if ($this->testRead()):// and $artNad->testAdd() $art=new TArt($nadrad,$this->uid,$this->lang,$this->grps,$this->basic['artpro']); if ($art->status): $art->basic['nazov']=$this->basic['nazov']; $art->basic['page']=$this->basic['page']; $art->basic['redir']=$this->basic['redir']; $art->basic['radenie']=$this->basic['radenie']; $art->basic['gright']=$this->basic['gright']; $art->basic['pright']=$this->basic['pright']; $art->basic['comps']=$this->basic['comps']; $art->basic['comp']=$this->basic['comp']; $art->data=$this->data; $art->save(); //attached files $files=getTable('SELECT * FROM art_06 WHERE art='.$this->basic['ID'].' ORDER BY poradie'); foreach ($files as $file): $art->attachFile($file['field'],$syscom->getRoot().$syscom->cfg['att_path'].$file['file'],'file'); endforeach; //rekurzivne kopirovanie if ($rek): $podrad=getTable('SELECT ID FROM art WHERE nadrad='.$this->basic['ID'].' ORDER BY '.$this->basic['radenie']); for ($i=0;$iuid); if ($temp_art->status) $temp_art->kopiruj($art->basic['ID'],1); endfor; endif; endif; endif; endif; } //setting functions---------------------------------------------------------------------------- function setUser($usr,$grps=''){ global $session; if (!empty($usr)): $this->uid=$usr; // $wusr=getValue("SELECT ID, meno FROM webuser ORDER BY ID"); $this->grps=empty($grps)?getList('SELECT grp FROM usr_01 WHERE usr='.$this->uid,"('')"):$grps; $pom=explode(',',str_replace(array("'",'(',')'),array('','',''),$this->grps)); for ($i=0;$igroups[trim($pom[$i])]=1; else: $this->uid=0; $this->wuid=0; $this->grps="('')"; $this->groups=array(); endif; } function setRights(){ if ($this->uid): $userGrp=!empty($this->groups[$this->basic['grp']]);//uzivatel je v skupine $userPub=!empty($this->groups[$this->basic['pub']]); //citanie $this->right_read=($userPub and ($this->testPublic()));//verejnost $this->right_read=($this->right_read or ($userGrp and (($this->basic['gright'] & 1)==1)));//skupina $this->right_read=($this->right_read or (($this->uid==$this->basic['usr']) and (($this->basic['uright'] & 1)==1))); //uzivatel //zapis $this->right_write=($userGrp and (($this->basic['gright'] & 2)==2));//skupina $this->right_write=($this->right_write or (($this->uid==$this->basic['usr']) and (($this->basic['uright'] & 2)==2)));//uzivatel //pridavanie $this->right_add=($userGrp and (($this->basic['gright'] & 4)==4));//skupina $this->right_add=($this->right_add or (($this->uid==$this->basic['usr']) and (($this->basic['uright'] & 4)==4)));//uzivatel //mazanie $this->right_delete=($userGrp and (($this->basic['gright'] & 8)==8));//skupina $this->right_delete=($this->right_delete or (($this->uid==$this->basic['usr']) and (($this->basic['uright'] & 8)==8)));//uzivatel //publikovanie $this->right_pub=(($this->uid==$this->basic['usr']) or $userGrp); //ak definovany webuser if (!empty($this->wuid)): $this->right_read=($this->right_read or (($this->wuid==$this->basic['wusr']) and (($this->basic['wuright'] & 1)==1))); //web uzivatel $this->right_write=($this->right_write or (($this->wuid==$this->basic['wusr']) and (($this->basic['wuright'] & 2)==2)));//uzivatel $this->right_add=($this->right_add or (($this->wuid==$this->basic['wusr']) and (($this->basic['wuright'] & 4)==4)));//uzivatel $this->right_delete=($this->right_delete or (($this->wuid==$this->basic['wusr']) and (($this->basic['wuright'] & 8)==8)));//uzivatel endif; endif; } function setAccess($usr,$grps=''){ if(is_object($usr)): $this->identity=$usr; $this->setUser($this->identity->getUser()); else: $this->setUser($usr,$grps); endif; $this->setRights(); } function setGrp($grp,$rek){ if ($this->basic['usr']==$this->uid): uni_query("UPDATE art SET grp='".$grp."' WHERE ID=".$this->basic['ID']); endif; if ($rek): //rekurzivna zmena $podrad=getTable('SELECT ID FROM art WHERE nadrad='.$this->basic['ID']); for ($i=0;$iuid); if (is_object($temp_art)) $temp_art->setGrp($grp,1); endfor; endif; } function setPub($pub,$rek){ if ($this->basic['usr']==$this->uid): uni_query("UPDATE art SET pub='".$pub."' WHERE ID=".$this->basic['ID']); endif; if ($rek): //rekurzivna zmena $podrad=getTable('SELECT ID FROM art WHERE nadrad='.$this->basic['ID']); for ($i=0;$iuid); if (is_object($temp_art)) $temp_art->setPub($pub,1); endfor; endif; } function setOwn($usr,$rek){ global $session; //zmenu moze robit administrator alebo local admin, ktory ma pravo zapisovat dokument if (($session->user['role']==5) or ($session->user['role']==4 and $this->testWrite())): uni_query("UPDATE art SET usr='".$usr."' WHERE ID=".$this->basic['ID']); endif; if ($rek): //rekurzivna zmena $podrad=getTable('SELECT ID FROM art WHERE nadrad='.$this->basic['ID']); for ($i=0;$iuid); if (is_object($temp_art)) $temp_art->setOwn($usr,1); endfor; endif; } function setWusr($wusr,$rek){ global $syscom; //zmenu moze robit administrator alebo local admin, ktory ma pravo zapisovat dokument if ($this->basic['usr']==$this->uid): uni_query("UPDATE art SET wusr='".$wusr."' WHERE ID=".$this->basic['ID']); endif; if ($rek): //rekurzivna zmena $podrad=getTable('SELECT ID FROM art WHERE nadrad='.$this->basic['ID']); for ($i=0;$iuid); if (is_object($temp_art)) $temp_art->setWusr($wusr,1); endfor; endif; } function setPublic($pub,$time_from,$time_to,$role,$rek){ if ($this->testPub($role)): uni_query('UPDATE art SET pright='.$pub.', time_from='.adsq($time_from).', time_to='.adsq($time_to).' WHERE ID='.$this->basic['ID']); $this->basic['pright']=$pub; if ($rek): //rekurzivna zmena $podrad=getTable('SELECT ID FROM art WHERE nadrad='.$this->basic['ID']); for ($i=0;$iuid); if (is_object($temp_art)) $temp_art->setPublic($pub,$time_from,$time_to,$rek); endfor; endif; endif; } function setDocLang($lang,$rek){ global $syscom; if ($this->testWrite()): uni_query("UPDATE art SET lang='".addslashes($lang)."' WHERE ID=".$this->basic['ID']); endif; if ($rek): //rekurzivna zmena $podrad=getTable('SELECT ID FROM art WHERE nadrad='.$this->basic['ID']); for ($i=0;$iuid); if (is_object($temp_art)) $temp_art->setDocLang($lang,1); endfor; endif; } function setPage($page,$rek){ if ($this->testWrite()): $this->basic['page']=$page; uni_query("UPDATE art SET page='".addslashes($page)."' WHERE ID=".$this->basic['ID']); endif; if ($rek): //rekurzivna zmena $podrad=getTable('SELECT ID FROM art WHERE nadrad='.$this->basic['ID']); for ($i=0;$iuid); if (is_object($temp_art)) $temp_art->setPage($page,1); endfor; endif; } function setLang($lang){ $this->lang=(!empty($lang) and !(strpos($this->basic['lang'],$lang)===false))?$lang:$this->lang; } //getting functions---------------------------------------------------------------------------- function getLink(){ global $syscom; return $this->link?$this->link:($this->link=$syscom->locator->getLink($this->basic['ID'],$this->lang)); } //seo support------------------------------------------------------------ function setSeoElement($name,$lang, $default,$key,&$data){ if (!(($this->basic['seo_manual'] & $key)==$key)): $seo=$default; if ($this->artpro->basic['seo']): $temp=new TTemplate($this->artpro->basic['sablona1'],$lang,5,$name); $seo=(empty($temp->info['ID']) or ($temp->info['verzia']<>$name))?$seo:$temp->generate($data); endif; $seo=str_replace(array("\n","\r","\t",'"'),array(' ',' ',' ',''),$seo); uni_query("INSERT INTO art_05 SET art=".$this->basic['ID'].",lang='".$lang."',`".$name."`='".addslashes($seo)."' ON DUPLICATE KEY UPDATE `".$name."`='".addslashes($seo)."'"); endif; } function setSeo(){ $data=$this->getValues(2,''); $data['nazov']=$this->basic['nazov']; $langs=explode(',',$this->basic['lang']); for ($i=0;$isetSeoElement('title',$langs[$i],$this->getValue('nazov'),2,$data); $this->setSeoElement('desc',$langs[$i],'',4,$data); $this->setSeoElement('keys',$langs[$i],'',8,$data); endfor; } //testing functions---------------------------------------------------------------------------- function isSel(){ global $session; $ozn=getRow("SELECT art FROM cms_art_sel WHERE session='".$session->sid."' AND art=".$this->basic['ID']); return $ozn['art']?1:0; } function testPublic(){ $res=(($this->basic['pright']==1) or (($this->basic['pright']==3) and ( (mydatetime($this->basic['time_from'])?date('Y-m-d H:i:s')>=$this->basic['time_from']:1) and (mydatetime($this->basic['time_to'])?date('Y-m-d H:i:s')<=$this->basic['time_to']:1) ) )); return $res; } function testRead(){ return $this->right_read; } function testWrite(){ return $this->right_write; } function testAdd(){ return $this->right_add; } function testDelete(){ return $this->right_delete; } function testPub($role){ return (($role>=3) and $this->right_pub); } } function getRightSel($uid,$grps,$wuid=0){ $prava_public="(art.pub IN $grps AND (art.pright=1 OR (art.pright=3 AND (art.time_from<=now() OR art.time_from='0000-00-00 00:00:00') AND (art.time_to>=now() OR art.time_to='0000-00-00 00:00:00'))))"; $prava_grp="(art.grp IN $grps AND (art.gright & 1)=1)"; $prava_usr="(art.usr='$uid' AND (art.uright & 1)=1)"; $prava_wuid="(art.wusr='".$wuid."' AND (art.wuright & 1)=1)"; $prava='( '.$prava_public.' OR '.$prava_usr.' OR '.$prava_grp.(empty($wuid)?'':(' OR '.$prava_wuid)).')'; return $prava; } ?>identity=$identity; } public function setArtpro($artpro){ $this->artpro=$artpro; } public function setIdentity($identity){ $this->identity=$identity; } public function setLimit($count,$page){ $this->count=$count; $this->page=$page; } public function setFilter($filter){ $this->filter=$filter; } public function setCategory($field){ $this->category=$field; } public function setOrder($order){ $this->order=$order; } public function setParent($parent,$rec){ $this->parent=$parent; $this->rec=$rec; } public function addTable($table){ $this->table=$table; } private function getRightSel(){ $prava_public="(art.pub IN ".$this->identity->getGroups()." AND (art.pright=1 OR (art.pright=3 AND (art.time_from<=now() OR art.time_from='0000-00-00 00:00:00') AND (art.time_to>=now() OR art.time_to='0000-00-00 00:00:00'))))"; $prava_grp="(art.grp IN ".$this->identity->getGroups()." AND (art.gright & 1)=1)"; $prava_usr="(art.usr='".$this->identity->getUser()."' AND (art.uright & 1)=1)"; $prava_wuid="(art.wusr='".$this->identity->getWebUser()."' AND (art.wuright & 1)=1)"; $prava='( '.$prava_public.' OR '.$prava_usr.' OR '.$prava_grp.(!$this->identity->getWebUser()?'':(' OR '.$prava_wuid)).')'; return $prava; } public function setComputeCount($val){ $this->computeCount=$val; } public function getTotal(){ return $this->total; } public function getCount(){ return count($this->arts); } public function getArts(){ global $syscom; $preselect=array(); $select=array(); $tables=array('art'); $where=array(); $order=array(); if($this->computeCount): $preselect[]='SQL_CALC_FOUND_ROWS'; endif; $select[]='art.*'; if($this->artpro): $select[]='art_o'.$this->artpro.'.*'; $tables[]='art_o'.$this->artpro; $where[]='art.ID=art_o'.$this->artpro.'.ID'; endif; if($this->rec): $preselect[]='DISTINCT'; $tables[]='art_01'; $where[]='art_01.art=art.ID'; endif; if($this->parent): $where[]=($this->rec?'art_01.nadrad=':'art.nadrad=').$this->parent; endif; if($this->filter): $where[]=$this->filter; endif; $where[]=$this->getRightSel(); $limit=$this->count?(' LIMIT '.($this->page*$this->count).', '.$this->count):''; if($this->order): $order[]=$this->order; endif; $query='SELECT '.implode(' ',$preselect).' '.implode(', ',$select).' FROM '.implode(', ',$tables).' WHERE '.implode(' AND ',$where).($order?' ORDER BY '.implode(', ',$order):'').$limit; // print 'Query: '.$query.'|'; $items=getTable($query); $this->total=getValue('SELECT FOUND_ROWS()'); foreach($items as $item): //$this->arts[]= new TArt($this->artpro?$item:$item['ID'],$this->identity); $this->arts[]= $syscom->storage->getArt($this->artpro?$item:$item['ID'],$this->identity); endforeach; } public function show($kontext,$lang=''){ global $syscom; $this->getArts(); $res=''; $parData=array('count'=>count($this->arts)); $arts=array(); foreach($this->arts as $art) $arts[]=$art->ID; $syscom->locator->loadLinks($arts,$lang); for($i=0;$iarts);$i++): $art=&$this->arts[$i]; $art->setLang($lang); //start if($i==0): $res.=$art->show($kontext,'',$parData,'par1'); endif; //category if (!empty($this->category) and (($i==0) or ($art->getValue($this->category)<>$this->arts[$i-1]->getValue($this->category)))): $res.=$art->show($kontext,'','','par3'); endif; //document $data=array(); $data['ART_PC']=($i+1); $data['ART_MOD']=mod($i,2); $data['ART_FIRST']=(($i==0) or (!empty($this->category) and ($art->getValue($this->category)<>$this->arts[$i-1]->getValue($this->category))))?1:0; $data['ART_LAST']=(($i==(count($this->arts)-1)) or (!empty($this->category) and ($art->getValue($this->category)<>$this->arts[$i+1]->getValue($this->category))))?1:0; $res.=$art->show($kontext,'',$data); //end if($i==count($this->arts)-1): $res.=$art->show($kontext,'',$parData,'par2'); endif; endfor; return $res; } } ?>p['nadrad']=empty($this->p['nadrad'])?$this->art:$this->p['nadrad']; $this->p['verzia']=$this->getContext($this->p['verzia']); $subartpro=(empty($this->artObj)?'':$this->artObj->basic['subartpro']); $this->p['schema']=(empty($this->p['schema']) and !empty($subartpro))?$subartpro:$this->p['schema']; $this->p['filter']=empty($this->p['filter'])?'':$this->p['filter']; $this->p['order']=empty($this->p['order'])?(empty($this->artObj)?'':$this->artObj->basic['radenie']):$this->p['order']; $this->p['pocet']=empty($this->p['pocet'])?15:$this->p['pocet']; } function run(){ $arts = new TArts($this->identity); $arts->setArtpro($this->p['schema']); $arts->setFilter($this->p['filter']); $arts->setOrder($this->p['order']); $arts->setLimit($this->p['nestrankuj']?0:$this->p['pocet'],getInt('page')); $arts->setParent($this->p['nadrad'],0); $arts->setComputeCount(1); $res= $arts->show($this->p['verzia'],$this->lang); $poczaz=$arts->getTotal(); //strankovanie if ($poczaz>0 and empty($this->p['nestrankuj']) and ceil($poczaz/$this->p['pocet'])>1): $res.='
'.$this->addPages(ceil($poczaz/$this->p['pocet']),getInt('page')).'
'; endif; return $res; } } ?>p['eval']): return eval('return ('.$this->p['hodnota'].');')?$this->p['ano']:$this->p['nie']; else: return $this->p['hodnota']?$this->p['ano']:$this->p['nie']; endif; } } class cmsCompShow extends TComponent { var $par_key=array('art','sablona'); var $par_def=array(0,''); function run(){ global $syscom; $art=(is_numeric($this->p['art']))?$this->p['art']:getInt($this->p['art']); //$doc = new TArt($art,$this->uid,$this->lang); $doc=$syscom->storage->getArt($art,$this->identity); $doc->setLang($this->lang); $res=($doc->status)?$doc->show($this->p['sablona']):''; return $res; } } class cmsCompCut extends TComponent { var $par_key=array('ret','pocet','words'); var $par_def=array('',3,''); function run(){ if ($this->p['pocet']<3) $this->p['pocet']=3; $ret=strip_tags(str_replace(array('“','„','–','™','•'),array('“','„','–','™',''),html_entity_decode($this->p['ret'],ENT_COMPAT,'UTF-8'))); if($this->p['words']): $ret=(mb_strlen($ret)>$this->p['pocet'])?substr($ret,0,strrpos(mb_substr($ret,0,$this->p['pocet']-3,'UTF-8'),' ')).'...':$ret; else: $ret=(mb_strlen($ret)>$this->p['pocet'])?mb_substr($ret,0,$this->p['pocet']-3,'UTF-8').'...':$ret; endif; return htmlspecialchars($ret); } } class cmsCompDate extends TComponent { var $par_key=array('format','datum'); var $par_def=array('',''); function run(){ if ($this->p['datum']): return date($this->p['format'],date2stamp($this->p['datum'])); else: return date($this->p['format']); endif; } } class cmsCompEval extends TComponent { var $par_key=array('source'); var $par_def=array(''); function run(){ $result=''; eval($this->p['source']); return $result; } } class cmsCompInList extends TComponent { var $par_key=array('hodnoty','zoznam'); var $par_def=array('',''); function run(){ $hod=explode(',',$this->p['hodnoty']); $zoz=explode(',',$this->p['zoznam']); $res=false; for ($i=0;$ip['hodnoty']) and !empty($this->p['zoznam']) and in_array($hod[$i],$zoz))); endfor; return $res?1:0; } } class cmsCompHtmlSpec extends TComponent{ var $par_key=array('string'); var $par_def=array(''); function run(){ return htmlspecialchars($this->p['string']); } } class cmsCompNumberFormat extends TComponent { var $par_key=array('number','decimals','dec_point','thousands'); var $par_def=array(0,0,',',' '); function run(){ return number_format($this->p['number'],$this->p['decimals'],$this->p['dec_point'],$this->p['thousands']); } } class cmsCompLinksAct extends TComponent{ var $par_key=array('string','typ','max'); var $par_def=array('',0,150); function run(){ //www + mail $pattern[0][]='#(((http[s]{0,1}://[a-zA-Z0-9_-]*[.]{1})|(www.))([a-z:A-Z0-9_\/.-]*))#e'; $replace[0][]="''.(strlen('\\0')>$max?(substr('\\0',0,$max-3).'...'):'\\0').''"; $pattern[0][]='#(^|\s)(([a-z0-9._%+-]+)@(([.-]?[a-z0-9])*))#is'; $replace[0][]='\\1\\2'; //iba www $pattern[1][]='#(((http[s]{0,1}://[a-zA-Z0-9_-]*[.]{1})|(www.))([a-z:A-Z0-9_\/.-]*))#e'; $replace[1][]="''.(strlen('\\0')>$max?(substr('\\0',0,$max-3).'...'):'\\0').''"; //iba mail $pattern[2][]='#(^|\s)(([a-z0-9._%+-]+)@(([.-]?[a-z0-9])*))#is'; $replace[2][]='\\1\\2'; //0- \\0||1 - \\1||2 - \\2||3 - \\3||4 - \\4||5 - \\5 return preg_replace($pattern[$this->p['typ']],$replace[$this->p['typ']],$this->p['string']); } } ?>info=getRow('SELECT * FROM cms_menu WHERE kod='.adsq($this->p['kod']).' AND (lang='.adsq($this->lang).' OR lang="")'); if (!empty($this->info)): $this->ID=$this->info['ID']; //inicializacia $this->level_from=empty($this->p['lev_from'])?1:$this->p['lev_from']; $this->level_to=empty($this->p['lev_to'])?$this->info['level']:$this->p['lev_to']; $this->design=empty($this->p['design'])?getRow('SELECT * FROM cms_menu_03 ORDER BY ID ASC'):getRow('SELECT * FROM cms_menu_03 WHERE ID='.intVal($this->p['design'])); $this->design['classes']=unserialize($this->design['classes']); $this->vzdy=$this->p['vzdy']; //vybrane polozky if ($this->p['selected']): $selected=getRow('SELECT cms_menu_01.ID, cms_menu_01.nadrad, cms_menu_01.level FROM cms_menu_01 WHERE cms_menu_01.ID='.intval($this->p['selected']),1); $this->selected=$selected['ID']; elseif (!empty($this->info['item_link']) and getInt($this->info['item_link'])): $selected=getRow('SELECT cms_menu_01.ID, cms_menu_01.nadrad, cms_menu_01.level FROM cms_menu_01, art_01 WHERE cms_menu_01.menu='.intval($this->ID).' AND cms_menu_01.art=art_01.nadrad AND art_01.art='.$this->art.' ORDER BY cms_menu_01.ID='.getInt($this->info['item_link']).' DESC, level DESC'); $this->selected=$selected['ID']; elseif (($this->info['auto']==1)): $selected=getRow('SELECT cms_menu_01.ID, cms_menu_01.nadrad, cms_menu_01.level FROM cms_menu_01, art_01 WHERE cms_menu_01.menu='.intval($this->ID).' AND cms_menu_01.art=art_01.nadrad AND art_01.art='.$this->art.' ORDER BY cms_menu_01.art='.$this->art.' DESC, level DESC'); $this->selected=$selected['ID']; endif; //otvorene polozky if ($this->selected): if ($selected['level']==1) $this->opened=array($this->selected); elseif ($selected['level']==2) $this->opened=array($this->selected,$selected['nadrad']); else $this->opened=getArray('SELECT nadrad FROM cms_menu_02 WHERE item='.$this->selected,0,2); endif; endif; if ($cfg['debug_mode']): $debug->debugAction('Menu['.$this->p['kod'].']: initialize',$start); endif; } private function setAddParam($par){ $this->add_param=$par; } private function generateItems($nadrad){ global $syscom; $res=''; if(!empty($this->polozky[$nadrad])): $co=array('[nazov]','[linka]','[ID]','[level]','[sel]','[open]','[link]','[caption]','[par1]','[par2]','[item]','[childs]','[target]','[class]'); $res.=(isset($this->design['classes']['group_'.$this->polozky[$nadrad][0]['level']]))?str_replace('[class]',$this->design['classes']['group_'.$this->polozky[$nadrad][0]['level']],$this->design['group_before']):$this->design['group_before']; foreach($this->polozky[$nadrad] as &$item): if($item['typ']==2 || !empty($this->arts[$item['art']]) || ($item['typ']==3 && $item['link'])): unset($zaco); $zaco[0]=$item['nazov']; if($item['typ']==1): $art=&$this->arts[$item['art']]; //linka $add_par=(empty($this->info['item_link'])?'':$this->info['item_link'].'='.$item['ID']); $add_par.=empty($this->add_param)?'':((empty($add_par)?'':'&').$this->add_param); $zaco[1]=(!empty($item['redir']))?$item['redir']:$syscom->locator->getLink($item['art'],$this->lang,$add_par,1); elseif($item['typ']==3): $zaco[1]=$item['link']; else: $zaco[1]=''; endif; //----------- $zaco[2]=$item['art']; $zaco[3]=$item['level']; $zaco[4]=($this->selected==$item['ID'])?((isset($this->design['classes']['class_sel']) && $this->design['classes']['class_sel'])?$this->design['classes']['class_sel']:1):''; $zaco[5]=in_array($item['ID'],$this->opened)?((isset($this->design['classes']['class_open']) && $this->design['classes']['class_open'])?$this->design['classes']['class_open']:1):''; $zaco[6]=$zaco[1]; $zaco[7]=$zaco[0]; $zaco[8]=$item['par1']; $zaco[9]=$item['par2']; $zaco[10]=$item['ID']; $zaco[11]=$item['childs']?((isset($this->design['classes']['class_childs']) && $this->design['classes']['class_childs'])?$this->design['classes']['class_childs']:1):''; $zaco[12]=$item['blank']?'target="_blank"':''; $zaco[13]=isset($this->design['classes']['item_'.$item['level']])?$this->design['classes']['item_'.$item['level']]:$item['level']; $res.=str_replace($co,$zaco,$this->design['item_before']); if (($item['typ']==1 && !empty($item['art'])) || ($item['typ']==3 && $item['link'])): $res.=str_replace($co,$zaco,$this->design['item']); elseif($item['typ']==2): $res.=str_replace($co,$zaco,$this->design['title']); endif; if((!empty($this->polozky[$item['ID']])) and ($item['level']<$this->level_to)): $res.=$this->generateItems($item['ID']); endif; $res.=$this->design['item_after']; endif; endforeach; $res.=$this->design['group_after']; endif; return $res; } public function run(){ global $cfg,$debug,$syscom; if ($cfg['debug_mode']) $start=microtime(true)*1000; $res=''; if (!empty($this->info) && !empty($this->design)): //nadradena polozka if ($this->level_from==1): $nadrad=0; else: if (!empty($this->opened)): $nadrad=getValue('SELECT nadrad FROM cms_menu_01 WHERE menu='.$this->ID.' AND level='.intval($this->level_from).' AND nadrad IN ('.implode(',',$this->opened).')');//." ORDER BY level DESC" endif; if(empty($nadrad) and !empty($this->vzdy)): $nadrad=getValue('SELECT ID FROM cms_menu_01 WHERE menu='.$this->ID.' AND level='.($this->level_from-1).' ORDER BY poradie'); endif; $nadrad=empty($nadrad)?-1:$nadrad; endif; //polozky if ($nadrad<>-1): $openlist=$this->opened; $openlist[$nadrad]=$nadrad; if ($this->p['open_all']): $polozky=getTable('SELECT nadrad,ID,art,nazov,typ,par1,par2,level,childs,link,blank FROM cms_menu_01 WHERE menu='.$this->ID.' AND level>='.$this->level_from.' AND level<='.$this->level_to.' ORDER BY poradie'); else: $polozky=getTable('SELECT nadrad,ID,art,nazov,typ,par1,par2,level,childs,link,blank FROM cms_menu_01 WHERE menu='.$this->ID.' AND nadrad IN ('.implode(',',$openlist).') AND level>='.$this->level_from.' AND level<='.$this->level_to.' ORDER BY poradie'); endif; $arts=array(); $this->polozky=array(0=>array()); for($i=0;$ipolozky[$polozky[$i]['nadrad']][]=$polozky[$i]; if ($polozky[$i]['typ']==1) $arts[]=$polozky[$i]['art']; endfor; if (!empty($arts)): $this->arts=getArray('SELECT ID, nazov, page, redir'.($this->compat?'':', seo_link').', lang FROM art WHERE ID IN ('.implode(',',$arts).') AND '.getRightSel($this->uid,$this->grps)); $syscom->locator->loadLinks($arts,$this->lang); endif; //generovanie menu $res.=$this->generateItems($nadrad); endif; endif; if ($cfg['debug_mode']): $debug->debugAction('Menu['.$this->info['kod'].']: generate',$start); endif; return $res; } } ?>