示例#1
0
function get_robot()
{
    if (is_robot()) {
        $agent = strtolower($_SERVER['HTTP_USER_AGENT']);
        foreach ($ROBOT as $k => $v) {
            if (strpos($agent, $k) !== false) {
                return $k;
            }
        }
        return 'other';
    }
    return '';
}
示例#2
0
文件: DB.php 项目: robbiespire/paQui
	/**
	 * Gets data from the session data table and loads Member
	 * objects into the User from the loaded data.
	 *
	 * @since 1.1
	 *
	 * @return boolean
	 **/
	function load ($id) {
		$db = &DB::get();

		if (is_robot() || empty($this->session)) return true;

		$loaded = false;

		$query = "SELECT * FROM $this->_table WHERE session='$this->session'";
		if ($result = $db->query($query)) {
			if (substr($result->data,0,1) == "!") {
				$key = $_COOKIE[ECART_SECURE_KEY];
				if (empty($key) && !is_ecart_secure())
					ecart_redirect(force_ssl(raw_request_url(),true));
				$readable = $db->query("SELECT AES_DECRYPT('".
										mysql_real_escape_string(
											base64_decode(
												substr($result->data,1)
											)
										)."','$key') AS data");
				$result->data = $readable->data;
			}
			$this->ip = $result->ip;
			$this->data = unserialize($result->data);
			$this->created = mktimestamp($result->created);
			$this->modified = mktimestamp($result->modified);
			$loaded = true;

			do_action('ecart_session_loaded');
		} else {
			if (!empty($this->session))
				$db->query("INSERT INTO $this->_table (session, ip, data, created, modified)
							VALUES ('$this->session','$this->ip','',now(),now())");
		}
		do_action('ecart_session_load');

		// Read standard session data
		if (@file_exists("$this->path/sess_$id"))
			return (string) @file_get_contents("$this->path/sess_$id");

		return $loaded;
	}
示例#3
0
function process_post_views_action($output_type = 'content')
{
    global $wpdb, $post, $user_ID;
    $id = intval($post->ID);
    if (cache_enable()) {
        wp_enqueue_script('jquery');
    }
    if (!wp_is_post_revision($post)) {
        if ($output_type == 'excerpt') {
            $need_rec = true;
        } else {
            if (is_single() || is_page()) {
                $need_rec = true;
            } else {
                $need_rec = false;
            }
        }
        if ($need_rec) {
            $agent = $_SERVER['HTTP_USER_AGENT'];
            $pv_is_rec = false;
            $pv_rec_options = get_option('post_views_rec_options');
            $rec_option = $pv_rec_options['rec_option'];
            $is_usecookie = $pv_rec_options['rec_cookie'];
            if ($is_usecookie == 1) {
                $pv_url = md5($_SERVER['REQUEST_URI']);
                $pv_cookie = $_COOKIE[$pv_url];
                if (empty($pv_cookie)) {
                    if ($rec_option == 1) {
                        if (intval($user_ID) == 0) {
                            $pv_is_rec = true;
                        }
                    } else {
                        if ($rec_option == 2) {
                            if (intval($user_ID) > 0) {
                                $pv_is_rec = true;
                            }
                        } else {
                            $pv_is_rec = true;
                        }
                    }
                }
            } else {
                if ($rec_option == 1) {
                    if (intval($user_ID) == 0) {
                        $pv_is_rec = true;
                    }
                } else {
                    if ($rec_option == 2) {
                        if (intval($user_ID) > 0) {
                            $pv_is_rec = true;
                        }
                    } else {
                        $pv_is_rec = true;
                    }
                }
            }
            if (is_robot($agent)) {
                if (cache_enable()) {
                    if (is_feed()) {
                        post_views_update('robot', $id, $output_type);
                    } else {
                        cache_print('robot', $id, $output_type);
                    }
                } else {
                    post_views_update('robot', $id, $output_type);
                }
            } else {
                if ($pv_is_rec) {
                    if (cache_enable()) {
                        if (is_feed()) {
                            post_views_update('normal', $id, $output_type);
                        } else {
                            cache_print('normal', $id, $output_type);
                        }
                    } else {
                        post_views_update('normal', $id, $output_type);
                    }
                }
            }
        }
    }
}
示例#4
0
        $_GET = daddslashes($_GET);
    }
    if ($_COOKIE) {
        $_COOKIE = daddslashes($_COOKIE);
    }
}
if (function_exists('date_default_timezone_set')) {
    date_default_timezone_set($CFG['timezone']);
}
$DT_PRE = $CFG['tb_pre'];
$DT_QST = addslashes($_SERVER['QUERY_STRING']);
$DT_TIME = time() + $CFG['timediff'];
$DT_IP = get_env('ip');
$DT_URL = get_env('url');
$DT_REF = get_env('referer');
$DT_BOT = is_robot();
header("Content-Type:text/html;charset=" . DT_CHARSET);
require DT_ROOT . '/include/db_' . $CFG['database'] . '.class.php';
require DT_ROOT . '/include/cache_' . $CFG['cache'] . '.class.php';
require DT_ROOT . '/include/session_' . $CFG['session'] . '.class.php';
require DT_ROOT . '/include/file.func.php';
if (!empty($_SERVER['REQUEST_URI'])) {
    strip_uri($_SERVER['REQUEST_URI']);
}
if ($_POST) {
    $_POST = strip_sql($_POST);
    strip_key($_POST);
}
if ($_GET) {
    $_GET = strip_sql($_GET);
    strip_key($_GET);
 function load($id)
 {
     global $Shopp;
     $db = DB::get();
     if (is_robot()) {
         return true;
     }
     $query = "SELECT * FROM {$this->_table} WHERE session='{$this->session}'";
     // echo "$query".BR;
     if ($result = $db->query($query)) {
         if (substr($result->data, 0, 1) == "!") {
             $key = $_COOKIE[SHOPP_SECURE_KEY];
             $readable = $db->query("SELECT AES_DECRYPT('" . mysql_real_escape_string(base64_decode(substr($result->data, 1))) . "','{$key}') AS data");
             $result->data = $readable->data;
         }
         $this->ip = $result->ip;
         $this->data = unserialize($result->data);
         if (empty($result->contents)) {
             $this->contents = array();
         } else {
             $this->contents = unserialize($result->contents);
         }
         $this->created = mktimestamp($result->created);
         $this->modified = mktimestamp($result->modified);
     } else {
         $db->query("INSERT INTO {$this->_table} (session, ip, data, contents, created, modified) \n\t\t\t\t\t\t\tVALUES ('{$this->session}','{$this->ip}','','',now(),now())");
     }
     if (empty($this->data->Errors)) {
         $this->data->Errors = new ShoppErrors();
     }
     if ($Shopp->Settings->get('shipping') == "off") {
         $this->data->ShippingDisabled = true;
     }
     // Read standard session data
     if (file_exists("{$this->path}/sess_{$id}")) {
         return (string) file_get_contents("{$this->path}/sess_{$id}");
     }
     return true;
 }