//連線 MySQL 主機
$db_link = mysql_connect("142.171.99.132","neodesig_ken","Yxul4dj4");
//設定 MySQL 編碼語系成為 utf8
mysql_query("SET NAMES 'utf8'",$db_link);
//設定 MySQL 客戶端成為 utf8
mysql_query("SET CHARACTER_SET_CLIENT='utf8'",$db_link);
//設定 MySQL 結果輸出成為 utf8
mysql_query("SET CHARACTER_SET_RESULTS='utf8'",$db_link);
//選擇資料庫進行連線
mysql_select_db("neodesig_fuchuang",$db_link);
// 這是可以 Scrollable 加上圖片可以 Tooltip 然後點選圖片呈現 Overlay 的自定函式
function gallery($img_info=array(),$items="")
{
$count = count($img_info);
for ($i=1;$i<$count+1;$i++)
{
if ($i<10)
{
$img_list.= "
\n";
}
else
{
$img_list.= "
\n";
}
}
return $img_list;
}
//設備規劃與系列產品的分類 tabs
function tabs($current="")
{
if ($current <= 2)//設備規劃
{
$c = 3;
$i = 1;
}
elseif ($current <= 7)//系列產品
{
$c = 8;
$i = 3;
}
elseif ($current <= 10)//精選案例
{
$c = 11;
$i = 8;
}
for ($t=$i;$t<$c;$t++)
{
if ($current == $t)
{
$tabs_list.= <<\n
TAB;
}
else
{
$tabs_list.= ($t == 10)? <<\n
TAB
:<<\n
TAB;
}
}
return $tabs_list;
}
//設備規劃與系列產品的選單形象圖片
function menuimg($page="")
{
if ($page==1 || $page==2)
{
$imgname = "menu_img_plan.jpg";
}
elseif ($page==8)
{
$imgname = "menu_img_case.jpg";
}
else
{
$imgname = "menu_img_product.jpg";
}
return $imgname;
}
$overlay = <<
OVERLAY;
$jquery = <<
$(document).ready(function() {
/* chained call: scrollable().find("a").tooltip().overlay().gallery(); */
$(".scrollable").scrollable().find("a").tooltip({
// use this single tooltip element for all trigger elements
tip: '#tooltip'
}).overlay({
// each trigger uses the same overlay with id "gallery"
target: '#gallery',
// optional exposing effect with custom color
expose: '#111',
// clicking outside the overlay does not close it
closeOnClick: false
// gallery plugin
}).gallery({
// do not use the same disabled class name as scrollable
disabledClass: 'inactive'
});
});
QUERY;
$page_name = array(
1 => " | 設備規劃 | 全新規劃",
" | 設備規劃 | 翻修規劃",
" | 系列產品 | 環保系列",
" | 系列產品 | 爐灶系列",
" | 系列產品 | 水槽與工作台",
" | 系列產品 | 冷熱服務設備",
" | 系列產品 | 冷凍冷藏",
" | 精選案例");
function login($id="",$pw="",$process)
{
switch ($process)
{
case "loging":
if (empty($id) or empty($pw))
{
$autoback = " onLoad=\"setTimeout('history.go(-1)',1000)\"";
$content = <<請輸入帳號或密碼!
MAIN;
}
else
{
if (check_user($id,$pw)==false)
{
$autoback = " onLoad=\"setTimeout('history.go(-1)',1000)\"";
$content = <<請輸入正確的帳號與密碼!
MAIN;
}
elseif (check_user($id,$pw))
{
$main = "loging on";
return $main;
}
}
break;
default:
$content = <<
帳號
密碼
MAIN;
}
$page_title = "富創餐飲設備 | 會員登入";
$form = <<
$content
MAIN;
$main = array($page_title,$autoback,$form);
return $main;
}
function video($id,$pw,$op)
{
global $db_link;
if (check_user($id,$pw))
{
//抓出登入會員的序號
$query = "SELECT * FROM user WHERE user_id='{$id}' && user_category='2'";
$result = mysql_query($query,$db_link) or die("無法取得 {$id} 的資料!
");
list ($sn,$user_id,$user_pw,$user_email,$user_nickname,$user_url,$user_reg,$user_cat) = mysql_fetch_array($result);
$list_query = "SELECT * FROM video WHERE user_sn=$sn";
$result = mysql_query($list_query , $db_link);
$i=1;
while ($data = mysql_fetch_array($result))
{
list ($sn,$video_url,$video_title)= $data;
$video_url = explode("http://youtu.be/", $video_url);
if ($i==1){$main[0]=$video_url[1];}
$listing.=($i==1)?
" ":
" ";
$i++;
}
}
else
{
}
$main[1] = <<
您好:{$user_email}
登出
選擇影片:
影片載入中...
MAIN;
return $main;
}
function logout()
{
$_SESSION = array();
session_destroy();
$main = " onLoad=\"setTimeout(window.close, 0)\"";
return $main;
}
function check_user($id="",$pw="")
{
global $db_link;
$query = "SELECT * FROM user WHERE user_id='{$id}' && user_category='2'";
$result = mysql_query($query,$db_link) or die("無法取得 {$id} 的資料!
");
$user = mysql_fetch_assoc($result);
if($user['user_id'] == $id and $user['user_pw'] == $pw and $user['user_category']==2)
{
if(empty($_SESSION["user_id"]) && empty($_SESSION["user_pw"]))
{
$_SESSION["user_id"]=$id;
$_SESSION["user_pw"]=$pw;
}
return true;
}
return false;
}
?>