Inheritance: extends lithium\data\Model
Ejemplo n.º 1
0
 public function actionIndex($page = 1)
 {
     $NewsModel = new News();
     $Query = $NewsModel->select();
     $totalNewsNumber = $Query->count();
     $Pagination = new Pages($totalNewsNumber, 20);
     $Pagination->setCurrent($page);
     $News = $Query->offset($Pagination->offset())->limit($Pagination->resultsOnPage())->get();
     $this->render('index', ['totalNewsNumber' => $totalNewsNumber, 'News' => $News, 'Pagination' => $Pagination, 'newsOnPage' => 10], !Application::$i->Input->isAjax());
 }
Ejemplo n.º 2
0
 public function actionView()
 {
     $id = \Yii::$app->request->get('id');
     $pageInfo = Pages::findOne($id);
     $userCount = Users::getAllCount();
     return $this->render('view', ['pageInfo' => $pageInfo, 'userCount' => $userCount]);
 }
Ejemplo n.º 3
0
 public function index()
 {
     $page = Pages::find('first', array('conditions' => array('pagename' => 'process/index')));
     $title = $page['title'];
     $keywords = $page['keywords'];
     $description = $page['description'];
     return compact('title', 'keywords', 'description');
 }
Ejemplo n.º 4
0
 public function sectionAction(request $req, $res)
 {
     $this->data['pageData'] = SectionFactory::getSectionWithRequest($req);
     $this->setRequestResult($req, $res);
     $this->data['subSections'] = Sections::getSubSections($this->data['pageData']->id);
     $this->data['pagesLinks'] = Pages::where('category_id', $this->data['pageData']->id)->get();
     $this->render('public\\main\\pages\\section_page.twig');
 }
Ejemplo n.º 5
0
 public function actionPage($slug)
 {
     $model = Pages::findOne(['slug' => $slug]);
     if ($model === null) {
         throw new NotFoundHttpException();
     }
     // renders a view named "view" and applies a layout to it
     return $this->render('view', ['model' => $model]);
 }
Ejemplo n.º 6
0
 public static function getPage($url, $field)
 {
     $page = Pages::find()->where("url = :url", [':url' => $url])->one();
     if ($page != null) {
         return $page->{$field};
     } else {
         return '';
     }
 }
Ejemplo n.º 7
0
 public function actionPage($view)
 {
     $page = Pages::findOne(['slug' => '/' . $view]);
     if ($page == null) {
         return $this->render('error');
     }
     $news = new ActiveDataProvider(['query' => News::find(), 'sort' => ['defaultOrder' => ['data_new' => SORT_DESC]], 'pagination' => ['pageSize' => 3, 'validatePage' => false]]);
     return $this->render('index', ['page' => $page, 'news' => $news]);
 }
Ejemplo n.º 8
0
 public function actionIndex()
 {
     $page = Pages::findOne(['slug' => Yii::$app->request->url]);
     $news = new ActiveDataProvider(['query' => News::find()]);
     if ($page == null) {
         return $this->render('error');
     }
     return $this->render('index', ['page' => $page, 'news' => $news]);
 }
Ejemplo n.º 9
0
 protected function setMetaData()
 {
     $this->data['title'] = $this->data['pageData']->name . ' page';
     $this->data['description'] = $this->data['pageData']->preview_text;
     $this->data['keywords'] = '';
     $this->data['h1'] = $this->data['pageData']->name;
     if ($id = $this->data['pageData']->category_id) {
         $this->data['categoryData'] = Pages::find($id);
     }
 }
Ejemplo n.º 10
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Pages::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]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'url', $this->url])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'meta_title', $this->meta_title])->andFilterWhere(['like', 'meta_keywords', $this->meta_keywords])->andFilterWhere(['like', 'meta_description', $this->meta_description]);
     return $dataProvider;
 }
Ejemplo n.º 11
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Pages::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_page' => $this->id_page]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'keyword_page', $this->keyword_page])->andFilterWhere(['like', 'desc_page', $this->desc_page])->andFilterWhere(['like', 'content_page', $this->content_page])->andFilterWhere(['like', 'slug', $this->slug]);
     return $dataProvider;
 }
Ejemplo n.º 12
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Pages::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'user_id' => $this->user_id, 'updated_at' => $this->updated_at, 'created_at' => $this->created_at, 'active' => $this->active]);
     $query->andFilterWhere(['like', 'header', $this->header])->andFilterWhere(['like', 'text', $this->text])->andFilterWhere(['like', 'url', $this->url]);
     return $dataProvider;
 }
Ejemplo n.º 13
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Pages::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, 'create_time' => $this->create_time, 'update_time' => $this->update_time]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'create_user', $this->create_user])->andFilterWhere(['like', 'update_user', $this->update_user]);
     return $dataProvider;
 }
