/** * Process a template (catch displayed content) * * @param string $id template id * @param array $vars template variables * * @return string parsed template content */ public static function process($id, $vars = array()) { // Are we asked to not output context related html comments ? $addctx = true; if (substr($id, 0, 1) == '!') { $addctx = false; $id = substr($id, 1); } // Resolve template file path $path = self::resolve($id); return (new Event('template_process', $id, $path, $vars, $addctx))->trigger(function ($id, $path, $vars, $addctx) { // Lambda renderer to isolate context $renderer = function ($_path, $_vars) { foreach ($_vars as $_k => $_v) { if (substr($_k, 0, 1) != '_') { ${$_k} = $_v; } } include $_path; }; // Render $exception = null; ob_start(); try { $renderer($path, $vars); } catch (Exception $e) { $exception = $e; } $content = ob_get_clean(); // Translation syntax $content = preg_replace_callback('`\\{(loc|tr|translate):([^}]+)\\}`', function ($m) { return (string) Lang::translate($m[2]); }, $content); // Config syntax $content = preg_replace_callback('`\\{(cfg|conf|config):([^}]+)\\}`', function ($m) { return Config::get($m[2]); }, $content); // Image syntax $content = preg_replace_callback('`\\{(img|image):([^}]+)\\}`', function ($m) { return GUI::path('images/' . $m[2]); }, $content); // Path syntax $content = preg_replace_callback('`\\{(path):([^}]*)\\}`', function ($m) { return GUI::path($m[2]); }, $content); // URL syntax $content = preg_replace_callback('`\\{(url):([^}]*)\\}`', function ($m) { return preg_replace('`^(https?://)?([^/]+)/`', '/', Config::get('application_url')) . $m[2]; }, $content); // Add context as a html comment if required if ($addctx) { $content = "\n" . '<!-- template:' . $id . ' start -->' . "\n" . $content . "\n" . '<!-- template:' . $id . ' end -->' . "\n"; } // If rendering threw rethrow if ($exception) { throw $exception; } return $content; }); }
public function blacklistAction() { $model = new FriendsModel(); Pagination::calculate(get('page', 'int'), 15, $model->countFriends(Request::getParam('user')->id, 'out', 0, 1, false)); $this->view->blacklist = $model->getFriends(Request::getParam('user')->id, 'out', 0, 1, false, Pagination::$start, Pagination::$end); $this->view->title = Lang::translate('BLACKLIST_TITLE'); }
/** * Generates Rackspace API key credentials * {@inheritDoc} */ public function getCredentials() { $secret = $this->getSecret(); if (!empty($secret['username']) && !empty($secret['apiKey'])) { $credentials = array('auth' => array('RAX-KSKEY:apiKeyCredentials' => array('username' => $secret['username'], 'apiKey' => $secret['apiKey']))); if (!empty($secret['tenantName'])) { $credentials['auth']['tenantName'] = $secret['tenantName']; } elseif (!empty($secret['tenantId'])) { $credentials['auth']['tenantId'] = $secret['tenantId']; } return json_encode($credentials); } else { throw new Exceptions\CredentialError(Lang::translate('Unrecognized credential secret')); } }
public function view() { $strings = $_GET['strings']; $namespace = empty($_GET['namespace']) ? null : General::sanitize($_GET['namespace']); $new = array(); foreach ($strings as $key => $value) { // Check value if (empty($value) || ($value = 'false')) { $value = $key; } $value = General::sanitize($value); // Translate $new[$value] = Lang::translate(urldecode($value), null, $namespace); } $this->_Result = $new; }
/** * Sets metadata values from an array, with optional prefix * * If $prefix is provided, then only array keys that match the prefix * are set as metadata values, and $prefix is stripped from the key name. * * @param array $values an array of key/value pairs to set * @param string $prefix if provided, a prefix that is used to identify * metadata values. For example, you can set values from headers * for a Container by using $prefix='X-Container-Meta-'. * @return void */ public function setArray($values, $prefix = null) { if (empty($values)) { return false; } foreach ($values as $key => $value) { if ($prefix) { if (strpos($key, $prefix) === 0) { $name = substr($key, strlen($prefix)); $this->getLogger()->info(Lang::translate('Setting [{name}] to [{value}]'), array('name' => $name, 'value' => $value)); $this->{$name} = $value; } } else { $this->{$key} = $value; } } }
/** * Sets metadata values from an array, with optional prefix * * If $prefix is provided, then only array keys that match the prefix * are set as metadata values, and $prefix is stripped from the key name. * * @param array $values an array of key/value pairs to set * @param string $prefix if provided, a prefix that is used to identify * metadata values. For example, you can set values from headers * for a Container by using $prefix='X-Container-Meta-'. * @return void */ public function SetArray($values, $prefix = null) { if (empty($values)) { return false; } foreach ($values as $key => $value) { if ($prefix) { if (strpos($key, $prefix) === 0) { $name = substr($key, strlen($prefix)); $this->debug(Lang::translate('Setting [%s] to [%s]'), $name, $value); $this->{$name} = $value; } } else { $this->{$key} = $value; } } }
public function indexAction() { $model = new ChatModel(); setSession('chat_ses', 0); $this->view->list = $model->getChatMessages('chat'); $this->view->title = Lang::translate('INDEX_TITLE'); $this->view->onlines = $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++; } */ }
<div class="box"> <?php if (getCookie('error')) { echo getCookie('error'); } ?> <?php if ($this->msg) { echo $this->msg; echo '<br/><a href="' . url('page', 'recovery') . '">' . Lang::translate("RECOVERY_GO_BACK") . '</a>'; } else { ?> <form action="<?php echo url('page', 'recovery'); ?> " method="POST"> <div class="formRow"> <div class="formRowTitle"> {L:RECOVERY_EMAIL} </div> <div class="formRowField"> <input type="email" name="email" value="<?php echo post('email') ? post('email') : ''; ?> " required="required" /> </div> </div> <div class="formRow">
public function banAction() { //$model = new ProfileModel(); $this->view->title = Lang::translate('BAN_TITLE'); }
public function userstatAction() { $model = new AdminModel(); $this->view->count = $model->countUsers(); $this->view->count24h = $model->countUsers("`dateLast` > '" . (time() - 24 * 3600) . "'"); $this->view->list = $model->getUsersOnline(); $this->view->title = Lang::translate('USERSTAT_TITLE'); }
<h1>{L:INDEX_TITLE}</h1> <div><a class="marker-icon" href="{URL:admin/news}">{L:INDEX_NEWS}</a></div> <div><a href="{URL:admin/verify_users}"><?php echo Lang::translate('INDEX_VERIFY_USERS') . ' (' . $this->countVerifyUsers . ')'; ?> </a></div> <div><a href="{URL:admin/disputes}">{L:INDEX_DISPUTES}</a></div> <div><a href="{URL:admin/servers}">{L:INDEX_SERVERS}</a></div> <div><a class="marker-icon" href="{URL:admin/users}">{L:INDEX_USERS}</a></div> <div><a class="marker-icon" href="{URL:admin/userstat}">{L:INDEX_USERS_STAT}</a></div> <div><a class="marker-icon" href="{URL:admin/guests}">{L:INDEX_GUESTS}</a></div>
public function social_saveAction() { if (empty($_SERVER['HTTP_X_REQUESTED_WITH'])) { error404(); } $model = new SettingsModel(); $save['facebook'] = post('__facebook'); $save['steam'] = post('__steam'); $save['twitch'] = post('__twitch'); $save['twitter'] = post('__twitter'); $save['youtube'] = post('__youtube'); $model->setSettings(Request::getParam('user')->id, $save); $status = '<div class="">' . Lang::translate('SOCIAL_SAVED') . '</div>'; $response['error'] = 0; $response['target_h']['#status'] = $status; echo json_encode($response); exit; }
/** * Returns the resource name for the URL of the object; must be overridden * in child classes * * For example, a server is `/servers/`, a database instance is * `/instances/`. Must be overridden in child classes. * * @throws UrlError */ public static function resourceName() { if (isset(static::$url_resource)) { return static::$url_resource; } throw new Exceptions\UrlError(sprintf(Lang::translate('No URL resource defined for class [%s] in ResourceName()'), get_class())); }
<h1>{L:INDEX_VERIFY_USERS}</h1> <?php while ($list = mysqli_fetch_object($this->list)) { echo '<div>'; echo '<a href="' . url($list->id) . '">' . $list->nickname . '</a>'; echo ' <span id="verify' . $list->id . '">('; echo '<a onclick="' . ajaxLoad(url('admin', 'verify_users_submit'), 'verifys', 'id:' . $list->id) . '">' . Lang::translate('VERIFY_USERS_SUBMIT') . '</a> | '; echo '<a onclick="' . ajaxLoad(url('admin', 'verify_users_reject'), 'verifyr', 'id:' . $list->id) . '">' . Lang::translate('VERIFY_USERS_REJECT') . '</a>'; echo ')</span>'; echo ' / Steam '; if ($list->steamid) { echo '<span class="c_green">✔</span>'; } else { echo '<span class="c_red">✖</span>'; } echo '</div>'; }
/** * selects only specified items from the Collection * * This provides a simple form of filtering on Collections. For each item * in the collection, it calls the callback function, passing it the item. * If the callback returns `TRUE`, then the item is retained; if it returns * `FALSE`, then the item is deleted from the collection. * * Note that this should not supersede server-side filtering; the * `Collection::Select()` method requires that *all* of the data for the * Collection be retrieved from the server before the filtering is * performed; this can be very inefficient, especially for large data * sets. This method is mostly useful on smaller-sized sets. * * Example: * <code> * $services = $connection->ServiceList(); * $services->Select(function($item){ return $item->region=='ORD';}); * // now the $services Collection only has items from the ORD region * </code> * * `Select()` is *destructive*; that is, it actually removes entries from * the collection. For example, if you use `Select()` to find items with * the ID > 10, then use it again to find items that are <= 10, it will * return an empty list. * * @api * @param callable $testfunc a callback function that is passed each item * in turn. Note that `Select()` performs an explicit test for * `FALSE`, so functions like `strpos()` need to be cast into a * boolean value (and not just return the integer). * @returns void * @throws DomainError if callback doesn't return a boolean value */ public function select($testfunc) { foreach ($this->getItemList() as $index => $item) { $test = call_user_func($testfunc, $item); if (!is_bool($test)) { throw new Exceptions\DomainError(Lang::translate('Callback function for Collection::Select() did not return boolean')); } if ($test === false) { unset($this->itemList[$index]); } } }
<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 echo $list["uid"]; ?>
if ($this->profile->iSport) { echo '<div class="profileRowInfo">' . Lang::translate('INDEX_FAVORITES_SPORT') . ': ' . $this->profile->iSport . '</div>'; } echo '</div>'; echo '<div class="pHr"></div>'; echo '<div class="pr_block left">'; // Referral echo '<div class="pTitle">' . Lang::translate('INDEX_INVITE') . '</div>'; echo '<div class="profileRowInfo">' . Lang::translate('INDEX_REFERRAL') . ': ' . $this->ref_count . '</div>'; // Reg code if (Request::getParam('user')->id && Request::getParam('user')->id == $this->profile->id) { echo '<div><a onclick="' . ajaxLoad(url('profile', 'regcode'), 'reg_code') . '">' . Lang::translate('INDEX_GET_REG_CODE') . '</a>: <span id="reg_code"></span></div>'; } echo '</div>'; echo '<div class="pr_block right">'; // Info echo '<div class="pTitle">' . Lang::translate('INDEX_INFO') . '</div>'; echo '<div class="profileRowInfo">' . Lang::translate('INDEX_LAST_VISIT') . ': ' . printTime($this->profile->dateLast) . '</div>'; echo '<div class="profileRowInfo">' . Lang::translate('INDEX_DATE_REG') . ': ' . printTime($this->profile->dateReg) . '</div>'; echo '</div>'; echo '<div class="pHr"></div>'; echo '<div class="merits">'; if ($this->profile->steamid) { echo '<div><img src="' . _SITEDIR_ . 'public/images/img/steamverie.jpg" title=""></div>'; } if ($this->profile->role != 'guest' && $this->profile->role != 'claim') { echo '<div><img src="' . _SITEDIR_ . 'public/images/img/verifieduser.jpg" title=""></div>'; } echo '</div>'; echo '</div>'; echo '<div class="clear"></div>';
</div> <div class="formRowField"> <input type="text" name="email" autocomplete="off" value="<?php echo $email->email; ?> "> </div> </div> <div class="formRow"> <div class="formRowTitle"> <?php echo Lang::translate('INDEX_NEWS_EMAIL'); ?> : </div> <div class="formRowField"> <input type="checkbox" name="news" value="1" autocomplete="off" checked="checked"> </div> </div> <div class="formRow"> <div class="formRowTitle"></div> <div class="formRowField"> <input type="submit" value="<?php echo Lang::translate('INDEX_BUTTON_SAVE'); ?> "> </div> </div> </form>
</div> <div class="formRow"> <div class="formRowTitle"> <?php echo Lang::translate('GENERAL_ABOUT'); ?> : </div> <div class="formRowField"> <textarea name="about"><?php echo Request::getParam('user')->about; ?> </textarea> </div> </div> <div class="formRow"> <div class="formRowTitle"> </div> <div class="formRowField"> <input type="submit" value="<?php echo Lang::translate('GENERAL_BUTTON_SAVE'); ?> "> </div> </div> </form> </div>
/** * Function callbackParser * @param $buffer */ function callbackParser($buffer) { $arr1 = array(); $arr2 = array(); preg_match_all("~{([0-9A-Z_]{1,}):([0-9A-Za-z_//#]+)}~", $buffer, $m); foreach ($m[1] as $key => $value) { if ($value == 'L') { $arr1[] = '{' . $value . ':' . $m[2][$key] . '}'; $arr2[] = Lang::translate($m[2][$key]); } elseif ($value == 'URL') { $arr1[] = '{' . $value . ':' . $m[2][$key] . '}'; $arr2[] = url($m[2][$key]); } } $ar = str_replace($arr1, $arr2, $buffer); Request::setParam('buffer', $ar); Request::setParam('buf', $m); }
<div class="formRowTitle"> <?php echo Lang::translate('RIG_CASE'); ?> : </div> <div class="formRowField"> <input type="text" id="iCase" value="<?php echo Request::getParam('user')->iCase; ?> "> </div> </div> <div class="formRow"> <div class="formRowTitle"> </div> <div class="formRowField"> <button onclick="<?php echo ajaxLoad(url('settings', 'rig_save'), 'rig', '#videoCard!|#soundCard!|#cpu!|#ram!|#hardDrive!|#os!|#headset!|#mouse!|#mousepad!|#keyboard!|#monitor!|#iCase!'); ?> "> <?php echo Lang::translate('RIG_BUTTON_SAVE'); ?> </button> </div> </div> </div>
</div> <div class="formRow"> <div class="formRowTitle"></div> <div class="formRowField"> <input type="submit" value="<?php echo Lang::translate('REG_SUBMIT'); ?> "> </div> </div> </form> <style> .hidesr { display: none; padding: 2px; color: red;
/** * The translation function accepts an English string and returns its translation * to the active system language. If the given string is not available in the * current dictionary the original English string will be returned. Given an optional * `$inserts` array, the function will replace translation placeholders using `vsprintf()`. * Since Symphony 2.3, it is also possible to have multiple translation of the same string * according to the page namespace (i.e. the value returned by Symphony's `getPageNamespace()` * method). In your lang file, use the `$dictionary` key as namespace and its value as an array * of context-aware translations, as shown below: * * $dictionary = array( * [...] * * 'Create new' => 'Translation for Create New', * * '/blueprints/datasources' => array( * 'Create new' => * 'If we are inside a /blueprints/datasources/* page, this translation will be returned for the string' * ), * * [...] * ); * * @see core.Symphony#getPageNamespace() * @param string $string * The string that should be translated * @param array $inserts (optional) * Optional array used to replace translation placeholders, defaults to NULL * @return string * Returns the translated string */ function __($string, $inserts = null) { return Lang::translate($string, $inserts); }
<div class="formRowTitle"> <?php echo Lang::translate('FAVORITES_SPORT'); ?> : </div> <div class="formRowField"> <textarea id="iSport"><?php echo Request::getParam('user')->iSport; ?> </textarea> </div> </div> <div class="formRow"> <div class="formRowTitle"> </div> <div class="formRowField"> <button onclick="<?php echo ajaxLoad(url('settings', 'favorites_save'), 'favorites', '#iPlayer!|#iTeam!|#iGame!|#iRole!|#iMusic!|#iFood!|#iSport!'); ?> "> <?php echo Lang::translate('FAVORITES_BUTTON_SAVE'); ?> </button> </div> </div> </div>
public function passwordResetAction() { if (isset(Request::getUri()[0])) { $model = new PageModel(); if ($model->recoveryHashExist(Request::getUri()[0])) { $this->view->success = false; if (isPost()) { $post = allPost(); if (isset($post['email']) && isset($post['password']) && isset($post['password2'])) { if ($post['password'] == $post['password2']) { if (checkLenght($post['password'], 6, 20)) { if ($model->recoveryHashExist(Request::getUri()[0], $post['email'])) { if ($model->resetPassword($post['email'], $post['password'])) { $this->view->msg = "You have successfully changed password."; $this->view->success = true; $message = "Dear,<br/>Your account password at <a href=\"" . SITE_URL . "\">" . SITE_NAME . "</a> was changed.<br/>" . "New password is " . $post['password'] . "<br/>" . "Please do not share him!" . "<br/><br/>" . "Thanks for using our service,<br/>" . "Best regards,<br/>Administration."; $headers = "MIME-Version: 1.0\r\n" . "Content-type: text/html; charset=utf-8\r\n"; if (mail($post['email'], "Password Reset", $message, $headers)) { $this->view->msg .= " Notification about password reset was sent to your email."; } } else { $this->view->msg = "Something wrong. Please try again later."; } } else { $this->view->msg = "Wrong email. Please check entered data"; } } else { $this->view->msg = "Allowed password length may be from 6 to 20 characters."; } } else { $this->view->msg = "Passwords aren't similar! Try again"; } } else { $this->view->msg = "You must fill all fields! Try again"; } } $model->deleteOldRecovery(); $this->view->langPars = true; $this->view->hash = Request::getUri()[0]; $this->view->title = Lang::translate("PASSWORD_RESET_TITLE"); } else { setMyCookie('error', "Wrong password recovery code.", time() + 5); redirect(url('page', 'recovery')); } } else { redirect(url()); } }
/** * throws a UpdateError for subclasses that don't support Update * * @throws UpdateError */ protected function NoUpdate() { throw new Exceptions\UpdateError(sprintf(Lang::translate('[%s] does not support Update()'), get_class())); }
public static function ajaxPagination($count = 2, $separate = 'span', $data = array()) { $html = null; if (self::$page > 1) { $html .= '<' . $separate . '><a href="' . $data['href'] . '" onclick="' . ajaxLoad($data['url'], $data['permit'], $data['fields'] . 'page:' . (self::$page - 1)) . '" title="' . Lang::translate('PAGINATION_PREV') . '">' . Lang::translate('PAGINATION_PREV') . '</a></' . $separate . '>'; } if (self::$page > $count) { $from = self::$page - $count; } else { $from = 1; } if (self::$countPage - self::$page >= $count) { $to = self::$page + $count; } else { $to = self::$countPage; } if (self::$page > $count + 1) { $html .= '<' . $separate . '><a href="' . $data['href'] . '" onclick="' . ajaxLoad($data['url'], $data['permit'], $data['fields'] . 'page:1') . '">1</a></' . $separate . '>'; } if (self::$page > $count + 2) { $html .= '<' . $separate . '><a class="interspace">...</a></' . $separate . '>'; } for ($from; $from <= $to; $from++) { if (self::$page == $from) { $html .= '<' . $separate . '><a class="active">' . $from . '</a></' . $separate . '>'; } else { $html .= '<' . $separate . '><a href="' . $data['href'] . '" onclick="' . ajaxLoad($data['url'], $data['permit'], $data['fields'] . 'page:' . $from) . '">' . $from . '</a></' . $separate . '>'; } } if (self::$page + $count < self::$countPage - 1) { $html .= '<' . $separate . '><a class="interspace">...</a></' . $separate . '>'; } if (self::$page + $count < self::$countPage) { $html .= '<' . $separate . '><a href="' . $data['href'] . '" onclick="' . ajaxLoad($data['url'], $data['permit'], $data['fields'] . 'page:' . self::$countPage) . '">' . self::$countPage . '</a></' . $separate . '>'; } if (self::$page < self::$countPage) { $html .= '<' . $separate . '><a href="' . $data['href'] . '" onclick="' . ajaxLoad($data['url'], $data['permit'], $data['fields'] . 'page:' . (self::$page + 1)) . '" title="' . Lang::translate('PAGINATION_NEXT') . '">' . Lang::translate('PAGINATION_NEXT') . '</a></' . $separate . '>'; } return $html; }
public function sendAction() { if (empty($_SERVER['HTTP_X_REQUESTED_WITH'])) { error404(); } $model = new MailModel(); $hash = post('__hash'); $dialog = getSession($hash); $response['error'] = 0; if (!$dialog['did']) { $response['error'] = 'There is no dialogue'; echo json_encode($response); exit; } $dialogCon = $model->getDialogByID($dialog['did']); if ($dialogCon->uid1 == Request::getParam('user')->id) { $userId = $dialogCon->uid2; } elseif ($dialogCon->uid2 == Request::getParam('user')->id) { $userId = $dialogCon->uid1; } $friendStatus = $model->friendsStatus(Request::getParam('user')->id, $userId); if ($friendStatus['ban'] == 1) { $response['target_a']['#dialog'] = '<div>' . Lang::translate('SEND_BAN') . '</div>'; echo json_encode($response); exit; } $message['did'] = $dialog['did']; $message['uid'] = Request::getParam('user')->id; $message['name'] = Request::getParam('user')->nickname; $message['message'] = post('__msg'); $message['time'] = time(); if (!empty($message['message'])) { if ($dialog['pos'] == 1) { $pos = 2; } else { $pos = 1; } $query = $model->getInsertQuery('messages', $message); $query .= "UPDATE `dialog` SET `countMsg{$pos}` = `countMsg{$pos}` +1 , `time` = '" . time() . "' WHERE `id` = '" . $dialog['did'] . "';"; $model->multiQuery($query); } echo json_encode($response); exit; }