private function calc_auth_key($u, $ip = false)
 {
     if (!$ip) {
         $ip = getIp();
     }
     return substr(md5($u['username'] . $u['password'] . $ip), 10);
 }
Пример #2
0
 /**
  * 注册商城会员
  *
  * @param	array $param 会员信息
  * @return	array 数组格式的返回结果
  */
 public function addMember($param)
 {
     if (empty($param)) {
         return false;
     }
     $member_info = array();
     $member_info['member_id'] = $param['member_id'];
     $member_info['member_name'] = trim($param['member_name']);
     $member_info['member_passwd'] = md5(trim($param['member_passwd']));
     $member_info['member_email'] = trim($param['member_email']);
     $member_info['member_mobile'] = trim($param['member_mobile']);
     $member_info['member_time'] = time();
     $member_info['member_login_time'] = $member_info['member_time'];
     $member_info['member_old_login_time'] = $member_info['member_time'];
     $member_info['member_login_ip'] = getIp();
     $member_info['member_old_login_ip'] = $member_info['member_login_ip'];
     $member_info['member_truename'] = $param['member_truename'];
     $member_info['member_qq'] = $param['member_qq'];
     $member_info['member_sex'] = $param['member_sex'];
     $member_info['member_avatar'] = $param['member_avatar'];
     $member_info['member_qqopenid'] = $param['member_qqopenid'];
     $member_info['member_qqinfo'] = $param['member_qqinfo'];
     $member_info['member_sinaopenid'] = $param['member_sinaopenid'];
     $member_info['member_sinainfo'] = $param['member_sinainfo'];
     $result = Db::insert('member', $member_info);
     if ($result) {
         return Db::getLastId();
     } else {
         return false;
     }
 }
Пример #3
0
 /**
  * add chat msg
  *
  * @param
  * @return array
  */
 public function addMsg($msg)
 {
     $msg['f_ip'] = getIp();
     $msg['r_state'] = '1';
     //state:1--read ,2--unread
     $msg['add_time'] = time();
     $m_id = $this->table('chat_msg')->insert($msg);
     if ($m_id > 0) {
         $msg['m_id'] = $m_id;
         unset($msg['r_state']);
         $this->table('chat_log')->insert($msg);
         $msg['m_id'] = $m_id;
         $msg['add_time'] = date('Y-m-d H:i:s', $msg['add_time']);
         $t_msg = $msg['t_msg'];
         $goods_id = 0;
         $goods_info = array();
         $pattern = '#' . SHOP_SITE_URL . '/index.php\\?act=goods&op=index&goods_id=(\\d+)$#';
         preg_match($pattern, $t_msg, $matches);
         if (intval($matches[1]) < 1) {
             //伪静态
             $pattern = '#' . SHOP_SITE_URL . '/item-(\\d+)\\.html$#';
             preg_match($pattern, $t_msg, $matches);
         }
         $goods_id = intval($matches[1]);
         if ($goods_id >= 1) {
             $goods_info = $this->getGoodsInfo($goods_id);
             $goods_id = intval($goods_info['goods_id']);
         }
         $msg['goods_id'] = $goods_id;
         $msg['goods_info'] = $goods_info;
         return $msg;
     } else {
         return 0;
     }
 }
