public function editAction()
 {
     $pageId = Request::getParam('pageId');
     if ($pageId === false) {
         $this->doesNotExist();
         return;
     }
     $properties = $this->pages->getProperties($pageId);
     if ($properties === false) {
         $this->doesNotExist();
         return;
     }
     if (!$this->helpers->canAccessPage($pageId, Acl::ACTION_EDIT)) {
         $this->accessDenied();
         return;
     }
     $this->view->assign('pageId', $pageId);
     $pages = DataStructure::pagesArray();
     if (isset($pages[$properties['template-id']])) {
         $this->view->assign('pageDataStructure', $pages[$properties['template-id']]['structure']);
         /*Helpers::dump($pages[$properties['template-id']]['structure']);
           die();*/
     }
     $isGlobalElementsPage = false;
     if ($properties['template-id'] == Pages::GLOBAL_ELEMENTS) {
         $isGlobalElementsPage = true;
     }
     $this->view->assign('isGlobalElementsPage', $isGlobalElementsPage);
 }
Example #2
0
 public function deleteAction()
 {
     $request = new Request();
     $id = $request->getParam('id');
     $Category = new Category();
     $Category->deleteCategory($id);
     header('location: ' . Url::getUrl('category', 'list', array('status' => 10)));
 }
Example #3
0
 /**
  * Returns the requested action name (default to "index")
  * 
  * @return string
  */
 protected function getActionName()
 {
     $action = $this->request->getParam('action');
     if (empty($action)) {
         $action = 'index';
     }
     return $action;
 }
Example #4
0
 /**
  * validate
  *
  * Run validation process
  *
  * @return null
  */
 public function validate()
 {
     // each fields
     foreach ($this->_rules as $fieldName => &$rules) {
         $isValid = true;
         $value = $this->_type == 'POST' ? \Request::getPostParam($fieldName) : \Request::getParam($fieldName);
         // each field rules
         foreach ($rules as &$rule) {
             $ruleSize = sizeof($rule);
             if ($ruleSize < 2) {
                 continue;
             }
             // filtering/casting
             if ($rule[0] == 'filter') {
                 $filterNS = '\\common\\filters\\' . $rule[1];
                 $filter = \App::getInstance($filterNS);
                 if ($ruleSize > 2) {
                     $args = array_slice($rule, 2);
                     array_unshift($args, $value);
                     $ref = new \ReflectionMethod($filterNS, 'run');
                     $value = $ref->invokeArgs($filter, $args);
                 } else {
                     $value = $filter->run($value);
                 }
                 // validation
             } else {
                 if ($rule[0] == 'negation' || $rule[0] == 'assertion') {
                     $validatorNS = '\\common\\validators\\' . $rule[1];
                     $validator = \App::getInstance($validatorNS);
                     if ($ruleSize > 3) {
                         $args = array_slice($rule, 2, -1);
                         array_unshift($args, $value);
                         $ref = new \ReflectionMethod($validatorNS, 'isValid');
                         $isValid = $ref->invokeArgs($validator, $args);
                     } else {
                         $isValid = $validator->isValid($value);
                     }
                     // invert to assertion
                     if ($rule[0] == 'assertion') {
                         $isValid = !$isValid;
                     }
                     // update status, append message and out of chain
                     if (!$isValid) {
                         $this->addMessage($fieldName, array_pop($rule));
                         break;
                     }
                     // unknown item type of chain
                 } else {
                     continue;
                 }
             }
         }
         // store sanitized value
         if ($isValid) {
             $this->_data->{$fieldName} = $value;
         }
     }
 }
