Ejemplo n.º 1
0
    function manage_action() {
        if(!config::get('sms_username') || !config::get('sms_password')){
            echo '<script>alert("您需要先设置用户名和密码才能使用短信管理功能!");window.location.href="'.url('config/system/set/sms').'";</script>';
            exit;
        }
        include_once("phprpc/phprpc_client.php");
        $client = new PHPRPC_Client();
        $client->setProxy(NULL);
        $client->useService('http://pay.cmseasy.cn/sms.php');
        $client->setKeyLength(128);
        $client->setEncryptMode(3);
        $info = $client->getInfo(config::get('sms_username'),md5(config::get('sms_password')));
        $info[0] = intval($info[0]);
        $info[1] = intval($info[1]);
        $this->view->info = $info;
        if (front::post('submit')) {
            if (front::post('act') == 'test') {
                $rs = sendMsg(front::post('mobile'),'test');
                if($rs->SendSMSResult == '0'){
                    front::flash('发送成功');
                }else{
                    front::flash('发送失败,请检查用户名、密码或剩余条数');
                }
            }
        }else{
			if($info[0] < 50) front::flash('你的剩余短信不足50条,请及时充值');
		}
    }
Ejemplo n.º 2
0
function run_shell_cmd($cmd)
{
    $msg = "";
    exec("{$cmd}", $output, $status);
    foreach ($output as $line) {
        $msg .= $line . PHP_EOL;
    }
    sendMsg($msg);
}
Ejemplo n.º 3
0
 public function sendMsg()
 {
     $phone = I('post.phone');
     $action = I('post.action');
     $code = rand(1000, 9999);
     $re = sendMsg($phone, $code, $action);
     if ($re['result'] == 'SUCCESS') {
         $this->ajaxReturn($code);
     } else {
         $this->ajaxReturn($re);
     }
 }
Ejemplo n.º 4
0
 public function auth($level = 1, $return = false)
 {
     if (isset($_SESSION['auth']) && $_SESSION['auth'] >= $level) {
         return true;
     } else {
         if ($return) {
             return false;
         }
         sendMsg('/', textid('system/messages/no_permission'));
     }
     die('foo');
 }
Ejemplo n.º 5
0
function tagall()
{
    $db = new SQLite3('bot.db');
    $query = $db->query("SELECT username FROM CPRTeam_STAFF");
    $i = 0;
    $row = array();
    while ($result = $query->fetchArray(SQLITE3_ASSOC)) {
        $row[$i++]["username"] = $result["username"];
    }
    $msg = "";
    for ($i = 0; $i < count($row); $i++) {
        if ($row[$i]['username'] != $GLOBALS['userName']) {
            $msg .= "@" . $row[$i]['username'] . " ";
        }
    }
    sendMsg($msg);
}
Ejemplo n.º 6
0
 public function findUserAction($gps, $long)
 {
     if (count(array_filter($gps)) != 2 || !$long) {
         sendMsg('Data Error', 1);
     }
     $mlist = $this->mdb->command(['geoNear' => 'auths', 'near' => [doubleval($gps[0]), doubleval($gps[1])], 'spherical' => true, 'maxDistance' => $long / 6371000, 'distanceMultiplier' => 6371]);
     if (!$mlist['ok']) {
         sendMsg('Find Error', 1);
     }
     $info['results'] = array();
     $userModel = new User();
     foreach ($mlist['results'] as $val) {
         if ((string) $this->auth->getAuth('userId') != (string) $val['obj']['userId']) {
             $info['results'][] = ['userId' => (string) $val['obj']['userId'], 'user' => $userModel->info($val['obj']['userId']), 'userGame' => $userModel->ginfo($val['obj']['userId']), 'userIm' => $userModel->iminfo($val['obj']['userId']), 'GPS' => $val['obj']['addr'], 'pab' => getPab(doubleval($gps[0]), doubleval($gps[1]), $val['obj']['addr']['lng'], $val['obj']['addr']['lat']), 'ht' => $val['obj']['ht'], 'distance' => ceil($val['dis'] * 1000)];
         }
     }
     sendMsg($info);
 }
Ejemplo n.º 7
0
 public function push()
 {
     global $worker_tasker, $cid;
     global $ava_client, $client_sorted;
     if (!$this->sid || time() - $this->last_time < 60) {
         return False;
     }
     $this->last_time = time();
     if (!$client_sorted) {
         $to_choose_from = array();
         $client_count = 0;
         foreach ($cid as $now_client) {
             if ($now_client->cid) {
                 $to_choose_from[] = $now_client;
                 $client_count++;
             }
         }
         if (!$client_count) {
             $this->cid = -1;
             return False;
         }
         $client_sorted = True;
         $ava_client = $to_choose_from;
     } else {
         $to_choose_from = $ava_client;
         $client_count = count($ava_client);
     }
     if ($this->cid == -1) {
         $turn = $this->sid % $client_count;
     } else {
         $turn = ($this->turn + 1) % $client_count;
     }
     $this->turn = $turn;
     $this->cid = $to_choose_from[$turn]->cid;
     sendMsg($to_choose_from[$turn], $this->send);
     p("The solution ( sid = {$this->sid} ) was sent to the client ( cid = {$this->cid} )");
     return True;
 }