Ejemplo n.º 14
0
 protected function menuCreator()
 {
     $this->container->dispatcher->addListener('publiccontroller.menu.logic', function ($event) {
         $items = Pages::where('show_in_menu', 1)->where('active', 1)->orderBy('sort', 'asc')->get();
         $name = '';
         if ($route = $event->getParams()->request->getAttribute('route')) {
             $name = $route->getName();
         }
         $menu = $event->getParams()->menu;
         foreach ($items as $item) {
             $menu[] = ['name' => $item->name_for_menu, 'current' => (bool) ($name == 'page.' . $item->id), 'section' => $item->category_id, 'code' => $item->code, 'id' => $item->id, 'url' => 'page.' . $item->id];
         }
         $event->getParams()->menu = $menu;
     });
 }
Ejemplo n.º 15
0
Archivo: q3.php Proyecto: riros/tests
function recTree($parentid, $lvl)
{
    $pages = Pages::findAll(['parent' => $parentid]);
    $lvl++;
    echo '<ul>';
    foreach ($pages as $page) {
        echo '<li>';
        $id = $page->pid;
        if ($lvl > 1) {
            echo '->';
        }
        echo $page->title;
        recTree($id, $lvl);
        echo '</li>';
    }
    $lvl--;
    echo '</ul>';
}
Ejemplo n.º 16
0
 public function actionIndex()
 {
     $userCount = Users::getAllCount();
     $oneNewsPic = News::getOnePicIndexNewsByCategory(2);
     $newsA = News::getIndexNewsByCategory(2, 6);
     $newsB = News::getIndexNewsByCategory(5, 12);
     $newsC = News::getIndexNewsByCategory(7, 5);
     $newsF = News::getOnePicIndexNewsByCategory(2);
     $newsRegister = TrainUsers::getAllByCount(5);
     $newContent = Pages::findOne(9);
     if (!empty($newsRegister)) {
         foreach ($newsRegister as $key => $val) {
             $newsD[$key]['title'] = Users::getOneUserNameById($val['user_id']) . "报名" . Train::getOneTrainNameById($val['train_id']) . "已被录取";
             $newsD[$key]['create_time'] = $val['create_time'];
             $newsD[$key]['user_id'] = $val['user_id'];
         }
     }
     $newsE = News::getIndexNewsByCategory(6, 5);
     $data = ['userCount' => $userCount, 'oneNewsPic' => $oneNewsPic, 'newsA' => $newsA, 'newsB' => $newsB, 'newsC' => $newsC, 'newsD' => $newsD, 'newsE' => $newsE, 'newsF' => $newsF, 'newsRegister' => $newContent];
     return $this->render('index', ['data' => $data]);
 }
