Re: Deprecated: mysql_connect(): The mysql extension is deprecated
<?php
date_default_timezone_set('Asia/Kuala_Lumpur');
$db_host = "localhost";
$db_user = "siteu";
$db_password = "12345678";
$db_databasename = "site1";
session_start();
$sessionID = $_COOKIE['PHPSESSID'];
// Fix for removed Session functions
function fix_session_register(){
function session_register(){
$args = func_get_args();
foreach ($args as $key){
$_SESSION[$key]=$GLOBALS[$key];
}
}
function session_is_registered($key){
return isset($_SESSION[$key]);
}
function session_unregister($key){
unset($_SESSION[$key]);
}
}
if (!function_exists('session_register')) fix_session_register();
function konekdb() {
global $db_host, $db_user, $db_password, $db_databasename;
mysql_connect( $db_host, $db_user, $db_password ) or error( mysql_error() );
mysql_select_db( $db_databasename );
}
function error ($error) {
include "error.php";
exit;
}
function CekAdmin() {
session_start();
global $admin_Passwd, $admin_Name;
if( session_is_registered( "admin_Name" ) && session_is_registered( "admin_Passwd" ) ) {
konekdb();
$result=mysql_query( "SELECT user_admin, passwd_admin FROM admin WHERE user_admin='$admin_Name' AND BINARY passwd_admin='$admin_Passwd'" ) or error( mysql_error() );
if( mysql_num_rows( $result ) == 1 ) return true;
}
return false;
}
function CekUser() {
session_start();
global $username, $password;
if( session_is_registered( "username" ) && session_is_registered( "password" ) ) {
$result=mysql_query( "SELECT username, passwd FROM member WHERE username='$username' AND BINARY passwd='$password'" ) or error( "Login failed, please contact adminstrator" ) ;
if( mysql_num_rows( $result ) == 1 )
return true;
}
return false;
}
function cek_email($email) {
if (!preg_match('/^[0-9a-zA-Z\.\-\_]+\@[0-9a-zA-Z\.\-]+$/', $email))
return false;
if (preg_match('/^[^0-9a-zA-Z]|[^0-9a-zA-Z]$/', $email))
return false;
if (!preg_match('/([0-9a-zA-Z_]{1})\@./', $email) )
return false;
if (!preg_match('/.\@([0-9a-zA-Z_]{1})/', $email) )
return false;
if (preg_match('/.\.\-.|.\-\..|.\.\..|.\-\-./', $email) )
return false;
if (preg_match('/.\.\_.|.\-\_.|.\_\..|.\_\-.|.\_\_./', $email) )
return false;
if (!preg_match('/\.([a-zA-Z]{2,5})$/', $email) )
return false;
return true;
}
function kirimemail( $from, $to, $subject, $body ) {
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/plain; charset=ios-8859-1\r\n";
$headers .= "From: {$from}\r\n";
$result = @mail( $to, $subject, $body, $headers );
if( $result ) return true;
else return false;
}
function rupiah($rp) {
$rupiah = "";
$p = strlen($rp);
while($p > 3)
{
$rupiah = "." . substr($rp,-3) . $rupiah;
$l = strlen($rp) - 3;
$rp = substr($rp,0,$l);
$p = strlen($rp);
}
$rupiah = "RM " . $rp . $rupiah . ",-";
return $rupiah;
}
function jumlahpengunjung() {
$timeoutseconds=300; // Timeout value in seconds
$timestamp=time();
$timeout=$timestamp-$timeoutseconds;
//konekdb();
mysql_query("INSERT INTO useronline VALUES ('$timestamp','$REMOTE_ADDR','$PHP_SELF')") or die("Useronline Database INSERT Error");
mysql_query("DELETE FROM useronline WHERE timestamp<$timeout") or die("Useronline Database DELETE Error");
$result=mysql_query("SELECT DISTINCT ip FROM useronline WHERE file='$PHP_SELF'") or die("Useronline Database SELECT Error");
$user =mysql_num_rows($result);
//mysql_close();
if ($user==1) {echo"$user";} else {echo"$user";}
}
/*
function db_result_to_array($query)
{
$result=mysql_query($query);
$res_array = array();
for ($count=0; $row = @mysql_fetch_array($result); $count++)
$res_array[$count] = $row;
return $res_array;
}
*/
$kalenderindo = array("Mon" => "Isnin",
"Tue" => "Selasa",
"Wed" => "Rabu",
"Thu" => "Khamis",
"Fri" => "Jumaat",
"Sat" => "Sabtu",
"Sun" => "Ahad",
"Jan" => "Januari",
"Feb" => "Februari",
"Mar" => "Mac",
"Apr" => "April",
"May" => "Mei",
"Jun" => "Jun",
"Jul" => "Julai",
"Aug" => "Ogos",
"Sep" => "September",
"Oct" => "Oktober",
"Nov" => "November",
"Dec" => "Disember");
?>