/** * Creates a new Hwboxfw model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { // preparing for file upload to sae storage $s2 = new SaeStorage(); $model = new Hwboxfw(); if ($model->load(Yii::$app->request->post())) { // get the instance of the uploaded file $model->file = UploadedFile::getInstance($model, 'file'); //$model->file = $s2->inputFile(UploadedFile::getInstance($model,'file')); //$model->file = $s2->inputFile($file); // 上传一个文件 //Storage::putObject(Storage::inputFile($file), $bucketName, $uploadName) $imageName = $model->file->name; //keep original file name in server $tempName = $model->file->tempName; $fileSize = $model->file->size; //$model->file->saveAs('uploads/'.$imageName.'.'.$model->file->extension ); // save file in server with same extension // $name = $_FILES['file'][$imageName]; // $s2->upload('uploads',$name,$_FILES['file']['tmp_name']); $bucketName = 'uploads'; //$model->file to be investigated //$bucketName and $imageName is CORRECT; //$s2->putObject($model->file, $bucketName, $imageName); //此行语句仅仅将$_FILES的各种属性记录下来保存到文件里,文件实际内容丢失 //$dumpdata = file_get_contents($_FILES["file"]["tmp_name"]); //$dowLoadUrl = $stor->write($domain,$fileDataName,$dumpdata);//用write就行了 $dumpdata = file_get_contents($tempName); $inputFile = $s2->inputFile($tempName); $s2->putObject($inputFile, $bucketName, $imageName); // 上传一个文件的用法,但在yii/web/UploadedFile中,只有对其属性的操作,可能还是需要用COPY的方法从TEMP_NAME到目的地目录 //Storage::putObject(Storage::inputFile($file), $bucketName, $uploadName) //var_dump($model->file); /// var_dump($_FILES); //save the path in the db column $model->file_path_name = $s2->getUrl("uploads", $imageName); //$model->file = 'uploads/'.$imageName.'.'.$model->file->extension ; //$model->file_path_name = 'uploads/'.$imageName; //$model->date = date('Y-m-d h:m:s'); // save the date and time as a record of input moment $model->save(); //这一步会检查RULES,如果强制REQUIRED,这一步不会成功,那么FWID的自增值就取不到,后面redirect出错 return $this->redirect(['view', 'id' => $model->FWID]); } else { return $this->render('create', ['model' => $model]); } }
public function getUrl() { header("Content-type:text/html;charset=utf-8"); Storage::setAuth('gxmty:zlkmj4x530', '5i4ikkiy24yky2mzy4kh5j1440z2mx40i5im2x4x'); $fileList = Storage::getBucket('buptfile'); $fileNum = count($fileList); $this->fileList = $fileList; $this->num = $fileNum; $this->display(); //dump($fileList); }
function saePutObjectFile($tmpFile, $bucket, $uri) { $s = new Storage(); $s->putObjectFile($tmpFile, $bucket, $uri); $s->setExceptions(true); }
$rs = mysqli_query($link_r, "select * from xyh_pv where time=16&&day=1 ;"); $rs = mysqli_fetch_array($rs); $pv116 = $rs['pv']; $rs = mysqli_query($link_r, "select * from xyh_pv where time=17&&day=1 ;"); $rs = mysqli_fetch_array($rs); $pv117 = $rs['pv']; $rs = mysqli_query($link_r, "select * from xyh_pv where time=18&&day=1 ;"); $rs = mysqli_fetch_array($rs); $pv118 = $rs['pv']; $rs = mysqli_query($link_r, "select * from xyh_pv where time=19&&day=1 ;"); $rs = mysqli_fetch_array($rs); $pv119 = $rs['pv']; $rs = mysqli_query($link_r, "select * from xyh_pv where time=20&&day=1 ;"); $rs = mysqli_fetch_array($rs); $pv120 = $rs['pv']; $rs = mysqli_query($link_r, "select * from xyh_pv where time=21&&day=1 ;"); $rs = mysqli_fetch_array($rs); $pv121 = $rs['pv']; $rs = mysqli_query($link_r, "select * from xyh_pv where time=22&&day=1 ;"); $rs = mysqli_fetch_array($rs); $pv122 = $rs['pv']; $rs = mysqli_query($link_r, "select * from xyh_pv where time=23&&day=1 ;"); $rs = mysqli_fetch_array($rs); $pv123 = $rs['pv']; $fpdata = "\n\t\t\tvar Charts = function () {\n\t\t\treturn { //main function to initiate the module\n\t\t\t\tinit: function () {\n\t\t\t\t\tApp.addResponsiveHandler(function () {\n\t\t\t\t\t\tCharts.initPieCharts(); \n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\tinitCharts: function () {\n\t\t\t\t\tif (!jQuery.plot) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tvar data = [];\n\t\t\t\t\tvar totalPoints = 250; // random data generator for plot charts\n\t\t\t\t\tfunction getRandomData() {\n\t\t\t\t\t\tif (data.length > 0) data = data.slice(1); // do a random walk\n\t\t\t\t\t\twhile (data.length < totalPoints) {\n\t\t\t\t\t\t\tvar prev = data.length > 0 ? data[data.length - 1] : 50;\n\t\t\t\t\t\t\tvar y = prev + Math.random() * 10 - 5;\n\t\t\t\t\t\t\tif (y < 0) y = 0;\n\t\t\t\t\t\t\tif (y > 100) y = 100;\n\t\t\t\t\t\t\tdata.push(y);\n\t\t\t\t\t\t} // zip the generated y values with the x values\n\t\t\t\t\t\tvar res = [];\n\t\t\t\t\t\tfor (var i = 0; i < data.length; ++i) res.push([i, data[i]])\n\t\t\t\t\t\treturn res;\n\t\t\t\t\t}\n\t\t\t\t\tfunction chart1() {\n\t\t\t\t\t\tvar pageviews = [\n\t\t\t\t\t\t\t[0,{$pv10}],[1,{$pv11}],[2,{$pv12}],[3, {$pv13}],[4, {$pv14}],[5,{$pv15}],[6, {$pv16}],[7, {$pv17}],[8, {$pv18}],[9, {$pv19}],[10, {$pv110}],[11, {$pv111}],[12, {$pv112}],[13, {$pv113}],[14, {$pv114}],[15, {$pv115}],[16, {$pv116}],[17, {$pv117}],[18, {$pv118}],[19, {$pv119}],[20, {$pv120}],[21, {$pv121}],[22, {$pv122}],[23, {$pv123}],\n\t\t\t\t\t\t\t];\n\t\t\t\t\t\tvar visitors = [\n\t\t\t\t\t\t\t[0, {$pv00}],[1, {$pv01}],[2,{$pv02}],[3, {$pv03}],[4, {$pv04}],[5, {$pv05}],[6, {$pv06}],[7, {$pv07}],[8, {$pv08}],[9, {$pv09}],[10, {$pv010}],[11, {$pv011}],[12, {$pv012}],[13,{$pv013}],[14, {$pv014}],[15, {$pv015}],[16, {$pv016}],[17, {$pv017}],[18, {$pv018}],[19, {$pv019}],[20, {$pv020}],[21, {$pv021}],[22, {$pv022}],[23, {$pv023}],\n\t\t\t\t\t\t];\n\t\t\t\t\t\tvar plot = \$.plot(\$(\"#chart_1\"), [{\n\t\t\t\t\t\t\tdata: pageviews,\n\t\t\t\t\t\t\tlabel: \"昨日访问量\"\n\t\t\t\t\t\t}, {\n\t\t\t\t\t\t\tdata: visitors,\n\t\t\t\t\t\t\tlabel: \"今日访问量\"\n\t\t\t\t\t\t}], {\n\t\t\t\t\t\t\tseries: {\n\t\t\t\t\t\t\t\tlines: {\n\t\t\t\t\t\t\t\t\tshow: true,\n\t\t\t\t\t\t\t\t\tlineWidth: 2,\n\t\t\t\t\t\t\t\t\tfill: true,\n\t\t\t\t\t\t\t\t\tfillColor: {\n\t\t\t\t\t\t\t\t\t\tcolors: [{\n\t\t\t\t\t\t\t\t\t\t\topacity: 0.05\n\t\t\t\t\t\t\t\t\t\t}, {\n\t\t\t\t\t\t\t\t\t\t\topacity: 0.01\n\t\t\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tpoints: {\n\t\t\t\t\t\t\t\t\tshow: true\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\tshadowSize: 2\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tgrid: {\n\t\t\t\t\t\t\t\thoverable: true,\n\t\t\t\t\t\t\t\tclickable: true,\n\t\t\t\t\t\t\t\ttickColor: \"#eee\",\n\t\t\t\t\t\t\t\tborderWidth: 0\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tcolors: [\"#d12610\", \"#37b7f3\", \"#52e136\"],\n\t\t\t\t\t\t\txaxis: {\n\t\t\t\t\t\t\t\tticks: 11,\n\t\t\t\t\t\t\t\ttickDecimals: 0\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tyaxis: {\n\t\t\t\t\t\t\t\tticks: 11,\n\t\t\t\t\t\t\t\ttickDecimals: 0\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t\tfunction showTooltip(x, y, contents) {\n\t\t\t\t\t\t\t\$('<div id=\"tooltip\">' + contents + '</div>').css({\n\t\t\t\t\t\t\t\tposition: 'absolute',\n\t\t\t\t\t\t\t\tdisplay: 'none',\n\t\t\t\t\t\t\t\ttop: y + 5,\n\t\t\t\t\t\t\t\tleft: x + 15,\n\t\t\t\t\t\t\t\tborder: '1px solid #333',\n\t\t\t\t\t\t\t\tpadding: '4px',\n\t\t\t\t\t\t\t\tcolor: '#fff',\n\t\t\t\t\t\t\t\t'border-radius': '3px',\n\t\t\t\t\t\t\t\t'background-color': '#333',\n\t\t\t\t\t\t\t\topacity: 0.80\n\t\t\t\t\t\t\t}).appendTo(\"body\").fadeIn(200);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tvar previousPoint = null;\n\t\t\t\t\t\t\$(\"#chart_2\").bind(\"plothover\", function (event, pos, item) {\n\t\t\t\t\t\t\t\$(\"#x\").text(pos.x.toFixed(2));\n\t\t\t\t\t\t\t\$(\"#y\").text(pos.y.toFixed(2));\n\t\t\t\t\t\t\tif (item) {\n\t\t\t\t\t\t\t\tif (previousPoint != item.dataIndex) {\n\t\t\t\t\t\t\t\t\tpreviousPoint = item.dataIndex;\n\t\t\t\t\t\t\t\t\t\$(\"#tooltip\").remove();\n\t\t\t\t\t\t\t\t\tvar x = item.datapoint[0].toFixed(2),\n\t\t\t\t\t\t\t\t\t\ty = item.datapoint[1].toFixed(2);\n\t\t\t\t\t\t\t\t\tshowTooltip(item.pageX, item.pageY, item.series.label + \" of \" + x + \" = \" + y);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\$(\"#tooltip\").remove();\n\t\t\t\t\t\t\t\tpreviousPoint = null;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\t//graph\n\t\t\t\t\tchart1();\n\t\t\t\t},\n\t\t\t};\n\t\t}();"; echo SAE_TMP_PATH; file_put_contents(SAE_TMP_PATH . charts . js, "{$fpdata}"); Storage::setAuth('nn33ztwwxwq:zzz041ymx2', '32xlm5ji1404m4yl0hyxz24ilhj50h3lz5ji4hhh'); Storage::deleteObject('publicfile', 'charts.js'); Storage::putObject(Storage::inputFile(SAE_TMP_PATH . charts . js), 'publicfile', 'charts.js'); echo "ok";
<?php // 连主库 $link = mysql_connect(SAE_MYSQL_HOST_M . ':' . SAE_MYSQL_PORT, SAE_MYSQL_USER, SAE_MYSQL_PASS); // 连从库 // $link=mysql_connect(SAE_MYSQL_HOST_S.':'.SAE_MYSQL_PORT,SAE_MYSQL_USER,SAE_MYSQL_PASS); if ($link) { mysql_select_db(SAE_MYSQL_DB, $link); $AllplayerName = $_POST['playerName']; $AllplayerPassWord = $_POST['playerPassWord']; $image = 'http://shadowfax-xiachiquan.stor.sinaapp.com/' . $AllplayerName . "_Avatar" . ".png"; $result = mysql_query("INSERT INTO player_info(AllplayerName,AllplayerAvatar,AllplayerPassWord) VALUES('" . $AllplayerName . "','" . $image . "','" . $AllplayerPassWord . "')"); } ?> <?php use sinacloud\sae\Storage; // 面向对象方式(e,g; $s->getObject(...)): $s = new Storage($AccessKey, $SecretKey); $file = $_FILES['file']['tmp_name']; $bucketName = 'xiachiquan'; $AllplayerName = $_POST['playerName']; $uploadName = $AllplayerName . "_Avatar" . ".png"; // 上传一个文件 Storage::putObject(Storage::inputFile($file), $bucketName, $uploadName);
public function responseMsg() { //get post data, May be due to the different environments $postStr = $GLOBALS["HTTP_RAW_POST_DATA"]; //extract post data if (!empty($postStr)) { /* libxml_disable_entity_loader is to prevent XML eXternal Entity Injection, the best way is to check the validity of xml by yourself */ libxml_disable_entity_loader(true); $postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA); $fromUsername = $postObj->FromUserName; $toUsername = $postObj->ToUserName; $keyword = trim($postObj->Content); $time = time(); //消息类型 $form_MsgType = $postObj->MsgType; //文字消息模板 $textTpl = "<xml>\n\t\t\t\t\t\t\t<ToUserName><![CDATA[%s]]></ToUserName>\n\t\t\t\t\t\t\t<FromUserName><![CDATA[%s]]></FromUserName>\n\t\t\t\t\t\t\t<CreateTime>%s</CreateTime>\n\t\t\t\t\t\t\t<MsgType><![CDATA[%s]]></MsgType>\n\t\t\t\t\t\t\t<Content><![CDATA[%s]]></Content>\n\t\t\t\t\t\t\t<FuncFlag>0</FuncFlag>\n\t\t\t\t\t\t\t</xml>"; //事件消息 if ($form_MsgType == "event") { //获取某一特定事件,这里是订阅事件 $form_event = $postObj->Event; //如果是订阅事件 if ($form_event == "subscribe") { //回复欢迎文字消息 $msgType = "text"; $contentStr = "感谢您关注江大计算机考研![愉快]\n回复数据结构可以获得数据结构有关资料\n回复复试可以获得复试资料\n回复导师可以查看导师信息\n发送位置信息可以获取天气预报\n还可以给我发图片\n有意见可以回复我哦\n平台建设中请见谅![玫瑰]\n by XiJiaxiang"; $resultStr = sprintf($textTpl, $fromUsername, $toUsername, time(), $msgType, $contentStr); echo $resultStr; exit; } } //非文字消息,这里是图片消息 if ($form_MsgType == "image") { //获取图片url $from_PicUrl = $postObj->PicUrl; //创建图片名称 $filename = $fromUsername . date("YmdHis") . ".jpg"; //抓取的图片类, 新浪云平台提供 $saefetch = new SaeFetchurl(); //抓取图片 $PicResource = $saefetch->fetch($from_PicUrl); //没有错误 if ($saefetch->errno() == 0) { //use sinacloud\sae\Storage as Storage; //使用全局变量global 新浪Storage提供。 global $storage; $storage = new Storage(); //写入图片,第一个参数是文件,第二个是bucket(新浪方面)。第三个存储路径 $storage->putObject($PicResource, "********", "wexinPic/" . $filename); //提示上传成功,返回消息给用户 $msgType = "text"; $resultStr = sprintf($textTpl, $fromUsername, $toUsername, time(), $msgType, "收到图片了哦"); echo $resultStr; exit; } else { //提示失败 $msgType = "text"; $resultStr = sprintf($textTpl, $fromUsername, $toUsername, time(), $msgType, "图片上传失败"); echo $resultStr; exit; } } //非文字消息,这里是地理位置信息 if ($form_MsgType == "location") { $from_Location_X = $postObj->Location_X; //经度 echo $from_Location_X; $from_Location_Y = $postObj->Location_Y; //纬度 echo $from_Location_Y; $from_Location_Scale = $postObj->Scale; //地图缩放信息 $from_Location_Label = $postObj->Label; //地址信息 //使用百度地图api解析地址 //example //http://api.map.baidu.com/geocoder/v2/?ak=E4805d16520de693a3fe707cdc962045&callback=renderReverse&location=39.983424,1//16.322987&output=json&pois=1 $map_api_url = "http://api.map.baidu.com/geocoder/v2/?"; //坐标类型 $map_coord_type = "coordtype=wgs84ll"; $ak = "ak=****************************"; //建立抓取对象 $fetch = new SaeFetchurl(); //抓取返回的xml文件,也可以利用json $geocoder = $fetch->fetch($map_api_url . $ak . "&callback=renderReverse&location=" . $from_Location_X . "," . $from_Location_Y . "&output=xml&pois=1"); //抓取成功 if ($fetch->errno() == 0) { //正则表达式匹配城市 preg_match_all("/\\<city\\>(.*?)\\<\\/city\\>/", $geocoder, $city); //将市区县替换为空 例如北京市=》北京 $city = str_replace(array("市", "区", "县"), array("", "", ""), $city[1][0]); echo $city; //通过新浪天气接口查询天气链接 //example http://php.weather.sina.com.cn/xml.php?city=%B1%B1%BE%A9&password=DJOYnieT8234jlsK&day=0 $weather_api_url = "http://php.weather.sina.com.cn/xml.php?"; //改变编码 $city = "city=" . urlencode(iconv("UTF-8", "GBK", $city)); echo $city; //抓取当天天气 $weather = $fetch->fetch($weather_api_url . $city . "&password=DJOYnieT8234jlsK&day=0"); //抓取到天气 if ($fetch->errno() == 0 && strstr($weather, "Weather")) { //正则表达式获取数据 preg_match_all("/\\<city\\>(.*?)\\<\\/city\\>/", $weather, $w_city); preg_match_all("/\\<status2\\>(.*?)\\<\\/status2\\>/", $weather, $w_status2); preg_match_all("/\\<status1\\>(.*?)\\<\\/status1\\>/", $weather, $w_status1); preg_match_all("/\\<temperature2\\>(.*?)\\<\\/temperature2\\>/", $weather, $w_temperature2); preg_match_all("/\\<temperature1\\>(.*?)\\<\\/temperature1\\>/", $weather, $w_temperature1); preg_match_all("/\\<direction1\\>(.*?)\\<\\/direction1\\>/", $weather, $w_direction1); preg_match_all("/\\<direction2\\>(.*?)\\<\\/direction2\\>/", $weather, $w_direction2); preg_match_all("/\\<power1\\>(.*?)\\<\\/power1\\>/", $weather, $w_power1); preg_match_all("/\\<power2\\>(.*?)\\<\\/power2\\>/", $weather, $w_power2); //如果天气变化一致 if ($w_status2[1][0] == $w_status1[1][0]) { $w_status = $w_status2[1][0]; } else { $w_status = $w_status2[1][0] . "转" . $w_status1[1][0]; } $weather_res = array($w_city[1][0] . "天气预报", "天气:" . $w_status, "气温:" . $w_temperature2[1][0] . "℃-" . $w_temperature1[1][0] . "℃", "风向:" . $w_direction1[1][0], "风力:" . $w_power1[1][0] . "级"); $weather_res = implode("\n", $weather_res); //消息回复 $msgType = "text"; $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $weather_res); echo $resultStr; exit; } else { echo "抓取天气信息失败"; exit; } } } //回复关键字 if (!empty($keyword)) { switch ($keyword) { case "数据结构": $msgType = "text"; $contentStr = "http://pan.baidu.com/s/1kUr9NRD"; $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr); echo $resultStr; break; case "复试": $msgType = "text"; $contentStr = "http://pan.baidu.com/s/1c1sT2Q8"; $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr); echo $resultStr; break; case "author": case "作者": $msgType = "text"; $contentStr = "qq:1163451848"; $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr); echo $resultStr; break; //考研时间 //考研时间 case "考研时间": $resultStr = "<xml>\n\t\t\t\t\t\t\t\t\t<ToUserName><![CDATA[" . $fromUsername . "]]></ToUserName>\n\t\t\t\t\t\t\t\t\t<FromUserName><![CDATA[" . $toUsername . "]]></FromUserName>\n\t\t\t\t\t\t\t\t\t<CreateTime>" . time() . "</CreateTime>\n\t\t\t\t\t\t\t\t\t<MsgType><![CDATA[news]]></MsgType>\n\t\t\t\t\t\t\t\t\t<ArticleCount>1</ArticleCount>\n\t\t\t\t\t\t\t\t\t<Articles>\n\t\t\t\t\t\t\t\t\t<item>\n\t\t\t\t\t\t\t\t\t\t<Title><![CDATA[考研时间]]></Title> \n\t\t\t\t\t\t\t\t\t\t<Description><![CDATA[test only1]]></Description>\n\t\t\t\t\t\t\t\t\t\t<PicUrl><![CDATA[http://xijiaxiangwexin-xijiaxiangwexin.stor.sinaapp.com/pic%2Ftime.jpg]]></PicUrl>\n\t\t\t\t\t\t\t\t\t\t<Url><![CDATA[http://xijiaxiangwexin.sinaapp.com/wexin/kaoyantime.php]]></Url>\n\t\t\t\t\t\t\t\t\t</item>\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t</Articles>\n\t\t\t\t\t\t\t\t\t<FuncFlag>0</FuncFlag>\n\t\t\t\t\t\t\t\t\t</xml> "; echo $resultStr; break; case "天气": $resultStr = "<xml>\n\t\t\t\t\t\t\t\t\t<ToUserName><![CDATA[" . $fromUsername . "]]></ToUserName>\n\t\t\t\t\t\t\t\t\t<FromUserName><![CDATA[" . $toUsername . "]]></FromUserName>\n\t\t\t\t\t\t\t\t\t<CreateTime>" . time() . "</CreateTime>\n\t\t\t\t\t\t\t\t\t<MsgType><![CDATA[news]]></MsgType>\n\t\t\t\t\t\t\t\t\t<ArticleCount>1</ArticleCount>\n\t\t\t\t\t\t\t\t\t<Articles>\n\t\t\t\t\t\t\t\t\t<item>\n\t\t\t\t\t\t\t\t\t\t<Title><![CDATA[天气预报]]></Title> \n\t\t\t\t\t\t\t\t\t\t<Description><![CDATA[test only]]></Description>\n\t\t\t\t\t\t\t\t\t\t<PicUrl><![CDATA[http://xijiaxiangwexin-xijiaxiangwexin.stor.sinaapp.com/pic%2Fweather.jpg]]></PicUrl>\n\t\t\t\t\t\t\t\t\t\t<Url><![CDATA[http://xijiaxiangwexin.sinaapp.com/wexin/weather.php]]></Url>\n\t\t\t\t\t\t\t\t\t</item>\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t</Articles>\n\t\t\t\t\t\t\t\t\t<FuncFlag>0</FuncFlag>\n\t\t\t\t\t\t\t\t\t</xml> "; echo $resultStr; break; case "导师": $msgType = "text"; $contentStr = "1. https://github.com/TutorWikiUJS/TutorWiki" . "\n" . "2. http://pan.baidu.com/s/1i3PrVPN"; $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr); echo $resultStr; break; default: //引入turling机器人 $msgType = "text"; //显示一样的消息 $contentStr = $keyword; $ch = curl_init(); $url = 'http://www.tuling123.com/openapi/api?key=*****************&info=' . $keyword . '&userid=' . $fromUsername; curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // 执行HTTP请求 curl_setopt($ch, CURLOPT_URL, $url); $res = curl_exec($ch); $resarr = json_decode($res, true); switch ($resarr["code"]) { case "100000": echo "text"; $string = str_replace("<br>", "\n", $resarr["text"]); break; case "200000": echo "url"; $string = $resarr["text"] . "\n" . "详细请点击:" . $resarr["url"]; break; case "302000": echo "news"; echo $resarr["text"] . "\n"; for ($i = 0; $i < count($resarr["list"]); $i++) { $string = "-----------------------" . "\n"; $string .= $resarr["list"][$i]["article"] . "\n"; $string .= $resarr["list"][$i]["source"] . "\n"; $string .= $resarr["list"][$i]["detailurl"] . "\n"; } break; //case "305000":echo "trains";break; //case "306000":echo "flights";break; //case "305000":echo "trains";break; //case "306000":echo "flights";break; case "308000": echo "cai pu"; $string = $resarr["text"] . "\n"; $string .= "-----------------------" . "\n"; $string .= "<" . $resarr["list"]["0"]["name"] . ">\n"; $string .= "配料:" . $resarr["list"]["0"]["info"] . "\n"; $string .= "详细请点击:" . $resarr["list"]["0"]["detailurl"] . "\n"; break; case "40001": $string = "sorry,sth wrong"; echo "1 turling_err"; break; case "40002": $string = "sorry,sth wrong"; echo "2 turling_err null"; break; case "40004": $string = "sorry,sth wrong"; echo "3 turling_err full"; break; case "40007": $string = "sorry,sth wrong"; echo "4 turling_err "; break; default: $string = "sorry,sth wrong"; echo "turling_err"; break; } $contentStr = $string; $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr); echo $resultStr; } } else { echo "something i didn't know :)"; } } else { echo ""; exit; } }
<?php header("content-type:text/html;charset=utf-8"); include "conn.php"; use sinacloud\sae\Storage; $s = new Storage(); if (!empty($_POST['uName'])) { $uName = $_POST['uName']; //设备号 echo $uName; $sql0 = "select * from uploadpicture where devID='{$uName}' "; $query0 = mysql_query($sql0); $rs0 = mysql_fetch_array($query0); $ret_time = $rs0['time']; $ret_devID = $rs0['devID']; $ret_name = $rs0['picName']; if ($ret_devID === $uName) { $uImg = $_FILES['uImg']; //print_r($uImg); //判断上传类型 $ext = explode(".", $uImg["name"]); $extName = end($ext); if ($extName != "jpg") { echo "文件类型错误<a href='uploadtostor.php'>返回</a>"; exit; } //检测文件大小 if ($uImg["size"] > 2000000) { echo "文件超过2M<a href='uploadtostor.php'>返回</a>"; exit; }
<?php // $f = new SaeFetchurl(); //myapp-mybucket.stor.sinaapp.com/pic%2Ftime.jpg $content = $f->fetch("http://xijiaxiangwexin-xijiaxiangwexin.stor.sinaapp.com/pic%2Ftime.jpg"); if ($f->errno() == 0) { echo "success"; } else { echo $f->errmsg(); } use sinacloud\sae\Storage; $s = new Storage(); //$file=fopen("/test/read.txt","r"); $state = $s->putObject($content, "xijiaxiangwexin", "pic/time1.jpg"); echo $state; //·¢ÆðpostÇëÇó /*$f=new SaeFetchurl(); $f->setMethod("post"); $f->setPostData( array("user"=>"xi","pwd"=>"123") ); $content=$f->fetch("http://xijiaxiangwexin.sinaapp.com/test/form_test_do.php"); if($f->errno()==0)echo $content."ok"; else echo $f->errmsg();*/
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta name="viewport" content="width=device-width"/> <meta name="viewport" content="inital-scale=1.0,user-scalable=no"/> <meta name="apple-mobile-web-app-capavle" content="yes"/> <meta name="apple-mobile-web-app-status-bar-style" content="black"/> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>远程图片</title> </head> <?php include "conn.php"; use sinacloud\sae\Storage; $s = new Storage(); $text_list = $s->listBuckets(); //获取bucket信息 $devID = "oF-YDuCa_GxDWDvfPjZTF579mVrY"; $sql0 = "select * from uploadpicture where devID='{$devID}' "; $query0 = mysql_query($sql0); $rs0 = mysql_fetch_array($query0); $ret_time = $rs0['time']; $ret_devID = $rs0['devID']; $ret_name = $rs0['picName']; $ext = explode(";", $ret_name); $filename = end($ext); echo $filename; //找到最新图片name //获取一个Object的外网临时访问URL $contentStr = $s->getTempUrl("yijianlian001", "uploadpicture/{$filename}.jpg", "GET", 600);