Ejemplo n.º 1
0
 function _thumb_media_id($cover_id)
 {
     $cover = get_cover($cover_id);
     $driver = C('PICTURE_UPLOAD_DRIVER');
     if ($driver != 'Local' && !file_exists(SITE_PATH . $cover['path'])) {
         // 先把图片下载到本地
         $pathinfo = pathinfo(SITE_PATH . $cover['path']);
         mkdirs($pathinfo['dirname']);
         $content = wp_file_get_contents($cover['url']);
         $res = file_put_contents(SITE_PATH . $cover['path'], $content);
         if ($res) {
             return '';
         }
     }
     $path = $cover['path'];
     if (!$path) {
         return '';
     }
     $param['type'] = 'thumb';
     $param['media'] = '@' . realpath(SITE_PATH . $path);
     $url = 'https://api.weixin.qq.com/cgi-bin/material/add_material?access_token=' . get_access_token();
     $res = post_data($url, $param, true);
     if (isset($res['errcode']) && $res['errcode'] != 0) {
         return '';
     }
     $map['cover_id'] = $cover_id;
     $map['manager_id'] = $this->mid;
     $this->where($map)->setField('thumb_media_id', $res['media_id']);
     return $res['media_id'];
 }
Ejemplo n.º 2
0
/**
 * get_token	gets an edit token
 *
 * @return	string	edit token
 */
function get_token()
{
    $postdata = http_build_query(array('action' => 'tokens', 'format' => 'json'));
    $page = post_data($postdata);
    $token = $page->{'tokens'}->{'edittoken'};
    return $token;
}
Ejemplo n.º 3
0
function getDomainInfo()
{
    $url = 'https://dnsapi.cn/Domain.List';
    $config = array('login_email' => '*****@*****.**', 'login_password' => 'pdcxaje127', 'format' => 'json', 'lang' => 'cn', 'error_on_empty' => 'no');
    $post_data = post_data($url, $config);
    return json_decode($post_data, true);
}
Ejemplo n.º 4
0
 function move_group($id, $group_id)
 {
     is_array($id) || ($id = explode(',', $id));
     $data['uid'] = $map['uid'] = array('in', $id);
     // $data ['group_id'] = $group_id; //TODO 前端微信用户只能有一个微信组
     $res = M('auth_group_access')->where($data)->delete();
     $data['group_id'] = $group_id;
     foreach ($id as $uid) {
         $data['uid'] = $uid;
         $res = M('auth_group_access')->add($data);
         // 更新用户缓存
         D('Common/User')->getUserInfo($uid, true);
     }
     $group = $this->find($group_id);
     // 同步到微信端
     if (C('USER_GROUP') && !empty($group['wechat_group_id'])) {
         $url = 'https://api.weixin.qq.com/cgi-bin/groups/members/update?access_token=' . get_access_token();
         $map['token'] = get_token();
         $follow = M('public_follow')->where($map)->field('openid, uid')->select();
         foreach ($follow as $v) {
             if (empty($v['openid'])) {
                 continue;
             }
             $param['openid'] = $v['openid'];
             $param['to_groupid'] = $group['wechat_group_id'];
             $param = JSON($param);
             $res = post_data($url, $param);
         }
     }
     return $group;
 }
Ejemplo n.º 5
0
/**
 * create_notice
 * 
 * @return	string
 */
function create_notice()
{
    $title = "New Page (" . date("Y-m-d H:i:s") . ")";
    $text = "{{Notice d'œuvre\n|titre= \nartiste= \n}}";
    // Post new content
    $postdata = http_build_query(array('action' => 'edit', 'format' => 'json', 'title' => $title, 'text' => $text, 'token' => get_token()));
    $page = post_data($postdata);
    return $page->{'edit'}->{'pageid'};
    #return 'undefined';
}
Ejemplo n.º 6
0
 function reply($dataArr, $keywordArr = array())
 {
     // addWeixinLog ( $dataArr, 'PublicBindModel' );
     if ($dataArr['Content'] == 'TESTCOMPONENT_MSG_TYPE_TEXT') {
         $this->replyText('TESTCOMPONENT_MSG_TYPE_TEXT_callback');
     } elseif (strpos($dataArr['Content'], 'QUERY_AUTH_CODE') !== false) {
         // addWeixinLog ( $dataArr ['Content'], '222' );
         $query_auth_code = str_replace('QUERY_AUTH_CODE:', '', $dataArr['Content']);
         $info = D('Addons://PublicBind/PublicBind')->getAuthInfo($query_auth_code);
         // addWeixinLog ( $info, '555' );
         $param['touser'] = $dataArr['FromUserName'];
         $param['msgtype'] = 'text';
         $param['text']['content'] = $query_auth_code . '_from_api';
         $url = 'https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=' . $info['authorization_info']['authorizer_access_token'];
         // addWeixinLog ( $param, $url );
         $res = post_data($url, $param);
     } else {
         $this->replyText($dataArr['Event'] . 'from_callback');
     }
 }
Ejemplo n.º 7
0
<?php