Example #5
0
 public static function response()
 {
     // get the path from url
     $request_uri = Request::getParam('uri');
     $function = null;
     // iterate route list
     foreach (static::$list as $uri_pattern_regex => $options) {
         // replace the required route format to regex
         $uri_pattern_regex = preg_replace('/<<(?P<args>.*?)>>/', '(?P<$1>[^/]+)', $uri_pattern_regex);
         // replace the not required route format to regex
         $uri_pattern_regex = preg_replace('/(?P<part>[\\/]<\\?(.*?)\\?>+)/', '/?(?P<$2>[.\\w\\d\\X\\-%/]*)', $uri_pattern_regex);
         // replace '/' character to escaped '\/' for regex
         $uri_pattern_regex = preg_replace('/\\//', '\\/', $uri_pattern_regex);
         // extend it with regex anchors
         $uri_pattern_regex = '/^' . $uri_pattern_regex . '$/';
         $match = preg_match($uri_pattern_regex, $request_uri);
         // IF match the uri_pattern and correct request method from route pattern list
         // THEN store the action and break the loop
         if ($match && ($options['request_method'] == Request::getParam('method') || $options['request_method'] == 'any')) {
             $function = $options['action'];
             break;
         }
     }
     if ($function) {
         // get the action of route parameters
         $function_parameters = static::getArgs($function);
         // search the args of request uri
         preg_match_all($uri_pattern_regex, $request_uri, $request_uri_args_match);
         $args = [];
         foreach ($function_parameters as $function_arg) {
             // class type parameters because dependency injection
             if ($function_arg->getClass()) {
                 $class_name = $function_arg->getClass()->name;
                 $args[] = new $class_name();
                 continue;
             }
             // normal parameters from request uri
             foreach ($request_uri_args_match as $arg_name => $request_arg_value) {
                 if ($arg_name === $function_arg->name) {
                     $args[] = urldecode($request_arg_value[0]);
                 }
             }
         }
         // call the actions with args of request uri
         if (get_class($function) == 'ReflectionMethod') {
             $declaring_class = $function->getDeclaringClass()->name;
             $response = $function->invokeArgs(new $declaring_class(), $args);
         } else {
             $response = $function->invokeArgs($args);
         }
         if (gettype($response) === 'string') {
             $response = new Response($response);
         }
         return $response;
     }
     Response::abort(404);
 }
Example #6
0
File: core.php Project: AidaDC/to
 static function init()
 {
     self::$conf = Registry::getInstance();
     Request::retrieve();
     self::$controller = Request::getCont();
     self::$action = Request::getAct();
     self::$params = Request::getParam();
     self::router();
 }
Example #7
0
 public static function getParam($key, $default = null, $sanitize = true)
 {
     $result = Request::getParam($key, $default);
     if ($sanitize) {
         $result = htmlspecialchars($result);
         $result = trim($result);
     }
     return $result;
 }
Example #8
0
 /**
  * __construct
  *
  * Topic request process validation class constructor.
  * Definition of validation rules
  *
  * @return null
  */
 public function __construct()
 {
     parent::__construct();
     $this->_rules = array('id' => array(array('negation', 'IsNaturalNumber', null), array('filter', 'ToInt'), array('negation', 'GreatThanZero', null)));
     // append unrequired page number
     if (\Request::getParam('page') !== null) {
         $this->_rules['page'] = array(array('negation', 'IsNaturalNumber', null), array('filter', 'ToInt'), array('negation', 'GreatThanZero', null));
     } else {
         $this->_data->page = 1;
     }
 }
Example #9
0
 /**
  * Load layout
  * @param string $layout
  */
 public function Layout($layout = 'layout')
 {
     if (!$this->viewParser) {
         ob_start("callbackParser");
         include_once _SYSDIR_ . 'layout/' . $layout . '.php';
         ob_end_flush();
         echo Request::getParam('buffer');
     } else {
         include_once _SYSDIR_ . 'layout/' . $layout . '.php';
     }
 }
Example #10
0
 static function init()
 {
     //now we can evaluate the request
     self::$conf = Registry::getInstance();
     Request::retrieve();
     self::$controller = Request::getCont();
     self::$action = Request::getAct();
     self::$params = Request::getParam();
     //now we have the array parameters to route
     self::router();
 }
