"; echo "location.href='" . $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 "
  $dialogType - $title
$message
"; } 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 ""; if ($showFirstCaption != "") echo ""; if ($strValue == 1) $strSelOpt1 = " SELECTED "; else if ($strValue == 2) $strSelOpt2 = " SELECTED "; else if ($strValue == 3) $strSelOpt3 = " SELECTED "; echo ""; echo ""; echo ""; echo ""; } // kong update 10April2007 function sectionControl($sectionArray, $strVariable, $strValue, $showFirstCaption, $firstOptionValue, $otherArgs, $checkDisabled=0, $controlDisabled=0) { if ($otherArgs == "") $otherArgs = ""; if ($controlDisabled == 0) echo ""; if ($showFirstCaption != "") echo ""; for ($i=1; $i$title"; else echo ""; } else { if ($disabled == 0) { if ($id == $strValue) echo ""; else echo ""; } } } echo ""; } function templateControl($templateArray, $strVariable, $strValue, $showFirstCaption, $firstOptionValue, $otherArgs) { ?> "; for ($i=1; $i$desc"; else echo ""; } echo ""; } function sequenceControl($strVariable, $strValue, $showFirstCaption, $firstOptionValue, $otherArgs) { if ($otherArgs == "") $otherArgs = "style='width=180px' "; echo ""; } function operatorConstructSQL($operator_id, $strValue) { $myOperator = array( "1" => "=", "2" => "<>", "3" => "<", "4" => "<=", "5" => ">", "6" => ">=", "7" => "%like%", "8" => "%like", "9" => "like%", "10" => "is null"); if (($operator_id >=1) && ($operator_id <=6)) $retStr = $myOperator[$operator_id] . " '" . quote_smart($strValue) . "'"; else { if ($operator_id == 7) $retStr = " like '" . quote_smart("%" . $strValue . "%") . "'"; if ($operator_id == 8) $retStr = " like '" . quote_smart("%" . $strValue) . "'"; if ($operator_id == 9) $retStr = " like '" . quote_smart($strValue . "%") . "'"; if ($operator_id == 10) $retStr = " is null "; } return $retStr; } function getSection_Caption ($sectionArray, $section_id) { if ($section_id != "") { list($id, $title, $disabled) = split(":", $sectionArray[$section_id]); return $title; } else return "-"; } function checkSection_Disabled ($sectionArray, $section_id) { if ($section_id != "") { list($id, $title, $disabled) = split(":", $sectionArray[$section_id]); return $disabled; } else return "0"; } function getRecipesSection_Caption($recipes_section_id) { for ($i=0; $i"; } function getImagefolder_Caption ($imagefolder_id) { if ($imagefolder_id != "") { $sql="SELECT * FROM imagefolder WHERE imagefolder_id = ".$imagefolder_id; $result =mysql_query($sql); if ($result && (mysql_num_rows($result) > 0)) { while($row=mysql_fetch_array($result)) { $local_imagefolder_name = trim($row['imagefolder_name']); return $local_imagefolder_name; } } } else return "-"; } function getSectionContent_Caption ($content_id) { if ($content_id != "") { $sql="SELECT * FROM content WHERE content_id = ".$content_id; $result =mysql_query($sql); if ($result && (mysql_num_rows($result) > 0)) { while($row=mysql_fetch_array($result)) { $local_content_name = trim($row['content_name']); return $local_content_name; } } } else return "-"; } function getStatus_Caption ($status_id) { if ($status_id == 1) return "Active"; else if ($status_id == 2) return "Inactive"; else if ($status_id == 3) return "Suspended"; else return "-"; } function getAdminGroup_Caption ($adminGroup_id) { if ($adminGroup_id == 1) return "Super"; else if ($adminGroup_id == 2) return "Normal"; else return "-"; } function check_datestring($strDateTime) { list($strDate, $strTime) = split(" ", $strDateTime); if ($strDate == "0000-00-00") return 0; // yy/mm/dd if (preg_match('/^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})$/',$strDate)) return 1; // dd/mm/yy else if (preg_match('/^([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{4})$/',$strDate)) return 1; else return 0; } function getSQLDateFormat($dateOriFmt,$dateStr) { if (trim($dateStr) == "") return "null"; else if ($dateOriFmt == "DD/MM/YYYY") { list($d, $m, $y) = split("\/", $dateStr); return "\"" . $y . "/" . $m . "/" . $d . "\"" ; } else return "null"; } function displayDateFormat($dateStr) { if (check_datestring($dateStr) == 1) return date("d/m/Y", strtotime($dateStr)); else return ""; } function yearControl($strVariable, $strValue, $showFirstCaption, $firstOptionValue, $otherArgs) { echo ""; } function birthdateControl($strVar, $strDate, $readonly, $onActionOpt) { if ($strDate != "") { $strDate = str_replace("-", "/", $strDate); list($myYear,$myMonth,$myDay)=split("\/", $strDate); } $arrayMon = array("", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"); $dVar = $strVar . "_day"; $mVar = $strVar . "_mon"; $yVar = $strVar . "_yer"; echo ""; echo ""; echo ""; } function displayDateTimeFormat($dateStr) { if (check_datestring($dateStr) == 1) return date("d/m/Y G:i a", strtotime($dateStr)); else return ""; } function displayDateTimeFormat2($dateStr) { if (check_datestring($dateStr) == 1) return date("d M Y", strtotime($dateStr)); else return ""; } function db_isRecordExist($tableName, $fieldName, $value) { $total = 0; $sqlStatement = "SELECT count(*) as totalrow FROM $tableName WHERE $fieldName = '$value'"; $result = mysql_query($sqlStatement); $row_count = mysql_fetch_array($result); $total = $row_count['totalrow']; return $total; } function db_executeSQL($sqlStatement) { $result=mysql_query($sqlStatement); if ($result) { return mysql_affected_rows(); } else { debug(mysql_error()); debug(mysql_errno()); debugstop($sqlStatement); return -1; } } function db_NumberOfRows($tableName) { $sql="SELECT * FROM $tableName"; $result=mysql_query($sql); if ($result) return mysql_num_rows($result); else return -1; } //function printMessage($lang, $codeNumber) { function getCodeMsg($lang, $codeNumber) { $var = "MSGCODE_" . $codeNumber; if ($lang->$var == "") return "cannot find codeNumber=$codeNumber"; else return $lang->$var; } function db_activateAccount($member_login_name, $member_activate_code, &$ret_ValArray) { $sql="SELECT * FROM member WHERE login_name = '$member_login_name' and activate_code = '$member_activate_code'"; $result=mysql_query($sql); if ($result) { if (mysql_num_rows($result) == 1) { $ret_ValArray = mysql_fetch_array($result); $local_member_id = $ret_ValArray['member_id']; $local_activate_flag = $ret_ValArray['activate_flag']; $local_email = $ret_ValArray['email_1']; $local_login_name = $ret_ValArray['login_name']; $local_family_name = $ret_ValArray['family_name']; $local_fore_name = $ret_ValArray['fore_name']; $local_diff_name = $ret_ValArray['diff_name']; $local_title = $ret_ValArray['title']; if ($local_activate_flag == 1) { return 2; // this record already activated } else { // generate password... $newPassword = getRandomPassword(); $newPassword_enc = getPassword($newPassword); // activation code match success, update activation-date $sql="UPDATE member SET login_password = '$newPassword_enc', activate_date = now(), activate_flag = 1, login_attempt=0 WHERE member_id = '$local_member_id'"; $result=mysql_query($sql); // sendmail to user $mailContent = getContents('EMAIL_ACCOUNT_ACTIVATED'); $mailContent = str_replace("%_MEMBER_%", $local_family_name, $mailContent); $mailContent = str_replace("%_LOGIN_NAME_%", $local_login_name, $mailContent); $mailContent = str_replace("%_LOGIN_PASSWORD_%", $newPassword, $mailContent); $mailSubject = "Account Activated"; compose_mail($local_email, $local_login_name, $mailSubject, $mailContent); return 1; } } else return 3; } else return 3; } function db_CheckMemberLogin($member_attemp_limit, $login_name, $login_password, &$retValArray) { $login_password = getPassword($login_password); $sql="SELECT * FROM member WHERE login_name = '$login_name' and login_password = '$login_password'"; $result=mysql_query($sql); if ($result) { if (mysql_num_rows($result) == 1) { $retValArray = mysql_fetch_array($result); // record status_id $local_status_id = $retValArray["status_id"]; $local_member_id = $retValArray["member_id"]; $local_activate_flag = $retValArray["activate_flag"]; if ($local_activate_flag != 1) { return 4; // account not activated yet } else if ($local_status_id == 1) { // login success, update last_logindate $sql="UPDATE member SET last_login = now(), login_attempt=0 WHERE member_id = '$local_member_id'"; $result=mysql_query($sql); return 1; // valid login } else { if ($local_status_id == 2) return 2; // inactive member user else return 3; // suspend member user } } else { // add login_attempt value... $sql="UPDATE member SET login_attempt=login_attempt+1 WHERE login_name = '$login_name'"; $result=mysql_query($sql); // lock record if login_attempt value reach to limit.... $sql ="SELECT login_attempt FROM member WHERE login_name = '$login_name'"; $result =mysql_query($sql); $row = mysql_fetch_array($result); $login_attempt= $row['login_attempt']; if ($login_attempt > $member_attemp_limit) { // set member status = 3 suspended $sql="UPDATE member SET status_id = 3 WHERE login_name = '$login_name'"; $result=mysql_query($sql); return 3; // suspended } } } return 5; } function db_CheckAdminLogin($login_name, $login_password, &$retValArray) { $login_password = getPassword($login_password); $sql="SELECT * FROM admin WHERE login_name = '$login_name' and login_password = '$login_password'"; //$sql="SELECT * FROM admin WHERE login_name = '$login_name'"; $result=mysql_query($sql); if ($result) { if (mysql_num_rows($result) == 1) { $retValArray = mysql_fetch_array($result); // record status_id $local_status_id = $retValArray["status_id"]; $local_admin_id = $retValArray["admin_id"]; if ($local_status_id == 1) { // login success, update last_logindate $sql="UPDATE admin SET last_login = now() WHERE admin_id = '$local_admin_id'"; $result=mysql_query($sql); return 1; // valid login } else { if ($local_status_id == 2) return 2; // inactive admin user else return 3; // suspend admin user } } else { return 4; // invalid user } } else { return 4; // invalid user } } function getContents($content_type, $section_id = 1) { if (($content_type != "") && ($section_id == 1)) { // section_id = 1;general if ($content_type !="") { $sql="SELECT * FROM content WHERE section_id = '1' AND content_name = '$content_type'"; $condition = "section_id = '1' AND content_name = '$content_type'"; } } else if (($content_type == "") && ($section_id != 1)) { // section_id = other... $sql="SELECT * FROM content WHERE section_id = '$section_id'"; $condition = "section_id = '$section_id'"; } if ($sql != "") { $result=mysql_query($sql); if ($result) { // update view counter $dummy = mysql_query("UPDATE content SET viewcounter = viewcounter+1 WHERE $condition"); if (mysql_num_rows($result) == 1) { $row = mysql_fetch_array($result); $local_content_id = $row['content_id']; $local_content_name = $row['content_name']; $local_short_desc = nl2br($row['short_desc']); $local_long_desc = $row['long_desc']; if ($section_id == 1) { if (strlen($local_short_desc) > 0) $outputText = $local_short_desc; if (strlen($local_long_desc) > 0) $outputText .= "
" . $local_long_desc; return $outputText; } else { if (strlen($local_short_desc) > 0) { $outputText = $local_short_desc; $outputText .= "

"; } $outputText .= $local_long_desc; return $outputText; } } } } } /*leng*/ function news_sectionControl($news_sectionArray, $strVariable, $strValue, $showFirstCaption, $firstOptionValue, $otherArgs) { if ($otherArgs == "") $otherArgs = "style='width=180px' "; echo ""; } function getNews_Section_Caption ($news_sectionArray, $section_id) { if ($section_id != "") { list($id, $title) = split(":", $news_sectionArray[$section_id]); return $title; } else return "-"; } function truncate($string, $length) { $paragraph = explode(" ", $string); if($length < count($paragraph)) { for($i = 0; $i < $length; $i++) { if($i < $length - 1) { $output .= $paragraph[$i] . " "; } else { $output .= $paragraph[$i]; } } return $output; } return $string; } function getYear_Range_Caption ($classnote_YearRangeArray, $year_range_id) { if ($year_range_id != "") { list($id, $year_range) = split(":", $classnote_YearRangeArray[$year_range_id]); return $year_range; } else return "-"; } function getYear_Range_Count_Message ($year_range_id) { $sql ="SELECT COUNT(*) AS counter FROM member_classnote WHERE year_range = $year_range_id AND status_id = 1"; $result =mysql_query($sql); $row = mysql_fetch_array($result); if ($row['counter'] > 0) { $message_counter = $row['counter']; } else { $message_counter = 0; } return $message_counter; } function getMemberName ($member_id) { $sql ="SELECT family_name, fore_name FROM member WHERE member_id = '$member_id'"; $result =mysql_query($sql); $row = mysql_fetch_array($result); $member_name = $row['family_name'] . " " . $row['fore_name']; return $member_name; } function classnote_YearRangeControl($classnote_YearRangeArray, $strVariable, $strValue, $showFirstCaption, $firstOptionValue, $otherArgs) { if ($otherArgs == "") $otherArgs = "style='width=180px' "; echo ""; } function createImageBinary($filename, $filetype, $MAX_WIDTH, $MAX_HEIGHT, $fixed=0) { if($filetype == "image/pjpeg" || $file_type == "image/jpeg"){ $src = imagecreatefromjpeg($filename); } else if($filetype == "image/x-png" || $file_type == "image/png"){ $src = imagecreatefrompng($filename); }else if($filetype == "image/gif"){ $src = imagecreatefromgif($filename); } $newwidth=0; list($width,$height)=getimagesize($filename); if ($width >= $MAX_WIDTH+1) { $newwidth=$MAX_WIDTH; $newheight=($height/$width)*$newwidth; } else if ($height >= $MAX_HEIGHT+1) { $newheight=$MAX_HEIGHT; $newwidth=($width/$height)*$newheight; } if ($newwidth == 0) { $instr = fopen($filename,"rb"); return addslashes(fread($instr,filesize($temp_filename))); } else { if (function_exists(imagecreatetruecolor)){ $tmp=imagecreatetruecolor($newwidth,$newheight); }else{ die("Error: Please make sure you have GD library ver 2+"); } imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height); $filename = $filename.".siz"; imagejpeg($tmp,$filename,100); $instr = fopen($filename,"rb"); return addslashes(fread($instr,filesize($filename))); } } function getTemplateLayout($template_id) { /* "1:template_1.gif:No image", "2:template_2.gif:Image on left", "3:template_3.gif:Image on left mix with text", "4:template_4.gif:Image on right mix with text", "5:template_5.gif:Image on left bottom", "6:template_6.gif:3 Images on bottom"); */ if ($template_id == 1) { $html_string = "



"; } else if ($template_id == 2) { $html_string = "








"; } else if (($template_id == 3) OR ($template_id == 4)) { $html_string = "




"; } else if ($template_id == 5) { $html_string = "




"; } else if ($template_id == 6) { $html_string = "




    
"; } if ($template_id == 7) { $html_string = "


  
  


"; } return $html_string; } ?> Welcome To Arthritis Foundation Malaysia