/** * 获取分页的HTML代码 * * @param number $total_rows * @param number $per_page * @param string $base_url * @return string */ function page($total_rows, $per_page = 10, $base_url = NULL) { // 加载CI的pagination类库 $CI =& get_instance(); $CI->load->library('pagination'); // 处理base_url if ($base_url === NULL) { // 获取URI $base_url = server('REDIRECT_URL') . '?'; // 获取GET参数,并且剔除参数p,组建新的base_url $gets = get(); if ($gets !== FALSE) { if (isset($gets['p'])) { unset($gets['p']); } if (count($gets) > 0) { $query_string = http_build_query($gets); $base_url .= $query_string; } } } // 设置CI的分页配置 $config = array('base_url' => $base_url, 'per_page' => $per_page, 'total_rows' => $total_rows, 'num_links' => 10, 'query_string_segment' => 'p', 'first_link' => '首页', 'last_link' => '末页', 'prev_link' => '<', 'next_link' => '>', 'use_page_numbers' => TRUE, 'page_query_string' => TRUE, 'cur_tag_open' => '<a class="current">', 'cur_tag_close' => '</a>'); // 初始化和返回链接 $CI->pagination->initialize($config); return $CI->pagination->create_links(); }
function ip_address() { $ING =& get_instance(); if ($ING->input->fetch_ip_address() !== FALSE) { return $ING->input->fetch_ip_address(); } $proxy_ips = config_item('proxy_ips'); if (!empty($proxy_ips)) { $proxy_ips = explode(',', str_replace(' ', '', $proxy_ips)); foreach (array('HTTP_X_FORWARDED_FOR', 'HTTP_CLIENT_IP', 'HTTP_X_CLIENT_IP', 'HTTP_X_CLUSTER_CLIENT_IP') as $header) { if (($spoof = server($header)) !== FALSE) { // Some proxies typically list the whole chain of IP // addresses through which the client has reached us. // e.g. client_ip, proxy_ip1, proxy_ip2, etc. if (strpos($spoof, ',') !== FALSE) { $spoof = explode(',', $spoof, 2); $spoof = $spoof[0]; } if (!valid_ip($spoof)) { $spoof = FALSE; } else { break; } } } $ING->input->set_ip_address($spoof !== FALSE && in_array($_SERVER['REMOTE_ADDR'], $proxy_ips, TRUE) ? $spoof : $_SERVER['REMOTE_ADDR']); } else { $ING->input->set_ip_address($_SERVER['REMOTE_ADDR']); } if (!valid_ip($ING->input->fetch_ip_address())) { $ING->input->set_ip_address('0.0.0.0'); } return $ING->input->fetch_ip_address(); }
function insertElement() { if (isset($_POST['ClassificationID'])) { $ClassificationID = json_decode(sanitize($_POST['ClassificationID'])); } if (isset($_POST['Element'])) { $Element = json_decode(sanitize($_POST['Element'])); } if (isset($_POST['AtomicMass'])) { $AtomicMass = json_decode(sanitize($_POST['AtomicMass'])); } $dbConn = mysqli_connect(server(), username(), password(), db("Elements")); if ($dbConn->connect_error) { die("Connection failed: " . $dbConn->connect_error); } $query = "INSERT INTO Elements ( ClassificationID, Element, AtomicMass ) " . "VALUES ( " . "" . $ClassificationID . ", " . "'" . $Element . "', " . "" . $AtomicMass . " );"; $result = $dbConn->query($query); $return = new stdClass(); $return->querystring = (string) $query; if ($result) { $return->success = true; } else { $return->success = false; } return json_encode($return); }
public function use(int $roleId = 6) : bool { $this->permission = INDIVIDUALSTRUCTURES_PERMISSION_CONFIG['page']; if (isset($this->permission[$roleId])) { $rules = $this->permission[$roleId]; } else { return false; } $currentUrl = server('currentPath'); switch ($rules) { case 'all': return true; break; case 'any': return false; break; } if (is_array($rules)) { $pages = current($rules); $type = key($rules); foreach ($pages as $page) { $page = trim($page); if (stripos($page[0], '!') === 0) { $rule = substr(trim($page), 1); } else { $rule = trim($page); } if ($type === "perm") { if (strpos($currentUrl, $rule) > -1) { return true; } else { $this->result = false; } } else { if (strpos($currentUrl, $rule) > -1) { return false; } else { $this->result = true; } } } return $this->result; } else { if ($rules[0] === "!") { $page = substr(trim($rules), 1); } else { $page = trim($rules); } if (strpos($currentUrl, $page) > -1) { if ($rules[0] !== "!") { return true; } else { return false; } } else { return true; } } }
/** * Handle the event. * * @param \Apolune\Account\Events\Email\RequestAccepted $event * @return void */ public function handle(Email\RequestAccepted $event) { list($account, $password) = [$event->account, $event->password]; $this->mailer->send('theme::_emails.new-email', compact('account', 'password'), function ($message) use($account) { $message->to($account->email()); $message->subject(trans('theme::_emails/new-email.title', ['server' => server()->name()])); }); }
function currentUrl(string $fix = '') : string { $currentUrl = sslStatus() . host() . internalCleanInjection(server('requestUri')); if (!empty($fix)) { return rtrim(suffix($currentUrl), $fix) . $fix; } return $currentUrl; }
public function server(string $name = '', $value = NULL) { // @value parametresi boş değilse if (!empty($value)) { $_SERVER[$name] = $value; } return server($name); }
public function process() { $this->log->add('Request Received from: ' . server('REMOTE_ADDR')); $encoding = $this->decode($this->request); if ($encoding != self::ENC_RAW) { $this->log->add('Parsed Request: ' . print_r($this->request, true)); } return $this; }
protected function setUpServer() { $username = getenv('DEPLOYER_USERNAME') ?: 'deployer'; $password = getenv('DEPLOYER_PASSWORD') ?: 'deployer_password'; server('remote_auth_by_password', 'localhost', 22)->env('deploy_path', self::$deployPath)->user($username)->password($password); server('remote_auth_by_identity_file', 'localhost', 22)->env('deploy_path', self::$deployPath)->user($username)->identityFile(); server('remote_auth_by_pem_file', 'localhost', 22)->env('deploy_path', self::$deployPath)->user($username)->pemFile('~/.ssh/id_rsa.pem'); server('remote_auth_by_agent', 'localhost', 22)->env('deploy_path', self::$deployPath)->user($username)->forwardAgent(); }
public function connect($i = 0) { $env = server("SERVER_ADDR") == "::1" || server("SERVER_ADDR") == "127.0.0.1" ? true : false; $conn = mysqli_connect($env ? "localhost" : "mysql.hostinger.com.br", $env ? "root" : "u398318873_tj", $env ? "" : "Knowledge1", $env ? "controk" : "u398318873_bda"); if (mysqli_connect_errno()) { AJAXReturn("error", "Falha ao se conectar ao MySQL:<p>({$conn->connect_errno})</p><p>{$conn->connect_error}</p>"); } elseif ($i == 0) { $this->conn = $conn; } elseif ($i == 1) { return $conn; } }
public function onBoot() { // TODO: Implement onBoot() method. $this->getDI()->setShared('url', function () { $protocol = stripos(server('SERVER_PROTOCOL'), 'https') === true ? 'https://' : 'http://'; $hostname = server('HTTP_HOST'); $url = new Url(); $url->setStaticBaseUri(env('static_url', "{$protocol}{$hostname}/")); $url->setBaseUri(env('base_url', '/')); return $url; }); }
/** * Load server list file. * @param string $file */ function serverList($file) { $serverList = Yaml::parse(file_get_contents($file)); foreach ((array) $serverList as $name => $config) { try { if (!is_array($config)) { throw new \RuntimeException(); } $da = new \Deployer\Type\DotArray($config); if ($da->hasKey('local')) { $builder = localServer($name); } else { $builder = $da->hasKey('port') ? server($name, $da['host'], $da['port']) : server($name, $da['host']); } unset($da['local']); unset($da['host']); unset($da['port']); if ($da->hasKey('identity_file')) { if ($da['identity_file'] === null) { $builder->identityFile(); } else { $builder->identityFile($da['identity_file.public_key'], $da['identity_file.private_key'], $da['identity_file.password']); } unset($da['identity_file']); } if ($da->hasKey('identity_config')) { if ($da['identity_config'] === null) { $builder->configFile(); } else { $builder->configFile($da['identity_config']); } unset($da['identity_config']); } if ($da->hasKey('forward_agent')) { $builder->forwardAgent(); unset($da['forward_agent']); } foreach (['user', 'password', 'stage', 'pem_file'] as $key) { if ($da->hasKey($key)) { $method = lcfirst(str_replace(' ', '', ucwords(str_replace('_', ' ', $key)))); $builder->{$method}($da[$key]); unset($da[$key]); } } // Everything else are env vars. foreach ($da->toArray() as $key => $value) { $builder->env($key, $value); } } catch (\RuntimeException $e) { throw new \RuntimeException("Error in parsing `{$file}` file."); } } }
/** * Hook Done */ public function hookDone() { if (cogear()->session->get('Онлайн') === NULL or time() - cogear()->session->get('Онлайн') > config('widgets.Онлайн.period', 60)) { $Онлайн = new Db_ORM('Онлайн'); $Онлайн->uid = user()->id; $Онлайн->user_agent = server('HTTP_USER_AGENT'); $Онлайн->session_id = cogear()->session->get('session_id'); $Онлайн->ip = cogear()->session->get('ip'); $Онлайн->created_date = time(); $Онлайн->insert(); cogear()->session->set('Онлайн', time()); } }
function internalRequestURI() : string { $requestUri = currentUri() ? str_replace(DIRECTORY_INDEX . '/', '', currentUri()) : substr(server('currentPath'), 1); if (isset($requestUri[strlen($requestUri) - 1]) && $requestUri[strlen($requestUri) - 1] === '/') { $requestUri = substr($requestUri, 0, -1); } $requestUri = internalCleanInjection(internalRouteURI($requestUri)); $requestUri = internalCleanURIPrefix($requestUri, currentLang()); if (defined('_CURRENT_PROJECT')) { $requestUri = internalCleanURIPrefix($requestUri, _CURRENT_PROJECT); } return $requestUri; }
function currentPath(bool $isPath = true) : string { $currentPagePath = str_replace("/" . getLang() . "/", "", server('currentPath')); if (isset($currentPagePath[0]) && $currentPagePath[0] === "/") { $currentPagePath = substr($currentPagePath, 1, strlen($currentPagePath) - 1); } if ($isPath === true) { return $currentPagePath; } else { $str = explode("/", $currentPagePath); if (count($str) > 1) { return $str[count($str) - 1]; } return $str[0]; } }
function lang_http_accept() { $langs = array(); foreach (explode(',', server('HTTP_ACCEPT_LANGUAGE')) as $lang) { $pattern = '/^(?P<primarytag>[a-zA-Z]{2,8})' . '(?:-(?P<subtag>[a-zA-Z]{2,8}))?(?:(?:;q=)' . '(?P<quantifier>\\d\\.\\d))?$/'; $splits = array(); if (preg_match($pattern, $lang, $splits)) { $a = $splits["primarytag"]; if (isset($splits["subtag"]) && $splits["subtag"] != "") { $a = $a . "_" . $splits["subtag"]; } $langs[] = $a; } else { // No match } } return $langs; }
function put($key = null, $default = null) { static $_PUT = null; if ($_PUT === null) { if (req()->isPUT()) { if (strtoupper(server('request_method')) == 'PUT') { parse_str(file_get_contents('php://input'), $_PUT); } else { $_PUT =& $_POST; } } else { $_PUT = array(); } } if ($key === null) { return $_PUT; } return isset($_PUT[$key]) ? $_PUT[$key] : $default; }
/** * Run the migrations. * * @return void */ public function up() { $countries = server()->countries(); Schema::create('__pandaac_registration', function (Blueprint $table) use($countries) { $table->increments('id'); $table->integer('account_id'); $table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade'); $table->string('firstname', 50); $table->string('surname', 50); $table->enum('country', $countries->keys()->toArray()); $table->date('birthday')->default('0000-00-00'); $table->enum('gender', ['female', 'male']); $table->timestamp('request_date')->nullable()->default('0000-00-00 00:00:00'); $table->string('request_firstname', 50)->nullable()->default(null); $table->string('request_surname', 50)->nullable()->default(null); $table->enum('request_country', $countries->keys()->toArray())->nullable()->default(null); $table->timestamps(); }); }
function get_application_path() { // Default to http protocol $proto = "http"; // Detect if we are running HTTPS or proxied HTTPS if (server('HTTPS') == 'on') { // Web server is running native HTTPS $proto = "https"; } elseif (server('HTTP_X_FORWARDED_PROTO') == "https") { // Web server is running behind a proxy which is running HTTPS $proto = "https"; } if (isset($_SERVER['HTTP_X_FORWARDED_SERVER'])) { $path = dirname("{$proto}://" . server('HTTP_X_FORWARDED_SERVER') . server('SCRIPT_NAME')) . "/"; } else { $path = dirname("{$proto}://" . server('HTTP_HOST') . server('SCRIPT_NAME')) . "/"; } return $path; }
public function connect() { if (server("SERVER_ADDR") == "::1" || server("SERVER_ADDR") == "127.0.0.1") { $this->host = "localhost"; $this->db = "deway"; $this->user = "******"; $this->password = ""; } else { $this->host = "mysql.hostinger.com.br"; $this->db = "u398318873_deway"; $this->user = "******"; $this->password = "******"; } $conn = mysqli_connect($this->host, $this->user, $this->password, $this->db); if (mysqli_connect_errno()) { AJAXReturn("{'type':'error','msg':'Falha ao se conectar ao MySQL:<p>({$conn->connect_errno})</p><p>{$conn->connect_error}</p>'}"); } else { return $conn; } }
function piclive($addr) { //Test the server connection $link = $addr; $s_link = str_replace("::", ":", $link); list($addr, $port) = explode(':', "{$s_link}"); if (empty($port)) { $port = 80; } $churl = @fsockopen(server($addr), $port, $errno, $errstr, 1); if (!$churl) { if ("{$errstr}" == "Connection refused") { return "offlin.jpg"; } else { return "notres.jpg"; } } else { return "onlin.jpg"; } }
function piclive($addr) { //Test the server connection $link = $addr; $s_link = str_replace("::", ":", $link); list($addr, $port) = explode(':', "{$s_link}"); if (empty($port)) { $port = 80; } include 'themes/' . $_COOKIE['theme_name'] . '.inc'; $churl = @fsockopen(server($addr), $port, $errno, $errstr, 1); if (!$churl) { if ("{$errstr}" == "Connection refused") { return "src={$a2pic}"; } else { return "src={$a3pic}"; } } else { return "src={$a1pic}"; } }
/** * 多语言 * @param string key键 * @return string */ function L($key) { static $lang; static $package; if (!$lang) { // 设置默认值 $lang = 'zh-cn'; // 遍历查询 if ($language = server('HTTP_ACCEPT_LANGUAGE')) { $types = array('zh-cn', 'zh', 'en', 'fr', 'de', 'jp', 'ko', 'es', 'sv'); foreach ($types as $type) { $pattern = "/{$type}/i"; if (preg_match($pattern, $language)) { $lang = $type; break; } } } // 读取语言包信息 $package = (require LANGUAGE . "{$lang}.php"); } return isset($package[$key]) ? $package[$key] : NULL; }
die; } } } else { $oInfos = new Infos(Data::get("home")); $title = $oInfos->title; $app->redirect('/admin/_connect.html'); die; } }); $app->get('/admin/_connect.html', function () { global $app, $smarty; if (get('error', 0) > 0) { $sPage = Data::get('home'); } else { $sPage = strpos(server('HTTP_REFERER'), server('HTTP_HOST')) !== false ? str_replace('http://' . server('HTTP_HOST') . '/', '', server('HTTP_REFERER')) : Data::get('home'); } $oParser = DomParser::getInstance(); $oParser->init(ROOT . $sPage, new Infos($sPage)); $oParser->displayConnectBox($sPage, get('error', 0)); die; }); $app->get('/admin/:page.html', 'admin_middleware', function ($sPage) { global $app, $smarty; $oParser = DomParser::getInstance(); $oParser->init(ROOT . $sPage . '.html', new Infos($sPage . '.html')); $oParser->display($sPage); die; }); $app->post('/admin/save/:ref/', 'admin_middleware', function ($sRef) use($app) { $oBrick = Brick::get($sRef);
/** * Delete post * * @param type $cid */ public function delete_action($post_id) { $post = new Post(); $post->id = $post_id; if ($post->find() && access('Post.delete.all')) { if ($post->delete()) { $message = t('Пост удалён'); if (Ajax::is()) { $data['success'] = TRUE; $data['messages'] = array(array('type' => 'success', 'body' => $message)); $data['redirect'] = server('referer'); $ajax = new Ajax(); $ajax->json($data); } $post = new Post(); $post->id = $post->post_id; flash_success($message); back(-2); } } }
public function page($roleId = '6') { if (!is_numeric($roleId)) { return Error::set(lang('Error', 'numericParameter', 'roleId')); } $this->permission = $this->config['page']; if (isset($this->permission[$roleId])) { $rules = $this->permission[$roleId]; } else { return false; } $currentUrl = server('currentPath'); switch ($rules) { case 'all': return true; break; case 'any': return false; break; } if (strpos($rules, "|")) { $pages = explode("|", $rules); foreach ($pages as $page) { $page = trim($page); if (@$page[0] === "!") { $rule = substr(trim($page), 1); } else { $rule = trim($page); } if ($pages[0] === "perm->") { if (strpos($currentUrl, $rule) > -1) { return true; } else { $this->result = false; } } else { if (@strpos($currentUrl, $rule) > -1) { return false; } else { $this->result = true; } } } return $this->result; } else { if ($rules[0] === "!") { $page = substr(trim($rules), 1); } else { $page = trim($rules); } if (strpos($currentUrl, $page) > -1) { if ($rules[0] !== "!") { return true; } else { return false; } } else { return true; } } }
<?php date_default_timezone_set('Europe/Stockholm'); include_once 'vendor/deployer/deployer/recipe/common.php'; include_once 'pull.php'; include_once 'deploy.php'; server('development', 'newsflow.dev', 22)->env('deploy_path', '/var/www')->env('branch', 'master')->stage('development')->user('vagrant', 'vagrant'); server('production', 'andreasek.se', 22)->env('deploy_path', '/mnt/persist/www/newsflow33')->user('root')->env('branch', 'master')->stage('production')->identityFile(); set('repository', 'git@github.com:ekandreas/newsflow33.git');
<?php require 'recipe/common.php'; server('{host}', '{host}', 22)->user('{username}')->identityFile('{key_path}{host}.pub', '{key_path}{host}')->stage('{host}')->env('deploy_path', '{path}'); set('repository', '{repo}'); set('branch', '{branch}');
public static function execute($controller, $action = 'index', $cache = -1) { $out = \Sauce\Base::$response; $hash = md5(URI . '?' . server('QUERY_STRING') . '#' . session_id()); \Sauce\Logger::debug("Executing {$controller}#{$action}"); if ($cache > 0 && ($test = \Cashier\Base::fetch($hash))) { @(list($out->status, $out->headers, $out->response) = $test); } else { $controller_path = path(APP_PATH, 'app', 'controllers'); $controller_base = path($controller_path, 'base.php'); $controller_file = path($controller_path, "{$controller}.php"); if (!is_file($controller_file)) { throw new \Exception("Missing '{$controller_file}' file"); } is_file($controller_base) && (require $controller_base); require $controller_file; $base_name = classify(basename(APP_PATH)); $class_name = classify($controller); if (!class_exists($class_name)) { throw new \Exception("Missing '{$class_name}' class"); } $app = new $class_name(); $klass = new \ReflectionClass($app); $type = params('format'); $handle = new \Postman\Handle($app, $type); $methods = $klass->getMethods(\ReflectionMethod::IS_STATIC); foreach ($methods as $callback) { $fn = $callback->getName(); if (substr($fn, 0, 3) === 'as_') { $handle->register(substr($fn, 3), function () use($class_name, $fn) { return call_user_func_array("{$class_name}::{$fn}", func_get_args()); }); } } $test = $handle->exists($action) ? $handle->execute($action) : array(); $vars = (array) $class_name::$view; $params = $klass->getStaticProperties(); if ($type) { if (!in_array($type, $params['responds_to'])) { throw new \Exception("Unknown response for '{$type}' type"); } \Sauce\Logger::debug("Using response for '{$type}' type"); if (isset($test[2])) { $test = $handle->responds($test[2], $params); } else { $test = array(202, array(), ''); } } @(list($out->status, $out->headers, $out->response) = $test); $params['status'] && ($out->status = (int) $params['status']); $params['headers'] && ($out->headers = (array) $params['headers']); if ($out->response === NULL) { \Sauce\Logger::debug("Rendering view {$controller}/{$action}.php"); $out->response = partial("{$controller}/{$action}.php", $vars); if ($params['layout']) { \Sauce\Logger::debug("Using layout layouts/{$params['layout']}.php"); $layout_file = "layouts/{$params['layout']}.php"; $out->response = partial($layout_file, array('head' => join("\n", $params['head']), 'title' => $params['title'], 'body' => $out->response, 'view' => $vars)); } } if ($cache > 0) { \Sauce\Logger::debug("Caching for {$cache} seconds ({$controller}#{$action})"); \Cashier\Base::store($hash, array($out->status, $out->headers, $out->response), $cache); } } return $out; }
array_shift($v); if ($key == '_menus_') { $keys = $v; } foreach ($v as $ka => $va) { if ($va) { $n[$k]++; } } if ($key) { $re[$key] = $v; } } if ($n) { $max = max($n); foreach ($re as $k => $v) { for ($i = 0; $i < $max; $i++) { $ret[$k][$i] = $v[$i]; } } //$keys[$i] return $ret; } } //if($_GET['table']=='server/shared_files'){require_once('../progb/finder.php'); distrib_share();} if ($_GET['table']) { echo server(); } if ($_GET['call']) { echo clkt($_GET['call']); }