Example #11
0
 /**
  * Generates the required Criteria object for the search.
  *
  * @param string|array $attr
  */
 protected function generateCriteria($attr = 'search')
 {
     if (is_array($attr)) {
         $search = $attr;
         $sensitive = false;
     } else {
         $search = $this->request->getParam($attr);
         $sensitive = $this->request->getParam('case_sensitive', false);
     }
     if (is_array($search)) {
         foreach ($search as $key => $value) {
             if ($key === 'exact') {
                 continue;
             }
             $exactMatch = isset($search['exact'][$key]) && $search['exact'][$key];
             if (!is_array($value)) {
                 $this->addCompare($this->criteria, $key, $value, $sensitive, 'AND', $exactMatch);
             } else {
                 if ($key === 'filterid') {
                     foreach ($value as $fieldName => $fieldValue) {
                         if ($fieldValue > 0) {
                             $this->addCompare($this->criteria, $fieldName, $fieldValue, $sensitive, 'AND', true);
                         }
                     }
                 }
                 if (!isset($value['value'])) {
                     //no value provided to search against
                     continue;
                 }
                 $searchTerm = $value['value'];
                 $this->addCompare($this->criteria, $key, $searchTerm, $sensitive, 'AND', $exactMatch);
                 if (array_key_exists('compare_to', $value) && is_array($value['compare_to'])) {
                     foreach ($value['compare_to'] as $compareTo) {
                         $this->addCompare($this->criteria, $compareTo, $searchTerm, $sensitive, 'OR', $exactMatch);
                     }
                 }
             }
         }
     }
     if ($this->model->hasAttribute('display_order')) {
         $this->criteria->order = 'display_order asc';
     } else {
         $order = $this->request->getParam('d');
         $sortColumn = $this->request->getParam('c');
         if ($sortColumn) {
             $this->relationalAttribute($this->criteria, $sortColumn, $attr);
             if ($order) {
                 $sortColumn .= ' DESC';
             }
             $this->criteria->order = $sortColumn;
         }
     }
 }
Example #12
0
 public function route()
 {
     $request = new Request();
     $moduleParam = $request->getParam('module');
     $Module = ucfirst($moduleParam);
     require_once $GLOBALS['srcdir'] . '/ESign/' . $Module . '/Controller.php';
     $controllerClass = "\\ESign\\" . $Module . "_Controller";
     $controller = new $controllerClass($request);
     if ($controller instanceof Abstract_Controller) {
         $controller->run();
     }
 }
Example #13
0
 public function index()
 {
     //$data = file_get_contents('php://input');
     //print_r($data);
     $x = new Request();
     $p = $x->getParam('POST');
     print_r($p);
     //print_r();
     $favicon = $this->reg->cfg->config('domain') . "/favicon.ico";
     Template::setBaseDir('views');
     Template::display('AdminLogin.php', array('favicon' => $favicon, 'css' => function ($csls) {
         print "http://localhost/lorb/lorb/mxfactory/css/" . $csls;
     }, 'url_login' => $this->reg->front->getRawURL()));
 }
Example #14
0
 /**
  * __construct
  *
  * Topic request process validation class constructor.
  * Definition of validation rules
  *
  * @return null
  */
 public function __construct()
 {
     parent::__construct();
     // append unrequired filter type
     if (\Request::getParam('by') !== null) {
         $this->_rules['by'] = array(array('negation', 'IsString', null), array('filter', 'ToString'), array('filter', 'Trim'), array('assertion', 'IsEmpty', null));
     } else {
         $this->_data->by = 'last';
     }
     // append unrequired page number
     if (\Request::getParam('page') !== null) {
         $this->_rules['page'] = array(array('negation', 'IsNaturalNumber', null), array('filter', 'ToInt'), array('negation', 'GreatThanZero', null));
     } else {
         $this->_data->page = 1;
     }
 }
