Пример #1
0
/**
 * Set the necessary cookies for the user to be logged into the forum.
 *
 * Frontend cookie names:
 * - lastvisit, lastactivity, sessionhash
 * Backend cookie names:
 * - cpsession, userid, password
 *
 * However, in all cases the cookiedomain is NOT prefixed with a dot unless
 * cookie domain has not been manually altered to either a suggested value or
 * custom value in vB's settings.
 */
function drupalvb_set_login_cookies($userid)
{
    // Load required vB user data.
    $vbuser = db_fetch_array(drupalvb_db_query("SELECT userid, password, salt FROM {user} WHERE userid = %d", $userid));
    if (!$vbuser) {
        return FALSE;
    }
    $vb_config = drupalvb_get('config');
    $vb_options = drupalvb_get('options');
    $cookie_prefix = isset($vb_config['Misc']['cookieprefix']) ? $vb_config['Misc']['cookieprefix'] : 'bb';
    $cookie_path = $vb_options['cookiepath'];
    $cookie_domain = !empty($vb_options['cookiedomain']) ? $vb_options['cookiedomain'] : $GLOBALS['cookie_domain'];
    $now = time();
    $expire = $now + (@ini_get('session.cookie_lifetime') ? ini_get('session.cookie_lifetime') : 60 * 60 * 24 * 365);
    // Clear out old session (if available).
    if (!empty($_COOKIE[$cookie_prefix . 'sessionhash'])) {
        drupalvb_db_query("DELETE FROM {session} WHERE sessionhash = '%s'", $_COOKIE[$cookie_prefix . 'sessionhash']);
    }
    // Setup user session.
    $ip = implode('.', array_slice(explode('.', drupalvb_get_ip()), 0, 4 - $vb_options['ipcheck']));
    $idhash = md5($_SERVER['HTTP_USER_AGENT'] . $ip);
    $sessionhash = md5($now . request_uri() . $idhash . $_SERVER['REMOTE_ADDR'] . user_password(6));
    drupalvb_db_query("REPLACE INTO {session} (sessionhash, userid, host, idhash, lastactivity, location, useragent, loggedin) VALUES ('%s', %d, '%s', '%s', %d, '%s', '%s', %d)", $sessionhash, $vbuser['userid'], substr($_SERVER['REMOTE_ADDR'], 0, 15), $idhash, $now, '/forum/', $_SERVER['HTTP_USER_AGENT'], 2);
    // Setup cookies.
    setcookie($cookie_prefix . 'sessionhash', $sessionhash, $expire, $cookie_path, $cookie_domain);
    setcookie($cookie_prefix . 'lastvisit', $now, $expire, $cookie_path, $cookie_domain);
    setcookie($cookie_prefix . 'lastactivity', $now, $expire, $cookie_path, $cookie_domain);
    setcookie($cookie_prefix . 'userid', $vbuser['userid'], $expire, $cookie_path, $cookie_domain);
    setcookie($cookie_prefix . 'password', md5($vbuser['password'] . variable_get('drupalvb_license', '')), $expire, $cookie_path, $cookie_domain);
    return TRUE;
}
Пример #2
0
function mvp_preprocess_html(&$vars)
{
    drupal_add_js(drupal_get_path('theme', 'mvp') . '/js/modernizr.min.js', array('scope' => 'header_scripts', 'every_page' => TRUE, 'weight' => 0));
    drupal_add_js(drupal_get_path('theme', 'mvp') . '/js/jquery-1.8.2.min.js', array('scope' => 'header', 'group' => JS_LIBRARY, 'every_page' => TRUE, 'weight' => 0));
    drupal_add_js(drupal_get_path('theme', 'mvp') . '/js/jquery-ui-1.10.4.min.js', array('scope' => 'header', 'group' => JS_LIBRARY, 'every_page' => TRUE, 'weight' => 3));
    if (request_uri() == '/content-dashboard') {
        drupal_add_js('(function($) {
      Drupal.behaviors.chosenSelects = {
        attach: function(context, settings) {
          $(".views-widget-filter-edit-type select#edit-type").chosen({
            width: "200px",
            placeholder_text_multiple: "Enter in a Content Type"
          });
          $(".views-widget-filter-edit-status-1 select").chosen({
            width: "200px",
            disable_search_threshold: 3
          });
        }
      };
    })(jQuery);', array('type' => 'inline', 'group' => JS_THEME, 'weight' => 2, 'defer' => TRUE));
    }
    $node = menu_get_object();
    if ($node && $node->nid) {
        $vars['theme_hook_suggestions'][] = 'html__' . $node->type;
    }
}
Пример #3
0
/**
 * Implements hook_preprocess_page().
 */
