mirror of
https://github.com/Mibew/tray.git
synced 2025-01-22 18:10:34 +03:00
minor: formatting
git-svn-id: https://webim.svn.sourceforge.net/svnroot/webim/trunk@112 c66351dc-e62f-0410-b875-e3a5c0b9693f
This commit is contained in:
parent
7427fb4c68
commit
bcc0ad4746
@ -36,17 +36,10 @@ function get_operators() {
|
|||||||
$link = connect();
|
$link = connect();
|
||||||
|
|
||||||
$query = "select * from chatoperator order by vclogin";
|
$query = "select * from chatoperator order by vclogin";
|
||||||
$result = mysql_query($query,$link) or die(' Query failed: ' .mysql_error().": ".$query);
|
$result = select_multi_assoc($query, $link);
|
||||||
|
|
||||||
$operators = array();
|
|
||||||
while ($op = mysql_fetch_array($result, MYSQL_ASSOC)) {
|
|
||||||
$operators[] = $op;
|
|
||||||
}
|
|
||||||
|
|
||||||
mysql_free_result($result);
|
|
||||||
mysql_close($link);
|
mysql_close($link);
|
||||||
return $operators;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function update_operator($operatorid,$login,$password,$localename,$commonname) {
|
function update_operator($operatorid,$login,$password,$localename,$commonname) {
|
||||||
$link = connect();
|
$link = connect();
|
||||||
@ -65,7 +58,7 @@ function update_operator($operatorid,$login,$password,$localename,$commonname) {
|
|||||||
|
|
||||||
function create_operator_($login,$password,$localename,$commonname,$link) {
|
function create_operator_($login,$password,$localename,$commonname,$link) {
|
||||||
$query = sprintf(
|
$query = sprintf(
|
||||||
"insert into chatoperator (vclogin,vcpassword,vclocalename,vccommonname".") values ('%s','%s','%s','%s'".")",
|
"insert into chatoperator (vclogin,vcpassword,vclocalename,vccommonname) values ('%s','%s','%s','%s')",
|
||||||
mysql_real_escape_string($login),
|
mysql_real_escape_string($login),
|
||||||
md5($password),
|
md5($password),
|
||||||
mysql_real_escape_string($localename),
|
mysql_real_escape_string($localename),
|
||||||
|
@ -34,31 +34,31 @@ function setup_pagination($items,$default_items_per_page=15) {
|
|||||||
$items_per_page = verifyparam("items", "/^\d{1,3}$/", $default_items_per_page);
|
$items_per_page = verifyparam("items", "/^\d{1,3}$/", $default_items_per_page);
|
||||||
if( $items_per_page < 2 )
|
if( $items_per_page < 2 )
|
||||||
$items_per_page = 2;
|
$items_per_page = 2;
|
||||||
|
|
||||||
$total_pages = div(count($items) + $items_per_page - 1, $items_per_page);
|
$total_pages = div(count($items) + $items_per_page - 1, $items_per_page);
|
||||||
$curr_page = verifyparam("page", "/^\d{1,6}$/", 1);
|
$curr_page = verifyparam("page", "/^\d{1,6}$/", 1);
|
||||||
|
|
||||||
if( $curr_page < 1 )
|
if( $curr_page < 1 )
|
||||||
$curr_page = 1;
|
$curr_page = 1;
|
||||||
if( $curr_page > $total_pages )
|
if( $curr_page > $total_pages )
|
||||||
$curr_page = $total_pages;
|
$curr_page = $total_pages;
|
||||||
|
|
||||||
$start_index = ($curr_page-1)*$items_per_page;
|
$start_index = ($curr_page-1)*$items_per_page;
|
||||||
$end_index = min($start_index+$items_per_page, count($items));
|
$end_index = min($start_index+$items_per_page, count($items));
|
||||||
$page['pagination.items'] = array_slice($items, $start_index, $end_index-$start_index);
|
$page['pagination.items'] = array_slice($items, $start_index, $end_index-$start_index);
|
||||||
$page['pagination'] =
|
$page['pagination'] =
|
||||||
array( "page" => $curr_page, "items" => $items_per_page, "total" => $total_pages,
|
array( "page" => $curr_page, "items" => $items_per_page, "total" => $total_pages,
|
||||||
"count" => count($items), "start" => $start_index, "end" => $end_index );
|
"count" => count($items), "start" => $start_index, "end" => $end_index );
|
||||||
} else {
|
} else {
|
||||||
$page['pagination.items'] = false;
|
$page['pagination.items'] = false;
|
||||||
$page['pagination'] = true;
|
$page['pagination'] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setup_empty_pagination() {
|
function setup_empty_pagination() {
|
||||||
global $page;
|
global $page;
|
||||||
$page['pagination.items'] = false;
|
$page['pagination.items'] = false;
|
||||||
$page['pagination'] = false;
|
$page['pagination'] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function generate_pagination($pagination) {
|
function generate_pagination($pagination) {
|
||||||
@ -72,7 +72,7 @@ function generate_pagination($pagination) {
|
|||||||
|
|
||||||
$minPage = max( $curr_page - $links_on_page, 1 );
|
$minPage = max( $curr_page - $links_on_page, 1 );
|
||||||
$maxPage = min( $curr_page + $links_on_page, $pagination['total'] );
|
$maxPage = min( $curr_page + $links_on_page, $pagination['total'] );
|
||||||
|
|
||||||
if( $curr_page > 1 ) {
|
if( $curr_page > 1 ) {
|
||||||
$result .= generate_pagination_link($curr_page-1, generate_pagination_image("prevpage")).$pagination_spacing;
|
$result .= generate_pagination_link($curr_page-1, generate_pagination_image("prevpage")).$pagination_spacing;
|
||||||
}
|
}
|
||||||
@ -87,7 +87,6 @@ function generate_pagination($pagination) {
|
|||||||
$result .= $pagination_spacing;
|
$result .= $pagination_spacing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if( $curr_page < $pagination['total'] ) {
|
if( $curr_page < $pagination['total'] ) {
|
||||||
$result .= $pagination_spacing.generate_pagination_link($curr_page+1, generate_pagination_image("nextpage"));
|
$result .= $pagination_spacing.generate_pagination_link($curr_page+1, generate_pagination_image("nextpage"));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user