Пример #4
0
function hasPool()
{
    require 'classes/db_connection.php';
    require 'config/dbconfig.php';
    require 'functions/fun-net.inc.php';
    // Get Remote user IP
    $remoteIP = getIp();
    $conn = new db_connection($hostname, $username, $password, $database);
    $result = $conn->select("user_control", array("username"), "address='{$remoteIP}'");
    //
    if ($conn->affected_rows() == 1) {
        $data = $conn->fetch_array($result);
        $login = $data['username'];
        $result = $conn->select("tec_users", array("nome"), "login='******'");
        $data = $conn->fetch_array($result);
        $nome = $data['nome'];
        $_SESSION['IP'] = $remoteIP;
        $_SESSION['LOGIN'] = $login;
    } else {
        $nome = "404";
    }
    // Return array of values
    //$info[] = array();
    $info['IP'] = $remoteIP;
    $info['USER'] = $nome;
    $info['LOGIN'] = $login;
    print json_encode($info);
}
Пример #5
0
 /**
  * 登录时创建会话SESSION
  *
  * @param array $member_info 会员信息
  */
 public function createSession($member_info = array())
 {
     if (empty($member_info) || !is_array($member_info)) {
         return;
     }
     $_SESSION['is_login'] = '******';
     $_SESSION['member_id'] = $member_info['member_id'];
     $_SESSION['member_name'] = $member_info['member_name'];
     $_SESSION['member_email'] = $member_info['member_email'];
     $_SESSION['is_buy'] = $member_info['is_buy'];
     $_SESSION['avatar'] = $member_info['member_avatar'];
     $seller_info = Model('seller')->getSellerInfo(array('member_id' => $_SESSION['member_id']));
     $_SESSION['store_id'] = $seller_info['store_id'];
     if (trim($member_info['member_qqopenid'])) {
         $_SESSION['openid'] = $member_info['member_qqopenid'];
     }
     if (trim($member_info['member_sinaopenid'])) {
         $_SESSION['slast_key']['uid'] = $member_info['member_sinaopenid'];
     }
     if (!empty($member_info['member_login_time'])) {
         //登录时间更新
         $update_info = array('member_login_num' => $member_info['member_login_num'] + 1, 'member_login_time' => time(), 'member_old_login_time' => $member_info['member_login_time'], 'member_login_ip' => getIp(), 'member_old_login_ip' => $member_info['member_login_ip']);
         $this->updateMember($update_info, $member_info['member_id']);
     }
 }
Пример #6
0
 public function index()
 {
     $this->load->helper('ip');
     $this->load->model('tongji_model');
     $referer = '';
     if (preg_match('/' . str_replace('.', '\\.', $_SERVER['HTTP_HOST']) . '/i', $_SERVER['HTTP_REFERER'])) {
         $referer = '直接访问';
     } elseif (preg_match('/baidu\\.com/i', $_SERVER['HTTP_REFERER'])) {
         $referer = '百度';
     } elseif (preg_match('/google\\.\\w+/i', $_SERVER['HTTP_REFERER'])) {
         $referer = '谷歌';
     } elseif (preg_match('/so\\.com/i', $_SERVER['HTTP_REFERER'])) {
         $referer = '360搜索';
     } elseif (preg_match('/sogou\\.com/i', $_SERVER['HTTP_REFERER'])) {
         $referer = '搜狗';
     } else {
         $referer = 'NULL';
     }
     $user_agent = $_GET['userAgent'];
     if (empty($user_agent)) {
         $user_agent = 'NULL';
     }
     $this->tongji_model->insert(array('ip' => ip2long(getIp()), 'date' => date('Y-m-d', time()), 'user_agent' => $user_agent, 'referer' => $referer));
     die(json_encode(array('code' => 200, 'message' => '成功')));
 }
Пример #7
0
 function doLogin()
 {
     if (!verifyHash($_POST['hash'])) {
         $this->error('非验证的来源!');
     }
     if (empty($_POST['username'])) {
         $this->error('帐号不能为空!');
     }
     if (empty($_POST['password'])) {
         $this->error('密码不能为空!');
     }
     if (empty($_POST['verify'])) {
         $this->error('验证码不能为空!');
     }
     if ($_SESSION['verify'] != strtolower($_POST['verify'])) {
         $this->error('验证码错误!');
     }
     $info = m('User')->getRowByName($_POST['username']);
     if (empty($info)) {
         $this->error('账号不存在');
     }
     if ($info['password'] != md5($_POST['password'])) {
         $this->error('密码错误!');
     }
     $_SESSION['user_id'] = $info['id'];
     $_SESSION['user_name'] = $info['username'];
     $_SESSION['shop_id'] = $info['shop_id'];
     $_SESSION['shop_name'] = $info['shop_name'];
     $_SESSION['role_id'] = $info['role_id'];
     $data = array();
     $data['login_time'] = time();
     $data['ip_address'] = getIp();
     m('User')->update($data, "id='{$info['id']}'");
     $this->success('登录成功!', url());
 }