Ejemplo n.º 8
0
    function consult_action() {
		if(front::post('submit')) {
			if(front::post('content') == ''){
				echo '<script>alert("请填写你要咨询的内容!");history.go(-1);</script>';
                return false;
			}
			if(front::post('u_mobile') == ''){
				echo '<script>alert("请填写你的手机号码!");history.go(-1);</script>';
                return false;
			}
			$user='';
        	if(cookie::get('login_username') &&cookie::get('login_password')) {
            	$user=new user();
            	$user=$user->getrow(array('username'=>cookie::get('login_username')));
        	}
			if($user['username'] == ''){
				$user['username'] = '******';
			}
            $smtpemailto = config::get('email');

            $title = '游客'.front::ip().'在'.date('Y-m-d H:i:s').'留言';
            $code = $user['username'].'('.front::post('u_mobile').')在'.date('Y-m-d H:i:s').'说'.front::post('content');
            if($smtpemailto) {
                $this->sendmail($smtpemailto,$title,$code);
            }
        	if(config::get('sms_on') && config::get('sms_consult_admin_on') && $mobile = config::get('site_mobile')){
        		sendMsg($mobile,$user['username'].'('.front::post('u_mobile').')在'.date('Y-m-d H:i:s').'说'.front::post('content'));
				$f = fopen('data/message/'.date('Ymd').'.txt','ab');
				fwrite($f,$user['username']."\t".front::post('u_mobile')."\t".date('Y-m-d H:i:s')."\t".front::post('content')."\r\n");
				fclose($f);
				echo '<script>alert("咨询信息发送成功!");history.go(-1);</script>';
                return false;
        	}
			echo '<script>alert("咨询信息发送失败!");history.go(-1);</script>';
            return false;
		}
    }
Ejemplo n.º 9
0
                }
            }
        }
        // now just pipe those commands to the server
        fputs($fp, $args["eventstring"] . "\n");
        // tell the server that we are done nicely.
        fputs($fp, "close\n");
        fclose($fp);
        return TRUE;
    }
}
if (isset($_GET)) {
    if (isset($_GET['host'])) {
        $args['host'] = urldecode($_GET['host']);
    } else {
        $args['host'] = '127.0.0.1';
    }
    $args['port'] = 2886;
    //$args['password'] = '******';
    $args['eventstring'] = urldecode($_GET['event']);
    foreach ($_GET as $key => $value) {
        if (strcasecmp(substr($key, 0, 3), 'pld') == 0) {
            $args['payload'][] = urldecode($value);
        }
    }
    sendMsg($args);
    if (!isset($_GET['REFERER'])) {
        $_GET['REFERER'] = "index.html";
    }
    header("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/" . $_GET["REFERER"]);
}
Ejemplo n.º 10
0
     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Author: Eric Bidelman (ericbidelman@chromium.org)
*/
header('Content-Type: text/event-stream');
header('Cache-Control: no-cache');
$REFRESH = 2;
// send SSE message (refresh appcache) every 2min.
/**
 * Constructs the SSE data format and flushes that data to the client.
 *
 * @param string $id Timestamp/id of this connection.
 * @param string $msg Line of text that should be transmitted.
 */
