public function _initialize() { if (is_localhost()) { } else { dump('不是本机访问'); //exit; } }
function my_content_type_exception_handler($e) { $message = "Error: " . htmlspecialchars($e->getMessage()); if (is_localhost()) { // only display trace locally $message .= "\nTrace:" . print_exception_trace_js($e); } echo "alert(" . json_encode($message) . ");"; }
function my_content_type_exception_handler($e) { $message = "Error: " . htmlspecialchars($e->getMessage()); $result = array('success' => false, 'message' => $message); if (is_localhost()) { // only display trace locally $result['trace'] = print_exception_trace_js($e); } echo json_encode($result); }
{ # Get Variables Object global $_variables; # Get Variable if (!is_null($name)) { return $_variables->get($name); } # Get All Variables return $_variables->get(); } /** * Get Variables * * @since 1.0.0 */ function vars() { return get(); } # Debug helpers set('dev', array('localhost' => is_localhost())); # Page variables set('page', array('is_home' => is_home(), 'path' => $_path, 'slug' => get_page()), true); # User variables set('user', array('is_loggedin' => is_loggedin())); # Various useful variables set('this_year', this_year()); # Trigger: variables_init if (extras_enabled()) { do_trigger('variables_init'); }
function __construct() { global $lang, $dB; $this->dB = $dB; // Parse the definitions to this object.. This nos not necessary but in case of changes... $this->root_url = __CHV_RELATIVE_ROOT__; $this->base_url = __CHV_BASE_URL__; $this->path_images = rtrim(__CHV_PATH_IMAGES__, '/') . '/'; $this->path_theme = __CHV_PATH_THEME__; // Parse the params $this->request_uri = $_SERVER['REQUEST_URI']; $this->script_name = $_SERVER['SCRIPT_NAME']; $this->valid_request = sanitize_path($this->request_uri); // Build the canonical request // All the dirs will have a traling slash no matter in what whe are (Linux, Windows, etc) $this->canonical_request = '/' . $this->valid_request; if (is_dir(__CHV_ROOT_DIR__ . $this->valid_request)) { $this->canonical_request .= '/'; } $this->handled_request = $this->root_url == '/' ? $this->valid_request : str_ireplace($this->root_url, '', $this->add_trailing_slashes($this->request_uri)); $this->request_array = explode('/', rtrim(str_replace("//", "/", str_replace("?", "/", $this->handled_request)), '/')); $this->base_request = $this->request_array[0]; // Override this vars just for the admin area if ($this->base_request == chevereto_config('admin_folder')) { $this->root_url = __CHV_RELATIVE_ADMIN__; $this->base_url = __CHV_ADMIN_URL__; } // If the request is invalid we make a 301 redirection to the canonical url. if ($this->root_url !== $this->request_uri and $this->canonical_request !== $this->request_uri) { $this->redirect($this->base_redirection($this->canonical_request), 301); } // It's a valid request on admin or index.php? if ($this->base_request !== chevereto_config('admin_folder')) { if ($this->is_index()) { $this->proccess_request(); } } else { // Admin credentials if (!check_value(chevereto_config('admin_password'))) { $admin_password_errors[] = 'You need to set the admin password in <code>$config[\'admin_password\']</code>'; } if (chevereto_config('admin_password') == 'password') { $admin_password_errors[] = 'You haven\'t changed the default admin password. Please set this value in <code>$config[\'admin_password\']</code>'; } if (check_value($admin_password_errors) && !is_localhost()) { chevereto_die($admin_password_errors, 'Config error', array('You need to fix the configuration related to the admin credentials before use this area.')); } require_once __CHV_PATH_ADMIN_CLASSES__ . 'class.adminhandler.php'; $handler = new AdminHandler($this->valid_request); die; } }
/** * Format a number to the lowest precision that's necessary, to a maximum of the * given precision. */ function number_format_autoprecision($n, $precision = 8, $dec_point = ".", $thousands_sep = ",") { if (!is_numeric($n) && $n && is_localhost()) { throw new Exception("'{$n}' is not numeric"); } // find the lowest precision that we need for ($i = 0; $i < $precision - 1; $i++) { if (number_format($n, (int) $i, ".", "") == $n) { $precision = (int) $i; break; } } return number_format($n, $precision, $dec_point, $thousands_sep); }
function api_v1_graphs($graph) { $start_time = microtime(true); $result = array(); /** * Graph rendering goes like this: * 0. check graph rendering permissions * 1. get raw graph data (from a {@link GraphRenderer} through {@link construct_graph_renderer()}) * 2. apply deltas as necessary * 3. add technicals as necessary * 4. strip dates outside of the requested ?days parameter (e.g. from extra_days) * 5. construct heading and links * 6. construct subheading and revise last_updated * 7. return data * that is, deltas and technicals are done on the server-side; not the client-side. */ $renderer = construct_graph_renderer($graph['graph_type'], $graph['arg0'], $graph['arg0_resolved']); // 0. check graph rendering permissions if ($renderer->requiresUser()) { if (!isset($graph['user_id']) || !$graph['user_id']) { throw new GraphException("No user specified for authenticated graph"); } if (!isset($graph['user_hash']) || !$graph['user_hash']) { throw new GraphException("No user hash specified for authenticated graph"); } $user = get_user($graph['user_id']); if (!$user) { throw new GraphException("No such user found"); } if (!has_expected_user_graph_hash($graph['user_hash'], $user)) { throw new GraphException("Mismatched user hash for user " . $graph['user_id'] . " with graph type " . $graph['graph_type']); } if ($renderer->requiresAdmin()) { if (!$user['is_admin']) { throw new GraphException("Graph requires administrator privileges"); } } $renderer->setUser($user['id']); } if ($renderer->usesDays()) { // 0.5 limit 'days' parameter as necessary $get_permitted_days = get_permitted_days(); $has_valid_days = false; foreach ($get_permitted_days as $key => $days) { if ($days['days'] == $graph['days']) { $has_valid_days = true; } } if (!$has_valid_days) { throw new GraphException("Invalid days '" . $graph['days'] . "' for graph that requires days"); } } // 1. get raw graph data try { $data = $renderer->getData($graph['days']); $original_count = count($data['data']); $result['type'] = $renderer->getChartType(); // 2. apply deltas as necessary $data['data'] = calculate_graph_deltas($graph, $data['data'], false); // if there is no data, bail out early if (count($data['data']) == 0) { $result['type'] = 'nodata'; } else { if ($renderer->canHaveTechnicals()) { // 3. add technicals as necessary // (only if there is at least one point of data, otherwise calculate_technicals() will throw an error) $technicals = calculate_technicals($graph, $data['data'], $data['columns'], false); $data['columns'] = $technicals['headings']; $data['data'] = $technicals['data']; } } // 4. discard early data if ($renderer->usesDays()) { $data['data'] = discard_early_data($data['data'], $graph['days']); $after_discard_count = count($data['data']); } $result['columns'] = $data['columns']; $result['key'] = $data['key']; $result['data'] = $data['data']; // clean up columns foreach ($result['columns'] as $key => $value) { $result['columns'][$key]['technical'] = isset($result['columns'][$key]['technical']) && $result['columns'][$key]['technical'] ? true : false; if ($result['columns'][$key]['technical']) { if (!isset($result['columns'][$key]['type'])) { $result['columns'][$key]['type'] = 'number'; } } } } catch (NoDataGraphException_AddAccountsAddresses $e) { $result['type'] = 'nodata'; $result['text'] = ct("Either you have not specified any accounts or addresses, or these addresses and accounts have not yet been updated by :site_name."); $result['args'] = array(':site_name' => get_site_config('site_name')); $result['data'] = array(); $data['last_updated'] = false; $data['add_accounts_addresses'] = true; } catch (NoDataGraphException_AddCurrencies $e) { $result['type'] = 'nodata'; $result['text'] = ct("Either you have not enabled this currency, or your summaries for this currency have not yet been updated by :site_name."); $result['args'] = array(':site_name' => get_site_config('site_name')); $result['data'] = array(); $data['last_updated'] = false; $data['add_more_currencies'] = true; } // 5. construct heading and links $result['heading'] = array('label' => $renderer->getTitle(), 'args' => $renderer->getTitleArgs(), 'url' => $renderer->getURL(), 'title' => $renderer->getLabel()); if (isset($data['h1'])) { $result['h1'] = $data['h1']; } if (isset($data['h2'])) { $result['h2'] = $data['h2']; } if (isset($data['no_header'])) { $result['noHeader'] = $data['no_header']; } // 6. construct subheading and revise last_updated\ if ($result['type'] != 'nodata' && $renderer->hasSubheading()) { $suffix = ""; if ($graph['delta'] == 'percent') { $suffix .= '%'; } if ($renderer->getCustomSubheading() !== false) { $result['subheading'] = number_format_html($renderer->getCustomSubheading(), 4, $suffix); } else { if ($result['type'] == 'piechart') { // sum up the first row and use that as a total if (count($data['data']) != 1) { throw new GraphException("Expected one row of data for a piechart, got " . count($data['data'])); } $sum = 0; foreach ($data['data'] as $ignored => $row) { foreach ($row as $value) { $sum += $value; } } $result['subheading'] = number_format_html($sum, 4, $suffix); } else { $result['subheading'] = format_subheading_values_objects($graph, $data['data'], $data['columns']); } } } $result['lastUpdated'] = recent_format_html($data['last_updated']); $result['timestamp'] = iso_date(); $result['classes'] = $renderer->getClasses(); $result['graph_type'] = $graph['graph_type']; if (is_localhost()) { $result['_debug'] = $graph; if (isset($after_discard_count)) { $result['_debug']['data_discarded'] = $original_count - $after_discard_count; } else { $result['_debug']['data_not_discarded'] = true; } } // make sure that all 'number'-typed data is numeric foreach ($result['data'] as $i => $row) { foreach ($row as $key => $value) { $column = $result['columns'][$key]; if ($column['type'] == 'number' || $column['type'] == 'percent') { $result['data'][$i][$key] = (double) $value; if (is_localhost()) { $result['_debug']['number_formatted'] = true; } } } } // make sure that all data rows are numeric arrays and not objects // i.e. reindex everything to be numeric arrays, so they aren't output as JSON objects foreach ($result['data'] as $i => $row) { $new_row = array_values($row); foreach ($row as $key => $value) { $new_row[$key] = $value; } $result['data'][$i] = $new_row; } // format any extra text from the result if (isset($data['add_more_currencies'])) { $result['extra'] = array('classes' => 'add_accounts', 'href' => url_for('wizard_currencies'), 'label' => ct("Add more currencies"), 'args' => array()); } if (isset($data['add_accounts_addresses'])) { $result['extra'] = array('classes' => 'add_accounts', 'href' => url_for('wizard_accounts'), 'label' => ct("Add accounts and addresses"), 'args' => array()); } // 7. calculate if the graph data may be out of date if ($renderer->requiresUser() && $renderer->getUser()) { $user = get_user($renderer->getUser()); if ($user && $renderer->usesSummaries() && (!$user['has_added_account'] || !$user['is_first_report_sent'] || strtotime($user['last_account_change']) > strtotime($user['last_sum_job']))) { $result['outofdate'] = true; } } $end_time = microtime(true); $time_diff = ($end_time - $start_time) * 1000; $result['time'] = (double) number_format_autoprecision($time_diff, 1, '.', ''); $result['hash'] = $graph['hash']; // 7. return data return $result; }
/** * is_upload_flood * Returns true or false if the script spot flood upload */ function is_upload_flood() { if (is_localhost() || is_admin() || !conditional_config('flood_protection')) { return false; } global $dB; $flood = $dB->query_fetch_single("\n\t\tSELECT\n\t\t\tCOUNT(IF(image_date >= DATE_SUB(NOW(), INTERVAL 1 MINUTE), 1, NULL)) AS minute,\n\t\t\tCOUNT(IF(image_date >= DATE_SUB(NOW(), INTERVAL 1 HOUR), 1, NULL)) AS hour,\n\t\t\tCOUNT(IF(image_date >= DATE_SUB(NOW(), INTERVAL 1 DAY), 1, NULL)) AS day,\n\t\t\tCOUNT(IF(image_date >= DATE_SUB(NOW(), INTERVAL 1 WEEK), 1, NULL)) AS week,\n\t\t\tCOUNT(IF(image_date >= DATE_SUB(NOW(), INTERVAL 1 MONTH), 1, NULL)) AS month\n\t\tFROM chv_images WHERE uploader_ip=? AND image_date >= DATE_SUB(NOW(), INTERVAL 1 MONTH)", $_SERVER['REMOTE_ADDR']); if (chevereto_config('max_uploads_per_minute') > 0 && $flood['minute'] >= chevereto_config('max_uploads_per_minute') || chevereto_config('max_uploads_per_hour') > 0 && $flood['hour'] >= chevereto_config('max_uploads_per_hour') || chevereto_config('max_uploads_per_day') > 0 && $flood['day'] >= chevereto_config('max_uploads_per_day') || chevereto_config('max_uploads_per_week') > 0 && $flood['week'] >= chevereto_config('max_uploads_per_week') || chevereto_config('max_uploads_per_month') > 0 && $flood['month'] >= chevereto_config('max_uploads_per_month')) { $email_report = chevereto_config('flood_report_email'); if (check_value($email_report)) { $message_report .= 'User IP ' . $_SERVER['REMOTE_ADDR'] . "\n\n"; $message_report .= 'Uploads per time period' . "\n"; $message_report .= 'Minute: ' . $flood['minute'] . "\n"; $message_report .= 'Hour: ' . $flood['hour'] . "\n"; $message_report .= 'Week: ' . $flood['day'] . "\n"; $message_report .= 'Month: ' . $flood['week'] . "\n"; @mail($email_report, chevereto_config('site_name') . ' Flood report (' . $_SERVER['REMOTE_ADDR'] . ')', $message_report, "From: Chevereto Report <report@" . HTTP_HOST . ">"); } return true; } }
/** * returns hash of default permissions. * check if the page '.' exists and returns this instead. */ function defaultPerms() { //Todo: check for the existance of '.' and take this instead. //Todo: honor more config.ini auth settings here $perm = array('view' => array(ACL_EVERY => true), 'edit' => array(ACL_EVERY => true), 'create' => array(ACL_EVERY => true), 'list' => array(ACL_EVERY => true), 'remove' => array(ACL_ADMIN => true, ACL_OWNER => true), 'purge' => array(ACL_ADMIN => true, ACL_OWNER => true), 'dump' => array(ACL_ADMIN => true, ACL_OWNER => true), 'change' => array(ACL_ADMIN => true, ACL_OWNER => true)); if (ZIPDUMP_AUTH) { $perm['dump'] = array(ACL_ADMIN => true, ACL_OWNER => true); } elseif (INSECURE_ACTIONS_LOCALHOST_ONLY) { if (is_localhost()) { $perm['dump'] = array(ACL_EVERY => true); } else { $perm['dump'] = array(ACL_ADMIN => true); } } else { $perm['dump'] = array(ACL_EVERY => true); } if (defined('REQUIRE_SIGNIN_BEFORE_EDIT') && REQUIRE_SIGNIN_BEFORE_EDIT) { $perm['edit'] = array(ACL_SIGNED => true); } // view: if (!ALLOW_ANON_USER) { if (!ALLOW_USER_PASSWORDS) { $perm['view'] = array(ACL_SIGNED => true); } else { $perm['view'] = array(ACL_AUTHENTICATED => true); } $perm['view'][ACL_BOGOUSER] = ALLOW_BOGO_LOGIN ? true : false; } // edit: if (!ALLOW_ANON_EDIT) { if (!ALLOW_USER_PASSWORDS) { $perm['edit'] = array(ACL_SIGNED => true); } else { $perm['edit'] = array(ACL_AUTHENTICATED => true); } $perm['edit'][ACL_BOGOUSER] = ALLOW_BOGO_LOGIN ? true : false; $perm['create'] = $perm['edit']; } return $perm; }
<?php // custom extensions override defaults if (file_exists(__DIR__ . "/../config/config.php")) { require __DIR__ . "/../config/config.php"; } Openclerk\Config::merge(array("site_name" => "Openclerk", "site_email" => "*****@*****.**", "site_id" => "openclerk", "openid_host" => "localhost", "absolute_url" => "http://localhost/clerk/", "openclerk_version" => "0.35", "display_errors" => is_localhost(), "database_slave" => true, "database_host_master" => "localhost", "database_host_slave" => "localhost", "database_port" => 3306, "database_name" => "clerk", "database_username" => "clerk", "database_password" => "clerk", "database_timezone" => false, "phpmailer_host" => "mail.example.com", "phpmailer_username" => "sync", "phpmailer_password" => base64_decode("xxx"), "phpmailer_from" => "*****@*****.**", "phpmailer_from_name" => "*****@*****.**", "phpmailer_reply_to" => "*****@*****.**", "phpmailer_bcc" => "*****@*****.**", "admin_email" => "*****@*****.**", "password_salt" => "abc123", "password_reset_salt" => "abc456", "unsubscribe_salt" => "123abc", "user_graph_hash_salt" => "456789", "google_analytics_account" => "UA-12345678-1", "automated_key" => "abc123", "refresh_queue_hours" => 2, "refresh_queue_hours_premium" => 1, "refresh_queue_hours_system" => 0.1, "refresh_queue_hours_ticker" => 0.1, "system_user_id" => 100, "get_contents_timeout" => 5, "get_openid_timeout" => 5, "default_login" => 'user', "signup_login" => 'wizard_currencies', "autologin_expire_days" => 30, "autologin_cookie_seconds" => 60 * 60 * 24 * 30, "external_sample_size" => 10000, "default_cache_seconds" => 60 * 60 * 24 * 7, "vote_coins_multiplier" => 10, "metrics_enabled" => true, "metrics_db_enabled" => true, "metrics_page_enabled" => true, "metrics_curl_enabled" => true, "metrics_store" => true, "show_i18n" => false, "log_missing_i18n" => false, "allow_fake_login" => false, "performance_metrics_enabled" => false, "performance_metrics_slow_query" => 250, "performance_metrics_repeated_query" => 5, "performance_metrics_slow_curl" => 2000, "performance_metrics_repeated_curl" => 2, "jobs_enabled" => !file_exists(__DIR__ . "/../deploy.lock"), "maximum_jobs_running" => 20, "max_job_executions" => 5, "throttle_btcguild" => 30, "throttle_blockchain" => 5, "external_sample_size" => 10000, "default_job_priority" => 10, "premium_job_priority" => 5, "job_test_priority" => 5, "heavy_requests_seconds" => 10, "default_graph_width" => 110, "default_graph_height" => 110, "default_user_graph_width" => 4, "default_user_graph_height" => 2, "default_user_graph_days" => 45, "graph_refresh_public" => 30, "graph_refresh_free" => 30, "graph_refresh_premium" => 1, "technical_period_max" => 365, "ftc_address_url" => "http://explorer.feathercoin.com/address/%s", "ftc_block_url" => "http://explorer.feathercoin.com/chain/Feathercoin/q/getblockcount", "ppc_address_url" => "http://ppc.blockr.io/api/v1/address/info/%s", "ppc_block_url" => "http://ppc.blockr.io/api/v1/block/info/last", "nvc_address_url" => "https://explorer.novaco.in/address/%s", "nvc_block_url_html" => "https://explorer.novaco.in/", "xpm_address_url" => "https://coinplorer.com/XPM/Addresses/%s", "xpm_block_url_html" => "http://xpm.cryptocoinexplorer.com/block/-1", "trc_address_url" => "http://trc.cryptocoinexplorer.com/address/%s", "trc_block_url_html" => "http://trc.cryptocoinexplorer.com/block/-1", "dog_address_url" => "http://dogechain.info//address/%s", "dog_block_url" => "http://dogechain.info//chain/Dogecoin/q/getblockcount", "mec_address_url" => "http://mega.rapta.net:2750/address/%s", "mec_block_url" => "http://mega.rapta.net:2750/chain/Megacoin/q/getblockcount", "xrp_address_url" => "https://ripple.com/graph/#%s", "nmc_address_url" => "http://namecha.in/address/%s", "nmc_block_url_html" => "http://namecha.in/", "dgc_address_url" => "http://dgc.blockr.io/api/v1/address/info/%s", "dgc_block_url" => "http://dgc.blockr.io/api/v1/block/info/last", "wdc_address_url" => "http://www.worldcoinexplorer.com/api/address/%s", "wdc_block_url" => "http://www.worldcoinexplorer.com/api/coindetails", "ixc_address_url" => "http://block.al.tcoin.info/address/%s", "ixc_block_url" => "http://block.al.tcoin.info/chain/Ixcoin/q/getblockcount", "vtc_address_url" => "https://explorer.vertcoin.org/address/%s", "vtc_block_url" => "https://explorer.vertcoin.org/chain/Vertcoin/q/getblockcount", "net_address_url" => "http://explorer.netcoinfoundation.org/address/%s", "net_block_url" => "http://explorer.netcoinfoundation.org/chain/Netcoin/q/getblockcount", "hbn_address_url" => "http://162.217.249.198:1080/address/%s", "hbn_block_url" => "http://162.217.249.198:1080/chain/Hobonickels/q/getblockcount", "drk_address_url" => "http://explorer.darkcoin.io/address/%s", "drk_block_url" => "http://explorer.darkcoin.io/chain/Darkcoin/q/getblockcount", "vrc_address_url" => "https://chainz.cryptoid.info/vrc/address.dws?%s", "vrc_balance_url" => "http://chainz.cryptoid.info/vrc/api.dws?q=getbalance&a=%s", "vrc_received_url" => "http://chainz.cryptoid.info/vrc/api.dws?q=getreceivedbyaddress&a=%s", "vrc_block_url" => "http://chainz.cryptoid.info/vrc/api.dws?q=getblockcount", "nxt_address_url" => "http://nxtexplorer.com/nxt/nxt.cgi?action=3000&acc=%s", "rdd_address_url" => "http://live.reddcoin.com/address/%s", "rdd_block_url" => "http://live.reddcoin.com/api/status?q=getInfo", "via_address_url" => "http://explorer.viacoin.org/address/%s", "via_block_url" => "http://explorer.viacoin.org/api/status?q=getInfo", "nbt_address_url" => "https://blockexplorer.nu/address/%s/1/newest", "nsr_address_url" => "https://blockexplorer.nu/address/%s/1/newest", "ftc_confirmations" => 6, "ppc_confirmations" => 6, "nvc_confirmations" => 6, "trc_confirmations" => 6, "dog_confirmations" => 6, "mec_confirmations" => 6, "nmc_confirmations" => 6, "dgc_confirmations" => 6, "ixc_confirmations" => 6, "vtc_confirmations" => 6, "net_confirmations" => 6, "hbn_confirmations" => 6, "drk_confirmations" => 6, "blockchain_api_key" => false, "anxpro_example_api_key" => '...', "anxpro_example_api_secret" => '...', "exchange_cryptsy_key" => "...", "exchange_cryptsy_secret" => "...", "premium_currencies" => array('btc', 'ltc'), "premium_btc_monthly" => 0.02, "premium_btc_yearly" => 0.2, "premium_ltc_monthly" => 1, "premium_ltc_yearly" => 10, "premium_reminder_days" => 7, "outstanding_reminder_hours" => 24, "outstanding_abandon_days" => 7, "premium_user_votes" => 10, "btc_confirmations" => 6, "ltc_confirmations" => 6, "dog_confirmations" => 6, "premium_btc_discount" => 0, "premium_ltc_discount" => 0, "premium_welcome" => false, "new_user_premium_update_hours" => 24, "user_expiry_days" => 30, "taxable_countries" => array(), "archive_ticker_data" => "-31 days", "archive_summary_data" => "-31 days", "archive_balances_data" => "-31 days", "default_css" => "styles/default.css", "custom_css" => false, "forum_link" => "http://bitcointalk.org/", "blog_link" => "http://blog.cryptfolio.com/", "google_groups_announce" => "openclerk-announce", "version_history_link" => "https://groups.google.com/forum/#!forum/cryptfolio-announce")); // absolute URLs as necessary Openclerk\Config::merge(array('coinbase_redirect_uri' => absolute_url(url_for('coinbase')))); $global_get_site_config = null; /** * @deprecated use {@link config()} instead */ function get_site_config($key = null, $fail_if_missing = true) { return \Openclerk\Config::get($key, $fail_if_missing === false ? false : null); } function config($key, $default = null) { return \Openclerk\Config::get($key, $default); } $global_get_premium_config = null; /** * This function provides the premium account configuration for an Openclerk instance, * based on {@link #get_default_premium_config()} and {@link #get_premium_config_ext()} * It can be extended by defining a function 'get_premium_config_ext()' * and providing a new map of keys to values. * * Config values here will never change between calls so can be cached. * TODO this should be moved into `\Openclerk\Config::get("premium_$key")` */
function requiredAuthorityForAction($action) { global $DisabledActions; if ($DisabledActions and in_array($action, $DisabledActions)) { return WIKIAUTH_UNOBTAINABLE; } if (ENABLE_PAGEPERM and class_exists("PagePermission")) { return requiredAuthorityForPage($action); } else { // FIXME: clean up. switch ($action) { case 'browse': case 'viewsource': case 'diff': case 'select': case 'search': case 'pdf': case 'captcha': case 'wikitohtml': case 'setpref': return WIKIAUTH_ANON; case 'xmlrpc': case 'soap': case 'dumphtml': if (INSECURE_ACTIONS_LOCALHOST_ONLY and !is_localhost()) { return WIKIAUTH_ADMIN; } return WIKIAUTH_ANON; case 'ziphtml': if (ZIPDUMP_AUTH) { return WIKIAUTH_ADMIN; } if (INSECURE_ACTIONS_LOCALHOST_ONLY and !is_localhost()) { return WIKIAUTH_ADMIN; } return WIKIAUTH_ANON; case 'dumpserial': if (INSECURE_ACTIONS_LOCALHOST_ONLY and is_localhost()) { return WIKIAUTH_ANON; } return WIKIAUTH_ADMIN; case 'zip': if (ZIPDUMP_AUTH) { return WIKIAUTH_ADMIN; } return WIKIAUTH_ANON; case 'edit': case 'revert': case 'rename': if (defined('REQUIRE_SIGNIN_BEFORE_EDIT') && REQUIRE_SIGNIN_BEFORE_EDIT) { return WIKIAUTH_BOGO; } return WIKIAUTH_ANON; // return WIKIAUTH_BOGO; // return WIKIAUTH_BOGO; case 'create': $page = $this->getPage(); $current = $page->getCurrentRevision(); if ($current->hasDefaultContents()) { return $this->requiredAuthorityForAction('edit'); } return $this->requiredAuthorityForAction('browse'); case 'upload': case 'loadfile': case 'purge': case 'remove': case 'lock': case 'unlock': case 'upgrade': case 'chown': case 'setacl': case 'setaclsimple': return WIKIAUTH_ADMIN; /* authcheck occurs only in the plugin. required actionpage RateIt */ /* case 'rate': case 'delete_rating': // Perhaps this should be WIKIAUTH_USER return WIKIAUTH_BOGO; */ /* authcheck occurs only in the plugin. required actionpage RateIt */ /* case 'rate': case 'delete_rating': // Perhaps this should be WIKIAUTH_USER return WIKIAUTH_BOGO; */ default: global $WikiNameRegexp; if (preg_match("/{$WikiNameRegexp}\\Z/A", $action)) { return WIKIAUTH_ANON; } else { return WIKIAUTH_ADMIN; } } } }
<?php use Theme\Variables; /** * Variables Object */ $variables = new Variables(); # Debug helpers $variables->add('dev', array('localhost' => is_localhost())); # Theme $variables->add('theme', array('supports' => array_key_exists('supports', $theme) ? $theme['supports'] : array())); # Global Site Variables $variables->add('site', array('name' => SITE_NAME, 'email' => SITE_EMAIL, 'domain' => SITE_DOMAIN, 'styles' => load_asset($theme_config['styles'], 'css'), 'scripts' => load_asset($theme_config['scripts'], 'js'), 'assets' => assets_dir(), 'ie' => array('min' => 9, 'strict' => false))); # Page variables $variables->add('page', array('is_home' => is_home(), 'path' => $path, 'slug' => get_page()), true); # User variables $variables->add('user', array('logged_in' => is_loggedin())); # Various useful variables $variables->add('this_year', this_year()); /** ----------------------------------- ** * Default page meta is set here but * * should be overridden in your * * model files. Access the array using * * $_['page']['meta'] from your model. * ** ----------------------------------- **/ # Page meta data $meta = array($variables->get('page|slug') => array('title' => SITE_NAME, 'description' => 'Description', 'keywords' => 'Keywords', 'canonical' => 'Canonical')); $variables->extend('page', 'meta', $meta[$variables->get('page|slug')]);
if (count($files) != 1) { return null; } return file_get_contents($files[0]->getPathname()); } /** * @param string $id * @return bool Whether the page described by $id exists or not. */ function is_page($id) { return 1 == (new Finder())->files()->in(GP_PAGES_PATH)->name($id)->count(); } // Engine : Silex App ////////////////////////////////////////////////////////// $app = new Application(); $app['debug'] = is_localhost() || false; // Templating : Twig /////////////////////////////////////////////////////////// $twig_loader = new Twig_Loader_Filesystem(array(GP_ROOT_PATH . 'view')); $twig = new Twig_Environment($twig_loader, array('cache' => GP_ROOT_PATH . 'cache')); // Route : Aliases ///////////////////////////////////////////////////////////// $app->get('/', function (Application $app) { return $app->redirect('page/1'); }); // Route : Show a Page in the Story //////////////////////////////////////////// $app->get('/page/{id}', function (Application $app, $id) use($twig) { // Grab the source file contents $source = get_page($id); if (null == $source) { $app->abort(404, "Page {$id} does not exist."); } // Handle page inclusions `{% include page xxx %}`
echo get_template_directory_uri(); ?> /js/jquery.sticky-kit.min.js"></script> <script src="<?php echo get_template_directory_uri(); ?> /js/jquery.tooltipster.min.js"></script> <script src="<?php echo get_template_directory_uri(); ?> /js/main.js"></script> <?php if (!is_localhost()) { ?> <script> (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-65880784-1', 'auto'); ga('send', 'pageview'); </script> <?php } ?> <script>
<?php use Theme\Variables; /** * Variables Object */ $variables = new Variables($_config); # Include Variable Functions require __DIR__ . '/functions/variables.php'; # Debug helpers add_var('dev', array('localhost' => is_localhost())); # Page variables add_var('page', array('is_home' => is_home(), 'path' => $path, 'slug' => get_page()), true); # User variables add_var('user', array('is_loggedin' => is_loggedin())); # Various useful variables add_var('this_year', this_year());
function grazr_icon($args = array()) { global $request, $WikiTheme; if (is_localhost()) { return ''; } if (SERVER_PROTOCOL == "https") { return ''; } $our_url = WikiURL($request->getArg('pagename'), array_merge(array('action' => $this->action, 'format' => 'rss2'), $args), true); $rss_url = 'http://grazr.com/gzpanel.html?' . $our_url; return $WikiTheme->makeButton("grazr", $rss_url, 'rssicon'); }
PageRenderer::addTemplatesLocation(__DIR__ . "/../templates"); PageRenderer::addTemplatesLocation(__DIR__ . "/../config/templates"); /** * Include compiled header code, this was a hack to work around * Grunt/build/deploy issues. TODO clean this up and remove this workaround */ function include_head_compiled() { echo "<!-- compiled head -->"; $head_compiled = __DIR__ . "/head-compiled.html"; if (file_exists($head_compiled)) { require $head_compiled; } else { // fix relative paths $input = file_get_contents(__DIR__ . "/../layout/head.html"); $input = str_replace("src=\"", "src=\"" . htmlspecialchars(calculate_relative_path()), $input); echo $input; } echo "<!-- /compiled head -->"; } try { \Openclerk\Router::process($path); } catch (\Openclerk\RouterException $e) { header("HTTP/1.0 404 Not Found"); $errors = array(); $errors[] = htmlspecialchars($e->getMessage()); if (is_localhost()) { $errors[] = htmlspecialchars($e->getPrevious()->getMessage()); } require __DIR__ . "/404.php"; }
http://opensource.org/licenses/MIT --------------------------------------------------------------------- */ define('access', 'API'); require_once 'includes/chevereto.php'; /*** Die, die, die my darling ***/ if (chevereto_config('api_key') == 'my_api_key' and chevereto_config('api_mode') == 'private' and !is_localhost()) { chevereto_die(array('Open <code>includes/config.php</code>', 'Edit <code>$config[\'api_key\'] = \'my_api_key\';</code> with a different key.'), 'API key', array('You haven\'t changed the default api key, the API won\'t work until you fix this.')); } $key = $_REQUEST['key']; $to_upload = $_REQUEST['upload']; $to_resize = $_REQUEST['resize_width']; $format = $_REQUEST['format']; $callback = $_REQUEST['callback']; /*** Checks the auth ***/ if (api_mode('private') and api_key() !== $key and !is_localhost()) { $error_key_msg = 'Invalid API key'; $ERROR_AUTH_API = array('status_code' => 403, 'status_txt' => $error_key_msg); switch ($format) { default: case 'json': default: json_output($ERROR_AUTH_API, $callback); break; case 'xml': xml_output($ERROR_AUTH_API); break; case 'txt': echo $error_key_msg; break; }
<?php require __DIR__ . "/../vendor/autoload.php"; require __DIR__ . "/functions.php"; // set up config Openclerk\Config::merge(array("site_name" => "genealogy", "absolute_url" => is_localhost() ? "http://localhost/genealogy/" : "http://example.com/", "display_errors" => is_localhost())); // set up routes \Openclerk\Router::addRoutes(array(":page" => "pages/:page.php")); // set up pages \Pages\PageRenderer::addTemplatesLocation(__DIR__ . "/../site/templates"); \Pages\PageRenderer::addStylesheet(\Openclerk\Router::urlFor("css/default.css")); \Pages\PageRenderer::addJavascript("https://code.jquery.com/jquery-2.1.1.min.js"); \Pages\PageRenderer::addJavascript(\Openclerk\Router::urlFor("js/default.js")); require __DIR__ . "/tree.php";