/**
  * 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]);
     }
 }
Exemple #2
0
$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";
Exemple #3
0
<?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);