Exemple #1
0
 public function load()
 {
     if (isset($_GET['_gn_']) && !$this->player->isSpy) {
         require_once MODEL_PATH . "profile.php";
         $mprof = new ProfileModel();
         $mprof->resetGNewsFlag($this->player->playerId);
     }
     parent::load();
     $this->heroCount = $this->data['hero_in_village_id'] == $this->data['selected_village_id'] ? 1 : 0;
     $t_arr = explode("|", $this->data['troops_num']);
     foreach ($t_arr as $t_str) {
         $t2_arr = explode(":", $t_str);
         $t2_arr = explode(",", $t2_arr[1]);
         foreach ($t2_arr as $t2_str) {
             $tnum = explode(" ", $t2_str);
             $tid = explode(" ", $t2_str);
             list($tid, $tnum) = $tid;
             if ($tid == 99 || $tnum == 0) {
                 continue;
             }
             if ($tnum == 0 - 1) {
                 $this->heroCount++;
                 continue;
             }
             if (isset($this->troops[$tid])) {
                 $this->troops[$tid] += $tnum;
             } else {
                 $this->troops[$tid] = $tnum;
             }
         }
     }
     ksort($this->troops, SORT_NUMERIC);
 }
Exemple #2
0
 public function changeProfile($id)
 {
     if (!empty($_POST)) {
         $instance = new ProfileModel();
         $instance->update($id, ['first_name' => $_POST['first_name'], 'last_name' => $_POST['last_name'], 'cpostal' => $_POST['cpostal'], 'adress' => $_POST['adress'], 'departement' => $_POST['departement'], 'region' => $_POST['region'], 'city' => $_POST['city'], 'country' => $_POST['country'], 'birthday' => $_POST['birthday']]);
     }
 }
Exemple #3
0
 public function load()
 {
     parent::load();
     if (!$this->globalModel->isGameOver()) {
         exit(0);
     } else {
         $m = new ProfileModel();
         $this->playerData = $m->getWinnerPlayer();
         $m->dispose();
     }
 }
 public function authAction()
 {
     $model = new PageModel();
     if (isPost()) {
         $email = post('email');
         $password = md5(post('password'));
         $user = $model->getUserByEP($email, $password);
         if ($user->id) {
             $modelProfile = new ProfileModel();
             $updateString = "`looking` = 0";
             $recId = $modelProfile->checkDiscoverRecord($user->id);
             if (!empty($recId->id)) {
                 $modelProfile->updateDiscoverRecord($recId->id, $updateString);
             }
             if (post("remember-me") == 1) {
                 $cookie_live_time = 7 * 24 * 60 * 60;
                 setMyCookie('user', $user->id, time() + $cookie_live_time);
             }
             setSession('user', $user->id, false);
             redirect(url($user->id));
         } else {
             $error = "error";
             setSession('login_error', "invalid");
             //  redirect(url());
             setMyCookie('login_error', "You have input the incorrect username and password, try again", time() + 5);
             redirect(url('page', 'index'));
         }
     }
 }
 public function indexAction()
 {
     header('content-type: application/json');
     header('Access-Control-Allow-Origin: *');
     header('Access-Control-Allow-Methods: POST');
     $valid = true;
     $errors = [];
     $username = trim(ucwords(strtolower(htmlentities($_POST['username']))));
     $password = hash('sha256', strrev(ProfileModel::getTimestamp($this->pdo, $username)) . htmlentities($_POST['password']) . '\\Rand0msalT/');
     if (!isset($username) || empty($username)) {
         $errors['username'] = '******';
         $valid = false;
     } elseif (SigninModel::checkUsername($this->pdo, $username) !== $username) {
         $errors['username'] = '******'existe pas</span>';
         $valid = false;
     } elseif (!isset($password) || empty($password)) {
         $errors['password'] = '******';
         $valid = false;
     } elseif (SigninModel::getPassword($this->pdo, $username) !== $password) {
         $errors['password'] = '******';
         $valid = false;
     }
     $errors['valid'] = $valid;
     if ($valid) {
         if (isset($_POST['remember'])) {
             CookieController::create($this->pdo, $username, $password);
         }
         AuthModel::authUser($this->pdo, $username, $password);
     }
     echo json_encode($errors);
 }
 public function usersearch($data = Null)
 {
     $inputs = Input::get();
     $groupmemberid = groupmemberModel::where('group_id', $data)->get()->lists('user_id');
     $groupmemberuserid = ProfileModel::whereNotIn('user.ID', $groupmemberid)->lists('ID');
     $searcheduser = Input::get('usersearch');
     $groupmemberuseridlist = ProfileModel::select('profilepicture', 'firstname', 'lastname', 'username', 'ID')->where('username', 'like', '%' . $searcheduser . '%')->whereIn('user.ID', $groupmemberuserid)->Orwhere('firstname', 'like', '%' . $searcheduser . '%')->whereIn('user.ID', $groupmemberuserid)->where('user.status', 1)->get();
     return View::make('user/view/registermember')->with('group_id', $data)->with('searcheduser', $searcheduser)->with('savegroupmembers', $groupmemberuseridlist);
 }
 public function deleteAction()
 {
     if (isset($_SESSION['auth'])) {
         ProfileModel::deleteUser($this->pdo, $_SESSION['auth']['username']);
         header('Location: /logout');
         exit;
     } else {
         header('Location: /login');
         exit;
     }
 }
 public function indexAction()
 {
     if (isset($_SESSION['auth']) && $_SESSION['auth']['permissions'] === 'superadmin') {
         header('content-type: application/json');
         header('Access-Control-Allow-Origin: *');
         header('Access-Control-Allow-Methods: GET');
         echo json_encode(ProfileModel::showLastUsers($this->pdo));
     } else {
         header('Location: /');
         exit;
     }
 }