function eu_projects_theme_preprocess_page(&$vars, $hook)
{
    $path_alias = drupal_get_path_alias();
    // Webtools.
    $inline_script = '<script defer src="//europa.eu/webtools/load.js" type="text/javascript"></script>';
    $element = array('#type' => 'markup', '#markup' => $inline_script);
    drupal_add_html_head($element, 'webtools');
    // Apple-touch-icon-precomposed.
    $apple_touch_icon_precomposed = array('#tag' => 'link', '#attributes' => array('href' => file_create_url(path_to_theme() . '/images/apple-touch-icon.png'), 'rel' => 'apple-touch-icon-precomposed'));
    drupal_add_html_head($apple_touch_icon_precomposed, 'apple-touch-icon-precomposed');
    // Apple-touch-icon.
    $apple_touch_icon = array('#tag' => 'link', '#attributes' => array('href' => file_create_url(path_to_theme() . '/images/apple-touch-icon.png'), 'rel' => 'icon'));
    drupal_add_html_head($apple_touch_icon, 'apple-touch-icon');
    // Apple-mobile-web-app-capable.
    $apple_mobile_web_app_capable = array('#tag' => 'meta', '#attributes' => array('name' => 'apple-mobile-web-app-capable', 'content' => 'yes'));
    drupal_add_html_head($apple_mobile_web_app_capable, 'apple-mobile-web-app-capable');
    // Application-name.
    $application_name = array('#tag' => 'meta', '#attributes' => array('name' => 'application-name', 'content' => t('EU Results')));
    drupal_add_html_head($application_name, 'application-name');
    // Apple-mobile-web-app-title.
    $apple_mobile_web_app_title = array('#tag' => 'meta', '#attributes' => array('name' => 'apple-mobile-web-app-title', 'content' => t('EU Results')));
    drupal_add_html_head($apple_mobile_web_app_title, 'apple-mobile-web-app-title');
    // Apple-touch-startup-image-ec.
    $apple_touch_startup_image_ec = array('#tag' => 'meta', '#attributes' => array('rel' => 'apple-touch-startup-image-ec', 'href' => file_create_url(path_to_theme() . '/images/startup-image.png')));
    drupal_add_html_head($apple_touch_startup_image_ec, 'apple-touch-startup-image-ec');
    // Preload geojson for map
    if ($path_alias == 'search-projects') {
        $path = explode('?', request_uri());
        $var = isset($path[1]) ? '?' . $path[1] : '';
        $preload_geojson = array('#tag' => 'link', '#attributes' => array('rel' => 'prefetch', 'href' => $GLOBALS['base_url'] . '/projects-geojson_' . $GLOBALS['language']->language . $var));
        drupal_add_html_head($preload_geojson, 'preload_geojson');
    }
}
Пример #4
0
/**
 * Parse any get params that might be hidden in the URL
 */
function parse_params()
{
    // --[ mod_rewrite code ]--
    if (!isset($_GET[ROSTER_PAGE])) {
        $uri = request_uri();
        $page = substr($uri, strlen(ROSTER_PATH));
        list($page) = explode('.', $page);
        // Build the Roster page var
        $pages = array();
        foreach (explode('/', $page) as $get) {
            if (strpos($get, '=') === false) {
                $pages[] = $get;
            } else {
                parse_str($get, $get);
                if (!get_magic_quotes_gpc()) {
                    $get = escape_array($get);
                }
                $_GET = array_overlay($get, $_GET);
            }
        }
        // Needed in case someone specified www.example.com/roster/index.php.
        // That format is the only one that works in IIS
        if ($pages == array('index')) {
            $pages = array();
        }
        $_GET[ROSTER_PAGE] = implode('-', $pages);
    }
}
function brukar_client_oauth_callback()
{
    require_once drupal_get_path('module', 'brukar_common') . '/OAuth.php';
    $method = new OAuthSignatureMethod_HMAC_SHA1();
    $consumer = new OAuthConsumer(variable_get('brukar_consumer_key'), variable_get('brukar_consumer_secret'));
    if (isset($_SESSION['auth_oauth']) && $_SESSION['auth_oauth']['oauth_token'] == $_GET['oauth_token']) {
        unset($_GET['oauth_token']);
        $tmp = new OAuthToken($_SESSION['auth_oauth']['oauth_token'], $_SESSION['auth_oauth']['oauth_token_secret']);
        $req = OAuthRequest::from_consumer_and_token($consumer, $tmp, 'GET', variable_get('brukar_url') . 'server/oauth/access_token', array());
        $req->sign_request($method, $consumer, $tmp);
        parse_str(trim(file_get_contents($req->to_url())), $token);
        unset($_SESSION['auth_oauth']);
        if (count($token) > 0) {
            $_SESSION['_brukar_access_token'] = array('token' => $token['oauth_token'], 'token_secret' => $token['oauth_token_secret']);
            $token = new OAuthToken($token['oauth_token'], $token['oauth_token_secret']);
            $req = OAuthRequest::from_consumer_and_token($consumer, $token, 'GET', variable_get('brukar_url') . 'server/oauth/user', array());
            $req->sign_request($method, $consumer, $token);
            brukar_client_login((array) json_decode(trim(file_get_contents($req->to_url()))));
        }
    }
    $debug_data = array('cookie' => $_COOKIE, 'request_uri' => request_uri(), 'auth_oauth' => isset($_SESSION['auth_oauth']) ? $_SESSION['auth_oauth'] : 'no auth_oauth');
    watchdog('brukar_client', 'User login failed.<br/>Debug data:<br/><pre>!debug_data</pre><br/>', array('!debug_data' => print_r($debug_data, TRUE)), WATCHDOG_ERROR);
    drupal_set_message(t('Noe gikk feil under innlogging.'), 'warning');
    drupal_goto('<front>');
}
Пример #6
0
 /**
  * 构造函数 
  */
 public function __construct()
 {
     parent::__construct();
     //读取语言包
     Language::read('home_cart_index');
     //允许不登录就可以访问的op
     $op_arr = array('ajaxcart', 'add', 'drop');
     $op_str = '';
     $op_str = isset($_GET['op']) ? $_GET['op'] : $_POST['op'];
     if (!in_array($op_str, $op_arr) && !$_SESSION['member_id']) {
         $current_url = request_uri();
         redirect('index.php?act=login&ref_url=' . urlencode($current_url));
     }
     //验证该会员是否禁止购买
     $noallowbuyop_arr = array('step1', 'step2');
     $noallowbuyop_str = '';
     $noallowbuyop_str = isset($_GET['op']) ? $_GET['op'] : $_POST['op'];
     if (in_array($noallowbuyop_str, $noallowbuyop_arr)) {
         $member_model = Model('member');
         $member_id = intval($_SESSION['member_id']);
         $member_info = $member_model->infoMember(array('member_id' => "{$member_id}"));
         if (empty($member_info) || !$member_info['is_buy']) {
             showMessage(Language::get('cart_buy_noallow'), '', 'html', 'error');
         }
         unset($member_id);
         unset($member_info);
         unset($member_model);
     }
 }
