public function playerVisibilityAction() { if (isPost()) { $post = allPost(); $model = new ProfileModel(); $response['error'] = 0; $text = "Error caused.."; if (isset($post['mid'])) { $recId = $model->checkDiscoverRecord($post['mid']); // TODO він страшнючий, але поки не вирішив куди його діти, і як без нього обійтись $column = "available"; $show = 0; switch ($post["task"]) { case "show": $show = 1; $column = "available"; $text = "INDEX_HIDE"; $post["task"] = "hide"; break; case "hide": $show = 0; $column = "available"; $text = "INDEX_SHOW"; $post["task"] = "show"; break; case "sttop": $show = 0; $column = "looking"; $post["task"] = "look"; $text = "INDEX_LOOKING_CHALLENGE"; break; case "look": $show = 1; $column = "looking"; $text = "INDEX_STOP_LOOKING"; $post["task"] = "sttop"; break; } $class = $show == 0 ? $column . "-h" : $column; $columns = "`uid`, `{$column}`, `last_{$column}`"; $value = $post['mid'] . ", {$show}, " . time(); $updateString = "`{$column}` = {$show}, `last_{$column}` = " . time(); if (isset($post['amount'])) { $updateString .= ", `amount` = '{$post['amount']}'"; } if (!empty($recId->id)) { $model->updateDiscoverRecord($recId->id, $updateString); } else { $model->insertDiscoverRecord($columns, $value); } if ($column == "looking" and $show == 0) { $response['target_h']["#" . $column] = '<input id="challenge-amount" class="challenge-amount" list="amount" value="5" name="amount"> <datalist id="amount"> <option value="5">5$</option> <option value="10">10$</option> <option value="20">20$</option> <option value="50">50$</option> <option value="100">100$</option> </datalist>'; } $response['target_h']["#" . $column] .= '<a class="' . $class . '" onclick="' . ajaxLoad(url('profile', 'playerVisibility'), 'reqest', 'task:' . $post['task'] . '|mid:' . $post['mid']) . '">' . Lang::translate($text) . '</a>'; } else { $response['error'] = "No id"; } } else { $response['error'] = "No POST"; } echo json_encode($response); exit; }
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')); } } }
} </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>