' . print_r($_SERVER, true) . ''); require_once('../admin/db.connect.php'); require_once('../admin/library/utils.class.php'); require_once('../admin/library/kikiladi.utils.class.php'); setlocale(LC_ALL, 'fr_FR.UTF-8'); define('ITEMS_PER_PAGE', 15); define('MAX_DISPLAYED_PAGES', 9); function filterParam($param) { $param = mb_strtolower(trim(stripslashes($param)),'UTF-8'); $param = str_replace('_', ' ', $param); $param = trim($param); $param = preg_replace('/[^A-Za-z0-9 \'âàçéèêëïîòôöù\-\?]/', '', $param); return $param; } function filterLink($param) { $param = mb_strtolower(trim(stripslashes($param)),'UTF-8'); $param = preg_replace('/[^A-Za-z0-9 \'âàçéèêëïîòôöù\-]/', '', $param); $param = str_replace(' ', '_', $param); return $param; } if (isset($_GET['p']) && is_numeric($_GET['p']) && $_GET['p'] > 0) { $page = $_GET['p']; } else { $page = 1; } if (isset($_GET['s']) && is_numeric($_GET['s']) && $_GET['s'] > 0) { $startId = $_GET['s']; } $limitStart = (($page-1) * ITEMS_PER_PAGE); // resultat de citations images $citationImageList = array(); $sql = "select * from citation_image where status = 'active'"; $imageResult = mysql_query($sql) or die(mysql_error()); $recordCount = mysql_num_rows($imageResult); if (!isset($startId)) { $sql = "select * from citation_image where status = 'active' order by id DESC limit " . $limitStart . ', ' . ITEMS_PER_PAGE; $imageResult = mysql_query($sql) or die(mysql_error()); while ($imageRow = mysql_fetch_assoc($imageResult)) { $citationImageList[$imageRow['id']] = $imageRow; } } else { $allImageList = array(); $sql = "select * from citation_image where status = 'active' order by id DESC"; $imageResult = mysql_query($sql) or die(mysql_error()); while ($imageRow = mysql_fetch_assoc($imageResult)) { if ($imageRow['id'] == $startId) { $initialIndex = count($allImageList); } $allImageList[] = $imageRow; } $init = $initialIndex + $limitStart; $i = $init; if ($init < count($allImageList)) { for ($i=$init; $i < ($init+ITEMS_PER_PAGE); $i++) { if (!isset($allImageList[$i])) { break; } $citationImageList[$allImageList[$i]['id']] = $allImageList[$i]; } } if (count($citationImageList) < ITEMS_PER_PAGE) { $init = $i - count($allImageList); for ($i=$init; $i < $init + ITEMS_PER_PAGE; $i++) { if ($allImageList[$i]['id'] == $startId) { break; } $citationImageList[$allImageList[$i]['id']] = $allImageList[$i]; if (count($citationImageList) >= ITEMS_PER_PAGE) { break; } } } } $totalPages = intval($recordCount / ITEMS_PER_PAGE) + 1; if ($recordCount % ITEMS_PER_PAGE == 0) { $totalPages--; } if ($page > $totalPages) { $page = 1; } if ($totalPages > 1) { if ($totalPages > MAX_DISPLAYED_PAGES) { if ($page < round(MAX_DISPLAYED_PAGES / 2)) { $firstPage = 1; $lastPage = MAX_DISPLAYED_PAGES; } elseif ($page > $totalPages - floor(MAX_DISPLAYED_PAGES / 2)) { $lastPage = $totalPages; $firstPage = $totalPages - MAX_DISPLAYED_PAGES + 1; } else { $firstPage = $page - floor(MAX_DISPLAYED_PAGES / 2); $lastPage = $firstPage + MAX_DISPLAYED_PAGES - 1; } } else { $firstPage = 1; $lastPage = $totalPages; } $format = $_SERVER['PHP_SELF'] . '?p={{pid}}'; if (isset($startId)) { $format .= '&s=' . $startId; } if ($firstPage > 1) { $pagesHtml = '<<'; } else { $pagesHtml = '<<'; } $pagesHtml .= '   '; $isFirst = true; for ($i=$firstPage; $i<= $lastPage; $i++) { if (!$isFirst) { $pagesHtml .= ' - '; } if ($i == $page) { $pagesHtml .= $i; } else { $pagesHtml .= '' . $i . ''; } $isFirst = false; } $pagesHtml .= '   '; if ($page < $totalPages && $totalPages > MAX_DISPLAYED_PAGES) { $pagesHtml .= '>>'; } else { $pagesHtml .= '>>'; } } else { $pagesHtml = ''; } ?> KIKILADI - Citations & proverbes illustrées.
0): ?>
$info): ?>