Пример #7
0
 /** 
  * 页面及错误(Exception)
  * 
  * @param Exception $ex 
  * @param mixed $message
  *
  */
 public static function request_error(Exception $ex = null, $message = null)
 {
     $code = 'error';
     if (!is_null($ex)) {
         $message = $ex->getMessage();
         if (false !== stripos($message, 'Unable to find a route to match the URI') || false !== stripos($message, 'not found on this server')) {
             $code = 404;
         }
         // Log the error
         //    if( $GLOBALS['__mogujie']['log_errors'] ){
         //      Kohana::$log->add(Kohana_Log::ERROR, var_export($ex,true) );
         //  }
     }
     if (empty($message)) {
         $message = 'unkown error';
     }
     View::bind_global('message', $message);
     View::bind_global('exception', $ex);
     $msg = $message . '-' . $ex;
     View::bind_global('msg', $msg);
     $uri = request_uri();
     crond_log("uri:{$uri}; code:{$code}; msg:{$msg}; referer:{$_SERVER['HTTP_REFERER']}", 'request_error.log');
     switch ($code) {
         case 404:
             //header("Status: 404 Not Found"); //header("HTTP/1.0 404 Not Found");
             echo Request::factory("error/404")->execute();
             break;
         default:
             echo Request::factory("error/index")->execute();
             break;
     }
     exit;
 }
Пример #8
0
 protected function check_login()
 {
     if (!isset($_SESSION['is_login'])) {
         $ref_url = MICROSHOP_SITE_URL . request_uri();
         header('location: ' . SHOP_SITE_URL . '/index.php?act=login&ref_url=' . getRefUrl());
         die;
     }
 }
Пример #9
0
 protected function check_login()
 {
     if (!isset($_SESSION['is_login'])) {
         $ref_url = MICROSHOP_SITEURL . request_uri();
         header("location: " . SiteUrl . "/index.php?act=login&ref_url=" . getrefurl());
         exit;
     }
 }