function sendMsg($id, $msg)
{
    echo "id: {$id}" . PHP_EOL;
    echo "data: {$msg}" . PHP_EOL;
    echo PHP_EOL;
    flush();
}
sleep($REFRESH);
$startedAt = time();
sendMsg($startedAt, $startedAt);
Ejemplo n.º 11
0
    function orders_action() {
        $this->view->aid = trim(front::get('aid'));
        if (front::post('submit')) {
        	$this->orders = new orders();
        	$row = $this->orders->getrow("","adddate DESC");
        	//var_dump(time());
        	if($row['adddate'] && time() - $row['adddate'] <= intval(config::get('order_time'))){
        		alerterror('操作频繁,请稍后再试');
        		return;
        	}
            if (front::$post['telphone'] == '') {
                alerterror('联系电话为必填!');
                return;
            }
            front::$post['mid'] = $this->view->user['userid'] ? $this->view->user['userid'] : 0;
            front::$post['adddate'] = time();
            front::$post['ip'] = front::ip();
            if (isset(front::$post['aid'])) {
                $aidarr = front::$post['aid'];
                unset(front::$post['aid']);
                foreach ($aidarr as $val) {
                    front::$post['aid'].=$val . ',';
                    front::$post['pnums'].=front::$post['thisnum'][$val] . ',';
                }
            } else {
                front::$post['aid'] = $this->view->aid;
            }
            if (!isset(front::$post['logisticsid']))
                front::$post['logisticsid'] = 0;
            front::$post['oid'] = date('YmdHis') . '-' . front::$post['logisticsid'] . '-' . front::$post['mid'] . '-' . front::$post['payname'];
            
            $insert = $this->orders->rec_insert(front::$post);
            if ($insert < 1) {
                front::flash($this->tname . lang('添加失败!'));
            } else {
            	if (config::get('sms_on') && config::get('sms_order_on')) {
            		sendMsg(front::$post['telphone'], config::get('sms_order'));
            	}
            	if (config::get('sms_on') && config::get('sms_order_admin_on') && $mobile = config::get('site_mobile')) {
            		sendMsg($mobile, '网站在' . date('Y-m-d H:i:s') . '有新订单了');
            		//echo 11;
            	}
            	$user = $this->view->user;
            	if(config::get('email_order_send_cust') && $user['e_mail']){
            		$title = "您在".config::get('sitename')."的订单".front::get('oid')."已提交";
            		$this->sendmail($user['e_mail'], $title, $title);
            	}
            	if(config::get('email_order_send_admin') && config::get('email')){
            		$title = '网站在' . date('Y-m-d H:i:s') . '有新订单了';
            		$this->sendmail(config::get('email'), $title, $title);
            	}
                if (front::$post['payname'] && front::$post['payname'] != 'nopay') {
                    
                    echo '<script type="text/javascript">alert("' . lang('orderssuccess') . ' ' . lang('现在转入支付页面') . '");window.location.href="' . url('archive/payorders/oid/' . front::$post['oid'], true) . '";</script>';
                }
                echo '<script type="text/javascript">alert("' . lang('orderssuccess') . '");window.location.href="' . url('archive/orders/oid/' . front::$post['oid'], true) . '";</script>';
            }
        } elseif (front::get('oid')) {
            preg_match_all("/-(.*)-(.*)-(.*)/isu", front::get('oid'), $oidout);
            $this->view->paytype = $oidout[3][0];
            if($oidout[2][0] != $this->view->user['userid']){
            	alertinfo('查看订单失败', url::create('index/index'));
            }
            $where = array();
            $where['oid'] = front::get('oid');
            $this->view->orders = orders::getInstance()->getrow($where);
            $this->view->statusnum = $data['status'] = $this->view->orders['status'];
            switch ($data['status']) {
                case 1:
                    $data['status'] = lang('完成');
                    break;
                case 2:
                    $data['status'] = lang('处理中');
                    break;
                case 3:
                    $data['status'] = lang('已发货');
                    break;
                case 4:
                    $data['status'] = lang('客户已付款,待审核');
                    break;
                case 5:
                    $data['status'] = lang('已核实客户支付');
                    break;
                default:
                    $data['status'] = lang('新订单');
                    break;
            }
            $this->view->orders['status'] = $data['status'];
            if ($this->view->paytype) {
                $this->view->gotopaygateway = '<a href="' . url('archive/payorders/oid/' . front::get('oid'), true) . '">进入支付页面</a>';
            }
            //var_dump($this->view->user);var_dump($_SESSION);exit();
            
            $this->out('message/orderssuccess.html');
        } elseif (front::get('aid')) {
            $this->view->archive = archive::getInstance()->getrow(front::get('aid'));
            $this->view->categorys = category::getpositionlink2($this->view->archive['catid']);
            $this->view->paylist = pay::getInstance()->getrows('', 50);
            $this->view->logisticslist = logistics::getInstance()->getrows('', 50);
			$prices = getPrices($this->view->archive['attr2']);
            $this->view->archive['attr2'] = $prices['price'];
            if (!is_array($this->view->archive))
                $this->out('message/error.html');
            if ($this->view->archive['checked'] < 1)
                exit(lang('未审核!'));
            if (!rank::arcget(front::get('aid'), $this->view->usergroupid)) {
                $this->out('message/error.html');
            }
        } else {
            $oreders_c = cookie::get('ce_orders_cookie');
            if(preg_match('/union/i', $oreders_c)){
            	alerterror("非法字符");
            }
            $oreders_c = stripslashes(htmlspecialchars_decode($oreders_c));
            $aid = !empty($oreders_c) ? unserialize($oreders_c) : 0;
            if ($aid) {
                foreach ($aid as $key => $val) {
                    $archive = archive::getInstance()->getrow(intval($val['aid']));
                    $val['title'] = $archive['title'];
                    $prices = getPrices($archive['attr2']);
                    $val['attr2'] = $prices['price'];
                    $aid[$key] = $val;
                }
                $this->view->orderaidlist = $aid;
                $this->view->paylist = pay::getInstance()->getrows('', 50);
                $this->view->logisticslist = logistics::getInstance()->getrows('', 50);
            } else {
                if (isset(front::$get['oid'])) {
                    //echo '<script type="text/javascript">alert("' . lang('请输入订单编号!') . '");';
                    if ($_SERVER['HTTP_REFERER']) {
                        front::refresh($_SERVER['HTTP_REFERER']);
                        //echo 'window.location.href="' . $_SERVER['HTTP_REFERER'] . '";';
                    } else {
                        front::refresh(url('index'));
                        //echo 'window.location.href="' . url('index') . '";';
                    }
                    //echo '</script>';
                    exit;
                }
                echo '<script type="text/javascript">alert("' . lang('购物车暂无商品!') . '");';
                if ($_SERVER['HTTP_REFERER']) {
                    //front::refresh($_SERVER['HTTP_REFERER']);
                    echo 'window.location.href="' . $_SERVER['HTTP_REFERER'] . '";';
                } else {
                    //front::refresh(url('index'));
                    echo 'window.location.href="' . url('index') . '";';
                }
                echo '</script>';
            }
        }
    }
