public function Rates($FirstCurrency = "BTC", $SecondCurrency = "USD") { $title = $FirstCurrency . "/" . $SecondCurrency; $back = strtolower($FirstCurrency . "_" . $SecondCurrency); $Refresh = "No"; $user = Session::read('member'); $id = $user['_id']; $details = Details::find('first', array('conditions' => array('user_id' => $id))); if ($details['page.refresh'] == true || $details['page.refresh'] == 1) { $data = array('page.refresh' => false); Details::find('all', array('conditions' => array('user_id' => $id)))->save($data); $Refresh = "Yes"; } $URL = "/" . $locale . 'ex/x/' . $back; $trades = Trades::find('first', array('conditions' => array('trade' => $title))); if ($trades['refresh'] == true || $trades['refresh'] == 1) { $data = array('refresh' => false); Trades::find('all', array('conditions' => array('trade' => $title)))->save($data); $Refresh = "Yes"; } $mongodb = Connections::get('default')->connection; $Rates = Orders::connection()->connection->command(array('aggregate' => 'orders', 'pipeline' => array(array('$project' => array('_id' => 0, 'Action' => '$Action', 'PerPrice' => '$PerPrice', 'Completed' => '$Completed', 'FirstCurrency' => '$FirstCurrency', 'SecondCurrency' => '$SecondCurrency', 'TransactDateTime' => '$Transact.DateTime')), array('$match' => array('Completed' => 'Y', 'FirstCurrency' => $FirstCurrency, 'SecondCurrency' => $SecondCurrency)), array('$group' => array('_id' => array('year' => array('$year' => '$TransactDateTime'), 'month' => array('$month' => '$TransactDateTime'), 'day' => array('$dayOfMonth' => '$TransactDateTime')), 'min' => array('$min' => '$PerPrice'), 'max' => array('$max' => '$PerPrice'))), array('$sort' => array('_id.year' => -1, '_id.month' => -1, '_id.day' => -1)), array('$limit' => 1)))); // print_r($Rates['result']); foreach ($Rates['result'] as $r) { $Low = $r['min']; $High = $r['max']; } $Last = Orders::find('all', array('conditions' => array('Completed' => 'Y', 'FirstCurrency' => $FirstCurrency, 'SecondCurrency' => $SecondCurrency), 'limit' => 1, 'order' => array('Transact.DateTime' => 'DESC'))); foreach ($Last as $l) { $LastPrice = $l['PerPrice']; } $TotalOrders = Orders::connection()->connection->command(array('aggregate' => 'orders', 'pipeline' => array(array('$project' => array('_id' => 0, 'Action' => '$Action', 'Amount' => '$Amount', 'Completed' => '$Completed', 'FirstCurrency' => '$FirstCurrency', 'SecondCurrency' => '$SecondCurrency', 'TransactDateTime' => '$Transact.DateTime', 'TotalAmount' => array('$multiply' => array('$Amount', '$PerPrice')))), array('$match' => array('Completed' => 'Y', 'Action' => 'Buy', 'FirstCurrency' => $FirstCurrency, 'SecondCurrency' => $SecondCurrency)), array('$group' => array('_id' => array('year' => array('$year' => '$TransactDateTime'), 'month' => array('$month' => '$TransactDateTime')), 'Amount' => array('$sum' => '$Amount'), 'TotalAmount' => array('$sum' => '$TotalAmount'))), array('$sort' => array('_id.year' => -1, '_id.month' => -1)), array('$limit' => 1)))); // print_r($SecondCurrency); return $this->render(array('json' => array('Refresh' => $Refresh, 'URL' => $URL, 'Low' => number_format($Low, 5), 'High' => number_format($High, 5), 'Last' => number_format($LastPrice, 5), 'VolumeFirst' => number_format($TotalOrders['result'][0]['Amount'], 5), 'VolumeSecond' => number_format($TotalOrders['result'][0]['TotalAmount'], 3), 'VolumeFirstUnit' => $FirstCurrency, 'VolumeSecondUnit' => $SecondCurrency))); }
public function document() { $user = Session::read('member'); $id = md5($user['email']); $document = Details::find('first', array('conditions' => array('user_id' => (string) $user['_id']))); // if(count($document)==0){return $this->redirect('/');} $uploadOk = 1; if ($this->request->data) { $extension = pathinfo($this->request->data['file']['name'], PATHINFO_EXTENSION); $allowed = array('pdf'); if (!in_array(strtolower($extension), $allowed)) { $msg = "Sorry, only PDF files are allowed."; $uploadOk = 0; } if ($uploadOk = 1) { $option = 'doc'; $data = array('details_' . $option . '_id' => (string) $document['_id'], 'docname' => $this->request->data['docname'], 'date' => $this->request->data['date'], 'DateTime' => new \MongoDate(), 'keywords' => $this->request->data['keywords'], 'description' => $this->request->data['description'], $option => $this->request->data['file'], $option . '.verified' => 'No', $option . '.IP' => $_SERVER['REMOTE_ADDR']); $field = 'details_' . $option . '_id'; $Documents = Documents::create($data); $saved = $Documents->save(); $fileData = array('file' => $this->request->data['file'], 'documents_' . $option . '_id' => (string) $Documents->_id); $file = File::create(); if ($file->save($fileData)) { $msg = "Upload OK"; } $image_address = File::find('first', array('conditions' => array('documents_doc_id' => (string) $Documents->_id))); if ($image_address['filename'] != "") { $imagename_address = $image_address['_id'] . '_' . $image_address['filename']; $path = LITHIUM_APP_PATH . '/webroot/download/' . $imagename_address; file_put_contents($path, $image_address->file->getBytes()); } // print_r($path); $pages = $this->getPDFPages($path); // Output: 13 // print_r($pages);exit; unlink($path); $docdata = array(); foreach ($pages as $page) { $params = explode(":", $page); $left = $params[0]; $right = $params[1]; $docdata = array_merge($docdata, array($left => trim($right))); } $data = array("document" => $docdata); $conditions = array("_id" => (string) $Documents->_id); Documents::update($data, $conditions); // Use the function } } return $this->redirect('ex::save'); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Details::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'userid' => $this->userid]); $query->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'city', $this->city]); return $dataProvider; }
public function getKYCWallet() { $kyc = $this->request->query['kyc']; $opts = array('http' => array('method' => "GET", 'user_agent' => "MozillaXYZ/1.0")); $context = stream_context_create($opts); $json = file_get_contents('https://kycglobal.net/kyc/info/' . $kyc, false, $context); $details = json_decode($json); if ($details->percent > 60) { $user = Session::read('default'); $data = array('kyc_id' => $kyc); $conditions = array("walletid" => $user['walletid']); Details::update($data, $conditions); return $this->render(array('json' => array('success' => 1, 'email' => $details->email, 'name' => $details->details->Name->first . " " . $details->details->Name->last, 'phone' => $details->details->Mobile, 'score' => $details->score, 'percent' => $details->percent))); } else { return $this->render(array('json' => array('success' => 0))); } }
public function save($id = null) { $user = Session::read('member'); if ($user == "") { return $this->redirect('/'); } // $id = md5($user['email']); if ($id != "") { $data = array("Saved" => "Yes"); $conditions = array('_id' => $id); Documents::update($data, $conditions); $this->redirect("ex::dashboard"); } $detail = Details::find('first', array('conditions' => array('user_id' => (string) $user['_id']))); $option = 'fileType'; $document = Documents::find('first', array('conditions' => array('details_doc_id' => (string) $detail['_id'], 'Saved' => null))); $rates = Rates::find('first', array('conditions' => array('Min' => array('$lte' => intval($document['document']['Pages'])), 'Max' => array('$gte' => intval($document['document']['Pages']))))); return compact('document', 'rates'); }
public function index($s = null) { $greencoin = new Greencoin('http://' . GREENCOIN_WALLET_SERVER . ':' . GREENCOIN_WALLET_PORT, GREENCOIN_WALLET_USERNAME, GREENCOIN_WALLET_PASSWORD); $paytxfee = Parameters::find('first'); $txfee = $paytxfee['payxgctxfee']; $getrawtransaction = $greencoin->getrawtransaction($s); $decoderawtransaction = $greencoin->decoderawtransaction($getrawtransaction); foreach ($decoderawtransaction['vout'] as $out) { foreach ($out['scriptPubKey']['addresses'] as $address) { $username = $greencoin->getaccount($address); $Amount = (double) $out['value']; if ($greencoin->getaccount($address) != "") { $Transactions = Transactions::find('first', array('conditions' => array('TransactionHash' => $s))); if ($Transactions['_id'] == "") { $t = Transactions::create(); $Amount = $Amount; $comment = "Move from User: "******"; Address: " . GREENCOINX_ADDRESS . "; Amount:" . $Amount . ";"; $transfer = $greencoin->sendfrom($username, GREENCOINX_ADDRESS, (double) $Amount, (int) 0, $comment); if (isset($transfer['error'])) { $error = $transfer['error']; } else { $error = $transfer; } $data = array('DateTime' => new \MongoDate(), 'TransactionHash' => $s, 'username' => $username, 'address' => $address, 'Currency' => 'XGC', 'Amount' => $Amount, 'Added' => true, 'Transfer' => $comment); $t->save($data); $userName = str_replace("SiiCrypto-", "", $username); $details = Details::find('first', array('conditions' => array('username' => (string) $userName))); $dataDetails = array('balance.XGC' => (double) ((double) $details['balance.XGC'] + (double) $Amount), 'XGCnewaddress' => 'Yes'); $details = Details::find('all', array('conditions' => array('username' => (string) $userName)))->save($dataDetails); } else { $Transactions = Transactions::find('first', array('conditions' => array('TransactionHash' => $s)))->save($data); } } } } }
public function listusers() { $ParentDetails = Details::find('all'); $i = 0; foreach ($ParentDetails as $pd) { $left = $pd['left']; $right = $pd['right']; $NDCount = Details::count(array('left' => array('$lt' => $left), 'right' => array('$gt' => $right))); $userlist[$i]['count'] = $NDCount; $username = Users::find('all', array('conditions' => array('_id' => $pd['user_id']))); foreach ($username as $u) { $userlist[$i]['username'] = $u['username']; } $i++; } /* $mongodb = Connections::get('default')->connection; $details = Details::connection()->connection->command(array( 'aggregate' => 'details', 'pipeline' => array( array('$group' => array( '_id' => array( 'parent'=>array( 'puser_id'=>'$user_id', 'pleft'=>'$left', 'pright'=>'$right', ), ) ), '$group' =>array( '_id' => '$user_id', 'count' => array('$sum' => 1), 'puser'=>'$parent.puser_id' ), ), ) )); */ return array($userlist); }
public function settings() { $user = Session::read('default'); if ($user == "") { return $this->redirect('wallet::login'); } $wallet = Users::find("first", array("conditions" => array("walletid" => $user['walletid']))); $details = Details::find("first", array("conditions" => array("walletid" => $user['walletid']))); $greencoinAddress = $wallet['greencoinAddress'][0]; $address = Addresses::find("first", array("conditions" => array("a_id" => $greencoinAddress))); //$txid = "315965f1702a9bc0f5dede3f8bb81e8497e004789965452988d136b16391b8a5"; $balance = $address['balance'] / 100000000; $sent = $address['sent'] / 100000000; $receive = $address['receive'] / 100000000; if ($this->request->data) { if (stristr($_SERVER['HTTP_REFERER'], COMPANY_URL) === FALSE) { return $this->redirect('/wallet/login'); exit; } $data = array('alert.email.signin' => (bool) $this->request->data['alert_email_signin'], 'alert.email.receive' => (bool) $this->request->data['alert_email_receive'], 'alert.email.send' => (bool) $this->request->data['alert_email_send'], 'alert.phone.signin' => (bool) $this->request->data['alert_phone_signin'], 'alert.phone.receive' => (bool) $this->request->data['alert_phone_receive'], 'alert.phone.send' => (bool) $this->request->data['alert_phone_send'], 'password.send.email' => (bool) $this->request->data['password_send_email'], 'password.send.phone' => (bool) $this->request->data['password_send_phone']); $conditions = array("walletid" => $user['walletid']); $save = Details::update($data, $conditions); } $details = Details::find("first", array("conditions" => array("walletid" => $user['walletid']))); $ga = new GoogleAuthenticator(); $secret = $details['secret']; $qrCodeUrl = $ga->getQRCodeGoogleUrl(COMPANY_URL, $secret); return compact('greencoinAddress', 'wallet', 'balance', 'sent', 'receive', 'user', 'details', 'qrCodeUrl'); }
public function checkUser() { $user = Users::find('first'); $detail = Details::find('first'); $uuid = new Uuid(); $xemail = $uuid->hashme($user['email']); $xwalletid = $uuid->hashme($user['walletid']); $xmain_email = $uuid->hashme(MAIN_EMAIL); $xescrow_email = $uuid->hashme(ESCROW_EMAIL); return $this->render(array('json' => array("success" => 1, "user" => $user, "detail" => $detail, "xemail" => $xemail, "xwalletid" => $xwalletid, "main_email" => MAIN_EMAIL, "escrow_email" => ESCROW_EMAIL, "xmain_email" => $xmain_email, "xescrow_email" => $xescrow_email))); }
<?php use lithium\storage\Session; use app\models\Pages; use app\models\Details; use app\models\Parameters; if (!isset($title)) { $page = Pages::find('first', array('conditions' => array('pagename' => 'home'))); $title = $page['title']; $keywords = $page['keywords']; $description = $page['description']; } $user = Session::read('default'); $detail = Details::find("first", array("conditions" => array("user_id" => $user["_id"]))); $parameters = Parameters::find('first'); //Pagetime Start $mtime = microtime(); $mtime = explode(" ", $mtime); $mtime = $mtime[1] + $mtime[0]; $pagestarttime = $mtime; //Pagetime End ?> <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <?php echo $this->html->charset(); ?>
public function index() { $usernameX = "SiiUserA"; $details = Details::find('first', array('conditions' => array('username' => 'SiiUserA'))); if ($usernameX == $details['username']) { $keyX = $details['key']; } $usernameY = "SiiUserB"; $details = Details::find('first', array('conditions' => array('username' => 'SiiUserB'))); if ($usernameY == $details['username']) { $keyY = $details['key']; } $trades = Trades::find('all'); foreach ($trades as $trade) { $pair = substr($trade['trade'], 0, 3) . "_" . substr($trade['trade'], 4, 3); $amount = $trade['amount'] + $this->float_rand(0, 1, 3); $price = $trade['Base'] + $this->float_rand(0, 0.5, 4); if (round($this->float_rand(0, 1, 0), 0) != 0) { $ActionX = "Buy"; // $usernameX = "SiiUserA"; $ActionY = "Sell"; // $usernameY = "SiiUserB"; $nounce = time(); } else { $ActionX = "Sell"; // $usernameX = "SiiUserB"; $ActionY = "Buy"; // $usernameY = "SiiUserA"; $nounce = time(); } $url = "https://spotcrypto.com/API/Trade/" . $keyX; $fields = array(); $fields_string = ""; $fields = array('type' => $ActionX, 'pair' => $pair, 'amount' => $amount, 'price' => $price, 'nounce' => $nounce); print_r($pair); foreach ($fields as $key => $value) { $fields_string .= $key . '=' . $value . '&'; } rtrim($fields_string, '&'); print_r("\n"); print_r($url); print_r("\n"); print_r($fields_string); print_r("\n"); $useragent = "Mozilla 5.0 "; $ch = curl_init(); //set the url, number of POST vars, POST data curl_setopt($ch, CURLOPT_USERAGENT, $useragent); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, count($fields)); curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_VERBOSE, false); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); //execute post $result = curl_exec($ch); curl_close($ch); /////////////////////////////////////////////////////////////////////////////////// $fields = array(); $fields_string = ""; $url = "https://spotcrypto.com/API/Trade/" . $keyY; $fields = array('type' => $ActionY, 'pair' => $pair, 'amount' => $amount, 'price' => $price, 'nounce' => $nounce); print_r($pair); foreach ($fields as $key => $value) { $fields_string .= $key . '=' . $value . '&'; } rtrim($fields_string, '&'); print_r("\n"); print_r($url); print_r("\n"); print_r($fields_string); print_r("\n"); $useragent = "Mozilla 5.0 "; $ch = curl_init(); //set the url, number of POST vars, POST data curl_setopt($ch, CURLOPT_USERAGENT, $useragent); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, count($fields)); curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_VERBOSE, false); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); //execute post $result = curl_exec($ch); curl_close($ch); } }
/** * Finds the Details model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Details the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Details::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function CheckTOTP() { $user = Session::read('default'); if ($user == "") { return $this->redirect('wallet::login'); } $wallet = Users::find("first", array("conditions" => array("walletid" => $user['walletid']))); $details = Details::find('first', array('conditions' => array('walletid' => $user['walletid']))); $CheckCode = $this->request->query['CheckCode']; $ga = new GoogleAuthenticator(); $checkResult = $ga->verifyCode($details['secret'], $CheckCode, 2); if ($checkResult) { $data = array('withdraw.security.totp' => true); $conditions = array("walletid" => $user['walletid']); $save = Details::update($data, $conditions); return $this->render(array('json' => array('success' => 1))); } else { $data = array('withdraw.security.totp' => false); $conditions = array("walletid" => $user['walletid']); $save = Details::update($data, $conditions); return $this->render(array('json' => array('success' => 0))); } }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $user = \App\Models\User::all(); if (count($user) > 1) { if (!empty($id)) { // Verificando se existe imagem $imagem = \App\Models\Details::where("detail_perfil_id", $id)->where("detail_avatar", "!=", '')->first(); if (isset($imagem) && $imagem->detail_avatar != '' && \File::exists('uploads/' . $imagem->detail_avatar)) { \File::delete('uploads/' . $imagem->detail_avatar); } $delete = \App\Models\User::where("id", $id)->delete(); if ($delete) { $details = \App\Models\Details::where("detail_perfil_id", $id)->delete(); if ($details) { return 'sucesso'; } } } } else { return 'ultimousuario'; } }
public function password() { if ($this->request->data) { if (stristr($_SERVER['HTTP_REFERER'], COMPANY_URL) === FALSE) { return $this->redirect('/login'); exit; } $details = Details::find('first', array('conditions' => array('key' => $this->request->data['key']), 'fields' => array('user_id'))); $msg = "Password Not Changed!"; // print_r($details['user_id']); if ($details['user_id'] != "") { if ($this->request->data['password'] == $this->request->data['password2']) { // print_r($this->request->data['password']); $user = Users::find('first', array('conditions' => array('_id' => $details['user_id']))); // print_r($user['password']); if ($user['password'] != String::hash($this->request->data['password'])) { print_r($details['user_id']); $data = array('password' => String::hash($this->request->data['password'])); // print_r($data); $user = Users::find('all', array('conditions' => array('_id' => $details['user_id'])))->save($data, array('validate' => false)); // print_r($user); if ($user) { $msg = "Password changed!"; } } else { $msg = "Password same as old password!"; } } else { $msg = "New password does not match!"; } } } return compact('msg'); }
public function add() { //assume there's no problem with authentication $noauth = false; //perform the authentication check and redirect on success Session::delete('default'); $response = file_get_contents("http://ipinfo.io/{$_SERVER['REMOTE_ADDR']}"); $IPResponse = json_decode($response); if ($IPResponse->tor) { // Display error message or something $user = ""; Session::delete('default'); return false; } $user = Users::find("first", array("conditions" => array("username" => $this->request->data['username']))); $default = array('username' => $user['username'], '_id' => $user['_id'], 'firstname' => $user['firstname'], 'lastname' => $user['lastname'], 'email' => $user['email'], 'walletid' => $user['walletid']); if (password_verify($this->request->data['password'], $user['password'])) { //Redirect on successful login $loginpassword = $this->request->data['loginpassword']; Session::write('default', $default); $details = Details::find('first', array('conditions' => array('username' => $default['username'], 'user_id' => (string) $default['_id']))); if ($details['active'] == "No") { Session::delete('default'); return $this->redirect('/'); exit; } if ($details["EmailPasswordSecurity"] === "true" || $details["EmailPasswordSecurity"] === null) { if ($details['oneCode'] === $this->request->data['loginpassword']) { $data = array('oneCodeused' => 'Yes', 'lastconnected' => array('IP' => $IPResponse->ip, 'ISO' => $IPResponse->country, 'hostname' => $IPResponse->hostname, 'city' => $IPResponse->city, 'region' => $IPResponse->region, 'loc' => $IPResponse->loc, 'org' => $IPResponse->org, 'postal' => $IPResponse->postal, 'DateTime' => new \MongoDate())); $details = Details::find('first', array('conditions' => array('username' => $default['username'], 'user_id' => (string) $default['_id'])))->save($data); $details = Details::find('first', array('conditions' => array('username' => $default['username'], 'user_id' => (string) $default['_id']))); if ($details["TOTP.Validate"] == 1 && $details["TOTP.Login"] == true) { $totp = $this->request->data['totp']; $ga = new GoogleAuthenticator(); if ($totp == "") { Session::delete('default'); } else { $checkResult = $ga->verifyCode($details['secret'], $totp, 2); if ($checkResult == 1) { Session::write('default', $default); $user = Session::read('default'); ///////////////////////////////////////////////////////////////////////////////// $function = new Functions(); $IP = $function->get_ip_address(); $data = array('username' => $user['username'], 'IP' => $IPResponse->ip, 'ISO' => $IPResponse->country, 'hostname' => $IPResponse->hostname, 'city' => $IPResponse->city, 'region' => $IPResponse->region, 'loc' => $IPResponse->loc, 'org' => $IPResponse->org, 'postal' => $IPResponse->postal, 'DateTime' => new \MongoDate()); Logins::create()->save($data); ///////////////////////////////////////////////////////////////////////////////// $user = Session::read('default'); return $this->redirect('ex::dashboard'); exit; } else { Session::delete('default'); } } } else { Session::write('default', $default); $user = Session::read('default'); ///////////////////////////////////////////////////////////////////////////////// $function = new Functions(); $IP = $function->get_ip_address(); $data = array('username' => $user['username'], 'IP' => $IPResponse->ip, 'ISO' => $IPResponse->country, 'hostname' => $IPResponse->hostname, 'city' => $IPResponse->city, 'region' => $IPResponse->region, 'loc' => $IPResponse->loc, 'org' => $IPResponse->org, 'postal' => $IPResponse->postal, 'DateTime' => new \MongoDate()); Logins::create()->save($data); ///////////////////////////////////////////////////////////////////////////////// $user = Session::read('default'); return $this->redirect('ex::dashboard'); exit; } } else { Session::delete('default'); } } else { $data = array('oneCodeused' => 'Yes', 'lastconnected' => array('IP' => $IPResponse->ip, 'ISO' => $IPResponse->country, 'hostname' => $IPResponse->hostname, 'city' => $IPResponse->city, 'region' => $IPResponse->region, 'loc' => $IPResponse->loc, 'org' => $IPResponse->org, 'postal' => $IPResponse->postal, 'DateTime' => new \MongoDate())); $details = Details::find('first', array('conditions' => array('username' => $default['username'], 'user_id' => (string) $default['_id'])))->save($data); $details = Details::find('first', array('conditions' => array('username' => $default['username'], 'user_id' => (string) $default['_id']))); Session::write('default', $default); $user = Session::read('default'); ///////////////////////////////////////////////////////////////////////////////// $function = new Functions(); $IP = $function->get_ip_address(); $data = array('username' => $user['username'], 'IP' => $IPResponse->ip, 'ISO' => $IPResponse->country, 'hostname' => $IPResponse->hostname, 'city' => $IPResponse->city, 'region' => $IPResponse->region, 'loc' => $IPResponse->loc, 'org' => $IPResponse->org, 'postal' => $IPResponse->postal, 'DateTime' => new \MongoDate()); Logins::create()->save($data); ///////////////////////////////////////////////////////////////////////////////// $user = Session::read('default'); return $this->redirect('ex::dashboard'); } } //if theres still post data, and we weren't redirected above, then login failed if ($this->request->data) { //Login failed, trigger the error message if (isset($this->request->query['check']) && $this->request->query['check'] == SECURITY_CHECK) { $check = $this->request->query['check']; } $noauth = true; } //Return noauth status $page = Pages::find('first', array('conditions' => array('pagename' => 'login'))); $title = $page['title']; $keywords = $page['keywords']; $description = $page['description']; return compact('noauth', 'title', 'keywords', 'description'); return $this->redirect('/'); exit; // Handle failed authentication attempts }
public function EmailPasswordSecurity($value = false) { $user = Session::read('default'); $user_id = $user['_id']; if ($user == "") { return $this->redirect('/login'); } $data = array('EmailPasswordSecurity' => $value); $conditions = array('user_id' => $user_id); $details = Details::update($data, $conditions); return $this->render(array('json' => array("Updated" => $value))); }
public function cancelorder($key = null) { if (!$this->request->data) { return $this->render(array('json' => array('success' => 0, 'now' => time(), 'error' => "Not submitted through POST."))); } if ($key == null) { return $this->render(array('json' => array('success' => 0, 'now' => time(), 'error' => "Key not specified. Please get your key from your settings page under security."))); } else { $details = Details::find('first', array('conditions' => array('key' => $key))); if (count($details) == 0) { return $this->render(array('json' => array('success' => 0, 'now' => time(), 'error' => "Incorrect Key! Please get your key from your settings page under security."))); } else { if (!$this->requestAPI("cancelorder", $details['username'])) { return $this->render(array('json' => array('success' => 0, 'now' => time(), 'error' => "Too many requests from your IP. Try after some time."))); } $ID = $this->request->data['order_id']; if ($ID == "") { return $this->render(array('json' => array('success' => 0, 'now' => time(), 'error' => "Order ID cannot be null."))); } $Orders = Orders::find('first', array('conditions' => array('_id' => new MongoID($ID)))); if ($Orders['Completed'] == 'N') { $details = Details::find('first', array('conditions' => array('user_id' => (string) $Orders['user_id']))); if ($Orders['Action'] == 'Buy') { $balanceFirst = 'balance.' . $Orders['FirstCurrency']; $balanceSecond = 'balance.' . $Orders['SecondCurrency']; $data = array($balanceSecond => (double) ($details[$balanceSecond] + $Orders['PerPrice'] * $Orders['Amount'])); $details = Details::find('all', array('conditions' => array('user_id' => $Orders['user_id'], 'username' => $Orders['username'])))->save($data); } if ($Orders['Action'] == 'Sell') { $balanceFirst = 'balance.' . $Orders['FirstCurrency']; $balanceSecond = 'balance.' . $Orders['SecondCurrency']; $data = array($balanceFirst => (double) ($details[$balanceFirst] + (double) $Orders['Amount'])); $details = Details::find('all', array('conditions' => array('user_id' => $Orders['user_id'], 'username' => $Orders['username'])))->save($data); } $Remove = Orders::remove(array('_id' => $ID)); $result = $Remove; $data = array('page.refresh' => true); Details::find('all')->save($data); return $this->render(array('json' => array('success' => 1, 'now' => time(), 'result' => $result))); } } } }
public function SendFriendsEmails($order_id, $user_id) { $order = Orders::find('first', array('conditions' => array('_id' => new MongoID($order_id)))); $user = Users::find('first', array('conditions' => array('_id' => new MongoID($user_id)))); //***************************************************************************** //***************************************************************************** $mongodb = Connections::get('default')->connection; $Friends = Details::connection()->connection->command(array('aggregate' => 'details', 'pipeline' => array(array('$project' => array('_id' => 0, 'user_id' => '$user_id', 'username' => '$username', 'Friend' => '$Friend')), array('$unwind' => '$Friend'), array('$match' => array('Friend' => $user['username']))))); $friends = array(); if (count($Friends['result']) > 0) { foreach ($Friends['result'] as $friend) { array_push($friends, $friend['username']); } } // print_r($friends); $usersToSend = Users::find('all', array('conditions' => array('username' => array('$in' => $friends)), 'fields' => array('email', 'username'))); foreach ($usersToSend as $userToSend) { $sendEmailTo = $userToSend['email']; $sendUserName = $userToSend['username']; //***************************************************************************** //***************************************************************************** $view = new View(array('loader' => 'File', 'renderer' => 'File', 'paths' => array('template' => '{:library}/views/{:controller}/{:template}.{:type}.php'))); $body = $view->render('template', compact('order', 'sendUserName'), array('controller' => 'ex', 'template' => 'FriendRequest', 'type' => 'mail', 'layout' => false)); $transport = Swift_MailTransport::newInstance(); $mailer = Swift_Mailer::newInstance($transport); $message = Swift_Message::newInstance(); $message->setSubject("Your friend placed an order"); $message->setFrom(array(NOREPLY => 'Your friend placed an order')); $message->setTo($sendEmailTo); // $message->addBcc(MAIL_1); // $message->addBcc(MAIL_2); // $message->addBcc(MAIL_3); $message->setBody($body, 'text/html'); $mailer->send($message); } }
/** * @return \yii\db\ActiveQuery */ public function getDetails() { return $this->hasMany(Details::className(), ['userid' => 'id']); }
public function RemoveCompletedOrder($ID) { if ($this->__init() == false) { $this->redirect('ex::dashboard'); } $Orders = Orders::find('first', array('conditions' => array('_id' => new MongoID($ID)))); /* print_r($Orders['_id']); print_r("<br>"); print_r($Orders['Transact']['id']); print_r("<br>"); */ if ($Orders['Completed'] == 'Y') { $details = Details::find('first', array('conditions' => array('user_id' => (string) $Orders['user_id']))); if ($Orders['Action'] == 'Buy') { $balanceFirst = 'balance.' . $Orders['FirstCurrency']; $balanceSecond = 'balance.' . $Orders['SecondCurrency']; $data = array($balanceSecond => (double) ($details[$balanceSecond] + $Orders['PerPrice'] * $Orders['Amount'])); /* print_r($Orders['username']); print_r($details[$balanceSecond]); print_r($data); */ $details = Details::find('all', array('conditions' => array('user_id' => $Orders['user_id'], 'username' => $Orders['username'])))->save($data); $fromUser = Details::find('first', array('conditions' => array('user_id' => (string) $Orders['Transact']['user_id']))); $data = array($balanceFirst => (double) ($fromUser[$balanceFirst] + (double) $Orders['Amount'])); /* print_r($Orders['Transact']['username']); print_r($fromUser[$balanceFirst]); print_r($data); */ $details = Details::find('all', array('conditions' => array('user_id' => $Orders['Transact']['user_id'], 'username' => $Orders['Transact']['username'])))->save($data); } if ($Orders['Action'] == 'Sell') { $balanceFirst = 'balance.' . $Orders['FirstCurrency']; $balanceSecond = 'balance.' . $Orders['SecondCurrency']; $data = array($balanceFirst => (double) ($details[$balanceFirst] + (double) $Orders['Amount'])); /* print_r($Orders['username']); print_r($details[$balanceFirst]); print_r($data); */ $details = Details::find('all', array('conditions' => array('user_id' => $Orders['user_id'], 'username' => $Orders['username'])))->save($data); $fromUser = Details::find('first', array('conditions' => array('user_id' => (string) $Orders['Transact']['user_id']))); $data = array($balanceSecond => (double) ($fromUser[$balanceSecond] + $Orders['PerPrice'] * $Orders['Amount'])); /* print_r($Orders['Transact']['username']); print_r($fromUser[$balanceSecond]); print_r($data); */ $details = Details::find('all', array('conditions' => array('user_id' => $Orders['Transact']['user_id'], 'username' => $Orders['Transact']['username'])))->save($data); } $Remove = Orders::remove(array('_id' => $Orders['_id'])); $Remove = Orders::remove(array('_id' => $Orders['Transact']['id'])); $data = array('page.refresh' => true); Details::find('all')->save($data); } $this->redirect(array('controller' => 'Admin', 'action' => "orders")); }