persistent) { $this->link = mysql_pconnect($Config->mysql_host,$Config->mysql_user,$Config->mysql_host); } else { $this->link = mysql_connect($Config->mysql_host,$Config->mysql_user,$Config->mysql_pass); } mysql_select_db($Config->mysql_base); $this->prefix = $Config->prefix; //Adds prefix. } function query($query) { $this->query = sprintf($query, $Config->prefix); $this->result = mysql_query($this->query,$this->link); return $this->result; } } class getImage { function getImage() { // Constructor should open DB connectivity. $db = new dbcon(); } function Imagedata($imgid) { $imgid = mysql_string_real_escape($imgid, $db->link); //Sanitize input $db->query("SELECT * FROM `%sfiles` WHERE `id` = $imgid"); //Run query. ID is uniq. so should get one row. $imagearray = mysql_fetch_array($db->result); } } class Pagination { var $tot_results = 0; var $results_per_page = 1; var $current_page = 1; var $tot_pages = 1; var $current_result_start = 0; var $current_result_end = 0; function Pagination($current_page = 1, $tot_results = 0, $results_per_page = 1) { $this->setCurrentPage($current_page); $this->setTotalResults($tot_results); $this->setResultsPerPage($results_per_page); $this->calculate(); } function setTotalResults($tot_results) { $tot_results = (int) $tot_results; if ($tot_results < 0) { $tot_results = 0; } $this->tot_results = $tot_results; } function setResultsPerPage($results_per_page) { $results_per_page = (int) $results_per_page; if ($results_per_page < 1) { $results_per_page = 1; } $this->results_per_page = $results_per_page; } function setCurrentPage($current_page) { $current_page = (int) $current_page; if ($current_page < 1) { $current_page = 1; } $this->current_page = (int) $current_page; } function calculate() { if ($this->tot_results == 0) { $this->tot_pages = 1; $this->current_page = 1; $this->current_result_start = 0; $this->current_result_end = 0; return; } $this->tot_pages = (int)($this->tot_results / $this->results_per_page); if (($this->tot_results % $this->results_per_page) != 0) { $this->tot_pages++; } if ($this->current_page > $this->tot_pages) { $this->current_page = $this->tot_pages; } $result_end = $this->results_per_page * $this->current_page; if ($result_end > $this->tot_results) { $this->current_result_end = $this->tot_results; } else { $this->current_result_end = $result_end; } $this->current_result_start = $result_end - $this->results_per_page + 1; } } ?>