//header('Content-type: application/json');
require './../config.php';
require './../functions.php';
if ($_POST == null) {
    exit;
}
if (post_data('email') != null and post_data('password') == null) {
    $email = htmlspecialchars($_POST['email']);
    $total = count($DB->query("SELECT * FROM user WHERE email=?", array($email)));
    if ($total == 1) {
        $result = array('valid' => 'true');
    } else {
        $result = array('valid' => 'false');
    }
} else {
    $myusername = $_POST['email'];
    $mypassword = $_POST['password'];
    $mypassword = MD5($mypassword . '404notfound');
    $count = count($DB->query("SELECT * FROM user WHERE email=? and pass=?", array($myusername, $mypassword)));
    if ($count == 1) {
        session_start();
        $_SESSION['myusername'] = $myusername;
        $_SESSION['mypassword'] = $mypassword;
        $result['message'] = "success";
        // session_register("mypassword");
        //header("location:userpanel.php");
    } else {
        $result['message'] = "errow";
    }
Ejemplo n.º 8
0
function upload_youkang_image($path, $type = 'image')
{
    $url = 'http://www.youkang120.com:84/uploadAudio?userName=18820475115&pwd=123456&bizType=2';
    $param['type'] = $type;
    $param['media'] = '@' . realpath($path);
    $end = '\\r\\n';
    $twoHyphens = '--';
    $boundary = '************';
    $header[] = 'Content-Type: multipart/form-data;boundary=' . $boundary;
    $res = post_data($url, $param, true);
    if (isset($res['errcode']) && $res['errcode'] != 0) {
        $this->error(error_msg($res, '图片上传'));
        exit;
    }
    $content = $twoHyphens . $boundary;
    $content = $end;
    $content = 'Content-Disposition: form-data; ' . 'name="file1";filename="image.jpg"';
    $content = $end;
    $content = $end;
    //file
    $twoHyphens . $boundary . $twoHyphens;
    $end;
    return $res['media_id'];
}
Ejemplo n.º 9
0
 function _get_file_media_id($file_id, $type = 'voice', $title = '', $introduction = '')
 {
     $fileInfo = M('file')->find($file_id);
     if ($fileInfo) {
         $path = '/Uploads/Download/' . $fileInfo['savepath'] . $fileInfo['savename'];
         if (!$path) {
             $this->error('获取素材失败');
             exit;
         }
         $param['type'] = $type;
         $param['media'] = '@' . realpath(SITE_PATH . $path);
         if ($type == 'video') {
             $param['description']['title'] = $title;
             $param['description']['introduction'] = $introduction;
         }
         $url = 'https://api.weixin.qq.com/cgi-bin/material/add_material?access_token=' . get_access_token();
         $res = post_data($url, $param);
         if (!$res) {
             $this->error('同步失败');
         }
         if (isset($res['errcode']) && $res['errcode'] != 0) {
             $this->error(error_msg($res, '素材上传'));
             exit;
         }
     }
     return $res['media_id'];
 }
 function getPublicInfo($authorizer_appid)
 {
     $res['status'] = false;
     $component_access_token = $this->_get_component_access_token();
     if ($component_access_token == false) {
         $res['msg'] = '获取access_token失败!';
         return $res;
     }
     $key = 'getPublicInfo_' . $authorizer_appid;
     $data = S($key);
     if ($data === false) {
         $url = 'https://api.weixin.qq.com/cgi-bin/component/api_get_authorizer_info?component_access_token=' . $component_access_token;
         $param['component_appid'] = $this->component_appid;
         $param['authorizer_appid'] = $authorizer_appid;
         $data = post_data($url, $param);
         if (!isset($data['authorizer_info']['user_name'])) {
             $res['msg'] = '获取公众号信息失败!';
             return $res;
         }
         S($key, $data, $data['expires_in']);
     }
     return $data;
 }
Ejemplo n.º 11
0
<?php

$appKey = '123456';
$appSecret = '123456';
$mobileNumber = '13578888888';
$amount = '10';
$url = 'http://121.40.104.167:8080/charge/mobilefee';
$param = array('appKey' => $appKey, 'mobileNumber' => $mobileNumber, 'amount' => $amount, 'verify' => md5($appKey . $mobileNumber . $amount . $appSecret));
function post_data($url, $param)
{
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($param));
    // curl_setopt($ch, CURLOPT_PROXY, '127.0.0.1:8888');
    // curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,0);
    // receive server response ...
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $server_output = curl_exec($ch);
    curl_close($ch);
    return $server_output;
}
$res = post_data($url, $param);
var_dump(json_decode($res));
 function _video_download($media_id, $cover_url)
 {
     $savePath = SITE_PATH . '/Uploads/Download/' . time_format(NOW_TIME, 'Y-m-d');
     mkdirs($savePath);
     $ext = 'mp4';
     if (empty($cover_url)) {
         // 获取图片URL
         $url = 'https://api.weixin.qq.com/cgi-bin/material/get_material?access_token=' . get_access_token();
         $param['media_id'] = $media_id;
         $info = post_data($url, $param);
         if (isset($info['errcode']) && $info['errcode'] != 0) {
             $this->error(error_msg($info, '下载视频文件素材失败'));
             exit;
         }
         return $info;
     } else {
         $content = wp_file_get_contents($cover_url);
         // 获取图片扩展名
         $picExt = substr($cover_url, strrpos($cover_url, '=') + 1);
         // $picExt=='jpeg'
         if (empty($picExt)) {
             $picExt = $ext;
         }
         $picName = NOW_TIME . '.' . $picExt;
         $picPath = $savePath . '/' . $picName;
         $res = file_put_contents($picPath, $content);
         if (!$res) {
             $this->error('远程视频文件下载失败');
             exit;
         }
     }
     $cover_id = 0;
     if ($res) {
         // 保存记录,添加到picture表里,获取coverid
         $url = U('File/uploadPicture', array('session_id' => session_id()));
         $_FILES['download'] = array('name' => $picName, 'type' => 'application/octet-stream', 'tmp_name' => $picPath, 'size' => $res, 'error' => 0);
         $File = D('File');
         $file_driver = C('DOWNLOAD_UPLOAD_DRIVER');
         $info = $File->upload($_FILES, C('DOWNLOAD_UPLOAD'), C('DOWNLOAD_UPLOAD_DRIVER'), C("UPLOAD_{$file_driver}_CONFIG"));
         $cover_id = $info['download']['id'];
         unlink($picPath);
     }
     return $cover_id;
 }
 function tongbu_follow()
 {
     $map['manager_id'] = $this->mid;
     $map['token'] = get_token();
     $list = M('auth_group')->where($map)->select();
     foreach ($list as $v) {
         $arr[$v['id']] = $v['wechat_group_id'];
     }
     $id = I('id', 0, 'intval');
     $map['id'] = array('gt', $id);
     $map['has_subscribe'] = 1;
     $map['token'] = get_token();
     $follow_list = M('public_follow')->where($map)->order('id asc')->limit(5)->select();
     if (!$follow_list) {
         echo 'update over!';
         exit;
     }
     $access_token = get_access_token();
     $url = 'https://api.weixin.qq.com/cgi-bin/groups/members/update?access_token=' . $access_token;
     foreach ($follow_list as $follow) {
         $param['openid'] = $follow['openid'];
         $param['to_groupid'] = intval($arr[$follow['group']]);
         $param = JSON($param);
         $res = post_data($url, $param);
         $has_subscribe = $res['errcode'] == 43004 ? 0 : 1;
         M('public_follow')->where('id=' . $follow['id'])->setField('has_subscribe', $has_subscribe);
     }
     $param2['id'] = $follow['id'];
     $url = U('tongbu_follow', $param2);
     $url = addons_url('tongbu_follow');
     $this->success('同步用户数据中,请勿关闭', $url);
     // echo 'update follow_id: ' . $follow ['id'] . ', please wait!';
     // echo '<script>window.location.href="' . $url . '";</script>';
 }