Пример #8
0
 public function login()
 {
     $verify = I('verify');
     if (check_verify($verify)) {
         $db = D('UserRelation');
         if ($userInfo = $db->getUserInfo()) {
             if ($userInfo['status'] == 1) {
                 $this->error('用户已被锁定,请联系管理员');
                 return false;
             }
             $rid = '';
             foreach ($userInfo['role'] as $k => $v) {
                 $rid .= $v['rid'] . ',';
             }
             $_SESSION['admin']['id'] = $userInfo['id'];
             $_SESSION['admin']['username'] = $userInfo['username'];
             $_SESSION['admin']['rid'] = trim($rid, ',');
             if (I('remember') == 'on') {
                 $ip = get_client_ip();
                 $setcookie = base64_encode($userInfo['id'] . '|' . $ip);
                 setcookie('adminuser', $setcookie, time() + 24 * 60 * 60, '/');
             }
             $data = array('loginIp' => getIp(), 'loginTime' => date('Y-m-d H:i:s'));
             M('user')->where(array('id' => $userInfo['id']))->save($data);
             $this->success('登陆成功', U('Index/index'));
         } else {
             $msg = $db->getError() ? $db->getError() : '用户名或密码不正确';
             $this->error($msg);
         }
     } else {
         $this->error('验证码不正确');
     }
 }
Пример #9
0
 /**
  *
  * @return mixed
  */
 public function actionCreate()
 {
     global $API_CODE;
     if (isset($_POST['user'])) {
         //Validation
         $new_data_error_msg = '';
         if (!strlen(trim($_POST['user'])) || !strlen(trim($_POST['content']))) {
             $new_data_error_msg = t('FILL_NOT_COMPLETE');
         } elseif (strlen($_POST['content'] > 580)) {
             $new_data_error_msg = t('WORDS_TOO_LONG');
         } elseif (ZFramework::app()->valid_code_open == 1 && gd_loaded() && !$this->_verifyCode->check($_POST['valid_code'])) {
             $new_data_error_msg = t('CAPTCHA_WRONG');
         }
         if ($new_data_error_msg) {
             if (defined('API_MODE')) {
                 $error_array = array('error_code' => '400', 'error' => $API_CODE['400'], 'error_detail' => $new_data_error_msg);
                 die(function_exists('json_encode') ? json_encode($error_array) : CJSON::encode($error_array));
             }
             if (!empty($_POST['ajax'])) {
                 die($new_data_error_msg);
             } else {
                 show_message($new_data_error_msg, true, 'index.php');
             }
         }
         // Ready to send query to database
         $user = $this->_model->escape_string($_POST['user']);
         if (!isset($_SESSION['admin']) && $_POST['user'] == ZFramework::app()->admin) {
             $user = '******';
         }
         $userExists = $this->_model->queryAll(sprintf(parse_tbprefix("SELECT * FROM <sysuser> WHERE username='******'"), $this->_model->escape_string($_POST['user'])));
         if ($userExists && @$_SESSION['user'] != $_POST['user']) {
             $user = '******';
         }
         $content = $this->_model->escape_string($_POST['content']);
         if (isset($_SESSION['uid'])) {
             $sql_insert = sprintf(parse_tbprefix("INSERT INTO <post> ( uid , content , post_time , ip ) VALUES ( %d , '%s' , %d , '%s' )"), $_SESSION['uid'], $content, time(), getIp());
         } else {
             $sql_insert = sprintf(parse_tbprefix("INSERT INTO <post> ( uname , content , post_time , ip ) VALUES ( '%s' ,'%s' , %d , '%s')"), $user, $content, time(), getIp());
         }
         // Send query to database
         if (!$this->_model->query($sql_insert)) {
             die($this->_model->error());
         }
         performEvent('PostController/actionCreate', array($user, $content, time() + ZFramework::app()->timezone * 60 * 60));
         if (defined('API_MODE')) {
             $json_array = array('insert_id' => $this->_model->insert_id());
             die(function_exists('json_encode') ? json_encode($json_array) : CJSON::encode($json_array));
         }
         if (isset($_POST['ajax'])) {
             echo 'OK';
             return TRUE;
         }
     }
     if (defined('API_MODE')) {
         $error_array = array('error_code' => '400', 'error' => $API_CODE['400'], 'error_detail' => t('ONLY_POST'));
         die(function_exists('json_encode') ? json_encode($error_array) : CJSON::encode($error_array));
     }
     header("Location:index.php");
 }