Exemple #9
0
 /**
  * import
  *
  * @access public
  * @return void
  */
 public function import()
 {
     $shows = ShowModel::getAllShows();
     if (count($shows) == 0) {
         throw new \Exception("Failed to retrieve all the shows from Spinitron. Check your settings.");
     }
     foreach ($shows as $show) {
         $this->createShow($show);
     }
     $profiles = ProfileModel::getAllDJProfiles();
     if (count($profiles) == 0) {
         throw new \Exception("Failed to retrieve all the DJ profiles from Spinitron. Check your settings.");
     }
     foreach ($profiles as $profile) {
         $this->createProfile($profile);
     }
 }
 public function setLoseAction()
 {
     $response['error'] = 0;
     if (isPost()) {
         $post = allPost();
         $model = new ProfileModel();
         if ($post['mid']) {
             $match = $model->getMatchByID($post['mid']);
             if ($match->blocked && !($match->pwin == "1" && $match->uwin == "2") && !($match->pwin == "2" && $match->uwin == "1")) {
                 if (Request::getParam('user')->id == $match->uid) {
                     $data['uwin'] = '2';
                     if ($match->pwin == "1") {
                         $data['status'] = 2;
                         $winner = $match->pid;
                         $loser = $match->uid;
                     }
                 } elseif (Request::getParam('user')->id == $match->pid) {
                     $data['pwin'] = '2';
                     if ($match->uwin == "1") {
                         $data['status'] = 2;
                         $winner = $match->uid;
                         $loser = $match->pid;
                     }
                 }
                 if ($data && $model->updateMatchWL($post['mid'], $data)) {
                     if ($winner && $loser) {
                         if ($winner == Request::getParam('user')->id) {
                             $userW = Request::getParam('user');
                             $userL = $model->getUserByID($loser);
                         } else {
                             $userW = $model->getUserByID($winner);
                             $userL = Request::getParam('user');
                         }
                         $countGamesW = $userW->wins + $userW->losses + 1;
                         $countGamesL = $userL->wins + $userL->losses + 1;
                         $eloW = elo($userW->elo, $userL->elo, $countGamesW, 1);
                         $eloL = elo($userL->elo, $userW->elo, $countGamesL, 0);
                         $model->updateWLStat($winner, $loser, $eloW, $eloL);
                     }
                 } else {
                     $response['error'] = Lang::translate("MATCH_DB_ERROR");
                 }
             } else {
                 $response['error'] = Lang::translate("MATCH_ENDED");
             }
         }
     } else {
         $response['error'] = Lang::translate("MATCH_EMPTY_DATA");
     }
     echo json_encode($response);
     exit;
 }
    public function laravel_register()
    {
        $username = Input::get('username');
        $email = Input::get('email');
        $pass = Input::get('password');
        $password = Hash::make(Input::get('password'));
        $dateofbirth = Input::get('dateofbirth');
        $data = Input::except(array('_token', 'client_login'));
        // $validator = Validator::make($data,$rule);
        $validator = Validator::make($data, ProfileModel::$webrule);
        $lantyp = Session::get('language');
        $data['password'] = $password;
        if ($validator->fails()) {
            //return $validator->messages();
            if ($validator->messages()->first('terms') != "") {
                $terms = "Accept terms";
            } else {
                $terms = "";
            }
            $languageDetails = languageModel::select($lantyp, 'ctrlCaptionId')->whereIn('value_en', [$validator->messages()->first('username'), $validator->messages()->first('email'), $validator->messages()->first('password'), $validator->messages()->first('dateofbirth'), $terms])->get()->toArray();
            foreach ($languageDetails as $key => $val) {
                if (in_array($val['ctrlCaptionId'], ['alert_enterusername', 'alert_alreadyuser'])) {
                    $er_data['username'] = "******" . $val['ctrlCaptionId'] . "'>" . $val[$lantyp] . "</span>";
                } elseif (in_array($val['ctrlCaptionId'], ['alert_enteremail', 'alert_validemail', 'alertr_emailalready'])) {
                    $er_data['email'] = "<span id='" . $val['ctrlCaptionId'] . "'>" . $val[$lantyp] . "</span>";
                } elseif (in_array($val['ctrlCaptionId'], ['alert_enterpassword', 'alert_minpass5'])) {
                    $er_data['password'] = "******" . $val['ctrlCaptionId'] . "'>" . $val[$lantyp] . "</span>";
                } elseif (in_array($val['ctrlCaptionId'], ['alert_enterdob'])) {
                    $er_data['dateofbirth'] = "<span id='" . $val['ctrlCaptionId'] . "'>" . $val[$lantyp] . "</span>";
                } else {
                    if (in_array($val['ctrlCaptionId'], ['alert_enterterms'])) {
                        $er_data['terms'] = "<span id='" . $val['ctrlCaptionId'] . "'>" . $val[$lantyp] . "</span>";
                    }
                }
            }
            //return $er_data;
            return View::make('user/register/userregister')->with('er_data', $er_data)->with('old_value', $data);
        } else {
            unset($data['terms']);
            $lantyp = Session::get('language');
            $data['timezone'] = "EST";
            $data['status'] = 1;
            $userregister = ProfileModel::create($data);
            Mail::send([], array('pass' => $pass, 'email' => $email, 'username' => $username), function ($message) use($pass, $email, $username) {
                //$user = MailTemplate::find(1);
                //$mail_body = $user->MailContent;
                //$mail_body = str_replace("{password}", Session::get('sess_string'), $mail_body);
                /* $mail_body = "Dear {username},<br><br>Your DingDatt Registration successfully completed.Your Login details are<br><br>Username: {username}<br>Password: {password} <br><br> Thank You, <br><br>Regards,<br>DingDatt";
                   $mail_body = str_replace("{password}", $pass, $mail_body);
                   $mail_body = str_replace("{username}", $username, $mail_body); */
                $mail_body = '<style>.thank{text-align:center; width:100%;}
					.but_color{color:#ffffff;}
					.cont_name{width:100px;}
					.cont_value{width:500px;}
					
					</style>
			 <body style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif; margin:0px auto; padding:0px;">

				<div style="margin:0px auto;background:#e5e5e5;float:left;	width:98%;	height:30px;margin:0px 1%;  border-bottom:#005377 1px solid;vertical-align: text-middle;">
					&nbsp;&nbsp;<a href="' . URL() . '"><img src="' . URL::to('assets/images/logo.png') . '" style="margin-top:3px; line-height:20px;" /></a>&nbsp;&nbsp;
				</div>
				<div style="background:#ffffff;float:left;padding:10px 20px;margin:1px 1%;" >
					<div class="thank" style="font-size:16px;color: #078AC2;font-weight:bold;float:left;width:100%;margin-top:10px;text-align:left;">Dear ' . $username . '</div>
					
					<div style="font-size:12px;	color: #000000;	float:left;padding:10px 2px;width:100%;margin:15px;">Your DingDatt Registration successfully completed.Your Login details are<br><br>Username: '******'<br>Password: '******'
			 </div>
					
					<div style="margin:10px;"><a href="' . URL() . '"><img src="' . URL::to('assets/inner/images/vist_dingdatt.png') . '" width="120" height="30" /></a>
					</div>
				</div>
											
				<div style="font-size:12px; margin-top:10px;color: #5b5b5b;/*	background:#e5e5e5;*/width:95%;vertical-align: text-middle;height:30px;margin:0% 1%;padding:0px 15px; border-top:#005377 1px solid; border-bottom:5px solid background:#e5e5e5;line-height:25px; ">
				
				</body>';
                $message->setBody($mail_body, 'text/html');
                $message->to($email);
                $message->subject('DingDatt Registration');
            });
            $labelname = ['txt_userdetaile_save_msg'];
            $languageDetails = languageModel::select($lantyp)->whereIn('ctrlCaptionId', $labelname)->get()->toArray();
            return View::make('user/register/userregister')->with('Message', $languageDetails[0][$lantyp]);
            //return Redirect::to('userregister')->with('Message', );
            // return Redirect::to('userregister')->with('Message', $languageDetails[0][$lantyp]);
        }
    }
 public function indexAction()
 {
     header('content-type: application/json');
     header('Access-Control-Allow-Origin: *');
     header('Access-Control-Allow-Methods: POST');
     $valid = true;
     $errors = [];
     $username = trim(ucwords(strtolower(htmlentities($_POST['username']))));
     $first_name = trim(ucwords(strtolower(htmlentities($_POST['first-name']))));
     $last_name = trim(ucwords(strtolower(htmlentities($_POST['last-name']))));
     $mail = trim(htmlentities(strtolower($_POST['mail'])));
     $password = trim(htmlentities($_POST['password']));
     $password2 = trim(htmlentities($_POST['password2']));
     $old_username = $_SESSION['auth']['username'];
     $id = ProfileModel::getID($this->pdo, $old_username);
     $timestamp = ProfileModel::getTimestamp($this->pdo, $old_username);
     if (!isset($username) || empty($username)) {
         $errors['username'] = '******';
         $valid = false;
     } elseif (strlen($username) < 6) {
         $errors['username'] = '******';
         $valid = false;
     } elseif (strlen($username) > 24) {
         $errors['username'] = '******';
         $valid = false;
     }
     if (!isset($first_name) || empty($first_name)) {
         $errors['firstName'] = '<span class="errors">Non saisi</span>';
         $valid = false;
     } elseif (strlen($first_name) < 2) {
         $errors['firstName'] = '<span class="errors">2 caractères min</span>';
         $valid = false;
     } elseif (strlen($first_name) > 32) {
         $errors['firstName'] = '<span class="errors">32 caractères max</span>';
         $valid = false;
     }
     if (!isset($last_name) || empty($last_name)) {
         $errors['lastName'] = '<span class="errors">Non saisi</span>';
         $valid = false;
     } elseif (strlen($last_name) < 2) {
         $errors['lastName'] = '<span class="errors">2 caractères min</span>';
         $valid = false;
     } elseif (strlen($last_name) > 32) {
         $errors['lastName'] = '<span class="errors">32 caractères max</span>';
         $valid = false;
     }
     if (!isset($mail) || empty($mail)) {
         $errors['mail'] = '<span class="errors">Non saisi</span>';
         $valid = false;
     } elseif (!filter_var($mail, FILTER_VALIDATE_EMAIL)) {
         $errors['mail'] = '<span class="errors">Format incorrect</span>';
         $valid = false;
     }
     if (!isset($password) || empty($password)) {
         $password = SigninModel::getPassword($this->pdo, $old_username);
         $hash = $password;
         $empty_pass = true;
     } elseif (strlen($password) < 8) {
         $errors['password'] = '******';
         $valid = false;
     } else {
         $hash = hash('sha256', strrev($timestamp) . $password . '\\Rand0msalT/');
     }
     if (!isset($password2) || empty($password2)) {
         if (isset($empty_pass)) {
             $password2 = $password;
         } else {
             $errors['password2'] = '<span class="errors">Non saisi</span>';
             $valid = false;
         }
     } elseif ($password2 !== $password) {
         $errors['password2'] = '<span class="errors">Non identiques</span>';
         $valid = false;
     }
     $errors['valid'] = $valid;
     if ($valid) {
         ProfileModel::editUser($this->pdo, $id, $old_username, $username, $first_name, $last_name, $mail, $hash);
         // Update session variables
         unset($_SESSION);
         session_destroy();
         setcookie('auth', '', time() - 3600, '/', null, null, true);
         session_start();
         AuthModel::authUser($this->pdo, $username, $hash);
     }
     echo json_encode($errors);
 }
Exemple #13
0
 function run($db, $type)
 {
     $test = new \Test();
     // setup
     ///////////////////////////////////
     $author = new \AuthorModel();
     $news = new \NewsModel();
     $profile = new \ProfileModel();
     $tag = new \TagModel();
     $ac = $author::resolveConfiguration();
     $author_pk = is_int(strpos($type, 'sql')) ? $ac['primary'] : '_id';
     $nc = $news::resolveConfiguration();
     $news_pk = is_int(strpos($type, 'sql')) ? $nc['primary'] : '_id';
     $tc = $tag::resolveConfiguration();
     $tag_pk = is_int(strpos($type, 'sql')) ? $tc['primary'] : '_id';
     $authorIDs = $author->find()->getAll('_id');
     $all = $news->find();
     $newsIDs = $all->getAll('_id');
     $profileIDs = $profile->find()->getAll('_id');
     $tagIDs = $tag->find()->getAll('_id');
     // add another relation
     $news->load(array('title = ?', 'CSS3 Showcase'));
     $news->author = $author->load(array($author_pk . ' = ?', $authorIDs[0]));
     $news->save();
     $news->reset();
     $author->reset();
     // has-filter on belongs-to relation
     ///////////////////////////////////
     $result = $author->has('news', array('title like ?', '%Image%'))->afind();
     $test->expect(count($result) == 1 && $result[0]['name'] == 'Johnny English', $type . ': has filter on many-to-one field');
     $test->expect(count($result[0]['news']) == 2 && $result[0]['news'][0]['title'] == 'Responsive Images' && $result[0]['news'][1]['title'] == 'CSS3 Showcase', $type . ': has filter does not prune relation set');
     $result = $news->has('author', array('name = ?', 'Johnny English'))->afind();
     $test->expect(count($result) == 2 && $result[0]['title'] == 'Responsive Images' && $result[1]['title'] == 'CSS3 Showcase', $type . ': has filter on one-to-many field');
     // add another profile
     $profile->message = 'Beam me up, Scotty!';
     $profile->author = $authorIDs[2];
     $profile->save();
     $profile->reset();
     $result = $author->has('profile', array('message LIKE ?', '%Scotty%'))->afind();
     $test->expect(count($result) == 1 && $result[0]['name'] == 'James T. Kirk' && $result[0]['profile']['message'] == 'Beam me up, Scotty!', $type . ': has filter on one-to-one field');
     $result = $profile->has('author', array('name LIKE ?', '%Kirk%'))->afind();
     $test->expect(count($result) == 1 && $result[0]['message'] == 'Beam me up, Scotty!' && $result[0]['author']['name'] == 'James T. Kirk', $type . ': has filter on one-to-one field, inverse');
     // add mm tags
     $news->load(array('title = ?', 'Responsive Images'));
     $news->tags2 = array($tagIDs[0], $tagIDs[1]);
     $news->save();
     $news->load(array('title = ?', 'CSS3 Showcase'));
     $news->tags2 = array($tagIDs[1], $tagIDs[2]);
     $news->save();
     $news->reset();
     $result = $news->has('tags2', array('title like ?', '%Design%'))->find();
     $test->expect(count($result) == 1 && $result[0]['title'] == 'Responsive Images', $type . ': has filter on many-to-many field');
     $result = $news->has('tags2', array('title = ?', 'Responsive'))->find();
     $test->expect(count($result) == 2 && $result[0]['title'] == 'Responsive Images' && $result[1]['title'] == 'CSS3 Showcase', $type . ': has filter on many-to-many field, additional test');
     $result = $tag->has('news', array('title = ?', 'Responsive Images'))->find();
     $test->expect(count($result) == 2 && $result[0]['title'] == 'Web Design' && $result[1]['title'] == 'Responsive', $type . ': has filter on many-to-many field, inverse');
     // add another tag
     $news->load(array('title = ?', 'Touchable Interfaces'));
     $news->tags2 = array($tagIDs[1]);
     $news->save();
     $news->reset();
     $tag->has('news', array('text LIKE ? and title LIKE ?', '%Lorem%', '%Interface%'));
     $result = $tag->find();
     $test->expect(count($result) == 1 && $result[0]['title'] == 'Responsive', $type . ': has filter with multiple conditions');
     $news->has('tags2', array('title = ? OR title = ?', 'Usability', 'Web Design'));
     $result = $news->afind(array('text = ?', 'Lorem Ipsun'));
     $test->expect(count($result) == 1 && $result[0]['title'] == 'Responsive Images', $type . ': find with condition and has filter');
     $news->load(array('title = ?', 'Responsive Images'));
     $news->author = $authorIDs[1];
     $news->save();
     $news->reset();
     $news->has('tags2', array('title = ? OR title = ?', 'Usability', 'Web Design'));
     $news->has('author', array('name = ?', 'Ridley Scott'));
     $result = $news->afind();
     $test->expect(count($result) == 1 && $result[0]['title'] == 'Responsive Images', $type . ': find with multiple has filters on different relations');
     // add another news to author 2
     $news->load(array($news_pk . ' = ?', $newsIDs[2]));
     $news->author = $authorIDs[1];
     $news->save();
     $news->reset();
     $news->has('author', array('name = ?', 'Ridley Scott'));
     $news->load();
     $res = array();
     while (!$news->dry()) {
         $res[] = $news->title;
         $news->next();
     }
     $test->expect(count($res) == 2 && $res[0] == 'Responsive Images' && $res[1] == 'Touchable Interfaces', $type . ': has filter in load context');
     $news->reset();
     $news->fields(array('title'));
     $news->load();
     $test->expect(!empty($news->title) && empty($news->author) && empty($news->text) && empty($news->tags) && empty($news->tags2), $type . ': use a whitelist to restrict fields');
     unset($news);
     $news = new \NewsModel();
     $news->fields(array('title', 'tags', 'tags2', 'author'), true);
     $news->load();
     $test->expect(empty($news->title) && empty($news->author) && !empty($news->text) && empty($news->tags) && empty($news->tags2), $type . ': use a blacklist to restrict fields');
     unset($news);
     $news = new \NewsModel();
     $news->fields(array('tags.title'));
     $news->load();
     $test->expect(!empty($news->tags[0]->title) && empty($news->tags[0]->news), $type . ': set restricted fields to related mappers');
     $news->filter('tags2', null, array('order' => 'title ASC'));
     $news->load(array('title = ?', 'Responsive Images'));
     $test->expect($news->tags2[0]->title == 'Responsive' && $news->tags2[1]->title == 'Web Design', $type . ': filter with sorting of related records');
     // get all tags sorted by their usage in news articles
     $tag->reset();
     $tag->countRel('news');
     $result = $tag->find(null, array('order' => 'count_news DESC, title'))->castAll(0);
     $test->expect($result[0]['title'] == 'Responsive' && $result[0]['count_news'] == 3 && $result[1]['title'] == 'Usability' && $result[1]['count_news'] == 1 && $result[2]['title'] == 'Web Design' && $result[2]['count_news'] == 1, $type . ': count and sort on many-to-many relation');
     // get all authors sorted by the amount of news they have written
     $author->reset();
     $author->countRel('news');
     $result = $author->find(null, array('order' => 'count_news DESC'))->castAll(0);
     $test->expect($result[0]['name'] == 'Ridley Scott' && $result[0]['count_news'] == 2 && $result[1]['name'] == 'Johnny English' && $result[1]['count_news'] == 1 && $result[2]['name'] == 'James T. Kirk' && $result[2]['count_news'] == null, $type . ': count and sort on one-to-many relation');
     $tag->reset();
     $tag->countRel('news');
     $result = $tag->find(null, array('order' => 'count_news DESC, title DESC', 'limit' => 1, 'offset' => 1))->castAll(0);
     $test->expect($result[0]['title'] == 'Web Design' && $result[0]['count_news'] == 1, $type . ': apply limit and offset on aggregated collection');
     $author->reset();
     $author->countRel('news');
     $author->has('news', array('text like ?', '%Lorem%'));
     $result = $author->find()->castAll(0);
     $test->expect(count($result) == 1 && $result[0]['name'] == 'Ridley Scott' && $result[0]['count_news'] == 2, $type . ': has-filter and 1:M relation counter');
     $author->reset();
     $id = $author->load()->next()->_id;
     $tag->reset();
     $tag->countRel('news');
     $tag->has('news', array('author = ?', $id));
     $result = $tag->find(null, array('order' => 'count_news desc'))->castAll(0);
     $test->expect(count($result) == 2 && $result[0]['title'] == 'Responsive' && $result[0]['count_news'] == 3 && $result[1]['title'] == 'Web Design' && $result[1]['count_news'] == 1, $type . ': has-filter and M:M relation counter');
     ///////////////////////////////////
     return $test->results();
 }
Exemple #14
0
/**
 * Upgrades a Version 23 version of the Yioop! database to a Version 24 version
 * @param object $db datasource to use to upgrade
 */
function upgradeDatabaseVersion24(&$db)
{
    /** Get base class for profile_model.php*/
    require_once BASE_DIR . "/models/model.php";
    /** For ProfileModel::createDatabaseTables method */
    require_once BASE_DIR . "/models/profile_model.php";
    $db->execute("DELETE FROM VERSION WHERE ID < 23");
    $db->execute("UPDATE VERSION SET ID=24 WHERE ID=23");
    $profile_model = new ProfileModel(DB_NAME, false);
    $profile_model->db = $db;
    $dbinfo = array("DBMS" => DBMS, "DB_HOST" => DB_HOST, "DB_USER" => DB_USER, "DB_PASSWORD" => DB_PASSWORD, "DB_NAME" => DB_NAME);
    $profile_model->initializeSql($db, $dbinfo);
    foreach ($profile_model->create_statements as $object_name => $statement) {
        if (stristr($object_name, "_INDEX")) {
            if (!$db->execute($statement)) {
                echo $statement . " ERROR!";
                exit;
            }
        } else {
            if (!$db->execute("ALTER TABLE {$object_name} RENAME TO " . $object_name . "_OLD")) {
                echo "RENAME {$object_name} ERROR!";
                exit;
            }
            if (!$db->execute($statement)) {
                echo $statement . " ERROR!";
                exit;
            }
            DatasourceManager::copyTable($object_name . "_OLD", $db, $object_name, $db);
            $db->execute("DROP TABLE " . $object_name . "_OLD");
        }
    }
}
Exemple #15
0
 public function load()
 {
     parent::load();
     $this->isAdmin = $this->data['player_type'] == PLAYERTYPE_ADMIN;
     $uid = isset($_GET['uid']) && 0 < intval($_GET['uid']) ? intval($_GET['uid']) : $this->player->playerId;
     if ($this->isAdmin && isset($_GET['spy']) && 0 < $uid && $uid != $this->player->playerId) {
         $gameStatus = $this->player->gameStatus;
         $previd = $this->player->playerId;
         $this->player = new Player();
         $this->player->playerId = $uid;
         $this->player->prevPlayerId = $previd;
         $this->player->isAgent = FALSE;
         $this->player->isSpy = TRUE;
         $this->player->gameStatus = $gameStatus;
         $this->player->save();
         $this->redirect("village1.php");
     } else {
         $this->selectedTabIndex = 0;
         $this->fullView = FALSE;
         $m = new ProfileModel();
         if ($uid != $this->player->playerId) {
             $this->profileData = $m->getPlayerDataById($uid);
             $this->villagesCount = sizeof(explode(",", $this->profileData['villages_id']));
             $this->villages = $m->getVillagesSummary($this->profileData['villages_id']);
             if ($this->profileData == NULL) {
                 $m->dispose();
                 $this->redirect("village1.php");
             }
         } else {
             $this->profileData = $this->data;
             $this->protectiontime = $m->getPlayerDataById($uid);
             $this->profileData['id'] = $uid;
             $this->fullView = !$this->player->isAgent;
             $this->selectedTabIndex = !$this->player->isAgent && isset($_GET['t']) && is_numeric($_GET['t']) && 0 <= intval($_GET['t']) && intval($_GET['t']) <= 4 ? intval($_GET['t']) : 0;
             if ($this->selectedTabIndex == 4 && $this->data['player_type'] == PLAYERTYPE_TATAR) {
                 $this->selectedTabIndex = 0;
             }
             $agentForPlayers = trim($this->profileData['agent_for_players']) == "" ? array() : explode(",", $this->profileData['agent_for_players']);
             foreach ($agentForPlayers as $agent) {
                 $agentName = explode(" ", $agent);
                 $agentId = explode(" ", $agent);
                 list($agentId, $agentName) = $agentId;
                 $this->agentForPlayers[$agentId] = $agentName;
             }
             $myAgentPlayers = trim($this->profileData['my_agent_players']) == "" ? array() : explode(",", $this->profileData['my_agent_players']);
             foreach ($myAgentPlayers as $agent) {
                 $agentName = explode(" ", $agent);
                 $agentId = explode(" ", $agent);
                 list($agentId, $agentName) = $agentId;
                 $this->myAgentPlayers[$agentId] = $agentName;
             }
             $this->profileData['rank'] = $m->getPlayerRank($uid, $this->profileData['total_people_count'] * 10 + $this->profileData['villages_count']);
             if ($this->isPost()) {
                 if ($this->fullView && isset($_POST['e'])) {
                     switch ($_POST['e']) {
                         case 1:
                             if (!empty($_FILES['avatar']['name'])) {
                                 $exe = explode(".", $_FILES['avatar']['name']);
                                 $EXT = end($exe);
                                 $array = array("GIF", "SWF", "BMP", "TIFF", "JPG", "PNG", "JEPG");
                                 if (in_array(strtoupper($EXT), $array)) {
                                     $i = time();
                                     $avatar = $i . "." . $EXT;
                                     $test = move_uploaded_file($_FILES['avatar']['tmp_name'], ROOT_PATH . "avatar/" . $avatar);
                                     if ($test) {
                                         if ($_POST['oldavatar'] != "http://www.dboor.com/tatar/assets/default/img/q/l6.jpg") {
                                             @unlink(@$_POST['oldavatar']);
                                         }
                                     } else {
                                         $avatar = $_POST['oldavatar'];
                                     }
                                 } else {
                                     $avatar = $_POST['oldavatar'];
                                 }
                             } else {
                                 $avatar = $_POST['oldavatar'];
                             }
                             $avatar = empty($avatar) ? "/assets/default/img/q/l6.jpg" : "/avatar/" . $avatar;
                             $_y_ = isset($_POST['jahr']) && 1930 <= intval($_POST['jahr']) && intval($_POST['jahr']) <= 2005 ? intval($_POST['jahr']) : "";
                             $_m_ = isset($_POST['monat']) && 1 <= intval($_POST['monat']) && intval($_POST['monat']) <= 12 ? intval($_POST['monat']) : "";
                             $_d_ = isset($_POST['tag']) && 1 <= intval($_POST['tag']) && intval($_POST['tag']) <= 31 ? intval($_POST['tag']) : "";
                             $newData = array("gender" => 0 <= intval($_POST['mw']) && intval($_POST['mw']) <= 2 ? intval($_POST['mw']) : 0, "house_name" => isset($_POST['ort']) ? $_POST['ort'] : "", "village_name" => isset($_POST['dname']) ? $_POST['dname'] : "", "avatar" => htmlspecialchars($avatar), "description1" => isset($_POST['be1']) ? htmlspecialchars($_POST['be1']) : "", "description2" => isset($_POST['be2']) ? htmlspecialchars($_POST['be2']) : "", "birthData" => $_y_ . "-" . $_m_ . "-" . $_d_, "villages" => $this->data['villages_data']);
                             $m->editPlayerProfile($this->player->playerId, $newData);
                             $m->dispose();
                             $this->redirect("profile.php");
                             return;
                         case 2:
                             if (isset($_POST['pw1'], $_POST['pw2']) && isset($_POST['pw3']) && $_POST['pw2'] == $_POST['pw3'] && 4 <= strlen($_POST['pw2']) && strtolower($this->profileData['pwd']) == strtolower(md5($_POST['pw1']))) {
                                 $m->changePlayerPassword($this->player->playerId, md5($_POST['pw2']));
                             }
                             if (isset($_POST['email_alt'], $_POST['email_neu']) && strtolower($this->profileData['email']) == strtolower($_POST['email_alt']) && preg_match("/^[^@]+@[a-zA-Z0-9._-]+\\.[a-zA-Z]+\$/", $_POST['email_neu'])) {
                                 $m->changePlayerEmail($this->player->playerId, $_POST['email_neu']);
                             }
                             break;
                         case 3:
                             if (isset($_POST['v1']) && trim($_POST['v1']) != "" && sizeof($this->myAgentPlayers) < 2) {
                                 $aid = $m->getPlayerIdByName($_POST['v1']);
                                 if (0 < intval($aid) && $aid != $this->player->playerId && !isset($this->myAgentPlayers[$aid])) {
                                     $_agentsFor = $m->getPlayerAgentForById(intval($aid));
                                     if (1 < sizeof(explode(",", $_agentsFor))) {
                                         $this->errorText = profile_setagent_err_msg;
                                     } else {
                                         $this->myAgentPlayers[$aid] = $_POST['v1'];
                                         $m->setMyAgents($this->player->playerId, $this->data['name'], $this->myAgentPlayers, $aid);
                                     }
                                 }
                             }
                             break;
                         case 4:
                             if (isset($_POST['del']) && $_POST['del'] == 1 && strtolower($this->profileData['pwd']) == strtolower(md5($_POST['del_pw'])) && !$this->isPlayerInDeletionProgress() && !$this->isGameTransientStopped() && !$this->isGameOver()) {
                                 $this->queueModel->addTask(new QueueTask(QS_ACCOUNT_DELETE, $this->player->playerId, 259200));
                             }
                     }
                 }
             } else {
                 if ($this->selectedTabIndex == 3) {
                     if (isset($_GET['aid']) && 0 < intval($_GET['aid'])) {
                         $aid = intval($_GET['aid']);
                         if (isset($this->myAgentPlayers[$aid])) {
                             unset($this->myAgentPlayers[$aid]);
                             $m->removeMyAgents($this->player->playerId, $this->myAgentPlayers, $aid);
                         }
                     } else {
                         if (isset($_GET['afid']) && 0 < intval($_GET['afid'])) {
                             $aid = intval($_GET['afid']);
                             if (isset($this->agentForPlayers[$aid])) {
                                 unset($this->agentForPlayers[$aid]);
                                 $m->removeAgentsFor($this->player->playerId, $this->agentForPlayers, $aid);
                             }
                         }
                     }
                 } else {
                     if ($this->selectedTabIndex == 4 && isset($_GET['qid']) && 0 < intval($_GET['qid'])) {
                         $this->queueModel->cancelTask($this->player->playerId, intval($_GET['qid']));
                     }
                 }
             }
             if ($this->selectedTabIndex == 0) {
                 $this->villagesCount = sizeof(explode(",", $this->profileData['villages_id']));
                 $this->villages = $m->getVillagesSummary($this->profileData['villages_id']);
             } else {
                 if ($this->selectedTabIndex == 1) {
                     $birth_date = $this->profileData['birth_date'];
                     if (!$birth_date) {
                         $birth_date = "0-0-0";
                     }
                     $day = explode("-", $birth_date);
                     $month = explode("-", $birth_date);
                     $year = explode("-", $birth_date);
                     list($year, $month, $day) = $year;
                     $this->birthDate = array("year" => $year, "month" => $month, "day" => $day);
                 }
             }
             $m->dispose();
         }
     }
 }
 public static function getAllDJProfiles()
 {
     $response = json_encode(ProfileModel::getAllDJProfiles());
     echo $response;
     die;
 }
 public static function start()
 {
     // Include model
     incFile('modules/profile/system/Model.php');
     incFile('../mail/class.phpmailer.php');
     // Connect to DB
     $model = new ProfileModel();
     if (getSession('user')) {
         $id = getSession('user');
     } else {
         $id = getCookie('user');
         setSession('user', $id, false);
     }
     //  $id = (getSession('user')) ? getSession('user') : getCookie('user') ;
     if ($id) {
         $uData = array();
         // Update user
         $uData['controller'] = CONTROLLER;
         $uData['action'] = ACTION;
         $uData['dateLast'] = time();
         $model->updateUserByID($uData, $id);
         // Get data user
         Request::setParam('user', $model->getUserByID($id));
         // Count new message
         Request::setParam('countMsg', $model->countMsg($id));
         // Count new message
         Request::setParam('countRequests', $model->countRequests($id));
         // Count challenges
         Request::setParam('countChallenges', $model->countChallengesList($id));
     } else {
         $gip = ip2long($_SERVER['REMOTE_ADDR']);
         // Null
         Request::setParam('user', null);
         // Guest
         Request::setParam('guest', $model->getGuestByIP($gip));
         // Role
         Request::setRole('guest');
         /*
         // Language
         if (CONTROLLER == 'page' && ACTION == 'lang') {
             if (Request::getUri(0) == 'ru' OR Request::getUri(0) == 'en')
                 setMyCookie('lang', Request::getUri(0), time() + 365 * 86400);
         }
         
         $lang = getCookie('lang');
         
         if ($lang == 'ru' OR $lang == 'en')
             Lang::setLanguage($lang);
         else
             Lang::setLanguage();
         */
         if (Request::getParam('guest')->id) {
             $gData['count'] = Request::getParam('guest')->count + 1;
             $gData['time'] = time();
             $model->update('guests', $gData, "`id` = '" . Request::getParam('guest')->id . "' LIMIT 1");
         } else {
             $gData['ip'] = $gip;
             $gData['browser'] = $_SERVER['HTTP_USER_AGENT'];
             $gData['referer'] = $_SERVER['HTTP_REFERER'];
             $gData['count'] = 1;
             $gData['time'] = time();
             $model->insert('guests', $gData);
         }
     }
     // Count users online
     Request::setParam('countUsersOnline', $model->countUsersOnline());
     // Count guests online
     Request::setParam('countGuestsOnline', $model->countGuestsOnline());
 }
Exemple #18
0
<?php

require_once "models/ProfileModel.php";
@session_start();
if (isset($_SESSION['email'])) {
    $pm = new ProfileModel();
    $picture = $pm->getPicture($_SESSION['email']);
    header("Cache-Control: no-cache, must-revalidate");
    header("Content-Type: image/jpeg");
    echo $picture;
}
 public function inviteall_follower()
 {
     $follower_ids = Input::get("follower_list");
     $contest_id = Input::get("contest_id");
     $follower_ids = explode(',', $follower_ids);
     $followercount = count($follower_ids);
     $curdate = date('Y-m-d H:i:s');
     $contest_det = contestModel::where("ID", $contest_id)->first();
     if (Auth::user()->firstname != '') {
         $inviter = Auth::user()->firstname . " " . Auth::user()->lastname;
     } else {
         $inviter = Auth::user()->username;
     }
     if ($contest_det['contesttype'] == "p") {
         $contesttype = "Photo";
     } else {
         if ($contest_det['contesttype'] == "v") {
             $contesttype = "Video";
         } else {
             if ($contest_det['contesttype'] == "t") {
                 $contesttype = "Topic";
             }
         }
     }
     $contestname = $contest_det['contest_name'];
     if ($followercount > 0) {
         for ($i = 0; $i < $followercount; $i++) {
             $invited = invitefollowerforcontestModel::where('follower_id', $follower_ids[$i])->where('contest_id', $contest_id)->count();
             if ($invited == 0) {
                 $input_details['follower_id'] = $follower_ids[$i];
                 $input_details['contest_id'] = $contest_id;
                 $input_details['invitedate'] = $curdate;
                 invitefollowerforcontestModel::create($input_details);
                 $invited_member = privateusercontestModel::where("contest_id", $contest_id)->where('user_id', $follower_ids[$i])->count();
                 if ($contest_det['visibility'] == "p" && $invited_member == 0) {
                     $privat_user['user_id'] = $follower_ids[$i];
                     $privat_user['contest_id'] = $contest_id;
                     $privat_user['requesteddate'] = date('Y-m-d H:i:s');
                     $privat_user['status'] = 1;
                     privateusercontestModel::create($privat_user);
                 }
                 if ($invited_member == 0) {
                     $user = ProfileModel::where('ID', $followerid)->first();
                     if ($user['firstname'] != '') {
                         $name = $user['firstname'] . ' ' . $user['lastname'];
                     } else {
                         $name = $user['username'];
                     }
                     $email = $user['email'];
                     $this->invitefollowerforcontestmail($name, $email, $inviter, $contesttype, $contestname, $contest_id);
                 }
             }
         }
         return 1;
     } else {
         return 0;
     }
 }
Exemple #20
0
}
?>

                                    </tbody>
                                    </table>   
                                    </div>
                                    <div id="tab-body-2" class="tab-body">


                                        <form id="editprofile" name="edit_profile_update" enctype="multipart/form-data"  action="{{ URL::to('/adduser') }}" method="post" class="form_mid">
                                            @if(isset($Message))
                                            <p class="alert" style="color:green;padding:5px;text-align:center;font-size:13px">{{ $Message }}</p>
                                            @endif
                                            <?php 
