0) {
$litype=mysql_result($result,0,0);
}
*/
$litype=-1;
}
if($litype!=-1) {
$other='&litype='.$litype;
$extraa=' and litype='.$litype.' ';
}
else {
$other='';
$extraa='';
}
/*
$other='&litype='.$litype;
$extraa=' and litype='.$litype.' ';
*/
function set_string($str) {
$str=strip_tags($str);
$str=htmlentities($str);
return $str;}
if(isset($_POST['insert'])&&(@$_POST['litype']!=-1)){
$name=addslashes(set_string(@$_POST['name']));
$email=addslashes(set_string(@$_POST['email']));
$comments=addslashes(set_string(@$_POST['comments']));
$link=addslashes(strip_tags(@$_POST['link']));
$litype=addslashes(strip_tags(@$_POST['litype']))+0;
$query = "insert into cms_links (name,email,comments,link,litype) values ('$name','$email','$comments','$link',$litype)";
if(mysql_query($query,$con)) {
$mess= 'Succesfuly inserted. Your links will appear after approving by web administration staff.';
}else{$mess= 'Insertion has failed';}
}else{$mess= 'Please select a Category.';$reload=1;}
//
//**********************************************************************************************
// how many rows to show per page
$rowsPerPage =5;
$pagin_max_dis_page_nums=3;
$out='';
$out_nav='';
// by default we show first page
$pagin_pageNum = 1;
$pagin_porder='a';
// if $_GET['page'] defined, use it as page number
if(isset($_GET['page'])&&isset($_GET['porder']))
{
$pagin_pageNum = $_GET['page'];
$pagin_porder=$_GET['porder'];
}
// counting the offset
$offset = ($pagin_pageNum - 1) * $rowsPerPage;
$query = " SELECT * FROM cms_links where status=1 $extraa order by id desc" .
" LIMIT $offset, $rowsPerPage";
$pagin_result = mysql_query($query) or die('Error, failed');
// print the random numbers
while($row = mysql_fetch_array($pagin_result))
{
$out.='
';
}
// how many rows we have in database
$query = "SELECT COUNT(id) AS numrows FROM cms_links where status=1 $extraa order by id desc";
$pagin_result = mysql_query($query) or die('Error, query failed');
$row = mysql_fetch_array($pagin_result, MYSQL_ASSOC);
$numrows = $row['numrows'];
// how many pages we have when using paging?
$pagin_maxPage = ceil($numrows/$rowsPerPage);
// print the link to access each page
$pagin_self = $_SERVER['PHP_SELF'];
$pagin_nav = '';
for($pagin_page = 1; $pagin_page <= $pagin_maxPage; $pagin_page++)
{
if ($pagin_page == $pagin_pageNum)
{
$pagin_nav .= " $pagin_page "; // no need to create a link to current page
}
else
{
$pagin_nav .= " $pagin_page ";
}
}
// creating previous and next link
// plus the link to go straight to
// the first and last page
if ($pagin_pageNum > 1)
{
$pagin_page = $pagin_pageNum - 1;
$pagin_prev = " [Prev] ";
$pagin_first = " [First Page] ";
}
else
{
$pagin_prev = ' '; // we're on page one, don't print previous link
$pagin_first = ' '; // nor the first page link
}
if ($pagin_pageNum < $pagin_maxPage)
{
$pagin_page = $pagin_pageNum + 1;
$pagin_next = " [Next] ";
$pagin_last = " [Last Page] ";
}
else
{
$pagin_next = ' '; // we're on the last page, don't print next link
$pagin_last = ' '; // nor the last page link
}
// and close the database connection
include('cms/library/closedb.php') ;
mysql_free_result($pagin_result);
$pagin_nav = '';
/*
1- select the value for porder
2- select the values for $pagin_page and $pagin_max_dis_page_nums
*/
$pagin_start=1;
if(($pagin_maxPage<=$pagin_max_dis_page_nums)&&($pagin_porder=="a")){$case=1;}
if(($pagin_maxPage>$pagin_max_dis_page_nums)&&($pagin_porder=="a")&&(($pagin_maxPage-$pagin_pageNum+1)>=$pagin_max_dis_page_nums)){$case=2;}
if(($pagin_maxPage>$pagin_max_dis_page_nums)&&($pagin_porder=="a")&&(($pagin_maxPage-$pagin_pageNum+1)<$pagin_max_dis_page_nums)){$case=3;}
switch ($case) {
case 1: $pagin_start=1;$pagin_porder='a';$pagin_max_dis_page_nums=$pagin_maxPage;break;
case 2:$pagin_start=$pagin_pageNum;$pagin_porder='a';$pagin_max_dis_page_nums=($pagin_max_dis_page_nums+$pagin_pageNum-1);break;
case 3:$pagin_start=$pagin_maxPage-$pagin_max_dis_page_nums+1;$pagin_porder='a';$pagin_max_dis_page_nums=$pagin_maxPage;break;
default:
}
for($pagin_page = $pagin_start; $pagin_page <= $pagin_max_dis_page_nums; $pagin_page++)
{
if ($pagin_page == $pagin_pageNum)
{
$pagin_nav .= " $pagin_page "; // no need to create a link to current page
}
else
{
$pagin_nav .= " $pagin_page ";
}
}
function link_types(){
global $litype;
if ($litype!=-1) {
}
include "cms/library/config.php";
include "cms/library/opendb.php";
$query = " SELECT id,name FROM cms_links_types where status=1 order by id asc";
$result = mysql_query($query , $con) or die('Error, failed');
if( mysql_num_rows($result )>0) {
for($i=0;$i<(mysql_num_rows($result ));$i++) {
$litype=mysql_result($result,$i,0 );
$query2 = " SELECT count(litype) FROM cms_links where litype=$litype and status=1 ";
$result2 = mysql_query($query2 , $con) or die('Error, failed');
echo ' '.mysql_result($result,$i,1 ).' ('.mysql_result($result2,0,0 ).') ';
}
} else {echo 'No Links Categories ';}
}
function all_items(){
global $litype;
if ($litype!=-1) {
}
include "cms/library/config.php";
include "cms/library/opendb.php";
$query = " SELECT id,name FROM cms_links_types where status=1 order by id asc";
$result = mysql_query($query , $con) or die('Error, failed');
if( mysql_num_rows($result )>0) {
$num=0;
for($i=0;$i<(mysql_num_rows($result ));$i++) {
$litype=mysql_result($result,$i,0 );
$query2 = " SELECT count(litype) FROM cms_links where litype=$litype and status=1 ";
$result2 = mysql_query($query2 , $con) or die('Error, failed');
$num +=mysql_result($result2,0,0 );
}
echo $num ;
} else {echo '0';}
}
function litype_select(){
include "cms/library/config.php";
include "cms/library/opendb.php";
$query = " SELECT id,name FROM cms_links_types where status=1 order by id asc";
$result = mysql_query($query , $con) or die('Error, failed');
if( mysql_num_rows($result )>0) {
for($i=0;$i<(mysql_num_rows($result ));$i++) {
echo '';
}
} else {echo '';}}
//**********************************************************************************************
?>
Links