Entries Tagged as ''

装discuz时的php错误

用discuz4.1.0搭一个论坛的时候

http://forum.xxx.com/install.php

出了一个错误:

Fatal error: Call to undefined function preg_replace() in /path/install.php on line xxx

这是因为php缺少PCRE(Perl Compatible Regular Expression)库的支持造成的

于是装上pcre

因为系统是FreeBSD,php版本是4.x

所以

cd /usr/ports/deve/php4-pcre;make;make install

然后再重起apache

则搞定了

squid的result code

原文出自这里

The TCP_ codes refer to requests on the HTTP port (usually 3128). The UDP_ codes refer to requests on the ICP port (usually 3130). If ICP logging was disabled using the log_icp_queries option, no ICP replies will be logged.

The following result codes were taken from a Squid-2, compare with the log_tags struct in src/access_log.c:

 

TCP_HIT

A valid copy of the requested object was in the cache.

TCP_MISS

The requested object was not in the cache.

TCP_REFRESH_HIT

The requested object was cached but STALE. The IMS query for the object resulted in "304 not modified".

TCP_REF_FAIL_HIT

The requested object was cached but STALE. The IMS query failed and the stale object was delivered.

TCP_REFRESH_MISS

The requested object was cached but STALE. The IMS query returned the new content.

TCP_CLIENT_REFRESH_MISS

The client issued a "no-cache" pragma, or some analogous cache control command along with the request. Thus, the cache has to refetch the object.

TCP_IMS_HIT

The client issued an IMS request for an object which was in the cache and fresh.

TCP_SWAPFAIL_MISS

The object was believed to be in the cache, but could not be accessed.

TCP_NEGATIVE_HIT

Request for a negatively cached object, e.g. "404 not found", for which the cache believes to know that it is inaccessible. Also refer to the explainations for negative_ttl in your squid.conf file.

TCP_MEM_HIT

A valid copy of the requested object was in the cache and it was in memory, thus avoiding disk accesses.

TCP_DENIED

Access was denied for this request.

TCP_OFFLINE_HIT

The requested object was retrieved from the cache during offline mode. The offline mode never validates any object, see offline_mode in squid.conf file.

UDP_HIT

A valid copy of the requested object was in the cache.

UDP_MISS

The requested object is not in this cache.

UDP_DENIED

Access was denied for this request.

UDP_INVALID

An invalid request was received.

UDP_MISS_NOFETCH

During "-Y" startup, or during frequent failures, a cache in hit only mode will return either UDP_HIT or this code. Neighbours will thus only fetch hits.

NONE

Seen with errors and cachemgr requests.

 

The following codes are no longer available in Squid-2:

 

ERR_*

Errors are now contained in the status code.

TCP_CLIENT_REFRESH

See: TCP_CLIENT_REFRESH_MISS.

TCP_SWAPFAIL

See: TCP_SWAPFAIL_MISS.

TCP_IMS_MISS

Deleted, TCP_IMS_HIT used instead.

UDP_HIT_OBJ

Hit objects are no longer available.

UDP_RELOADING

See: UDP_MISS_NOFETCH

squid的一个错误:“FATAL: Bungled squid.conf”

跑squid碰到一个问题

运行程序的时候报:

FATAL: Bungled squid.conf line xxx:  cache_dir ufs /path/cache  256 16 256

Squid Cache (Version 2.5.STABLE13-xxxxxxxx):: Terminated abnormally.

结果发现是因为存储缓存用的是ufs

启用这种格式必须在编译squid的时候加上async-io的支持

于是重新编译squid,加上async-io支持

./configure –enable-async-io

这里如果cache_dir不是设的ufs而是aufs的话,还需要加上参数–enable-storeio=aufs

然后再

make;make install

再启动squid

就OK了

第一个用到多线程的perl程序

用来检查库里的代理列表是否依旧可用

多线程是用上了,但是不知道缺省是起几个线程

:(

#!/usr/bin/perl

use strict;

use DBI();

use HTTP::ProxyCheck;

use threads;

my $DEBUG = 1;

# Connect to the database.

my $TimeToLive = 5;     # 3 days

my $dbh = DBI->connect("DBI:mysql:database=proxyservers;host=localhost;mysql_socket=/var/lib/mysql/mysql.sock",

                        "root", "", {’RaiseError’ => 1});

my $sql = "select id, ipn, port from proxy where now() - INTERVAL 1 day > t_checked order by t_checked";

print $sql if ($DEBUG);

my $sth = $dbh->prepare("$sql");

$sth->execute();

while (my $ref=$sth->fetchrow_hashref()) {

        my $thr = threads->new(\&CheckHTTPProxy, "$ref->{’ipn’}", "$ref->{’port’}");

        if ($thr->join) {

#       if (CheckHTTPProxy($ref->{’ipn’}, $ref->{’port’})) {

                $sql = "update proxy set t_checked = now() where id = $ref->{’id’}";

                print $sql if ($DEBUG);

                $dbh->do("$sql");

        }

}

$sql = "delete from proxy where now() - INTERVAL $TimeToLive day > t_checked";

print $sql if ($DEBUG);

$dbh->do("$sql");

$dbh->disconnect();

sub CheckHTTPProxy

{

        my ($ipn, $port) = @_;

        my $ip = num2str($ipn);

        my $proxy = "$ip:$port";

        my $url = ‘http://search.cpan.org/’;

        my $proxy_check = new HTTP::ProxyCheck(

                proxy           => $proxy,

                url             => $url,

                answer_size     => ‘header’,

                print_error     => 0,

        ) or return 0;

        print "Trying to connect to ‘$proxy’ and retrieve ‘$url’\n" if ($DEBUG);

        if ( $proxy_check->check() ) {

                print "’$proxy’ returns:\n\n", $proxy_check->get_answer(), "\n\n" if ($DEBUG);

                return 1;

        } else {

                print "Error: ", $proxy_check->get_error(), "\n" if ($DEBUG);

                return 0;

        }

}

sub num2str

{

        my ($ipn) = @_;

        my $z = $ipn % 256;

        $ipn >>= 8;

        my $y = $ipn % 256;

        $ipn >>= 8;

        my $x = $ipn % 256;

        $ipn >>= 8;

        my $w = $ipn % 256;

        return "$w.$x.$y.$z";

}

perl的运算符x

有时候需要在shell里生成多少个重复字符的字符串

用perl的这个运算符就非常方便

比如

perl -e ‘print "a" x 100′

这将会打印100个字符"a"

perl的官方文档里是这么讲的:

Binary "x" is the repetition operator. In scalar context or if the left operand is not enclosed in parentheses, it returns a string consisting of the left operand repeated the number of times specified by the right operand. In list context, if the left operand is enclosed in parentheses or is a list formed by qw/STRING/, it repeats the list. If the right operand is zero or negative, it returns an empty string or an empty list, depending on the context.

    print '-' x 80;             # print row of dashes
print "\t" x ($tab/8), ' ' x ($tab%8);      # tab over
@ones = (1) x 80;           # a list of 80 1's
@ones = (5) x @ones;        # set all elements to 5