$user_id = Auth::user()->ID;
$profileData = ProfileModel::where('ID', $user_id)->first();
$interestList = InterestCategoryModel::lists('Interest_name', 'Interest_id');
$userInterest = InterestCategoryModel::lists('Interest_name', 'Interest_id');
//$userInterest=userinterestModel::where('user_id',$user_id)->lists('interest_id');
$timezoneList = timezoneDBModel::lists('timezonename', 'timezonevalue');
if (Session::has('er_data')) {
    $er_data = Session::get('er_data');
}
if (Session::has('old_data')) {
    $old_data = Session::get('old_data');
}
?>
                                            <div class="loginform loginbox mar1">

                                                <legend class="radius"><div class="leg_head"><span id="txt_logininfo">Login Info</span></div>
Exemple #21
0
 /**
  * getShowDJs
  *
  * @param \WP_Post $post
  * @static
  * @access private
  * @return void
  */
 private static function getShowDJs(\WP_Post $post)
 {
     $djs = array();
     $showDJs = unserialize(self::getMetaData($post->ID, '_wpspin_show_djs'));
     foreach ($showDJs as $dj) {
         $djs[] = ProfileModel::getDJInfo($dj['UserID']);
     }
     return $djs;
 }
Exemple #22
0
<?php

$pageLocalModel = new ProfileModel();
$stamina = 0;
$uid = Request::getParam('user')->id;
$pageLocalModel->checkStamina($uid);
$stamina = $pageLocalModel->getStamina($uid);
$staminaMax = $pageLocalModel->getStaminaMax($uid);
$staminaPercent = $stamina * 100 / $staminaMax;
$staminaPercent = $staminaPercent < 0 ? 0 : $staminaPercent;
?>
<a href="{URL:/main}"><div class="logo"></div></a>

