db=new InterCE_DB(1); $this->t=new cTemplate('_HTML'); $this->sess=&$sess_allow; // $this->conf=&$conf; $requrence=array(); } ################################################################################### ## gets needed content of label in specified language (either given or default) function get_lang_text($name,&$out,$lang='') { if($lang) $this->get_text($name,$out,$lang); else $this->get_text($name,$out,$this->conf['lang']); } ################################################################################### ## gets content of label from database, if no language is specified gets universal ## version of label function get_text($name,&$out,$lang='') { $n_cross=$n_data=false; if($lang=='') $lang=$this->conf['lang']; $this->db->query(0,"select id,type,data from storage_defs where name='$name' and lang='$lang'"); if($this->db->next_row(0)) { $type=$this->db->get(0,'type'); $data=$this->db->get(0,'data'); $this->db->query(0,'select `table`,`row` from storage_cross where id='.$data); if($this->db->next_row(0)) { $table=$this->db->get(0,'table'); $row=$this->db->get(0,'row'); if($table!='u') { $this->db->query(0,'select `data` from storage_'.$table.'_data where id='.$row); if($this->db->next_row(0)) { $out=$this->db->get(0,'data'); } else if($this->sess) //FIXME: allowed only when apropriate permission is granted $n_data=true; } else if($this->sess) //FIXME: allowed only when apropriate permission is granted $n_data=true; } else if($this->sess) //FIXME: allowed only when apropriate permission is granted $n_cross=$n_data=true; } if($n_data) { $this->db->query(0,'insert into storage_s_data (data) values (\'\')'); $row=$this->db->get_rowid(0); $table='s'; $out=''; if(!$n_cross) $this->db->query(0,"update storage_cross set `table`='$table', `row`=$row where id=$data"); } if($n_cross) { $this->db->query(0,"commit"); $this->db->query(0,"insert into storage_cross (`table`,`row`) values ('$table',$row)"); $data=$this->db->get_rowid(0); $this->db->query(0,"commit"); $this->db->query(0,"update storage_defs set data=$data where name='$name' and lang='$lang'"); } if($this->sess) //FIXME: allowed only when apropriate permission is granted { $a['CMS_INIT']['name']=$name; $a['CMS_INIT']['title']=$name; $a['CMS_INIT']['lang']=$this->conf['lang']; $this->t->runTemplate($this->conf['templates_dir'].'interCE_cms_'.$this->conf['cms_template'].'.thtml',$a); $out.=$this->t->html; } } ################################################################################### ## gets full content of label and returns clear html content function get_content($name,&$out) { $a=array(); $a['CMS_OUT']=$this->parse_content($name); $this->t->runTemplate($this->conf['templates_dir'].'interCE_cms_'.$this->conf['cms_template'].'.thtml',$a); $out.=$this->t->html; } ################################################################################### ## parses content of label with requrences tracking function parse_content($name) { $result=''; $spc=substr($name,0,1); if($spc=='@') // get content of special tag { $spc=substr($name,1); if($spc=='login_form') return array('cms'=>$this->page_login_form(),'name'=>$name); // else if($spc=='current_user_list') // return array('cms'=>page_current_users(),'name'=>$name); } else { $this->get_text($name,$result); // get content of label from database $run=true; $str=0; // preg_match_all('/(\[\[)(.+)(]])/',$result,$matches,PREG_OFFSET_CAPTURE); // FIXME: change loop below to preg_match_all //dig($matches); while($run) { $str=strpos($result,'[[',$str); if($str===false) $run=false; else { $stp=strpos($result,']]'); if($stp===false) $run=false; else { $pre=substr($result,0,$str); $str+=2; $mid=substr($result,$str,$stp-$str); $sem=strpos($mid,':'); if($sem===false) { global $conf; $lang=$this->conf['lang']; } else { $lang=substr($mid,0,$sem); $mid=substr($mid,$sem+1); } $med=$mid; $this->get_text($med,$mid,$lang); $pos=substr($result,$stp+2); //$result=$pre.'

'.$mid.'

