/** * Get Invitation List from database **/ function getInvitationList() { // Require DB Config require_once "../lib/picasa/config.php"; // Records Array $allRec = array(); // Create an instance of ADO connection object $conn = new COM("ADODB.Connection") or die("Cannot start ADO"); // Define connection string, specify database driver $connStr = "PROVIDER=SQLOLEDB;SERVER=" . $server . ";UID=" . $username . ";PWD=" . $passwd . ";DATABASE=" . $db; $conn->open($connStr); //Open the connection to the database //SQL statement that will query the database $query = "SELECT * FROM tbl_picasa"; //execute SQL statement and return records $rs = $conn->execute($query); $num_columns = $rs->Fields->Count(); for ($i = 0; $i < $num_columns; $i++) { $fld[$i] = $rs->Fields($i); } while (!$rs->EOF) { $rec = array(); for ($i = 0; $i < $num_columns; $i++) { array_push($rec, $fld[$i]->value); } array_push($allRec, $rec); $rs->MoveNext(); //move on to the next record } //close the connection and recordset objects freeing up resources $rs->Close(); $conn->Close(); $rs = null; $conn = null; return $allRec; }
<?php $myServer = "localhost"; $myUser = "******"; $myPass = "******"; $myDB = "hams_BlissDB"; //create an instance of the ADO connection object $conn = new COM("ADODB.Connection") or die("Cannot start ADO"); //define connection string, specify database driver $connStr = "PROVIDER=SQLOLEDB;SERVER=" . $myServer . ";UID=" . $myUser . ";PWD=" . $myPass . ";DATABASE=" . $myDB; $conn->open($connStr); //Open the connection to the database //declare the SQL statement that will query the database $query = "SELECT * FROM Order_from_HAMS"; //execute the SQL statement and return records $rs = $conn->execute($query); $num_columns = $rs->Fields->Count(); echo $num_columns . "<br>"; for ($i = 0; $i < $num_columns; $i++) { $fld[$i] = $rs->Fields($i); } echo "<table>"; while (!$rs->EOF) { echo "<tr>"; for ($i = 0; $i < $num_columns; $i++) { echo "<td>" . $fld[$i]->value . "</td>"; } echo "</tr>"; $rs->MoveNext(); //move on to the next record }
<?php $myServer = "192.168.10.212"; $myUser = "******"; $myPass = "******"; $myDB = "IABAS2014_ACS_set"; //create an instance of the ADO connection object $conn = new COM ("ADODB.Connection") or die("Cannot start ADO"); //define connection string, specify database driver $connStr = "PROVIDER=SQLOLEDB;SERVER=".$myServer.";UID=".$myUser.";PWD=".$myPass.";DATABASE=".$myDB; $conn->open($connStr); //Open the connection to the database //declare the SQL statement that will query the database $query = "SELECT * FROM CANDIDATOS"; //execute the SQL statement and return records $rs = $conn->execute($query); $num_columns = $rs->Fields->Count(); echo $num_columns . "<br>"; for ($i=0; $i < $num_columns; $i++) { $fld[$i] = $rs->Fields($i); } echo "<table>"; while (!$rs->EOF) //carry on looping through while there are records
function sendsms($mob, $content) { //add by whh 2015-1-27 file_put_contents('/tmp/debug', date('m-d H:i:s') . " " . print_r($mob, true) . "\n", FILE_APPEND); file_put_contents('/tmp/debug', date('m-d H:i:s') . " " . print_r($content, true) . "\n", FILE_APPEND); $server_url = 'http://3tong.net/services/sms?wsdl'; $user_name = 'dh21944'; $password = '******'; include_once dirname(__FILE__) . "/sms/dahan/class.dahansms.php"; $dahan = new dahanClient(); $dahan->Client($server_url, $user_name, $password); $res = $dahan->dahanSMS($mob, $content); //发送短信结束 以下是插入数据库 $data['telephone'] = $mob; $data['send_content'] = $content; $data['back_result'] = $res; $data['send_time'] = date('Y-m-d H:i:s', time()); M('sendsms')->add($data); return true; include_once dirname(__FILE__) . "/sms/dream/class.dream.php"; $dream = new dream(); $res = $dream->send($mob, $content); file_put_contents('/tmp/debug', date('m-d H:i:s') . " " . print_r($res, true) . "\n", FILE_APPEND); return true; $msgconfig = FS("Webconfig/msgconfig"); $type = $msgconfig['sms']['type']; // type=0 吉信通短信接口 type=1 漫道短信接口 type=2 亿美短信接口 if ($type == 0) { $uid = $msgconfig['sms']['user1']; //分配给你的账号 $pwd = $msgconfig['sms']['pass1']; //密码 $mob = $mob; //发送号码用逗号分隔 if (PATH_SEPARATOR == ':') { //如果是Linux系统,则执行linux短息接口 $url = "http://service.winic.org:8009/sys_port/gateway/?id=%s&pwd=%s&to=%s&content=%s&time="; $id = urlencode($uid); $pwd = urlencode($pwd); $to = urlencode($mob); $content = iconv("UTF-8", "GB2312", $content); $rurl = sprintf($url, $id, $pwd, $to, $content); $ch = curl_init(); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_URL, $rurl); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $result = curl_exec($ch); curl_close($ch); $status = substr($result, 0, 3); if ($status === "000") { return true; } else { return false; } } else { $content = urlencode(auto_charset($content, "utf-8", 'gbk')); //短信内容 $sendurl = "http://service.winic.org:8009/sys_port/gateway/?"; $sdata = "id=" . $uid . "&pwd=" . $pwd . "&to=" . $mob . "&content=" . $content . "&time="; $xhr = new COM("MSXML2.XMLHTTP"); $xhr->open("POST", $sendurl, false); $xhr->setRequestHeader("Content-type:", "text/xml;charset=GB2312"); $xhr->setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); $xhr->send($sdata); $data = explode("/", $xhr->responseText); if ($data[0] == "000") { return true; } else { return false; } } } elseif ($type == 1) { /////////////////////////////////////////漫道短信接口 开始///////////////////////////////////////////////////////////// //如果您的系统是utf-8,请转成GB2312 后,再提交、 $flag = 0; //要post的数据 $argv = array('sn' => $msgconfig['sms']['user2'], 'pwd' => $msgconfig['sms']['pass2'], 'mobile' => $mob, 'content' => iconv("UTF-8", "gb2312//IGNORE", $content), 'ext' => '', 'stime' => '', 'rrid' => ''); //构造要post的字符串 foreach ($argv as $key => $value) { if ($flag != 0) { $params .= "&"; $flag = 1; } $params .= $key . "="; $params .= urlencode($value); $flag = 1; } $length = strlen($params); //创建socket连接 $fp = fsockopen("sdk2.zucp.net", 8060, $errno, $errstr, 10) or exit($errstr . "--->" . $errno); //构造post请求的头 $header = "POST /webservice.asmx/mt HTTP/1.1\r\n"; $header .= "Host:sdk2.zucp.net\r\n"; $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; $header .= "Content-Length: " . $length . "\r\n"; $header .= "Connection: Close\r\n\r\n"; //添加post的字符串 $header .= $params . "\r\n"; //发送post的数据 fputs($fp, $header); $inheader = 1; while (!feof($fp)) { $line = fgets($fp, 1024); //去除请求包的头只显示页面的返回数据 if ($inheader && ($line == "\n" || $line == "\r\n")) { $inheader = 0; } if ($inheader == 0) { // echo $line; } } $line = str_replace("\n<string xmlns=\"http://tempuri.org/\">", "", $line); $line = str_replace("</string>\n", "", $line); $result = explode("-", $line); if (count($result) > 1) { return false; } else { return true; } /////////////////////////////////////////漫道短信接口 结束///////////////////////////////////////////////////////////// } elseif ($type == 2) { ////////////////////////////////////////////////////////亿美短信接口 开始///////////////////////////////////////////// $uid = $msgconfig['sms']['user3']; //分配给你的账号 $pwd = $msgconfig['sms']['pass3']; //密码 $mob = $mob; //发送号码用逗号分隔 $content = urlencode(auto_charset($content, "utf-8", 'gbk')); //短信内容 $sendurl = "http://sdk229ws.eucp.b2m.cn:8080/sdkproxy/sendsms.action?"; $sendurl .= 'cdkey=' . $serialNumber . '&password='******'&phone=' . $mob . '&message=' . $content . '&addserial='; $d = @file_get_contents($sendurl, false); preg_match_all('/ <response> (.*)<\\/response>/isU', $d, $arr); foreach ($arr[1] as $k => $v) { preg_match_all('# <error>(.*)</error> #isU', $v, $ar[$k]); $data[] = $ar[$k][1]; } if ($data[0][0] == "0") { return true; } else { return false; } ////////////////////////////////////////////////////////亿美短信接口 结束///////////////////////////////////////////// } else { return false; } }