Пример #10
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     // Log execution time.
     $start_time = microtime(TRUE);
     // Try to load the files count from cache. This function will accept two
     // arguments:
     // - cache object name (cid)
     // - cache bin, the (optional) cache bin (most often a database table) where
     //   the object is to be saved.
     //
     // cache_get() returns the cached object or FALSE if object does not exist.
     if ($cache = \Drupal::cache()->get('cache_example_files_count')) {
         /*
          * Get cached data. Complex data types will be unserialized automatically.
          */
         $files_count = $cache->data;
     } else {
         // If there was no cached data available we have to search filesystem.
         // Recursively get all files from Drupal's folder.
         $files_count = count(file_scan_directory('.', '/.*/'));
         // Since we have recalculated, we now need to store the new data into
         // cache. Complex data types will be automatically serialized before
         // being saved into cache.
         // Here we use the default setting and create an unexpiring cache item.
         // See below for an example that creates an expiring cache item.
         \Drupal::cache()->set('cache_example_files_count', $files_count, CacheBackendInterface::CACHE_PERMANENT);
     }
     $end_time = microtime(TRUE);
     $duration = $end_time - $start_time;
     // Format intro message.
     $intro_message = '<p>' . t('This example will search the entire drupal folder and display a count of the files in it.') . ' ';
     $intro_message .= t('This can take a while, since there are a lot of files to be searched.') . ' ';
     $intro_message .= t('We will search filesystem just once and save output to the cache. We will use cached data for later requests.') . '</p>';
     $intro_message .= '<p>' . t('<a href="@url">Reload this page</a> to see cache in action.', array('@url' => request_uri())) . ' ';
     $intro_message .= t('You can use the button below to remove cached data.') . '</p>';
     $form['file_search'] = array('#type' => 'fieldset', '#title' => t('File search caching'));
     $form['file_search']['introduction'] = array('#markup' => $intro_message);
     $color = empty($cache) ? 'red' : 'green';
     $retrieval = empty($cache) ? t('calculated by traversing the filesystem') : t('retrieved from cache');
     $form['file_search']['statistics'] = array('#type' => 'item', '#markup' => t('%count files exist in this Drupal installation; @retrieval in @time ms. <br/>(Source: <span style="color:@color;">@source</span>)', array('%count' => $files_count, '@retrieval' => $retrieval, '@time' => number_format($duration * 1000, 2), '@color' => $color, '@source' => empty($cache) ? t('actual file search') : t('cached'))));
     $form['file_search']['remove_file_count'] = array('#type' => 'submit', '#submit' => array(array($this, 'expireFiles')), '#value' => t('Explicitly remove cached file count'));
     $form['expiration_demo'] = array('#type' => 'fieldset', '#title' => t('Cache expiration settings'));
     $form['expiration_demo']['explanation'] = array('#markup' => t('A cache item can be set as CACHE_PERMANENT, meaning that it will only be removed when explicitly cleared, or it can have an expiration time (a Unix timestamp).'));
     $item = \Drupal::cache()->get('cache_example_expiring_item', TRUE);
     if ($item == FALSE) {
         $item_status = t('Cache item does not exist');
     } else {
         $item_status = $item->valid ? t('Cache item exists and is set to expire at %time', array('%time' => $item->data)) : t('Cache_item is invalid');
     }
     $form['expiration_demo']['current_status'] = array('#type' => 'item', '#title' => t('Current status of cache item "cache_example_expiring_item"'), '#markup' => $item_status);
     $form['expiration_demo']['expiration'] = array('#type' => 'select', '#title' => t('Time before cache expiration'), '#options' => array('never_remove' => t('CACHE_PERMANENT'), -10 => t('Immediate expiration'), 10 => t('10 seconds from form submission'), 60 => t('1 minute from form submission'), 300 => t('5 minutes from form submission')), '#default_value' => -10, '#description' => t('Any cache item can be set to only expire when explicitly cleared, or to expire at a given time.'));
     $form['expiration_demo']['create_cache_item'] = array('#type' => 'submit', '#value' => t('Create a cache item with this expiration'), '#submit' => array(array($this, 'createExpiringItem')));
     $form['cache_clearing'] = array('#type' => 'fieldset', '#title' => t('Expire and remove options'), '#description' => t("We have APIs to expire cached items and also to just remove them. Unfortunately, they're all the same API, cache_clear_all"));
     $form['cache_clearing']['cache_clear_type'] = array('#type' => 'radios', '#title' => t('Type of cache clearing to do'), '#options' => array('expire' => t('Remove items from the "cache" bin that have expired'), 'remove_all' => t('Remove all items from the "cache" bin regardless of expiration'), 'remove_tag' => t('Remove all items in the "cache" bin with the tag "cache_example" set to 1')), '#default_value' => 'expire');
     // Submit button to clear cached data.
     $form['cache_clearing']['clear_expired'] = array('#type' => 'submit', '#value' => t('Clear or expire cache'), '#submit' => array(array($this, 'cacheClearing')), '#access' => \Drupal::currentUser()->hasPermission('administer site configuration'));
     return $form;
 }
function xssAttackDetected()
{
    @ob_end_clean();
    while (@ob_end_clean()) {
    }
    @file_put_contents('sites/default/files/debugXSS.log', "========== XSS ATTACK BLOCKED ==========" . "\nURL: " . request_uri() . "\nPOST: " . print_r($_POST, true) . "\n", FILE_APPEND);
    header("HTTP/1.0 403 Forbidden - XSS Detected");
    exit('Exiting - Cross-site-scripting or injection attempt detected.');
}
Пример #12
0
/**
 * @file
 * template.php
 */
