Location: PHPKode > scripts > Particle Gallery > includes/functions_other.php
<?php
function dopaging($pages, $cur = "", $url, $pagevar = ""){
	global $config;
	
	// standard validation
	$pages = intval($pages);
	$cur   = intval($cur);
	
	// work out page variable
	$pv = ($pagevar == "") ? "page" : $pagevar;
	
	if ($pages < 1){ return false; }
	if ($cur == 0){ $cur = 1; }
	
	// work out the page listings
	$pl = intval($config["pagelistings"]);
	$bl = ($cur - $pl); // boundary, lower
	$bu = ($cur + $pl); // boundary, upper
	
	// loop through each result
	for($i = 1; $i <= $pages; $i++){
		if(($cur) == $i){
			$result .= '<a href="' . $url . '&amp;' . $pv . '=' . $i . '"><strong>' . $i . '</strong></a> ';
		} elseif ($i >= $bl && $i <= $bu){
			$result .= '<a href="' . $url . '&amp;' . $pv . '=' . $i . '">' . $i . '</a> ';
		} elseif ($i == 1){
			$result .= '<a href="' . $url . '&amp;' . $pv . '=' . $i . '">' . $i . '</a>... ';
		} elseif ($i == $pages){
			$result .= '...<a href="' . $url . '&amp;' . $pv . '=' . $i . '">' . $i . '</a> ';
		}
	}
	
	// and return
	return $result;
}

// generate a random password
function GeneratePassword() {
	
    $salt = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
	srand((double)microtime()*1000000);  
    $i = 0;
    while ($i < 8) {  // change for other length
        $num = rand() % 33;
        $tmp = substr($salt, $num, 1);
        $pass = $pass . $tmp;
        $i++;
    }
    
    return $pass;
}

function randomimage(){
	global $db, $dbprefix;
	
	// exclude hidden albums
	if ($usr->Access > 1){
		$hid = "0";
	} else {
		$hid = fetchhiddenstack();
		$hid = process_stack($hid);
	}
	
	// get recordset
	$sql = "SELECT imageid FROM " . $dbprefix . "images WHERE albumid NOT REGEXP '^(" . $hid . ")$' AND visible = 1 ORDER BY RAND(" . (time() * 75636) . ") LIMIT 0, 1";
	$rec = $db->execute($sql);
	
	// and return result
	if ($rec->rows < 1){
		return false;
	} else {
		return $rec->fields["imageid"];
	}
}
?>
Return current item: Particle Gallery