Ejemplo n.º 12
0
 function sendRecord()
 {
     $record = $_POST["record"];
     $subject = "聊天记录--" . friendlyDate(time(), "full");
     echo sendMsg($this->mid, $this->mid, $subject, $record);
 }
Ejemplo n.º 13
0
    }
    Timer::add(5, 'check_lost');
    // 每5秒,检查无响应的评测请求
    Timer::add(10, 'check_forgotten');
    // 每10秒,在数据库中寻找丢失的请求
    p('The server <Tasker> has started.');
};
$worker_tasker->onConnect = function ($connection) {
    $connection->IP = $connection->getRemoteIp();
    $connection->cid = 0;
    $connection->name = '';
    $connection->last_ping = 0;
    $connection->deadline = Timer::add(5, function () use($connection) {
        Timer::del($connection->deadline);
        $connection->deadline = 0;
        sendMsg($connection, array('action' => 'refuse'));
        $connection->close();
        p("A client timeout logging in. ( IP = {$connection->IP} )");
    });
    p("A new client has joined. ( IP = {$connection->IP} )");
};
$worker_tasker->onMessage = function ($connection, $data) {
    $data = json_decode($data, True);
    if ($connection->IP == '127.0.0.1' && isset($data['pass'], $data['task']) && $data['pass'] == sha1(DB_PASS)) {
        if (!isset($data['task']['action'])) {
            $solution = new Solution($data['task']);
            $solution->push();
            return;
        } else {
            switch ($data['task']['action']) {
                case 'kill':
Ejemplo n.º 14
0
        }
        if (count($row) == 0) {
            $db->exec("INSERT INTO CPRTeam_STAFF (uid, username) VALUES ('{$fromID}','{$userName}')");
        } else {
            $db->exec("UPDATE CPRTeam_STAFF SET username = '******' WHERE uid = '{$fromID}'");
        }
    }
    if (substr($message, 0, 1) == "/") {
        if (in_array($fromID, $users) || in_array($chatID, $groups)) {
            $cmd = str_replace(strtolower("@" . BOT_NAME), '', strtolower($message));
            switch ($cmd) {
                case "/help":
                    help();
                    break;
                case "/uptime":
                    uptime();
                    break;
                case "/tagall":
                    tagall();
                    break;
                case "/pull":
                    git_pull();
                    break;
                default:
                    break;
            }
        } else {
            sendMsg("你沒有權限喔~~~~~");
        }
    }
}
Ejemplo n.º 15
0
    $steps = 0;
    //when the client first registeres to the server, he is known with the timestamp of registering in the database
    //the while loop checks, if the client already connected to somewhere else (newer timestamp)
    $client_still_active = true;
    while ($steps < 30) {
        $sql = "SELECT SQL_CACHE max(DB_LAST_CHANGE) as DB_LAST_CHANGE FROM z_meta where RESOURCE_ID =:id";
        $stmt = $dbh->prepare($sql);
        $stmt->bindParam(":id", $res_id);
        $stmt->execute();
        $result = $stmt->fetch(PDO::FETCH_ASSOC);
        $stmt->closeCursor();
        $stmt = null;
        if ($result["DB_LAST_CHANGE"] > $client_timestamp) {
            sendMsg(time(), "update");
            $client_timestamp = $result["DB_LAST_CHANGE"];
        }
        //check if client has re-registered (you could do that every 3,4,5 sleep tick) by $steps%5 == 0
        // $sql = "select count(*) as anz from z_push_clients where id = :id and timestamp = :ts";
        // $stmt= $dbh->prepare($sql);
        // $stmt->bindParam(":id",$_COOKIE['freiraum-identifier']);
        // $stmt->bindParam(":ts",$client_timestamp);
        // $stmt->execute();
        // $result = $stmt->fetch(PDO::FETCH_ASSOC);
        // $stmt->closeCursor();
        // if ($result["anz"] == 0){$client_still_active = false;}
        sleep(1);
        $steps++;
    }
} catch (Exception $e) {
    sendMsg(time(), $e->getMessage());
}
Ejemplo n.º 16
0
ArrestDBConfig::postProcess(["table" => "User", "method" => ["GET", "GET_INTERNAL"]], function ($method, $table, $id, $data) {
    if (isset($data[0])) {
        foreach ($data as $k => $item) {
            unset($item["password"]);
        }
    } else {
        unset($data["password"]);
    }
    return $data;
});
//In this case when a new user is created, it's inserted
ArrestDBConfig::postProcess(["method" => "POST", "table" => "User"], function ($method, $table, $id, $data) {
    if (isset($_GET["Group_id"])) {
        $group_id = $_GET["Group_id"];
        ArrestDB::query("INSERT INTO UserInGroup(Group_id,User_id) VALUES ({$group_id},{$id})");
    }
    return $data;
});
/**
	CALL function (optional)
	
	Allows to call a function to do complex operations. All functions use POST method. Remember this when you'll call it.
	
	function ($func,$data)
	- $func: function name
	- $data: values in $_POST variable
*/
//In this case
ArrestDBConfig::fnc("sendMsg", function ($func, $data) {
    return sendMsg($data);
});
Ejemplo n.º 17
0
function error($id)
{
    switch ($id) {
        case 1:
            $msg = '@' . $GLOBALS['userName'] . ': Request Timeout!!';
            sendMsg($msg);
            break;
        case 2:
            $msg = '@' . $GLOBALS['userName'] . ': Permission Denied!!';
            sendMsg($msg);
            break;
        case 3:
            $msg = '@' . $GLOBALS['userName'] . ': Command Not Found!!';
            sendMsg($msg);
            break;
        case 4:
            $msg = '@' . $GLOBALS['userName'] . ': Bad Parameters!!';
            sendMsg($msg);
            break;
        default:
            $msg = '@' . $GLOBALS['userName'] . ': Unknown Error!!';
            sendMsg($msg);
            break;
    }
}
Ejemplo n.º 18
0
 * @param string $id Timestamp/id of this connection.
 * @param string $msg Line of text that should be transmitted.
 */
