I have inherited a website that was abandoned by it's designer, the guy started with a CMS called Simple Content Management. The core of the system works fine and i am figuring out all the ins and outs of the admin slowly, but surely.
My issue is his page nav special edit for navigating through advertisements that are displayed one at a time. The information is all obtained through MySQL.
Currently the script goes << < 1 > >>
The client wants << < 1 2 3 4 5 > >>
This is probably an easy fix, but I am not that experienced in the coding end of things. The code doesn't deal with rows and I have spent hours trying to figure out where to change something that will make this happen.
I have 3 pages involved, a .tpl , init.php and the display page pro.php. If I have any clue what I am doing this special edit he did in the init.php is where I need to tweek something, I think!
I probably am throwing alot more code at you than i need to, but I wanted to make sure you understood what I am dealing with here.
Can anyone make sense of it and drop me a clue?
error_reporting(E_ALL & ~E_NOTICE);
session_start();
// [ UTF WITHOUT BOM]
include('database.php');
include('func_database.php');
include('func_theme.php');
include('func_form.php');
include('func_files.php');
include('func_seo.php');
include('func_menu.php');
include('func_auth.php');
include('func_mail.php');
include('func_misc.php');
include('func_banners.php');
$sc->webTitle = "SCM";
$sc->admin = 'admvdin_session';
$sc->base = basename($_SERVER[PHP_SELF]);
function MultiStipSlashes(&$arr)
{
if (is_array($arr))
foreach ($arr as $list => $key)
{
if (is_array($key))
MultiStipSlashes($arr[$list]);
else
$arr[$list] = addslashes($key);
}
}
MultiStipSlashes($_POST);
MultiStipSlashes($_GET);
extract($_POST);
extract($_GET);
function pages($tb, $url, $perpage='20', $where='')
{
global $sc, $page;
$cquery = mysql_fetch_array(mysql_query("SELECT COUNT(*) as count FROM ".$tb." ".$where));
$count = $cquery[count];
if ($sc->perpage && $page != 'all') $perpage = $sc->perpage;
else if ($page == 'all')
{
$sc->limit = '0';
$sc->perpage = $count;
}
if (!$page || $page == 1) $sc->limit = 0;
else if ($page != 'all') $sc->limit = $page * $perpage - $perpage;
if ($page != 'all' && $count != 0)
{
if (!$page) $page = 1;
$pages = ceil($count / $perpage);
$npages = $pages - $page;
if ($page > 1) $pagelst[] = '<a href="'.$url.'&page='.($page-1).'">'.($page-1).'</a>';
if ($page != $pages) $gonext = ' | <a href="'.$url.'&page='.($page+1).'">Next</a> ';
if ($page > 1) $goprev = ' <a href="'.$url.'&page='.($page-1).'">Prev</a> | ';
$next = ($page + 3);
if ($next > $pages) $next = $pages;
for ($i=$page; $i<=$next; $i++)
{
$pagelst[] = '<a href="'.$url.'&page='.$i.'" '.($i == $page ? 'style="font-weight: bold;"' : '').'>'.$i.'</a>';
}
$pagenav = $prev.implode($pagelst, ' | ');
}
if ($page != 'all')
$txt = 'Pages: '.$goprev.$pagenav.$gonext.' [ <a href="'.$url.'&page=all">All</a> ]';
else
$txt = 'Showing '.$count.' pages';
if ($count == 0) unset($txt);
return $txt;
}
// SPECIAL EDIT
function propages($tb, $url, $perpage='20', $where='', $pr, $id)
{
global $sc, $page;
$cquery = mysql_fetch_array(mysql_query("SELECT COUNT(*) as count FROM ".$tb." ".$where));
$count = $cquery[count];
if ($sc->perpage && $page != 'all') $perpage = $sc->perpage;
else if ($page == 'all')
{
$sc->limit = '0';
$sc->perpage = $count;
}
if (!$page) $page = 1;
if (!$page || $page == 1) $sc->limit = 0;
else if ($page != 'all') $sc->limit = $page * $perpage - $perpage;
if ($page != 'all' && $count != 0)
{
if (!$page) $page = 1;
//$pages = (ceil($count / $perpage)-1);
$pages = ceil($count / $perpage);
// add javascript limit to page
$sc->java_pages = 'var total_pages = '.$pages.';';
$npages = $pages - $page;
if ($count > $page) $gonext = '<a href="javascript: getBanners(\''.$pr.'\', \''.($page+1).'\', 1, '.($page+1).', '.$id.');"><img src="simages/nextAr.jpg" /></a> ';
//if ($count > ($page+1)) $gonext = '<a href="javascript: getBanners(\''.$pr.'\', \''.($page+1).'\', 20, '.($page+1).', '.$id.');" id="_'.$id.'"><img src="simages/nextAr.jpg" /></a> ';
if ($page !=1 && $page) $goprev = ' <a href="javascript: getBanners(\''.$pr.'\', \''.($page-1).'\', 1, '.($page-1).', '.$id.');"><img src="simages/prevAr.jpg" /></a>';
if ($page > 1) $first = '<a href="javascript: getBanners(\''.$pr.'\', \'0\', 1, 1, '.$id.');"><img src="simages/firstAr.jpg" /></a> ';
if ($page != $pages && $pages != 1) $last = ' <a href="javascript: getBanners(\''.$pr.'\', \''.($pages-2).'\', 1, '.$pages.', '.$id.');"><img src="simages/lastAr.jpg" /></a>';
}
$txt = $first.$goprev.' <span id="thisPage">'.$page.'</span> '.$gonext.$last;
return $txt;
}
function goto($url)
{
if ($url)
header("Location: ".$url);
else
header("Location: ".$sc->webAdd);
}
function lst($tb, $pos, $where='')
{
// function get table name and position, build select box with order
global $sc;
$lst = mysql_query("SELECT * FROM ".$tb." ".($where ? "WHERE ".$where : '')." ORDER BY lst");
$txt .= '<select name="db[lst]">'."\n";
if ($pos) $txt .= '<option value="'.$pos.'">At the same place</option>'."\n";
$txt .= '<option value="0">First</option>'."\n";
while ($ww = mysql_fetch_array($lst, MYSQL_ASSOC))
{
$txt .= '<option value="'.$ww['lst'].'.5">After '.$ww['title'].'</option>'."\n";
}
$txt .= '</select>'."\n";
return $txt;
I thank everyone and anyone than can help with this issue, I have other issues with this site I will share and deal with after I solve this one.
Thanks,
Tek