Пример #10
0
 function read($key)
 {
     $Query = mysql_query("select `sessionvalue` from `sessions` where `sessionkey`='" . $key . "' and `sessionexpiry`>'" . date("Y-m-d H:i:s") . "' and `sessionip`='" . getIp() . "'", $this->oDB);
     $aValue = mysql_fetch_assoc($Query);
     if (empty($aValue)) {
         return NULL;
     }
     return $aValue["sessionvalue"];
 }
Пример #11
0
function die2($debug_str)
{
    global $private_network;
    if (preg_match($private_network, getIp())) {
        die($debug_str);
    } else {
        die("GENERIC_ERROR");
    }
}
Пример #12
0
 private function replaceData($data)
 {
     $data['ip'] = getIp();
     $data['ratingspage_id'] = $data['id'];
     $data['ratingspage_type'] = str_replace("\\", "_", Crypt::decrypt($data['model']));
     $data['rating'] = $data['value'];
     if (Sentry::check()) {
         $data['user_id'] = Sentry::getUser()->id;
     }
     return $data;
 }
Пример #13
0
	/**
	 * 初始化,未启用内存保存时默认使用lock表存储
	 *
	 * @param unknown_type $type
	 */
	private static function init($type){
		if (C('cache_open')){
			self::$lock = Cache::getInstance('cacheredis');
		}else{
			self::$lock = new lock();
		}
		if (!isset(self::$processid[$type])){
			$ip = sprintf('%u',ip2long(getIp()));
			self::$processid[$type] = str_pad($ip,10,'0').self::parsekey($type);;
			self::$lockid[$type] = str_pad($ip,11,'0').self::parsekey($type);;
		}
	}
Пример #14
0
function getCity()
{
    $ip = getIp();
    $uri = "http://api.map.baidu.com/location/ip?ak=A20cb515b0fa284cb99c36956c06e737&ip={$ip}&coor=bd09ll";
    $str = file_get_contents($uri);
    $cityArr = json_decode($str);
    if ($cityArr->{'status'} == 0) {
        return $cityArr->{'content'}->{'address_detail'}->{'city'};
    } else {
        return '';
    }
}
Пример #15
0
 public function saveAction()
 {
     $this->_helper->layout->disableLayout();
     $parameters = $this->getRequest()->getParams();
     $errors = array();
     $auth = Zend_Auth::getInstance();
     $publication = new Publication($parameters['f_publication']);
     if ($auth->getIdentity()) {
         $acceptanceRepository = $this->getHelper('entity')->getRepository('Newscoop\\Entity\\Comment\\Acceptance');
         $user = new User($auth->getIdentity());
         $userIp = getIp();
         if ($acceptanceRepository->checkParamsBanned($user->m_data['Name'], $user->m_data['EMail'], $userIp, $parameters['f_publication'])) {
             $errors[] = $this->view->translate('You have been banned from writing feedbacks.');
         }
     } else {
         $errors[] = $this->view->translate('You are not logged in.');
     }
     if (!array_key_exists('f_feedback_content', $parameters) || empty($parameters['f_feedback_content'])) {
         $errors[] = $this->view->translate('Feedback content was not filled in.');
     }
     if (empty($errors)) {
         $feedbackRepository = $this->getHelper('entity')->getRepository('Newscoop\\Entity\\Feedback');
         $feedback = new Feedback();
         $values = array('user' => $auth->getIdentity(), 'publication' => $parameters['f_publication'], 'section' => $parameters['f_section'], 'article' => $parameters['f_article'], 'subject' => $parameters['f_feedback_subject'], 'message' => $parameters['f_feedback_content'], 'url' => $parameters['f_feedback_url'], 'time_created' => new DateTime(), 'language' => $parameters['f_language'], 'status' => 'pending', 'attachment_type' => 'none', 'attachment_id' => 0);
         if (isset($parameters['image_id'])) {
             $values['attachment_type'] = 'image';
             $values['attachment_id'] = $parameters['image_id'];
             $feedbackRepository->save($feedback, $values);
             $feedbackRepository->flush();
             $current_user = $this->_helper->service('user')->getCurrentUser();
             $this->_helper->service->getService('dispatcher')->notify('image.delivered', new GenericEvent($this, array('user' => $current_user)));
             $this->view->response = $this->view->translate('File is uploaded and your message is sent.');
         } else {
             if (isset($parameters['document_id'])) {
                 $values['attachment_type'] = 'document';
                 $values['attachment_id'] = $parameters['document_id'];
                 $feedbackRepository->save($feedback, $values);
                 $feedbackRepository->flush();
                 $current_user = $this->_helper->service('user')->getCurrentUser();
                 $this->_helper->service->getService('dispatcher')->notify('document.delivered', new GenericEvent($this, array('user' => $current_user)));
                 $this->view->response = $this->view->translate('File is uploaded and your message is sent.');
             } else {
                 $feedbackRepository->save($feedback, $values);
                 $feedbackRepository->flush();
                 $this->view->response = $this->view->translate('Your message is sent.');
             }
         }
     } else {
         $errors = implode('<br>', $errors);
         $errors = $this->view->translate('Following errors have been found:') . '<br>' . $errors;
         $this->view->response = $errors;
     }
 }