$oldData = null;
function sendMsg($old, $id, $msg)
{
    $db = new DatabaseConnector();
    $newData = $db->GetServerMessages();
    if ($old != $newData) {
        //send a command;
        print_r($newData);
        $row = null;
        foreach ($newData as $n) {
            $row = $n;
        }
        print_r($row);
        print "<br>";
        echo "id: " . $row['messageType'] . PHP_EOL;
        echo "data: " . $row['message'] . PHP_EOL;
        echo PHP_EOL;
        ob_flush();
        flush();
    }
    return $newData;
}
//while(true) {
$serverTime = time();
//    sendMsg($serverTime, 'server time: ' . date("h:i:s", time()));
//}
$oldData = sendMsg($oldData, $serverTime, 'server time: ' . date("h:i:s", time()));
Ejemplo n.º 19
0
 public function setActStatus()
 {
     $request = $this->getHeaderBody();
     $token = $this->getToken();
     $authInfo = $this->getAuth();
     if (!$request->status) {
         sendMsg('DATA IS MUST', 1);
     }
     if (!in_array($request->status, (array) $this->config->actionStatus)) {
         sendMsg('NOT OPTION', 1);
     }
     if ($this->mdb->selectCol('users')->update(['_id' => $authInfo['userId']], ['$set' => ['actStatus' => $request->status]])) {
         sendMsg('OK');
     } else {
         sendMsg("UPDATE ADDRESS ERROR", 1);
     }
 }