<?php 
if (Request::getParam('user')->id) {
    echo '<div class="profile_bar">';
    echo '<div class="nav_profile">';
    echo '<img class="avatar" src="' . getAvatar(Request::getParam('user')->id) . '" alt="Avatar" />';
    echo '<div class="nav_profile_name"><a href="' . url(Request::getParam('user')->id) . '">' . Request::getParam('user')->nickname . '</a></div>';
    echo '<div class="stamina-bar"><div class="full" style="width:' . $staminaPercent . '%"></div></div>';
    echo '</div>';
    echo '<ul class="nav_personal">';
    echo '<li class="friends-icon"><a href="' . url('friends') . '" title="{L:FRIENDS}">' . (Request::getParam('countRequests') > 0 ? '(+' . Request::getParam('countRequests') . ')' : '') . '</a></li>';
    echo '<li class="mail-icon"><a href="' . url('mail') . '" title="{L:MAIL}">' . (Request::getParam('countMsg') > 0 ? '(+' . Request::getParam('countMsg') . ')' : '') . '</a></li>';
    echo '<li class="settings-icon"><a href="' . url('settings') . '" title="{L:SETTINGS}"></a></li>';
    echo '<li class="exit-icon"><a href="' . url('profile', 'exit') . '" title="{L:EXIT}"></a></li>';
    echo '</ul>';
    echo '</div>';
    echo '<div class="nav_menu">';
    if (Request::getRole() == 'moder' or Request::getRole() == 'admin') {
        echo '<a class="admin-panel" href="{URL:admin}">{L:ADMIN_PANEL}</a>';
Exemple #23
0
 function run($db, $type)
 {
     $test = new \Test();
     // clear existing data
     \AuthorModel::setdown();
     \TagModel::setdown();
     \NewsModel::setdown();
     \ProfileModel::setdown();
     // setup models
     \AuthorModel::setup();
     \TagModel::setup();
     \NewsModel::setup();
     \ProfileModel::setup();
     // setup Author
     ///////////////////////////////////
     $author_id = array();
     $author = new \AuthorModel();
     $ac = $author::resolveConfiguration();
     $author_pk = is_int(strpos($type, 'sql')) ? $ac['primary'] : '_id';
     $author->name = 'Johnny English';
     $author->save();
     $author_id[] = $author->_id;
     $author->reset();
     $author->name = 'Ridley Scott';
     $author->save();
     $author_id[] = $author->_id;
     $author->reset();
     $author->name = 'James T. Kirk';
     $author->save();
     $author_id[] = $author->_id;
     $author->reset();
     $allauthors = $author->find()->castAll();
     $allauthors = $this->getResult($allauthors);
     $test->expect(json_encode($allauthors) == '[{"name":"Johnny English"},{"name":"Ridley Scott"},{"name":"James T. Kirk"}]', $type . ': all AuthorModel items created');
     // setup Tags
     ///////////////////////////////////
     $tag_id = array();
     $tag = new \TagModel();
     $tc = $tag::resolveConfiguration();
     $tag_pk = is_int(strpos($type, 'sql')) ? $tc['primary'] : '_id';
     $tag->title = 'Web Design';
     $tag->save();
     $tag_id[] = $tag->_id;
     $tag->reset();
     $tag->title = 'Responsive';
     $tag->save();
     $tag_id[] = $tag->_id;
     $tag->reset();
     $tag->title = 'Usability';
     $tag->save();
     $tag_id[] = $tag->_id;
     $tag->reset();
     $allTags = $this->getResult($tag->find());
     $test->expect(json_encode($allTags) == '[{"title":"Web Design"},{"title":"Responsive"},{"title":"Usability"}]', $type . ': all TagModel items created');
     // setup News
     ///////////////////////////////////
     $news_id = array();
     $news = new \NewsModel();
     $nc = $news::resolveConfiguration();
     $news_pk = is_int(strpos($type, 'sql')) ? $nc['primary'] : '_id';
     $news->title = 'Responsive Images';
     $news->text = 'Lorem Ipsun';
     $news->save();
     $news_id[] = $news->_id;
     $news->reset();
     $news->title = 'CSS3 Showcase';
     $news->text = 'News Text 2';
     $news->save();
     $news_id[] = $news->_id;
     $news->reset();
     $news->title = 'Touchable Interfaces';
     $news->text = 'Lorem Foo';
     $news->save();
     $news_id[] = $news->_id;
     $news->reset();
     $allnews = $this->getResult($news->find(null, array('order' => 'title')));
     $test->expect(count($allnews) == 3 && $allnews[0]['title'] == 'CSS3 Showcase' && $allnews[1]['title'] == 'Responsive Images' && $allnews[2]['title'] == 'Touchable Interfaces', $type . ': all NewsModel items created');
     // belongs-to author relation
     ///////////////////////////////////
     $author->load();
     $news->load(array($news_pk . ' = ?', $news_id[0]));
     $news->author = $author;
     $news->save();
     $news->reset();
     $news->load(array($news_pk . ' = ?', $news_id[0]));
     $test->expect($news->author->name == 'Johnny English', $type . ': belongs-to-one: author relation created');
     $news->author = NULL;
     $news->save();
     $news->reset();
     $news->load(array($news_pk . ' = ?', $news_id[0]));
     $test->expect(empty($news->author), $type . ': belongs-to-one: author relation released');
     $news->author = $author->_id;
     $news->save();
     $news->reset();
     $news->load(array($news_pk . ' = ?', $news_id[0]));
     $test->expect($news->author->name == 'Johnny English', $type . ': belongs-to-one: relation created by raw id');
     // belongs-to-many tag relation
     ///////////////////////////////////
     $tag1 = new \TagModel();
     $tag1->load(array($tag_pk . ' = ?', $tag_id[0]));
     $tag2 = new \TagModel();
     $tag2->load(array($tag_pk . ' = ?', $tag_id[1]));
     $news->tags = array($tag1, $tag2);
     $news->save();
     $news->reset();
     $news->load(array($news_pk . ' = ?', $news_id[0]));
     $test->expect($news->tags[0]->title == 'Web Design' && $news->tags[1]->title == 'Responsive', $type . ': belongs-to-many: relations created with array of mapper objects');
     $news->reset();
     $news->load(array($news_pk . ' = ?', $news_id[1]));
     $news->tags = array($tag_id[1], $tag_id[2]);
     $news->save();
     $news->reset();
     $news->load(array($news_pk . ' = ?', $news_id[1]));
     $test->expect(count($news->tags) == 2 && $news->tags[0]->title == 'Responsive' && $news->tags[1]->title == 'Usability', $type . ': belongs-to-many: relations created with array of IDs');
     $news->tags = null;
     $news->save();
     $news->reset();
     $news->load(array($news_pk . ' = ?', $news_id[1]));
     $test->expect(empty($news->tags), $type . ': belongs-to-many: relations released');
     $tag->reset();
     $news->load(array($news_pk . ' = ?', $news_id[1]));
     $news->tags = $tag->load(array($tag_pk . ' != ?', $tag_id[0]));
     $news->save();
     $news->reset();
     $news->load(array($news_pk . ' = ?', $news_id[1]));
     $test->expect($news->tags[0]->title == 'Responsive' && $news->tags[1]->title == 'Usability', $type . ': belongs-to-many: relations created with hydrated mapper');
     $news->reset();
     $tag->reset();
     $news->load(array($news_pk . ' = ?', $news_id[2]));
     $news->tags = $tag_id[0] . ';' . $tag_id[2];
     $news->save();
     $news->reset();
     $news->load(array($news_pk . ' = ?', $news_id[2]));
     $test->expect($news->tags[0]->title == 'Web Design' && $news->tags[1]->title == 'Usability', $type . ': belongs-to-many: relations created with split-able string');
     $test->expect(is_object($news->tags) && $news->tags instanceof \DB\CortexCollection, $type . ': belongs-to-many: result is collection');
     // has-one relation
     ///////////////////////////////////
     $profile = new ProfileModel();
     $pc = $profile::resolveConfiguration();
     $profile_pk = is_int(strpos($type, 'sql')) ? $pc['primary'] : '_id';
     $profile->message = 'Hello World';
     $profile->author = $author->load(array($author_pk . ' = ?', $author_id[0]));
     $profile->save();
     $profile_id = $profile->_id;
     $profile->reset();
     $author->reset();
     $author->load(array($author_pk . ' = ?', $author_id[0]));
     $profile->load(array($profile_pk . ' = ?', $profile_id));
     $test->expect($author->profile->message == 'Hello World' && $profile->author->name == "Johnny English", $type . ': has-one: relation assigned');
     $profile->reset();
     $profile->message = 'I\'m feeling lucky';
     $profile->image = 'lolcat.jpg';
     $author->reset();
     $author->load(array($author_pk . ' = ?', $author_id[1]));
     $author->profile = $profile;
     $author->save();
     $profile->reset();
     $author->reset();
     $author->load(array($author_pk . ' = ?', $author_id[1]));
     $test->expect($author->profile->message == 'I\'m feeling lucky', $type . ': has-one: inverse relation');
     // has-many relation
     ///////////////////////////////////
     $author->load(array($author_pk . ' = ?', $author_id[0]));
     $result = $this->getResult($author->news);
     $test->expect($result[0]['title'] == "Responsive Images" && $result[0]['tags'][0]['title'] == 'Web Design' && $result[0]['tags'][1]['title'] == 'Responsive', $type . ': has-many inverse relation');
     // many to many relation
     ///////////////////////////////////
     $news->load(array($news_pk . ' = ?', $news_id[0]));
     $news->tags2 = array($tag_id[0], $tag_id[1]);
     $news->save();
     $news->reset();
     $news->load(array($news_pk . ' = ?', $news_id[0]));
     $test->expect($news->tags2[0]['title'] == 'Web Design' && $news->tags2[1]['title'] == 'Responsive', $type . ': many-to-many relation created');
     $test->expect(is_object($news->tags2) && $news->tags2 instanceof \DB\CortexCollection, $type . ': many-to-many: result is collection');
     $tag3 = $tag->load(array($tag_pk . ' = ?', $tag_id[2]));
     $news->tags2[] = $tag3;
     $news->save();
     $a = count($news->tags2);
     $news->reset();
     $news->load(array($news_pk . ' = ?', $news_id[0]));
     $test->expect(count($news->tags2) == 3 && $a == 3, $type . ': many-to-many relation added implicitly');
     $news->load(array($news_pk . ' = ?', $news_id[0]));
     $news->tags2 = NULL;
     $news->save();
     $news->reset();
     $news->load(array($news_pk . ' = ?', $news_id[0]));
     $test->expect(is_null($news->tags2), $type . ': many-to-many relation released');
     $news->reset();
     $news->title = 'Can it run Crysis?';
     $news->text = 'XOXO';
     $news->tags2 = array($tag_id[0]);
     $news->save();
     $news_id[] = $news->_id;
     $news->reset();
     $news->load(array($news_pk . ' = ?', $news_id[3]));
     $a = count($news->tags2);
     $tag1 = $tag->find(array($tag_pk . ' = ?', $tag_id[0]));
     $b = count($tag1[0]->news);
     $c = $tag1[0]->news[0]->title == 'Can it run Crysis?';
     $news->erase();
     $tag1 = $tag->find(array($tag_pk . ' = ?', $tag_id[0]));
     $d = count($tag1[0]->news);
     $test->expect($a == 1 && $b == 1 && $c && $d == 0, $type . ': many-to-many relation cleaned by erase cascade');
     $news->load(array($news_pk . ' = ?', $news_id[0]));
     $all = $news->find();
     $test->expect($all[1]->tags2 === NULL && $all[2]->author === NULL, $type . ': empty relations are NULL');
     $arr = $news->cast();
     $test->expect(is_array($arr['tags']), $type . ': collection becomes array in casted model');
     if ($type == 'mongo') {
         $test->expect(is_string($arr['_id']), $type . ': id becomes string in casted model');
     }
     ///////////////////////////////////
     return $test->results();
 }
Exemple #24
0
function loadInitialData()
{
    $res = new xajaxResponse();
    $regionSelect = "<select disabled=\"disabled\"><option>Select Value ...</option></select>\n";
    $apcodeSelect = "<select disabled=\"disabled\"><option>Select Value ...</option></select>\n";
    //if no default Profile is set in the SESSION we only need to load the Countrys
    if (!isset($_SESSION['defaultProfile'])) {
        $depSelect = getCountrySelect("dep_country", "Select Value ...");
        $res->addAssign("dep_country", "innerHTML", $depSelect);
        $res->addAssign("dep_region", "innerHTML", $regionSelect);
        $res->addAssign("dep_apcode", "innerHTML", $apcodeSelect);
    } else {
        // Load the airport information from the profile and set all
        // relevant selects of the departure airport to that values
        $pm = new ProfileModel();
        try {
            $airportInfos = $pm->getAirportInfoByEmail($_SESSION['defaultProfile']);
        } catch (Exception $e) {
            if ($e->getCode() == 6) {
                $res2 = new xajaxResponse();
                $res2->addAssign("contentView", "innerHTML", $e->getMessage());
                return $res2;
            }
        }
        unset($pm);
        $depCountrySelect = getCountrySelect("dep_country", $airportInfos[0]['country']);
        $depRegionSelect = getRegionSelect("dep_region", $airportInfos[0]['ccode'], $airportInfos[0]['region']);
        $depApCodeSelect = getApCodeSelect("dep_apcode", $airportInfos[0]['ccode'], $airportInfos[0]['region'], $airportInfos[0]['iatacode']);
        $res->addAssign("dep_country", "innerHTML", $depCountrySelect);
        $res->addAssign("dep_region", "innerHTML", $depRegionSelect);
        $res->addAssign("dep_apcode", "innerHTML", $depApCodeSelect);
    }
    $arvSelect = getCountrySelect("arv_country");
    $res->addAssign("arv_country", "innerHTML", $arvSelect);
    $res->addAssign("arv_region", "innerHTML", $regionSelect);
    $res->addAssign("arv_apcode", "innerHTML", $apcodeSelect);
    //$res->addAssign("contentView","innerHTML","");
    return $res;
}
Exemple #25
0
 private function listRecentStatuses($user)
 {
     $profile = new ProfileModel($this->registry, $user);
     $profile->toTags('p_');
     $this->registry->getObject('template')->getPage()->addTag('referer', isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '');
     // post status / public message box
     if ($this->registry->getObject('authenticate')->isLoggedIn() == true) {
         if (isset($_POST) && count($_POST) > 0) {
             $this->addStatus($user);
         }
         $loggedInUser = $this->registry->getObject('authenticate')->getUser()->getUserID();
         if ($loggedInUser == $user) {
             $this->registry->getObject('template')->addTemplateBit('status_update', 'profile_status_update.php');
         } else {
             require_once 'relation.php';
             $relationships = new RelationsGet($this->registry);
             $connections = $relationships->getNetwork($user, false);
             if (in_array($loggedInUser, $connections)) {
                 $this->registry->getObject('template')->addTemplateBit('status_update', 'profile_status_post.php');
             } else {
                 $this->registry->getObject('template')->getPage()->addTag('status_update', '');
             }
         }
     } else {
         $this->registry->getObject('template')->getPage()->addTag('status_update', '');
     }
     $this->registry->getObject('template')->buildFromTemplate('header.php', 'profile_status_list.php', 'footer.php');
     $updates = array();
     $ids = array();
     $status_ids = array();
     $sql = "SELECT t.type_reference, t.type_name, s.*,pa.username as poster_user, pa.name as poster_name, i.image, v.video_id, l.URL, l.description FROM status_types t, profile p, profile pa, statuses s LEFT JOIN statuses_images i ON s.ID=i.id LEFT JOIN statuses_videos v ON s.ID=v.id LEFT JOIN statuses_links l ON s.ID=l.id WHERE t.ID=s.type AND p.user_id=s.profile AND pa.user_id=s.poster AND p.user_id=" . $user . " ORDER BY s.ID DESC LIMIT 20";
     $this->registry->getObject('db')->executeQuery($sql);
     if ($this->registry->getObject('db')->numRows() > 0) {
         while ($row = $this->registry->getObject('db')->getRows()) {
             $updates[] = $row;
             $ids[$row['ID']] = $row;
             $status_ids[] = $row['ID'];
         }
     }
     require_once 'streamController.php';
     $stream = new StreamController($this->registry, false);
     $stream->commentary($status_ids);
     $cache = $this->registry->getObject('db')->cacheData($updates);
     $this->registry->getObject('template')->getPage()->addTag('updates', array('DATA', $cache));
     foreach ($ids as $id => $data) {
         $this->registry->getObject('template')->addTemplateBit('update-' . $id, 'profile_update_' . $data['type_reference'] . '.php', $data);
     }
     //var_dump($this->registry->getObject('template')->getPage()->getTags());
     //var_dump($cache);
 }
 /**
  * Vendor login
  *
  *@return redirect
  */
 function postLogin()
 {
     $rules = array('email' => 'required|email', 'password' => 'required|min:2');
     $email = Input::get('email');
     $password = Input::get('password');
     $validator = Validator::make(['email' => $email, 'password' => $password], $rules);
     if ($validator->passes()) {
         $vendorExists = ProfileModel::vendorExists($email, $password);
         if ($vendorExists) {
             Session::put('vendor_id', $vendorExists);
             return Redirect::to('/profile');
         } else {
             return Redirect::to('/')->with('e_msg', 'Login credentials are incorrect.');
         }
     }
     return Redirect::to('/')->with('e_msg', 'Something went wrong with the login!')->withErrors($validator)->withInput();
 }
 public function userdelete()
 {
     $userid = $_GET['userid'];
     /// Comment delete //////////
     $cmtcnt = commentModel::select('id')->where('userid', $userid)->get();
     for ($i = 0; $i < count($cmtcnt); $i++) {
         $replycnt = replycommentModel::where('comment_id', $cmtcnt[$i]['id'])->get()->count();
         if ($replycnt) {
             replycommentModel::where('comment_id', $cmtcnt[$i]['id'])->delete();
         }
     }
     /// REply comt delete /////
     $replycmtcnt = replycommentModel::where('user_id', $userid)->get()->count();
     if ($replycmtcnt) {
         replycommentModel::where('user_id', $userid)->delete();
     }
     /// Contest delete/////
     $contestcnt = contestModel::select('ID')->where('createdby', $userid)->get();
     for ($k = 0; $k < count($contestcnt); $k++) {
         $conpartdet = contestparticipantModel::select('ID')->where('contest_id', $contestcnt[$k]['ID'])->get();
         for ($p = 0; $p < count($conpartdet); $p++) {
             $cmtcnt = commentModel::where('contest_participant_id', $conpartdet[$p]['ID'])->delete();
             votingModel::where('contest_participant_id', $conpartdet[$p]['ID'])->delete();
         }
         $contestintrdlet = contestinterestModel::where('contest_id', $contestcnt[$k]['ID'])->delete();
         invitefollowerforcontestModel::where('contest_id', $contestcnt[$k]['ID'])->delete();
         invitegroupforcontestModel::where('contest_id', $contestcnt[$k]['ID'])->delete();
         leaderboardModel::where('contest_id', $contestcnt[$k]['ID'])->delete();
         privateusercontestModel::where('contest_id', $contestcnt[$k]['ID'])->delete();
         contestModel::where('createdby', $userid)->delete();
         contestparticipantModel::where('contest_id', $contestcnt[$k]['ID'])->delete();
     }
     ///Contestparticipant delete ///////////
     $contestparticipant = contestparticipantModel::where('user_id', $userid)->get();
     for ($p = 0; $p < count($contestparticipant); $p++) {
         $cmtcnt = commentModel::where('contest_participant_id', $contestparticipant[$p]['ID'])->delete();
         votingModel::where('contest_participant_id', $contestparticipant[$p]['ID'])->delete();
     }
     ///////////////Group //////////////////
     $group = groupModel::select('ID')->where('createdby', $userid)->get();
     if (count($group) > 0) {
         groupmemberModel::where('group_id', $group[0]['ID'])->delete();
         invitegroupforcontestModel::where('group_id', $group[0]['ID'])->delete();
         invitememberforgroupModel::where('group_id', $group[0]['ID'])->delete();
     }
     contestparticipantModel::where('user_id', $userid)->delete();
     followModel::where('userid', $userid)->delete();
     followModel::where('followerid', $userid)->delete();
     userinterestModel::where('user_id', $userid)->delete();
     votingModel::where('user_id', $userid)->delete();
     invitememberforgroupModel::where('user_id', $userid)->delete();
     groupmemberModel::where('user_id', $userid)->delete();
     ProfileModel::where('ID', $userid)->delete();
     $er_data['message'] = 'User details deleted successfully';
     return Redirect::to('user')->with('er_data', $er_data);
 }
Exemple #28
0
<?php

$model = new ProfileModel();
?>
<style scoped>
    .start-battle-button button{
        display: inline-block;
        border: none;
        background: #a1192a;
        color: #cecaca;
        padding: 15px 30px;
        -webkit-border-radius:5px;
        -moz-border-radius:5px;
        border-radius:5px;
        font-size: 16px;
        font-family: Novecentosanswide-Bold, sans-serif;
        margin: 10px 0 0 0;
    }
    .neve{
        font-family: Novecentosanswide-Bold, sans-serif;
    }
    .start-battle-button button:hover{
        background: #e63a19;
    }
    .start-battle-button{
        text-align: center;
    }
    .ladder-top{
        margin:0 0 25px 0;
    }
</style>
 public function profileupdate($data = Null)
 {
     //$data = Auth::user()->ID;
     $editid = $data;
     $GeneralData = Input::except(array('_token', 'status', 'pagename', 'profilepicture', 'profileimgedithidden', 'interest', 'update_profile'));
     $newimg = Input::file('profilepicture');
     if ($newimg != '') {
         $destinationPath = 'public/assets/upload/profile';
         $filename = Input::file('profilepicture')->getClientOriginalName();
         $Image = str_random(8) . '_' . $filename;
         $GeneralData['profilepicture'] = $Image;
         $uploadSuccess = Input::file('profilepicture')->move($destinationPath, $Image);
     }
     $interest = Input::get('interest');
     $interest_length = sizeof(Input::get('interest'));
     if ($interest_length > 0) {
         userinterestModel::whereNotIn('interest_id', $interest)->where('user_id', '=', $data)->delete();
         for ($i = 0; $i < $interest_length; $i++) {
             $interes['user_id'] = $data;
             $interes['interest_id'] = $interest[$i];
             $userInterest = userinterestModel::where('user_id', $data)->where('interest_id', $interest[$i])->lists('interest_id');
             if (count($userInterest) < 1) {
                 userinterestModel::create($interes);
             }
             unset($interes);
         }
     } else {
         userinterestModel::where('user_id', '=', $data)->delete();
     }
     $cur_date = date('Y-m-d');
     $updaterules = array('username' => 'required|unique:user,username,' . $data, 'password' => 'confirmed|min:5', 'email' => 'required|email|unique:user,email,' . $data, 'dateofbirth' => 'required', 'timezone' => 'required|min:2');
     $validation = Validator::make($GeneralData, $updaterules);
     $newpassword = Input::get('password');
     if ($newpassword != "") {
         $GeneralData['password'] = Hash::make(Input::get('password'));
     } else {
         unset($GeneralData["password"]);
     }
     unset($GeneralData["password_confirmation"]);
     $updatedata = $GeneralData;
     $lantyp = Session::get('language');
     if ($lantyp == "") {
         $lantyp = "value_en";
     }
     if (!isset($updatedata['maritalstatus'])) {
         $updatedata['maritalstatus'] = 0;
     }
     if ($validation->passes()) {
         $affectedRows = ProfileModel::where('ID', $data)->update($updatedata);
         $lantyp = Session::get('language');
         $labelname = ['txt_user_update_msg'];
         $languageDetails = languageModel::select($lantyp)->whereIn('ctrlCaptionId', $labelname)->get()->toArray();
         $user_id = $data;
         $profileData = ProfileModel::where('ID', $user_id)->first();
         $interestList = InterestCategoryModel::lists('Interest_name', 'Interest_id');
         $userInterest = userinterestModel::where('user_id', $user_id)->lists('interest_id');
         $er_data['Message'] = "<span id='txt_user_update_msg'>" . $languageDetails[0][$lantyp] . "</span>";
         return Redirect::to('/edit_profile/' . $data)->with('er_data', $er_data)->with('user_id', $user_id);
     } else {
         $languageDetails = languageModel::select($lantyp, 'ctrlCaptionId')->whereIn('value_en', [$validation->messages()->first('username'), $validation->messages()->first('password'), $validation->messages()->first('email'), $validation->messages()->first('dateofbirth'), $validation->messages()->first('timezone')])->get()->toArray();
         foreach ($languageDetails as $key => $val) {
             if (in_array($val['ctrlCaptionId'], ['alert_enterusername', 'alert_alreadyuser'])) {
                 $er_data['username'] = "******" . $val['ctrlCaptionId'] . "'>" . $val[$lantyp] . "</span>";
             } elseif (in_array($val['ctrlCaptionId'], ['alert_enterpassword', 'alert_minpass5', 'alert_passconfnotmatch'])) {
                 $er_data['password'] = "******" . $val['ctrlCaptionId'] . "'>" . $val[$lantyp] . "</span>";
             } elseif (in_array($val['ctrlCaptionId'], ['alert_enteremail', 'alert_validemail', 'alertr_emailalready'])) {
                 $er_data['email'] = "<span id='" . $val['ctrlCaptionId'] . "'>" . $val[$lantyp] . "</span>";
             } elseif (in_array($val['ctrlCaptionId'], ['alert_enterdob'])) {
                 $er_data['dateofbirth'] = "<span id='" . $val['ctrlCaptionId'] . "'>" . $val[$lantyp] . "</span>";
             } elseif (in_array($val['ctrlCaptionId'], ['txt_timezone_required'])) {
                 $er_data['timezone'] = "<span id='" . $val['ctrlCaptionId'] . "'>Timezone is required</span>";
             }
         }
         return Redirect::to('/edit_profile/' . $data)->with('er_data', $er_data)->with('old_data', $updatedata);
     }
 }
</style>
<div class="discover-page-wrapper">
<h1>{L:DISCOVER_WELCOME}</h1>
<h2>{L:DISCOVER_ABOUT}</h2>
<div class="user-list">

        <?php 
$userID = Request::getParam('user')->id;
while ($list = mysqli_fetch_assoc($this->list)) {
    $lastLooking = ceil((time() - $list["last_looking"]) / 60);
    $lastAvailable = ceil((time() - $list["dateLast"]) / 60);
    if ($lastLooking > 60 && $list["looking"] == 1) {
        $model = new ProfileModel();
        $model->updateDiscoverRecord($list["id"], "`looking`=0");
    } else {
        $model = new ProfileModel();
        $matchCount = $model->checkMatchExist($userID, $list["uid"]);
        $text = $list["looking"] == 1 ? Lang::translate('DISCOVER_LOOKING_TEXT') . " {$list['amount']}\$ " . $lastLooking . Lang::translate('DISCOVER_MINUTES_AGO') : Lang::translate('DISCOVER_LAST_ONLINE') . $lastAvailable . Lang::translate('DISCOVER_MINUTES_AGO');
        ?>

                            <div class="player-info">
                                <div class="profile-img">
                                    <a href="/<?php 
        echo $list["uid"];
        ?>
">
                                     <img src="/app/public/images/img/avatar.jpg" alt="Player photo">
                                    </a>
                                </div>
                                <p class="margin-bottom-zero">
                                    <a href="/<?php