Пример #16
0
 public function valid()
 {
     if (false == $this->checkSignature()) {
         $ip = getIp();
         interface_log(ERROR, EC_OTHER, 'malicious: ' . $ip);
         exit(0);
     }
     $echoStr = $_GET["echostr"];
     if ($echoStr) {
         echo $echoStr;
         exit(0);
     }
 }
Пример #17
0
 /**
  * login user, either by a temporary session or a stored cookie.
  *
  * @param int $id
  * @param bool[optional] $rememberMe
  * @return void
  */
 public function login($id, $name, $groups, $rememberMe = false)
 {
     session_destroy();
     $sessid = randomString();
     session_id($sessid);
     session_start();
     $_SESSION['online'] = TRUE;
     $_SESSION['ip'] = getIp();
     $_SESSION['proxy'] = getProxy();
     if ($rememberMe) {
         setcookie('userid', serialize(array($id, $name, $groups)), time() + 60 * 60 * 24 * 999, '/', '.madr.se', false, true);
     }
     $_SESSION['userid'] = serialize(array($id, $name, $groups));
 }
Пример #18
0
 public function add_user($mem_name, $mem_pwd, $mem_email, $mem_group = 0)
 {
     //获取当前时间戳作为 用户注册时间
     $mem_regtime = time();
     //刚注册时,最后登陆时间为注册时间
     $mem_llogtime = $mem_regtime;
     //最后一次登陆IP,因为是注册,所以取当前IP
     $llogip = getIp();
     //构造 $coloumns	字段
     $coloumns = "mem_name,mem_pwd,mem_email,mem_group,mem_regtime,mem_llogtime,mem_llogip";
     //构造 $values		值
     $values = "'" . $mem_name . "','" . $mem_pwd . "','" . $mem_email . "','" . $mem_group . "','" . $mem_regtime . "','" . $mem_llogtime . "','" . $llogip . "'";
     //增加用户
     parent::db_insert('t_member', $coloumns, $values);
 }
Пример #19
0
 /**
  * login user, either by a temporary session or a stored cookie.
  *
  * @param int $id
  * @param bool[optional] $rememberMe
  * @return void
  */
 public function setOnline($id, $name, $groups, $rememberMe = false)
 {
     // if success:
     session_destroy();
     $sessid = randomString();
     session_id($sessid);
     session_start();
     $_SESSION['online'] = TRUE;
     $_SESSION['ip'] = getIp();
     $_SESSION['proxy'] = getProxy();
     if ($rememberMe) {
         setcookie('userid', serialize(array($id, $name, $groups)), time() + 60 * 60 * 24 * 999, '/', COOKIE_DOMAIN, false, true);
     }
     $_SESSION['userid'] = serialize(array($id, $name, $groups));
     $this->groups = $groups;
 }