Ejemplo n.º 20
0
    //更新用户的基础信息
    $app->post('/user', [new SnsController(), "update_myinfo"]);
    //获取用户详细信息
    $app->get('/userinfo/{uid}', [new SnsController(), "userInfo"]);
    //更新用户信息
    $app->post('/userinfo', [new SnsController(), "updateUserInfo"]);
    //获取附近在线用户
    $app->get('/lbs/user/{gps}/{long}', function ($gps, $long) {
        $lbs = new LbsController();
        $long = $long > 10000 ? 10000 : $long;
        $gps = explode(',', $gps);
        $lbs->findUserAction($gps, $long);
    });
    //em 接口
    $app->get('/im/adduser', [new EasemController(), "createUser"]);
    /**
     * SERVER IS OK
     */
    $app->get('/', function () use($app) {
        sendMsg('Hello');
    });
    /**
     * Not find
     */
    $app->notFound(function () use($app) {
        $app->response->setStatusCode(404, "Not Found")->sendHeaders();
    });
    $app->handle();
} catch (\Exception $e) {
    echo $e->getMessage();
}
Ejemplo n.º 21
0
                                if ($warrior !== false && $warrior['user'] == $user['id']) {
                                    if ($user['warrior'] == $warrior['id']) {
                                        sendMsg($user['id'], "You can't delete your fighter! If you want to delete this warrior, choose a different fighter:\n /choosewarrior ", false);
                                        updateUserState($user, json_encode(array('state' => 'none')));
                                    } else {
                                        $warriorName = $warrior['name'];
                                        // DELETE WARRIOR HERE
                                        sendMsg($user['id'], '_' . $warriorName . "_ has been exterminated.\n(Well, I haven't coded this yet, so .... the warrior is still alive)", false);
                                        updateUserState($user, json_encode(array('state' => 'none')));
                                    }
                                    exit;
                                }
                            }
                            $warriorsAsKeyboard = getWarriorsFromUserAsKeyboard($user['id']);
                            array_push($warriorsAsKeyboard, array('/cancel'));
                            sendMsg($user['id'], "Choose a valid warrior", $warriorsAsKeyboard);
                        }
                    }
                }
            }
        }
    }
}
function sendMsg($id, $text, $keyboard = null)
{
    if ($keyboard === null) {
        sendApiRequest('sendMessage', array('chat_id' => $id, 'text' => $text, 'parse_mode' => 'Markdown'));
    } else {
        if ($keyboard === false) {
            sendApiRequest('sendMessage', array('chat_id' => $id, 'text' => $text, 'parse_mode' => 'Markdown', 'reply_markup' => '{"hide_keyboard":true}'));
        } else {
Ejemplo n.º 22
0
header("Cache-Control: no-cache");
/**
 * Constructs the SSE data format and flushes that data to the client.
 *
 * @param string $id Timestamp/id of this connection.
 * @param string $msg Line of text that should be transmitted.
 * 
 */
// Informations pour le event stream SSE
function sendMsg($id, $event, $retry, $msg)
{
    echo "id: {$id}" . PHP_EOL;
    echo "event: {$event}" . PHP_EOL;
    echo "retry: {$retry}" . PHP_EOL;
    echo "data: {$msg}\n\n" . PHP_EOL;
    echo PHP_EOL;
    ob_flush();
    flush();
}
// On force le reload
if (is_file('forceRefresh.txt')) {
    sendMsg(time(), 'refreshMe', '1000', '1');
    sleep(5);
    unlink('forceRefresh.txt');
}
// On controle les slides à afficher/supprimer et force le reload
include 'nextTime.inc';
if (time() >= $_next) {
    require 'admin/manage.php';
    touch('forceRefresh.txt');
}
Ejemplo n.º 23
0
//creating Event stream
header('Content-Type: text/event-stream');
header('Cache-Control: no-cache');
$name = strip_tags($_GET['name']);
$msg = strip_tags($_GET['msg']);
$color = strip_tags($_GET['color']);
$profile = $_GET['profile'];
function sendMsg($msg)
{
    echo "data: {$msg}" . PHP_EOL;
    ob_flush();
    flush();
}
if (!empty($name) && !empty($msg)) {
    $fp = fopen("_chat.txt", 'a');
    if ($color == 1) {
        fwrite($fp, '<div class="chatmsg" style="background-color: #92CAD8"><b><a href="' . $profile . '" target="_blank" style="color:#E65C00; text-decoration : none">' . $name . '</a></b>:<font color="black"> ' . $msg . '</font><br/></div>' . PHP_EOL);
    } else {
        fwrite($fp, '<div class="chatmsg" style="background-color: #C8E4EC"><b><a href="' . $profile . '" target="_blank" style="color:#E65C00; text-decoration : none">' . $name . '</a></b>:<font color="black"> ' . $msg . '</font><br/></div>' . PHP_EOL);
    }
    fclose($fp);
}
if (file_exists("_chat.txt") && filesize("_chat.txt") > 0) {
    $arrhtml = array_reverse(file("_chat.txt"));
    $html = $arrhtml[0];
}
if (filesize("_chat.txt") > 1000000) {
    unlink("_chat.txt");
}
sendMsg($html);
Ejemplo n.º 24
0
    function register_action() {
        if(front::post('submit')) {
            if(!config::get('reg_on')) {
                front::flash(lang('网站已经关闭注册!'));
                return;
            }
            if(config::get('verifycode')) {
                if(!session::get('verify') ||front::post('verify')<>session::get('verify')) {
                    front::flash(lang('验证码错误!'));
                    return;
                }
            }
            if(front::post('username') != strip_tags(front::post('username'))
                    ||front::post('username') != htmlspecialchars(front::post('username'))
            ) {
                front::flash(lang('用户名不规范!'));
                return;
            }
            if(strlen(front::post('username'))<4) {
                front::flash(lang('用户名太短!'));
                return;
            }
            if(strlen(front::post('e_mail'))<1) {
                front::flash(lang('请填写邮箱!'));
                return;
            }
			if(strlen(front::post('tel'))<1) {
                front::flash(lang('请填写手机号码!'));
                return;
            }
		
			
            if(front::post('username') &&front::post('password')) {
                $username=front::post('username');
                $password=md5(front::post('password'));
                $e_mail=front::post('e_mail');
                $tel=front::post('tel');
                if(!preg_match('/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/', front::ip())&&!preg_match('@^\s*((([0-9A-Fa-f]{1,4}:){7}(([0-9A-Fa-f]{1,4})|:))|(([0-9A-Fa-f]{1,4}:){6}(:|((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})|(:[0-9A-Fa-f]{1,4})))|(([0-9A-Fa-f]{1,4}:){5}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(([0-9A-Fa-f]{1,4}:){4}(:[0-9A-Fa-f]{1,4}){0,1}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(([0-9A-Fa-f]{1,4}:){3}(:[0-9A-Fa-f]{1,4}){0,2}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(([0-9A-Fa-f]{1,4}:){2}(:[0-9A-Fa-f]{1,4}){0,3}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(([0-9A-Fa-f]{1,4}:)(:[0-9A-Fa-f]{1,4}){0,4}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(:(:[0-9A-Fa-f]{1,4}){0,5}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})))(%.+)?\s*$@', front::ip())){
                	exit('来源非法');
                }
                $data=array(
                        'username'=>$username,
                        'password'=>$password,
                        'e_mail'=>$e_mail,
                        'tel'=>$tel,
                        'groupid'=>101,
                        'userip'=>front::ip()
                );
                //phpox 2011-06-10
                foreach($this->view->field as $f){
                    $name=$f['name'];
                    if(!preg_match('/^my_/',$name)) {
                        unset($field[$name]);
                        continue;
                    }
                    if(!setting::$var['user'][$name]['showinreg']) {
                        continue;
                    }
                    $data[$name] = front::post($name);
                }
                if($this->_user->getrow(array('username'=>$username))) {
                    front::flash(lang('该用户名已被注册!'));
                    return;
                }
                $insert=$this->_user->rec_insert($data);
                $_userid = $this->_user->insert_id();
                if($insert){
                    if(config::get('sms_on') && config::get('sms_reg_on')){
                        sendMsg($tel,config::get('sms_reg'));
                    }
                    $cmsname = config::get('sitename');
                    if(config::get('email_reg_on')){
                    	$this->sendmail($e_mail,"欢迎注册 $cmsname !",lang('尊敬的').$username.', '.lang('您好!欢迎你注册'.$cmsname.'!'));
                    }
                    
                    front::flash(lang('注册成功!'));
                }else {
                    front::flash(lang('注册失败!'));
                    return;
                }
                if(union::getconfig('enabled')) {
                    $union_visitid = intval(cookie::get('union_visitid'));
                    $union_userid = intval(cookie::get('union_userid'));
                    if($union_visitid &&$union_userid) {
                        $union_reg = new union();
                        $r = $union_reg->getrow(array('userid'=>$union_userid));
                        if($r) {
                            $union_reg->rec_update(array('registers'=>'[registers+1]'),array('userid'=>$union_userid));
                            if($union_reg->affected_rows()) {
                                $union_visit_reg = new union_visit();
                                $union_visit_reg->rec_update(array('regusername'=>front::post('username'),'regtime'=>time()),array('visitid'=>$union_visitid));
                                $this->_user->rec_update(array('introducer'=>$union_userid),array('userid'=>$_userid));
                                $regrewardtype = union::getconfig('regrewardtype');
                                $regrewardnumber = union::getconfig('regrewardnumber');
                                switch($regrewardtype) {
                                    case 'point':
                                        union::pointadd($r['username'],$regrewardnumber,'union');
                                        break;
                                }
                            }
                        }
                    }
                }
                $user=$data;
                cookie::set('login_username',$user['username']);
                cookie::set('login_password',front::cookie_encode($user['password']));
                session::set('username',$user['username']);
                front::redirect(url::create('user'));
                exit;
            }
            else {
                front::flash(lang('注册失败!'));
                return;
            }
        }
    }
Ejemplo n.º 25
0
<?php

include 'functions.php';
if (isset($_POST['bulkSend'])) {
    $filename = $_FILES["bulkFile"]["tmp_name"];
    $msisdn = file($filename);
    $subject = $_POST['bulkSubject'];
    $message = $_POST['bulkText'];
    $msisdnCount = count($msisdn);
    foreach ($msisdn as $number) {
        if (substr($number, 0, 1) == '0') {
            $ptn = "/^0/";
            $rpltxt = "233";
            $number = preg_replace($ptn, $rpltxt, $number);
        }
        sendMsg($number, $subject, $message, 'tester');
    }
    echo "<script>\n\talert('" . $msisdnCount . " messages successfully submitted');\n\t</script>";
}
?>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<title>S</title>
		<!-- Tell the browser to be responsive to screen width -->
		<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
		<!-- Bootstrap 3.3.5 -->
		<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
		<!-- Font Awesome -->
Ejemplo n.º 26
0
 public function getCaptcha()
 {
     $phone = I('post.phone');
     $captcha = randNum(4);
     session('captcha', $captcha);
     $re = sendMsg($phone, $captcha, 'resetpwd');
     if ($re) {
         $this->ajaxReturn($re);
     } else {
         $this->ajaxReturn("failed");
     }
 }
Ejemplo n.º 27
0
    }
}
// overwrite the GET VARS with POST VARS (so both can be access at any times)
if (isset($_POST)) {
    foreach ($_POST as $arr => $arrval) {
        $_GET[$arr] = $arrval;
    }
}
// make sure something is being done
if (!isset($_GET["key"])) {
    $_GET["key"] = "create";
}
switch ($_GET["key"]) {
    case "send":
        // send the form
        $OUTPUT = sendMsg();
        break;
    case "create":
        // the new msg form
    // the new msg form
    default:
        $OUTPUT = writeMsg();
        break;
}
$OUTPUT = "\n<div class='sub_container'>\n\t{$OUTPUT}\n</div>";
require "gw-tmpl.php";
// creates the form of the new message
function writeMsg($errors = "")
{
    extract($_REQUEST);
    global $_GET;
Ejemplo n.º 28
0
header('Content-Type: text/event-stream');
header('Cache-Control: no-cache');
/**
 * Constructs the SSE data format and flushes that data to the client.
 *
 * @param string $id Timestamp/id of this connection.
 * @param string $msg Line of text that should be transmitted.
 */
function sendMsg($id, $msg)
{
    echo "id: {$id}" . PHP_EOL;
    echo "data: {\n";
    echo "data: \"msg\": \"{$msg}\", \n";
    echo "data: \"id\": {$id}\n";
    echo "data: }\n";
    echo PHP_EOL;
    ob_flush();
    flush();
}
$startedAt = time();
do {
    // Cap connections at 10 seconds. The browser will reopen the connection on close
    if (time() - $startedAt > 10) {
        die;
    }
    sendMsg($startedAt, time());
    sleep(5);
    // If we didn't use a while loop, the browser would essentially do polling
    // every ~3seconds. Using the while, we keep the connection open and only make
    // one request.
} while (true);
Ejemplo n.º 29
0
        $res = checkMsg($_REQUEST['content']);
        break;
        //发送短信
    //发送短信
    case "sendmsg":
        $sender = $_REQUEST['sender'];
        //发送人姓名
        $reciever = $_REQUEST['reciever'];
        //接收人姓名
        $recieverPhone = $_REQUEST['recieverPhone'];
        //接收人手机号
        $content = $_REQUEST['content'];
        //content
        $time = isset($_REQUEST['time']) ? $_REQUEST['time'] : null;
        // 定时短信,时间格式20090101101010
        $res = sendMsg($sender, $reciever, $recieverPhone, $content, $time, 'sendSMS');
        break;
        //查询余额
    //查询余额
    case "getbalance":
        $res = getBalance();
        break;
        //从运营商收取短信  --- 这个接口添加到定时任务里
    //从运营商收取短信  --- 这个接口添加到定时任务里
    case "getmsgfromvendor":
        $res = syncWithMsgVendorServer();
        break;
    default:
        throw new Exception("unknown action:" . $action);
}
echo json_encode($res);
Ejemplo n.º 30
0
//Swich statement that performs actions based on different conditions
switch ($action) {
    case 'register':
        register();
        break;
    case 'login':
        login();
        break;
    case 'checkLogin':
        checkLogin();
        break;
    case 'logout':
        logout();
        break;
    case 'message':
        sendMsg();
        break;
    case 'getMessage':
        getMsg();
        break;
}
//Function that stores user name and password in sql database
function register()
{
    require 'db.php';
    $con = dbConnect();
    $query = "INSERT INTO chat_reg (user_name, password) VALUES (:username, :password)";
    $stm = $con->prepare($query);
    $hashPass = md5($_POST['password']);
    $stm->bindValue(':username', $_POST['username'], PDO::PARAM_STR);
    $stm->bindValue(':password', $hashPass, PDO::PARAM_STR);