Ejemplo n.º 17
0
 /**
  * Finds the Pages model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Pages the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Pages::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Ejemplo n.º 18
0
?>
    <!-- menu -->

    <div class="c text-center">
        <h1 class="fs22 fw400 opensans" style="margin-bottom: 5px;">
            <?php 
echo \app\models\Pages::getPage('/photo', 'title');
?>
        </h1>
    </div>

    <!-- intro text -->
    <div class="c-c">
        <div class="c text-center">
            <p><?php 
echo \app\models\Pages::getPage('/photo', 'description');
?>
</p>
        </div>
    </div>
    <!-- intro text -->

    <div class="gray-bg">

        <!-- gallery -->


        <div class="c-c gallery ok">

            <?php 
foreach ($photos as $k => $photo) {
Ejemplo n.º 19
0
?>
    <!-- menu -->

    <div class="c text-center">
        <h1 class="fs22 fw400 opensans"  style="margin-bottom: 5px;">
            <?php 
echo \app\models\Pages::getPage('/video', 'title');
?>
        </h1>
    </div>

    <!-- intro text -->
    <div class="c-c">
        <div class="c text-center">
            <p><?php 
echo \app\models\Pages::getPage('/video', 'description');
?>
</p>
        </div>
    </div>
    <!-- intro text -->

    <div class="gray-bg">

        <!-- gallery -->
        <div class="c-c gallery">

            <?php 
foreach ($videos as $k => $video) {
    ?>
                <div class="c x1d3--d x1d3--t x1d2--m gallery-element">
Ejemplo n.º 20
0
 public function actionRegisterCoachSuccess()
 {
     $userName = Yii::$app->user->identity->username;
     $levelName = Level::getOneLevelNameById(Yii::$app->user->identity->level_id);
     $userLevelInfo = UsersLevel::findOne(['user_id' => Yii::$app->user->id, 'level_id' => Yii::$app->user->identity->level_id]);
     $newRegNews = News::getNewsByCategory(8, 5);
     $regComment = Pages::getContentById(4);
     $data = ['newRegNews' => $newRegNews, 'regComment' => $regComment, 'userName' => $userName, 'levelName' => $levelName, 'userLevelInfo' => $userLevelInfo];
     return $this->render('register-coach-success', ['data' => $data]);
 }
Ejemplo n.º 21
0
    <title><?php 
echo Html::encode($this->title);
?>
</title>
    <?php 
$this->head();
?>
</head>
<body>

<?php 
$this->beginBody();
?>
    <div class="wrap">
        <?php 
$menuItems = Pages::getItems();
if (!Yii::$app->user->isGuest) {
    $menuItems[] = ['label' => 'AdminPanel', 'url' => ['admin/default/index']];
} else {
    $menuItems[] = ['label' => 'Login', 'url' => ['/admin']];
}
NavBar::begin(['brandLabel' => 'My Company', 'brandUrl' => Yii::$app->homeUrl, 'options' => ['class' => 'navbar-inverse navbar-fixed-top']]);
echo Nav::widget(['options' => ['class' => 'navbar-nav navbar-right'], 'items' => $menuItems]);
NavBar::end();
?>

        <div class="container">
            <?php 
echo Breadcrumbs::widget(['links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : []]);
?>
            <?php 
Ejemplo n.º 22
0
 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
 }
Ejemplo n.º 23
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     try {
         $this->validate($request, ['type' => 'required', 'content' => 'required|min:10']);
         $isactive = $request->input('is_active') ? true : false;
         $content = htmlspecialchars($request->input('content'), ENT_NOQUOTES);
         $pageobj = new Pages();
         $pageobj->where('id', $id)->update(['type' => $request->input('type'), 'content' => $request->input('content'), 'is_active' => $isactive]);
         return Redirect::to("/back/page/edit/{$id}")->with('message', $request->input('type') . ' was successfully updated');
     } catch (Exception $e) {
         return Redirect::to("/back/page/edit/{$id}")->with('message', 'Oops! Something went wrong. Please try again later');
     }
 }
Ejemplo n.º 24
0
 public function pageadd()
 {
     if ($this->request->data) {
         Pages::create()->save($this->request->data);
     }
     $this->redirect('admin::pages');
 }
Ejemplo n.º 25
0
 public function x($currency = null)
 {
     if ($this->request->query['json'] == true) {
         $this->_render['type'] = 'json';
     }
     if ($currency == null) {
         $this->redirect(array('controller' => 'ex', 'action' => 'dashboard/'));
     }
     $first_curr = strtoupper(substr($currency, 0, 3));
     $second_curr = strtoupper(substr($currency, 4, 3));
     $title = $first_curr . "/" . $second_curr;
     $currencyStatus = Trades::find('first', array('conditions' => array('trade' => $title)));
     $this->SetGraph($first_curr, $second_curr);
     $user = Session::read('default');
     $id = $user['_id'];
     //		if($id==null){$this->redirect(array('controller'=>'ex','action'=>'dashboard/'));}
     $details = Details::find('first', array('conditions' => array('user_id' => $id)));
     // if trade order is submitted by post ----------------
     if ($this->request->data) {
         $data = array('page.refresh' => true);
         Details::find('all')->save($data);
         $data = array('refresh' => true);
         Trades::find('all', array('conditions' => array('trade' => $title)))->save($data);
         $commission = Parameters::find('first', array('conditions' => array('commission' => true)));
         $SellMultiple = $this->request->data['SellMultiple'];
         $BuyMultiple = $this->request->data['BuyMultiple'];
         $SellIDs = $this->request->data['SellIDs'];
         $BuyIDs = $this->request->data['BuyIDs'];
         $Action = $this->request->data['Action'];
         if ($Action == "Buy") {
             if ((double) $this->request->data['BuyAmount'] <= 0) {
                 $this->redirect($this->request->params);
             }
             if ((double) $this->request->data['BuyPriceper'] <= 0) {
                 $this->redirect($this->request->params);
             }
             if ((double) $this->request->data['BuyCommission'] <= 0) {
                 $this->redirect($this->request->params);
             }
             if ((double) $this->request->data['BuyCommissionAmount'] <= 0) {
                 $this->redirect($this->request->params);
             }
             $PendingAction = 'Sell';
             $FirstCurrency = $this->request->data['BuyFirstCurrency'];
             $SecondCurrency = $this->request->data['BuySecondCurrency'];
             $Commission = $this->request->data['BuyCommission'];
             //				$CommissionAmount = $this->request->data['BuyCommissionAmount'];
             $CommissionCurrency = $this->request->data['BuyCommissionCurrency'];
             $Amount = $this->request->data['BuyAmount'];
             $PerPrice = $this->request->data['BuyPriceper'];
             $BalanceAmount = $details['balance'][$SecondCurrency];
             $CommissionAmount = $Amount * $commission['value'] / 100;
             $NewBalanceAmount = round($BalanceAmount - $Amount * $PerPrice, 8);
             $Currency = 'balance.' . $SecondCurrency;
             // Update balance of user with NewBalance Amount
             $data = array('balance.' . $SecondCurrency => (double) $NewBalanceAmount);
             $details = Details::find('first', array('conditions' => array('user_id' => $id)))->save($data);
         }
         if ($Action == "Sell") {
             if ((double) $this->request->data['SellAmount'] <= 0) {
                 $this->redirect($this->request->params);
             }
             if ((double) $this->request->data['SellPriceper'] <= 0) {
                 $this->redirect($this->request->params);
             }
             if ((double) $this->request->data['SellCommission'] <= 0) {
                 $this->redirect($this->request->params);
             }
             if ((double) $this->request->data['SellCommissionAmount'] <= 0) {
                 $this->redirect($this->request->params);
             }
             $PendingAction = 'Buy';
             $FirstCurrency = $this->request->data['SellFirstCurrency'];
             $SecondCurrency = $this->request->data['SellSecondCurrency'];
             $Commission = $this->request->data['SellCommission'];
             //				$CommissionAmount = $this->request->data['SellCommissionAmount'];
             $CommissionCurrency = $this->request->data['SellCommissionCurrency'];
             $Amount = $this->request->data['SellAmount'];
             $PerPrice = $this->request->data['SellPriceper'];
             $BalanceAmount = $details['balance'][$FirstCurrency];
             $CommissionAmount = $Amount * $PerPrice * $commission['value'] / 100;
             $NewBalanceAmount = round($BalanceAmount - $Amount, 8);
             $Currency = 'balance.' . $FirstCurrency;
             // Update balance of user with NewBalance Amount
             $data = array('balance.' . $FirstCurrency => (double) $NewBalanceAmount);
             $details = Details::find('first', array('conditions' => array('user_id' => $id)))->save($data);
         }
         $data = array('Action' => $Action, 'FirstCurrency' => $FirstCurrency, 'SecondCurrency' => $SecondCurrency, 'CommissionPercent' => (double) $Commission, 'Commission.Amount' => (double) $CommissionAmount, 'Commission.Currency' => $CommissionCurrency, 'Amount' => (double) $Amount, 'PerPrice' => (double) $PerPrice, 'DateTime' => new \MongoDate(), 'Completed' => 'N', 'IP' => $_SERVER['REMOTE_ADDR'], 'username' => $user['username'], 'user_id' => $user['_id']);
         // Create Order for the user
         $orders = Orders::create();
         $orders->save($data);
         $order_id = $orders->_id;
         $this->SendEmails($order_id, $user['_id']);
         //			$this->SendFriendsEmails($order_id,$user['_id']);
         /*
         if($PendingAction=="Buy"){
         	$PendingOrders = Orders::find('all',
         	array(
         		'conditions'=> array(
         			'Action' => $PendingAction,
         			'FirstCurrency' => $FirstCurrency,
         			'SecondCurrency' => $SecondCurrency,
         			'Completed' => 'N',
         			'user_id' => array('$ne' => $user['_id']),
         			'PerPrice' => array('$gte'=>(float)($PerPrice)),
         		),
         		'order'=>array('DateTime'=>'ASC')
         	));
         }
         if($PendingAction=="Sell"){
         	$PendingOrders = Orders::find('all',
         	array(
         		'conditions'=> array(
         			'Action' => $PendingAction,
         			'FirstCurrency' => $FirstCurrency,
         			'SecondCurrency' => $SecondCurrency,
         			'Completed' => 'N',
         			'user_id' => array('$ne' => $user['_id']),
         			'PerPrice' => array('$lte'=>(float)($PerPrice)),
         		),
         		'order'=>array('DateTime'=>'ASC')
         	));
         }
         
         	foreach($PendingOrders as $PO){
         		$PreviousOrder = 	$this->ChangePreviousOrder($PO['_id'],$order_id,$PerPrice,$user);
         		$this->updateBalance($PO['_id']);
         		$this->SendOrderCompleteEmails($PO['_id'],$PO['user_id']);						
         		
         		$NewOrder = $this->ChangeCurrentOrder($order_id,$PO['_id'],$PO['Amount'],$user);					
         		$this->updateBalance($order_id);
         		$this->SendOrderCompleteEmails($order_id,$user['_id']);						
         		
         		if($NewOrder==false){
         			break;
         		}
         		$order_id = $NewOrder;
         	}
         //				 exit;
         $this->redirect($this->request->params);			// get out of this page and load the page again without POST!			
         */
         if ($SellMultiple == "Y" || $BuyMultiple == "Y") {
             if ($SellMultiple == "Y") {
                 $IDs = $SellIDs;
             }
             if ($BuyMultiple == "Y") {
                 $IDs = $BuyIDs;
             }
             $ids = explode(",", $IDs);
             foreach ($ids as $id) {
                 if ($id != "") {
                     $PO = Orders::find('first', array('conditions' => array('_id' => new MongoID($id))));
                     //							print_r($PO['user_id']);
                     //							print_r($PO['username']);
                     $data = array('Completed' => 'Y', 'Transact.id' => $order_id, 'Transact.username' => $user['username'], 'Transact.user_id' => $user['_id'], 'Transact.DateTime' => new \MongoDate());
                     $orders = Orders::find('first', array('conditions' => array('_id' => $PO['_id'])))->save($data);
                     $orders = Orders::find('first', array('conditions' => array('_id' => $PO['_id'])));
                     $data = array('Completed' => 'Y', 'Transact.id' => $PO['_id'], 'Transact.username' => $PO['username'], 'Transact.user_id' => $PO['user_id'], 'Transact.DateTime' => new \MongoDate());
                     $orders = Orders::find('first', array('conditions' => array('_id' => $order_id)))->save($data);
                     $this->updateBalance($order_id);
                     $this->updateBalance($PO['_id']);
                     $this->SendOrderCompleteEmails($order_id, $user['_id']);
                     $this->SendOrderCompleteEmails($PO['_id'], $PO['user_id']);
                 }
             }
             $this->redirect($this->request->params);
         }
         //Start FOR loop-----------------------------------------------------
         $PendingOrders = Orders::find('all', array('conditions' => array('Action' => $PendingAction, 'FirstCurrency' => $FirstCurrency, 'SecondCurrency' => $SecondCurrency, 'Completed' => 'N', 'user_id' => array('$ne' => $user['_id']), 'PerPrice' => (double) $PerPrice), 'order' => array('DateTime' => 'ASC')));
         foreach ($PendingOrders as $PO) {
             if ((double) $PO['Amount'] == (double) $Amount) {
                 $data = array('Completed' => 'Y', 'Transact.id' => $order_id, 'Transact.username' => $user['username'], 'Transact.user_id' => $user['_id'], 'Transact.DateTime' => new \MongoDate());
                 $orders = Orders::find('first', array('conditions' => array('_id' => $PO['_id'])))->save($data);
                 $orders = Orders::find('first', array('conditions' => array('_id' => $PO['_id'])));
                 $data = array('Completed' => 'Y', 'Transact.id' => $PO['_id'], 'Transact.username' => $PO['username'], 'Transact.user_id' => $PO['user_id'], 'Transact.DateTime' => new \MongoDate());
                 $orders = Orders::find('first', array('conditions' => array('_id' => $order_id)))->save($data);
                 $this->updateBalance($order_id);
                 $this->updateBalance($PO['_id']);
                 $this->SendOrderCompleteEmails($order_id, $user['_id']);
                 $this->SendOrderCompleteEmails($PO['_id'], $PO['user_id']);
                 break;
             }
             if ((double) $PO['Amount'] > (double) $Amount) {
                 // Update Previous Order with New Order Amount and New Commission and Transact User
                 if ($PO['Action'] == "Buy") {
                     $PrevCommAmount = round($PO['CommissionPercent'] * $Amount / 100, 8);
                     $CurrCommAmount = round($PO['CommissionPercent'] * ($PO['Amount'] - $Amount) * $PO['PrePrice'] / 100, 8);
                     $PrevCommCurr = $PO['FirstCurrency'];
                     $CurrCommCurr = $PO['SecondCurrency'];
                 } else {
                     $PrevCommAmount = round((double) $PO['CommissionPercent'] * (double) $Amount * (double) $PerPrice / 100, 8);
                     $CurrCommAmount = round($PO['CommissionPercent'] * $Amount / 100, 8);
                     $PrevCommCurr = $PO['SecondCurrency'];
                     $CurrCommCurr = $PO['FirstCurrency'];
                 }
                 $data = array('Commission.Amount' => (double) $PrevCommAmount, 'Amount' => (double) $Amount, 'Completed' => 'Y', 'Transact.id' => $order_id, 'Transact.username' => $user['username'], 'Transact.user_id' => $user['_id'], 'Transact.DateTime' => new \MongoDate(), 'Order' => 'P>C: Update Previous Commission and Amount and Complete Order');
                 $orders = Orders::find('first', array('conditions' => array('_id' => $PO['_id'])))->save($data);
                 // --------------------Complete
                 // Create new Order for Previous Order so that the order tallies
                 if ($PO['Action'] == "Buy") {
                     $PrevCommAmount = round((double) round((double) $PO['Amount'] - (double) $Amount, 8) * (double) $PO['CommissionPercent'] / 100, 8);
                 } else {
                     $PrevCommAmount = round((double) round((double) $PO['Amount'] - (double) $Amount, 8) * (double) $PO['PerPrice'] * (double) $PO['CommissionPercent'] / 100, 8);
                 }
                 $data = array('Amount' => (double) round((double) $PO['Amount'] - (double) $Amount, 8), 'Action' => $PO['Action'], 'FirstCurrency' => $PO['FirstCurrency'], 'SecondCurrency' => $PO['SecondCurrency'], 'CommissionPercent' => (double) $PO['CommissionPercent'], 'Commission.Amount' => (double) $PrevCommAmount, 'Commission.Currency' => $PrevCommCurr, 'PerPrice' => (double) $PO['PerPrice'], 'DateTime' => $PO['DateTime'], 'Completed' => 'N', 'IP' => $PO['IP'], 'username' => $PO['username'], 'user_id' => $PO['user_id'], 'Order' => 'P>C: Create New Previous Order with Balance details');
                 $orders = Orders::create();
                 $orders->save($data);
                 //-------------------Complete
                 //Update New order with Transact User
                 $data = array('Completed' => 'Y', 'Transact.id' => $PO['_id'], 'Transact.username' => $PO['username'], 'Transact.user_id' => $PO['user_id'], 'Transact.DateTime' => new \MongoDate(), 'Order' => 'P>C: Update current order no change in commission or amount');
                 $orders = Orders::find('first', array('conditions' => array('_id' => $order_id)))->save($data);
                 //---------------------Complete
                 //To update Balance
                 $this->updateBalance($order_id);
                 $this->updateBalance($PO['_id']);
                 $this->SendOrderCompleteEmails($order_id, $user['_id']);
                 $this->SendOrderCompleteEmails($PO['_id'], $PO['user_id']);
                 break;
             }
             if ((double) $PO['Amount'] < (double) $Amount) {
                 // Update Previous Order with New Order Amount and New Commission and Transact User
                 if ($PO['Action'] == "Buy") {
                     $PrevCommAmount = round($PO['CommissionPercent'] * ($PO['Amount'] - $Amount) / 100, 8);
                     $CurrCommAmount = round($PO['CommissionPercent'] * ($PO['Amount'] - $Amount) * $PO['PrePrice'] / 100, 8);
                     $PrevCommCurr = $PO['FirstCurrency'];
                     $CurrCommCurr = $PO['SecondCurrency'];
                 } else {
                     $PrevCommAmount = round($PO['CommissionPercent'] * ($PO['Amount'] - $Amount) * $PO['PerPrice'] / 100, 8);
                     $CurrCommAmount = round($PO['CommissionPercent'] * ($PO['Amount'] - $Amount) / 100, 8);
                     $PrevCommCurr = $PO['SecondCurrency'];
                     $CurrCommCurr = $PO['FirstCurrency'];
                 }
                 if ($PO['Action'] == "Buy") {
                     $PrevCommAmount = round($PO['CommissionPercent'] * $PO['Amount'] / 100, 8);
                 } else {
                     $PrevCommAmount = round($PO['CommissionPercent'] * $PO['Amount'] * $PO['PerPrice'] / 100, 8);
                 }
                 $data = array('Commission.Amount' => (double) $PrevCommAmount, 'Amount' => (double) $PO['Amount'], 'Completed' => 'Y', 'Transact.id' => $order_id, 'Transact.username' => $user['username'], 'Transact.user_id' => $user['_id'], 'Transact.DateTime' => new \MongoDate(), 'Order' => 'P<C: Update Previous Record');
                 $orders = Orders::find('first', array('conditions' => array('_id' => $PO['_id'])))->save($data);
                 //--------------------Complete
                 // Update current order with new commission and amount
                 if ($PO['Action'] == "Buy") {
                     $CurrCommAmount = round($PO['CommissionPercent'] * $PO['Amount'] * $PO['PerPrice'] / 100, 8);
                 } else {
                     $CurrCommAmount = round($PO['CommissionPercent'] * $PO['Amount'] / 100, 8);
                 }
                 $data = array('Commission.Amount' => (double) $CurrCommAmount, 'Amount' => (double) $PO['Amount'], 'Completed' => 'Y', 'Transact.id' => $PO['_id'], 'Transact.username' => $PO['username'], 'Transact.user_id' => $PO['user_id'], 'Transact.DateTime' => new \MongoDate(), 'Order' => 'P<C: Update current record');
                 $orders = Orders::find('first', array('conditions' => array('_id' => $order_id)))->save($data);
                 //--------------------Complete
                 //Create a new order of pending amount
                 if ($PO['Action'] == 'Buy') {
                     $CurrCommAmount = round($PO['CommissionPercent'] * (double) round((double) $Amount - (double) $PO['Amount'], 8) * $PerPrice / 100, 8);
                 } else {
                     $CurrCommAmount = round($PO['CommissionPercent'] * (double) round((double) $Amount - (double) $PO['Amount'], 8) / 100, 8);
                 }
                 $data = array('Action' => $Action, 'FirstCurrency' => $FirstCurrency, 'SecondCurrency' => $SecondCurrency, 'CommissionPercent' => (double) $Commission, 'Commission.Amount' => (double) $CurrCommAmount, 'Commission.Currency' => $CurrCommCurr, 'Amount' => (double) round((double) $Amount - (double) $PO['Amount'], 8), 'PerPrice' => (double) $PerPrice, 'DateTime' => new \MongoDate(), 'Completed' => 'N', 'IP' => $_SERVER['REMOTE_ADDR'], 'username' => $user['username'], 'user_id' => $user['_id'], 'Order' => 'P<C: Create New Previous Order with Balance details');
                 $orders = Orders::create();
                 $orders->save($data);
                 $this->updateBalance($order_id);
                 $this->updateBalance($PO['_id']);
                 $this->SendOrderCompleteEmails($order_id, $user['_id']);
                 $this->SendOrderCompleteEmails($PO['_id'], $PO['user_id']);
                 break;
             }
         }
         // End FOR Loop -----------------------------------
         //			exit; // Temporary EXIT
         $this->redirect($this->request->params);
         // get out of this page and load the page again without POST!
     }
     // submitted by post!
     // without POST... load the page!
     $details = Details::find('first', array('conditions' => array('user_id' => $id)));
     $mongodb = Connections::get('default')->connection;
     $TotalSellOrders = Orders::connection()->connection->command(array('aggregate' => 'orders', 'pipeline' => array(array('$project' => array('_id' => 0, 'Action' => '$Action', 'Amount' => '$Amount', 'Completed' => '$Completed', 'FirstCurrency' => '$FirstCurrency', 'SecondCurrency' => '$SecondCurrency', 'TotalAmount' => array('$multiply' => array('$Amount', '$PerPrice')))), array('$match' => array('Action' => 'Sell', 'Completed' => 'N', 'FirstCurrency' => $first_curr, 'SecondCurrency' => $second_curr)), array('$group' => array('_id' => array(), 'Amount' => array('$sum' => '$Amount'), 'TotalAmount' => array('$sum' => '$TotalAmount'))), array('$sort' => array('PerPrice' => 1)))));
     $TotalBuyOrders = Orders::connection()->connection->command(array('aggregate' => 'orders', 'pipeline' => array(array('$project' => array('_id' => 0, 'Action' => '$Action', 'Amount' => '$Amount', 'Completed' => '$Completed', 'FirstCurrency' => '$FirstCurrency', 'SecondCurrency' => '$SecondCurrency', 'TotalAmount' => array('$multiply' => array('$Amount', '$PerPrice')))), array('$match' => array('Action' => 'Buy', 'Completed' => 'N', 'FirstCurrency' => $first_curr, 'SecondCurrency' => $second_curr)), array('$group' => array('_id' => array(), 'Amount' => array('$sum' => '$Amount'), 'TotalAmount' => array('$sum' => '$TotalAmount'))), array('$sort' => array('PerPrice' => 1)))));
     $SellOrders = Orders::connection()->connection->command(array('aggregate' => 'orders', 'pipeline' => array(array('$project' => array('_id' => 1, 'Action' => '$Action', 'Amount' => '$Amount', 'user_id' => '$user_id', 'username' => '$username', 'PerPrice' => '$PerPrice', 'Completed' => '$Completed', 'FirstCurrency' => '$FirstCurrency', 'SecondCurrency' => '$SecondCurrency')), array('$match' => array('Action' => 'Sell', 'Completed' => 'N', 'FirstCurrency' => $first_curr, 'SecondCurrency' => $second_curr)), array('$group' => array('_id' => array('PerPrice' => '$PerPrice', 'username' => '$username', 'user_id' => '$user_id', 'id' => '$_id'), 'Amount' => array('$sum' => '$Amount'), 'No' => array('$sum' => 1))), array('$sort' => array('_id.PerPrice' => 1)), array('$limit' => 20))));
     $BuyOrders = Orders::connection()->connection->command(array('aggregate' => 'orders', 'pipeline' => array(array('$project' => array('_id' => 1, 'Action' => '$Action', 'Amount' => '$Amount', 'user_id' => '$user_id', 'username' => '$username', 'PerPrice' => '$PerPrice', 'Completed' => '$Completed', 'FirstCurrency' => '$FirstCurrency', 'SecondCurrency' => '$SecondCurrency')), array('$match' => array('Action' => 'Buy', 'Completed' => 'N', 'FirstCurrency' => $first_curr, 'SecondCurrency' => $second_curr)), array('$group' => array('_id' => array('PerPrice' => '$PerPrice', 'username' => '$username', 'user_id' => '$user_id', 'id' => '$_id'), 'Amount' => array('$sum' => '$Amount'), 'No' => array('$sum' => 1))), array('$sort' => array('_id.PerPrice' => -1)), array('$limit' => 20))));
     $YourOrders = Orders::find('all', array('conditions' => array('user_id' => $id, 'Completed' => 'N', 'FirstCurrency' => $first_curr, 'SecondCurrency' => $second_curr), 'order' => array('DateTime' => -1)));
     $YourCompleteOrders = Orders::find('all', array('conditions' => array('user_id' => $id, 'Completed' => 'Y', 'FirstCurrency' => $first_curr, 'SecondCurrency' => $second_curr), 'order' => array('DateTime' => -1)));
     $page = Pages::find('first', array('conditions' => array('pagename' => 'ex/x/' . $currency)));
     $this->SetForecastGraph($SellOrders, $BuyOrders, $first_curr, $second_curr);
     $title = $page['title'];
     $keywords = $page['keywords'];
     $description = $page['description'];
     $settings = Settings::find('first');
     return compact('title', 'details', 'SellOrders', 'BuyOrders', 'TotalSellOrders', 'TotalBuyOrders', 'YourOrders', 'YourCompleteOrders', 'keywords', 'description', 'settings', 'currencyStatus');
 }
