זה הDB :
PHP קוד:
<?php
class db {
function connect($host,$user,$pass,$db_name) {
@mysql_connect($host,$user,$pass) or db::set_error("Could Not Connect to the MySQL Database!");
@mysql_select_db($db_name) or db::set_error("Could Not Select the MySQL Database!");
}
function query_error($sql_query) {
die('<div style="width: 500px; font-family: arial;">
<span style="font-size: 24px"><span style="color: red">Fatal Error:</span>There is a problem with the query !</span>
<hr style="color: red; height: 1px;">
<span style="font-size: 15px">The Query Was:</span>
<textarea style="width: 100%; height: 100px">'.$sql_query.'</textarea>
<hr style="color: red; height: 1px">
<span style="font-size: 15px">MySQL Says:</span>
'.mysql_error().'
</div>');
}
function set_error($error) {
die('<div style="width: 500px; font-family: arial;">
<span style="font-size: 24px; color: red">Fatal Error!</span>
<hr style="color: red; height: 1px;">
'.$error.'
</div>');
}
function query($sql_query) {
$query = mysql_query($sql_query) or db::query_error($sql_query);
return $query;
}
function fetch($query) {
$return = mysql_fetch_array($query);
return $return;
}
function select($tbl = FALSE,$where = FALSE,$order = FALSE,$limit = FALSE) {
if($where) {
$where_do = " WHERE $where";
} else {
$where_do = "";
}
if($limit) {
$limit_do = " LIMIT $limit";
} else {
$limit_do = "";
}
if($order) {
if($order != "rand()") {
$order = explode(",",$order);
$order_do = " ORDER BY $order[0] $order[1]";
} else {
$order_do = " ORDER BY rand()";
}
} else {
$order_do = "";
}
if(!$tbl) {
db::set_error("You didn't set a table name.");
}
$query = db::query("SELECT * FROM `{$tbl}`{$where_do}{$order_do}{$limit_do}");
return $query;
}
function delete($tbl = FALSE,$where = FALSE) {
if(!$tbl) {
db::set_error("You didn't set a table name to delete from.");
}
if(!$where) {
db::set_error('You didn\'t set the "WHERE" method.');
}
db::query("DELETE FROM $tbl WHERE $where");
}
function insert($tbl = FALSE,$values = FALSE){
if(!$tbl) {
db::set_error("You didn't set a table name to insert to.");
}
if(!$values) {
db::set_error("You didn't set which values to insert.");
}
db::query("INSERT INTO $tbl VALUES($values)");
}
function update($tbl = FALSE,$values = FALSE,$where = FALSE) {
if(!$tbl) {
db::set_error("You didn't set the table name to update.");
}
if(!$values) {
db::set_error("You didn't set which values to update.");
}
$values = explode(",",$values);
$i = 0;
foreach($values as $key) {
$i++;
if($i == 1) {
$comma = "";
} else {
$comma = ",";
}
$key = explode("#",$key);
for($i=1;$i < count($key);$i++) {
if($i == count($key) - 1) {
$telephone = "";
} else {
$telephone = "#";
}
$all_key .= "$key[$i]{$telephone}";
}
$values_do .= "{$comma} $key[0] = '$all_key'";
}
if($where) {
$where_do = " WHERE {$where}";
}
db::query("UPDATE $tbl SET $values_do{$where_do}");
}
function secure($text) {
$text = mysql_real_escape_string($text);
return $text;
}
function count($text) {
$text = mysql_num_rows($text);
return $text;
}
}
$db = new db;
?>
וזו הפונקציה המלאה שקוראת לשליפה:
PHP קוד:
function badmins() {
$where = "`srLogged`='1'";
$order = '`srID` DESC';
$select = db::select('users', $where, $order);
$lis = null;
while($row = db::fetch($select)) {
$name = $row['srFName'];
$location = null;
$id = $row['srID'];
$lis .= '<li><span class="span1">'.$name.'</span><span class="span2">'.$location.'</span><a href="?op=badmin&do=logout&id='.$id.'"><img src="images/X.png" alt="נתק מנהל" /></a></li>';
}
return skin::logmanage($lis);
}