Example #15
0
 public function getAction()
 {
     if (empty($_SERVER['HTTP_X_REQUESTED_WITH'])) {
         error404();
     }
     $model = new ChatModel();
     $dialog = '';
     $userList = '';
     $lastMessageID = getSession('chat_lmid', false);
     $chatList = $model->getChatMessages('chat', 'ASC', $lastMessageID);
     if ($chatList) {
         foreach ($chatList as $value) {
             $msg = ' ' . $value['message'];
             if (strpos($msg, Request::getParam('user')->nickname) !== false) {
                 $color = ' chat_your_msg';
             } else {
                 $color = false;
             }
             $dialog .= '<div class="chat_message' . $color . '">' . '<div class="chat_img"><a href="' . url($value['uid']) . '" target="_blank"><img src="' . getAvatar($value['uid'], 's') . '"></a></div>' . '<div class="chat_text">' . '<div><span class="chat_nickname" onclick="chatNickname(\'' . $value['uName'] . '\');">' . $value['uName'] . '</span> <span class="chat_time">' . printTime($value['time']) . '</span></div>' . '<div>' . $value['message'] . '</div>' . '</div>' . '</div>';
             setSession('chat_lmid', $value['id']);
         }
     }
     unset($chatList);
     /*
     if (time()%5 == 0 OR getSession('chat_ses') == 0) {
         $listUserOnline = $model->getUserOnline();
         $countUser = 0;
     
     
         while ($list = mysqli_fetch_object($listUserOnline)) {
             $userList .= '<li><a href="' . url($list->id) . '" target="_blank"><span>' . $list->nickname . '</span><span class="level-icon">' . $list->level . '</span></a></li>';
             $countUser++;
         }
     
     
         $response['userList'] = $userList;
         $response['countUser'] = $countUser;
     }
     */
     $response['error'] = 0;
     if ($dialog) {
         $response['target_a']['#dialog'] = $dialog;
     }
     setSession('chat_ses', 1);
     echo json_encode($response);
     exit;
 }
Example #16
0
 public static function start()
 {
     // Generate session if it is not exist
     if (!static::getSessionId()) {
         static::generateSession();
     }
     // set local container from session
     static::$container = static::$handler->read(static::getSessionId());
     $navigator = static::get('navigator');
     if ($navigator['masked_ip'] != long2ip(ip2long(Request::getParam('ip_address')) & ip2long("255.255.0.0")) || $navigator['agent'] != Request::getParam('user_agent') || $navigator['accept_encoding'] != Request::getParam('accept_encoding') || $navigator['accept_language'] != Request::getParam('accept_language')) {
         static::$handler->destroy(static::getSessionId());
         static::generateSession();
     }
     // Store these values into the session so I can check on subsequent requests.
     $navigator = ['masked_ip' => long2ip(ip2long(Request::getParam('ip_address')) & ip2long("255.255.0.0")), 'agent' => Request::getParam('user_agent'), 'accept_encoding' => Request::getParam('accept_encoding'), 'accept_language' => Request::getParam('accept_language')];
     static::put('navigator', $navigator);
     static::put('last_activity', time());
 }
Example #17
0
 /**
  * Create the controller coresponding to the request if the access is granted
  * @param Request $p_oRequest User request
  * @return Controller Associated controller
  * @throws Error
  */
 private function createController($p_oRequest)
 {
     // Create current user
     $oCurrentUser = new User();
     $oCurrentUser->loadFromSession();
     if ($p_oRequest->existParam('p')) {
         $this->sPage = strtolower($p_oRequest->getParam('p'));
     } elseif ($oCurrentUser->checkAccess('search')) {
         $this->sPage = 'search';
     } else {
         $this->sPage = 'login';
     }
     // Check for access
     if (!$oCurrentUser->checkAccess($this->sPage)) {
         throw new Error('FRAMEWORK_ERROR_ACCESS_PRIVILEGE', 2);
     }
     // Create controller
     $sControllerClass = "Controller" . ucfirst($this->sPage);
     $this->oController = new $sControllerClass($p_oRequest);
     $this->oController->setCurrentUser($oCurrentUser);
 }