Ejemplo n.º 14
0
}
echo "</div>";
//
if (isset($_POST['descsensor'])) {
    // 2. DescribeSensor
    echo "<h2> The Details of Sensors in SOS </h2>";
    $procedure = $_POST['descsensor'];
    //echo $procedure."<br/>";
    // sample request
    //$dSensorURL = "http://localhost/istsos/service_name?service=SOS&request=describeSensor&procedure=hum_bs_1&responseFormat=text/xml;subtype='sensorML/1.0.0'&version=1.0.0";
    $dSensorURL = GetDescribeSenURL2($DescribeSenStr, $procedure, $RespFormat);
    session_start();
    $dSensorURL = $_SESSION['rawURL'] . $dSensorURL;
    $dSensorstring = "";
    //echo "URL Used / Accessed: ".$dSensorURL."</br>";
    $dSoutput = post_data($dSensorURL, $dSensorstring);
    //print_r($dSoutput);
    // a. Quantity
    $Quantity = array('Quantity', 'definition');
    $myQuantity = parse_describeSense($dSoutput, $Quantity);
    $myCleanQuantity = cleanQuantity($myQuantity);
    //print_r($myCleanQuantity);
    // b. co-ordinates
    $reference = array('Point', 'srsName', 'gml:id');
    $myCoOrd = getCoOrdinates($dSoutput, $reference);
    //echo "</br></br>";
    //print_r($myCoOrd);
    // c. Sensing time Interval
    $reference = 'interval';
    $myInterval = getInterval($dSoutput, $reference);
    //echo "</br></br>";
 function get_image_media_id($cover_id)
 {
     $cover = get_cover($cover_id);
     $driver = C('PICTURE_UPLOAD_DRIVER');
     if ($driver != 'Local' && !file_exists(SITE_PATH . $cover['path'])) {
         // 先把图片下载到本地
         $pathinfo = pathinfo(SITE_PATH . $cover['path']);
         mkdirs($pathinfo['dirname']);
         $content = wp_file_get_contents($cover['url']);
         $res = file_put_contents(SITE_PATH . $cover['path'], $content);
         if (!$res) {
             $this->error('远程图片下载失败');
         }
     }
     $path = $cover['path'];
     if (!$path) {
         $this->error('获取图片素材失败');
     }
     $param['type'] = 'image';
     $param['media'] = '@' . realpath(SITE_PATH . $path);
     $url = 'https://api.weixin.qq.com/cgi-bin/media/upload?access_token=' . get_access_token();
     $res = post_data($url, $param, true);
     if (isset($res['errcode']) && $res['errcode'] != 0) {
         $this->error(error_msg($res, '封面图上传'));
     }
     return $res['media_id'];
 }
Ejemplo n.º 16
0
/**
 * set_notice_data
 *
 * @param		$id					string
 * @param		$field					string
 * @param		$date						string
 * @param		$value					string
 * @param		$operation			string
 * @param		$argument				string
 * @return	string
 */
function set_notice_data($id, $field, $date, $value, $operation, $argument)
{
    global $app_g_API_URL;
    // Get page content
    $postdata = http_build_query(array('action' => 'query', 'prop' => 'revisions', 'rvprop' => 'content', 'pageids' => $id, 'format' => 'json'));
    $data = json_decode(file_get_contents($app_g_API_URL . "?" . $postdata))->{'query'}->{'pages'}->{$id};
    if ($data->{'title'} == null) {
        // This page doesn't exist -> WrongNotice
        return "WrongNotice";
    } else {
        #echo json_encode($data)."<br />";
        #return;
        $content = $data->{'revisions'}[0]->{'*'};
        if ($content == null || $content == "") {
            // No content -> EmptyNotice
            return "EmptyNotice ";
        } else {
            if ($operation == null || $operation == "") {
                // No operation specified -> EmptyOperation
                return "EmptyOperation";
            } else {
                if ($operation != "add" && $operation != "replace" && $operation != "delete") {
                    // Wrong operation -> WrongOperation
                    return "WrongOperation";
                } else {
                    if ($field == null || $field == "") {
                        // No field -> EmptyField
                        return "EmptyField ";
                    } else {
                        // Split content into fields and values
                        $start_text = eregi_replace("^([^\\|]*).*\$", "\\1", $content);
                        $end_text = eregi_replace("^.*(}}[^}]*)\$", "\\1", $content);
                        $content = eregi_replace("^[^\\|]*", "", $content);
                        $content = eregi_replace("}}[^}]*\$", "", $content);
                        $content = eregi_replace("([^\n])\\|([^\n\\|=]*)=", "\\1\n|\\2=", $content);
                        $content = split("\n", $content);
                        $fields = array();
                        foreach ($content as &$i) {
                            $i = eregi_replace("^\\|", "", $i);
                            $f = eregi_replace("^([^=]*)=(.*)\$", "\\1", $i);
                            $v = eregi_replace("^([^=]*)=(.*)\$", "\\2", $i);
                            $fields[$f] = $v;
                        }
                        // Do whatever action must be done
                        if ($operation == "replace") {
                            if ($fields[$field] == "" || $fields[$field] == null) {
                                return "WrongField";
                            } else {
                                $fields[$field] = $value;
                            }
                        } else {
                            if ($operation == "add") {
                                if ($fields[$field] != "" && $fields[$field] != null) {
                                    $fields[$field] .= ", " . $value;
                                } else {
                                    $fields[$field] = $value;
                                    upload_file($filename);
                                }
                            } else {
                                if ($operation == "delete") {
                                    if ($fields[$field] == "" || $fields[$field] == null) {
                                        return "WrongField";
                                    } else {
                                        unset($fields[$field]);
                                    }
                                }
                            }
                        }
                        // Construct new content
                        $content = $start_text;
                        foreach ($fields as $key => $element) {
                            if ($key != "" && $key != null) {
                                $content .= "|" . $key . "=" . $element . "\n";
                            }
                        }
                        $content .= $end_text;
                        // Post new content
                        $postdata = http_build_query(array('action' => 'edit', 'pageid' => $id, 'format' => 'json', 'text' => $content, 'token' => get_token()));
                        $page = post_data($postdata);
                        return $page->{'edit'}->{'result'};
                    }
                }
            }
        }
    }
}
Ejemplo n.º 17
0
<?php

//header('Content-type: application/json');
require './../config.php';
require './../functions.php';
if ($_POST == null) {
    exit;
}
if (post_data('adusername') != null and post_data('adpassword') == null) {
    $user = htmlspecialchars($_POST['adusername']);
    $total = count($DB->query("SELECT * FROM ad where user=?", array($user)));
    if ($total == 1) {
        $result = array('valid' => 'true');
    } else {
        $result = array('valid' => 'false');
    }
} else {
    $myusername = $_POST['adusername'];
    $mypassword = $_POST['adpassword'];
    $mypassword = MD5($mypassword . '404notfound');
    $count = count($DB->query("SELECT * FROM ad WHERE user=? and pass=?", array($myusername, $mypassword)));
    if ($count == 1) {
        session_start();
        $_SESSION['aduser'] = $myusername;
        $_SESSION['adpass'] = $mypassword;
        $result['message'] = "success";
        // session_register("mypassword");
        //header("location:userpanel.php");
    } else {
        $result['message'] = "errow";
    }
Ejemplo n.º 18
0
function cbrobot_queues()
{
    ?>
	<script type="text/javascript" src="<?php 
    bloginfo('wpurl');
    ?>
/wp-content/plugins/cbrobot/js/jquery.js"></script>
	<script type="text/javascript" src="<?php 
    bloginfo('wpurl');
    ?>
/wp-content/plugins/cbrobot/js/jquery.validate.js"></script>
<?php 
    global $wpdb;
    $options = unserialize(get_option("cbrobot_options"));
    if ($_POST['cbrobot_create_queue_save']) {
        $error = array();
        $blog_id = $_POST['cbrobot_bg_id'];
        $email = $_POST['cbrobot_bg_email'];
        $password = $_POST['cbrobot_bg_password'];
        $url = $_POST['cbrobot_bg_url'];
        $asin = $_POST['cbrobot_aa_asin'];
        if (!$blog_id) {
            echo '<div class="error"><p>***กรุณากรอก Blog Id***</p></div>';
            $error[] = "E_ID";
        }
        if (!$email) {
            echo '<div class="error"><p>***กรุณากรอก Email***</p></div>';
            $error[] = "E_EMAIL";
        }
        if (!$password) {
            echo '<div class="error"><p>***กรุณากรอก Password***</p></div>';
            $error[] = "E_PASSWORD";
        }
        if (!$url) {
            echo '<div class="error"><p>***กรุณากรอก URL***</p></div>';
            $error[] = "E_URL";
        }
        if (!$asin) {
            echo '<div class="error"><p>***กรุณากรอก Asin***</p></div>';
            $error[] = "E_ASIN";
        }
        if (count($error) == 0) {
            require_once "lib/content.php";
            require_once "lib/xmlrpc.php";
            $param = array();
            /* Load XML Template Config */
            $config = simplexml_load_file(ABSPATH . "/wp-content/plugins/cbrobot/template.xml");
            $title = base64_decode($config->title);
            $content = base64_decode($config->content);
            $client = new IXR_Client('http://www.channgamsim.com/xmlrpc.php');
            $params = array(0, $options['cbrobot_username'], $options['cbrobot_password'], $options['cbrobot_aa_affkey'], $options['cbrobot_aa_apikey'], $options['cbrobot_aa_secretkey'], $asin);
            if (!$client->query('demo.test', $params)) {
                echo '<div class="error">***' . $client->getErrorCode() . ' : ' . $client->getErrorMessage() . '***</div>';
            } else {
                $obj_content = new Content();
                $val = $client->message->params[0][Items][Item];
                $title = $obj_content->getXML($val, $title, $keyword);
                $content = $obj_content->getXML($val, $content, $keyword);
                $title = Content::spin_content($title);
                $content = Content::spin_content($content);
                $sql = "INSERT INTO " . $wpdb->prefix . "cbrobot_queues (blog_id, blog_email, blog_password, blog_url, asin, title, content, queue_time)\r\n\t\t\t            VALUES ('" . trim($blog_id) . "','" . trim($email) . "','" . trim($password) . "','" . trim($url) . "','" . trim($asin) . "',\r\n\t\t\t\t\t\t        '" . trim(base64_encode($title)) . "','" . trim(base64_encode($content)) . "','" . time() . "');";
                if ($result = $wpdb->query($sql)) {
                    echo '<div class="updated"><p>' . __('Insert Queue.', 'cbrobot') . '</p></div>';
                } else {
                    echo '<div class="error">***Not Insert Data' . $result . '***</div>';
                }
            }
        } else {
            ?>
			<script type="text/javascript" > 
				       $().ready(function() {
							$("#cbrobot_bg_id").val('<?php 
            echo $blog_id;
            ?>
');
							$("#cbrobot_bg_email").val('<?php 
            echo $email;
            ?>
');
							$("#cbrobot_bg_password").val('<?php 
            echo $password;
            ?>
');
							$("#cbrobot_bg_url").val('<?php 
            echo $url;
            ?>
');
							$("#cbrobot_aa_asin").val('<?php 
            echo $asin;
            ?>
');
			           });
			</script>
			<?php 
        }
    }
    if ($_GET['postdata']) {
        $id = $_GET['postdata'];
        post_data($id);
    }
    if ($_GET['delete']) {
        $id = $_GET['delete'];
        delete_data($id);
    }
    include_once "display-queues.php";
}
Ejemplo n.º 19
0
Archivo: index.php Proyecto: d42f/s-eng
<?php

require_once '../../db.php';
header('Content-Type: application/json');
$fields = array('name', 'birthday', 'email', 'level');
$types = array('string', 'date', 'string', 'string');
$data = null;
switch ($_SERVER['REQUEST_METHOD']) {
    case 'POST':
        $data = post_data('learners', $fields, $types);
        break;
    case 'PUT':
        if (isset($_REQUEST['id'])) {
            $data = put_relations_data($_REQUEST['id'], 'relations', 'learner_id', 'teacher_id');
        }
        break;
    case 'DELETE':
        $data = delete_data('learners');
        break;
    default:
        if (isset($_REQUEST['teacher_id'])) {
            $data = get_data_by_relate_id('teachers', 'learners', 'teacher_id', 'learner_id', $_REQUEST['teacher_id']);
            break;
        }
        $data = get_data('learners', array('id', 'name', 'birthday', 'email', 'level'), 'learner_id', 'teacher_id');
        break;
}
if (is_null($data)) {
    http_response_code(400);
    die;
}
Ejemplo n.º 20
0
	    'ric' => 'CNCBRR=ECI',
	    'CF_YIELD' => 0.0,
	    'CF_CLOSE' => 0.0,
	    'CF_LAST' => 17.5,
	    'country' => '中国',
	    'title' => '中国存款准备金率',
	    'right' => 5 
	   );
*/
#提交post数据
include_once 'post_data.php';
#print_r($re_list);
#($title, $before, $prediction, $result, $country, $rank=1)
if ('' != $re_list['GN_TXT16_4'] && '' != $re_list['SEC_ACT_1']) {
    echo 'jim-test';
    post_data($re_list['title'], $re_list['CTBTR_1'], $re_list['SEC_ACT_1'], $re_list['GN_TXT16_4'], $re_list['country'], $re_list['right']);
    echo 'commit_net<br/>';
    //print_r(post_data($re_list['title'], $re_list['HTS_CLOSE2'], $re_list['SEC_YLD_1'], $re_list['CF_LAST'], $re_list['country'], $re_list['right']));
}
file_put_contents('ric_index.log', ($ric_index + 1) % $max);
$r_url = REDIRECT_URL;
if ($ric_index < MAX_DATA_COUNT || 0 == $ric_index) {
    sleep(10);
    #$url = "http://bbs.lampbrother.net";
    echo "<script language='javascript' \n    type='text/javascript'>";
    echo "window.location.href='{$r_url}'";
    echo "</script>";
    #header("location:http://localhost/sample_api/cnglod/redirect.php");
} else {
    echo '跑结束';
}
 function set_remark()
 {
     $map['uid'] = I('uid', 0, 'intval');
     if (empty($map['uid'])) {
         $this->error('用户信息出错');
     }
     $param['remark'] = I('remark');
     if (empty($param['remark'])) {
         $this->error('备注不能为空');
     }
     $map['token'] = get_token();
     $info = M('public_follow')->where($map)->find();
     if (!$info) {
         $this->error('用户信息出错啦');
     }
     $res = M('public_follow')->where($map)->save($param);
     if ($res !== false) {
         // 同步到微信端
         D('Common/User')->getUserInfo($map['uid'], true);
         if (C('USER_REMARK')) {
             $url = 'https://api.weixin.qq.com/cgi-bin/user/info/updateremark?access_token=' . get_access_token();
             $param['openid'] = $info['openid'];
             $result = post_data($url, $param);
             if ($res['errcode'] != 0) {
                 $this->error(error_msg($res));
             }
         }
     } else {
         $this->error('保存数据库失败');
     }
     $this->success('设置成功');
 }
Ejemplo n.º 22
0
 function syc_user()
 {
     $map['token'] = $map2['token'] = $map5['token'] = get_token();
     $map['syc_status'] = 0;
     $list = M('public_follow')->where($map)->field('uid,openid')->limit(100)->select();
     if (empty($list)) {
         $this->success('用户分组信息同步中', U('syc_user_group'));
         exit;
     }
     foreach ($list as $vo) {
         $param['user_list'][] = array('openid' => $vo['openid'], 'lang' => 'zh-CN');
         $openids[] = $vo['openid'];
         $uids[$vo['openid']] = $vo['uid'];
     }
     // 先把关注状态设置未关注
     $map2['openid'] = array('in', $openids);
     M('public_follow')->where($map2)->setField('has_subscribe', 0);
     $url = 'https://api.weixin.qq.com/cgi-bin/user/info/batchget?access_token=' . get_access_token();
     $data = post_data($url, $param);
     $userDao = D('Common/User');
     $config = getAddonConfig('UserCenter');
     foreach ($data['user_info_list'] as $u) {
         if ($u['subscribe'] == 0) {
             continue;
         }
         $uid = intval($uids[$u['openid']]);
         if ($uid == 0) {
             // 新增加的用户
             $u['experience'] = intval($config['experience']);
             $u['score'] = intval($config['score']);
             $u['reg_time'] = $u['subscribe_time'];
             $u['status'] = 1;
             $u['is_init'] = 1;
             $u['is_audit'] = 1;
             $uid = D('Common/User')->addUser($u);
             $map5['openid'] = $u['openid'];
             $uid > 0 && M('public_follow')->where($map5)->setField('uid', $uid);
         } else {
             // 更新的用户
             $userDao->updateInfo($uid, $u);
         }
         $openidArr[] = $u['openid'];
     }
     M('public_follow')->where($map2)->setField('syc_status', 1);
     // 设置关注状态
     if (!empty($openidArr)) {
         $map2['openid'] = array('in', $openidArr);
         M('public_follow')->where($map2)->setField('has_subscribe', 1);
     }
     $this->success('同步用户数据中,请勿关闭', U('syc_user?uid=' . $uid));
 }
Ejemplo n.º 23
0
 function _autoUpdateUser()
 {
     // 获取openid列表
     $url = 'https://api.weixin.qq.com/cgi-bin/user/get?access_token=' . get_access_token();
     // 只取第一页数据
     $data = wp_file_get_contents($url);
     $data = json_decode($data, true);
     if (!isset($data['count']) || $data['count'] == 0) {
         return false;
     }
     $map['openid'] = array('in', $data['data']['openid']);
     $map['token'] = $save['token'] = get_token();
     $openids = M('public_follow')->where($map)->getFields('openid');
     $diff = array_diff((array) $data['data']['openid'], (array) $openids);
     if (empty($diff)) {
         // 没有需要同步的用户
         return false;
     }
     foreach ($diff as $oid) {
         $param['user_list'][] = array('openid' => $oid, 'lang' => 'zh-CN');
         $openids[] = $oid;
     }
     $url = 'https://api.weixin.qq.com/cgi-bin/user/info/batchget?access_token=' . get_access_token();
     $data = post_data($url, $param);
     if (empty($data['user_info_list'])) {
         return false;
     }
     $userDao = D('Common/User');
     $config = getAddonConfig('UserCenter');
     if (isset($_GET['test'])) {
         dump($config);
         exit;
     }
     foreach ($data['user_info_list'] as $u) {
         if ($u['subscribe'] == 0) {
             continue;
         }
         $u['experience'] = intval($config['experience']);
         $u['score'] = intval($config['score']);
         $u['reg_time'] = $u['subscribe_time'];
         $u['status'] = 1;
         $u['is_init'] = 1;
         $u['is_audit'] = 1;
         $uid = D('Common/User')->addUser($u);
         $save['openid'] = $u['openid'];
         $save['uid'] = $uid;
         $save['syc_status'] = 2;
         $save['has_subscribe'] = 1;
         $res = M('public_follow')->add($save);
     }
 }
Ejemplo n.º 24
0
function addWeixinLog($data, $data_post = '', $wechat = false)
{
    $log['cTime'] = time();
    $log['cTime_format'] = date('Y-m-d H:i:s', $log['cTime']);
    $log['data'] = is_array($data) ? serialize($data) : $data;
    $log['data_post'] = is_array($data_post) ? serialize($data_post) : $data_post;
    M('weixin_log')->add($log);
    // 通过微信客服接口直接回复调试信息
    if ($wechat) {
        $url = 'https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=' . get_access_token();
        $param['touser'] = get_openid();
        $param['msgtype'] = 'text';
        $param['text']['content'] = 'data: ' . $log['data'] . '<br/> data_post: ' . $log['data_post'];
        post_data($url, $param);
    }
}
 function _sucai_media_info()
 {
     $type = I('msg_type');
     $content = I('content');
     $appmsg_id = I('appmsg_id');
     // $image = I ( 'image' );
     if ($type == 'text') {
         if (empty($content)) {
             $this->error('文本内容不能为空');
         }
         $res['media_id'] = $content;
         $res['msgtype'] = 'text';
         $_POST['content'] = $content;
     } else {
         if ($type == 'appmsg') {
             if (empty($appmsg_id)) {
                 $this->error('图文素材不能为空');
             }
             $res['media_id'] = D('Home/Material')->getMediaIdByGroupId($appmsg_id);
             $_POST['media_id'] = $res['media_id'];
             $res['msgtype'] = 'mpnews';
         } else {
             if ($type == 'voice') {
                 $voice = I('voice_id');
                 if (empty($voice)) {
                     $this->error('语音素材不能为空');
                 }
                 $file = M('material_file')->find($voice);
                 if ($file['media_id']) {
                     $res['media_id'] = $file['media_id'];
                 } else {
                     $res['media_id'] = D('Common/Custom')->get_file_media_id($file['file_id'], 'voice');
                 }
                 $res['msgtype'] = 'voice';
             } else {
                 if ($type == 'video') {
                     $video = I('video_id');
                     if (empty($video)) {
                         $this->error('视频素材不能为空');
                     }
                     $file = M('material_file')->find($video);
                     if ($file['media_id']) {
                         $mediaId = $file['media_id'];
                     } else {
                         $mediaId = D('Common/Custom')->get_file_media_id($file['file_id'], 'video');
                     }
                     $data['media_id'] = $mediaId;
                     $data['title'] = $file['title'];
                     $data['description'] = $file['introduction'];
                     $url1 = "https://file.api.weixin.qq.com/cgi-bin/media/uploadvideo?access_token=" . get_access_token();
                     $result = post_data($url1, $data);
                     $res['media_id'] = $result['media_id'];
                     $res['msgtype'] = 'mpvideo';
                 }
             }
         }
     }
     $_POST['msgtype'] = $res['msgtype'];
     return $res;
 }
Ejemplo n.º 26
0
include_once '../includes/func_gen_urls.php';
include_once '../includes/all_html.php';
//
//set up variables
if (isset($_POST['userurl'])) {
    $myCapURL = GetCapURL($_POST['userurl'], $CapString);
    session_start();
    $_SESSION['rawURL'] = $_POST['userurl'];
    $_SESSION['myCapURL'] = $myCapURL;
    //to store URL as an session variable
    //1. GetCapabilities
    $getCstring = '';
    //
    echo "<p><b> Select Sensors to View Observations </b></p>";
    // use post_data function to post xml string and catch response
    $output = post_data($myCapURL, $getCstring);
    if ($output) {
        //print_r($output);
        // func from func_parse_cap 3.
        // a. offering
        $offering = array('ObservationOffering', 'gml:id');
        $myOffering = getOffering($output, $offering);
        $myCurrentOffering = $myOffering[0]['ObservationOffering'];
        //$myCleanOff = cleanOff($myOffering);
        echo "<p>Offering : " . $myCurrentOffering . "</p>";
        //print_r($myCleanOff);
        // b. eventTime
        $timePosition = array('beginPosition', 'endPosition');
        $myBeginTime = getTime($output, $timePosition[0]);
        $FrmT = getTimeSeperated($myBeginTime[0]['beginPosition']);
        //print_r($myBeginTime);
Ejemplo n.º 27
0
        $result = array('valid' => 'true');
    } else {
        $result = array('valid' => 'false');
    }
}
//exit user
if (post_data('email') != NULL) {
    $email = htmlspecialchars($_POST['email']);
    $total = count($DB->query("SELECT * FROM user WHERE email=?", array($email)));
    if ($total != 1) {
        $result = array('valid' => 'true');
    } else {
        $result = array('valid' => 'false');
    }
}
if (post_data('password')) {
    $total == 0;
    //检查是否有相同用户
    // $sqlemail="SELECT * FROM user WHERE email='$email'";
    $pass = htmlspecialchars($_POST['password']);
    $total = count($DB->query("SELECT * FROM user WHERE email=?", array($email)));
    if ($total == 0) {
        //更新注册码状态
        $time = date('y-m-d h:i:s', time());
        // $status=$DB->query("select * from gift where number = ?", array($code));
        $DB->query("UPDATE gift SET status =? , usetime=? WHERE number=?", array(0, $time, $code));
        //密码加密处理
        $pass = MD5($pass . '404notfound');
        //创建随机端口 并且给定6位随机密码
        $port = rand($portwidth[0], $portwidth[1]);
        $ranpass = rand(100000, 999999);
Ejemplo n.º 28
0
 /**
  * 发布菜单到微信
  */
 public function send_menu()
 {
     $list = D('Menu')->init(get_token());
     $send_list = $this->json_menu($list);
     //删除菜单
     $access_token = get_access_token();
     file_get_contents('https://api.weixin.qq.com/cgi-bin/menu/delete?access_token=' . $access_token);
     //发送菜单
     $url = 'https://api.weixin.qq.com/cgi-bin/menu/create?access_token=' . $access_token;
     $res = post_data($url, $send_list);
     if ($res['errcode'] == 0) {
         $this->success('发送菜单成功');
     } else {
         $this->error(error_msg($res));
     }
 }
Ejemplo n.º 29
0
 function get_thumb_media_id($path = '')
 {
     // 	    $cover = get_cover ( $cover_id );
     // 	    $driver = C ( 'PICTURE_UPLOAD_DRIVER' );
     // 	    if ($driver != 'Local' && ! file_exists ( SITE_PATH . $cover ['path'] )) { // 先把图片下载到本地
     // 	        $pathinfo = pathinfo ( SITE_PATH . $cover ['path'] );
     // 	        mkdirs ( $pathinfo ['dirname'] );
     // 	        $content = wp_file_get_contents ( $cover ['url'] );
     // 	        $res = file_put_contents ( SITE_PATH . $cover ['path'], $content );
     // 	        if (! $res) {
     // 	            return 0;
     // 	        }
     // 	    }
     // 	    $path = $cover ['path'];
     if (!$path) {
         $path = '/Public/Home/images/spec_img_add.jpg';
     }
     $param['type'] = 'thumb';
     $param['media'] = '@' . realpath(SITE_PATH . $path);
     $url = 'https://api.weixin.qq.com/cgi-bin/media/upload?access_token=' . get_access_token();
     $res = post_data($url, $param, true);
     if (isset($res['errcode']) && $res['errcode'] != 0) {
         return 0;
     }
     return $res['thumb_media_id'];
 }
Ejemplo n.º 30
0
<?php

$handle = fopen("input.txt", "r");
if ($handle) {
    while (($buffer = fgets($handle, 4096)) !== false) {
        echo "<p>{$buffer}<p>";
        if (strpos($buffer, "bkk") === false) {
            get_data($buffer);
        } else {
            $pos = strpos($buffer, '?');
            $url = substr($buffer, 0, $pos);
            $post_data = substr($buffer, $pos + 1);
            post_data($url, $post_data);
        }
        echo "<p>-------------------- end ----------------------<p>";
    }
    if (!feof($handle)) {
        echo "Error: unexpected fgets() fail\n";
    }
    fclose($handle);
}
function post_data($url, $data_string)
{
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($curl, CURLOPT_POSTFIELDS, $data_string);
    curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: text/xml', 'Content-Length: ' . strlen($data_string)));
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    $data = curl_exec($curl);
    curl_close($curl);