// SrCMS config
if($_SERVER['HTTP_HOST']=='localhost'){
$conf_db_hostname = "localhost";
$conf_db_dbname = "cwmongolia";
$conf_db_username = "root";
$conf_db_password = "";
define("SU","http://localhost/cwmongolia/");
define("IMG","http://localhost/cwmongolia/images/");
define("ADMINPATH","http://localhost/cwmongolia/admin/");
define("_IMG",IMG);
define("SITEURL",SU);
define("ADMINURL",ADMINPATH);
}else{
$conf_db_hostname = "localhost";
$conf_db_dbname = "cwmongoliadb";
$conf_db_username = "cwmongoliadb";
$conf_db_password = "xgP#nqVGbrN@1";
define("SU","http://www.cwmongolia.com/");
define("IMG","http://www.cwmongolia.com/images/");
define("_IMG",IMG);
define("SITEURL",SU);
}
// mysql database connection
$connect_result = @mysql_connect($conf_db_hostname, $conf_db_username, $conf_db_password);
if($connect_result==false){
die("
SrCMS error: ".mysql_error()." ");
}
$connect_db = @mysql_select_db($conf_db_dbname, $connect_result);
if($connect_db==false){
die("SrCMS error: ".mysql_error()." ");
}
mysql_query("SET NAMES 'utf8';", $connect_result);
mysql_query("SET CHARACTER SET 'utf8';", $connect_result);
mysql_query("SET SESSION collation_connection = 'utf8_unicode_ci';", $connect_result);
// mysql database connection END
function phptime(){
return time();
}
function nosql($a){
$a = mysql_real_escape_string($a);
return $a;
}
function nohtml($a){
$a = htmlspecialchars($a);
return $a;
}
function delhtml($a){
$a = preg_replace("!\<(.*)\>!Usi", "", $a);
return $a;
}
function nocode($a){
$a = htmlspecialchars($a);
return $a;
}
// session start
session_start();
function is_admin(){
if($_SESSION["session2_admin_name"]==true AND $_SESSION["session2_admin_password"]==true){
$reply = 1;
}else{
$reply = 0;
}
return $reply;
}
function image_create($orig_img, $type, $max_w, $max_h, $output_img, $output_quality){
list($width_orig, $height_orig) = getimagesize($orig_img);
$ratio_orig = $width_orig/$height_orig;
if ($max_w/$max_h > $ratio_orig) {
$max_w = $max_h*$ratio_orig;
} else {
$max_h = $max_w/$ratio_orig;
}
if($type=="gif"){
$image_p = imagecreatetruecolor($max_w, $max_h);
$image = imagecreatefromgif($orig_img);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $max_w, $max_h, $width_orig, $height_orig);
imagegif($image_p, $output_img);
}
if($type=="jpg"){
$image_p = imagecreatetruecolor($max_w, $max_h);
$image = imagecreatefromjpeg($orig_img);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $max_w, $max_h, $width_orig, $height_orig);
imagejpeg($image_p, $output_img, $output_quality);
}
} // function im resize
function image_upload2($fieldname,$topath,$item_id){
global $_FILES;
if($_FILES[$fieldname]['size'] > 0){
switch($_FILES[$fieldname]['type']) {
case 'image/gif';
$i_type="gif";
break;
case 'image/jpeg';
$i_type="jpg";
break;
case 'image/pjpeg';
$i_type="jpg";
break;
} //swit
if($i_type){
$rand_name = $item_id."_".rand(1000000,9999999).".".$i_type;
if(move_uploaded_file($_FILES[$fieldname]['tmp_name'], $topath."".$rand_name)==true){
return $rand_name;
}else{
return 0;
}
}else{
return 0;
}
}else{
return 0;
}
}
function swf_upload($fieldname,$topath,$item_id){
global $_FILES;
if($_FILES[$fieldname]['size'] > 0){
switch($_FILES[$fieldname]['type']) {
case 'image/gif';
$i_type="gif";
break;
case 'image/jpeg';
$i_type="jpg";
break;
case 'image/pjpeg';
$i_type="jpg";
break;
case 'application/x-shockwave-flash';
$i_type="swf";
break;
} //swit
if($i_type){
$rand_name = $item_id."_".rand(1000000,9999999).".".$i_type;
if(move_uploaded_file($_FILES[$fieldname]['tmp_name'], $topath."".$rand_name)==true){
return $rand_name;
}else{
return 0;
}
}else{
return 0;
}
}else{
return 0;
}
}
function banner_show($gid){
$fetchgroup = mysql_fetch_array(mysql_query("SELECT * FROM srcms_banners_group WHERE id='$gid' "));
if($fetchgroup){
$sql = mysql_query("SELECT * FROM srcms_banners WHERE gid='$gid' ORDER BY list_order ASC ");
$num = mysql_num_rows($sql);
if($num > 0){
if($fetchgroup[torol]==0){
// list
echo "\n";
while($list = mysql_fetch_array($sql)){
echo "";
echo "";
$sizex = explode("x",$list[size]);
$w = $sizex[0];
$h = $sizex[1];
$type = substr($list[img],-3);
if($type=='jpg' OR $type=='gif'){
if($list[bairlal]==1){ $target = " target=\"_blank\" "; }else{ $target=''; }
if($list[linkurl]){ echo ""; }
echo " ";
if($list[linkurl]){ echo " "; }
}
if($type=='swf'){
$swf_url1 = SU."upload/webbanners/$list[img]";
$swf_url2 = SU."upload/webbanners/".str_replace(".swf","",$list[img]);
$neh1 = " ";
$neh2 = "'flashvars','linkurl=".urlencode($list[linkurl])."',";
echo '';
echo '
'.$neh1.'
';
}
echo " ";
echo " ";
echo "";
echo "";
echo " ";
echo " ";
echo " ";
}//whiel
echo "
\n";
}
if($fetchgroup[torol]==1){
// random one
$randid = rand(0,($num-1));
$list = mysql_fetch_array(mysql_query("SELECT * FROM srcms_banners WHERE gid='$gid' ORDER BY list_order ASC LIMIT ".$randid.",1 "));
echo "\n";
echo "";
echo "";
$sizex = explode("x",$list[size]);
$w = $sizex[0];
$h = $sizex[1];
$type = substr($list[img],-3);
if($type=='jpg' OR $type=='gif'){
if($list[bairlal]==1){ $target = " target=\"_blank\" "; }else{ $target=''; }
if($list[linkurl]){ echo ""; }
echo " ";
if($list[linkurl]){ echo " "; }
}
if($type=='swf'){
$swf_url1 = SU."upload/webbanners/$list[img]";
$swf_url2 = SU."upload/webbanners/".str_replace(".swf","",$list[img]);
$neh1 = " ";
$neh2 = "'flashvars','linkurl=".urlencode($list[linkurl])."',";
echo '';
echo '
'.$neh1.'
';
}
echo " ";
echo " ";
echo "
\n";
}
}
}
}
// banners end
function swf($zam,$link,$w,$h){
if($link){
$swf_url1 = $zam;
$swf_url2 = str_replace(".swf","",$zam);
$neh1 = " ";
$neh2 = "'flashvars','linkurl=".urlencode($link)."',";
}else{
$swf_url1 = $zam;
$swf_url2 = str_replace(".swf","",$zam);
}
echo '';
echo '
'.$neh1.'
';
}
$ru = $_SERVER["REQUEST_URI"];
$ru = "http://".$_SERVER["SERVER_NAME"].$ru;
$ru = str_replace(SITEURL,"",$ru);
$ru2 = explode("?",$ru);
$ru = $ru2[0];
if($ru==true){
if(substr($ru,-1)!="/"){
$ru .= "/";
}
$ru_t = explode("/",$ru);
$niit_ru_t = count($ru_t);
for($z=0;$z<$niit_ru_t;$z++){
$nm = $z+1;
$v_ner = "v".$nm;
$$v_ner = $ru_t[$z];
}
$suuliin_u = $niit_ru_t-1;
$suuliin_v_ner = "v".$suuliin_u;
$suuliin_v = $$suuliin_v_ner;
$suuliin_v = str_replace(".html","",$suuliin_v);
$suuliin_v = str_replace(".htm","",$suuliin_v);
$suuliin_v = str_replace(".php","",$suuliin_v);
$suuliin_v = str_replace(".asp","",$suuliin_v);
$suuliin_v = str_replace(".jsp","",$suuliin_v);
$$suuliin_v_ner = $suuliin_v;
}
function cmenu2($cid,$aaa){
global $lang;
$sql = mysql_query("SELECT * FROM srcms_contents WHERE cat='$cid' AND lang='$lang' AND publish='1' ORDER BY list_order ASC ");
$num = mysql_num_rows($sql);
if($num > 0){
$count=0;
while($list = mysql_fetch_array($sql)){
$count++;
mysql_query("UPDATE srcms_contents SET list_order='$count' WHERE id='$list[id]' ");
if($list[cat] != '0') { $expand = "class='sub'"; } else { $expand = "class='root'"; }
echo "";
$types = $list['content_torol'];
switch($types)
{
default:
break;
case "1":
echo "$list[title] ";
break;
case "2":
break;
case "3":
echo "$list[title] ";
break;
}
$sql2 = mysql_query("SELECT id FROM srcms_contents WHERE cat='$list[id]' AND lang='$lang' ");
$num2 = mysql_num_rows($sql2);
if($num2 > 0){
$dddd=$aaa+1;
echo ""; //style=\"display:none;\"
cmenu2($list[id],$dddd);
echo " ";
}
echo " ";
} //while
} // num
}
if($_POST){
foreach ($_POST as $key => $val) {
$$key = $val;
}
}
if($_GET){
foreach ($_GET as $key => $val) {
$$key = $val;
}
}
?>
CW MGL Co.,Ltd - Procurement and Service company