Example #18
0
 public function launch(Request $request, Response $response)
 {
     $message = null;
     $new_name = null;
     $delete_confirmation = null;
     if ($_SESSION['statut'] == "administrateur") {
         if ($request->getParam('operation')) {
             check_token(false);
             if ($request->getParam('operation') == "delete") {
                 if ($request->getParam('confirm_delete')) {
                     if ($request->getParam('id_calendrier')) {
                         $calendrier = new Calendrier();
                         $calendrier->id = $request->getParam('id_calendrier');
                         if (!$calendrier->delete()) {
                             $message = "Impossible de supprimer le calendrier";
                         }
                     }
                 } else {
                     if ($request->getParam('id_calendrier')) {
                         $delete_confirmation = "<form action=\"index.php?action=calendriermanager\" method=\"post\">" . add_token_field(false) . "\r\n\t\t\t\t\t\t\t\t\t\t\t<input name=\"operation\" type=\"hidden\" value=\"delete\">\r\n\t\t\t\t\t\t\t\t\t\t\t<input name=\"id_calendrier\" type=\"hidden\" value=\"" . $request->getParam('id_calendrier') . "\">\r\n\t\t\t\t\t\t\t\t\t\t\t<p>La suppression d'un calendrier entraîne la suppression de toutes les périodes calendaires qui en dépendent !</p>\r\n\t\t\t\t\t\t\t\t\t\t\t<input name=\"confirm_delete\" type=\"submit\" style=\"width:200px;\" value=\"Confirmer la suppression\">\r\n\t\t\t\t\t\t\t\t\t\t</form>";
                     }
                 }
             } else {
                 if ($request->getParam('operation') == "new") {
                     if ($request->getParam('nom_calendrier')) {
                         $calendrier = new Calendrier();
                         $calendrier->nom = $request->getParam('nom_calendrier');
                         if (!$calendrier->save()) {
                             $message = "Impossible de créer le calendrier";
                         }
                     }
                 } else {
                     if ($request->getParam('operation') == "modify_name") {
                         if ($request->getParam('new_name')) {
                             $calendrier = new Calendrier();
                             $calendrier->nom = $request->getParam('new_name');
                             $calendrier->id = $request->getParam('id_calendrier');
                             if (!$calendrier->update()) {
                                 $message = "Impossible de modifier le nom du calendrier";
                             }
                         } else {
                             if ($request->getParam('id_calendrier')) {
                                 $new_name = "<form action=\"index.php?action=calendriermanager\" method=\"post\">" . add_token_field(false) . "\r\n\t\t\t\t\t\t\t\t\t\t\t<input name=\"operation\" type=\"hidden\" value=\"modify_name\">\r\n\t\t\t\t\t\t\t\t\t\t\t<input name=\"id_calendrier\" type=\"hidden\" value=\"" . $request->getParam('id_calendrier') . "\">\r\n\t\t\t\t\t\t\t\t\t\t\t<input name=\"new_name\" type=\"text\" style=\"width:200px;\" value=\"" . Calendrier::getNom($request->getParam('id_calendrier')) . "\">\r\n\t\t\t\t\t\t\t\t\t\t\t<input name=\"bouton_valider_new_name\" type=\"submit\" style=\"width:200px;\" value=\"Modifier le nom du calendrier\">\r\n\t\t\t\t\t\t\t\t\t\t</form>";
                             }
                         }
                     } else {
                         if ($request->getParam('operation') == "edit_classes") {
                             if ($request->getParam('id_calendrier')) {
                                 $id_calendrier = $request->getParam('id_calendrier');
                                 $jointure = new jointure_calendar_classes();
                                 $periodes = new PeriodeCalendaire();
                                 $classe = new Classe();
                                 $jointure->id_calendar = $id_calendrier;
                                 $jointure->delete_classes();
                                 if ($request->getParam('classes_' . $id_calendrier)) {
                                     $liste_classes = null;
                                     foreach ($request->getParam('classes_' . $id_calendrier) as $id_classe) {
                                         $classe->id = $id_classe;
                                         $liste_classes .= $classe->getShortName() . ";";
                                         $jointure->id_classe = $id_classe;
                                         if (!$jointure->save_classe()) {
                                             $message .= "Une classe est déjà affectée dans un autre calendrier<br/>";
                                         }
                                     }
                                     // ================ Compatibilité pour les autres modules GEPi
                                     $periodes->id_calendar = $id_calendrier;
                                     $periodes->classes_concernees = $liste_classes;
                                     $periodes->update_classes();
                                 }
                             }
                         }
                     }
                 }
             }
         }
         calendar::updateTables();
     }
     $response->addVar('delete_confirmation', $delete_confirmation);
     $response->addVar('new_name', $new_name);
     $response->addVar('message', $message);
     $response->addVar('NomPeriode', calendar::getPeriodName(time()));
     $response->addVar('TypeSemaineCourante', calendar::getTypeCurrentWeek());
     $response->addVar('SemaineCourante', calendar::getCurrentWeek());
     $response->addVar('calendrier', calendar::GenerateCalendarList());
     $this->render("./lib/template/calendriermanagerSuccess.php");
     $this->printOut();
 }
}
?>

