1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
<? session_start(); ini_set('display_errors',0);
function sendEmail( $to, $subject, $content_arr = array(), $sender_name, $sender_email, $map_file ,$form_name) { $headers = "From: ".$sender_name." <".$sender_email.">\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=uft-8\r\n"; $headers .= "Reply-To: ".$sender_name."<".$sender_email.">\r\n"; $headers .= "Return-Path: ".$sender_name."<".$sender_email.">\r\n"; $headers .= "Message-ID: <".time()." ".$sender_email.">\r\n"; $headers .= "X-Mailer: PHP v".phpversion()."\r\n"; $msg = file_get_contents( 'email/'.$map_file ); $msg = str_replace('{sender_email}', $sender_email, $msg); foreach ( $content_arr as $key=>$value ){ $msg = str_replace('{'.$key.'}', $value, $msg); } include('phpmailer/class.phpmailer.php'); $x_mail = new PHPMailer(); $x_mail->IsSMTP(); //$x_mail->SMTPDebug = 2; $x_mail->Host = 'smtp.mandrillapp.com'; // Specify main and backup server $x_mail->Port = 587; // Set the SMTP port $x_mail->SMTPAuth = true; // Enable SMTP authentication $x_mail->Username = 'garricklam@onesolution.com.hk'; // SMTP username $x_mail->Password = 'lYtE-w6jVOD4vZQrurvraQ'; // SMTP password $x_mail->SMTPSecure = 'tls';
$x_mail->CharSet = "UTF-8"; $x_mail->Sender = $to; //$x_mail->AddReplyTo($enquiryemail, $company_name); $x_mail->From = $sender_email; $x_mail->FromName = $sender_name;
$x_mail->AddAddress($to, $form_name); //$x_mail->AddBCC("kelvinchan@onesolution.com.hk", $company_name);
$x_mail->WordWrap = 50; $x_mail->IsHTML(true); $x_mail->Subject = $subject; $x_mail->Body = $msg;
$x_mail->Send(); } function parsePages( $page = 1, $item_total = 0, $item_per_page = 6 ) { $page_total = ceil($item_total/$item_per_page); $page = !$page||$page>$page_total ? 1 : $page; $loopMin = $item_per_page*($page-1); $loopMix = $item_per_page+$loopMin; return array($page, $page_total, $loopMin, $loopMix); } function mysql_install($array,$table,$action='add',$idname="",$id=""){ //array字串(array_keys),db table name,add=新db edit=修改,del= 刪除 $arraykey=array_keys($array); if($action=='add'){ $sql= "INSERT INTO `".$table."` ("; for($i=0;$i<count($array);$i++){ if($i+1<count($array)){ $dot=','; }else{ $dot=''; } $sql.= "`".$arraykey[$i]."`".$dot; } $sql.= ') values ('; for($i=0;$i<count($array);$i++){ if($i+1<count($array)){ $dot=','; }else{ $dot=''; } $sql.= "'".$array[$arraykey[$i]]."'".$dot; //$sql.= "?".$dot; } $sql.= ')'; }else if($action=='edit'){ $sql="UPDATE `".$table."` SET "; for($i=0;$i<count($array);$i++){ if($i+1<count($array)){ $dot=','; }else{ $dot=''; } $sql.= "`".$arraykey[$i]."` = '".$array[$arraykey[$i]]."'".$dot; //$sql.= "`".$arraykey[$i]."` = ?".$dot; } $sql.=" WHERE `".$table."`.`".$idname."` =".$id.";"; //$sql.=" WHERE `".$table."`.`".$idname."` =?;"; }else if($action=='del'){ $sql.="DELETE FROM `".$table."` WHERE `".$table."`.`".$idname."` =".$id; } return $sql; } function redirect( $path ) { @header("Location: {$path}"); echo "<script language='JavaScript'>window.location='{$path}'</script>"; exit(); } class SQL{ function connect() { //$this->connection_link = mysql_connect('localhost', 'admin', 'PHac7dru'); $this->connection_link = mysql_connect('192.168.155.13', 'admin', 'PHac7dru'); mysql_query("SET NAMES 'utf8'"); mysql_query("SET NAMES 'utf8'", $this->connection_link); mysql_select_db('ergofito', $this->connection_link); } function resultSingleArr($sql, $secure = 1) { $result = mysql_query($sql, $this->connection_link); $sqlArr = mysql_fetch_array($result); mysql_free_result($result); return $secure ? $this->_secure($sqlArr) : $sqlArr; } function resultManyArr($sql, $startpt = 0, $secure = 1) { $result = mysql_query($sql, $this->connection_link); if ( mysql_num_rows($result) <= 0 ) return array(); while($row=mysql_fetch_assoc($result)) { $sqlArr[$startpt]=$row; $startpt++; } mysql_free_result($result); return $secure ? $this->_secure($sqlArr) : $sqlArr; } function _secure($data) { if (is_array($data)) { if (is_array($data[0])) { foreach ($data as $key=>$value) $data[$key] = $this->_htmlspecialchars($value); } else { $data = $this->_htmlspecialchars($data); } } else { $data = htmlspecialchars($data); } return $data; } function _htmlspecialchars($data) { if (is_array($data)) foreach ($data as $key=>$value) { $data[$key] = is_null($value) ? NULL : htmlspecialchars($value); } return $data; } } $SQL = new SQL(); $SQL->connect();
$sql="SELECT * FROM site_info where siteinfoid = 1 LIMIT 1"; $record_site_info = $SQL->resultSingleArr($sql); ?>
|