public function adminAdd() { $rank = isset($_POST['rank']) ? htmlspecialchars($_POST['rank']) : ''; $domain = isset($_POST['domain']) ? htmlspecialchars($_POST['domain']) : ''; if ($rank !== '' && $domain !== '') { $tableModel = new TableModel(); $tableModel->rank = $rank; $tableModel->name = $domain; $tableModel->save(); } return redirect()->intended('/adminview'); }
/** * Execute the console command. * * @return mixed */ public function handle() { $tableModel = new TableModel(); $tableModel->cleanTable(); for ($j = 0; $j < 5; $j++) { $accessKeyId = "AKIAJGMJHABBXMYJDXTQ"; $secretAccessKey = "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"; $ActionName = 'TopSites'; $ResponseGroupName = 'Country'; $ServiceHost = 'ats.amazonaws.com'; $NumReturn = 100; $StartNum = 1 + 100 * $j; $SigVersion = '2'; $HashAlgorithm = 'HmacSHA256'; $params = array('Action' => $ActionName, 'ResponseGroup' => $ResponseGroupName, 'AWSAccessKeyId' => $accessKeyId, 'Timestamp' => gmdate("Y-m-d\\TH:i:s.\\0\\0\\0\\Z", time()), 'CountryCode' => "", 'Count' => $NumReturn, 'Start' => $StartNum, 'SignatureVersion' => $SigVersion, 'SignatureMethod' => $HashAlgorithm); ksort($params); $keyvalue = array(); foreach ($params as $k => $v) { $keyvalue[] = $k . '=' . rawurlencode($v); } $queryParams = implode('&', $keyvalue); $sign = "GET\n" . strtolower($ServiceHost) . "\n/\n" . $queryParams; $sig1 = base64_encode(hash_hmac('sha256', $sign, $secretAccessKey, true)); $sig = rawurlencode($sig1); $url = 'http://' . $ServiceHost . '/?' . $queryParams . '&Signature=' . $sig; $ch = curl_init($url); curl_setopt($ch, CURLOPT_TIMEOUT, 4); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec($ch); curl_close($ch); $xml = new \SimpleXMLElement($result, null, false, 'http://ats.amazonaws.com/doc/2005-11-21'); foreach ($xml->Response->TopSitesResult->Alexa->TopSites->Country->Sites->children('http://ats.amazonaws.com/doc/2005-11-21') as $site) { $tableModel = new TableModel(); $tableModel->rank = $site->Global->Rank; $tableModel->name = $site->DataUrl; $tableModel->save(); } } }
/** * Run the database seeds. * * @return void */ public function run() { // $tableModel = new TableModel(); $tableModel->setTable('NewData'); for ($i = 0; $i < 10; $i++) { TableModel::create(array('ThisName' => $i, 'PowerName' => $i, 'vol1' => $i, 'volz1' => $i, 'cur1' => $i, 'condition1' => $i, 'RailwayName1' => $i, 'RailNum1' => $i, 'vol2' => $i, 'volz2' => $i, 'cur1' => $i, 'condition2' => $i, 'RailwayName2' => $i, 'RailNum2' => $i)); } $tableModel = new TableModel(); $tableModel->setTable('RailUse'); for ($i = 0; $i < 10; $i++) { TableModel::create(array('ThisName' => $i, 'PowerName' => $i, 'RailwayName' => $i, 'RailNum' => $i, 'BeginTime' => $i, 'StopTime' => $i, 'UseKWH' => $i)); } $tableModel = new TableModel(); $tableModel->setTable('PowerUse'); for ($i = 0; $i < 10; $i++) { TableModel::create(array('ThisName' => $i, 'PowerName' => $i, 'PowerNum' => $i, 'RailwayName' => $i, 'RailNum' => $i, 'BeginTime' => $i, 'StopTime' => $i, 'BeginKWH' => $i, 'StopKWH' => $i, 'UseKWH' => $i)); } $tableModel = new TableModel(); $tableModel->setTable('AlarmMessage'); for ($i = 0; $i < 10; $i++) { TableModel::create(array('ThisName' => $i, 'PowerName' => $i, 'PowerNum' => $i, 'Alarm' => $i, 'AlarmTime' => $i, 'EndTime' => $i, 'UseKWH' => $i)); } }
public function refreshNewDataT() { $i = 0; while ($i <= 15) { $row = TableModel::find($i); if ($row != null) { $x1 = rand(0, 200); $y1 = rand(0, 200); $row->vol1 = $x1 > $y1 ? $x1 : $y1; $row->volz1 = $x1 < $y1 ? $x1 : $y1; $row->cur1 = rand(0, 700); $x2 = rand(0, 750); $y2 = rand(0, 750); $row->vol2 = $x2 > $y2 ? $x2 : $y2; $row->volz2 = $x2 < $y2 ? $x2 : $y2; $row->cur2 = rand(0, 700); $row->save(); } $i++; } }