</ul>	
</div>

<div class="chatMain">

    <div class="chatBody" id="dialog">

        <?php 
// $list = array_reverse((array)$this->list);
if ($list) {
    foreach ($list as $value) {
        $msg = ' ' . $value['message'];
        if (strpos($msg, Request::getParam('user')->nickname) !== false) {
            $color = ' chat_your_msg';
        } else {
            $color = false;
        }
        echo '<div class="chat_message' . $color . '">' . '<div class="chat_img"><a href="' . url($value['uid']) . '" target="_blank"><img src="' . getAvatar($value['uid'], 's') . '"></a></div>' . '<div class="chat_text">' . '<div><span class="chat_nickname" onclick="chatNickname(\'' . $value['uName'] . '\');">' . $value['uName'] . '</span> <span class="chat_time">' . printTime($value['time']) . '</span></div>' . '<div>' . $value['message'] . '</div>' . '</div>' . '</div>';
        setSession('chat_lmid', $value['id']);
    }
}
?>

    </div>



    <script>
Example #20
0
<?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>';
    }
    echo '<a class="matches" href="{URL:matches}">{L:MENU_MATCHES}' . (Request::getParam('countChallenges') > 0 ? ' (+' . Request::getParam('countChallenges') . ')' : '') . '</a>';
    echo '<a class="notice" href="{URL:notice}">{L:MENU_NOTICE}' . (Request::getParam('user')->notice > 0 ? ' (+' . Request::getParam('user')->notice . ')' : '') . '</a>';
    echo '<a class="discover" href="{URL:discover}">{L:MENU_DISCOVER_PAGE}</a>';
    echo '<a class="chat" href="{URL:chat}">{L:MENU_CHAT}</a>';
    echo '<a class="ladders" href="{URL:ladders}">{L:MENU_LADDERS}</a>';
    echo '<a class="servers" href="{URL:servers}">{L:MENU_SERVERS}</a>';
    echo '<a class="maps" href="{URL:maps}">{L:MENU_MAPS}</a>';
    echo '<a class="news-main" href="{URL:main}">{L:MENU_NEWS}</a>';
    echo '</div>';
} else {
}
Example #21
0
 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;
 }
Example #22
0
<?php