'.$pos; $result=$pre.$mid.$pos; } } } } return array('cms'=>$result,'name'=>$name); } ################################################################################### ## parses content of label with requrences tracking function edit_content(&$out,&$id,&$name,$lang,&$content) { if($id) $this->db->query(0,'select d.id,`table`,row from storage_defs d,storage_cross c where d.id='.$id.' and c.id=d.data'); else { if($lang=='') $lang=$this->conf['lang']; $this->db->query(0,"select d.id,`table`,row from storage_defs d,storage_cross c where d.name='$name' and d.lang='$lang' and c.id=d.data"); } if($this->db->next_row(0)) { $id=$this->db->get(0,'id'); $this->db->query(0,'select `data` from storage_'.$this->db->get(0,'table').'_data where id='.$this->db->get(0,'row')); if($this->db->next_row(0)) { $data=$this->db->get(0,'data'); $this->db->query(0,'select d.name dn,t.name dt,d.lang from storage_defs d,storage_types t where d.id='.$id.' and t.id=d.type'); if($this->db->next_row(0)) { $a['CMS']['DEF']['id']=$id; $a['CMS']['DEF']['name']=$this->db->get(0,'dn'); $a['CMS']['DEF'][strtoupper($this->db->get(0,'dt'))]=''; $a['CMS']['DEF']['lang']=$this->db->get(0,'lang'); $a['CMS']['DEF']['content']=htmlspecialchars(str_replace(array("\r","\n"),array('',''),$data)); $a['CMS']['DEF']['refer']=$_SERVER['HTTP_REFERRER']; } } } else { $lang=$this->conf['lang']; $this->db->query(0,"insert into storage_s_data (data) values ('')"); $id=$this->db->get_rowid(); $this->db->query(0,"insert into storage_cross (`table`,`row`) values ('s',$id)"); $id=$this->db->get_rowid(); $this->db->query(0,"insert into storage_defs (name,type,lang,data) values ('$name',1,'$lang',$id)"); $id=$this->db->get_rowid(); $this->db->query(0,"commit"); $this->db->query(0,'select name from storage_types where id=1'); if($this->db->next_row(0)) { global $_SERVER; $a['CMS']['DEF']['id']=$id; $a['CMS']['DEF']['name']=$name; $a['CMS']['DEF'][strtoupper($this->db->get(0,'name'))]=''; $a['CMS']['DEF']['lang']=$lang; $a['CMS']['DEF']['content']=''; $a['CMS']['DEF']['refer']=$_SERVER['HTTP_REFERRER']; } } $this->t->runTemplate($this->conf['templates_dir'].'interCE_cms_'.$this->conf['cms_template'].'.thtml',$a); $out=$this->t->html; } ################################################################################### } ### end of InterCE_CMS ################################################################################### /* History: 2022.09.29 0.2.1 mod to adapt to PHP 8.1.8 edit_content() does not provide invoking withoul lang specified 2006.11.25 0.2.0 mod CMS functions encapsulated into class first version */ ?> 'A',1=>'9',2=>'B',3=>'C',4=>'D',5=>'E',6=>'F',7=>'G',8=>'H',9=>'I',10=>'J',11=>'K',12=>'L' ,13=>'M',14=>'N',15=>'O',16=>'P',17=>'Q',18=>'R',19=>'S',20=>'T',21=>'U',22=>'V',23=>'W',24=>'X',25=>'Y' ,26=>'Z',27=>'1',28=>'2',29=>'3',30=>'4',31=>'5',32=>'6',33=>'7',34=>'8'); $bin=''; $val=''; $l=strlen($string); for($i=0;$i<$l;$i+=2) $bin=sprintf('%s%08s',$bin,decbin(hexdec(substr($string,$i,2)))); $l=strlen($bin); for($i=0;$i<$l;$i+=10) { $ten=bindec(substr($bin,$i,10)); $t1=floor($ten/34); $t2=$tab[$ten-$t1*34]; $t1=$tab[$t1]; $val=$t1.$t2.$val; } return $val; } ################################################################################### ## changes decimal value into string of letters and digits which is shorter ## than original value function dec_literate($string,$len=0) { $tab=array(0=>'A',1=>'9',2=>'B',3=>'C',4=>'D',5=>'E',6=>'F',7=>'G',8=>'H',9=>'I',10=>'J',11=>'K',12=>'L' ,13=>'M',14=>'N',15=>'O',16=>'P',17=>'Q',18=>'R',19=>'S',20=>'T',21=>'U',22=>'V',23=>'W',24=>'X',25=>'Y' ,26=>'Z',27=>'1',28=>'2',29=>'3',30=>'4',31=>'5',32=>'6',33=>'7',34=>'8'); $bin=''; $val=''; $l=strlen($string); if($len==0) $len=$l; $string=sprintf('%0'.$len.'s',$string); for($i=0;$i<$l;$i+=2) $bin.=sprintf('%07s',decbin(substr($string,$i,2))); $l=ceil(strlen($bin)/10)*10; $bin=sprintf('%0'.$l.'s',$bin); for($i=0;$i<$l;$i+=10) { $ten=bindec(substr($bin,$i,10)); $t1=floor($ten/34); $t2=$tab[$ten-$t1*34]; $t1=$tab[$t1]; $val=$t1.$t2.$val; } return $val; } ################################################################################### ## changes literated decimal value into original decimal value function dec_deliterate($string) { $tab=array('A'=>0,'9'=>1,'B'=>2,'C'=>3,'D'=>4,'E'=>5,'F'=>6,'G'=>7,'H'=>8,'I'=>9,'J'=>10,'K'=>11,'L'=>12 ,'M'=>13,'N'=>14,'O'=>15,'P'=>16,'Q'=>17,'R'=>18,'S'=>19,'T'=>20,'U'=>21,'V'=>22,'W'=>23,'X'=>24,'Y'=>25 ,'Z'=>26,'1'=>27,'2'=>28,'3'=>29,'4'=>30,'5'=>31,'6'=>32,'7'=>33,'8'=>34); $bin=''; $val=''; $l=strlen($string); for($i=0;$i<$l;$i+=2) { $t1=$tab[substr($string,$i,1)]; $t2=$tab[substr($string,$i+1,1)]; $bin=sprintf('%010s',decbin($t1*34+$t2)).$bin; } $l=ceil(strlen($bin)/7)*7; $bin=sprintf('%0'.$l.'s',$bin); for($i=0;$i<$l;$i+=7) $val.=bindec(substr($bin,$i,7)); $l=0; $i=substr($val,0,1); while($i=='0') { $l++; $i=substr($val,$l,1); } if($l) $val=substr($val,$l); return $val; } //abcdefghijklmnopqrstuwxyz1234567890 /* History: 2006.12.15 0.0.2 add: dec_deliterate() function add: dec_literate() comments 2006.12.15 0.0.1 first revision */ ?> BLAD KRYTYCZNY: nie mozna wystartowac sesji!