Ejemplo n.º 26
0
<?php

use lithium\storage\Session;
use app\models\Pages;
if (!isset($title)) {
    $page = Pages::find('first', array('conditions' => array('pagename' => 'home')));
    $title = $page['title'];
    $keywords = $page['keywords'];
    $description = $page['description'];
}
$user = Session::read('member');
?>
<!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">
	<meta name="keywords" content="<?php 
if (isset($keywords)) {
    echo $keywords;
}
?>
">
	<meta name="description" content="<?php 
if (isset($description)) {
    echo $description;
}
?>
">
 <meta name="author" content="XGCwallet.com">
Ejemplo n.º 27
0
 public function sellshares()
 {
     $page = Pages::find('first', array('conditions' => array('pagename' => 'company/sellshares')));
     $title = $page['title'];
     $keywords = $page['keywords'];
     $description = $page['description'];
     return compact('title', 'keywords', 'description');
 }
Ejemplo n.º 28
0
 public function assign_volume_type($From, $To, $VolumeType)
 {
     /* 		echo $From;
     		echo $To;
     		echo $VolumeType;
      */
     $From_id = Pages::find(array('fields' => '_id'), array('conditions' => array('filename' => $From)));
     $To_id = Pages::find(array('fields' => '_id'), array('conditions' => array('_id' => $To)));
     $Types_id = Types::find(array('fields' => '_id'), array('conditions' => array('_id' => $VolumeType)));
     foreach ($Types_id as $t) {
         $type_id = $t['_id'];
         $type_name = $t['name'];
         $type_no = $t['no'];
     }
     foreach ($From_id as $t) {
         $from_sort_order = $t['sort_order'];
         $volume_number = $t['volume_number'];
     }
     foreach ($To_id as $t) {
         $to_sort_order = $t['sort_order'];
     }
     $data = array('type.no' => $type_no, 'type.id' => $type_id, 'type.name' => $type_name, 'ip' => $_SERVER['REMOTE_ADDR']);
     for ($i = $from_sort_order; $i <= $to_sort_order; $i++) {
         $new_page = Pages::find(array('fields' => '_id'), array('conditions' => array('sort_order' => $i, 'volume_number' => $volume_number)))->save($data);
     }
     //		return $this->render(array('json' => $data = array($new_page), 'status'=> 200));
 }