function bootstrapactency_preprocess_page(&$vars)
{
    /**
     * Special Front page ()
     */
    if (request_uri() === "/") {
        //$vars['theme_hook_suggestions'][] = "page__frontpage";
    }
}
Пример #13
0
function _get_sections()
{
    $site = array_slice(split('/', request_uri()), 1);
    if ($site[2] == 'admin') {
        return array($site[1]);
    } else {
        return array_filter($site, create_function('$a', 'return !empty($a);'));
    }
}
 function dispatchEmail($to, $sendermail, $subject, $message, $files = array())
 {
     // Debugging verbosity
     if (strpos($_SERVER['REQUEST_URI'], '-DEBUG-DISPATCHEMAIL-STARTFIN-WATCH-') !== false) {
         dsm("dispatchEmail triggered");
     }
     // State if this message is comming from an REI environment or not
     if (function_exists('version_awareness_environment_isproduction') && version_awareness_environment_isproduction() !== true) {
         $message = '<span style="color: red;">NOTICE: The following message was dispatched from the ' . version_awareness_env() . ' environment.<br/>' . 'This notice will not be prepended when the message comes from the production/staging environment</span>' . '<br/><hr/><br/>' . $message;
     }
     ini_set('sendmail_from', $sendermail);
     // email fields: to, from, subject, and so on
     $from = "BusinessUSA <" . $sendermail . ">";
     $headers = "From: {$sendermail}";
     if (!function_exists('version_awareness_environment_isproduction') || version_awareness_environment_isproduction() === true) {
         if (strpos(request_uri(), '-DEBUG-EMAIL-NOADDITIONALHEADERS-') === false) {
             $headers .= "\r\nReply-To: {$sendermail}";
             $headers .= "\r\nX-Mailer: PHP/" . phpversion();
             $headers .= "\r\nReturn-Path: {$sendermail}";
         }
     }
     // boundary
     $semi_rand = md5(time());
     $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
     // headers for attachment
     $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\"";
     // multipart boundary
     $message = "--{$mime_boundary}\n" . "Content-Type: text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n";
     // preparing attachments
     for ($i = 0; $i < count($files); $i++) {
         if (is_file($files[$i])) {
             $message .= "--{$mime_boundary}\n";
             $fp = @fopen($files[$i], "rb");
             $data = @fread($fp, filesize($files[$i]));
             @fclose($fp);
             $data = chunk_split(base64_encode($data));
             $message .= "Content-Type: application/octet-stream; name=\"" . basename($files[$i]) . "\"\n" . "Content-Description: " . basename($files[$i]) . "\n" . "Content-Disposition: attachment;\n" . " filename=\"" . basename($files[$i]) . "\"; size=" . filesize($files[$i]) . ";\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n";
         }
     }
     $message .= "--{$mime_boundary}--";
     if (!function_exists('version_awareness_environment_isproduction') || version_awareness_environment_isproduction() !== true) {
         $returnpath = "-f" . $sendermail;
     }
     // Dispatch email - debugging and verbosity
     $debug['mail-arguments'] = array('to' => $to, 'subject' => $subject, 'message' => $message, 'headers' => $headers, 'returnpath' => $returnpath);
     // Dispatch email - trigger the native PHP function: mail()
     $ok = @mail($to, $subject, $message, $headers, $returnpath);
     $debug['mail-return'] = $ok;
     // Further debug and verbosity
     if (strpos($_SERVER['REQUEST_URI'], '-DEBUG-DISPATCHEMAIL-VERBOSE-') !== false) {
         dsm($debug);
     }
     if (strpos($_SERVER['REQUEST_URI'], '-DEBUG-DISPATCHEMAIL-STARTFIN-WATCH-') !== false) {
         dsm("dispatchEmail will return {$ok}");
     }
     return $debug;
 }
Пример #15
0
function track($request_uri = false, $track_agent = false)
{
    global $track_log, $track_db;
    global $track_agent_blacklist;
    if (!($track_log or $track_db)) {
        return true;
    }
    if (!$request_uri) {
        $request_uri = request_uri();
    }
    if (!$request_uri) {
        return false;
    }
    $user_agent = false;
    if ($track_agent or $track_agent_blacklist) {
        $user_agent = user_agent();
        if (!validate_user_agent($user_agent)) {
            $user_agent = false;
        }
        if ($user_agent and $track_agent_blacklist) {
            $reg = '/' . implode('|', $track_agent_blacklist) . '/i';
            if (preg_match($reg, $user_agent)) {
                return true;
            }
        }
    }
    $r = true;
    if ($track_log) {
        require_once 'log.php';
        $logmsg = $request_uri;
        if ($user_agent) {
            $logmsg .= "\t" . $user_agent;
        }
        $r = write_log($track_log === true ? 'track.log' : $track_log, $logmsg);
        if (!$r) {
            return false;
        }
    }
    if ($track_db) {
        $ip_address = client_ip_address();
        if (!validate_ip_address($ip_address)) {
            return false;
        }
        $sqlipaddress = db_sql_arg($ip_address, false);
        $sqlrequesturi = db_sql_arg($request_uri, true);
        $sqluseragent = db_sql_arg($user_agent, true, true);
        $tabtrack = db_prefix_table($track_db === true ? 'track' : $track_db);
        $sql = "INSERT INTO {$tabtrack} (ip_address, request_uri, user_agent) VALUES (INET_ATON({$sqlipaddress}), {$sqlrequesturi}, {$sqluseragent})";
        $r = db_insert($sql);
        if (!$r) {
            return false;
        }
    }
    return true;
}
Пример #16
0
 public function __construct() {
     parent::__construct();
     if (!$_SESSION['member_id']){
         redirect('index.php?act=login&ref_url='.urlencode(request_uri()));
     }
     //验证该会员是否禁止购买
     if(!$_SESSION['is_buy']){
         showMessage(Language::get('cart_buy_noallow'),'','html','error');
     }
     Tpl::output('hidden_rtoolbar_cart', 1);
 }