Пример #20
0
 private function createPacketParam(){      
     $this->param['input_charset'] = $this->inputCharset;
     $this->param['spid'] = $this->spid;
     $this->param['wxappid'] = $this->appId;
     isset($this->param['client_ip']) || $this->param['client_ip'] = getIp();            
     if(!$this->checkMoney()){
         $this->setError('红包金额必须为1-100元这间!');
         return false;
     }else{//红包单位是分
         $this->param['total_amount'] *= 100;
     }
     $this->param['max_value'] = $this->param['min_value'] = $this->param['total_amount'];          
     $this->param['total_num'] = 1;     
     $sign = $this->md5Sign($this->param);
     $this->param['sign'] = $sign;
     return true;
 }
Пример #21
0
function getCountryCode()
{
    $ip = getIp();
    // debug:
    // $ip = "193.51.208.14"; // French IP
    // $ip = "71.164.115.181"; // US IP
    $location = null;
    if ($ip) {
        // db credentials, see db.php.example
        require 'db.php';
        DBconnect($server, $username, $password, $database);
        $location = ipRoughLocate($ip);
    }
    if (!$location || !$location["countryCode"] || $location["countryName"] == "(Unknown Country?)") {
        return "US";
    } else {
        return $location["countryCode"];
    }
}
Пример #22
0
function total_price()
{
    $total = 0;
    global $con;
    $ip = getIp();
    $sel_price = "select  *  from selections where ip_add ='{$ip}' ";
    $run_price = mysqli_query($con, $sel_price);
    while ($p_price = mysqli_fetch_array($run_price)) {
        $worker_id = $p_price['w_id'];
        $pro_price = "select  *  from workers where worker_id ='{$worker_id}' ";
        $run_pro_price = mysqli_query($con, $pro_price);
        while ($pp_price = mysqli_fetch_array($run_pro_price)) {
            $fee = array($pp_price['fee']);
            $values = array_sum($fee);
            $total += $values;
        }
    }
    echo $total;
}
Пример #23
0
function total_price()
{
    $total = 0;
    global $con;
    $ip = getIp();
    $sel_price = "select * from cart where ip_add='{$ip}'";
    $run_price = mysqli_query($con, $sel_price);
    while ($p_price = mysqli_fetch_array($run_price)) {
        $pro_id = $p_price['p_id'];
        $pro_price = "select * from products where product_id='{$pro_id}'";
        $run_pro_price = mysqli_query($con, $pro_price);
        while ($pp_price = mysqli_fetch_array($run_pro_price)) {
            $product_price = array($pp_price['product_price']);
            $values = array_sum($product_price);
            $total += $values;
        }
    }
    echo "\$" . $total;
}
Пример #24
0
	/**
	 * Identify same "customer" as someone with the same customer id, or ip address or email address.
	 *
	 * @return array
	 */
	public function getCustomerIdentifiers()
	{
		$ip = getIp();
		$quote = getCustomerQuote();
		$customerid = $quote->getCustomerId();
		$email = $quote->getBillingAddress()->getEmail();
		if ($email == '') {
			$customer = getCustomer($customerid);
			$email = $customer['custconemail'];
		}

		$identifiers = array(
			$ip,
			$customerid,
			$email,
		);

		return $identifiers;
	}