Ejemplo n.º 29
0
 public static function getPageByCode($code)
 {
     return Pages::where('code', $code)->where('active', 1)->first();
     return new \stdClass();
 }
Ejemplo n.º 30
0
 function dosave($records, $filename, $tagname)
 {
     // Find the record for the $filename to modify
     $findItem = Pages::find('all', array('conditions' => array('filename' => $filename)));
     $variable = array();
     // check  for the tagname, if present, assign the value to the variable...
     /* 	foreach($findItem as $f){
     		foreach($f->$tagname as $key=>$val){
     			array_push($variable,$key=$val);
     		}
     	} 
      */
     /* 	$variable = array(); */
     // add all values from $record (input by client) to $variable (data in Mongo)
     foreach ($records as $r) {
         array_push($variable, $r);
     }
     //	print_r($variable);exit;
     array_filter($variable);
     // add it to the original tagname as an array
     /* $data = array('$pullAll'=>array($tagname=>""));
     //print_r($data);exit;
     	$findPage = Pages::find(array('fields'=>'_id'),
     				array('conditions'=>array(
     							'filename'=>$filename
     						)
     					))->save($data);
      */
     $data = array($tagname => array_unique($variable));
     //print_r($data);
     //exit;
     // find the pagename with the file and save the $data....
     $findPage = Pages::find(array('fields' => '_id'), array('conditions' => array('filename' => $filename)))->save($data);
 }