try {
    set_include_path(get_include_path() . PATH_SEPARATOR . getcwd() . '/../lib/' . PATH_SEPARATOR . get_include_path() . PATH_SEPARATOR . getcwd() . '/../application/config/' . PATH_SEPARATOR . get_include_path() . PATH_SEPARATOR . getcwd() . '/../application/controllers/' . PATH_SEPARATOR . get_include_path() . PATH_SEPARATOR . getcwd() . '/../application/views/' . PATH_SEPARATOR . get_include_path() . PATH_SEPARATOR . getcwd() . '/../application/views/car/' . PATH_SEPARATOR . get_include_path() . PATH_SEPARATOR . getcwd() . '/../application/views/category/' . PATH_SEPARATOR . get_include_path() . PATH_SEPARATOR . getcwd() . '/../application/views/login/' . PATH_SEPARATOR . get_include_path() . PATH_SEPARATOR . getcwd() . '/../application/views/register/' . PATH_SEPARATOR . get_include_path() . PATH_SEPARATOR . getcwd() . '/../application/models/' . PATH_SEPARATOR . get_include_path() . PATH_SEPARATOR . getcwd() . '/../lib/WideImage/');
    function MVCAutoload($className)
    {
        include $className . '.php';
    }
    spl_autoload_register('MVCAutoload', true, true);
    session_start();
    $request = new Request();
    $controller = $request->getParam('controller', 'login');
    $action = $request->getParam('action', 'logform');
    $config = Config::getInstance();
    $config = $config->getConfig();
    //Debug::p($config, true);
    if (file_exists($config['APP_DIR'] . 'controllers/' . $controller . 'Controller.php')) {
        $requestObject = $controller . 'Controller';
        if (class_exists($requestObject)) {
            $actObject = new $requestObject();
            $requestAction = $action . 'Action';
            if (method_exists($requestObject, $requestAction)) {
                ob_start();
                $actObject->{$requestAction}();
                $layout = $actObject->layout;
                $content = ob_get_contents();
                ob_end_clean();
                if (isset($actObject->layoutName) && $actObject->layoutName != '') {
                    include_once $actObject->layoutName . '.php';
                } else {
                    include_once $config['LAYOUT'];
Example #23
0
class BadRequestException extends \Exception
{
    protected $body = "";
    public function setBody($body)
    {
        $this->body = $body;
    }
    public function getBody()
    {
        return $this->body;
    }
}
$response = array();
try {
    $request = new Request();
    $esId = $request->getParam('args/es_id');
    $session = new Db_Session();
    $session->load($esId);
    $memberId = $request->getParam('args/member_id');
    $member = new Db_Member();
    $member->load($memberId);
    if ($member->getIsGuest() || is_null($member->getIsGuest())) {
        Controller::preDispatchGuest(false);
    } else {
        Controller::preDispatch(false);
    }
    try {
        $file = new File($session->getFileId());
    } catch (\Exception $e) {
        Helper::warnLog('Error. Session no longer exists. ' . $e->getMessage());
        $ex = new BadRequestException();
Example #24
0
<div class="box_right">
    <?php 
if ($this->rightList->num_rows > 0) {
    while ($list = mysqli_fetch_object($this->rightList)) {
        $count = false;
        if ($list->uid1 == Request::getParam('user')->id) {
            $user = $list->uid2;
            if ($list->countMsg1 > 0) {
                $count = '<div class="mail_count">+' . $list->countMsg1 . '</div>';
            }
        } else {
            $user = $list->uid1;
            if ($list->countMsg2 > 0) {
                $count = '<div class="mail_count">+' . $list->countMsg2 . '</div>';
            }
        }
        echo '<div class="mail_box mail_link">' . '<a href="{URL:mail' . $user . '}"></a>' . $count . '<div class="mail_image"><img src="' . getAvatar($user, 's') . '"></div>' . '<div class="mail_name">' . $list->nickname . '</div>' . '<div class="mail_msg"><span class="mail_time">' . printTime($list->time) . '</span></div>' . '</div>';
    }
} else {
    echo '{L:INDEX_NO_DIALOGS}';
}
?>
</div>
 public function getAction()
 {
     $elements = $this->pages->getChildren();
     $children = $this->getSubElements($elements);
     $includeAnchors = Helpers::isTrue(Request::postParam('includeAnchors', Request::getParam('includeAnchors', false)));
     if ($includeAnchors) {
         Plugins::call(Plugins::PAGETREE_COLLECT_PAGE_ANCHORS, array(), $children);
     }
     $this->success(array('children' => $children));
 }
Example #26
0
<ul class="page_nav">
    <li><a href="{URL:matches}">{L:MATCHES_TITLE}</a></li>
    <li><a href="{URL:matches/challenges}">{L:CHALLENGES_TITLE}<?php 
echo Request::getParam('countChallenges') > 0 ? ' (+' . Request::getParam('countChallenges') . ')' : '';
?>
</a></li>
    <li><a class="active" href="{URL:matches/history}">{L:HISTORY_TITLE}</a></li>
</ul>

<table class="ladderTable">
    <tr>
        <th>#</th>
        <th>{L:MATCHES_USER}</th>
        <th>{L:MATCHES_STATUS}</th>
    </tr>
    <?php 
while ($list = mysqli_fetch_object($this->list)) {
    echo '<tr>';
    echo '<td>' . ++Pagination::$start . '</td>';
    echo '<td><a href="' . url('match' . $list->id) . '">' . $list->nickname . ' {L:CHALLENGES_CHALLENGED_YOU}';
    if ($list->country) {
        echo '<img src="' . _SITEDIR_ . 'public/images/country/' . mb_strtolower($list->country) . '.png">';
    }
    echo '</a></td>';
    echo '<td></td>';
    echo '</tr>';
}
?>
</table>

<?php 
Example #27
0
<?php

try {
    set_include_path(get_include_path() . PATH_SEPARATOR . getcwd() . '/../lib/' . PATH_SEPARATOR . get_include_path() . PATH_SEPARATOR . getcwd() . '/../application/config/' . PATH_SEPARATOR . get_include_path() . PATH_SEPARATOR . getcwd() . '/../application/controllers/' . PATH_SEPARATOR . get_include_path() . PATH_SEPARATOR . getcwd() . '/../application/views/' . PATH_SEPARATOR . get_include_path() . PATH_SEPARATOR . getcwd() . '/../application/models/' . PATH_SEPARATOR . get_include_path() . PATH_SEPARATOR . getcwd() . '/../lib/WideImage/');
    function MVCAutoload($className)
    {
        include $className . '.php';
    }
    spl_autoload_register('MVCAutoload', true, true);
    $request = new Request();
    session_start();
    $controller = $request->getParam('controller', 'index');
    $action = $request->getParam('action', 'index');
    $config = Config::getInstance();
    $config = $config->getConfig();
    if (file_exists($config['APP_DIR'] . 'controllers/' . $controller . 'Controller.php')) {
        $requestObject = $controller . 'Controller';
        if (class_exists($requestObject)) {
            $actObject = new $requestObject();
            $requestAction = $action . 'Action';
            if (method_exists($requestObject, $requestAction)) {
                ob_start();
                $actObject->{$requestAction}();
                $layout = $actObject->layout;
                $content = ob_get_contents();
                ob_end_clean();
                if (isset($actObject->layoutName) && $actObject->layoutName != '') {
                    include_once $actObject->layoutName . '.php';
                } else {
                    include_once $config['LAYOUT'];
                }
Example #28
0
 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());
 }
Example #29
0
File: script.php Project: Jatax/TKS
 * GNU Affero Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
session_start();
//Inclusion des fichiers
require './func/autoloader.func.php';
spl_autoload_register('autoloader');
include './framework/config.class.php';
require './framework/logger.class.php';
include './framework/request.class.php';
include './framework/view.class.php';
//Activation du DEBUG
if (Config::get('debug', false)) {
    ini_set('display_errors', 1);
} else {
    ini_set('display_errors', 0);
}
// Fusion des paramètres GET et POST de la requête
$oRequest = new Request(array_merge($_GET, $_POST));
//On regarde si on a demandé un script
if ($oRequest->existParam('p')) {
    $sScript = strtolower($oRequest->getParam('p'));
} else {
    $sScript = 'search';
}
//Inclusion du script
$sScriptClass = "Script" . ucfirst($sScript);
$oScript = new $sScriptClass($oRequest);
$oScript->procede();
Example #30
0
    }
    .discover-page-wrapper h1{
        margin-bottom: 8px;
    }
    .player-info{
        margin-bottom: 25px;
    }

</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