Пример #17
0
function corposs_preprocess_page(&$vars)
{
    $request = explode("/", request_uri());
    if ($request[1] == 'mandates' && empty($request[2])) {
        $path = drupal_get_path('theme', 'corposs');
        drupal_add_js($path . '/assets/js/mandate-filters.js', array('type' => 'file', 'group' => JS_THEME, 'weight' => 20));
    }
    if ($request[1] == 'anon-home' && empty($request[2])) {
        $vars['theme_hook_suggestions'][] = 'page__anon_home';
    }
}
Пример #18
0
 public function __construct()
 {
     parent::__construct();
     Language::read('home_cart_index');
     $op = isset($_GET['op']) ? $_GET['op'] : $_POST['op'];
     //允许不登录就可以访问的op
     $op_arr = array('ajax_load', 'add', 'del');
     if (!in_array($op, $op_arr) && !$_SESSION['member_id']) {
         $current_url = request_uri();
         redirect('index.php?act=login&ref_url=' . urlencode($current_url));
     }
 }
Пример #19
0
/**
 * Implements hook_TYPE_alter().
 *
 * @param array $options
 *   $options contains an array with configurations settings for used in the
 *   creation of the markup. The following elements may be in here.
 *
 *   - '#entity_type': The entity type this markup is define when called by a
 *                     field.
 *   - '#entity': Is the entity object when called by a field.
 *   - '#display': Is always defined and provide all the formatter
 *                 configuration.
 *   - '#url': The link to the entity when the entity has a url.
 */
function hook_addthis_markup_options_alter(&$options)
{
    global $base_root;
    // Change the url used on the share buttons.
    $options['#url'] = $base_root . request_uri();
    // To apply different service this to the block implementation try this.
    if (isset($options['#block']) && $options['#display']['type'] == 'addthis_basic_toolbox') {
        // Change the var below to add other services.
        $displayed_services = 'twitter,google_plusone,facebook';
        $options['#display']['settings']['share_services'] = $displayed_services;
        $options['#display']['settings']['buttons_size'] = AddThis::CSS_16x16;
    }
}
Пример #20
0
function test_request_uri()
{
    # TODO test with webbrick + CGIHandler (http://microjet.ath.cx/webrickguide/html/CGIHandler.html)
    # TODO request_uri must be also tested in a browser...
    assert_equal(request_uri(), "/");
    $path = dirname(__FILE__) . "/helpers/show_request_uri.php";
    $cmd = "php -f {$path}";
    assert_equal(exec($cmd, $res), "/");
    assert_equal(exec($cmd . " test", $res), "/test");
    assert_equal(exec($cmd . " /test", $res), "/test");
    assert_equal(exec($cmd . " /my-test/", $res), "/my-test");
    assert_not_equal(exec($cmd . " /my-test/?", $res), "/my-test");
    assert_not_equal(exec($cmd . " /my-test?var=1", $res), "/my-test");
}
/**
 * Override or insert variables for the page templates.
 */
function start_preprocess_html(&$vars)
{
    //Add noindex meta tag to dynamic page, when clean url enable
    if (!empty($GLOBALS['conf']['clean_url'])) {
        $current_uri = request_uri();
        $dynamic = strpos($current_uri, "?");
        if ($dynamic == TRUE) {
            $noindex = array('#tag' => 'meta', '#attributes' => array('name' => 'robots', 'content' => "noindex, follow"));
            drupal_add_html_head($noindex, 'noindex_follow');
        }
    }
    // Add Local styles
    // drupal_add_css('http://localhost/dev/start/css/style.css', array('group' => CSS_THEME, 'type' => 'external'));
}
Пример #22
0
 function RosterTemplate()
 {
     global $roster;
     if (!is_dir(ROSTER_TPLDIR . 'default')) {
         trigger_error("'default' theme does not exist", E_USER_ERROR);
     }
     if (is_dir(ROSTER_TPLDIR . $roster->config['theme'])) {
         $this->tpl = $roster->config['theme'];
     } else {
         $this->tpl = 'default';
     }
     $this->_tpldata['.'][0]['REQUEST_URI'] = str_replace('&', '&amp;', substr(request_uri(), strlen(ROSTER_PATH)));
     $this->root = ROSTER_TPLDIR . $this->tpl;
     $roster->config['theme_path'] = ROSTER_PATH . 'templates/' . $this->tpl;
 }
