PluginID=$array[0]+0; $this->Status=$array[1]+0; $this->PluginName=$array[2]; $this->Version=$array[3]; $this->FilesObject=$array[4]; $this->Files=$array[5]; $this->LastUpdated=$array[6]; $this->ORD = $array[7]+0; $this->Title=$array[8]; } } class pluginsDBRecord extends pluginsRecord { var $dbconn; function pluginsDBRecord($dbc) { $this->dbconn=$dbc; } function get() { global $DB_PREF; $sql="SELECT PluginID,Status,PluginName,Version,FilesObject,Files,LastUpdated,ORD,Title FROM ".DB_PREF."_plugins WHERE PluginID=".$this->PluginID; $ret=$this->dbconn->query($sql);while ($this->dbconn->next_row()) { $this->fillRecord($this->dbconn->row); } return($ret); } function getByName() { global $DB_PREF; $sql="SELECT PluginID,Status,PluginName,Version,FilesObject,Files,LastUpdated,ORD,Title,SerialKey FROM ".DB_PREF."_plugins WHERE PluginName='".$this->PluginName."'"; $ret=$this->dbconn->query($sql); while ($this->dbconn->next_row()) { //Lock with key //if ($this->dbconn->row[9]==generate_key($this->PluginName,sitename)){ $this->fillRecord($this->dbconn->row); //} } return($ret); } function insert() { global $DB_PREF; $sql="INSERT INTO ".DB_PREF."_plugins(Status,PluginName,Version,FilesObject,Files,LastUpdated,Title) VALUES('".$this->Status."','".$this->PluginName."','".$this->Version."','".$this->FilesObject."','".$this->Files."','".$this->LastUpdated."','".$this->Title."')"; $success=$this->dbconn->query($sql);if($success) $this->PluginID=$this->dbconn->insert_id(); return($success); } function update() { global $DB_PREF; $sql="UPDATE ".DB_PREF."_plugins SET Title='".$this->Title."',Status='".$this->Status."',PluginName='".$this->PluginName."',Version='".$this->Version."',FilesObject='".$this->FilesObject."',Files='".$this->Files."',LastUpdated='".$this->LastUpdated."' WHERE PluginID='".$this->PluginID."'"; $ret=$this->dbconn->query($sql);return($ret); return($ret); } function updateORD($ORD=0) { global $DB_PREF; $sql="UPDATE ".DB_PREF."_plugins SET ORD='".(int)$ORD."' WHERE PluginID='".$this->PluginID."'"; $ret=$this->dbconn->query($sql);return($ret); return($ret); } function delete() { global $DB_PREF; $sql="DELETE FROM ".DB_PREF."_plugins WHERE PluginID = '".$this->PluginID."' "; $ret=$this->dbconn->query($sql);while ($this->dbconn->next_row()) { $this->fillRecord($this->dbconn->row); } } } class pluginsList { var $list; function populate($dbconn,$st="",$ORD="") { global $DB_PREF; $counter=0;$this->list=null; $sql="SELECT PluginID,Status,PluginName,Version,FilesObject,Files,LastUpdated,ORD,Title,SerialKey FROM ".DB_PREF."_plugins WHERE PluginID>0 "; if ($st<>"") $sql.=" AND Status='1'"; if ($ORD) $sql .=" ".$ORD; if($dbconn->query($sql)) { while($dbconn->next_row()) { //Lock with key // if ($dbconn->row[9]==generate_key($dbconn->row[2],sitename)){ $this->list[$counter]=new pluginsRecord(); $this->list[$counter]->fillRecord($dbconn->row); $counter++; // } } } } function getAttributes($dbconn,$plgname){ if (!$plgname) return false; if (!$dbconn) return false; $sql="SELECT a.attrID,plg.PluginID,plg.PluginName from ".DB_PREF."_attr a join ".DB_PREF."_plugins plg on a.PluginID=plg.PluginID WHERE plg.PluginName LIKE '".strtolower($plgname)."' "; $res = $dbconn->query($sql); $ids = array(); while($dbconn->next_row(true)){ array_push($ids,$dbconn->row); } return $ids; } } function validate_plugin($dbconn,$name) { return true; $ret=0; $sql="SELECT SerialKey FROM ".DB_PREF."_plugins WHERE PluginName='".$name."'"; $dbconn->query($sql); while($dbconn->next_row()) { $key=$dbconn->row[0]; if ($key==generate_key($name,$_SERVER['HTTP_HOST'])||$_SERVER['HTTP_HOST']=="localhost") $ret=1; } return($ret); } function cache_function($buildCallback,$args = array(), $timeoutSeconds = 3600,$debug=0){ // Set up the filename for the cache file if(is_array($buildCallback)){ $cacheKey = get_class($buildCallback[0]) .'::'. $buildCallback[1]; }else{ $ar = ""; foreach ($args as $v){ if (get_class($v)) continue; $ar .=$v.":"; $ar = trim($ar); } $ar = substr($ar,0,-1); $cacheKey = $buildCallback . ':' . $ar; } //$cacheKey .= ':' . implode(':', $args); $file_path = CACHE_PATH . md5($cacheKey); // If the file hasn't yet been created or is out of date then call the require function and store it's result. if(!file_exists($file_path) OR (abs(time()-filemtime($file_path))) > $timeoutSeconds OR FORGET_CACHE){ $res = call_user_func_array($buildCallback, $args); $result = $buildCallback[0]->list; if ($debug) echo 'fetch from sql'; if (!$handle = fopen($file_path, 'w+')) { if ($debug) echo 'cannot open cache file'; } if (fwrite($handle, serialize($result)) === FALSE) { if ($debug) echo 'cannot write to cache file'; } fclose($handle); // Else, grab the result from the cache. }else{ $result = unserialize(file_get_contents($file_path)); if ($debug) echo 'fetched from disk cache'; } return $result; } ?>TotalPages = $this->getTotalPages(); $this->CurrentPage = $this->getCurrentPage(); $this->ResultArray = array("PREV_PAGE" => $this->getPrevPage(), "NEXT_PAGE" => $this->getNextPage(), "CURRENT_PAGE" => $this->CurrentPage, "TOTAL_PAGES" => $this->TotalPages, "TOTAL_RESULTS" => $this->TotalResults, "PAGE_NUMBERS" => $this->getNumbers(), "MYSQL_LIMIT1" => $this->getStartOffset(), "MYSQL_LIMIT2" => $this->ResultsPerPage, "START_OFFSET" => $this->getStartOffset(), "END_OFFSET" => $this->getEndOffset(), "RESULTS_PER_PAGE" => $this->ResultsPerPage,); return $this->ResultArray; } /* Start information functions */ function getTotalPages() { /* Make sure we don't devide by zero */ if ($this->TotalResults != 0 && $this->ResultsPerPage != 0) { $result = ceil($this->TotalResults / $this->ResultsPerPage); } /* If 0, make it 1 page */ if (isset ($result) && $result == 0) { return 1; } else { return $result; } } function getStartOffset() { $offset = $this->ResultsPerPage * ($this->CurrentPage - 1); if ($offset != 0) { $offset++; } return $offset; } function getEndOffset() { if ($this->getStartOffset() > ($this->TotalResults - $this->ResultsPerPage)) { $offset = $this->TotalResults; } elseif ($this->getStartOffset() != 0) { $offset = $this->getStartOffset() + $this->ResultsPerPage - 1; } else { $offset = $this->ResultsPerPage; } return $offset; } function getCurrentPage() { if (isset ($this->PageVarName) && $this->PageVarName > 0) { return $this->PageVarName; } else { return $this->CurrentPage; } } function getPrevPage() { if ($this->CurrentPage > 1) { return $this->CurrentPage - 1; } else { return false; } } function getNextPage() { if ($this->CurrentPage < $this->TotalPages) { return $this->CurrentPage + 1; } else { return false; } } function getStartNumber() { $links_per_page_half = round($this->LinksPerPage / 2); /* See if curpage is less than half links per page */ if ($this->CurrentPage <= $links_per_page_half || $this->TotalPages <= $this->LinksPerPage) { return 1; /* See if curpage is greater than TotalPages minus Half links per page */ } elseif ($this->CurrentPage >= ($this->TotalPages - $links_per_page_half)) { return $this->TotalPages - $this->LinksPerPage + 1; } else { return $this->CurrentPage - $links_per_page_half; } } function getEndNumber() { if ($this->TotalPages < $this->LinksPerPage) { return $this->TotalPages; } else { return $this->getStartNumber() + $this->LinksPerPage - 1; } } function getNumbers() { for ($i = $this->getStartNumber(); $i <= $this->getEndNumber(); $i++) { $numbers[] = $i; } return $numbers; } } function CreatePaging($url,$InfoArray, $First, $Last, $Previous, $Next, $thepages, $thepage, $thefrom) { $newArr = array(); $newArr = explode("?",$url); /*if ($thepages != "") { echo ''.$thepages.': ('.$thepage.' '.$InfoArray["CURRENT_PAGE"].' '.$thefrom.' '.$InfoArray["TOTAL_PAGES"].') '; } if ($InfoArray["CURRENT_PAGE"] != 1) { echo ''.$First.''; } else { echo ''.$First.''; } if ($InfoArray["PREV_PAGE"]) { echo ''.$Previous.''; } else { echo ''.$Previous.''; }*/ for ($i = 0; $i < count($InfoArray["PAGE_NUMBERS"]); $i++) { if ($InfoArray["CURRENT_PAGE"] == $InfoArray["PAGE_NUMBERS"][$i]) { echo ''.$InfoArray["PAGE_NUMBERS"][$i].''; } else { echo ''.$InfoArray["PAGE_NUMBERS"][$i].''; } } /*if ($InfoArray["NEXT_PAGE"]) { echo ''.$Next.''; } else { echo ''.$Next.''; } if ($InfoArray["CURRENT_PAGE"] != $InfoArray["TOTAL_PAGES"]) { echo ''.$Last.''; } else { echo ''.$Last.''; }*/ } ?>items=array(); $this->quan=array(); $this->discount=0; $this->itemsattr = array(); } function sendERROR($str="Uknown error",$site="") { echo ""; if ($site<>"") echo ""; return; } function add($id,$quant=1) { /*$totalquan=0; foreach($this->items as $k=>$v) { $totalquan+=$this->quan[$k]; } if ($totalquan>=10) $this->sendERROR("��� �������� �� ������ ���� ��� 10 �������"); */ if (!in_array($id,$this->items)) { array_push($this->items,$id); array_push($this->quan,$quant); } else { //tote yparxei //foreach($this->items as $k=>$v) { // if ($v==$id) { // $this->quan[$k]++; // //$this->itemsattr[$k] = array(); // //} } } function addAttr($id,$attr){ $this->itemsattr[$id][$attr['id']] = $attr; } function remove($id) { if (!in_array($id,$this->items)) { } else { //tote yparxei foreach($this->items as $k=>$v) { if ($v==$id) { $this->quan[$k]--; if ($this->quan[$k]<=0) $this->delete($id); } } } } function delete($id) { $temp=null; $temp2=null; $temp3=null; $i=0; foreach($this->items as $k=>$v) { if ($v<>$id) { $temp[$i]=$v; $temp2[$i]=$this->quan[$k]; $temp3[$i] = $this->itemsattr[$v]; $i++; } } $this->items=null; $this->quan=null; $this->itemsattr=null; $this->quan=$temp2; $this->items=$temp; $this->itemsattr = $temp3; } function deleteByID($id){ $p =""; foreach($this->items as $k=>$v){ if ($v==$id){ $p = $k; } } unset($this->items[$p]); unset($this->quan[$p]) ; unset($this->itemsattr[$id]); } function show() { echo "
";
            echo "Items:";
            print_r($this->items);
            echo "Quan:";
			print_r($this->quan);
            echo "Attrs";
			print_r($this->itemsattr);
            echo "Discount";
			print_r($this->discount);
            echo "
"; } } ?>