public function permission() { session_start(); $infoarr = @$_SESSION['user']; $media_id = @$_GET['media_id']; $Token1 = @$_GET['Token']; $type = @$_GET['ask_method']; if ($infoarr['openid'] != "") { if ($media_id == "") { $Token2 = ""; } else { include "../cache/" . $media_id . ".php"; $Token2 = $Token['token']; } if ($Token1 == $Token2 && $Token1 != "" && $Token2 != "") { $media_url = "http://weixin.faeries-land.com/uploadfile/" . $media_id . ".mp3"; $data = array('media_id' => "{$media_id}", 'media_url' => $media_url); $code = 0; $msg = "success!"; api_response::api_method($type, $code, $msg, $data); } else { $code = -1; $msg = "error:permission denied!"; $data = "null"; api_response::api_method($type, $code, $msg, $data); } } else { $code = -1; $msg = "error:You have to use wechat app to open! "; $data = "null"; api_response::api_method($type, $code, $msg, $data); } }
/** * Tests retrieval of a non-existing URL. */ function testInvalidGet() { $this->get('/something/def'); $this->assertEqual(api_response::getInstance()->getCode(), 404); $this->assertText('/error/code', '100'); $this->assertText('/error/msg', 'Bucket not defined: something'); }
public function permission() { session_start(); $media_id = @$_GET['media_id']; $Token1 = @$_GET['Token']; $type = @$_GET['ask_method']; if ($media_id == "") { $Token2 = ""; } else { include "./cache/" . $media_id . ".php"; $Token2 = $Token['token']; } if ($Token1 == $Token2 && $Token1 != "" && $Token2 != "") { $media_url = "http://card.sky31.com/recordings/" . $media_id . ".mp3"; $data = array('media_id' => "{$media_id}", 'media_url' => $media_url); $code = 0; $msg = "success!"; api_response::api_method($type, $code, $msg, $data); } else { $code = -1; $msg = "error:permission denied!"; $data = "null"; api_response::api_method($type, $code, $msg, $data); } }
public function get_status() { $UserID = $_POST['UserID']; $status = $_POST['status']; $type = $_GET['ask_method']; $res = new dbconnect(); $sql = "select* from users where UserName='******'"; $row = $res->connect($sql); if ($UserID == "" || $status == "") { $code = "409"; $msg = "error:UserID or status can not be empty!"; $data = "null"; $result = api_response::api_method($type, $code, $msg, $data); return $result; } else { if ($row['status'] == $status && $status != "") { $code = "200"; $msg = "success!"; $data = array('id' => "{$row['id']}", 'UserID' => "{$row['UserName']}", 'openid' => "{$row['openid']}", 'nickname' => "{$row['nickname']}", 'headimgurl' => "{$row['headimgurl']}", 'sex' => "{$row['sex']}", 'mobile' => "{$row['mobile']}"); $result = api_response::api_method($type, $code, $msg, $data); } else { $code = "406"; $msg = "error:Failure login status!"; $data = "null"; $result = api_response::api_method($type, $code, $msg, $data); } return $result; } }
/** * HEAD on an asset file. */ function testAssetFile() { $this->upload(); $this->head('/test/09/096dfa489bc3f21df56eded2143843f135ae967e/index.xml'); $response = api_response::getInstance(); $this->assertEqual($response->getCode(), 200); $this->assertEqual('', $response->getContents()); }
/** * Check that the asset is actually deleted. */ function testDeleteAssetCheckDeleted() { $this->testDeleteAsset(); try { $this->get('/test/09/096dfa489bc3f21df56eded2143843f135ae967e/index.xml'); } catch (api_testing_exception $e) { // pass - not expecting response XML } $response = api_response::getInstance(); $this->assertEqual($response->getCode(), 404); }
/** * Override OKAPI implementation with one that raises exceptions * on empty XML */ protected function loadResponse() { $response = api_response::getInstance(); $resp = $response->getContents(); if (empty($resp)) { throw new api_testing_exception("Empty response document"); } $dom = new DOMDocument(); if (!$dom->loadXML($resp)) { throw new api_testing_exception(sprintf("Unable to load XML: '%s'", $resp)); } $this->responseDom = $dom; }
function __construct() { try { $this->request = api_request::getInstance(); // echo "<pre>"; // print_r( $this->request); $this->response = api_response::getInstance(); $this->loadRoutes(); } catch (api_exception $e) { $this->catchFinalException($e); } catch (Exception $e) { $this->catchFinalException($e); } }
public function show($row, $type) { $data = array('media_id' => "{$row['media_id']}", 'title' => "{$row['title']}", 'content' => "{$row['content']}", 'create_at' => "{$row['create_at']}", 'From_nickname' => "{$row['From_nickname']}", 'To_nickname' => "{$row['To_nickname']}", 'code_url' => "http://weixin.faeries-land.com/code_img/" . $row['media_id'] . ".png"); if (empty($row)) { $code = -1; $msg = "error:The info not exist! "; $data = "null"; $result = api_response::api_method($type, $code, $msg, $data); } else { $code = 0; $msg = "success!"; $result = api_response::api_method($type, $code, $msg, $data); } return $result; }
public static function get_info() { $UserName = $_POST['UserName']; $PassWord = $_POST['PassWord']; $appID = $_GET['appID']; $type = $_GET['ask_method']; if ($UserName == "" || $PassWord == "") { $code = "409"; $msg = "error:UserName or password can not be empty!"; $data = "null"; $result = api_response::api_method($type, $code, $msg, $data); return $result; } else { $sql = "select*from users where UserName='******'"; $row = new dbconnect(); $row = $row->connect($sql); if (empty($row)) { $code = "404"; $msg = "error:The user does not exist!"; $data = "null"; $result = api_response::api_method($type, $code, $msg, $data); } else { $sql = "select*from users where UserName='******'&& PassWord='******' "; //$row=dbconnect::getInstance()->connect($sql); $row = new dbconnect(); $row = $row->connect($sql); $data = array('id' => "{$row['id']}", 'UserID' => "{$row['UserName']}", 'openid' => "{$row['openid']}", 'nickname' => "{$row['nickname']}", 'headimgurl' => "{$row['headimgurl']}", 'sex' => "{$row['sex']}", 'mobile' => "{$row['mobile']}"); if (empty($row)) { $code = "403"; $msg = "error:Incorrect password!"; $data = "null"; $result = api_response::api_method($type, $code, $msg, $data); } else { $code = "200"; $msg = "success!"; define("STR_MD", "23nbhjfdb#%#^A!~"); $status = md5($row['UserName'] . $row['PassWord'] . STR_MD . time()); $UserName = $row['UserName']; $result = new status(); $result->login_info($UserName, $status, $appID); $result = api_response::api_method($type, $code, $msg, $data); } } return $result; } }
public function show_receive() { $infoarr = @$_SESSION['user']; $type = @$_GET['ask_method']; $sql = "select*from card where to_openid='{$infoarr['openid']}'"; $result = new dbconnect(); $row = $result->connect($sql); if (empty($row)) { $code = -1; $msg = "error:The info not exist! "; $data = "null"; $result = api_response::api_method($type, $code, $msg, $data); } else { while ($row = $result->connect($sql)) { $data = array('media_id' => "{$row['media_id']}", 'title' => "{$row['title']}", 'content' => "{$row['content']}", 'create_at' => "{$row['create_at']}", 'From_nickname' => "{$row['From_nickname']}", 'To_nickname' => "{$row['To_nickname']}", 'code_url' => "http://weixin.faeries-land.com/card/ask_cardinfo.php?media_id={$row['media_id']}"); $code = 0; $msg = "success!"; $result = api_response::api_method($type, $code, $msg, $data); } } return $result; }
/** * Touch the asset with a valid custom expiry date and make * sure the views are updated. */ function testTouchWithCustomExpiryDate() { $this->testDefaultExpiry(); // Touch with 3 days expiry date try { $this->post('/test/09/096dfa489bc3f21df56eded2143843f135ae967e/index.xml', array('TTL' => '3')); } catch (api_testing_exception $e) { // pass - not expecting response XML } $response = api_response::getInstance(); $this->assertEqual($response->getCode(), 204); $this->assertEqual('', $response->getContents()); // Check that old view is gone $date = date('Y/m/d', time() + 7 * 24 * 60 * 60); $this->head('/test/expiry/' . $date . '/096dfa489bc3f21df56eded2143843f135ae967e/index.xml'); $response = api_response::getInstance(); $this->assertEqual($response->getCode(), 404); // Check that new view is valid $date = date('Y/m/d', time() + 3 * 24 * 60 * 60); $this->head('/test/expiry/' . $date . '/096dfa489bc3f21df56eded2143843f135ae967e/index.xml'); $response = api_response::getInstance(); $this->assertEqual($response->getCode(), 200); }
public function submit() { $type = @$_GET['ask_method']; $dir = dirname(__FILE__) . "/media/"; $filename1 = @$_POST['school_no'] . ".mp3"; $filename2 = @$_POST['school_no'] . ".wav"; $name = @$_POST['name']; $school_no = @$_POST['school_no']; $mobile = @$_POST['mobile']; $qq = @$_POST['qq']; $school = @$_POST['school']; $sex = @$_POST['sex']; $media_type = @$_POST['media_type']; $interesting = @$_POST['interesting']; $learn = @$_POST['learn']; //$media_url="http://weixin.faeries-land.com/multimedia/media/".@$_POST['upfile']; $used = @$_POST['used']; $other = @$_POST['other']; $create_at = date("Y-m-d H:i:s"); if (file_exists($dir . $filename1) || file_exists($dir . $filename2)) { $sql = "insert into media(name,school_no,mobile,qq,school,sex,media_type,interesting,learn,status,used,other,create_at)\n values('{$name}','{$school_no}','{$mobile}','{$qq}','{$school}','{$sex}','{$media_type}','{$interesting}','{$learn}','','{$used}','{$other}','{$create_at}') "; $conn = new mysqli(HOST, UserName, PassWord, DataBase); $conn->query("set names UTF8"); $result = $conn->query($sql); if ($result) { $sql = "select* from media where school_no='{$_POST['school_no']}' order by create_at desc "; $result = $conn->query($sql); $row = $result->fetch_array(); if ($row) { $code = 0; $msg = "success!"; $data = array('UserID' => "{$row['UserID']}", 'name' => "{$row['name']}", 'school_no' => "{$row['school_no']}", 'mobile' => "{$row['mobile']}", 'qq' => "{$row['qq']}", 'school' => "{$row['school']}", 'sex' => "{$row['sex']}", 'interesting' => "{$row['interesting']}", 'learn' => "{$row['learn']}", 'status' => "{$row['status']}", 'used' => "{$row['used']}", 'other' => "{$row['other']}"); api_response::api_method($type, $code, $msg, $data); } } else { $code = -1; $msg = "error:Database Exceptions!"; $data = "null"; api_response::api_method($type, $code, $msg, $data); } } else { $code = -1; $msg = "error:File not uploaded!"; $data = "null"; api_response::api_method($type, $code, $msg, $data); } }
public function show_info() { $type = @$_GET['ask_method']; $sql = "select*from card where openid='{$infoarr['openid']}'"; $result = new dbconnect(); $row = $result->connect($sql); if ($row) { $code = 0; $msg = "success!"; $data = array('media_id' => "{$row['media_id']}"); api_response::api_method($type, $code, $msg, $data); } else { $code = -1; $msg = "error:The info not exist!"; $data = "null"; api_response::api_method($type, $code, $msg, $data); } }
/** * Tests if we get a correct error for a hash which does not exist. * This test goes to the directory instead of the asset file. */ function testHeadNonexistingDirectoryHash() { $this->head('/test/sha1/abcdefghijklmnopqrstuvwxyzabcdefghijklmn'); $response = api_response::getInstance(); $this->assertEqual($response->getCode(), 404); $this->assertEqual('', $response->getContents()); }
/** * Tests that the correct rendition is saved. */ function testUploadRenditionVerify() { $this->testUploadRendition(); $this->get('/test/cb/cbf9f9f453acaba556e00b48951815da5611f975/index.xml'); $this->assertEqual(api_response::getInstance()->getCode(), 200); $localHash = sha1_file(dirname(__FILE__) . '/../res/vw_golf_blur.jpg'); $remoteFile = $this->getText('/registry/items/item[rendition="detailpage"]/location'); $remoteHash = sha1_file(binarypool_config::getRoot() . '/' . $remoteFile); $this->assertEqual($localHash, $remoteHash); }