Пример #23
0
/**
 * Override or insert variables into the html template.
 */
function basic_preprocess_html(&$vars)
{
    // Set meta tags for mobile CSS detection
    $meta['handheld'] = array('#tag' => 'meta', '#attributes' => array('name' => 'HandheldFriendly', 'content' => 'true'));
    $meta['apple-mobile-web-app-capable'] = array('#tag' => 'meta', '#attributes' => array('name' => 'apple-mobile-web-app-capable', 'content' => 'yes'));
    $meta['apple-mobile-web-app-status-bar-style'] = array('#tag' => 'meta', '#attributes' => array('name' => 'apple-mobile-web-app-status-bar-style', 'content' => 'black'));
    $meta['viewport'] = array('#tag' => 'meta', '#attributes' => array('name' => 'viewport', 'content' => 'initial-scale=1, user-scalable=0, minimum-scale=1, maximum-scale=1'));
    drupal_add_html_head($meta['handheld'], 'handheld');
    drupal_add_html_head($meta['apple-mobile-web-app-capable'], 'apple-mobile-web-app-capable');
    drupal_add_html_head($meta['apple-mobile-web-app-status-bar-style'], 'apple-mobile-web-app-status-bar-style');
    drupal_add_html_head($meta['viewport'], 'viewport');
    // Add class to body for home page
    if (request_uri() == base_path()) {
        $vars['classes_array'][] = "home";
    }
}
Пример #24
0
 private function parse_uri()
 {
     global $_SERVER;
     //set up variables for checking
     $fullpath = request_uri();
     $querystart = strpos($fullpath, "?");
     if ($querystart === false) {
         $path = $fullpath;
         $query = "";
     } else {
         $path = substr($fullpath, 0, $querystart);
         $query = "?" . substr($fullpath, $querystart + 1);
     }
     $this->path = $path;
     $this->query = $query;
 }
Пример #25
0
function pirateparty_process_page(&$vars)
{
    $alias = explode('/', drupal_get_path_alias(request_uri()));
    if ($alias[1] == "campaigns") {
        $vars['theme_hook_suggestions'][] = 'page__campaigns';
    }
    if ($alias[1] == "policy") {
        $vars['theme_hook_suggestions'][] = 'page__policy';
    }
    if ($alias[1] == "leaders-office") {
        $vars['theme_hook_suggestions'][] = 'page__leaders';
    }
    if ($alias[1] == "press") {
        $vars['theme_hook_suggestions'][] = 'page__press';
    }
}
Пример #26
0
function tep_update_whos_online()
{
    // WOL 1.6 - Need access to spider_flag and user_agent and moved some assignments up here from below
    global $customer_id, $spider_flag, $user_agent;
    $wo_ip_address = tep_get_ip_address();
    $wo_last_page_url = request_uri();
    $current_time = time();
    $xx_mins_ago = $current_time - 900;
    $wo_session_id = tep_session_id();
    $wo_user_agent = $user_agent;
    // WOL 1.6 EOF
    if ($customer_id > 0) {
        //if (tep_session_is_registered('customer_id')) {
        //$wo_session_id = tep_session_id();
        $wo_customer_id = $customer_id;
        $customer_query = tep_db_query("select customers_firstname, customers_lastname from " . TABLE_CUSTOMERS . " where customers_id = '" . (int) $customer_id . "'");
        $customer = tep_db_fetch_array($customer_query);
        $wo_full_name = $customer['customers_firstname'] . ' ' . $customer['customers_lastname'];
    } else {
        if ($spider_flag) {
            // Bots are customerID = -1
            $wo_customer_id = -1;
            // The Bots name is extracted from the User Agent in the WOE Admin screen
            $wo_full_name = $user_agent;
            // Session IDs are the WOE primary key.  If a Bot doesn't have a session (normally shouldn't),
            //   use the IP Address as unique identifier, otherwise, use the session ID
            if ($wo_session_id == "") {
                $wo_session_id = $wo_ip_address;
            }
        } else {
            // Must be a Guest
            $wo_full_name = 'Guest';
            $wo_customer_id = 0;
        }
        // WOL 1.6 EOF
    }
    // remove entries that have expired
    tep_db_query("delete from " . TABLE_WHOS_ONLINE . " where time_last_click < '" . $xx_mins_ago . "'");
    $stored_customer_query = tep_db_query("select count(*) as count from " . TABLE_WHOS_ONLINE . " where session_id = '" . tep_db_input($wo_session_id) . "'");
    $stored_customer = tep_db_fetch_array($stored_customer_query);
    if ($stored_customer['count'] > 0) {
        tep_db_query("update " . TABLE_WHOS_ONLINE . " set customer_id = '" . (int) $wo_customer_id . "', full_name = '" . tep_db_input($wo_full_name) . "', ip_address = '" . tep_db_input($wo_ip_address) . "', time_last_click = '" . tep_db_input($current_time) . "', last_page_url = '" . tep_db_input($wo_last_page_url) . "' where session_id = '" . tep_db_input($wo_session_id) . "'");
    } else {
        tep_db_query("insert into " . TABLE_WHOS_ONLINE . " (customer_id, full_name, session_id, ip_address, time_entry, time_last_click, last_page_url, http_referer, user_agent) values ('" . (int) $wo_customer_id . "', '" . tep_db_input($wo_full_name) . "', '" . tep_db_input($wo_session_id) . "', '" . tep_db_input($wo_ip_address) . "', '" . tep_db_input($current_time) . "', '" . tep_db_input($current_time) . "', '" . tep_db_input($wo_last_page_url) . "', '" . tep_db_input($_SERVER['HTTP_REFERER']) . "', '" . tep_db_input($user_agent) . "')");
    }
}
Пример #27
0
 /**
  * 构造函数 
  */
 public function __construct()
 {
     parent::__construct();
     //读取语言包
     Language::read('home_cart_index');
     if (!$_SESSION['member_id']) {
         redirect('index.php?act=login&ref_url=' . urlencode(request_uri()));
     }
     //验证该会员是否禁止购买
     $member_model = Model('member');
     $member_id = intval($_SESSION['member_id']);
     $member_info = $member_model->infoMember(array('member_id' => "{$member_id}"));
     if (empty($member_info) || !$member_info['is_buy']) {
         showMessage(Language::get('cart_buy_noallow'), '', 'html', 'error');
     }
     unset($member_id);
     unset($member_info);
     unset($member_model);
 }
