Functions
WebDev/*nix assorted functions & hacks
Search
find all
Array
-
Bash
-
Classes
-
Config
-
DateTime
-
Debug
-
dotjs
-
File
-
foooo
-
Git
-
HTML
-
Images
-
Javascript
-
Linux
-
Math
-
Misc
-
MySQL
-
OS X
-
Reading
-
Redis
-
Shell scripts
-
snippets
-
SQL
-
Strings
-
TextMate
-
Web
-
\(^o^)/ Fun!
-
_Misc hacks
-
_Pages
Misc
* Readme
** Meta: todo
bash colors. thing.
getset($key, $val=null)
get_vars_from_file($file)
googlinks($links, $total, $return=0)
header_404()
return_bytes($val)
valid_email($address)
9
found
auth
Name:
Category: Misc
Body:
/* $links is the number of links you want per page, $total the total nr of records found by the query, and $return returns the result in some different ways. 0 is as string, 1 is array of links or somesuch, wanted to add more. It creates links with a 'page=n' Get parameter, and uses the same. And it adds it to the current links, so searches done with GET will work fine. It uses http_raw_query() (functions.php?id=126) so you need that. */ #_______________________________________ # googlinks($links, $total, $return=0) / function googlinks($links, $total, $return=0) { global $me; $prev = 'vorige'; $next = 'volgende'; $page = (int) @$_GET['page']; $skip = $links * $page; $out = ''; $b = "style='font-weight: bold;'"; parse_str($_SERVER['QUERY_STRING'], $query); unset($query['page']); if ($query = http_raw_query($query)) $query .= '&'; $pages = ceil($total/$links)-1; $items[] = ($page > 0) ? array("« $prev", "$me?{$query}page=".($page-1)) : "<span style='color: gray;'>« $prev</span>"; for($i=0;$i<=$pages;$i++) { $items[] = array($i+1, "$me?{$query}page=$i"); } $items[] = ($page < $pages) ? array("$next »", "$me?{$query}page=".($page+1)) : "<span style='color: gray;'>$next »</span>"; if (! $return) { foreach($items as $val) $out .= ' '. (is_array($val) ? "<a href='{$val[1]}' ".(($val[0] == ($page+1)) ? $b : '').">{$val[0]}</a>" : $val); $out = substr($out, 1); }elseif ($return == 1) { $out = array(); foreach($items as $val) $out[] = is_array($val) ? "<a href='{$val[1]}' ".(($val[0] == ($page+1)) ? $b : '').">{$val[0]}</a>" : $val; } return $out; }
Footer