Пример #25
0
 public function saveAction()
 {
     global $_SERVER;
     $this->_helper->layout->disableLayout();
     $parameters = $this->getRequest()->getParams();
     $errors = array();
     $auth = Zend_Auth::getInstance();
     $article = new Article($parameters['f_language'], $parameters['f_article_number']);
     $publication = new Publication($article->getPublicationId());
     if ($auth->getIdentity()) {
         $acceptanceRepository = $this->getHelper('entity')->getRepository('Newscoop\\Entity\\Comment\\Acceptance');
         $userRepository = $this->getHelper('entity')->getRepository('Newscoop\\Entity\\User');
         $user = $userRepository->find($auth->getIdentity());
         $userIp = getIp();
         if ($acceptanceRepository->checkParamsBanned($user->getName(), $user->getEmail(), $userIp, $article->getPublicationId())) {
             $errors[] = $this->view->translate('You have been banned from writing comments.');
         }
     } else {
         $errors[] = $this->view->translate('You are not logged in.');
     }
     if (!array_key_exists('f_comment_subject', $parameters) || empty($parameters['f_comment_subject'])) {
         //$errors[] = getGS('The comment subject was not filled in.');
         $errors[] = $this->view->translate('The comment subject was not filled in.');
     }
     if (!array_key_exists('f_comment_content', $parameters) || empty($parameters['f_comment_content'])) {
         $errors[] = $this->view->translate('The comment content was not filled in.');
     }
     if (empty($errors)) {
         $commentRepository = $this->getHelper('entity')->getRepository('Newscoop\\Entity\\Comment');
         $comment = new Comment();
         $values = array('user' => $auth->getIdentity(), 'name' => $parameters['f_comment_nickname'], 'subject' => $parameters['f_comment_subject'], 'message' => $parameters['f_comment_content'], 'language' => $parameters['f_language'], 'thread' => $parameters['f_article_number'], 'ip' => $_SERVER['REMOTE_ADDR'], 'status' => 'approved', 'time_created' => new DateTime(), 'recommended' => '0');
         $commentRepository->save($comment, $values);
         $commentRepository->flush();
         $this->view->response = 'OK';
     } else {
         $errors = implode('<br>', $errors);
         $errors = $this->view->translate('Following errors have been found:') . '<br>' . $errors;
         $this->view->response = $errors;
     }
     $this->getHelper('contextSwitch')->addActionContext('save', 'json')->initContext();
 }
Пример #26
0
function Scan()
{
    $upnp = new Upnp();
    print 'searching...' . PHP_EOL;
    $everything = $upnp->discover();
    $result = [];
    foreach ($everything as $device) {
        //print_r($device);  //uncomment to see all available array elements for a device.
        $info = $device['description']['device'];
        // print array_search(, array_column( $result, 'ADDRESS'));
        if (!array_search_result($result, 'UUID', $info["UDN"])) {
            $result[] = ["ID" => $info["UDN"], "TITLE" => $info["friendlyName"], "ADDRESS" => $info["presentationURL"], "UUID" => $info["UDN"], "DESCRIPTION" => is_array($info["modelDescription"]) ? implode(',', $info["modelDescription"]) : $info["modelDescription"], "TYPE" => explode(":", $info["deviceType"])[3], "LOGO" => getDefImg($info), "SERIAL" => $info["serialNumber"], "MANUFACTURERURL" => $info["manufacturerURL"], "UPDATED" => '', "MODEL" => $info["modelName"], "MANUFACTURER" => $info["manufacturer"], "IP" => getIp($info)];
        }
    }
    /*
    print("<pre>");
    print_r($result);
     print("</pre>");
    */
    return $result;
}
Пример #27
0
 public static function page_end()
 {
     $agent = strtolower($_SERVER['HTTP_USER_AGENT']);
     if (strpos($agent, "spider") !== false || strpos($agent, "bot") !== false) {
         return;
     }
     $file = basename($_SERVER["PHP_SELF"]);
     if (checkSign(1)) {
         return;
     }
     $setting = self::setting();
     if (!$setting['counter']) {
         return;
     }
     global $db, $req;
     include ROOT_PATH . "/include/config.php";
     $ip = getIp();
     $cnt_visitor = $req->getCookie('cnt_visitor');
     $add_ip = 0;
     $pv = 0;
     $iv = 0;
     if (empty($cnt_visitor) || $cnt_visitor != $ip) {
         $req->setCookie("cnt_visitor", $ip, 60 * 60 * 24);
         $add_ip = 1;
     }
     if ($add_ip == 1 && $db->result($setting['db']['pre'] . "user_online", "ip", array("ip", "=", $ip))) {
         $add_ip = 0;
     }
     $count_online = $db->result($setting['db']['pre'] . "user_online", "count(distinct ip)");
     if ($record = $db->record($setting['db']['pre'] . "counter", "pv, iv, online", array("date", "f=", "curdate()"))) {
         $pv = $record['pv'] + 1;
         $iv = $record['iv'] + $add_ip;
         $online = max($record['online'], $count_online);
     } else {
         $pv = 1;
         $iv = 1;
         $online = 1;
     }
     return $db->replace($setting['db']['pre'] . "counter", array("curdate()", $pv, $iv, $online));
 }
