$_PHPLIB['basedir'] = '/home/afm/public_html/';
$_PHPLIB['sessdir'] = '/home/afm/public_html/tmp';
$_PHPLIB['filedir'] = '/home/afm/public_html/media/file/';
$_PHPLIB['imagedir'] = '/home/afm/public_html/media/image/';
$_PHPLIB['videodir'] = '/home/afm/public_html/media/flash/';
$_PHPLIB['phpdir'] = $_PHPLIB['basedir'] . 'php/';
$_PHPLIB['uploaddir'] = $_PHPLIB['basedir'] . 'upload/';
$_PHPLIB['incdir'] = $_PHPLIB['basedir'] . 'includes/';
$_PHPLIB['logdir'] = $_PHPLIB['basedir'] . 'logs\\';
$_PHPLIB['http_baseUrl'] = 'http://www.afm.org.my/';
$_PHPLIB['http_adminbaseUrl'] = 'http://www.afm.org.my/admin/';
$_PHPLIB['newslettersedir'] = $_PHPLIB['basedir'] . 'newsletters/';
$_PHPLIB['bannerdir'] = $_PHPLIB['basedir'] . '/banner/';
session_save_path($_PHPLIB['sessdir']);
session_start();
$maxUploadFileSize = 8388608; // 8MB
$acceptFileType = array("pdf", "doc", "txt");
$acceptImageType = array("gif", "jpg", "png");
$acceptAllType = array("gif", "jpg", "png","pdf", "doc", "txt");
$results_per_page_photo = 5;
$results_per_page = 10;
$admin_attemp_limit = 3;
$member_attemp_limit = 3;
$result_per_page_news = 5;
$host = "localhost"; // Host name
$username = "afm"; // Mysql username
$password = "jkl9oqK"; // Mysql password
$db_name = "afm_2010"; // Database name
$con = mysql_connect("$host","$username","$password");
if (!$con) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db("$db_name", $con);
?>
function myTruncate($string, $limit, $break=".", $pad="...")
{
if(strlen($string) <= $limit) return $string;
if(false !== ($breakpoint = strpos($string, $break, $limit))) {
if($breakpoint < strlen($string) - 1) {
$string = substr($string, 0, $breakpoint) . $pad;
}
}
return $string;
}
function jsRedirect($url) {
echo "";
}
function debug($str)
{
echo "
DEBUG:" . $str;
}
function debugstop($str)
{
echo "
DEBUG:" . $str;
exit;
}
function formatBytes($bytes, $precision = 2) {
$units = array('B', 'KB', 'MB', 'GB', 'TB');
$bytes = max($bytes, 0);
$pow = floor(($bytes ? log($bytes) : 0) / log(1024));
$pow = min($pow, count($units) - 1);
$bytes /= pow(1024, $pow);
return round($bytes, $precision) . ' ' . $units[$pow];
}
function increaseCounter($table, $counterField, $priField, $id)
{
$sql_counter = "UPDATE $table SET $counterField = $counterField + 1 WHERE status_id=1 AND $priField = '$id'";
$result_counter=mysql_query($sql_counter);
}
function check_email_address($email) {
if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) {
return false;
}
$email_array = explode("@", $email);
$local_array = explode(".", $email_array[0]);
for ($i = 0; $i < sizeof($local_array); $i++) {
if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) {
return false;
}
}
if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) {
$domain_array = explode(".", $email_array[1]);
if (sizeof($domain_array) < 2) {
return false; // Not enough parts to domain
}
for ($i = 0; $i < sizeof($domain_array); $i++) {
if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) {
return false;
}
}
}
return true;
}
function compose_mail($mailto_address, $mailto_name, $mailto_subject, $mailto_body) {
include("config.php");
$log_filename = $_PHPLIB['logdir'] . "mail.log";
// check email address
require_once("class.phpmailer.php");
if (check_email_address($mailto_address)) {
//require("class.phpmailer.php");
writelog ("Mailer Start: " . "mail to: $mailto_address" . " : ", $log_filename);
$mail = new PHPMailer();
$mail->IsSMTP(); // set mailer to use SMTP
$mail->AddAddress($mailto_address, $mailto_name);
$mail->WordWrap = 50; // set word wrap to 50 characters
$mail->IsHTML(true); // set email format to HTML
$mail->Subject = $mailto_subject;
$mail->Body = $mailto_body;
$mail->AltBody = $mailto_body;
if(!$mail->Send())
writelog ("Mailer Error: " . $mailto_body . " : " . $mail->ErrorInfo, $log_filename);
else
writelog ("Mailer Success: " . $mailto_body, $log_filename);
return 1;
} else {
writelog ("Mailer Failed: " . "invalid mail address: $mailto_address" . " : ", $log_filename);
return 2;
}
}
function quote_smart($value)
{
// Stripslashes
if (get_magic_quotes_gpc()) {
$value = stripslashes($value);
}
// Quote if not a number or a numeric string
if (!is_numeric($value)) {
$value = mysql_real_escape_string($value);
}
return trim($value);
}
function file_extension($filename)
{
$path_info = pathinfo($filename);
if (!isset($path_info['extension']))
$path_info['extension'] = "";
return $path_info['extension'];
}
function getPassword($passwordStr) {
return md5(trim($passwordStr));
}
function symbolFileControl($strVariable, $strValue, $showFirstCaption, $firstOptionValue, $otherArgs)
{
echo "";
}
function videoFileControl($strVariable, $strValue, $showFirstCaption, $firstOptionValue, $otherArgs)
{
echo "";
}
function docFileControl($strVariable, $strValue, $showFirstCaption, $firstOptionValue, $otherArgs)
{
echo "";
}
function getRandomPassword() {
$length = 6;
$randomCode = "";
$possible = "0123456789bcdfghjkmnpqrstvwxyz";
$i = 0;
while ($i < $length) {
$char = substr($possible, mt_rand(0, strlen($possible)-1), 1);
if (!strstr($randomCode, $char)) {
$randomCode .= $char;
$i++;
}
}
return $randomCode;
}
function getActivateCode() {
$length = 8;
$activateCode = "";
$possible = "0123456789bcdfghjkmnpqrstvwxyz";
$i = 0;
while ($i < $length) {
$char = substr($possible, mt_rand(0, strlen($possible)-1), 1);
if (!strstr($activateCode, $char)) {
$activateCode .= $char;
$i++;
}
}
return $activateCode;
}
function operatorControl($strVariable, $strValue) {
$myOperator = array(
"1" => "=",
"2" => "<>",
"3" => "<",
"4" => "<=",
"5" => ">",
"6" => ">=",
"7" => "%like%",
"8" => "%like",
"9" => "like%");
echo "";
}
function contentTypeControl($strVariable, $strValue, $showFirstCaption, $firstOptionValue, $otherArgs) {
$myLocation = array(
"1" => "Highlights",
"2" => "Articles",
"3" => "Downloads",
"4" => "Archives",
"5" => "Spotlight");
if ($otherArgs == "")
$otherArgs = "";
echo "";
}
function getContentType_Caption ($status_id) {
if ($status_id == 1)
return "Highlights";
else if ($status_id == 2)
return "Articles";
else if ($status_id == 3)
return "Downloads";
else if ($status_id == 4)
return "Archives";
else if ($status_id == 5)
return "Spotlight";
else
return "-";
}
// kong add 12-April-2007
function dialogbox($dialogType, $title, $message, $buttonCaption, $url) {
if ($dialogType == "info")
$dialogType = "Information";
else if ($dialogType == "err")
$dialogType = "Error";
echo "";
return "
";
}
function writelog ($logentry, $lgname) {
$lgname = $_PHPLIB['logdir'] . $lgname;
$logfile = @fopen ($lgname, "a+");
if (!$logfile) {
echo ("\n\n ERROR: Failed to open $lgname\n\n");
}
else {
fwrite ($logfile, "[".date ("D M d Y h:iA")."] [$logentry]\n");
fclose ($logfile);
}
}
function genderControl($strVariable, $strValue, $showFirstCaption, $firstOptionValue, $otherArgs) {
if ($otherArgs == "")
$otherArgs = "style='width=180px' ";
echo "";
}
function maritalControl($strVariable, $strValue, $showFirstCaption, $firstOptionValue, $otherArgs) {
if ($otherArgs == "")
$otherArgs = "style='width=180px' ";
echo "";
}
function nationalityControl($strVariable, $strValue, $showFirstCaption, $firstOptionValue, $otherArgs) {
if ($otherArgs == "")
$otherArgs = "style='width=180px' ";
echo "";
}
function countryControl($strVariable, $strValue, $showFirstCaption, $firstOptionValue, $otherArgs) {
$currentScriptName = $_SERVER["SCRIPT_NAME"];
$currentScriptName = preg_replace( '/^.+[\\\\\\/]/', '', $currentScriptName );
if ($currentScriptName == "index.php")
include("includes/dropdown.php");
else
include("../includes/dropdown.php");
if ($otherArgs == "")
$otherArgs = "style='width=180px' ";
echo "";
}
function industryControl($strVariable, $strValue, $showFirstCaption, $firstOptionValue, $otherArgs) {
if ($otherArgs == "")
$otherArgs = "style='width=280px' ";
echo "";
}
function employmentControl($strVariable, $strValue, $showFirstCaption, $firstOptionValue, $otherArgs) {
if ($otherArgs == "")
$otherArgs = "style='width=280px' ";
echo "";
}
function weightControl($strVariable, $strValue, $otherArgs) {
if ($otherArgs == "")
$otherArgs = "style='width=50px' ";
echo "";
}
function usergroupControl($strVariable, $strValue, $showFirstCaption, $firstOptionValue, $otherArgs) {
if ($otherArgs == "")
$otherArgs = "style='width=220px' ";
echo "";
}
function getUserGroup_Caption ($usergroup_id) {
if ($usergroup_id != "") {
$sql="SELECT * FROM usergroup WHERE usergroup_id = ".$usergroup_id;
$result =mysql_query($sql);
if ($result && (mysql_num_rows($result) > 0)) {
while($row=mysql_fetch_array($result)) {
$local_imagefolder_name = trim($row['usergroup_caption']);
return $local_imagefolder_name;
}
}
}
else
return "-";
}
function buildingControl($strVariable, $strValue, $showFirstCaption, $firstOptionValue, $otherArgs) {
if ($otherArgs == "")
$otherArgs = "style='width=220px' ";
echo "";
}
function frequencyControl($strVariable, $strValue, $showFirstCaption, $firstOptionValue, $otherArgs) {
if ($otherArgs == "")
$otherArgs = "style='width=220px' ";
echo "";
}
function departmentControlForEquipment($strVariable, $strValue, $showFirstCaption, $firstOptionValue, $otherArgs, $building_id) {
if ($otherArgs == "")
$otherArgs = "style='width=220px' ";
echo "";
}
function getBuilding_Caption ($building_id) {
if ($building_id != "") {
$sql="SELECT * FROM master_building WHERE building_id = ".$building_id;
$result =mysql_query($sql);
if ($result && (mysql_num_rows($result) > 0)) {
while($row=mysql_fetch_array($result)) {
$local_imagefolder_name = trim($row['building_name']);
return $local_imagefolder_name;
}
}
}
else
return "-";
}
function manufacturerControl($strVariable, $strValue, $showFirstCaption, $firstOptionValue, $otherArgs) {
if ($otherArgs == "")
$otherArgs = "style='width=220px' ";
echo "";
}
function getManufacturer_Caption ($manufacturer_id) {
if ($manufacturer_id != "") {
$sql="SELECT * FROM asset_manufacturer WHERE manufacturer_id = ".$manufacturer_id;
$result =mysql_query($sql);
if ($result && (mysql_num_rows($result) > 0)) {
while($row=mysql_fetch_array($result)) {
$local_imagefolder_name = trim($row['manufacturer_name']);
return $local_imagefolder_name;
}
}
}
else
return "-";
}
function categoryControl($strVariable, $strValue, $showFirstCaption, $firstOptionValue, $otherArgs) {
if ($otherArgs == "")
$otherArgs = "style='width=220px' ";
echo "";
}
function categoryControlForEquipment($strVariable, $strValue, $showFirstCaption, $firstOptionValue, $otherArgs, $manufacturer_id) {
if ($otherArgs == "")
$otherArgs = "style='width=220px' ";
echo "";
}
function getCategory_Caption ($category_id) {
if ($category_id != "") {
$sql="SELECT * FROM asset_category WHERE category_id = ".$category_id;
$result =mysql_query($sql);
if ($result && (mysql_num_rows($result) > 0)) {
while($row=mysql_fetch_array($result)) {
$local_imagefolder_name = trim($row['category_name']);
return $local_imagefolder_name;
}
}
}
else
return "-";
}
function typeControl($strVariable, $strValue, $showFirstCaption, $firstOptionValue, $otherArgs) {
if ($otherArgs == "")
$otherArgs = "style='width=220px' ";
echo "";
}
function typeControlForEquipment($strVariable, $strValue, $showFirstCaption, $firstOptionValue, $otherArgs, $manufacturer_id, $category_id) {
if ($otherArgs == "")
$otherArgs = "style='width=220px' ";
echo "";
}
function getType_Caption ($type_id) {
if ($type_id != "") {
$sql="SELECT * FROM asset_type WHERE type_id = ".$type_id;
$result =mysql_query($sql);
if ($result && (mysql_num_rows($result) > 0)) {
while($row=mysql_fetch_array($result)) {
$local_imagefolder_name = trim($row['type_name']);
return $local_imagefolder_name;
}
}
}
else
return "-";
}
function modelControl($strVariable, $strValue, $showFirstCaption, $firstOptionValue, $otherArgs) {
if ($otherArgs == "")
$otherArgs = "style='width=220px' ";
echo "";
}
function modelControlForEquipment($strVariable, $strValue, $showFirstCaption, $firstOptionValue, $otherArgs, $manufacturer_id, $category_id, $type_id) {
if ($otherArgs == "")
$otherArgs = "style='width=220px' ";
echo "";
}
function getModel_Caption ($model_id) {
if ($model_id != "") {
$sql="SELECT * FROM asset_model WHERE model_id = ".$model_id;
$result =mysql_query($sql);
if ($result && (mysql_num_rows($result) > 0)) {
while($row=mysql_fetch_array($result)) {
$local_imagefolder_name = trim($row['model_name']);
return $local_imagefolder_name;
}
}
}
else
return "-";
}
function eventsYearControl($strVariable, $strValue, $showFirstCaption, $firstOptionValue, $otherArgs) {
if ($otherArgs == "")
$otherArgs = "style='width=220px' ";
echo "";
}
function sectionContentDocControl($strVariable, $strValue, $showFirstCaption, $firstOptionValue, $otherArgs) {
if ($otherArgs == "")
$otherArgs = "style='width=220px' ";
echo "";
}
function recipeSectionControl($strVariable, $strValue, $showFirstCaption, $firstOptionValue) {
$otherArgs = "style='width=220px' ";
echo "";
}
function radioBtnControl($optionList, $strVariable, $strValue, $showFirstCaption, $firstOptionValue, $otherArgs, $breakline="") {
$itemArray = split("\|", $optionList);
echo "";
for ($i=0; $i $local_item " . $breakline;
else
echo " $local_item " . $breakline;
}
}
echo "";
}
function groupControl($strVariable, $strValue, $showFirstCaption, $firstOptionValue, $otherArgs) {
if ($otherArgs == "")
$otherArgs = "style='width=180px' ";
echo "";
}
function statusControl($strVariable, $strValue, $showFirstCaption, $firstOptionValue, $otherArgs, $disabled=0) {
if ($otherArgs == "")
$otherArgs = "style='width=180px' ";
if ($disabled == 0)
echo "