Пример #28
0
function forum_plus_preprocess_html(&$vars)
{
    $node_id = drupal_lookup_path('source', '404-page');
    if (!empty($node_id)) {
        $parts = explode("/", $node_id);
        $n_id = false;
        if (count($parts) > 1) {
            $n_id = $parts[1];
        }
        if (in_array("html__node__{$n_id}", $vars['theme_hook_suggestions'])) {
            $vars['theme_hook_suggestions'][] = 'html__404';
        }
    }
    if (count($vars['theme_hook_suggestions']) == 1) {
        if (isset($vars['page']['content']['system_main']['main']['#markup']) && trim($vars['page']['content']['system_main']['main']['#markup']) == t('The requested page "@path" could not be found.', array('@path' => request_uri()))) {
            $vars['theme_hook_suggestions'][] = 'html__404';
        }
    }
}
Пример #29
0
function hasta_menu_link(array $variables)
{
    $element = $variables['element'];
    $sub_menu = '';
    if (strpos($element['#href'], "_anchor_") !== false) {
        $element['#localized_options']['attributes']['data-scroll-to'] = str_replace("http://_anchor_", '#', $element['#href']);
        $element['#href'] = str_replace("http://_anchor_", '//' . $_SERVER['HTTP_HOST'] . request_uri() . '#', $element['#href']);
    }
    if ($element['#below']) {
        $element['#localized_options']['attributes']['class'][] = 'mn-has-sub';
        $element['#title'] = '<i class="fa fa-caret-right"></i> ' . $element['#title'];
        unset($element['#below']['#theme_wrappers']);
        $sub_menu = '<ul class = "mn-sub">' . drupal_render($element['#below']) . '</ul>';
    }
    $element['#localized_options']['html'] = TRUE;
    if (isset($element['#localized_options']['attributes']['class']) && in_array('active-trail', $element['#localized_options']['attributes']['class'])) {
        $element['#localized_options']['attributes']['class'][] = 'active';
    }
    $output = l($element['#title'], $element['#href'], $element['#localized_options']);
    return '<li>' . $output . $sub_menu . "</li>\n";
}
/**
 * Override theme_breadcrumb().
 */
function maxhealthcare_breadcrumb($breadcrumb)
{
    $links = array();
    $path = '';
    // Get URL arguments
    $arguments = explode('/', request_uri());
    // Remove empty values
    foreach ($arguments as $key => $value) {
        if (empty($value)) {
            unset($arguments[$key]);
        }
    }
    $arguments = array_values($arguments);
    // Add 'Home' link
    $links[] = l(t('Home'), '<front>');
    // Add other links
    if (!empty($arguments)) {
        foreach ($arguments as $key => $value) {
            // Don't make last breadcrumb a link
            if ($key == count($arguments) - 1) {
                $links[] = drupal_get_title();
            } else {
                if (!empty($path)) {
                    $path .= '/' . $value;
                } else {
                    $path .= $value;
                }
                $links[] = l(drupal_ucfirst($value), $path);
            }
        }
    }
    // Set custom breadcrumbs
    drupal_set_breadcrumb($links);
    // Get custom breadcrumbs
    $breadcrumb = drupal_get_breadcrumb();
    // Hide breadcrumbs if only 'Home' exists
    if (count($breadcrumb) > 1) {
        return '<div class="breadcrumb">' . implode(' &raquo; ', $breadcrumb) . '</div>';
    }
}