Пример #28
0
 /**
  * add msg
  *
  */
 public function send_msgOp()
 {
     $member = array();
     $model_chat = Model('web_chat');
     if (empty($_POST)) {
         $_POST = $_GET;
     }
     $member_id = $_SESSION['member_id'];
     $member_name = $_SESSION['member_name'];
     $f_id = intval($_POST['f_id']);
     $t_id = intval($_POST['t_id']);
     $t_name = trim($_POST['t_name']);
     if ($member_id < 1 || $member_id != $f_id) {
         $this->error(Language::get('nc_member_chat_login'));
     }
     $member = $model_chat->getMember($t_id);
     if ($t_name != $member['member_name']) {
         $this->error(Language::get('nc_member_chat_name_error'));
     }
     $msg = array();
     $msg['f_id'] = $f_id;
     $msg['f_name'] = $member_name;
     $msg['f_ip'] = getIp();
     $msg['t_id'] = $t_id;
     $msg['t_name'] = $t_name;
     $msg['t_msg'] = trim($_POST['t_msg']);
     $msg['r_state'] = '2';
     //state:1--read ,2--unread
     $msg['add_time'] = time();
     if ($msg['t_msg'] != '') {
         $state = $model_chat->add($msg);
     }
     if ($state) {
         $msg['m_id'] = $state;
         $msg['add_time'] = date('Y-m-d H:i:s', $msg['add_time']);
         $this->json($msg);
     } else {
         $this->error(Language::get('nc_member_chat_add_error'));
     }
 }
Пример #29
0
 private function createPacketParam() {
     //$this->param['input_charset'] = $this->inputCharset;
     // $this-> param['mch_id' ] = $this->spid;
     $this->param['mchid'] = "1237870602";
     //$this-> param['wxappid' ] = $this->appId;
     $this->param['mch_appid'] = "wxf305030001374a81";
     isset($this->param ['spbill_create_ip']) || $this->param['spbill_create_ip'] = getIp();
     /*
       if(!$this->checkMoney()){
       $this->setError( '红包金额必须为1-200元这间!' );
       return false;
       } else{//红包单位是分
       $this-> param['total_amount'] =$this-> param['total_amount']*100;
       }
      */
     //$this-> param['max_value' ] = $this->param['min_value' ] = $this->param['total_amount' ];         
     //$this-> param['total_num' ] = 1;
     //$this-> param['nonce_str' ] = strtoupper(md5(time()));
     $sign = $this->md5Sign($this->param);
     $this->param['sign'] = $sign;
     return true;
 }
Пример #30
0
 /**
  * 添加博客
  */
 public function blogaddAction()
 {
     $title = $this->_request->get('title');
     $desc = $this->_request->get('desc');
     $thumb = $this->_request->get('thumb');
     $content = $this->_request->get('content');
     $addip = getIp();
     $addtime = time();
     $blogData['title'] = $title;
     $blogData['description'] = $desc;
     $blogData['thumb'] = $thumb;
     $blogData['addip'] = $addip;
     $blogData['addtime'] = $addtime;
     $blogData['content'] = $content;
     $blogData['author'] = 'liufajun';
     // 作者
     $modBlog = new admin_BlogModel();
     $r = $modBlog->addBlog($blogData);
     if (!$r) {
         response('');
     }
     response('');
 }