debug = $debug; } function counter($sgn) { if ($sgn=="+") {$sql=" update counter cvalue set cvalue=cvalue+1"; $this->Login(); $this->ExecSQL($sql); $this->Logoff();} } function getcounter() { $sql=" select ip,cvalue from counter "; $this->Login(); $tmp=$this->Take($sql); $this->Logoff(); return $tmp[0][1]; } function getExtIco($ext) { $extArr=array('pdf','png','xls','doc','zip','jpg','jpeg','zip','txt'); if (in_array($ext,$extArr)) return $ext; else return 'nn'; } function langOn() { $sql="select lang from lang where status=1"; $this->Login(); $tmp=$this->TakeArr($sql); $this->Logoff(); return $tmp; } function getImage($modul,$box,$lang,$rewrite) { $path='images/'; if (!empty($box)) $box='-'.$box; if (!empty($lang)) $lang='-'.$this->getLang($_REQUEST[lang]); if (!empty($rewrite)) $rewrite='-'.$rewrite; if (file_exists('../'.$path.$modul.$box.$lang.$rewrite.'.png')) return $path.$modul.$box.$lang.$rewrite.'.png'; if (file_exists('../'.$path.$modul.$box.$lang.$rewrite.'.jpg')) return $path.$modul.$box.$lang.$rewrite.'.jpg'; if (file_exists('../'.$path.$modul.$box.'-pl'.$rewrite.'.png')) return $path.$modul.$box.'-pl'.$rewrite.'.png'; if (file_exists('../'.$path.$modul.$box.'-pl'.$rewrite.'.jpg')) return $path.$modul.$box.'-pl'.$rewrite.'.jpg'; if (file_exists('../'.$path.$modul.$box.$lang.'.png')) return $path.$modul.$box.$lang.'.png'; if (file_exists('../'.$path.$modul.$box.$lang.'.jpg')) return $path.$modul.$box.$lang.'.jpg'; if (file_exists('../'.$path.$modul.$box.'-pl'.'.png')) return $path.$modul.$box.'-pl'.'.png'; return $path.$modul.$box.'-pl'.'.jpg'; } function genKey() { return $this->KeyTable[(rand(0,count($this->KeyTable)))]; } function getLang($lang) { $tmp=$this->langOn(); for ($i=0; $iLogin(); $TMP=$this->TakeArr($sql); $this->Logoff(); return $TMP; } function getParamsValue($param) { $sql="select param_value,param,param_title,id,param_p1 from params where id='".$param."'"; $this->Login(); $TMP=$this->TakeArr($sql); $this->Logoff(); return $TMP; } function addParams($type,$p1,$p2) { switch (true) { case $type=="patternfile" : if (!empty($p2)) if ( is_uploaded_file($p2['tmp_name']) ) $mysqlPicture = addslashes(fread(fopen($p2['tmp_name'], "r"), $p2['size'])); else $mysqlPicture=' '; $sql= "insert into params SET param=concat('pattern".$p1."file_',".mt_rand(0,99999)."),param_title='".$p2['name']."',param_value='".$mysqlPicture."',param_p1='".$p2['size']."',param_p2='".$p2['type']."'"; $this->Login(); $this->ExecSQL($sql); $this->Logoff(); break; case $type=="pattern" : $this->Login(); $this->ExecSQL('BEGIN'); $sql= " insert into params SET param='paterncore'"; if ($this->ExecSQL($sql)>0) {$newid=mysql_insert_id(); $SQL[] = "update params set param='pattern".$newid."core',param_title='".$p1[patterncore]."', param_value='".$p1[patterncore]."' where Id='".$newid."'"; $SQL[] = "insert into params set param='pattern".$newid."subject' ,param_title='Temat', param_value='".$p1[patternsubject]."'"; $SQL[] = "insert into params set param='pattern".$newid."title' ,param_title='Opis dodatkowy', param_value='".$p1[patterntitle]."'"; $this->ExecTrans($SQL); $this->ExecSQL('COMMIT'); } else $this->ExecSQL('ROLLBACK'); $this->Logoff(); break; } } function delParams($wynik,$type) { $ctemp=count($wynik); $this->Login(); switch ($type) { case 'pattern': for ($i=0; $i<$ctemp; $i++){ $SQL[]="delete from params where param like '".$wynik[$i]."%' and param_type='I'"; } break; default: for ($i=0; $i<$ctemp; $i++){ $SQL[]="delete from params where id=".$wynik[$i]." and and param_type='I'"; } } $this->ExecTrans($SQL); $this->Logoff(); } function updParams($wynik) { $SQL=array(); while($val = current($wynik)) { $SQL[]= "update params set param_value='".$val."',param_title='".$val."' where param='".key($wynik)."'"; next($wynik); } $this->Login(); $this->ExecTrans($SQL); $this->Logoff(); } function TakeArr($LSQL) { if($this->debug==true) echo $LSQL."
"; // echo $LSQL; $result = mysql_query($LSQL,$this->conn); if (!$result) { die('Invalid query : ' . mysql_error().$LSQL); } //$tab=mysql_fetch_array($result); $keys=array('products_extra','Extra_'.$_REQUEST[lang]); $ckeys=count($keys); while($t=mysql_fetch_array($result)) { for ($i=0; $i<$ckeys; $i++){ $t[$keys[$i]]=html_entity_decode($t[$keys[$i]],ENT_COMPAT,'UTF-8'); }; $tab[]=$t; } return $tab; } function ExecTrans($ARR,$trans_parent=0) { $i=0; $cARR=count($ARR); for ($i=0; $i<$cARR; $i++) { $sql=$ARR[$i]; $result = mysql_query($sql,$this->conn); if(!$result) { echo 'SQL Query failed'.mysql_error(); $log[$i]=0; //zwraca gdy sie nie uda } } return $log; } //------------------------------------------------------------------------------ function Login() { $this->conn = mysql_connect($this->host,$this->user,$this->pass) or die ("Could not connect to MySQL "); $result = mysql_select_db($this->database,$this->conn) or die ("Could not select $this->database database"); } //------------------------------------------------------------------------------ function Logoff() { mysql_close($this->conn); return 0; } //------------------------------------------------------------------------------ function TakeTrans($sql,$trans) { if($this->debug==true) echo $sql."
"; $result = mysql_db_query($this->database,$sql,$trans); while($t=mysql_fetch_row($result)) $tab[]=$t; return $tab; } //------------------------------------------------------------------------------ function Take($LSQL) { if($this->debug==true) echo $LSQL."
"; $result = mysql_query($LSQL,$this->conn); if (!$result) { die('Invalid query : ' . mysql_error().$LSQL); } while($t=mysql_fetch_row($result)) $tab[]=$t; return $tab; } function TakeObj($LSQL) { if($this->debug==true) echo $LSQL."
"; $result = mysql_query($LSQL,$this->conn); if (!$result) { die('Invalid query: ' . mysql_error().$LSQL); } $tab=mysql_fetch_object($result); return $tab; } function ExecSQL($sql) { $sqltmp=$sql; while (stripos($sql, ";")>0) {$sqltmp=substr($sql,0,stripos($sql, ";")); $sql=substr($sql,stripos($sql, ";")+1); $result = mysql_query($sqltmp,$this->conn); } $result = mysql_query($sql,$this->conn); if(!$result) { echo 'SQL Query failed'.mysql_error(); return 0; //zwraca gdy sie nie uda } return 1; } function CheckToTable($licznik) { for($i=0; $i<$licznik; $i++) { $wartosc="c".$i; if($_REQUEST[$wartosc]=="on") { $numer="n".$i; $arr[$i]=$$number; echo "--".$i; } } return $arr; } function NavBar1($wszystkie,$HREF,$count) { $PAGES=ceil($wszystkie/$count); echo ""; if($PAGES>1) { //echo ""; echo ""; }echo "
Strony:
"; if ($_REQUEST['offset']!=0){ echo "<< Poprzednia "; } echo "|"; for($i=0,$page=1;$i<$PAGES;$i++,$page++) { if($i*$count==$_REQUEST['offset']) echo "".$page." | "; else echo "$page | "; } echo ""; if ($wszystkie>$_REQUEST['offset']+$count){ echo "Nastepna >>"; } echo "
"; } function NavBarOne($wszystkie,$HREF,$count) { $PAGES=ceil($wszystkie/$count); echo ""; if($PAGES>1) { //echo ""; echo ""; }echo "
Strony:
"; if ($_REQUEST['page']!=0){ echo "<< Poprzednia "; } echo "|"; for($i=0,$page=1;$i<$PAGES;$i++,$page++) { if($i*$count==$_REQUEST['page']) echo "".$page." | "; else echo "$page | "; } echo ""; if ($wszystkie>$_REQUEST['page']+$count){ echo "Nastepna >>"; } echo "
"; } function NavBar6($wszystkie,$HREF,$count,$bg) { $zakres=10; $lz=($zakres/2);$pz=($zakres/2); $PAGES=ceil($wszystkie/$count); echo ""; if($PAGES>1) { //echo ""; echo ""; }echo "
Strony:
"; if ($_REQUEST['page']!=0) {echo " <<Strona: ";} if ((($_REQUEST['page']-$lz)>0) and (($_REQUEST['page']+$pz)<$PAGES )) {$pp=$_REQUEST['page']-$lz; $pk=$_REQUEST['page']+$pz;} if ((($_REQUEST['page']-$lz)>0) and (($_REQUEST['page']+$pz)>$PAGES or $_REQUEST['page']+$pz==$PAGES)) {$pk=$PAGES;$pp=$PAGES-$zakres;} if ((($_REQUEST['page']-$lz)<0 or $_REQUEST['page']-$lz==0) and (($_REQUEST['page']+$pz)<$PAGES)) {$pp=1;$pk=$zakres;} if ((($_REQUEST['page']-$lz)<0 or $_REQUEST['page']-$lz==0) and (($_REQUEST['page']+$pz)>$PAGES or $_REQUEST['page']+$pz==$PAGES)) {$pp=1;$pk=$PAGES;} // for($i=0,$page1=1;$i<$PAGES;$i++,$page1++) for($i=($pp-1),$page1=$pp;$i<$pk;$i++,$page1++) { if(($i*$count)==$_REQUEST['page']) {echo "Strona:"; if (($_REQUEST['page'])==$i) echo ""; else echo ""; echo " ".$page1." "; if (($_REQUEST['page'])==$i) echo "|"; else echo ""; } else {echo ""; if (($_REQUEST['page'])==$i) echo "|"; else echo ""; echo " ".$page1." "; if (($_REQUEST['page'])==$i) echo "|"; else echo ""; } } if ($wszystkie>($_REQUEST['page']*$count)+$count){ echo ">>"; } echo "
"; } function NavBar($wszystkie,$HREF,$count,$bg,$wid) { $zakres=10; $lz=($zakres/2);$pz=($zakres/2); $PAGES=ceil($wszystkie/$count); echo ""; if($PAGES>1) { //echo ""; echo ""; }echo "
Strony:
"; if ($_REQUEST['page']!=0) {echo " <<Strona: ";} if ((($_REQUEST['page']-$lz)>0) and (($_REQUEST['page']+$pz)<$PAGES )) {$pp=$_REQUEST['page']-$lz; $pk=$_REQUEST['page']+$pz;} if ((($_REQUEST['page']-$lz)>0) and (($_REQUEST['page']+$pz)>$PAGES or $_REQUEST['page']+$pz==$PAGES)) {$pk=$PAGES;if ($PAGES<$zakres) $pp=1; else $pp=$PAGES-$zakres;} // if ((($_REQUEST['page']-$lz)<0 or $_REQUEST['page']-$lz==0) and (($_REQUEST['page']+$pz)<$PAGES)) {$pp=1;$pk=$zakres;} // if ((($_REQUEST['page']-$lz)<0 or $_REQUEST['page']-$lz==0) and (($_REQUEST['page']+$pz)>$PAGES or $_REQUEST['page']+$pz==$PAGES)) {$pp=1;$pk=$PAGES;} if ((($_REQUEST['page']-$lz)<0 or $_REQUEST['page']-$lz==0) and (($_REQUEST['page']+$pz)<$PAGES)) {$pp=1; if ($PAGES>$zakres) $pk=$zakres;else $pk=$PAGES;} if ((($_REQUEST['page']-$lz)<0 or $_REQUEST['page']-$lz==0) and (($_REQUEST['page']+$pz)>$PAGES or $_REQUEST['page']+$pz==$PAGES)) {$pp=1;if ($PAGES>$zakres) $pk=$zakres;else $pk=$PAGES;} // for($i=0,$page1=1;$i<$PAGES;$i++,$page1++) for($i=($pp-1),$page1=$pp;$i<$pk;$i++,$page1++) { if(($i*$count)==$_REQUEST['page']) {echo "Strona:"; if (($_REQUEST['page'])==$i) echo ""; else echo ""; echo " ".$page1." "; if (($_REQUEST['page'])==$i) echo "|"; else echo ""; } else {echo ""; if (($_REQUEST['page'])==$i) echo "|"; else echo ""; echo " ".$page1." "; if (($_REQUEST['page'])==$i) echo "|"; else echo ""; } } if ($wszystkie>($_REQUEST['page']*$count)+$count){ echo ">>"; } echo "
"; } function getTree( $lng,$node,$stopdepth) { $sql="select bone.id,parent,child,depth,category.Name_".$lng." as cname,category.CategoryName,category.image from bone inner join category on bone.child=category.Id where parent='".$node."' order by CategoryName,cname"; $this->Login(); $tree=$this->TakeArr($sql); $this->Logoff(); $ctree=count($tree); // if (empty($tree) or $tree[0][depth]>$stopdepth ) # jezeli brak rekodow opuszczam funkcje // { // return ; // } $initdepth=$tree[0][depth]; if (is_array($tree) and ($initdepth <$stopdepth or $initdepth ==$stopdepth )) { while($val = current($tree)) { $this->TreeRecord[]=array(str_repeat('-',$val[depth]),$val[child],$val[cname],$val[CategoryName],$val[image]); # wyswietlam nazwe pierwszego rekodu zwroconego przez SELECT; $this->getTree($lng,$val[child],$initdepth); next($tree); }} // for($r=0;($r<$ctree );$r++) # przechodze po rekordach skladnia musi byc z PHP // { // $this->TreeRecord[]=array(str_repeat('-',$tree[$r][depth]),$tree[$r][child],$tree[$r][cname],$tree[$r][CategoryName],$tree[$r][image]); # wyswietlam nazwe pierwszego rekodu zwroconego przez SELECT; // $this->getTree($lng,$tree[$r][child],$tree[0][depth]); // } } function getNodeCurent($lng,$nodename) {// parametry kategorii o nazwie $nodename $sql="select category.Name,category.Name_".$lng." as cname,category.CategoryName,category.image,category.Restriction,category.CategoryAction,category.id from category where category.Name='".$nodename."'"; $this->Login(); $tree=$this->TakeArr($sql); return $tree; } function getTreeNative( $lng,$node,$stopdepth) { $sql="select bone.id,parent,child,depth,category.Name_".$lng." as cname,category.CategoryName,category.image,category.Name,category.CategoryAction from bone inner join category on bone.child=category.Id where parent=".$node." order by category.Priority,cname"; $this->Login(); $tree=$this->TakeArr($sql); $this->Logoff(); $ctree=count($tree); if (empty($tree) or $tree[0][depth]>$stopdepth ) # jezeli brak rekodow opuszczam funkcje { return ; } $initdepth=$tree[0][depth]; if (is_array($tree) and ($initdepth <$stopdepth or $initdepth ==$stopdepth )) { while($val = current($tree)) { $this->TreeRecord[]=array(str_repeat('-',$val[depth]),$val[child],$val[cname],$val[CategoryName],$val[image],$val[Name],$val[CategoryAction]); # wyswietlam nazwe pierwszego rekodu zwroconego przez SELECT; $this->getTreeNative($lng,$val[child],$stopdepth); next($tree); }} } function getTreeTmp( $lng,$node,$stopdepth) { $sql="select bone.id,parent,child,depth,category.Name_".$lng." as cname,category.CategoryName,category.image from bone inner join category on bone.child=category.Id where parent='".$node."' order by CategoryName,cname"; $this->Login(); $tree=$this->TakeArr($sql); $this->Logoff(); $ctree=count($tree); // if (empty($tree) or $tree[0][depth]>$stopdepth ) # jezeli brak rekodow opuszczam funkcje // { // return ; // } for($r=0;$r<$ctree;$r++) # przechodze po rekordach skladnia musi byc z PHP { $this->TreeRecordTmp[]=array(str_repeat('-',$tree[$r][depth]),$tree[$r][child],$tree[$r][cname],$tree[$r][CategoryName],$tree[$r][image]); # wyswietlam nazwe pierwszego rekodu zwroconego przez SELECT; $this->getTreeTmp($lng,$tree[$r][child],$tree[0][depth]); } } function getTreeNull( $lng,$node,$stopdepth) { // ta sama funkcja co getTree tylko bez rekordu nadrzednego $sql="select bone.id,parent,child,depth,category.Name_".$lng." as cname,category.CategoryName,category.image from bone inner join category on bone.child=category.Id where parent='".$node."' order by CategoryName,cname"; $this->Login(); $tree=$this->TakeArr($sql); $this->Logoff(); $ctree=count($tree); // if (empty($tree) or $tree[0][depth]>$stopdepth ) # jezeli brak rekodow opuszczam funkcje // { // return ; // } for($r=0;$r<$ctree;$r++) # przechodze po rekordach skladnia musi byc z PHP { // $this->TreeRecord[]=array(str_repeat('-',$tree[$r][depth]),$tree[$r][child],$tree[$r][cname],$tree[$r][CategoryName],$tree[$r][image]); # wyswietlam nazwe pierwszego rekodu zwroconego przez SELECT; $this->getTree($lng,$tree[$r][child],$tree[0][depth]); } } function getTreeRev( $lng,$node) {$sql="select bone.id,parent,child,depth,category.Name_".$lng." as cname,category.CategoryName,category.image from bone inner join category on bone.child=category.Id where child='".$node."'"; $this->Login(); $tree=$this->TakeArr($sql); $this->Logoff(); $ctree=count($tree); if (empty($tree) ) # jezeli brak rekodow opuszczam funkcje {return ;} for($r=0;$r<$ctree;$r++) # przechodze po rekordach skladnia musi byc z PHP { $this->TreeRecord[]=array(str_repeat('-',$tree[$r][depth]),$tree[$r][child],$tree[$r][cname],$tree[$r][CategoryName],$tree[$r][image]); # wyswietlam nazwe pierwszego rekodu zwroconego przez SELECT; $this->getTreeRev($lng,$tree[$r][parent],$tree[0][depth]); } } function getTreeRevTmp( $lng,$node) {$sql="select bone.id,parent,child,depth,category.Name_".$lng." as cname,category.CategoryName,category.image from bone inner join category on bone.child=category.Id where child='".$node."'"; $this->Login(); $tree=$this->TakeArr($sql); $this->Logoff(); $ctree=count($tree); if (empty($tree) ) # jezeli brak rekodow opuszczam funkcje {return ;} for($r=0;$r<$ctree;$r++) # przechodze po rekordach skladnia musi byc z PHP { $this->TreeRecordTmp[]=array(str_repeat('-',$tree[$r][depth]),$tree[$r][child],$tree[$r][cname],$tree[$r][CategoryName],$tree[$r][image]); # wyswietlam nazwe pierwszego rekodu zwroconego przez SELECT; $this->getTreeRevTmp($lng,$tree[$r][parent],$tree[0][depth]); } } function TreeLink($lng,$node,$nodeb,$href) {// $node - wezel poczatkowy // $nodeb - wezel koncowy $this->TreeRecord=array(); $this->getTreeRev($lng,$node,5); $this->TreeRecord=array_reverse($this->TreeRecord); //$link=$this->TreeRecord[0][2]; for($i=count($this->TreeRecord);$i>0 and $this->TreeRecord[$i-1][1]!=$nodeb ;$i--) { $link="".$this->TreeRecord[$i-1][2].""." / ".$link; } $this->TreeRecord=array(); return $link; } function Tree($lng,$node,$stopdepth) { $this->getTreeRev( $lng,$node); /// $this->TreeRecord=array_slice ($this->TreeRecord, 1); $this->TreeRecord=array_reverse($this->TreeRecord); $this->getTree( $lng,$node, $stopdepth); $tmp=$this->getTreeNodeCurrent($lng,$node); if (is_array($tmp)){ while($val = current($tmp)){ if ($val[child] != $node) $this->TreeRecord[]=array(str_repeat('-',$val[depth]),$val[child],$val[cname],$val[CategoryName],$val[image]); next($tmp); } } return; } function TreeTmp($lng,$node,$stopdepth) { $this->getTreeRevTmp( $lng,$node); // $this->TreeRecord=array_slice ($this->TreeRecord, 1); $this->TreeRecordTmp=array_reverse($this->TreeRecordTmp); $this->getTreeTmp( $lng,$node, $stopdepth); return; } function getTreeNodeCurrent($lng,$node) {// wybiera wszystkie podrekordy nalezce do grupy o numerze $node $sql="select bone.id,parent,child,depth,category.Name,category.Name_".$lng." as cname,category.CategoryName,category.image,category.Restriction from (select * from bone where parent=(select parent from bone where child=".$node.") ) as bone inner join category on bone.child=category.Id order by category.Priority,cname"; $this->Login(); $tree=$this->TakeArr($sql); return $tree; } function getTreeNode($lng,$node) {// wybiera wszystkie podrekordy nalezce do grupy o numerze $node $sql="select bone.id,parent,child,depth,category.Name,category.Name_".$lng." as cname,category.CategoryName,category.image,category.imageen,category.Restriction from bone inner join category on bone.child=category.Id where parent='".$node."'"; $this->Login(); $tree=$this->TakeArr($sql); return $tree; } function GetUser($login,$pwd) { $sql=" select * from administrator where adm_login='".$login."' and adm_password='".$pwd."'"; $this->Login(); $tmp=$this->TakeArr($sql); $this->Logoff(); if (!empty($tmp)) { $_SESSION['User']=$tmp[0][0]; $_SESSION['Pwd']=$tmp[0][1]; $_SESSION['Prawo1']=$tmp[0][2]; $_SESSION['Prawo2']=$tmp[0][3]; $_SESSION['Prawo3']=$tmp[0][4]; if (!empty($tmp[0][dbuser])){ $this->user = $tmp[0][dbuser]; $this->pass = $tmp[0][dbpwd]; $this->charset=$tmp[0][dbcharset]; $this->host =$tmp[0][dbhost]; $this->database =$tmp[0][db]; $this->urlpath=$tmp[0][urlpath]; $this->BaseDir=$tmp[0][basedir]; $this->BaseDir2=$tmp[0][basedir2]; $this->PictDir= $tmp[0][pictdir]; $this->ImgSize= $tmp[0][imgsize]; $this->ImgSizeExt=$tmp[0][imgsizeext]; $this->ImgSizeSlide =$tmp[0][imgsizeslide]; $this->KeyTable = explode(',', $tmp[0][key1]); } $stat=1; } else { $stat=0; $_SESSION['User']=''; $_SESSION['Pwd']=''; $_SESSION['Prawo1']=''; $_SESSION['Prawo2']=''; $_SESSION['Prawo3']=''; $_SESSION['basedir']=''; } return $stat; } function AddLog($actiontext) { $sql= "insert into action_log (action_date,client,address,extra) values ('".date("Y-m-d H:i:s")."','".addcslashes(str_replace(';','',$_SERVER['HTTP_USER_AGENT']),'.')."','".addcslashes($_SERVER['REMOTE_ADDR'],'.')."','".$actiontext."')"; $this->Login(); $this->ExecSql($sql); $this->Logoff; } function browseUsers($id) { $sql= " select ID,Nick,Name from users"; if (!empty($id)) $sql.=" where ID='".$id."'"; $this->Login(); $tmp=$this->Take($sql); return $tmp; } function ShowGallery($ARR,$kolumn,$wierszy,$fp,$skinfile) // $width - szeroko�� w ilo�ciach obrazk�w // $ARR - tablica rysunk�w; // $fp - element do podswietlenia { if (empty($ARR)) return $res; $width=3; $high=ceil($count/$width); $tt=floor($count/$width); $k=$kolumn;$w=$wierszy; $width=$kolumn; $high=$wierszy; $j=0;$cARR=count($ARR); $pg=$_REQUEST['page']; if (!empty($_REQUEST['page'])) $pgurl="&page=".$pg; echo ""; do { $i=0; echo ""; do { $p=($k*$w*$pg)+($j*$k)+$i; //$this->GallerySkin($ARR,$p); include("admin/template/".$skinfile.".php"); $i++;} while (($i<$k and $p<($cARR)-1) ) ; echo "";$j++; } while (($j<$w and $p<($cARR)-1)); echo "
"; } function ShowGallery1($ARR,$kolumn,$wierszy,$fp,$skinfile) // $width - szeroko�� w ilo�ciach obrazk�w // $ARR - tablica rysunk�w; // $fp - element do podswietlenia { if (empty($ARR)) return $res; $width=3; $high=ceil($count/$width); $tt=floor($count/$width); $k=$kolumn;$w=$wierszy; $width=$kolumn; $high=$wierszy; $j=0;$cARR=count($ARR); $pg=$_REQUEST['offset']/($w*$k); if (!empty($_REQUEST['page'])) $pgurl="&page=".$pg; echo ""; do { $i=0; echo ""; do { $p=($k*$w*$pg)+($j*$k)+$i; //$this->GallerySkin($ARR,$p); include("admin/template/".$skinfile.".php"); $i++;} while (($i<$k and $p<($cARR)-1) ) ; echo "";$j++; } while (($j<$w and $p<($cARR)-1)); echo "
"; } }?>Base($debug); } function getSystemObject($id) { $sql="select * from options where id=".$id; $this->Login(); $tmp=$this->TakeArr($sql); $this->Logoff(); return $tmp; } function getSystemObjects($lang,$child,$id) { if (empty($child)) $activ=0; else $activ=1; $sql=" select id,name,title,status,child,lang,typeo,p1,p2,p3 from options where name like '%".$id."%' and (lang='".$lang."' or lang is null) and (child in ('"; $this->TreeRecordTmp=array(); $this->getTreeRevTmp($lang,$child); for ($i=0; $iTreeRecordTmp); $i++) { if ($i>0) $sql.="','"; $sql.=$this->TreeRecordTmp[$i][1];} $sql.="') or child is null) order by name,lang,child"; $this->Login(); $tmp=$this->TakeArr($sql); $this->Logoff(); return $tmp; } function getSystemObjectStatus($lang,$child,$id) { $sql=" select status from options where name='".$id."'"; if (empty($lang)) $sql.=" and lang is null" ; else $sql.=" and lang='".$lang."'"; if (empty($child)) $sql.=" and child is null"; else $sql.=" and child='".$child."'"; $this->Login(); $tmp=$this->Take($sql); $this->Logoff(); if (!empty($tmp)) return $tmp[0][0]; $sql=" select status from options where name='".$id."'"; if (empty($lang)) $sql.=" and lang is null"; else $sql.=" and lang='".$lang."'"; $sql.=" and child is null"; $this->Login(); $tmp=$this->Take($sql); $this->Logoff(); if (!empty($tmp)) return $tmp[0][0]; $sql=" select status from options where name='".$id."'"; $sql.=" and lang is null and child is null"; $this->Login(); $tmp=$this->Take($sql); $this->Logoff(); if (!empty($tmp)) return $tmp[0][0]; } function getSystemObjectStatus3($lang,$child,$id) { $this->TreeRecordTmp=array(); $this->getTreeRevTmp($lang,$child); $tmp=$this->TreeRecordTmp; if (!empty($tmp)) { $sql=" select status from options where name='".$id."' and lang='".$lang."' and child in ("; for ($i=0; $i0) $sql.=','; $sql.=$tmp[$i][1];} $sql.=")" ; $this->Login(); $tmp=$this->TakeArr($sql); $this->Logoff(); if (!empty($tmp))$tmp=end($tmp);} return $tmp[status]; } function getSystemObjectTitle3($lang,$child,$id) { $this->TreeRecordTmp=array(); $this->getTreeRevTmp($lang,$child); $tmp=$this->TreeRecordTmp; $sql=" select title from options where name='".$id."' and lang='".$lang."' and child "; if (!empty($tmp)) { $sql.=" in ("; for ($i=0; $i0) $sql.=','; $sql.=$tmp[$i][1];} $sql.=")" ; } else $sql.=" is null"; $this->Login(); $tmp=$this->TakeArr($sql); $this->Logoff(); if (!empty($tmp))$tmp=end($tmp); return $tmp[title]; } function getSystemObjectTitle($lang,$child,$id) { $sql=" select title from options where name='".$id."'"; if (empty($lang)) $sql.=" and lang is null" ; else $sql.=" and lang='".$lang."'"; if (empty($child)) $sql.=" and child is null"; else $sql.=" and child='".$child."'"; $this->Login(); $tmp=$this->Take($sql); $this->Logoff(); if (!empty($tmp)) return $tmp[0][0]; $sql=" select title from options where name='".$id."'"; if (empty($lang)) $sql.=" and lang is null"; else $sql.=" and lang='".$lang."'"; $sql.=" and child is null"; $this->Login(); $tmp=$this->Take($sql); $this->Logoff(); if (!empty($tmp)) return $tmp[0][0]; $sql=" select title from options where name='".$id."'"; $sql.=" and lang is null and child is null"; $this->Login(); $tmp=$this->Take($sql); $this->Logoff(); if (!empty($tmp)) return $tmp[0][0]; } function getSystemObjectStatus2($lang,$child,$id) { $sql=" select status from options where child='".$child."' and lang='".$lang."'and name='".$id."'"; $this->Login(); $tmp=$this->Take($sql); $this->Logoff(); if (!empty($tmp)) return $tmp[0][0]; $sql=" select status from options where lang='".$lang."' and name='".$id."'"; $this->Login(); $tmp=$this->Take($sql); $this->Logoff(); if (!empty($tmp)) return $tmp[0][0]; $sql=" select status from options where child='".$child."' and name='".$id."'"; $this->Login(); $tmp=$this->Take($sql); $this->Logoff(); if (!empty($tmp)) return $tmp[0][0]; $sql=" select status from options where name='".$id."'"; $this->Login(); $tmp=$this->Take($sql); $this->Logoff(); return $tmp[0][0]; } function getSystemObjectType($lang,$child,$id) { $sql=" select typeo,p1,p2,p3,p4,p5 from options where child='".$child."' and lang='".$lang."'and name='".$id."' "; $this->Login(); $tmp=$this->TakeArr($sql); $this->Logoff(); if (!empty($tmp))return $tmp[0]; $sql=" select typeo,p1,p2,p3,p4,p5 from options where lang='".$lang."' and name='".$id."' "; $this->Login(); $tmp=$this->TakeArr($sql); $this->Logoff(); if (!empty($tmp))return $tmp[0]; $sql=" select typeo,p1,p2,p3,p4,p5 from options where child='".$child."' and name='".$id."' "; $this->Login(); $tmp=$this->TakeArr($sql); $this->Logoff(); if (!empty($tmp))return $tmp[0]; $sql=" select typeo,p1,p2,p3,p4,p5 from options where name='".$id."' "; $this->Login(); $tmp=$this->TakeArr($sql); $this->Logoff(); return $tmp[0]; } function getSystemObjectTitle2($lang,$child,$id) {$lang=$this->getLang($lang); $sql=" select title from options where child='".$child."' and lang='".$lang."'and name='".$id."' "; $this->Login(); $tmp=$this->Take($sql); $this->Logoff(); if (!empty($tmp))return $tmp[0][0]; if (empty($child)) {$sql=" select title from options where lang='".$lang."' and name='".$id."' "; $this->Login(); $tmp=$this->Take($sql); $this->Logoff(); if (!empty($tmp))return $tmp[0][0];} if (empty($lang)){ $sql=" select title from options where child='".$child."' and name='".$id."' "; $this->Login(); $tmp=$this->Take($sql); $this->Logoff(); if (!empty($tmp))return $tmp[0][0];} $sql=" select title from options where name='".$id."' "; $this->Login(); $tmp=$this->Take($sql); $this->Logoff(); return $tmp[0][0]; } function getSystemObjectAction($id) { $sql=" select action from options where name='".$id."' and child is null and lang is null"; $this->Login(); $tmp=$this->Take($sql); $this->Logoff(); return $tmp[0][0]; } function getSystemObjectAction3($lang,$child,$id) { $this->TreeRecordTmp=array(); $this->getTreeRevTmp($lang,$child); $tmp=$this->TreeRecordTmp; $sql=" select action from options where name='".$id."' and lang='".$lang."' and child "; if (!empty($tmp)) { $sql.=" in ("; for ($i=0; $i0) $sql.=','; $sql.=$tmp[$i][1];} $sql.=")" ; } else $sql.=" is null"; $this->Login(); $tmp=$this->TakeArr($sql); $this->Logoff(); if (!empty($tmp))$tmp=end($tmp); return $tmp[action]; } function getProductTop($type) { $sql = " select products_id,products_uniqueid,products_bone,products_name,products_extra,"; $sql.="products_image,products_imageex,products_model,products_manufacturers,category.name, "; $sql.="products_weight,products_price,products_status,"; // dodatkowe kolumny danych $sql.=" products_weightwg,products_date_added,products_model,products_pricewg"; $sql.=" from products inner join category on products.products_bone=category.id "; $sql.=" where products_pricewg='t' "; $this->Login(); $tmp=$this->Take($sql); $this->Logoff(); return $tmp; } function getItemGroup($id) { $sql="select * from products_bone where products_id='".$id."'"; $this->Login(); $Temp=$this->TakeArr($sql); $this->Logoff(); return $Temp; } function updItem( $lang,$tmp,$Picture) { //if (!empty($Picture)) // $UploadPict=$this->uploadImage($Picture,$tmp); $TmpPicture[Pic]=$Picture[Pic]; $UploadPict=$this->uploadImage($TmpPicture,$tmp[Picture][Pic]); $TmpPicture=array(); $TmpPicture[Pic2]=$Picture[Pic2]; $UploadPict2=$this->uploadImage($TmpPicture,$tmp[Picture][Pic2]); $temp=$this->getProducts('pl','','',$tmp[products_id]); if (!empty($tmp[pcb]) ) { $Image=$this->BaseDir.$temp[0][products_image]; if (stripos($Image,'oimage')== 0) unlink($Image); $Image=$this->BaseDir.$temp[0][products_imageex]; if (stripos($Image,'oimage')== 0) unlink($Image); $Image=$this->BaseDir.str_replace($this->PictDir,$this->PictDir.'thumbs/',$temp[0][products_imageex]); $Image=str_replace( substr($Image,strripos($Image,'.')),'_1'.substr($Image,strripos($Image,'.')),$Image); if (stripos($Image,'oimage')== 0) unlink($Image); $UploadPict[Pic][0]=$this->PictDir.'noimage.jpg';$UploadPict[Pic][1]=$this->PictDir.'noimage2.jpg';} if (!empty($tmp[pcb2]) ) { $UploadPict2[Pic2][0]=$this->PictDir.'noimage.jpg';$UploadPict2[Pic2][1]=$this->PictDir.'noimage2.jpg'; $Image=$this->BaseDir.$temp[0][products_image2]; if (stripos($Image,'oimage')== 0) unlink($Image); $Image=$this->BaseDir.$temp[0][products_imageex2]; if (stripos($Image,'oimage')== 0) unlink($Image); $Image=$this->BaseDir.str_replace($this->PictDir,$this->PictDir.'thumbs/',$temp[0][products_imageex2]); $Image=str_replace( substr($Image,strripos($Image,'.')),'_1'.substr($Image,strripos($Image,'.')),$Image); if (stripos($Image,'oimage')== 0) unlink($Image);} $sql=" update products set products_uniqueid='".$tmp[products_uniqueid]."'"; if (!empty($UploadPict[Pic])) {$sql.=", products_image='".$UploadPict[Pic][0]."' , products_imageex='".$UploadPict[Pic][1]."'";} if (!empty($UploadPict2[Pic2])) {$sql.=", products_image2='".$UploadPict2[Pic2][0]."' , products_imageex2='".$UploadPict2[Pic2][1]."'"; } $sql.=", products_weight='".preg_replace('/[^0-9 ]+/i','',$tmp[products_weight])."',V1='".$tmp[V1]."',"; $sql.=" products_weightwg='".$tmp[products_weightwg]."',products_price='".$tmp[products_price]."',products_pricewg='".$tmp[products_pricewg]."',"; $sql.= " products_date_added='".date("Y-m-d H:i:s")."',V3='".$tmp[V3]."',V2='".$tmp[V2]."',products_unit='".$tmp[products_unit]."',products_model='".$tmp[products_model]."'"; $sql.=" where products_id='".$tmp[products_id]."'"; $SQL[]= $sql; $sql="select products_id from products_lang where products_id='".$tmp[products_id]."'and products_lang='".$lang."'"; $this->Login(); $tt2=$this->Take($sql); if (empty($tt2)) $SQL[]="INSERT INTO products_lang (products_uniqueid, products_name,products_extra,products_manufacturers, products_lang,products_id,products_price ) values('".$tmp[products_uniqueid]."','".htmlspecialchars($tmp[products_name])."', '".$tmp[products_extra]."','".$tmp[products_manufacturers]."','".$lang."',".$tmp[products_id].",'".$tmp[products_price]."')"; else $SQL[]=" update products_lang set products_uniqueid='".$tmp[products_uniqueid]."', products_name='".htmlspecialchars($tmp[products_name])."' , products_extra='".$tmp[products_extra]."',products_manufacturers='".$tmp[products_manufacturers]."',products_price='".$tmp[products_price]."' where products_id='".$tmp[products_id]."'and products_lang='".$lang."'"; $sql2 = " select products_image,products_imageex from products where products_id='".$tmp[products_id]."'"; $tt2=$this->Take($sql2); $this->ExecTrans($SQL); $this->Logoff(); $arr=array(); $arr[]=$tmp[bitem]; //wylacznie mozliwosci przyporzadkowania jednego produktu do wielu grup // $this->updItemOption($tmp[products_id]); switch ($tmp[opt][type]) { case 'slide': $tmp[opt][count]=count($tmp[opt])-1; $tmp[opt][p1]=$UploadPict[0];$tmp[opt][p2]=$UploadPict[1]; $tmp[opt][gid]=$tmp[14];$tmp[opt][id]=$tmp[0]; $tmp[opt][p10]=$tt2[0][0];$tmp[opt][p20]=$tt2[0][1]; $this->rebuildItemParams($tmp[opt]); break; } $this->AddLog('Zmodyfikowano zawartosc produktu nr:'.$tmp[products_id].'-'.htmlspecialchars($tmp[products_name])); } function addItem($lang,$tmp,$Picture) { $sql=" select products_uniqueid from products where products_uniqueid='".$tmp[products_uniqueid]. "'"; $this->Login(); $Temp=$this->Take($sql); $this->Logoff(); if (empty($Temp)) { if (!empty($tmp[Picture][Pic])) {$TmpPicture[Pic]=$Picture[Pic]; //array_pop($TmpPicture); $UploadPict=$this->uploadImage($TmpPicture,$tmp[Picture][Pic]);} if (!empty($tmp[Picture][Pic2])) {$TmpPicture[Pic2]=$Picture[Pic2]; //array_shift($TmpPicture); $UploadPict2=$this->uploadImage($TmpPicture,$tmp[Picture][Pic2]);} if (count($UploadPict[Pic])==0 or !empty($tmp[pcb])) {$UploadPict[Pic][0]=$this->PictDir.'noimage.jpg';$UploadPict[Pic][1]=$this->PictDir.'noimage2.jpg';} if (count($UploadPict2[Pic2])==0 or !empty($tmp[pcb2])) {$UploadPict2[Pic2][0]=$this->PictDir.'noimage.jpg';$UploadPict2[Pic2][1]=$this->PictDir.'noimage2.jpg';} $sql=" insert into products (products_uniqueid,products_name,"; $sql.=" products_image,products_imageex,products_image2,products_imageex2,products_weight,"; $sql.="V1,products_manufacturers,products_weightwg,products_price,"; $sql.="products_date_added,V2,V3,products_unit,products_model,products_pricewg)"; $sql.= " values ( '".$tmp[products_uniqueid]."','".htmlspecialchars($tmp[products_name])."','".$UploadPict[Pic][0]."','".$UploadPict[Pic][1]."','".$UploadPict2[Pic2][0]."','".$UploadPict2[Pic2][1]."','". preg_replace('/([A-Z]+)([A-Z][a-z])/','',$tmp[products_weight])."','"; $sql.= $tmp[V1]."','".$tmp[products_manufacturers]."','".$tmp[products_weightwg]; $sql.="','".$tmp[products_price]."','".date("Y-m-d H:i:s")."','".$tmp[V2]."','".$tmp[V3]."','".$tmp[products_unit]."','".$tmp[products_model]."','".$tmp[products_pricewg]."')"; echo $sql; $this->Login(); $this->ExecSQL($sql); $id=mysql_insert_id(); $this->Logoff(); $SQL[]=" update products set products_extra='".$tmp[products_extra]."' where products_id='".$id."'"; switch ($tmp[opt][type]) { case 'slide': $tmp[opt][count]=count($tmp[opt])-1; $tmp[opt][p1]=$UploadPict[0];$tmp[opt][p2]=$UploadPict[1]; $tmp[opt][gid]=$tmp[14];$tmp[opt][id]=$id; $tmp[opt][p10]='';$tmp[opt][p20]=''; $this->rebuildItemParams($tmp[opt]); break; } $lan=$this->langOn(); for ($i=0; $iLogin(); $this->ExecTrans($SQL); $this->Logoff(); $arr=array(); $arr[]=$tmp[bitem]; // wylaczenie mozliwosci przyporzadkowania jednego produktu do wielu grup //$this->addItemOption($arr,$id,$arr2); $this->addItemOptionNoTree($arr,$id,$arr2); $this->Login(); $this->renumberItem($tmp[bitem]); $this->Logoff(); $this->AddLog('Dodano produkt nr:'.$id.'-'.htmlspecialchars($tmp[products_name])); } } function rebuildItemParams($ARR) { switch ($ARR[type]) { case 'slide': //tu wstawic usuwanie plikow $sql="select typevalue from products_bone_params where products_id='".$ARR[id]."' and child='".$ARR[gid]."'"; $this->Login(); $tmp=$this->Take($sql); $this->Logoff(); $ctmp=count($tmp); for ($i=0; $i<$ctmp; $i++) {if (!empty($ARR[p10])) unlink($this->BaseDir.str_replace('/','/'.$tmp[$i][0].'mini/',$ARR[p10])); if (!empty($ARR[p20])) unlink($this->BaseDir.str_replace('/','/'.$tmp[$i][0],$ARR[p20])); } $SQL[]= " DELETE FROM products_bone_params where products_id='".$ARR[id]."' and child='".$ARR[gid]."'"; for ($i=0; $i<$ARR[count]; $i++) { //tu wstawi w ze slidami $params=$this->getPresentation('',$ARR[$i]); $SQL[]= " INSERT INTO products_bone_params SET child=".$ARR[gid].",products_id='".$ARR[id]."',type='".$params[0][1]."',typevalue='".$params[0][3]."', paramsid='".$ARR[$i]."'"; if (!empty($ARR[p1])) copy($this->BaseDir.$ARR[p1],$this->BaseDir.str_replace('/','/'.$params[0][3].'mini/',$ARR[p1])); else copy($this->BaseDir.$ARR[p10],$this->BaseDir.str_replace('/','/'.$params[0][3].'mini/',$ARR[p10])); if (!empty($ARR[p2])) copy($this->BaseDir.$ARR[p2],$this->BaseDir.str_replace('/','/'.$params[0][3],$ARR[p2])); else copy($this->BaseDir.$ARR[p20],$this->BaseDir.str_replace('/','/'.$params[0][3],$ARR[p20])); } $this->Login(); $this->ExecTrans($SQL); $this->Logoff(); break; } } function uploadImage($Picture,$PictureType) { // uploading zdjecia do katalogu tymczasowego podczas budowy oferty // kazde zdjecie ma swoj rozmiar w parametrach okreslonego zdjecia i dodatkowo jest generowane zdjecie // do slideshowa w katalogu "/thumbs" $OrdBaseDir= $this->PictDir;//echo $PictureType."+"; while($val = current($Picture)) { if (!empty($val['name'])) {if ( is_uploaded_file($val['tmp_name']) ) { //$PictureType[bitem] $PictureTmp=$this->getSystemObjectType('pl','',$PictureType); $ImageSize=$PictureTmp[p1]; $ImageSizeExt=$PictureTmp[p2];$ImageSizeSlide=$this->ImgSizeSlide; if (empty($PictureTmp[typeo])) {$ImageSize=$this->ImgSize;$ImageSizeExt=$this->ImgSizeExt;$ImageSizeSlide=$this->ImgSizeSlide;} //echo "=".$ImageSize."-".$ImageSizeExt."-".$ImageSizeSlide; $gn= mt_rand(0,9999999999); $Pic = strtolower($gn."_tmp".".".substr($val['name'],strrpos($val['name'],'.')+1,3)); $Pic2 = strtolower("mini_".$gn.".".substr($val['name'],strrpos($val['name'],'.')+1,3)); $Pic2Ext = strtolower($gn.".".substr($val['name'],strrpos($val['name'],'.')+1,3)); $Pic2Sub = strtolower($gn."_1.".substr($val['name'],strrpos($val['name'],'.')+1,3)); $Ext=substr($val['name'],strrpos($val['name'],'.')+1,3); $Image=$this->BaseDir.$OrdBaseDir.$Pic; $DstImage=$this->BaseDir.$OrdBaseDir.$Pic2; $DstImageExt=$this->BaseDir.$OrdBaseDir.$Pic2Ext; $DstImageSub=$this->BaseDir.$OrdBaseDir."thumbs/".$Pic2Sub; move_uploaded_file($val['tmp_name'],$Image); $Size = getimagesize($Image); $SrcX = $Size[0]; $SrcY = $Size[1]; if ($SrcX>$SrcY) $SrcMax=$SrcX; else $SrcMax=$SrcY; $DispRatioSub=$SrcMax/$ImageSizeSlide; $DispRatio=$SrcMax/$ImageSize; $DispRatioExt=$SrcMax/$ImageSizeExt; $DstXSub=round($SrcX/$DispRatioSub); $DstYSub=round($SrcY/$DispRatioSub); $DstX=round($SrcX/$DispRatio); $DstY=round($SrcY/$DispRatio); $DstXExt=round($SrcX/$DispRatioExt); $DstYExt=round($SrcY/$DispRatioExt); switch (strtoupper($Ext)) { case 'JPEG': $SrcImage = imagecreatefromjpeg($Image); break; case 'JPG': $SrcImage = imagecreatefromjpeg($Image); break; case 'PNG': $SrcImage = imagecreatefrompng($Image); break; case 'GIF': $SrcImage = imagecreatefromgif($Image); break; case 'WBM': $SrcImage = imagecreatefromwbmp($Image); break; } $DispDstImage= imagecreatetruecolor($DstX, $DstY); $DispDstImageExt= imagecreatetruecolor($DstXExt, $DstYExt); $DispDstImageSub= imagecreatetruecolor($DstXSub, $DstYSub); imagecopyresampled($DispDstImage,$SrcImage, 0, 0, 0, 0, $DstX, $DstY, $SrcX, $SrcY); imagecopyresampled($DispDstImageExt,$SrcImage, 0, 0, 0, 0, $DstXExt, $DstYExt, $SrcX, $SrcY); imagecopyresampled($DispDstImageSub,$SrcImage, 0, 0, 0, 0, $DstXSub, $DstYSub, $SrcX, $SrcY); switch (strtoupper($Ext)) { case 'JPEG': imagejpeg($DispDstImageSub,$DstImageSub,100); imagejpeg($DispDstImage,$DstImage,100); imagejpeg($DispDstImageExt,$DstImageExt,100); break; case 'JPG': imagejpeg($DispDstImageSub,$DstImageSub,100); imagejpeg($DispDstImage,$DstImage,100); imagejpeg($DispDstImageExt,$DstImageExt,100); break; case 'PNG': imagepng($DispDstImageSub,$DstImageSub,9); imagepng($DispDstImage,$DstImage,9); imagepng($DispDstImageExt,$DstImageExt,9); break; case 'GIF': imagegif($DispDstImageSub,$DstImageSub,9); imagegif($DispDstImage,$DstImage,9); imagegif($DispDstImageExt,$DstImageExt,9); break; case 'WBM': imagewbmp($DispDstImageSub,$DstImageSub,9); imagewbmp($DispDstImage,$DstImage,9); imagewbmp($DispDstImageExt,$DstImageExt,9); break; } imagedestroy($SrcImage); imagedestroy($DispDstImageSub); imagedestroy($DispDstImage); imagedestroy($DispDstImageExt); unlink($Image); $PicA[key($Picture)][]=$OrdBaseDir.$Pic2; $PicA[key($Picture)][]=$OrdBaseDir.$Pic2Ext; } } next($Picture); } return $PicA; } function uploadFile($Picture) { // uploading zdjcia do katalogu tymczasowego podczas budowy oferty $OrdBaseDir= $this->PictDir; //$this->BaseDir=$this->BaseDir.$OrdBaseDir; while($val = current($Picture)) { if (!empty($val['name'])) {if ( is_uploaded_file($val['tmp_name']) ) {$gn= mt_rand(0,9999999999); $Name = strtolower($gn.".".substr($val['name'],strrpos($val['name'],'.')+1,3)); $File=$this->BaseDir.$OrdBaseDir.$Name; move_uploaded_file($val['tmp_name'],$File); $PicA[]=$OrdBaseDir.$Name; }} next($Picture); } return $PicA; } function delItem($temp) { $ctemp=count($temp); $SQL=array(); $lg2=array(); for ($i=0; $i<$ctemp; $i++) {$this->Login(); $sql="select child from products_bone where products_id='".$temp[$i]."'"; $lg1=$this->Take($sql); while($val = current($lg1)) { $lg2[]=$val[0]; next($lg1); } $SQL[]=" delete from products where products_id='".$temp[$i]."'"; $tmp=$this->getProducts('pl','','',$temp[$i]); $Image=$this->BaseDir.$tmp[0][products_image]; if (stripos($Image,'oimage')== 0) unlink($Image); $Image=$this->BaseDir.$tmp[0][products_imageex]; if (stripos($Image,'oimage')== 0) unlink($Image); $Image=$this->BaseDir.str_replace($this->PictDir,$this->PictDir.'thumbs/',$tmp[0][products_imageex]); $Image=str_replace( substr($Image,strripos($Image,'.')),'_1'.substr($Image,strripos($Image,'.')),$Image); if (stripos($Image,'oimage')== 0) unlink($Image); $Image=$this->BaseDir.$tmp[0][products_image2]; if (stripos($Image,'oimage')== 0) unlink($Image); $Image=$this->BaseDir.$tmp[0][products_imageex2]; if (stripos($Image,'oimage')== 0) unlink($Image); $Image=$this->BaseDir.str_replace($this->PictDir,$this->PictDir.'thumbs/',$tmp[0][products_imageex2]); $Image=str_replace( substr($Image,strripos($Image,'.')),'_1'.substr($Image,strripos($Image,'.')),$Image); if (stripos($Image,'oimage')== 0) unlink($Image); $SQL[]=" delete from products_lang where products_id='".$temp[$i]."'"; $SQL[]=" delete from products_add where products_id='".$temp[$i]."'"; $SQL[]=" delete from products_add2 where products_id='".$temp[$i]."'"; $SQL[]=" delete from products_bone where products_id='".$temp[$i]."'"; $SQL[]=" delete from products_comment where products_id='".$temp[$i]."'"; $igal=$this->getItemGallery('',$temp[$i],''); if (!empty($igal)) {while($val = current($igal)) { $lg[]=$val[id]; next($igal); } $this->delItemGallery($lg);} $this->AddLog('Usunieto produkt:'.$temp[$i]); } $this->Login(); $this->ExecTrans($SQL); $this->Logoff(); $lg2=array_unique($lg2); $this->exportToSlide($lg2);//print_r($lg2); //$this->exportGroupToSlide($lg2); } function delItemGroup($temp,$ig) { $ctemp=count($temp); $this->Login(); for ($i=0; $i<$ctemp; $i++) { $SQL[]=" delete from products_bone where products_id='".$temp[$i]."' and child='".$ig."'"; } $this->ExecTrans($SQL); $lg[]=$ig; $this->exportToSlide($lg); //$this->exportGroupToSlide($lg); $this->Logoff(); } function getProducts($lang,$id,$add,$nid) // $id- grupa koncowa //$add - wyszukiwany ciag znakow //$nid - id itemu {if ($id=='1') $id=''; $sql = "select bone.depth,bone.parent,tmp1.* from bone left join ". "(select products_bone.child,products_bone.priority,products.* from products_bone inner join (select products.products_id,products.products_image,products_lang.products_extra,products.products_date_added, products.products_image2,products.products_imageex2, products.products_status,products.products_model,products.products_imageex,products.products_price, products_lang.products_manufacturers,products_lang.products_name,products_lang.products_lang, products.products_unit,products.products_pricewg from products inner join products_lang ON products.products_id=products_lang.products_id where products_lang.products_lang='".$lang."') as products on products_bone.products_id=products.products_id ) as tmp1 ". "on bone.child=tmp1.child where tmp1.products_id is not null"; if (!empty($id)) $sql.=" and bone.child='".$id."'"; if (!empty($nid)) $sql.=" and tmp1.products_id='".$nid."'"; if (!empty($add)) $sql.=" and tmp1.products_name like \"%".$add."%\" or tmp1.products_extra like \"%".$add."%\""; $sql.= " group by products_id order by tmp1.priority "; $this->Login(); $Temp=$this->TakeArr($sql); $this->Logoff(); return $Temp; } function moveItemGallery($ARR,$id,$target) { // $ARR - galerii podlegajace przesuwaniu // $id - produkt ktorego galeria jest porzadkowana // $target - docelowe miejsce przesuniecia $cARR=count($ARR); $this->Login(); for ($i=0; $i<$cARR; $i++) { $tm=$this->TakeArr('select priority from products_gallery where id='.$ARR[$i]); if ($tm[0][priority]>($target*100)) $sgn=-1; else $sgn=1; $SQL[]="UPDATE products_gallery set priority=".(($target*100)+$sgn*($i+1))." where id=".$ARR[$i]; } $sql="SET @rowCount = 0 ; update products_gallery inner join (SELECT id, @rowCount := @rowCount + 100 AS rowCount FROM products_gallery WHERE products_id = ".$id." order by priority) as detal on products_gallery.id = detal.id set products_gallery.priority=detal.rowCount "; $this->ExecTrans($SQL);$this->ExecSQL($sql); $this->exportItemGalleryToSlide($id); } function moveItem($ARR,$itemgroup,$target) { $sql="select child,products_id,priority from products_bone where child='".$itemgroup."' order by priority"; $this->Login(); $Temp=$this->Take($sql); $cTemp=count($Temp); $cARR=count($ARR); if ($target<$cTemp or $target==$cTemp ) { for ($i=0; $i<$cARR; $i++) {$sql="select priority from products_bone where child='".$itemgroup."' and products_id='".$ARR[$i]."' order by priority"; $Temp1=$this->Take($sql); if ($Temp1[0][0]>$Temp[($target-1)][2]) $sgn=-1; else $sgn=1; $TMP[]="update products_bone set priority=".($Temp[($target-1)][2]+(1*$sgn))." where products_id='".$ARR[$i]."' and child='".$itemgroup."'"; } } else{ for ($i=0; $i<$cARR; $i++) { $TMP[]="update products_bone set priority=".($target+$i)." where products_id='".$ARR[$i]."' and child='".$itemgroup."'"; } } $this->ExecTrans($TMP); $this->renumberItem($itemgroup);$arr[]=$itemgroup; $this->exportToSlide($arr); // $this->exportGroupToSlide($arr); //$this->Logoff(); } function renumberItem($itemgroup) { $sql="select child,products_id,priority from products_bone where child='".$itemgroup."' order by priority"; $ARR=$this->Take($sql); $cARR=count($ARR); for ($i=0; $i<$cARR; $i++) $TMP[]="update products_bone set priority=".(($i+1)*100)." where child='".$itemgroup."' and products_id='".$ARR[$i][1]."'"; $this->ExecTrans($TMP); } function getProductsAll($action) { $sql="select products.products_id,products.products_id,products.products_id,products.products_id,products.products_name,products.products_extra, ". "products.products_image,products.products_date_added, products_add2.id from products left join products_add2 on"; $sql.=" products.products_id=products_add2.products_id"; if ($action=='bprod') $sql.= " order by products.products_id "; if ($action=='bpprod') $sql.= " where products.products_status='t' group by products.products_id"; if ($action=='bprom') $sql.= " where products_add2.id is not null group by products.products_id order by products_add2.id "; $this->Login(); $Temp=$this->Take($sql); $this->Logoff(); return $Temp; } function getProduct($lang,$id) { if (!empty($lang)) {$sql = " select products.products_id,products.products_uniqueid,products.products_image,products.products_imageex, products.products_image2,products.products_imageex2, products.products_price,products.products_weight,products.products_weightwg,products.V2,products.V1,products.V3, products.products_model,products.products_pricewg, products_lang.products_name,products_lang.products_extra,products_lang.products_manufacturers,products_unit from products inner join products_lang ON products.products_id=products_lang.products_id where products_lang.products_lang='".$lang."'" ; if ( !empty($id)) $sql.=" and products.products_id='".$id."'"; } else {$sql = " select products.products_id,products.products_uniqueid,products.products_image,products.products_imageex, products.products_image2,products.products_imageex2, products.products_price,products.products_weight,products.products_weightwg,products.V2,products.V1,products.V3, products.products_name,products.products_extra,products.products_manufacturers,products_unit,products.products_pricewg from products "; if ( !empty($id)) $sql.=" where products.products_id='".$id."'"; } $this->Login(); $tmp=$this->TakeArr($sql); $this->Logoff(); return $tmp; } function getProductObjects($lang,$id,$id2) { $sql= " select products_add.id,products_add.products_id,products_add.name,name_ext,image,products.products_name,products_add.link, "; $sql.=" products.products_extra from products_add inner join ( select products.products_id,products_lang.products_name,products_lang.products_extra from products inner join products_lang on products.products_id=products_lang.products_id where products_lang.products_lang='".$lang."') as products on products_add.products_id = products.products_id"; if (!empty($id) or !empty($id2)) $sql.=" where "; if (!empty($id)) $sql.="products_add.products_id='".$id."'"; if (!empty($id2)) $sql.=" id='".$id2."'"; $sql.= " order by products.products_id,products_add.name "; $this->Login(); $tmp=$this->TakeArr($sql); $this->Logoff(); return $tmp; } function getProductBaners($id,$id2) { $sql= " select products_add2.id,products_add2.products_id,products_add2.name,name_ext,image,products.products_name,products_add2.link "; $sql.=" from products_add2 inner join products on products_add2.products_id = products.products_id "; if (!empty($id)or !empty($id2)) $sql.=" where "; if (!empty($id)) $sql.="products_add2.products_id='".$id."'"; if (!empty($id2)) $sql.=" id='".$id2."'"; $this->Login(); $tmp=$this->Take($sql); $this->Logoff(); return $tmp; } function addItemBaner($tmp,$Picture) { $sql=" select products_uniqueid from products_add2 where products_uniqueid='".$tmp[4]. "'"; $this->Login(); $Temp=$this->Take($sql); $this->Logoff(); if (empty($Temp)) { $UploadPict=$this->uploadImage($Picture,$this->ImgSize,$this->ImgSizeExt); if (count($UploadPict)==0) {$UploadPict[0]=$this->PictDir.'noimage.jpg';$UploadPict[1]=$this->PictDir.'noimage2.jpg';} $sql=" insert into products_add2 (products_id,products_uniqueid,name,name_ext,image,link)"; $sql.= " values ( '".$tmp[1]."','".$tmp[4]."','".$tmp[2]."','".$tmp[3]."','".$UploadPict[0]."','".$tmp[5]."')"; $this->Login(); $this->ExecSQL($sql); $this->Logoff(); } } function delItemObject($temp) { $ctemp=count($temp); $this->Login(); for ($i=0; $i<$ctemp; $i++){ $SQL[]=" delete from products_add where id='".$temp[$i]."'"; $sql="select products_id,image from products_add where id='".$temp[$i]."'"; $del=$this->TakeArr($sql); $File=$this->BaseDir.$del[0][image]; //echo $File; unlink($File); } $this->ExecTrans($SQL); $this->Logoff(); } function delItemBaner($temp) { $ctemp=count($temp); $this->Login(); for ($i=0; $i<$ctemp; $i++) $SQL[]=" delete from products_add2 where id='".$temp[$i]."'"; $this->ExecTrans($SQL); $this->Logoff(); } function updItemObject($tmp,$Picture) { if (!empty($Picture)) $UploadPict=$this->uploadFile($Picture); $sql=" update products_add set products_id='".$tmp[1]."', products_uniqueid='".$tmp[4]."',"; $sql.=" name='".$tmp[2]."',name_ext='".$tmp[3]."',link='".$tmp[5]."'"; if (!empty($UploadPict)) $sql.=", image='".$UploadPict[0]."'"; $sql.=" where id='".$tmp[0]."'"; $this->Login(); $this->ExecSQL($sql); $this->Logoff(); } function updItemBaner($tmp,$Picture) { if (!empty($Picture)) $UploadPict=$this->uploadImage($Picture,$this->ImgSize,$this->ImgSizeExt); $sql=" update products_add2 set products_id='".$tmp[1]."', products_uniqueid='".$tmp[4]."',"; $sql.=" name='".$tmp[2]."',name_ext='".$tmp[3]."',link='".$tmp[5]."'"; if (!empty($UploadPict)) $sql.=", image='".$UploadPict[0]."'"; $sql.=" where id='".$tmp[0]."'"; $this->Login(); $this->ExecSQL($sql); $this->Logoff(); } function addItemObject($tmp,$Picture) { $sql=" select products_uniqueid from products_add where products_uniqueid='".$tmp[4]. "'"; $this->Login(); $Temp=$this->Take($sql); $this->Logoff(); if (empty($Temp)) { $UploadPict=$this->uploadFile($Picture); if (count($UploadPict)==0) {$UploadPict[0]=$this->PictDir.'noimage.jpg';$UploadPict[1]=$this->PictDir.'noimage2.jpg';} $sql=" insert into products_add (products_id,products_uniqueid,name,name_ext,image,link)"; $sql.= " values ( '".$tmp[1]."','".$tmp[4]."','".$tmp[2]."','".$tmp[3]."','".$UploadPict[0]."','".$tmp[5]."')"; $this->Login(); $this->ExecSQL($sql); $this->Logoff(); } } function getProductCategory2($id,$pr) { $sql = "select tmp.* , tmp2.products_id from ". "(select bone.depth,bone.parent,bone.child,category.name,category.image ". "from bone inner join category on bone.child=category.id where bone.depth>0 and bone.depth<3 and bone.parent='".$pr."' ) as tmp ". "left join (select products_bone.child,products_bone.products_id from products_bone ". "where products_bone.products_id='".$id."')as tmp2 on tmp.child=tmp2.child order by child"; $this->Login(); $Temp=$this->Take($sql); $this->Logoff(); return $Temp; } function getProductCategory($id) { $sql="select child from products INNER join (select child,products_id from products_bone where products_id=".$id.") as products_bone on products.products_id=products_bone.products_id"; $this->Login(); $Temp=$this->TakeArr($sql); $this->Logoff(); for ($i=0; $iLogin(); $Temp=$this->Take($sql); $this->Logoff(); return $Temp; } function getPresentationForm($gid,$id) {//$gid - nr wezla // $id - nr produktu // $pid - id parametru $sql="select bone_params.child,bone_params.type,bone_params.typetitle,bone_params.typevalue"; $sql.=",bone_params.typedefault,tmp.typevalue,bone_params.id from bone_params left join"; $sql.="(select * from products_bone_params where products_bone_params.products_id='".$id."' )as tmp"; $sql.=" on bone_params.id=tmp.paramsid where bone_params.type='slide' and bone_params.child='".$gid."'"; $this->Login(); $Temp=$this->Take($sql); $this->Logoff(); return $Temp; } function getCategory($lang,$parent) { $sql = "select tmp.*,category.name_".$lang." as nameparent from category right join (select bone.depth,bone.parent,bone.child,". "category.name_".$lang." as name,category.extra_".$lang." as ename,category.image from bone inner join category on bone.child=category.id) as tmp ". "on category.id=tmp.parent where tmp.depth>0 and tmp.depth<3"; if (!empty($parent)) $sql.=" and tmp.parent='".$parent."'"; $this->Login(); $Temp=$this->TakeArr($sql); $this->Logoff(); return $Temp; } function getCategoryParent($lang,$cid) { $sql="select bone.depth,bone.parent,bone.child,category.name,". " category.name_".$lang." as cname,category.extra_".$lang." as ename,category.image from bone inner join category on bone.child=category.id". " where child='".$cid."'"; $this->Login(); $Temp=$this->TakeArr($sql); $this->Logoff(); return $Temp; } function getCategoryNative($lang,$cid) { $sql="select bone.depth,bone.parent,bone.child,". " category.name_".$lang.",category.extra_".$lang." as ename,category.image from bone inner join category on bone.child=category.id". " where child='".$cid."'"; $this->Login(); $Temp=$this->Take($sql); $this->Logoff(); return $Temp[0][3]; } function getCategoryExtra($lang,$cid) { $sql="select bone.depth,bone.parent,bone.child,". " category.name_".$lang.",category.extra_".$lang." as ename,category.image from bone inner join category on bone.child=category.id". " where child='".$cid."'"; $this->Login(); $Temp=$this->Take($sql); $this->Logoff(); return $Temp[0][4]; } function addItemOption2($arr,$id) { $carr=count($arr);$this->Login(); for ($i=0; $i<$carr; $i++) { $sql = " select parent, child, depth from bone where child='".$arr[$i]."'"; $Temp=$this->Take($sql); while ($Temp[0][2]>0) { $sql = "select * from products_bone where child='".$arr[$i]."' and products_id='".$id."'"; $Temporary=array(); $Temporary=$this->Take($sql); if (count($Temporary)>0 ) $SQL[]= " DELETE FROM products_bone where child='".$arr[$i]."' and products_id='".$id."'"; else $SQL[]= " INSERT INTO products_bone SET child='".$Temp[0][1]."' , products_id='".$id."'"; $sql = " select parent, child, depth from bone where child='".$Temp[0][0]."'"; $Temp=$this->Take($sql); } } $this->ExecTrans($SQL); } function addItemOption($arr,$id,$arr2) { //stworzenie listy grup do $this->Login(); $sql="select child from products_bone where products_id='".$id."'"; $lg1=$this->Take($sql); $lg=$arr; if (!empty($lg1)) {while($val = current($lg1)) { $lg[]=$val[0]; next($lg1); } } $carr=count($arr); $SQL[]= " DELETE FROM products_bone where products_id='".$id."'"; for ($i=0; $i<$carr; $i++) { $sql = " select parent, child, depth from bone where child='".$arr[$i]."'"; $Temp=$this->Take($sql); while ($Temp[0][2]>0) {$SQL[]= " INSERT INTO products_bone SET child='".$Temp[0][1]."' , products_id='".$id."' ,priority=0 "; $sql = " select parent, child, depth from bone where child='".$Temp[0][0]."'"; $Temp=$this->Take($sql);$lg[]=$Temp[0][1];} } $this->ExecTrans($SQL);$lg=array_unique($lg); $this->exportToSlide($lg); //$this->exportGroupToSlide($lg); } function addItemOptionNoTree($arr,$id,$arr2) { $this->Login(); $SQL[]= " DELETE FROM products_bone where products_id='".$id."'"; $SQL[]= " INSERT INTO products_bone SET child='".$arr[0]."' , products_id='".$id."' ,priority=0 "; $this->ExecTrans($SQL); $this->exportToSlide($arr); } function updItemOption($id) { //stworzenie listy grup do kty zdjecie $this->Login(); $sql="select child from products_bone where products_id='".$id."'"; $lg1=$this->Take($sql); if (!empty($lg1)) {while($val = current($lg1)) { $lg[]=$val[0]; next($lg1); } } $lg=array_unique($lg); $this->exportToSlide($lg); //$this->exportGroupToSlide($lg); } function exportGroupToSlide($arr) { $this->Login(); reset($arr); while($val=each($arr)){ $tmp=$this->getCategory('pl',$val[value]); $xmlbase=""; for ($i=0; $i"; if (file_exists($this->BaseDir.$this->PictDir.$tmp[$i][child].'.xml')) { $hxml=fopen($this->BaseDir.$this->PictDir.$tmp[$i][child].'.xml',"r+"); $xmlbase.=fread($hxml,filesize($this->BaseDir.$this->PictDir.$tmp[$i][child].'.xml')); fclose($hxml); } $xmlbase.=" "; } $xmlbase.=""; $hxml=fopen($this->BaseDir.$this->PictDir."bitem".$val[value].'.xml',"w+"); fwrite($hxml,$xmlbase.chr(13).chr(10)); fclose($hxml); } } function exportToSlide2($arr) { $this->Login(); reset($arr); $xmlbase=''; while($val=each($arr)){ $temp=$this->getProducts('pl',$val[value],'',''); $xmlbase=''; for ($i=0; $i ".$temp[$i][products_extra]."]]>"; } $hxml=fopen($this->BaseDir.$this->PictDir.$val[value].'.xml',"w+"); fwrite($hxml,$xmlbase.chr(13).chr(10)); fclose($hxml); // next($arr); } } function exportToSlide($arr) { // slideshow $this->Login(); reset($arr); while($val=each($arr)){ $xmlbase=" Gallery 1 ".$this->PictDir." "; $temp=$this->getProducts('pl',$val[value],'',''); for ($i=0; $i ".substr($temp[$i][products_imageex],10)." "; } $xmlbase.=" "; $hxml=fopen($this->BaseDir.$this->PictDir.$val[value].'.xml',"w+"); fwrite($hxml,$xmlbase.chr(13).chr(10)); fclose($hxml); // next($arr); } } function getSlideImage($il) { return str_replace($il,'.','_1.'); } function exportItemGalleryToSlide($item) { $tempnames=$this->getItemGalleryNames($item,''); $xmldelete=glob($this->BaseDir.$this->PictDir.'item'.$item.'*.xml'); for ($i=0; $i0) { while($val = current($tempnames)){ $temp=$this->getItemGallery('',$item,$val[gname]); if ($val[gname]=='Podstawowa') $galleryname=""; else $galleryname='_'.str_replace(' ','_',$val[gname]); $xmlbase=" Gallery 1 ".$this->PictDir." "; for ($i=0; $i ".substr($temp[$i][imageext],10)." ";} $xmlbase.=" "; $hxml=fopen($this->BaseDir.$this->PictDir.'item'.$item."_2".$galleryname.'.xml',"w+"); fwrite($hxml,$xmlbase.chr(13).chr(10)); fclose($hxml); $xmlbase=" Gallery 1 ".$this->PictDir." "; for ($i=0; $i ".substr($temp[$i][imageext2],10)." ";} $xmlbase.=" "; $hxml=fopen($this->BaseDir.$this->PictDir.'item'.$item."_3".$galleryname.'.xml',"w+"); fwrite($hxml,$xmlbase.chr(13).chr(10)); fclose($hxml); next($tempnames); } } } function getCategoryOptions() { $this->Login(); $Temp=$this->getCategory(1); $cTemp=count($Temp); for ($i=0; $i<$cTemp; $i++) { $TempExp[0][][0]=$Temp[0]; } $this->Logoff(); return $TempExp; } function GetCategoryDepth($id) { $sql="select depth from bone where child = '".$id."' "; $this->Login(); $Temp=$this->Take($sql); return $Temp; } function getCategoryTree($lang,$id) {$link=''; $sql = "select bone.parent, bone.child,bone.depth,category.Name,category.CategoryName ". "from bone left join category on bone.child=category.id where child='".$id."'"; $this->Login(); $Temp=$this->Take($sql); $bTemp=$Temp[0][2]; for ($i=$bTemp; $i>0; $i--) { $sql = "select bone.parent, bone.child,bone.depth,category.Name_".$lang." as name,category.CategoryName ". "from bone left join category on bone.child=category.id where child='".$id."'"; $Temp=$this->TakeArr($sql);if (!empty($link)) $sign=' -> '; $link="".$Temp[0][CategoryName]." ".$Temp[0][name]."".$sign.$link; $id=$Temp[0][0]; } $this->Logoff(); $all=$this->getCategory($lang,1);//print_r($all); $link=''.$all[0][nameparent].' -> '.$link; return $link; } function getProductSlide($type,$pos) { $sql="select products.products_id,products_name,products_extra,products_image,products_imageex,"; $sql.="products_add2.name, products_add2.image"; $sql.=" from products inner join products_add2 on products.products_id=products_add2.products_id"; $sql.=" order by products_add2.id" ; $this->Login(); $Temp=$this->Take($sql); $this->Logoff(); $exp="

urlpath."design/?module=foto&id=".$Temp[$pos][0]."\">urlpath.$Temp[$pos][6]."\" style=\"border:none;\" width=\"100\" />

"; return $exp; } function getObjectPromotion() { $sql= "select name, name_ext,image,link from products_add "; $this->Login(); $Temp=$this->Take($sql); $this->Logoff(); return $Temp; } function getProductPromotion($id) { $sql=" select tmp1.products_name,tmp1.products_extra,tmp1.products_image,tmp1.products_model from bone left join". " (select products_bone.child,products.products_id,products.products_name,products.products_extra, ". "products.products_image,products.products_date_added,products.products_status,products.products_model from products_bone". " inner join products on products_bone.products_id=products.products_id ) as tmp1". " on bone.child=tmp1.child where tmp1.products_id is not null and tmp1.products_status='t'". " and bone.child='".$id."'group by products_id"; $this->Login(); $Temp1=$this->Take($sql); $sql="select products_add.name,products_add.name_ext,products_add.image,products_add.link from products_add inner join ( select tmp1.products_id from bone left join ". " (select products_bone.child,products.products_id,products.products_name,products.products_extra,". "products.products_image,products.products_date_added,products.products_status,products.products_model from products_bone". " inner join products on products_bone.products_id=products.products_id ) as tmp1". " on bone.child=tmp1.child where tmp1.products_id is not null and tmp1.products_status='t'". " and bone.child='".$id."' group by products_id) as tmp2 on tmp2.products_id=products_add.products_id"; $Temp2=$this->Take($sql); $Temp=array_merge($Temp1,$Temp2); $this->Logoff(); return $Temp; } function browseBaners($id) { $sql= " select id,name,image,imageext,link from baners"; if (!empty($id)) $sql.=" where ID='".$id."'"; $this->Login(); $tmp=$this->Take($sql); return $tmp; } function addBaner($ARR) { } function updBaner($tmp,$Picture,$Picture2) { $BaseDir=$_SESSION['syspath'].'gallery/'; if (!empty($Picture)) {if ( is_uploaded_file($Picture['tmp_name']) ) { $name = mt_rand(0,9999999999).".jpg"; move_uploaded_file($Picture['tmp_name'],$BaseDir.$name); $name="gallery/".$name; } } else $name=""; if (!empty($Picture)) {if ( is_uploaded_file($Picture2['tmp_name']) ) { $name2 = mt_rand(0,9999999999).".jpg"; move_uploaded_file($Picture2['tmp_name'],$BaseDir.$name2); $name2="gallery/".$name2; } } else $name2=""; $sql=" update baners set name='".$tmp[1]."',"; $sql.=" link='".$tmp[2]."'"; if (!empty($name)) $sql.=", image='".$name."'"; if (!empty($name2)) $sql.=", imageext='".$name2."'"; $sql.=" where id='".$tmp[0]."'"; $this->Login(); $this->ExecSQL($sql); $this->Logoff(); } function browseUsers($id) { $sql= " select ID,Nick,Name from users"; if (!empty($id)) $sql.=" where ID='".$id."'"; $this->Login(); $tmp=$this->Take($sql); return $tmp; } function updItemComment($tmp) { $sql=" update products_comment set commentdate='".$tmp[4]."', uniqueid='".$tmp[7]."',"; $sql.=" rank='".$tmp[3]."',titleext='".$tmp[1]."',status='".$tmp[5]."',name='".$tmp[2]."'"; $sql.=" where id='".$tmp[0]."'"; $this->Login(); $this->ExecSQL($sql); $this->Logoff(); } function getItemComment($id,$idgall) { $sql=" select products_comment.id,products.products_id,titleext,commentdate,rank,products.products_image,products_comment.name,products_comment.owner_id,products_comment.status"; $sql.=" from products_comment inner join products on products.products_id=products_comment.products_id"; if (!empty($id)) $sql.=" where products_comment.id='".$id."'"; if (!empty($idgall)) $sql.=" where products_comment.products_id='".$idgall."'"; $this->Login(); $Temp=$this->Take($sql); $this->Logoff(); return $Temp ; } function getItemGallery($id,$idgall,$gallname) { //$id rysunku w galerii // $idgall id produktu $sql=" select products_gallery.id,products_gallery.products_id,title,titleext,image,products.products_name,products_gallery.imageext, "; $sql.=" products.products_image,products.products_imageex,products.products_image2,products.products_imageex2,products_gallery.gname from products_gallery inner join products on products_gallery.products_id=products.products_id where"; if (!empty($id)) $sql.=" products_gallery.id='".$id."'"; if (!empty($idgall)) $sql.=" products_gallery.products_id='".$idgall."'"; if (!empty($gallname)) $sql.=" and upper(products_gallery.gname)='".strtoupper($gallname)."'"; $sql.=" order by products_gallery.priority ASC"; $this->Login(); $Temp=$this->TakeArr($sql); $this->Logoff(); return $Temp ; } function getItemGalleryNames($idgall,$gallname) { $sql=" select products_gallery.gname from products_gallery where"; if (!empty($idgall)) $sql.=" products_gallery.products_id='".$idgall."'"; if (!empty($gallname)) $sql.=" and products_gallery.gname like '%".strtoupper($gallname)."%'"; $sql.=" group by products_gallery.gname ASC"; $this->Login(); $Temp=$this->TakeArr($sql); $this->Logoff(); return $Temp ; } function delItemComment($temp) { $ctemp=count($temp); $this->Login(); for ($i=0; $i<$ctemp; $i++) $SQL[]=" delete from products_comment where id='".$temp[$i]."'"; $this->ExecTrans($SQL); $this->Logoff(); } function delItemGallery($temp) { $ctemp=count($temp); $this->Login(); for ($i=0; $i<$ctemp; $i++) {$SQL[]=" delete from products_gallery where id='".$temp[$i]."'"; $sql="select products_id,image,imageext from products_gallery where id='".$temp[$i]."'"; $del=$this->TakeArr($sql); $Image=$this->BaseDir.$del[0][image]; if (stripos($Image,'oimage')== 0) unlink($Image); $Image=$this->BaseDir.$del[0][imageext]; if (stripos($Image,'oimage')== 0) unlink($Image); $Image=$this->BaseDir.str_replace($this->PictDir,$this->PictDir.'thumbs/',$del[0][imageext]); $Image=str_replace( substr($Image,strripos($Image,'.')),'_1'.substr($Image,strripos($Image,'.')),$Image); if (stripos($Image,'oimage')== 0) unlink($Image); } $this->ExecTrans($SQL); $this->Logoff(); $this->exportItemGalleryToSlide($del[0][products_id]); } function addItemComment($tmp) { $sql=" select uniqueid from products_comment where uniqueid='".$tmp[5]. "'"; $this->Login(); $Temp=$this->Take($sql); $this->Logoff(); if (empty($Temp)) { $sql=" insert into products_comment (products_id,uniqueid,titleext,owner_id,commentdate,rank,status,name)"; $sql.= " values ( '".$tmp[6]."','".$tmp[7]."','".$tmp[1]."','','".date("Y-m-d H:i:s")."','".$tmp[3]."','".$tmp[5]."','".$tmp[2]."')"; $this->Login(); $this->ExecSQL($sql); $this->Logoff(); } } function addItemGallery($tmp,$Picture) { $sql=" select uniqueid from products_gallery where uniqueid='".$tmp[5]. "'"; $this->Login(); $Temp=$this->Take($sql); $this->Logoff(); if (empty($Temp)) { $UploadPict=$this->uploadImage($Picture,$tmp[Picture][Pic]); if (count($UploadPict)==0) {$UploadPict[Pic][0]=$this->PictDir.'noimage.jpg';$UploadPict[Pic][1]=$this->PictDir.'noimage2.jpg'; $UploadPict[Pic][2]=$this->PictDir.'noimage2.jpg';} $sql=" insert into products_gallery (products_id,uniqueid,title,titleext,image,imageext,imageext2,gname)"; $sql.= " values ( '".$tmp[4]."','".$tmp[3]."','".$tmp[1]."','".$tmp[2]."','".$UploadPict[Pic][0]."','".$UploadPict[Pic][1]."','".$UploadPict[Pic][2]."'"; if (empty($tmp[gname])) $sql.=",'Podstawowa')"; else $sql.=",'".$tmp[gname]."')"; $this->Login(); $this->ExecSQL($sql); $tab[]=mysql_insert_id(); $this->Logoff(); $this->moveItemGallery($tab,$tmp[4],0); $this->exportItemGalleryToSlide($tmp[4]); } } function updItemGallery($tmp,$Picture) { if (!empty($Picture)) // $UploadPict=$this->uploadImage($Picture,$this->ImgSize,$this->ImgSizeExt); $UploadPict=$this->uploadImage($Picture,$tmp[Picture][Pic]); $sql=" update products_gallery set products_id='".$tmp[4]."', uniqueid='".$tmp[3]."',"; $sql.=" title='".$tmp[1]."',titleext='".$tmp[2]."'"; if (!empty($tmp[gname])) $sql.=",gname='".$tmp[gname]."'"; else $sql.=",gname='Podstawowa'"; if (!empty($UploadPict)) $sql.=",image='".$UploadPict[Pic][0]."',imageext='".$UploadPict[Pic][1]."'"; $sql.=" where id='".$tmp[0]."'"; $this->Login(); $this->ExecSQL($sql); $this->Logoff(); $this->exportItemGalleryToSlide($tmp[4]); } function getGroup($gid) { $sql=" select name from category where id='".$gid."'"; $this->Login(); $tmp=$this->Take($sql); $this->Logoff(); return $tmp; } function getItem($gid,$id,$fil) { $sql = " select products_id,products_uniqueid,products_bone,products_name,products_extra,"; $sql.="products_image,products_imageex,products_image2,products_imageex2,products_model,products_manufacturers,category.name, "; $sql.="products_weight,products_price,products_status,"; // dodatkowe kolumny danych $sql.=" products_weightwg, "; $sql.=" products_date_added"; $sql.=" from products inner join category on products.products_bone=category.id "; if (!empty($gid) and !empty($id)) $sql.="where products_bone='".$gid."' and products_id='".$id."'"; if (empty($gid) and !empty($id)) $sql.=" where products_id='".$id."'"; if (!empty($gid) and empty($id)) $sql.=" where products_bone='".$gid."'"; if (!empty($fil)) $sql.=" ".$fil; $this->Login(); $tmp=$this->Take($sql); $this->Logoff(); return $tmp; } } ?>