diff --git a/.gitignore b/.gitignore index 19ce2922..c60897f7 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,6 @@ .htconfig.php #* favicon.* - - +tests/coverage.html +/vendor +/nbproject/private/ diff --git a/.htaccess b/.htaccess old mode 100755 new mode 100644 diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..3cf4a7c0 --- /dev/null +++ b/Makefile @@ -0,0 +1,2 @@ +test: + cd tests && phpunit --coverage-html=coverage.html && x-www-browser ./coverage.html/index.html \ No newline at end of file diff --git a/README.md b/README.md index fd47fc6c..60b4f25e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,23 @@ -# Friendica Global Directory +# Decentralized Friendica Directory -Example cronjob. +## Installing + +### 1. Initialize the database + +Create a database with a username and a password. +Then import ````dfrndir.sql```` to it. + +### 2. Create an autoloader with composer + +Make sure you have composer installed globally, or rewrite the command to use a `.phar`. + +```sh +composer dump-autoload +``` + +### 3. Set up the cronjobs. + +Example cronjob using `www-data` user. ``` */30 * * * * www-data cd /var/www/friendica-directory; php include/cron_maintain.php @@ -58,8 +75,6 @@ You can check the backlog of this queue at the `/admin` page. * `.vcard .region` as `region` * `.vcard .postal-code` as `postal-code` * `.vcard .country-name` as `country-name` - * `.vcard .x-gender` as `gender` - * `.marital-text` as `marital` 3. If the `dfrn-global-visibility` value is set to false. Any existing records will be deleted. And the process exits here. @@ -93,4 +108,24 @@ You can check the backlog of this queue at the `/admin` page. 10. The `photo` provided will be downloaded and resized to 80x80, regardless of source size. 11. Should there somehow have been an error at this point such as that there is no profile ID known. - Everything will get deleted based on the original `?url=` parameter. \ No newline at end of file + Everything will get deleted based on the original `?url=` parameter. + +## Note about search + +The Directory uses MySQL fulltext capabilities to index profiles and offer a search feature. +However, the default minimum word size MySQL will index is 4, which ignores words like `PHP` and `USA`. + +To index words smaller than 4 characters, you will have to edit your my.cnf/my.ini file to include this: + +```` +[mysqld] +ft_min_word_len = 3 +```` + +Then restart your MySQL server. + +If you already had data in your profile table, you will need to rebuild the index by executing the following query: + +```` +REPAIR TABLE `profile` QUICK; +```` \ No newline at end of file diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 00000000..9b4db068 --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,43 @@ + +server_ip = "192.168.33.10" +server_memory = "384" # MB +server_timezone = "UTC" + +public_folder = "/vagrant" + +Vagrant.configure(2) do |config| + + # Set server to Ubuntu 14.04 + config.vm.box = "ubuntu/trusty64" + + # Disable automatic box update checking. If you disable this, then + # boxes will only be checked for updates when the user runs + # `vagrant box outdated`. This is not recommended. + # config.vm.box_check_update = false + + # Create a hostname, don't forget to put it to the `hosts` file + # This will point to the server's default virtual host + # TO DO: Make this work with virtualhost along-side xip.io URL + config.vm.hostname = "friendica.dev" + + # Create a static IP + config.vm.network :private_network, ip: server_ip + + # Share a folder between host and guest + config.vm.synced_folder "./", "/vagrant/", owner: "www-data", group: "vagrant" + + # Provider-specific configuration so you can fine-tune various + # backing providers for Vagrant. These expose provider-specific options. + config.vm.provider "virtualbox" do |vb| + # # Display the VirtualBox GUI when booting the machine + # vb.gui = true + # + # # Customize the amount of memory on the VM: + vb.memory = server_memory + end + + # Enable provisioning with a shell script. + config.vm.provision "shell", path: "./util/vagrant_provision.sh" + # run: "always" + # run: "once" +end diff --git a/assets/js/main.js b/assets/js/main.js new file mode 100644 index 00000000..e72c142b --- /dev/null +++ b/assets/js/main.js @@ -0,0 +1,30 @@ +jQuery(function($){ + + //Mobile menu, hamburger button. + $('body').on('click', '.hamburger', function(e){ + e.preventDefault(); + $('nav#links').toggleClass('open'); + }); + + // Show/hide the reset link if the search field is populated/empty + function updateResetButton() { + if ($('.search-field').val()) { + $('.reset').show(); + } else { + $('.reset').hide(); + } + } + $('body').on('keyup', '.search-field', updateResetButton) + + updateResetButton(); + + // Makes the entire profile card clickable... + $('body').on('click', '.profile', function(event) { + window.open(event.currentTarget.dataset.href, '_blank'); + }); + + // ...while keeping inner a tags clickable + $('body').on('click', '.profile a', function(event) { + event.stopPropagation(); + }) +}); diff --git a/assets/style.css b/assets/style.css new file mode 100644 index 00000000..7b54d664 --- /dev/null +++ b/assets/style.css @@ -0,0 +1,448 @@ +* { + box-sizing: border-box; +} + +html,body { + margin: 0; + padding: 0; +} + +html { + font-family: 'Open Sans', sans-serif; + font-weight: 300; + font-size: 100%; +} + +a {color: inherit;} + +p { + margin: 0 0 1em 0; +} + +.mobile { + display: none !important; +} + +#top-bar { + background: #f5f5f5; + padding: 8px 14px; + position: fixed; + z-index: 1; + top: 0; + height: 55px; + width: 100%; + font-weight: 300; + border-bottom: 1px solid #ddd; + display: flex; + justify-content: space-between; +} +#top-bar-spacer { + width: 100%; + height: 55px; +} + +#top-bar .header { + display: inline-block; + font-size: 16px; + font-weight: 300; + line-height: 19px; + background: url('/images/friendica.svg') top left no-repeat; + background-size: 14px; + padding-left: 18px; + margin: 0; + white-space: nowrap; +} + +#top-bar .search-form { + display: inline-block; +} +#top-bar .search-wrapper { + background: #fff; +} + +nav#links { + line-height: 39px; + white-space: nowrap; +} +nav#links a { + display: inline-block; + margin: 0 4px; + padding: 0 5px; +} + +.sub-menu-outer { + background: #eee; + line-height: 45px; + height: 45px; + border-bottom: 1px solid #ddd; +} +.sub-menu-outer .sub-menu-inner { + width: 500px; + margin: auto; +} +.sub-menu-inner .option { + padding: 9px 6px; + margin: 0 5px; +} +.sub-menu-inner .option.active { + border-bottom: 2px solid #f00; +} + +.homepage-wrapper { + width: 500px; + margin: auto; + text-align: center; +} + +.search-results, +.directory-results { + margin-bottom: 25px; +} + +.directory-results { + display: flex; + flex-flow: row; +} + +.directory-results > aside { + flex: 1 6 20%; + order: 1; + padding: 0 1em; +} + +.directory-results > section { + flex: 3 1 80%; + order: 2; +} + +.homepage-wrapper { + margin: 120px auto; +} + +.homepage-wrapper .header { + font-size: 68px; + font-weight: 100; + line-height: 0.9em; + background: url('/images/friendica.svg') top left no-repeat; + background-size: 61px; + margin-left: 40px; +} +.homepage-wrapper .about { + text-align: justify; + line-height: 1.5em; + color: #555; +} + +.homepage-wrapper .profiles { + margin-top: 3em; +} + +.profiles { + padding: 0 10px; + column-width: 400px; +} + +.profiles > figure { + display: inline-block; + cursor: pointer; +} + +nav#links a, +.sub-menu-outer a { + text-decoration: none; +} + +.search-results .intro { + text-align: justify; +} + +.site, +.profile { + width: 100%; + text-decoration: none; + color: #000; + padding: 2px; + outline: none; + margin: 5px 0; + display: inline; + background-color: rgba(0, 0, 0, .01); + border-radius: 23px .5em 23px .5em; +} + +.site { + padding: 14px 2px; + margin: 20px 0; + border-bottom: 1px dashed #ccc; +} + +.profile.selected, +.profile: focus, +.profile: hover { + padding: 1px; + border: 1px solid #ccc; +} + +.site .site-info, +.site .site-supports, +.profile .profile-photo, +.profile .profile-info { + display: table-cell; + vertical-align: top; + text-align: left; +} +.site .site-supports { + text-align: right; + padding: 8px; +} + +.profile .profile-photo { + float: left; + margin: 8px; + border-radius: 15px; + border: 1px solid #ddd; +} +.site .site-info, +.profile .profile-info { + padding: 8px; + width: 100%; +} +.site .site-info strong, +.profile .profile-info strong { + font-weight: 600; +} +.site .site-info .fa, +.profile .profile-info .fa { + line-height: 1.1em; + color: #999; +} +.site .site-info .url, +.profile .profile-info .url { + font-size: 80%; + margin-bottom: 3px; + color: #555; + + /** @see https: //css-tricks.com/snippets/css/prevent-long-urls-from-breaking-out-of-container/ */ + overflow-wrap: break-word; + word-wrap: break-word; + -ms-word-break: break-all; + word-break: break-all; + word-break: break-word; + -ms-hyphens: auto; + -moz-hyphens: auto; + -webkit-hyphens: auto; + hyphens: auto; +} + +.profile .profile-info .description { + margin-bottom: .5em; +} + +.search-wrapper { + position: relative; + display: inline-block; + width: 500px; + background: #f5f5f5; + border: 1px solid #ddd; + border-radius: 8px; + height: 38px; + line-height: 22px; +} +.search-wrapper .search-field { + line-height: 22px; + display: block; + border: none; + outline: none; + background: none; + padding: 8px 12px; + padding-right: 117px; + width: 100%; +} +.search-wrapper .reset { + position: absolute; + top: 0; + right: 65px; + height: 25px; + width: 25px; + margin: 6px; + padding: 0; + line-height: 1; + font-size: 12px; + color: #555; + background: #eee; + border: 1px solid #ddd; + border-radius: 20px; + font-family: 'FontAwesome'; + font-weight: 100; + line-height: 25px; + text-decoration: none; +} +.search-wrapper .search { + border: none; + border-left: 1px solid #ddd; + color: #555; + background: #eee; + position: absolute; + top: 0; + right: 0; + height: 36px; + width: 65px; + border-radius: 0 8px 8px 0; +} + +.health {font-size: 120%; vertical-align: bottom;} +.health.very-bad { color: #f99; } +.health.bad { color: #f1ba7a; } +.health.neutral { color: #e6e782; } +.health.ok { color: #bef273; } +.health.good { color: #7cf273; } +.health.perfect { color: #33ff80; } + +.btn { + border: 1px solid #ddd; + color: #555; + background: #eee; + border-radius: 8px 8px; + height: 36px; + line-height: 34px; + min-width: 80px; + padding: 0 10px; + text-decoration: none; + display: inline-block; +} + +/* smaller than tablet in portrait */ +@media screen and (max-width: 880px) { + + body { + overflow-x: hidden; + } + + .mobile { + display: inherit !important; + } + + #top-bar .header { + overflow: hidden; + width: 0px; + padding-left: 28px; + height: 28px; + background-size: 28px; + } + + #top-bar .search-form { + display: block; + width: 100%; + padding: 0 35px; + margin: 0; + } + + .homepage-wrapper, + .search-wrapper { + width: 100%; + max-width: 500px; + } + .homepage-wrapper .search-wrapper { + width: 100%; + } + + .homepage-wrapper { + margin: 90px auto; + } + + .search-results, + .sub-menu-outer .sub-menu-inner { + width: 95%; + max-width: 500px; + } + + .hamburger { + padding: 8px; + font-size: 22px; + line-height: 22px; + cursor: pointer; + } + + nav#links { + position: absolute; + width: 100%; + top: 54px; + right: 0; + padding-bottom: 5px; + } + nav#links .viewport { + position: absolute; + z-index: 1; + left: 100%; + width: 100%; + transition: left ease 200ms; + background: #fff; + padding: 20px 0; + box-shadow: 1px 3px 3px rgba(0,0,0,0.2); + font-size: 150%; + text-align: center; + } + nav#links.open .viewport { + left: 0%; + } + #top-bar nav#links .viewport { + background: #f5f5f5; + } + nav#links h3 { + margin: 0; + display: block; + line-height: 2em; + } + nav#links a { + display: block; + line-height: 2.5em; + margin: 4px 0; + } + + .profile, + .profile .profile-info { + overflow-wrap: break-word; + word-wrap: break-word; + overflow: hidden; + } + + .directory-results { + flex-flow: column; + } + + .directory-results > aside { + order: 2; + } + + .directory-results > section { + order: 1; + } + +} + +/* The moment the header starts getting squashed */ +@media screen and (max-width: 520px) { + .homepage-wrapper { + margin: 30px auto; + } + .homepage-wrapper .header { + font-size: 40px; + background-size: 36px; + display: inline-block; + margin-left: 18px; + width: 275px; + } +} + +/* close to mobile in portrait */ +@media screen and (max-width: 400px) { + + .profile .profile-photo { + width: 60px; + border-radius: 11.25px; + margin: 8px 4px; + } + .profile .profile-info .url { + display: none; + } + +} diff --git a/boot.php b/boot.php index 786f3045..1c869c39 100755 --- a/boot.php +++ b/boot.php @@ -1,419 +1,347 @@ \r\n"); +define('EOL', "
\r\n"); -define ( 'REGISTER_CLOSED', 0); -define ( 'REGISTER_APPROVE', 1); -define ( 'REGISTER_OPEN', 2); +define('REGISTER_CLOSED', 0); +define('REGISTER_APPROVE', 1); +define('REGISTER_OPEN', 2); -define ( 'DIRECTION_NONE', 0); -define ( 'DIRECTION_IN', 1); -define ( 'DIRECTION_OUT', 2); -define ( 'DIRECTION_BOTH', 3); +define('DIRECTION_NONE', 0); +define('DIRECTION_IN', 1); +define('DIRECTION_OUT', 2); +define('DIRECTION_BOTH', 3); -define ( 'NOTIFY_INTRO', 0x0001 ); -define ( 'NOTIFY_CONFIRM', 0x0002 ); -define ( 'NOTIFY_WALL', 0x0004 ); -define ( 'NOTIFY_COMMENT', 0x0008 ); -define ( 'NOTIFY_MAIL', 0x0010 ); +define('NOTIFY_INTRO', 0x0001); +define('NOTIFY_CONFIRM', 0x0002); +define('NOTIFY_WALL', 0x0004); +define('NOTIFY_COMMENT', 0x0008); +define('NOTIFY_MAIL', 0x0010); -define ( 'NAMESPACE_DFRN' , 'http://purl.org/macgirvin/dfrn/1.0' ); +define('NAMESPACE_DFRN', 'http://purl.org/macgirvin/dfrn/1.0'); /** * log levels */ +define('LOGGER_NORMAL', 0); +define('LOGGER_TRACE', 1); +define('LOGGER_DEBUG', 2); +define('LOGGER_DATA', 3); +define('LOGGER_ALL', 4); -define ( 'LOGGER_NORMAL', 0 ); -define ( 'LOGGER_TRACE', 1 ); -define ( 'LOGGER_DEBUG', 2 ); -define ( 'LOGGER_DATA', 3 ); -define ( 'LOGGER_ALL', 4 ); - - -if(! class_exists('App')) { -class App { - - public $module_loaded = false; - public $query_string; - public $config; - public $page; - public $profile; - public $user; - public $cid; - public $contact; - public $content; - public $data; - public $error = false; - public $cmd; - public $argv; - public $argc; - public $module; - public $pager; - public $strings; - public $path; - - private $scheme; - private $hostname; - private $baseurl; - private $db; - - function __construct() { - - $this->config = array(); - $this->page = array(); - $this->pager= array(); - - $this->scheme = ((isset($_SERVER['HTTPS']) - && ($_SERVER['HTTPS'])) ? 'https' : 'http' ); - $this->hostname = str_replace('www.','', - $_SERVER['SERVER_NAME']); - set_include_path("include/$this->hostname" - . PATH_SEPARATOR . 'include' - . PATH_SEPARATOR . '.' ); - - if(substr($_SERVER['QUERY_STRING'],0,2) == "q=") - $_SERVER['QUERY_STRING'] = substr($_SERVER['QUERY_STRING'],2); - - $this->query_string = $_SERVER['QUERY_STRING']; - - $this->cmd = trim($_GET['q'],'/'); - - - $this->argv = explode('/',$this->cmd); - $this->argc = count($this->argv); - if((array_key_exists('0',$this->argv)) && strlen($this->argv[0])) { - $this->module = $this->argv[0]; - } - else { - $this->module = 'directory'; - } - - $this->pager['page'] = ((x($_GET,'page')) ? $_GET['page'] : 1); - $this->pager['itemspage'] = 50; - $this->pager['start'] = ($this->pager['page'] * $this->pager['itemspage']) - $this->pager['itemspage']; - $this->pager['total'] = 0; - } - - function get_baseurl($ssl = false) { - if(strlen($this->baseurl)) - return $this->baseurl; - - $this->baseurl = (($ssl) ? 'https' : $this->scheme) . "://" . $this->hostname - . ((isset($this->path) && strlen($this->path)) - ? '/' . $this->path : '' ); - return $this->baseurl; - } - - function set_baseurl($url) { - $this->baseurl = $url; - $this->hostname = basename($url); - } - - function get_hostname() { - return $this->hostname; - } - - function set_hostname($h) { - $this->hostname = $h; - } - - function set_path($p) { - $this->path = ltrim(trim($p),'/'); - } - - function get_path() { - return $this->path; - } - - function set_pager_total($n) { - $this->pager['total'] = intval($n); - } - - function set_pager_itemspage($n) { - $this->pager['itemspage'] = intval($n); - $this->pager['start'] = ($this->pager['page'] * $this->pager['itemspage']) - $this->pager['itemspage']; - - } - - function init_pagehead() { - if(file_exists("view/head.tpl")) - $s = file_get_contents("view/head.tpl"); - $this->page['htmlhead'] = replace_macros($s,array( - '$baseurl' => $this->get_baseurl() - )); - } - -}} - - -if(! function_exists('x')) { -function x($s,$k = NULL) { - if($k != NULL) { - if((is_array($s)) && (array_key_exists($k,$s))) { - if($s[$k]) - return (int) 1; - return (int) 0; - } - return false; - } - else { - if(isset($s)) { - if($s) { - return (int) 1; +if (!function_exists('x')) { + function x($s, $k = null) + { + if ($k != null) { + if ((is_array($s)) && (array_key_exists($k, $s))) { + if ($s[$k]) { + return (int) 1; + } + return (int) 0; } - return (int) 0; + return false; + } else { + if (isset($s)) { + if ($s) { + return (int) 1; + } + return (int) 0; + } + return false; + } + } +} + +if (!function_exists('system_unavailable')) { + function system_unavailable() + { + include('system_unavailable.php'); + killme(); + } +} + +if (!function_exists('logger')) { + function logger($msg, $level = 0) + { + $debugging = 1; + $loglevel = LOGGER_ALL; + $logfile = 'logfile.out'; + + if ((!$debugging) || (!$logfile) || ($level > $loglevel)) { + return; + } + require_once('include/datetime.php'); + + @file_put_contents($logfile, datetime_convert() . ':' . ' ' . $msg . "\n", FILE_APPEND); + return; + } +} + + +if (!function_exists('replace_macros')) { + function replace_macros($s, $r) + { + $search = array(); + $replace = array(); + + if (is_array($r) && count($r)) { + foreach ($r as $k => $v) { + $search[] = $k; + $replace[] = $v; + } + } + return str_replace($search, $replace, $s); + } +} + + +if (!function_exists('load_translation_table')) { + function load_translation_table($lang) + { + global $a; + } +} + +if (!function_exists('t')) { + function t($s) + { + global $a; + + if ($a->strings[$s]) { + return $a->strings[$s]; + } + return $s; + } +} + +if (!function_exists('fetch_url')) { + function fetch_url($url, $binary = false, $timeout = 20) + { + $ch = curl_init($url); + if (!$ch) { + return false; + } + + curl_setopt($ch, CURLOPT_HEADER, 0); + curl_setopt($ch, CURLOPT_TIMEOUT, max(intval($timeout), 1)); //Minimum of 1 second timeout. + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); + curl_setopt($ch, CURLOPT_MAXREDIRS, 8); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + if ($binary) { + curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1); + } + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); + $s = curl_exec($ch); + curl_close($ch); + return($s); + } +} + +if (!function_exists('post_url')) { + function post_url($url, $params) + { + $ch = curl_init($url); + if (!$ch) { + return false; + } + + curl_setopt($ch, CURLOPT_HEADER, 0); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); + curl_setopt($ch, CURLOPT_MAXREDIRS, 8); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_POSTFIELDS, $params); + $s = curl_exec($ch); + curl_close($ch); + return($s); + } +} + +if (!function_exists('random_string')) { + function random_string() + { + return(hash('sha256', uniqid(rand(), true))); + } +} + +if (!function_exists('notags')) { + function notags($string) + { + // protect against :<> with high-bit set + return(str_replace(array("<", ">", "\xBA", "\xBC", "\xBE"), array('[', ']', '', '', ''), $string)); + } +} + +if (!function_exists('escape_tags')) { + function escape_tags($string) + { + return(htmlspecialchars($string)); + } +} + +if (!function_exists('login')) { + function login($register = false) + { + $o = ""; + $register_html = (($register) ? file_get_contents("view/register-link.tpl") : ""); + + + if (x($_SESSION, 'authenticated')) { + $o = file_get_contents("view/logout.tpl"); + } else { + $o = file_get_contents("view/login.tpl"); + + $o = replace_macros($o, array('$register_html' => $register_html)); + } + return $o; + } +} + +if (!function_exists('killme')) { + function killme() + { + session_write_close(); + closedb(); + exit; + } +} + +if (!function_exists('goaway')) { + function goaway($s) + { + header("Location: $s"); + killme(); + } +} + +if (!function_exists('local_user')) { + function local_user() + { + if ((x($_SESSION, 'authenticated')) && (x($_SESSION, 'uid'))) { + return $_SESSION['uid']; } return false; } -}} +} -if(! function_exists('system_unavailable')) { -function system_unavailable() { - include('system_unavailable.php'); - killme(); -}} - -if(! function_exists('logger')) { -function logger($msg,$level = 0) { - $debugging = 1; - $loglevel = LOGGER_ALL; - $logfile = 'logfile.out'; - - if((! $debugging) || (! $logfile) || ($level > $loglevel)) - return; - require_once('include/datetime.php'); - - @file_put_contents($logfile, datetime_convert() . ':' . ' ' . $msg . "\n", FILE_APPEND); - return; -}} - - -if(! function_exists('replace_macros')) { -function replace_macros($s,$r) { - - $search = array(); - $replace = array(); - - if(is_array($r) && count($r)) { - foreach ($r as $k => $v ) { - $search[] = $k; - $replace[] = $v; +if (!function_exists('notice')) { + function notice($s) + { + if (!isset($_SESSION['sysmsg'])) { + $_SESSION['sysmsg'] = ''; } + $_SESSION['sysmsg'] .= $s; } - return str_replace($search,$replace,$s); -}} +} - -if(! function_exists('load_translation_table')) { -function load_translation_table($lang) { - global $a; - -}} - -if(! function_exists('t')) { -function t($s) { - global $a; - - if($a->strings[$s]) - return $a->strings[$s]; - return $s; -}} - - - - -if(! function_exists('fetch_url')) { -function fetch_url($url,$binary = false, $timeout=20) { - $ch = curl_init($url); - if(! $ch) return false; - - curl_setopt($ch, CURLOPT_HEADER, 0); - curl_setopt($ch, CURLOPT_TIMEOUT, max(intval($timeout), 1)); //Minimum of 1 second timeout. - curl_setopt($ch, CURLOPT_FOLLOWLOCATION,true); - curl_setopt($ch, CURLOPT_MAXREDIRS,8); - curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); - if($binary) - curl_setopt($ch, CURLOPT_BINARYTRANSFER,1); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); - $s = curl_exec($ch); - curl_close($ch); - return($s); -}} - - -if(! function_exists('post_url')) { -function post_url($url,$params) { - $ch = curl_init($url); - if(! $ch) return false; - - curl_setopt($ch, CURLOPT_HEADER, 0); - curl_setopt($ch, CURLOPT_FOLLOWLOCATION,true); - curl_setopt($ch, CURLOPT_MAXREDIRS,8); - curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); - curl_setopt($ch, CURLOPT_POST,1); - curl_setopt($ch, CURLOPT_POSTFIELDS,$params); - $s = curl_exec($ch); - curl_close($ch); - return($s); -}} - - -if(! function_exists('random_string')) { -function random_string() { - return(hash('sha256',uniqid(rand(),true))); -}} - -if(! function_exists('notags')) { -function notags($string) { - // protect against :<> with high-bit set - return(str_replace(array("<",">","\xBA","\xBC","\xBE"), array('[',']','','',''), $string)); -}} - -if(! function_exists('escape_tags')) { -function escape_tags($string) { - - return(htmlspecialchars($string)); -}} - -if(! function_exists('login')) { -function login($register = false) { - $o = ""; - $register_html = (($register) ? file_get_contents("view/register-link.tpl") : ""); - - - if(x($_SESSION,'authenticated')) { - $o = file_get_contents("view/logout.tpl"); +if (!function_exists('hex2bin')) { + function hex2bin($s) + { + return(pack("H*", $s)); } - else { - $o = file_get_contents("view/login.tpl"); +} - $o = replace_macros($o,array('$register_html' => $register_html )); - } - return $o; -}} +if (!function_exists('paginate')) { + function paginate(&$a) + { + $o = ''; + $stripped = preg_replace("/&page=[0-9]*/", "", $a->query_string); + $stripped = str_replace('q=', '', $stripped); + $stripped = trim($stripped, '/'); + $pagenum = $a->pager['page']; + $url = $a->get_baseurl() . '/' . $stripped; + if ($a->pager['total'] > $a->pager['itemspage']) { + $o .= '
'; + if ($a->pager['page'] != 1) { + $o .= '' . "' . t('prev') . ' '; + } -if(! function_exists('killme')) { -function killme() { - session_write_close(); - closedb(); - exit; -}} + $o .= "" . t('first') . " "; -if(! function_exists('goaway')) { -function goaway($s) { - header("Location: $s"); - killme(); -}} - -if(! function_exists('local_user')) { -function local_user() { - if((x($_SESSION,'authenticated')) && (x($_SESSION,'uid'))) - return $_SESSION['uid']; - return false; -}} - -if(! function_exists('notice')) { -function notice($s) { - - $_SESSION['sysmsg'] .= $s; - -}} - -if(! function_exists('hex2bin')) { -function hex2bin($s) { - return(pack("H*",$s)); -}} - - - - - -if(! function_exists('paginate')) { -function paginate(&$a) { - $o = ''; - $stripped = ereg_replace("(&page=[0-9]*)","",$a->query_string); - $stripped = str_replace('q=','',$stripped); - $stripped = trim($stripped,'/'); - $pagenum = $a->pager['page']; - $url = $a->get_baseurl() . '/' . $stripped ; - - - if($a->pager['total'] > $a->pager['itemspage']) { - $o .= '
'; - if($a->pager['page'] != 1) - $o .= ''."pager['page'] - 1).'">' . t('prev') . ' '; - - $o .= "" . t('first') . " "; - - $numpages = $a->pager['total'] / $a->pager['itemspage']; + $numpages = $a->pager['total'] / $a->pager['itemspage']; $numstart = 1; - $numstop = $numpages; + $numstop = $numpages; - if($numpages > 14) { - $numstart = (($pagenum > 7) ? ($pagenum - 7) : 1); - $numstop = (($pagenum > ($numpages - 7)) ? $numpages : ($numstart + 14)); - } - - for($i = $numstart; $i <= $numstop; $i++){ - if($i == $a->pager['page']) - $o .= ''.(($i < 10) ? ' '.$i : $i); - else - $o .= "".(($i < 10) ? ' '.$i : $i).""; - $o .= ' '; + if ($numpages > 14) { + $numstart = (($pagenum > 7) ? ($pagenum - 7) : 1); + $numstop = (($pagenum > ($numpages - 7)) ? $numpages : ($numstart + 14)); + } + + for ($i = $numstart; $i <= $numstop; $i++) { + if ($i == $a->pager['page']) { + $o .= '' . (($i < 10) ? ' ' . $i : $i); + } else { + $o .= "" . (($i < 10) ? ' ' . $i : $i) . ""; + } + $o .= ' '; + } + + if (($a->pager['total'] % $a->pager['itemspage']) != 0) { + if ($i == $a->pager['page']) { + $o .= '' . (($i < 10) ? ' ' . $i : $i); + } else { + $o .= "" . (($i < 10) ? ' ' . $i : $i) . ""; + } + $o .= ' '; + } + + $lastpage = (($numpages > intval($numpages)) ? intval($numpages) + 1 : $numpages); + $o .= "" . t('last') . " "; + + if (($a->pager['total'] - ($a->pager['itemspage'] * $a->pager['page'])) > 0) { + $o .= '' . "' . t('next') . ''; + } + $o .= '
' . "\r\n"; } - - if(($a->pager['total'] % $a->pager['itemspage']) != 0) { - if($i == $a->pager['page']) - $o .= ''.(($i < 10) ? ' '.$i : $i); - else - $o .= "".(($i < 10) ? ' '.$i : $i).""; - $o .= ' '; - } - - $lastpage = (($numpages > intval($numpages)) ? intval($numpages)+1 : $numpages); - $o .= "" . t('last') . " "; - - if(($a->pager['total'] - ($a->pager['itemspage'] * $a->pager['page'])) > 0) - $o .= ''."pager['page'] + 1).'">' . t('next') . ''; - $o .= '
'."\r\n"; + return $o; } - return $o; -}} +} - -function get_my_url() { - if(x($_SESSION,'my_url')) +function get_my_url() +{ + if (x($_SESSION, 'my_url')) { return $_SESSION['my_url']; + } return false; } -function zrl($s,$force = false) { - if(! strlen($s)) +function zrl($s, $force = false) +{ + if (!strlen($s)) { return $s; - if((! strpos($s,'/profile/')) && (! $force)) + } + if ((!strpos($s, '/profile/')) && (!$force)) { return $s; - $achar = strpos($s,'?') ? '&' : '?'; + } + $achar = strpos($s, '?') ? '&' : '?'; $mine = get_my_url(); - if($mine and ! link_compare($mine,$s)) + if ($mine and ! link_compare($mine, $s)) { return $s . $achar . 'zrl=' . urlencode($mine); + } return $s; } -if(! function_exists('link_compare')) { -function link_compare($a,$b) { - if(strcasecmp(normalise_link($a),normalise_link($b)) === 0) - return true; - return false; -}} +if (!function_exists('link_compare')) { + function link_compare($a, $b) + { + if (strcasecmp(normalise_link($a), normalise_link($b)) === 0) { + return true; + } + return false; + } +} -if(! function_exists('normalise_link')) { -function normalise_link($url) { - $ret = str_replace(array('https:','//www.'), array('http:','//'), $url); - return(rtrim($ret,'/')); -}} +if (!function_exists('normalise_link')) { + function normalise_link($url) + { + $ret = str_replace(array('https:', '//www.'), array('http:', '//'), $url); + return(rtrim($ret, '/')); + } +} diff --git a/composer.json b/composer.json new file mode 100644 index 00000000..9dd0b869 --- /dev/null +++ b/composer.json @@ -0,0 +1,11 @@ +{ + "name": "friendica/dir", + "description": "The internet is our social network", + "license": "AGPL3", + "autoload": { + "psr-4": {"Friendica\\Directory\\": "src"} + }, + "require": { + "php": ">=5.3" + } +} \ No newline at end of file diff --git a/dfrndir.sql b/dfrndir.sql index 118e61e9..8d88a9d7 100644 --- a/dfrndir.sql +++ b/dfrndir.sql @@ -1,18 +1,7 @@ --- phpMyAdmin SQL Dump --- version 3.3.10.4 --- http://www.phpmyadmin.net --- --- Generation Time: May 15, 2012 at 11:03 PM --- Server version: 5.1.53 --- PHP Version: 5.3.5 +-- Generation Time: Apr 21, 2017 at 03:58 AM -SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; - - -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8 */; +SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; +SET time_zone = "+00:00"; -- -- @@ -24,12 +13,11 @@ SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; -- CREATE TABLE IF NOT EXISTS `flag` ( - `id` int(11) NOT NULL AUTO_INCREMENT, +`id` int(11) NOT NULL, `pid` int(11) NOT NULL, `reason` int(11) NOT NULL, - `total` int(11) NOT NULL DEFAULT '0', - PRIMARY KEY (`id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; + `total` int(11) NOT NULL DEFAULT '0' +) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- -------------------------------------------------------- @@ -38,12 +26,11 @@ CREATE TABLE IF NOT EXISTS `flag` ( -- CREATE TABLE IF NOT EXISTS `photo` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, +`id` int(10) unsigned NOT NULL, `profile-id` int(11) NOT NULL, `data` mediumblob NOT NULL, - `score` float NOT NULL DEFAULT '0', - PRIMARY KEY (`id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ; + `score` float NOT NULL DEFAULT '0' +) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- -------------------------------------------------------- @@ -52,7 +39,7 @@ CREATE TABLE IF NOT EXISTS `photo` ( -- CREATE TABLE IF NOT EXISTS `profile` ( - `id` int(11) NOT NULL AUTO_INCREMENT, +`id` int(11) NOT NULL, `name` char(255) NOT NULL, `nurl` char(255) NOT NULL, `comm` tinyint(1) NOT NULL DEFAULT '0', @@ -61,25 +48,13 @@ CREATE TABLE IF NOT EXISTS `profile` ( `region` char(255) NOT NULL, `postal-code` char(32) NOT NULL, `country-name` char(255) NOT NULL, - `gender` char(32) NOT NULL, - `marital` char(255) NOT NULL, `homepage` char(255) NOT NULL, `photo` char(255) NOT NULL, `tags` mediumtext NOT NULL, `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `updated` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - `censored` tinyint(4) NOT NULL DEFAULT '0', - PRIMARY KEY (`id`), - KEY `name` (`name`), - KEY `nurl` (`nurl`), - KEY `comm` (`comm`), - KEY `pdesc` (`pdesc`), - KEY `locality` (`locality`), - KEY `region` (`region`), - KEY `country-name` (`country-name`), - KEY `homepage` (`homepage`), - FULLTEXT KEY `tags` (`tags`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ; + `censored` tinyint(4) NOT NULL DEFAULT '0' +) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- -------------------------------------------------------- @@ -88,14 +63,11 @@ CREATE TABLE IF NOT EXISTS `profile` ( -- CREATE TABLE IF NOT EXISTS `session` ( - `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, +`id` bigint(20) unsigned NOT NULL, `sid` char(255) NOT NULL, `data` text NOT NULL, - `expire` int(10) unsigned NOT NULL, - PRIMARY KEY (`id`), - KEY `sid` (`sid`), - KEY `expire` (`expire`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ; + `expire` int(10) unsigned NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- -------------------------------------------------------- @@ -104,7 +76,7 @@ CREATE TABLE IF NOT EXISTS `session` ( -- CREATE TABLE IF NOT EXISTS `site` ( - `id` int(11) NOT NULL AUTO_INCREMENT, +`id` int(11) NOT NULL, `name` char(255) NOT NULL, `url` char(255) NOT NULL, `version` char(16) NOT NULL, @@ -113,37 +85,8 @@ CREATE TABLE IF NOT EXISTS `site` ( `info` text NOT NULL, `admin_name` char(255) NOT NULL, `admin_profile` char(255) NOT NULL, - `updated` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - PRIMARY KEY (`id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ; - --- -------------------------------------------------------- - --- --- Table structure for table `tag` --- - -CREATE TABLE IF NOT EXISTS `tag` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `term` char(255) NOT NULL, - `nurl` char(255) NOT NULL, - PRIMARY KEY (`id`), - KEY `term` (`term`), - KEY `nurl` (`nurl`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ; - --- -------------------------------------------------------- - --- --- Table structure for table `user` --- - -CREATE TABLE IF NOT EXISTS `user` ( - `uid` int(11) NOT NULL AUTO_INCREMENT, - `email` char(255) NOT NULL, - `password` char(255) NOT NULL, - PRIMARY KEY (`uid`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ; + `updated` datetime NOT NULL DEFAULT '0000-00-00 00:00:00' +) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- -------------------------------------------------------- @@ -152,76 +95,262 @@ CREATE TABLE IF NOT EXISTS `user` ( -- CREATE TABLE IF NOT EXISTS `site-health` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, +`id` int(10) unsigned NOT NULL, `base_url` varchar(255) NOT NULL, - `health_score` int(11) NOT NULL DEFAULT 0, - `no_scrape_url` varchar(255) NULL DEFAULT NULL, + `effective_base_url` varchar(255) DEFAULT NULL, + `health_score` int(11) NOT NULL DEFAULT '0', + `no_scrape_url` varchar(255) DEFAULT NULL, `dt_first_noticed` datetime NOT NULL, - `dt_last_seen` datetime NULL DEFAULT NULL, - `dt_last_probed` datetime NULL DEFAULT NULL, - `dt_last_heartbeat` datetime NULL DEFAULT NULL, - `name` varchar(255) NULL DEFAULT NULL, - `version` varchar(255) NULL DEFAULT NULL, - `plugins` text NULL DEFAULT NULL, - `reg_policy` char(32) NULL DEFAULT NULL, - `info` text NULL DEFAULT NULL, - `admin_name` varchar(255) NULL DEFAULT NULL, - `admin_profile` varchar(255) NULL DEFAULT NULL, - `ssl_state` bit(1) NULL DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `base_url` (`base_url`), - KEY `health_score` (`health_score`), - KEY `dt_last_seen` (`dt_last_seen`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ; + `dt_last_seen` datetime DEFAULT NULL, + `dt_last_probed` datetime DEFAULT NULL, + `dt_last_heartbeat` datetime DEFAULT NULL, + `name` varchar(255) DEFAULT NULL, + `version` varchar(255) DEFAULT NULL, + `plugins` text, + `reg_policy` char(32) DEFAULT NULL, + `info` text, + `admin_name` varchar(255) DEFAULT NULL, + `admin_profile` varchar(255) DEFAULT NULL, + `ssl_state` bit(1) DEFAULT NULL, + `ssl_grade` varchar(3) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +-- -------------------------------------------------------- + +-- +-- Table structure for table `site-probe` +-- CREATE TABLE IF NOT EXISTS `site-probe` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, +`id` int(10) unsigned NOT NULL, `site_health_id` int(10) unsigned NOT NULL, `dt_performed` datetime NOT NULL, - `request_time` int(10) unsigned NOT NULL, - PRIMARY KEY (`id`), - KEY `site_health_id` (`site_health_id`), - KEY `dt_performed` (`dt_performed`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ; + `request_time` int(10) unsigned NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +-- -------------------------------------------------------- + +-- +-- Table structure for table `site-scrape` +-- CREATE TABLE IF NOT EXISTS `site-scrape` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, +`id` int(10) unsigned NOT NULL, `site_health_id` int(10) unsigned NOT NULL, `dt_performed` datetime NOT NULL, `request_time` int(10) unsigned NOT NULL, `scrape_time` int(10) unsigned NOT NULL, `photo_time` int(10) unsigned NOT NULL, - `total_time` int(10) unsigned NOT NULL, - PRIMARY KEY (`id`), - KEY `site_health_id` (`site_health_id`), - KEY `dt_performed` (`dt_performed`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ; + `total_time` int(10) unsigned NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `sync-pull-queue` +-- + +CREATE TABLE IF NOT EXISTS `sync-pull-queue` ( + `url` varchar(255) NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `sync-push-queue` +-- + +CREATE TABLE IF NOT EXISTS `sync-push-queue` ( + `url` varchar(255) NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `sync-targets` +-- CREATE TABLE IF NOT EXISTS `sync-targets` ( `base_url` varchar(255) NOT NULL, `pull` bit(1) NOT NULL DEFAULT b'0', `push` bit(1) NOT NULL DEFAULT b'1', - `dt_last_pull` bigint unsigned NULL DEFAULT NULL, - PRIMARY KEY (`base_url`), - KEY `push` (`push`), - KEY `pull` (`pull`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ; + `dt_last_pull` bigint(20) unsigned DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8; -CREATE TABLE IF NOT EXISTS `sync-push-queue` ( - `url` varchar(255) NOT NULL, - PRIMARY KEY (`url`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 ; +-- -------------------------------------------------------- -CREATE TABLE IF NOT EXISTS `sync-pull-queue` ( - `url` varchar(255) NOT NULL, - PRIMARY KEY (`url`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 ; +-- +-- Table structure for table `sync-timestamps` +-- CREATE TABLE IF NOT EXISTS `sync-timestamps` ( `url` varchar(255) NOT NULL, - `modified` datetime NOT NULL, - PRIMARY KEY (`url`), - KEY `modified` (`modified`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 ; + `modified` datetime NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `tag` +-- + +CREATE TABLE IF NOT EXISTS `tag` ( +`id` int(11) NOT NULL, + `term` char(255) NOT NULL, + `nurl` char(255) NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `user` +-- + +CREATE TABLE IF NOT EXISTS `user` ( +`uid` int(11) NOT NULL, + `email` char(255) NOT NULL, + `password` char(255) NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Indexes for dumped tables +-- + +-- +-- Indexes for table `flag` +-- +ALTER TABLE `flag` + ADD PRIMARY KEY (`id`); + +-- +-- Indexes for table `photo` +-- +ALTER TABLE `photo` + ADD PRIMARY KEY (`id`); + +-- +-- Indexes for table `profile` +-- +ALTER TABLE `profile` + ADD PRIMARY KEY (`id`), ADD KEY `name` (`name`), ADD KEY `nurl` (`nurl`), ADD KEY `comm` (`comm`), ADD KEY `pdesc` (`pdesc`), ADD KEY `locality` (`locality`), ADD KEY `region` (`region`), ADD KEY `country-name` (`country-name`), ADD KEY `homepage` (`homepage`), ADD FULLTEXT KEY `tags` (`tags`), ADD FULLTEXT KEY `profile-ft` (`name`,`pdesc`,`homepage`,`locality`,`region`,`country-name`,`tags`); + +-- +-- Indexes for table `session` +-- +ALTER TABLE `session` + ADD PRIMARY KEY (`id`), ADD KEY `sid` (`sid`), ADD KEY `expire` (`expire`); + +-- +-- Indexes for table `site` +-- +ALTER TABLE `site` + ADD PRIMARY KEY (`id`); + +-- +-- Indexes for table `site-health` +-- +ALTER TABLE `site-health` + ADD PRIMARY KEY (`id`), ADD KEY `base_url` (`base_url`), ADD KEY `health_score` (`health_score`), ADD KEY `dt_last_seen` (`dt_last_seen`); + +-- +-- Indexes for table `site-probe` +-- +ALTER TABLE `site-probe` + ADD PRIMARY KEY (`id`), ADD KEY `site_health_id` (`site_health_id`), ADD KEY `dt_performed` (`dt_performed`); + +-- +-- Indexes for table `site-scrape` +-- +ALTER TABLE `site-scrape` + ADD PRIMARY KEY (`id`), ADD KEY `site_health_id` (`site_health_id`), ADD KEY `dt_performed` (`dt_performed`); + +-- +-- Indexes for table `sync-pull-queue` +-- +ALTER TABLE `sync-pull-queue` + ADD PRIMARY KEY (`url`); + +-- +-- Indexes for table `sync-push-queue` +-- +ALTER TABLE `sync-push-queue` + ADD PRIMARY KEY (`url`); + +-- +-- Indexes for table `sync-targets` +-- +ALTER TABLE `sync-targets` + ADD PRIMARY KEY (`base_url`), ADD KEY `push` (`push`), ADD KEY `pull` (`pull`); + +-- +-- Indexes for table `sync-timestamps` +-- +ALTER TABLE `sync-timestamps` + ADD PRIMARY KEY (`url`), ADD KEY `modified` (`modified`); + +-- +-- Indexes for table `tag` +-- +ALTER TABLE `tag` + ADD PRIMARY KEY (`id`), ADD KEY `term` (`term`), ADD KEY `nurl` (`nurl`); + +-- +-- Indexes for table `user` +-- +ALTER TABLE `user` + ADD PRIMARY KEY (`uid`); + +-- +-- AUTO_INCREMENT for dumped tables +-- + +-- +-- AUTO_INCREMENT for table `flag` +-- +ALTER TABLE `flag` +MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=6; +-- +-- AUTO_INCREMENT for table `photo` +-- +ALTER TABLE `photo` +MODIFY `id` int(10) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=1486; +-- +-- AUTO_INCREMENT for table `profile` +-- +ALTER TABLE `profile` +MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=1488; +-- +-- AUTO_INCREMENT for table `session` +-- +ALTER TABLE `session` +MODIFY `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=104; +-- +-- AUTO_INCREMENT for table `site` +-- +ALTER TABLE `site` +MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; +-- +-- AUTO_INCREMENT for table `site-health` +-- +ALTER TABLE `site-health` +MODIFY `id` int(10) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=1513; +-- +-- AUTO_INCREMENT for table `site-probe` +-- +ALTER TABLE `site-probe` +MODIFY `id` int(10) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=6651; +-- +-- AUTO_INCREMENT for table `site-scrape` +-- +ALTER TABLE `site-scrape` +MODIFY `id` int(10) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=21048; +-- +-- AUTO_INCREMENT for table `tag` +-- +ALTER TABLE `tag` +MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=2322; +-- +-- AUTO_INCREMENT for table `user` +-- +ALTER TABLE `user` +MODIFY `uid` int(11) NOT NULL AUTO_INCREMENT; \ No newline at end of file diff --git a/example.php b/example.php new file mode 100644 index 00000000..5f4ef6c8 --- /dev/null +++ b/example.php @@ -0,0 +1,14 @@ +sayHello(); diff --git a/htconfig.php b/htconfig.php new file mode 100644 index 00000000..d86fcff6 --- /dev/null +++ b/htconfig.php @@ -0,0 +1,91 @@ +config['sitename'] = "EXPERIMENTAL Friendica public directory"; + +//Statistic display settings. +$a->config['stats'] = array( + + //For site health, the max age for which to display data. + 'maxDataAge' => 3600*24*30*4 //120 days = ~4 months + +); + +//Settings related to the syncing feature. +$a->config['syncing'] = array( + + //Pulling may be quite intensive at first when it has to do a full sync and your directory is empty. + //This timeout should be shorter than your cronjob interval. Preferably with a little breathing room. + 'timeout' => 3*60, //3 minutes + + //Push new submits to the `sync-target` entries? + 'enable_pushing' => true, + + //Maximum amount of items per batch per target to push to other sync-targets. + //For example: 3 targets x20 items = 60 requests. + 'max_push_items' => 10, + + //Pull updates from the `sync-target` entries? + 'enable_pulling' => true, + + //This is your normal amount of threads for pulling. + //With regular intervals, there's no need to give this a high value. + //But when your server is brand new, you may want to keep this high for the first day or two. + 'pulling_threads' => 25, + + //How many items should we crawl per sync? + 'max_pull_items' => 250 + +); + +//Things related to site-health monitoring. +$a->config['site-health'] = array( + + //Wait for at least ... before probing a site again. + //The longer this value, the more "stable" site-healths will be over time. + //Note: If a bad (negative) health site submits something, a probe will be performed regardless. + 'min_probe_delay' => 24*3600, // 1 day + + //Probes get a simple /friendica/json file from the server. + //Feel free to set this timeout to a very tight value. + 'probe_timeout' => 5, // seconds + + //Imports should be fast. Feel free to prioritize healthy sites. + 'skip_import_threshold' => -20 + +); + +//Things related to the maintenance cronjob. +$a->config['maintenance'] = array( + + //This is to prevent I/O blocking. Will cost you some RAM overhead though. + //A good server should handle much more than this default, so you can tweak this. + 'threads' => 10, + + //Limit the amount of scrapes per execution of the maintainer. + //This will depend a lot on the frequency with which you call the maintainer. + //If you have 10 threads and 80 max_scrapes, that means each thread will handle 8 scrapes. + 'max_scrapes' => 80, + + //Wait for at least ... before scraping a profile again. + 'min_scrape_delay' => 3*24*3600, // 3 days + + //At which health value should we start removing profiles? + 'remove_profile_health_threshold' => -60 + +); \ No newline at end of file diff --git a/images/b_block.gif b/images/b_block.gif old mode 100755 new mode 100644 diff --git a/images/b_drop.gif b/images/b_drop.gif old mode 100755 new mode 100644 diff --git a/images/b_drop.png b/images/b_drop.png old mode 100755 new mode 100644 diff --git a/images/b_drophide.gif b/images/b_drophide.gif old mode 100755 new mode 100644 diff --git a/images/b_dropshow.gif b/images/b_dropshow.gif old mode 100755 new mode 100644 diff --git a/images/b_edit.gif b/images/b_edit.gif old mode 100755 new mode 100644 diff --git a/images/b_edit.png b/images/b_edit.png old mode 100755 new mode 100644 diff --git a/images/blue_flag_16.png b/images/blue_flag_16.png old mode 100755 new mode 100644 diff --git a/images/camera-icon.gif b/images/camera-icon.gif old mode 100755 new mode 100644 diff --git a/images/default-profile-sm.jpg b/images/default-profile-sm.jpg old mode 100755 new mode 100644 diff --git a/images/default-profile.jpg b/images/default-profile.jpg old mode 100755 new mode 100644 diff --git a/images/dfrn.gif b/images/dfrn.gif old mode 100755 new mode 100644 diff --git a/images/dislike.gif b/images/dislike.gif old mode 100755 new mode 100644 diff --git a/images/friendica-32.png b/images/friendica-32.png old mode 100755 new mode 100644 diff --git a/images/friendica.svg b/images/friendica.svg new file mode 100644 index 00000000..b001c0e0 --- /dev/null +++ b/images/friendica.svg @@ -0,0 +1,185 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + diff --git a/images/friendika-128.jpg b/images/friendika-128.jpg old mode 100755 new mode 100644 diff --git a/images/friendika-128.png b/images/friendika-128.png old mode 100755 new mode 100644 diff --git a/images/friendika-16.ico b/images/friendika-16.ico old mode 100755 new mode 100644 diff --git a/images/friendika-16.jpg b/images/friendika-16.jpg old mode 100755 new mode 100644 diff --git a/images/friendika-16.png b/images/friendika-16.png old mode 100755 new mode 100644 diff --git a/images/friendika-1600.png b/images/friendika-1600.png old mode 100755 new mode 100644 diff --git a/images/friendika-256.jpg b/images/friendika-256.jpg old mode 100755 new mode 100644 diff --git a/images/friendika-256.png b/images/friendika-256.png old mode 100755 new mode 100644 diff --git a/images/friendika-32.jpg b/images/friendika-32.jpg old mode 100755 new mode 100644 diff --git a/images/friendika-32.png b/images/friendika-32.png old mode 100755 new mode 100644 diff --git a/images/friendika-64.jpg b/images/friendika-64.jpg old mode 100755 new mode 100644 diff --git a/images/friendika-64.png b/images/friendika-64.png old mode 100755 new mode 100644 diff --git a/images/friendika.svg b/images/friendika.svg old mode 100755 new mode 100644 diff --git a/images/larrow.gif b/images/larrow.gif old mode 100755 new mode 100644 diff --git a/images/larrw.gif b/images/larrw.gif old mode 100755 new mode 100644 diff --git a/images/like.gif b/images/like.gif old mode 100755 new mode 100644 diff --git a/images/link-icon.gif b/images/link-icon.gif old mode 100755 new mode 100644 diff --git a/images/lock_icon.gif b/images/lock_icon.gif old mode 100755 new mode 100644 diff --git a/images/lrarrow.gif b/images/lrarrow.gif old mode 100755 new mode 100644 diff --git a/images/no.gif b/images/no.gif old mode 100755 new mode 100644 diff --git a/images/pen.png b/images/pen.png old mode 100755 new mode 100644 diff --git a/images/penhover.png b/images/penhover.png old mode 100755 new mode 100644 diff --git a/images/rarrow.gif b/images/rarrow.gif old mode 100755 new mode 100644 diff --git a/images/rarrw.gif b/images/rarrw.gif old mode 100755 new mode 100644 diff --git a/images/rotator.gif b/images/rotator.gif old mode 100755 new mode 100644 diff --git a/images/shield_2_16.png b/images/shield_2_16.png old mode 100755 new mode 100644 diff --git a/images/star.jpg b/images/star.jpg old mode 100755 new mode 100644 diff --git a/images/unlock_icon.gif b/images/unlock_icon.gif old mode 100755 new mode 100644 diff --git a/include/#rockstar.php# b/include/#rockstar.php# deleted file mode 100755 index 0ffa0010..00000000 --- a/include/#rockstar.php# +++ /dev/null @@ -1,166 +0,0 @@ -set_baseurl(get_config('system','url')); - - $u = q("SELECT * FROM `user` WHERE 1 LIMIT 1"); - if(! count($u)) - killme(); - - $uid = $u[0]['uid']; - $nickname = $u[0]['nickname']; - - $intros = q("SELECT `intro`.*, `intro`.`id` AS `intro_id`, `contact`.* - FROM `intro` LEFT JOIN `contact` ON `contact`.`id` = `intro`.`contact-id` - WHERE `intro`.`blocked` = 0 AND `intro`.`ignore` = 0"); - - if(! count($intros)) - return; - - - foreach($intros as $intro) { - - $intro_id = intval($intro['intro_id']); - - $dfrn_id = $intro['issued-id']; - $contact_id = $intro['contact-id']; - $relation = $intro['rel']; - $site_pubkey = $intro['site-pubkey']; - $dfrn_confirm = $intro['confirm']; - $aes_allow = $intro['aes_allow']; - - $res=openssl_pkey_new(array( - 'digest_alg' => 'whirlpool', - 'private_key_bits' => 4096, - 'encrypt_key' => false )); - - $private_key = ''; - - openssl_pkey_export($res, $private_key); - - $pubkey = openssl_pkey_get_details($res); - $public_key = $pubkey["key"]; - - $r = q("UPDATE `contact` SET `issued-pubkey` = '%s', `prvkey` = '%s' WHERE `id` = %d LIMIT 1", - dbesc($public_key), - dbesc($private_key), - intval($contact_id) - ); - - $params = array(); - - $src_aes_key = random_string(); - $result = ""; - - openssl_private_encrypt($dfrn_id,$result,$u[0]['prvkey']); - - $params['dfrn_id'] = $result; - $params['public_key'] = $public_key; - - $my_url = $a->get_baseurl() . '/profile/' . $nickname ; - - openssl_public_encrypt($my_url, $params['source_url'], $site_pubkey); - - if($aes_allow && function_exists('openssl_encrypt')) { - openssl_public_encrypt($src_aes_key, $params['aes_key'], $site_pubkey); - $params['public_key'] = openssl_encrypt($public_key,'AES-256-CBC',$src_aes_key); - } - - $res = post_url($dfrn_confirm,$params); - - $xml = simplexml_load_string($res); - $status = (int) $xml->status; - switch($status) { - case 0: - break; - case 1: - // birthday paradox - generate new dfrn-id and fall through. - - $new_dfrn_id = random_string(); - $r = q("UPDATE contact SET `issued-id` = '%s' WHERE `id` = %d LIMIT 1", - dbesc($new_dfrn_id), - intval($contact_id) - ); - case 2: - break; - - case 3: - default: - break; - } - - if(($status == 0 || $status == 3) && ($intro_id)) { - - // delete the notification - - $r = q("DELETE FROM `intro` WHERE `id` = %d LIMIT 1", - intval($intro_id) - ); - } - if($status != 0) - killme(); - - require_once("Photo.php"); - - $photo_failure = false; - - - $filename = basename($intro['photo']); - $img_str = fetch_url($intro['photo'],true); - $img = new Photo($img_str); - if($img) { - - $img->scaleImageSquare(175); - $hash = hash('md5',uniqid(mt_rand(),true)); - - $r = $img->store($contact_id, $hash, $filename, t('Contact Photos'), 4 ); - - if($r === false) - $photo_failure = true; - $img->scaleImage(80); - - $r = $img->store($contact_id, $hash, $filename, t('Contact Photos'), 5 ); - - if($r === false) - $photo_failure = true; - - $photo = $a->get_baseurl() . '/photo/' . $hash . '-4.jpg'; - $thumb = $a->get_baseurl() . '/photo/' . $hash . '-5.jpg'; - } - else - $photo_failure = true; - - if($photo_failure) { - $photo = $a->get_baseurl() . '/images/default-profile.jpg'; - $thumb = $a->get_baseurl() . '/images/default-profile-sm.jpg'; - } - - $r = q("UPDATE `contact` SET `photo` = '%s', `thumb` = '%s', `rel` = %d, - `name-date` = '%s', `uri-date` = '%s', `avatar-date` = '%s', - `readonly` = %d, `profile-id` = %d, `blocked` = 0, `pending` = 0, - `network` = 'dfrn' WHERE `id` = %d LIMIT 1", - dbesc($photo), - dbesc($thumb), - intval(($relation == DIRECTION_OUT) ? DIRECTION_BOTH : DIRECTION_IN), - dbesc(datetime_convert()), - dbesc(datetime_convert()), - dbesc(datetime_convert()), - intval((x($a->config,'rockstar-readonly')) ? $a->config['rockstar-readonly'] : 0), - intval((x($a->config,'rockstar-profile')) ? $a->config['rockstar-profile'] : 0), - intval($contact_id) - ); - - } - killme(); - diff --git a/include/Photo.php b/include/Photo.php old mode 100755 new mode 100644 index 1d1a8842..e5fd99be --- a/include/Photo.php +++ b/include/Photo.php @@ -186,5 +186,3 @@ class Photo { } } }} - - diff --git a/include/Scrape.php b/include/Scrape.php old mode 100755 new mode 100644 index a61d22d3..0c0a7326 --- a/include/Scrape.php +++ b/include/Scrape.php @@ -103,7 +103,7 @@ function scrape_dfrn($url, $max_nodes=3500) { $nodes_left = max(intval($max_nodes), $minNodes); $items = $dom->getElementsByTagName('*'); - $targets = array('fn', 'pdesc', 'photo', 'key', 'locality', 'region', 'postal-code', 'country-name', 'gender', 'marital'); + $targets = array('fn', 'pdesc', 'photo', 'key', 'locality', 'region', 'postal-code', 'country-name'); $targets_left = count($targets); foreach($items as $item) { if(attribute_contains($item->getAttribute('class'), 'vcard')) { @@ -141,16 +141,8 @@ function scrape_dfrn($url, $max_nodes=3500) { $ret['country-name'] = $x->textContent; $targets_left = pop_scrape_target($targets, 'country-name'); } - if(attribute_contains($x->getAttribute('class'),'x-gender')){ - $ret['gender'] = $x->textContent; - $targets_left = pop_scrape_target($targets, 'gender'); - } } } - if(attribute_contains($item->getAttribute('class'),'marital-text')){ - $ret['marital'] = $item->textContent; - $targets_left = pop_scrape_target($targets, 'marital'); - } $nodes_left--; if($nodes_left <= 0 || $targets_left <= 0) break; } @@ -191,4 +183,3 @@ function pop_scrape_target(&$array, $name) { unset($array[$at]); return count($array); }} - diff --git a/include/auth.php b/include/auth.php old mode 100755 new mode 100644 index fee336e8..72147d36 --- a/include/auth.php +++ b/include/auth.php @@ -72,5 +72,3 @@ function init_groups_visitor($contact_id) { } return $groups; }} - - diff --git a/include/bbcode.php b/include/bbcode.php old mode 100755 new mode 100644 diff --git a/include/cron_maintain.php b/include/cron_maintain.php index 33b164dd..960fe901 100644 --- a/include/cron_maintain.php +++ b/include/cron_maintain.php @@ -1,114 +1,130 @@ config['maintenance']['min_scrape_delay'])), + intval($a->config['maintenance']['max_scrapes']) +); + +//Nothing to do. +if (!$res || !count($res)) { + exit; +} + +//Close DB here. Threads need their private connection. +$db->getdb()->close(); + +//We need the scraper. +require_once 'include/submit.php'; + +//POSIX threads only. +if (!function_exists('pcntl_fork')) { + logger('Error: no pcntl_fork support. Are you running a different OS? Report an issue please.'); + die('Error: no pcntl_fork support. Are you running a different OS? Report an issue please.'); +} + +//Create the threads we need. +$items = count($res); +$threadc = min($a->config['maintenance']['threads'], $items); //Don't need more threads than items. +$threads = array(); + +//Debug... +if ($verbose) { + echo "Creating $threadc maintainer threads for $items profiles." . PHP_EOL; +} +logger("Creating $threadc maintainer threads for $items profiles."); + +for ($i = 0; $i < $threadc; $i++) { + + $pid = pcntl_fork(); + if ($pid === -1) { + if ($verbose) { + echo('Error: something went wrong with the fork. ' . pcntl_strerror()); + } + logger('Error: something went wrong with the fork. ' . pcntl_strerror()); + die('Error: something went wrong with the fork. ' . pcntl_strerror()); + } + + //You're a child, go do some labor! + if ($pid === 0) { + break; + } + + //Store the list of PID's. + if ($pid > 0) { + $threads[] = $pid; + } +} + +//The work for child processes. +if ($pid === 0) { + + //Lets be nice, we're only doing maintenance here... + pcntl_setpriority(5); + + //Get personal DBA's. $db = new dba($db_host, $db_user, $db_pass, $db_data, $install); - - //Get our set of items. Youngest items first, after the threshold. - //This may be counter-intuitive, but is to prevent items that fail to update from blocking the rest. - $res = q( - "SELECT `id`, `homepage`, `censored` FROM `profile` WHERE `updated` < '%s' ORDER BY `updated` DESC LIMIT %u", - dbesc(date('Y-m-d H:i:s', time()-$a->config['maintenance']['min_scrape_delay'])), - intval($a->config['maintenance']['max_scrapes']) - ); - - //Nothing to do. - if(!$res || !count($res)){ - exit; + + //Get our (round-robin) workload from the DB results. + $myIndex = $i + 1; + $workload = array(); + while (isset($res[$i])) { + $entry = $res[$i]; + $workload[] = $entry; + $ids[] = $entry['id']; + $i += $threadc; } - - //Close DB here. Threads need their private connection. - $db->getdb()->close(); - - //We need the scraper. - require_once('include/submit.php'); - - //POSIX threads only. - if(!function_exists('pcntl_fork')){ - logger('Error: no pcntl_fork support. Are you running a different OS? Report an issue please.'); - die('Error: no pcntl_fork support. Are you running a different OS? Report an issue please.'); - } - - //Create the threads we need. - $items = count($res); - $threadc = min($a->config['maintenance']['threads'], $items); //Don't need more threads than items. - $threads = array(); - - //Debug... - if($verbose) echo("Creating $threadc maintainer threads for $items profiles.".PHP_EOL); - logger("Creating $threadc maintainer threads for $items profiles."); - - for($i = 0; $i < $threadc; $i++){ - - $pid = pcntl_fork(); - if($pid === -1){ - if($verbose) echo('Error: something went wrong with the fork. '.pcntl_strerror()); - logger('Error: something went wrong with the fork. '.pcntl_strerror()); - die('Error: something went wrong with the fork. '.pcntl_strerror()); + + while (count($workload)) { + $entry = array_pop($workload); + set_time_limit(20); //This should work for 1 submit. + if ($verbose) { + echo "Submitting " . $entry['homepage'] . PHP_EOL; } - - //You're a child, go do some labor! - if($pid === 0) break; - - //Store the list of PID's. - if($pid > 0) $threads[] = $pid; - + run_submit($entry['homepage']); } - - //The work for child processes. - if($pid === 0){ - - //Lets be nice, we're only doing maintenance here... - pcntl_setpriority(5); - - //Get personal DBA's. - $db = new dba($db_host, $db_user, $db_pass, $db_data, $install); - - //Get our (round-robin) workload from the DB results. - $myIndex = $i+1; - $workload = array(); - while(isset($res[$i])){ - $entry = $res[$i]; - $workload[] = $entry; - $ids[] = $entry['id']; - $i+=$threadc; - } - - while(count($workload)){ - $entry = array_pop($workload); - set_time_limit(20); //This should work for 1 submit. - if($verbose) echo "Submitting ".$entry['homepage'].PHP_EOL; - run_submit($entry['homepage']); - } - - exit; - - } - + + exit; +} else { //The main process. - else{ - foreach($threads as $pid){ - pcntl_waitpid($pid, $status); - if($status !== 0){ - if($verbose) echo "Bad process return value $pid:$status".PHP_EOL; - logger("Bad process return value $pid:$status"); + foreach ($threads as $pid) { + pcntl_waitpid($pid, $status); + if ($status !== 0) { + if ($verbose) { + echo "Bad process return value $pid:$status" . PHP_EOL; } + logger("Bad process return value $pid:$status"); } - $time = time() - $start_maintain; - if($verbose) echo("Maintenance completed. Took $time seconds.".PHP_EOL); - logger("Maintenance completed. Took $time seconds."); - } \ No newline at end of file + } + $time = time() - $start_maintain; + if ($verbose) { + echo("Maintenance completed. Took $time seconds." . PHP_EOL); + } + logger("Maintenance completed. Took $time seconds."); +} diff --git a/include/cron_sync.php b/include/cron_sync.php index b4f6ec55..e9d2eb17 100644 --- a/include/cron_sync.php +++ b/include/cron_sync.php @@ -1,76 +1,84 @@ getdb()->close(); -if(count($pull_batch)) +if (count($pull_batch)) { run_pulling_job($a, $pull_batch, $db_host, $db_user, $db_pass, $db_data, $install); +} //Do our multi-fork job, if we have a batch and targets. -if(count($push_targets) && count($push_batch)) +if (count($push_targets) && count($push_batch)) { run_pushing_job($push_targets, $push_batch, $db_host, $db_user, $db_pass, $db_data, $install); +} //Log the time it took. $time = time() - $start_syncing; diff --git a/include/datetime.php b/include/datetime.php old mode 100755 new mode 100644 diff --git a/include/dba.php b/include/dba.php index a79477cf..877f6cd3 100755 --- a/include/dba.php +++ b/include/dba.php @@ -7,111 +7,130 @@ // x = 2: display full queries following content // x = 3: display full queries using echo; which will mess up display // really bad but will return output in stubborn cases. - -if(! class_exists('dba')) { -class dba { +class dba +{ private $debug = 0; public $db; - function __construct($server,$user,$pass,$db,$install = false) { - $this->db = @new mysqli($server,$user,$pass,$db); - if((mysqli_connect_errno()) && (! install)) - system_unavailable(); + public function __construct($server, $user, $pass, $db, $install = false) + { + $this->db = @new mysqli($server, $user, $pass, $db); + if ((mysqli_connect_errno()) && (! install)) { + system_unavailable(); + } } - public function getdb() { + public function getdb() + { return $this->db; } - public function q($sql) { + public function q($sql) + { global $debug_text; - - if(! $this->db ) + + if (! $this->db) { return false; - + } + $result = @$this->db->query($sql); - if($this->debug) { - + if ($this->debug) { $mesg = ''; - if($this->db->mysqli->errno) + if ($this->db->mysqli->errno) { $debug_text .= $this->db->mysqli->error . EOL; + } - if($result === false) + if ($result === false) { $mesg = 'false'; - elseif($result === true) + } elseif ($result === true) { $mesg = 'true'; - else + } else { $mesg = $result->num_rows.' results' . EOL; - + } + $str = 'SQL = ' . printable($sql) . EOL . 'SQL returned ' . $mesg . EOL; - switch($this->debug) { - case 3: - echo $str; - break; - default: - $debug_text .= $str; - break; - } + switch ($this->debug) { + case 3: + echo $str; + break; + default: + $debug_text .= $str; + break; + } } - if(($result === true) || ($result === false)) + if (($result === true) || ($result === false)) { return $result; + } $r = array(); - if($result->num_rows) { - while($x = $result->fetch_array(MYSQL_ASSOC)) + if ($result->num_rows) { + while ($x = $result->fetch_array(MYSQL_ASSOC)) { $r[] = $x; + } $result->free_result(); } - - if($this->debug == 2) - $debug_text .= printable(print_r($r, true). EOL); - elseif($this->debug == 3) - echo printable(print_r($r, true) . EOL) ; - return($r); + if ($this->debug == 2) { + $debug_text .= printable(print_r($r, true). EOL); + } elseif ($this->debug == 3) { + echo printable(print_r($r, true) . EOL) ; + } + + return $r; } - public function dbg($dbg) { + public function dbg($dbg) + { $this->debug = $dbg; } - public function escape($str) { + public function escape($str) + { return @$this->db->real_escape_string($str); } - function __destruct() { + public function __destruct() + { @$this->db->close(); } -}} +} -if(! function_exists('printable')) { -function printable($s) { - $s = preg_replace("~([\x01-\x08\x0E-\x0F\x10-\x1F\x7F-\xFF])~",".", $s); - $s = str_replace("\x00",'.',$s); - if(x($_SERVER,'SERVER_NAME')) - $s = escape_tags($s); - return $s; -}} +if (! function_exists('printable')) { + function printable($s) + { + $s = preg_replace("~([\x01-\x08\x0E-\x0F\x10-\x1F\x7F-\xFF])~", ".", $s); + $s = str_replace("\x00", '.', $s); + if (x($_SERVER, 'SERVER_NAME')) { + $s = escape_tags($s); + } + return $s; + } +} // Procedural functions -if(! function_exists('dbg')) { -function dbg($state) { - global $db; - $db->dbg($state); -}} +if (! function_exists('dbg')) { + function dbg($state) + { + global $db; + $db->dbg($state); + } +} -if(! function_exists('dbesc')) { -function dbesc($str) { - global $db; - if($db) - return($db->escape($str)); -}} +if (! function_exists('dbesc')) { + function dbesc($str) + { + global $db; + if ($db) { + return($db->escape($str)); + } + } +} // Function: q($sql,$args); @@ -119,46 +138,55 @@ function dbesc($str) { // Example: $r = q("SELECT * FROM `%s` WHERE `uid` = %d", // 'user', 1); -if(! function_exists('q')) { -function q($sql) { - - global $db; - $args = func_get_args(); - unset($args[0]); - if($db) - $ret = $db->q(vsprintf($sql,$args)); - if($db->db->errno) - logger('dba: ' . $db->db->error); +if (! function_exists('q')) { + function q($sql) + { + global $db; + $args = func_get_args(); + unset($args[0]); + if ($db) { + $ret = $db->q(vsprintf($sql, $args)); + } + if ($db->db->errno) { + logger('dba: ' . $db->db->error); + } - return $ret; -}} - - -// Caller is responsible for ensuring that any integer arguments to -// dbesc_array are actually integers and not malformed strings containing -// SQL injection vectors. All integer array elements should be specifically -// cast to int to avoid trouble. - - -if(! function_exists('dbesc_array_cb')) { -function dbesc_array_cb(&$item, $key) { - if(is_string($item)) - $item = dbesc($item); -}} - - -if(! function_exists('dbesc_array')) { -function dbesc_array(&$arr) { - if(is_array($arr) && count($arr)) { - array_walk($arr,'dbesc_array_cb'); + return $ret; } -}} +} -if(! function_exists('closedb')) { -function closedb() { - global $db; +// Caller is responsible for ensuring that any integer arguments to +// dbesc_array are actually integers and not malformed strings containing +// SQL injection vectors. All integer array elements should be specifically +// cast to int to avoid trouble. + + +if (! function_exists('dbesc_array_cb')) { + function dbesc_array_cb(&$item, $key) + { + if (is_string($item)) { + $item = dbesc($item); + } + } +} + + +if (! function_exists('dbesc_array')) { + function dbesc_array(&$arr) + { + if (is_array($arr) && count($arr)) { + array_walk($arr, 'dbesc_array_cb'); + } + } +} + + +if (! function_exists('closedb')) { + function closedb() + { + global $db; // $db->close(); -}} - + } +} diff --git a/include/directory.php b/include/directory.php old mode 100755 new mode 100644 index 5f835dc4..01d00e02 --- a/include/directory.php +++ b/include/directory.php @@ -1,28 +1,34 @@ set_baseurl(get_config('system','url')); - - $dir = get_config('system','directory_submit_url'); - - if(! strlen($dir)) - exit; - - fetch_url($dir . '?url=' . bin2hex($argv[1])); +unset($db_host, $db_user, $db_pass, $db_data); +if ($argc != 2) { exit; +} +load_config('system'); + +$a->set_baseurl(get_config('system', 'url')); + +$dir = get_config('system', 'directory_submit_url'); + +if (!strlen($dir)) { + exit; +} + +fetch_url($dir . '?url=' . bin2hex($argv[1])); + +exit; diff --git a/include/group.php b/include/group.php old mode 100755 new mode 100644 diff --git a/include/hostxrd.php b/include/hostxrd.php old mode 100755 new mode 100644 diff --git a/include/items.php b/include/items.php old mode 100755 new mode 100644 index 22509f24..3d7f0b9a --- a/include/items.php +++ b/include/items.php @@ -241,4 +241,3 @@ function post_remote($a,$arr) { return $current_post; } - diff --git a/include/jquery-1.4.2.min.js b/include/jquery-1.4.2.min.js deleted file mode 100755 index 7c243080..00000000 --- a/include/jquery-1.4.2.min.js +++ /dev/null @@ -1,154 +0,0 @@ -/*! - * jQuery JavaScript Library v1.4.2 - * http://jquery.com/ - * - * Copyright 2010, John Resig - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * Includes Sizzle.js - * http://sizzlejs.com/ - * Copyright 2010, The Dojo Foundation - * Released under the MIT, BSD, and GPL Licenses. - * - * Date: Sat Feb 13 22:33:48 2010 -0500 - */ -(function(A,w){function ma(){if(!c.isReady){try{s.documentElement.doScroll("left")}catch(a){setTimeout(ma,1);return}c.ready()}}function Qa(a,b){b.src?c.ajax({url:b.src,async:false,dataType:"script"}):c.globalEval(b.text||b.textContent||b.innerHTML||"");b.parentNode&&b.parentNode.removeChild(b)}function X(a,b,d,f,e,j){var i=a.length;if(typeof b==="object"){for(var o in b)X(a,o,b[o],f,e,d);return a}if(d!==w){f=!j&&f&&c.isFunction(d);for(o=0;o)[^>]*$|^#([\w-]+)$/,Ua=/^.[^:#\[\.,]*$/,Va=/\S/, -Wa=/^(\s|\u00A0)+|(\s|\u00A0)+$/g,Xa=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,P=navigator.userAgent,xa=false,Q=[],L,$=Object.prototype.toString,aa=Object.prototype.hasOwnProperty,ba=Array.prototype.push,R=Array.prototype.slice,ya=Array.prototype.indexOf;c.fn=c.prototype={init:function(a,b){var d,f;if(!a)return this;if(a.nodeType){this.context=this[0]=a;this.length=1;return this}if(a==="body"&&!b){this.context=s;this[0]=s.body;this.selector="body";this.length=1;return this}if(typeof a==="string")if((d=Ta.exec(a))&& -(d[1]||!b))if(d[1]){f=b?b.ownerDocument||b:s;if(a=Xa.exec(a))if(c.isPlainObject(b)){a=[s.createElement(a[1])];c.fn.attr.call(a,b,true)}else a=[f.createElement(a[1])];else{a=sa([d[1]],[f]);a=(a.cacheable?a.fragment.cloneNode(true):a.fragment).childNodes}return c.merge(this,a)}else{if(b=s.getElementById(d[2])){if(b.id!==d[2])return T.find(a);this.length=1;this[0]=b}this.context=s;this.selector=a;return this}else if(!b&&/^\w+$/.test(a)){this.selector=a;this.context=s;a=s.getElementsByTagName(a);return c.merge(this, -a)}else return!b||b.jquery?(b||T).find(a):c(b).find(a);else if(c.isFunction(a))return T.ready(a);if(a.selector!==w){this.selector=a.selector;this.context=a.context}return c.makeArray(a,this)},selector:"",jquery:"1.4.2",length:0,size:function(){return this.length},toArray:function(){return R.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this.slice(a)[0]:this[a]},pushStack:function(a,b,d){var f=c();c.isArray(a)?ba.apply(f,a):c.merge(f,a);f.prevObject=this;f.context=this.context;if(b=== -"find")f.selector=this.selector+(this.selector?" ":"")+d;else if(b)f.selector=this.selector+"."+b+"("+d+")";return f},each:function(a,b){return c.each(this,a,b)},ready:function(a){c.bindReady();if(c.isReady)a.call(s,c);else Q&&Q.push(a);return this},eq:function(a){return a===-1?this.slice(a):this.slice(a,+a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(R.apply(this,arguments),"slice",R.call(arguments).join(","))},map:function(a){return this.pushStack(c.map(this, -function(b,d){return a.call(b,d,b)}))},end:function(){return this.prevObject||c(null)},push:ba,sort:[].sort,splice:[].splice};c.fn.init.prototype=c.fn;c.extend=c.fn.extend=function(){var a=arguments[0]||{},b=1,d=arguments.length,f=false,e,j,i,o;if(typeof a==="boolean"){f=a;a=arguments[1]||{};b=2}if(typeof a!=="object"&&!c.isFunction(a))a={};if(d===b){a=this;--b}for(;b
a"; -var e=d.getElementsByTagName("*"),j=d.getElementsByTagName("a")[0];if(!(!e||!e.length||!j)){c.support={leadingWhitespace:d.firstChild.nodeType===3,tbody:!d.getElementsByTagName("tbody").length,htmlSerialize:!!d.getElementsByTagName("link").length,style:/red/.test(j.getAttribute("style")),hrefNormalized:j.getAttribute("href")==="/a",opacity:/^0.55$/.test(j.style.opacity),cssFloat:!!j.style.cssFloat,checkOn:d.getElementsByTagName("input")[0].value==="on",optSelected:s.createElement("select").appendChild(s.createElement("option")).selected, -parentNode:d.removeChild(d.appendChild(s.createElement("div"))).parentNode===null,deleteExpando:true,checkClone:false,scriptEval:false,noCloneEvent:true,boxModel:null};b.type="text/javascript";try{b.appendChild(s.createTextNode("window."+f+"=1;"))}catch(i){}a.insertBefore(b,a.firstChild);if(A[f]){c.support.scriptEval=true;delete A[f]}try{delete b.test}catch(o){c.support.deleteExpando=false}a.removeChild(b);if(d.attachEvent&&d.fireEvent){d.attachEvent("onclick",function k(){c.support.noCloneEvent= -false;d.detachEvent("onclick",k)});d.cloneNode(true).fireEvent("onclick")}d=s.createElement("div");d.innerHTML="";a=s.createDocumentFragment();a.appendChild(d.firstChild);c.support.checkClone=a.cloneNode(true).cloneNode(true).lastChild.checked;c(function(){var k=s.createElement("div");k.style.width=k.style.paddingLeft="1px";s.body.appendChild(k);c.boxModel=c.support.boxModel=k.offsetWidth===2;s.body.removeChild(k).style.display="none"});a=function(k){var n= -s.createElement("div");k="on"+k;var r=k in n;if(!r){n.setAttribute(k,"return;");r=typeof n[k]==="function"}return r};c.support.submitBubbles=a("submit");c.support.changeBubbles=a("change");a=b=d=e=j=null}})();c.props={"for":"htmlFor","class":"className",readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing",rowspan:"rowSpan",colspan:"colSpan",tabindex:"tabIndex",usemap:"useMap",frameborder:"frameBorder"};var G="jQuery"+J(),Ya=0,za={};c.extend({cache:{},expando:G,noData:{embed:true,object:true, -applet:true},data:function(a,b,d){if(!(a.nodeName&&c.noData[a.nodeName.toLowerCase()])){a=a==A?za:a;var f=a[G],e=c.cache;if(!f&&typeof b==="string"&&d===w)return null;f||(f=++Ya);if(typeof b==="object"){a[G]=f;e[f]=c.extend(true,{},b)}else if(!e[f]){a[G]=f;e[f]={}}a=e[f];if(d!==w)a[b]=d;return typeof b==="string"?a[b]:a}},removeData:function(a,b){if(!(a.nodeName&&c.noData[a.nodeName.toLowerCase()])){a=a==A?za:a;var d=a[G],f=c.cache,e=f[d];if(b){if(e){delete e[b];c.isEmptyObject(e)&&c.removeData(a)}}else{if(c.support.deleteExpando)delete a[c.expando]; -else a.removeAttribute&&a.removeAttribute(c.expando);delete f[d]}}}});c.fn.extend({data:function(a,b){if(typeof a==="undefined"&&this.length)return c.data(this[0]);else if(typeof a==="object")return this.each(function(){c.data(this,a)});var d=a.split(".");d[1]=d[1]?"."+d[1]:"";if(b===w){var f=this.triggerHandler("getData"+d[1]+"!",[d[0]]);if(f===w&&this.length)f=c.data(this[0],a);return f===w&&d[1]?this.data(d[0]):f}else return this.trigger("setData"+d[1]+"!",[d[0],b]).each(function(){c.data(this, -a,b)})},removeData:function(a){return this.each(function(){c.removeData(this,a)})}});c.extend({queue:function(a,b,d){if(a){b=(b||"fx")+"queue";var f=c.data(a,b);if(!d)return f||[];if(!f||c.isArray(d))f=c.data(a,b,c.makeArray(d));else f.push(d);return f}},dequeue:function(a,b){b=b||"fx";var d=c.queue(a,b),f=d.shift();if(f==="inprogress")f=d.shift();if(f){b==="fx"&&d.unshift("inprogress");f.call(a,function(){c.dequeue(a,b)})}}});c.fn.extend({queue:function(a,b){if(typeof a!=="string"){b=a;a="fx"}if(b=== -w)return c.queue(this[0],a);return this.each(function(){var d=c.queue(this,a,b);a==="fx"&&d[0]!=="inprogress"&&c.dequeue(this,a)})},dequeue:function(a){return this.each(function(){c.dequeue(this,a)})},delay:function(a,b){a=c.fx?c.fx.speeds[a]||a:a;b=b||"fx";return this.queue(b,function(){var d=this;setTimeout(function(){c.dequeue(d,b)},a)})},clearQueue:function(a){return this.queue(a||"fx",[])}});var Aa=/[\n\t]/g,ca=/\s+/,Za=/\r/g,$a=/href|src|style/,ab=/(button|input)/i,bb=/(button|input|object|select|textarea)/i, -cb=/^(a|area)$/i,Ba=/radio|checkbox/;c.fn.extend({attr:function(a,b){return X(this,a,b,true,c.attr)},removeAttr:function(a){return this.each(function(){c.attr(this,a,"");this.nodeType===1&&this.removeAttribute(a)})},addClass:function(a){if(c.isFunction(a))return this.each(function(n){var r=c(this);r.addClass(a.call(this,n,r.attr("class")))});if(a&&typeof a==="string")for(var b=(a||"").split(ca),d=0,f=this.length;d-1)return true;return false},val:function(a){if(a===w){var b=this[0];if(b){if(c.nodeName(b,"option"))return(b.attributes.value||{}).specified?b.value:b.text;if(c.nodeName(b,"select")){var d=b.selectedIndex,f=[],e=b.options;b=b.type==="select-one";if(d<0)return null;var j=b?d:0;for(d=b?d+1:e.length;j=0;else if(c.nodeName(this,"select")){var u=c.makeArray(r);c("option",this).each(function(){this.selected= -c.inArray(c(this).val(),u)>=0});if(!u.length)this.selectedIndex=-1}else this.value=r}})}});c.extend({attrFn:{val:true,css:true,html:true,text:true,data:true,width:true,height:true,offset:true},attr:function(a,b,d,f){if(!a||a.nodeType===3||a.nodeType===8)return w;if(f&&b in c.attrFn)return c(a)[b](d);f=a.nodeType!==1||!c.isXMLDoc(a);var e=d!==w;b=f&&c.props[b]||b;if(a.nodeType===1){var j=$a.test(b);if(b in a&&f&&!j){if(e){b==="type"&&ab.test(a.nodeName)&&a.parentNode&&c.error("type property can't be changed"); -a[b]=d}if(c.nodeName(a,"form")&&a.getAttributeNode(b))return a.getAttributeNode(b).nodeValue;if(b==="tabIndex")return(b=a.getAttributeNode("tabIndex"))&&b.specified?b.value:bb.test(a.nodeName)||cb.test(a.nodeName)&&a.href?0:w;return a[b]}if(!c.support.style&&f&&b==="style"){if(e)a.style.cssText=""+d;return a.style.cssText}e&&a.setAttribute(b,""+d);a=!c.support.hrefNormalized&&f&&j?a.getAttribute(b,2):a.getAttribute(b);return a===null?w:a}return c.style(a,b,d)}});var O=/\.(.*)$/,db=function(a){return a.replace(/[^\w\s\.\|`]/g, -function(b){return"\\"+b})};c.event={add:function(a,b,d,f){if(!(a.nodeType===3||a.nodeType===8)){if(a.setInterval&&a!==A&&!a.frameElement)a=A;var e,j;if(d.handler){e=d;d=e.handler}if(!d.guid)d.guid=c.guid++;if(j=c.data(a)){var i=j.events=j.events||{},o=j.handle;if(!o)j.handle=o=function(){return typeof c!=="undefined"&&!c.event.triggered?c.event.handle.apply(o.elem,arguments):w};o.elem=a;b=b.split(" ");for(var k,n=0,r;k=b[n++];){j=e?c.extend({},e):{handler:d,data:f};if(k.indexOf(".")>-1){r=k.split("."); -k=r.shift();j.namespace=r.slice(0).sort().join(".")}else{r=[];j.namespace=""}j.type=k;j.guid=d.guid;var u=i[k],z=c.event.special[k]||{};if(!u){u=i[k]=[];if(!z.setup||z.setup.call(a,f,r,o)===false)if(a.addEventListener)a.addEventListener(k,o,false);else a.attachEvent&&a.attachEvent("on"+k,o)}if(z.add){z.add.call(a,j);if(!j.handler.guid)j.handler.guid=d.guid}u.push(j);c.event.global[k]=true}a=null}}},global:{},remove:function(a,b,d,f){if(!(a.nodeType===3||a.nodeType===8)){var e,j=0,i,o,k,n,r,u,z=c.data(a), -C=z&&z.events;if(z&&C){if(b&&b.type){d=b.handler;b=b.type}if(!b||typeof b==="string"&&b.charAt(0)==="."){b=b||"";for(e in C)c.event.remove(a,e+b)}else{for(b=b.split(" ");e=b[j++];){n=e;i=e.indexOf(".")<0;o=[];if(!i){o=e.split(".");e=o.shift();k=new RegExp("(^|\\.)"+c.map(o.slice(0).sort(),db).join("\\.(?:.*\\.)?")+"(\\.|$)")}if(r=C[e])if(d){n=c.event.special[e]||{};for(B=f||0;B=0){a.type= -e=e.slice(0,-1);a.exclusive=true}if(!d){a.stopPropagation();c.event.global[e]&&c.each(c.cache,function(){this.events&&this.events[e]&&c.event.trigger(a,b,this.handle.elem)})}if(!d||d.nodeType===3||d.nodeType===8)return w;a.result=w;a.target=d;b=c.makeArray(b);b.unshift(a)}a.currentTarget=d;(f=c.data(d,"handle"))&&f.apply(d,b);f=d.parentNode||d.ownerDocument;try{if(!(d&&d.nodeName&&c.noData[d.nodeName.toLowerCase()]))if(d["on"+e]&&d["on"+e].apply(d,b)===false)a.result=false}catch(j){}if(!a.isPropagationStopped()&& -f)c.event.trigger(a,b,f,true);else if(!a.isDefaultPrevented()){f=a.target;var i,o=c.nodeName(f,"a")&&e==="click",k=c.event.special[e]||{};if((!k._default||k._default.call(d,a)===false)&&!o&&!(f&&f.nodeName&&c.noData[f.nodeName.toLowerCase()])){try{if(f[e]){if(i=f["on"+e])f["on"+e]=null;c.event.triggered=true;f[e]()}}catch(n){}if(i)f["on"+e]=i;c.event.triggered=false}}},handle:function(a){var b,d,f,e;a=arguments[0]=c.event.fix(a||A.event);a.currentTarget=this;b=a.type.indexOf(".")<0&&!a.exclusive; -if(!b){d=a.type.split(".");a.type=d.shift();f=new RegExp("(^|\\.)"+d.slice(0).sort().join("\\.(?:.*\\.)?")+"(\\.|$)")}e=c.data(this,"events");d=e[a.type];if(e&&d){d=d.slice(0);e=0;for(var j=d.length;e-1?c.map(a.options,function(f){return f.selected}).join("-"):"";else if(a.nodeName.toLowerCase()==="select")d=a.selectedIndex;return d},fa=function(a,b){var d=a.target,f,e;if(!(!da.test(d.nodeName)||d.readOnly)){f=c.data(d,"_change_data");e=Fa(d);if(a.type!=="focusout"||d.type!=="radio")c.data(d,"_change_data", -e);if(!(f===w||e===f))if(f!=null||e){a.type="change";return c.event.trigger(a,b,d)}}};c.event.special.change={filters:{focusout:fa,click:function(a){var b=a.target,d=b.type;if(d==="radio"||d==="checkbox"||b.nodeName.toLowerCase()==="select")return fa.call(this,a)},keydown:function(a){var b=a.target,d=b.type;if(a.keyCode===13&&b.nodeName.toLowerCase()!=="textarea"||a.keyCode===32&&(d==="checkbox"||d==="radio")||d==="select-multiple")return fa.call(this,a)},beforeactivate:function(a){a=a.target;c.data(a, -"_change_data",Fa(a))}},setup:function(){if(this.type==="file")return false;for(var a in ea)c.event.add(this,a+".specialChange",ea[a]);return da.test(this.nodeName)},teardown:function(){c.event.remove(this,".specialChange");return da.test(this.nodeName)}};ea=c.event.special.change.filters}s.addEventListener&&c.each({focus:"focusin",blur:"focusout"},function(a,b){function d(f){f=c.event.fix(f);f.type=b;return c.event.handle.call(this,f)}c.event.special[b]={setup:function(){this.addEventListener(a, -d,true)},teardown:function(){this.removeEventListener(a,d,true)}}});c.each(["bind","one"],function(a,b){c.fn[b]=function(d,f,e){if(typeof d==="object"){for(var j in d)this[b](j,f,d[j],e);return this}if(c.isFunction(f)){e=f;f=w}var i=b==="one"?c.proxy(e,function(k){c(this).unbind(k,i);return e.apply(this,arguments)}):e;if(d==="unload"&&b!=="one")this.one(d,f,e);else{j=0;for(var o=this.length;j0){y=t;break}}t=t[g]}m[q]=y}}}var f=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g, -e=0,j=Object.prototype.toString,i=false,o=true;[0,0].sort(function(){o=false;return 0});var k=function(g,h,l,m){l=l||[];var q=h=h||s;if(h.nodeType!==1&&h.nodeType!==9)return[];if(!g||typeof g!=="string")return l;for(var p=[],v,t,y,S,H=true,M=x(h),I=g;(f.exec(""),v=f.exec(I))!==null;){I=v[3];p.push(v[1]);if(v[2]){S=v[3];break}}if(p.length>1&&r.exec(g))if(p.length===2&&n.relative[p[0]])t=ga(p[0]+p[1],h);else for(t=n.relative[p[0]]?[h]:k(p.shift(),h);p.length;){g=p.shift();if(n.relative[g])g+=p.shift(); -t=ga(g,t)}else{if(!m&&p.length>1&&h.nodeType===9&&!M&&n.match.ID.test(p[0])&&!n.match.ID.test(p[p.length-1])){v=k.find(p.shift(),h,M);h=v.expr?k.filter(v.expr,v.set)[0]:v.set[0]}if(h){v=m?{expr:p.pop(),set:z(m)}:k.find(p.pop(),p.length===1&&(p[0]==="~"||p[0]==="+")&&h.parentNode?h.parentNode:h,M);t=v.expr?k.filter(v.expr,v.set):v.set;if(p.length>0)y=z(t);else H=false;for(;p.length;){var D=p.pop();v=D;if(n.relative[D])v=p.pop();else D="";if(v==null)v=h;n.relative[D](y,v,M)}}else y=[]}y||(y=t);y||k.error(D|| -g);if(j.call(y)==="[object Array]")if(H)if(h&&h.nodeType===1)for(g=0;y[g]!=null;g++){if(y[g]&&(y[g]===true||y[g].nodeType===1&&E(h,y[g])))l.push(t[g])}else for(g=0;y[g]!=null;g++)y[g]&&y[g].nodeType===1&&l.push(t[g]);else l.push.apply(l,y);else z(y,l);if(S){k(S,q,l,m);k.uniqueSort(l)}return l};k.uniqueSort=function(g){if(B){i=o;g.sort(B);if(i)for(var h=1;h":function(g,h){var l=typeof h==="string";if(l&&!/\W/.test(h)){h=h.toLowerCase();for(var m=0,q=g.length;m=0))l||m.push(v);else if(l)h[p]=false;return false},ID:function(g){return g[1].replace(/\\/g,"")},TAG:function(g){return g[1].toLowerCase()}, -CHILD:function(g){if(g[1]==="nth"){var h=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(g[2]==="even"&&"2n"||g[2]==="odd"&&"2n+1"||!/\D/.test(g[2])&&"0n+"+g[2]||g[2]);g[2]=h[1]+(h[2]||1)-0;g[3]=h[3]-0}g[0]=e++;return g},ATTR:function(g,h,l,m,q,p){h=g[1].replace(/\\/g,"");if(!p&&n.attrMap[h])g[1]=n.attrMap[h];if(g[2]==="~=")g[4]=" "+g[4]+" ";return g},PSEUDO:function(g,h,l,m,q){if(g[1]==="not")if((f.exec(g[3])||"").length>1||/^\w/.test(g[3]))g[3]=k(g[3],null,null,h);else{g=k.filter(g[3],h,l,true^q);l||m.push.apply(m, -g);return false}else if(n.match.POS.test(g[0])||n.match.CHILD.test(g[0]))return true;return g},POS:function(g){g.unshift(true);return g}},filters:{enabled:function(g){return g.disabled===false&&g.type!=="hidden"},disabled:function(g){return g.disabled===true},checked:function(g){return g.checked===true},selected:function(g){return g.selected===true},parent:function(g){return!!g.firstChild},empty:function(g){return!g.firstChild},has:function(g,h,l){return!!k(l[3],g).length},header:function(g){return/h\d/i.test(g.nodeName)}, -text:function(g){return"text"===g.type},radio:function(g){return"radio"===g.type},checkbox:function(g){return"checkbox"===g.type},file:function(g){return"file"===g.type},password:function(g){return"password"===g.type},submit:function(g){return"submit"===g.type},image:function(g){return"image"===g.type},reset:function(g){return"reset"===g.type},button:function(g){return"button"===g.type||g.nodeName.toLowerCase()==="button"},input:function(g){return/input|select|textarea|button/i.test(g.nodeName)}}, -setFilters:{first:function(g,h){return h===0},last:function(g,h,l,m){return h===m.length-1},even:function(g,h){return h%2===0},odd:function(g,h){return h%2===1},lt:function(g,h,l){return hl[3]-0},nth:function(g,h,l){return l[3]-0===h},eq:function(g,h,l){return l[3]-0===h}},filter:{PSEUDO:function(g,h,l,m){var q=h[1],p=n.filters[q];if(p)return p(g,l,h,m);else if(q==="contains")return(g.textContent||g.innerText||a([g])||"").indexOf(h[3])>=0;else if(q==="not"){h= -h[3];l=0;for(m=h.length;l=0}},ID:function(g,h){return g.nodeType===1&&g.getAttribute("id")===h},TAG:function(g,h){return h==="*"&&g.nodeType===1||g.nodeName.toLowerCase()===h},CLASS:function(g,h){return(" "+(g.className||g.getAttribute("class"))+" ").indexOf(h)>-1},ATTR:function(g,h){var l=h[1];g=n.attrHandle[l]?n.attrHandle[l](g):g[l]!=null?g[l]:g.getAttribute(l);l=g+"";var m=h[2];h=h[4];return g==null?m==="!=":m=== -"="?l===h:m==="*="?l.indexOf(h)>=0:m==="~="?(" "+l+" ").indexOf(h)>=0:!h?l&&g!==false:m==="!="?l!==h:m==="^="?l.indexOf(h)===0:m==="$="?l.substr(l.length-h.length)===h:m==="|="?l===h||l.substr(0,h.length+1)===h+"-":false},POS:function(g,h,l,m){var q=n.setFilters[h[2]];if(q)return q(g,l,h,m)}}},r=n.match.POS;for(var u in n.match){n.match[u]=new RegExp(n.match[u].source+/(?![^\[]*\])(?![^\(]*\))/.source);n.leftMatch[u]=new RegExp(/(^(?:.|\r|\n)*?)/.source+n.match[u].source.replace(/\\(\d+)/g,function(g, -h){return"\\"+(h-0+1)}))}var z=function(g,h){g=Array.prototype.slice.call(g,0);if(h){h.push.apply(h,g);return h}return g};try{Array.prototype.slice.call(s.documentElement.childNodes,0)}catch(C){z=function(g,h){h=h||[];if(j.call(g)==="[object Array]")Array.prototype.push.apply(h,g);else if(typeof g.length==="number")for(var l=0,m=g.length;l";var l=s.documentElement;l.insertBefore(g,l.firstChild);if(s.getElementById(h)){n.find.ID=function(m,q,p){if(typeof q.getElementById!=="undefined"&&!p)return(q=q.getElementById(m[1]))?q.id===m[1]||typeof q.getAttributeNode!=="undefined"&& -q.getAttributeNode("id").nodeValue===m[1]?[q]:w:[]};n.filter.ID=function(m,q){var p=typeof m.getAttributeNode!=="undefined"&&m.getAttributeNode("id");return m.nodeType===1&&p&&p.nodeValue===q}}l.removeChild(g);l=g=null})();(function(){var g=s.createElement("div");g.appendChild(s.createComment(""));if(g.getElementsByTagName("*").length>0)n.find.TAG=function(h,l){l=l.getElementsByTagName(h[1]);if(h[1]==="*"){h=[];for(var m=0;l[m];m++)l[m].nodeType===1&&h.push(l[m]);l=h}return l};g.innerHTML=""; -if(g.firstChild&&typeof g.firstChild.getAttribute!=="undefined"&&g.firstChild.getAttribute("href")!=="#")n.attrHandle.href=function(h){return h.getAttribute("href",2)};g=null})();s.querySelectorAll&&function(){var g=k,h=s.createElement("div");h.innerHTML="

";if(!(h.querySelectorAll&&h.querySelectorAll(".TEST").length===0)){k=function(m,q,p,v){q=q||s;if(!v&&q.nodeType===9&&!x(q))try{return z(q.querySelectorAll(m),p)}catch(t){}return g(m,q,p,v)};for(var l in g)k[l]=g[l];h=null}}(); -(function(){var g=s.createElement("div");g.innerHTML="
";if(!(!g.getElementsByClassName||g.getElementsByClassName("e").length===0)){g.lastChild.className="e";if(g.getElementsByClassName("e").length!==1){n.order.splice(1,0,"CLASS");n.find.CLASS=function(h,l,m){if(typeof l.getElementsByClassName!=="undefined"&&!m)return l.getElementsByClassName(h[1])};g=null}}})();var E=s.compareDocumentPosition?function(g,h){return!!(g.compareDocumentPosition(h)&16)}: -function(g,h){return g!==h&&(g.contains?g.contains(h):true)},x=function(g){return(g=(g?g.ownerDocument||g:0).documentElement)?g.nodeName!=="HTML":false},ga=function(g,h){var l=[],m="",q;for(h=h.nodeType?[h]:h;q=n.match.PSEUDO.exec(g);){m+=q[0];g=g.replace(n.match.PSEUDO,"")}g=n.relative[g]?g+"*":g;q=0;for(var p=h.length;q=0===d})};c.fn.extend({find:function(a){for(var b=this.pushStack("","find",a),d=0,f=0,e=this.length;f0)for(var j=d;j0},closest:function(a,b){if(c.isArray(a)){var d=[],f=this[0],e,j= -{},i;if(f&&a.length){e=0;for(var o=a.length;e-1:c(f).is(e)){d.push({selector:i,elem:f});delete j[i]}}f=f.parentNode}}return d}var k=c.expr.match.POS.test(a)?c(a,b||this.context):null;return this.map(function(n,r){for(;r&&r.ownerDocument&&r!==b;){if(k?k.index(r)>-1:c(r).is(a))return r;r=r.parentNode}return null})},index:function(a){if(!a||typeof a=== -"string")return c.inArray(this[0],a?c(a):this.parent().children());return c.inArray(a.jquery?a[0]:a,this)},add:function(a,b){a=typeof a==="string"?c(a,b||this.context):c.makeArray(a);b=c.merge(this.get(),a);return this.pushStack(qa(a[0])||qa(b[0])?b:c.unique(b))},andSelf:function(){return this.add(this.prevObject)}});c.each({parent:function(a){return(a=a.parentNode)&&a.nodeType!==11?a:null},parents:function(a){return c.dir(a,"parentNode")},parentsUntil:function(a,b,d){return c.dir(a,"parentNode", -d)},next:function(a){return c.nth(a,2,"nextSibling")},prev:function(a){return c.nth(a,2,"previousSibling")},nextAll:function(a){return c.dir(a,"nextSibling")},prevAll:function(a){return c.dir(a,"previousSibling")},nextUntil:function(a,b,d){return c.dir(a,"nextSibling",d)},prevUntil:function(a,b,d){return c.dir(a,"previousSibling",d)},siblings:function(a){return c.sibling(a.parentNode.firstChild,a)},children:function(a){return c.sibling(a.firstChild)},contents:function(a){return c.nodeName(a,"iframe")? -a.contentDocument||a.contentWindow.document:c.makeArray(a.childNodes)}},function(a,b){c.fn[a]=function(d,f){var e=c.map(this,b,d);eb.test(a)||(f=d);if(f&&typeof f==="string")e=c.filter(f,e);e=this.length>1?c.unique(e):e;if((this.length>1||gb.test(f))&&fb.test(a))e=e.reverse();return this.pushStack(e,a,R.call(arguments).join(","))}});c.extend({filter:function(a,b,d){if(d)a=":not("+a+")";return c.find.matches(a,b)},dir:function(a,b,d){var f=[];for(a=a[b];a&&a.nodeType!==9&&(d===w||a.nodeType!==1||!c(a).is(d));){a.nodeType=== -1&&f.push(a);a=a[b]}return f},nth:function(a,b,d){b=b||1;for(var f=0;a;a=a[d])if(a.nodeType===1&&++f===b)break;return a},sibling:function(a,b){for(var d=[];a;a=a.nextSibling)a.nodeType===1&&a!==b&&d.push(a);return d}});var Ja=/ jQuery\d+="(?:\d+|null)"/g,V=/^\s+/,Ka=/(<([\w:]+)[^>]*?)\/>/g,hb=/^(?:area|br|col|embed|hr|img|input|link|meta|param)$/i,La=/<([\w:]+)/,ib=/"},F={option:[1,""],legend:[1,"
","
"],thead:[1,"","
"],tr:[2,"","
"],td:[3,"","
"],col:[2,"","
"],area:[1,"",""],_default:[0,"",""]};F.optgroup=F.option;F.tbody=F.tfoot=F.colgroup=F.caption=F.thead;F.th=F.td;if(!c.support.htmlSerialize)F._default=[1,"div
","
"];c.fn.extend({text:function(a){if(c.isFunction(a))return this.each(function(b){var d= -c(this);d.text(a.call(this,b,d.text()))});if(typeof a!=="object"&&a!==w)return this.empty().append((this[0]&&this[0].ownerDocument||s).createTextNode(a));return c.text(this)},wrapAll:function(a){if(c.isFunction(a))return this.each(function(d){c(this).wrapAll(a.call(this,d))});if(this[0]){var b=c(a,this[0].ownerDocument).eq(0).clone(true);this[0].parentNode&&b.insertBefore(this[0]);b.map(function(){for(var d=this;d.firstChild&&d.firstChild.nodeType===1;)d=d.firstChild;return d}).append(this)}return this}, -wrapInner:function(a){if(c.isFunction(a))return this.each(function(b){c(this).wrapInner(a.call(this,b))});return this.each(function(){var b=c(this),d=b.contents();d.length?d.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){c(this).wrapAll(a)})},unwrap:function(){return this.parent().each(function(){c.nodeName(this,"body")||c(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.appendChild(a)})}, -prepend:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b,this)});else if(arguments.length){var a=c(arguments[0]);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b, -this.nextSibling)});else if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,c(arguments[0]).toArray());return a}},remove:function(a,b){for(var d=0,f;(f=this[d])!=null;d++)if(!a||c.filter(a,[f]).length){if(!b&&f.nodeType===1){c.cleanData(f.getElementsByTagName("*"));c.cleanData([f])}f.parentNode&&f.parentNode.removeChild(f)}return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++)for(b.nodeType===1&&c.cleanData(b.getElementsByTagName("*"));b.firstChild;)b.removeChild(b.firstChild); -return this},clone:function(a){var b=this.map(function(){if(!c.support.noCloneEvent&&!c.isXMLDoc(this)){var d=this.outerHTML,f=this.ownerDocument;if(!d){d=f.createElement("div");d.appendChild(this.cloneNode(true));d=d.innerHTML}return c.clean([d.replace(Ja,"").replace(/=([^="'>\s]+\/)>/g,'="$1">').replace(V,"")],f)[0]}else return this.cloneNode(true)});if(a===true){ra(this,b);ra(this.find("*"),b.find("*"))}return b},html:function(a){if(a===w)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(Ja, -""):null;else if(typeof a==="string"&&!ta.test(a)&&(c.support.leadingWhitespace||!V.test(a))&&!F[(La.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Ka,Ma);try{for(var b=0,d=this.length;b0||e.cacheable||this.length>1?k.cloneNode(true):k)}o.length&&c.each(o,Qa)}return this}});c.fragments={};c.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){c.fn[a]=function(d){var f=[];d=c(d);var e=this.length===1&&this[0].parentNode;if(e&&e.nodeType===11&&e.childNodes.length===1&&d.length===1){d[b](this[0]); -return this}else{e=0;for(var j=d.length;e0?this.clone(true):this).get();c.fn[b].apply(c(d[e]),i);f=f.concat(i)}return this.pushStack(f,a,d.selector)}}});c.extend({clean:function(a,b,d,f){b=b||s;if(typeof b.createElement==="undefined")b=b.ownerDocument||b[0]&&b[0].ownerDocument||s;for(var e=[],j=0,i;(i=a[j])!=null;j++){if(typeof i==="number")i+="";if(i){if(typeof i==="string"&&!jb.test(i))i=b.createTextNode(i);else if(typeof i==="string"){i=i.replace(Ka,Ma);var o=(La.exec(i)||["", -""])[1].toLowerCase(),k=F[o]||F._default,n=k[0],r=b.createElement("div");for(r.innerHTML=k[1]+i+k[2];n--;)r=r.lastChild;if(!c.support.tbody){n=ib.test(i);o=o==="table"&&!n?r.firstChild&&r.firstChild.childNodes:k[1]===""&&!n?r.childNodes:[];for(k=o.length-1;k>=0;--k)c.nodeName(o[k],"tbody")&&!o[k].childNodes.length&&o[k].parentNode.removeChild(o[k])}!c.support.leadingWhitespace&&V.test(i)&&r.insertBefore(b.createTextNode(V.exec(i)[0]),r.firstChild);i=r.childNodes}if(i.nodeType)e.push(i);else e= -c.merge(e,i)}}if(d)for(j=0;e[j];j++)if(f&&c.nodeName(e[j],"script")&&(!e[j].type||e[j].type.toLowerCase()==="text/javascript"))f.push(e[j].parentNode?e[j].parentNode.removeChild(e[j]):e[j]);else{e[j].nodeType===1&&e.splice.apply(e,[j+1,0].concat(c.makeArray(e[j].getElementsByTagName("script"))));d.appendChild(e[j])}return e},cleanData:function(a){for(var b,d,f=c.cache,e=c.event.special,j=c.support.deleteExpando,i=0,o;(o=a[i])!=null;i++)if(d=o[c.expando]){b=f[d];if(b.events)for(var k in b.events)e[k]? -c.event.remove(o,k):Ca(o,k,b.handle);if(j)delete o[c.expando];else o.removeAttribute&&o.removeAttribute(c.expando);delete f[d]}}});var kb=/z-?index|font-?weight|opacity|zoom|line-?height/i,Na=/alpha\([^)]*\)/,Oa=/opacity=([^)]*)/,ha=/float/i,ia=/-([a-z])/ig,lb=/([A-Z])/g,mb=/^-?\d+(?:px)?$/i,nb=/^-?\d/,ob={position:"absolute",visibility:"hidden",display:"block"},pb=["Left","Right"],qb=["Top","Bottom"],rb=s.defaultView&&s.defaultView.getComputedStyle,Pa=c.support.cssFloat?"cssFloat":"styleFloat",ja= -function(a,b){return b.toUpperCase()};c.fn.css=function(a,b){return X(this,a,b,true,function(d,f,e){if(e===w)return c.curCSS(d,f);if(typeof e==="number"&&!kb.test(f))e+="px";c.style(d,f,e)})};c.extend({style:function(a,b,d){if(!a||a.nodeType===3||a.nodeType===8)return w;if((b==="width"||b==="height")&&parseFloat(d)<0)d=w;var f=a.style||a,e=d!==w;if(!c.support.opacity&&b==="opacity"){if(e){f.zoom=1;b=parseInt(d,10)+""==="NaN"?"":"alpha(opacity="+d*100+")";a=f.filter||c.curCSS(a,"filter")||"";f.filter= -Na.test(a)?a.replace(Na,b):b}return f.filter&&f.filter.indexOf("opacity=")>=0?parseFloat(Oa.exec(f.filter)[1])/100+"":""}if(ha.test(b))b=Pa;b=b.replace(ia,ja);if(e)f[b]=d;return f[b]},css:function(a,b,d,f){if(b==="width"||b==="height"){var e,j=b==="width"?pb:qb;function i(){e=b==="width"?a.offsetWidth:a.offsetHeight;f!=="border"&&c.each(j,function(){f||(e-=parseFloat(c.curCSS(a,"padding"+this,true))||0);if(f==="margin")e+=parseFloat(c.curCSS(a,"margin"+this,true))||0;else e-=parseFloat(c.curCSS(a, -"border"+this+"Width",true))||0})}a.offsetWidth!==0?i():c.swap(a,ob,i);return Math.max(0,Math.round(e))}return c.curCSS(a,b,d)},curCSS:function(a,b,d){var f,e=a.style;if(!c.support.opacity&&b==="opacity"&&a.currentStyle){f=Oa.test(a.currentStyle.filter||"")?parseFloat(RegExp.$1)/100+"":"";return f===""?"1":f}if(ha.test(b))b=Pa;if(!d&&e&&e[b])f=e[b];else if(rb){if(ha.test(b))b="float";b=b.replace(lb,"-$1").toLowerCase();e=a.ownerDocument.defaultView;if(!e)return null;if(a=e.getComputedStyle(a,null))f= -a.getPropertyValue(b);if(b==="opacity"&&f==="")f="1"}else if(a.currentStyle){d=b.replace(ia,ja);f=a.currentStyle[b]||a.currentStyle[d];if(!mb.test(f)&&nb.test(f)){b=e.left;var j=a.runtimeStyle.left;a.runtimeStyle.left=a.currentStyle.left;e.left=d==="fontSize"?"1em":f||0;f=e.pixelLeft+"px";e.left=b;a.runtimeStyle.left=j}}return f},swap:function(a,b,d){var f={};for(var e in b){f[e]=a.style[e];a.style[e]=b[e]}d.call(a);for(e in b)a.style[e]=f[e]}});if(c.expr&&c.expr.filters){c.expr.filters.hidden=function(a){var b= -a.offsetWidth,d=a.offsetHeight,f=a.nodeName.toLowerCase()==="tr";return b===0&&d===0&&!f?true:b>0&&d>0&&!f?false:c.curCSS(a,"display")==="none"};c.expr.filters.visible=function(a){return!c.expr.filters.hidden(a)}}var sb=J(),tb=//gi,ub=/select|textarea/i,vb=/color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week/i,N=/=\?(&|$)/,ka=/\?/,wb=/(\?|&)_=.*?(&|$)/,xb=/^(\w+:)?\/\/([^\/?#]+)/,yb=/%20/g,zb=c.fn.load;c.fn.extend({load:function(a,b,d){if(typeof a!== -"string")return zb.call(this,a);else if(!this.length)return this;var f=a.indexOf(" ");if(f>=0){var e=a.slice(f,a.length);a=a.slice(0,f)}f="GET";if(b)if(c.isFunction(b)){d=b;b=null}else if(typeof b==="object"){b=c.param(b,c.ajaxSettings.traditional);f="POST"}var j=this;c.ajax({url:a,type:f,dataType:"html",data:b,complete:function(i,o){if(o==="success"||o==="notmodified")j.html(e?c("
").append(i.responseText.replace(tb,"")).find(e):i.responseText);d&&j.each(d,[i.responseText,o,i])}});return this}, -serialize:function(){return c.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?c.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||ub.test(this.nodeName)||vb.test(this.type))}).map(function(a,b){a=c(this).val();return a==null?null:c.isArray(a)?c.map(a,function(d){return{name:b.name,value:d}}):{name:b.name,value:a}}).get()}});c.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "), -function(a,b){c.fn[b]=function(d){return this.bind(b,d)}});c.extend({get:function(a,b,d,f){if(c.isFunction(b)){f=f||d;d=b;b=null}return c.ajax({type:"GET",url:a,data:b,success:d,dataType:f})},getScript:function(a,b){return c.get(a,null,b,"script")},getJSON:function(a,b,d){return c.get(a,b,d,"json")},post:function(a,b,d,f){if(c.isFunction(b)){f=f||d;d=b;b={}}return c.ajax({type:"POST",url:a,data:b,success:d,dataType:f})},ajaxSetup:function(a){c.extend(c.ajaxSettings,a)},ajaxSettings:{url:location.href, -global:true,type:"GET",contentType:"application/x-www-form-urlencoded",processData:true,async:true,xhr:A.XMLHttpRequest&&(A.location.protocol!=="file:"||!A.ActiveXObject)?function(){return new A.XMLHttpRequest}:function(){try{return new A.ActiveXObject("Microsoft.XMLHTTP")}catch(a){}},accepts:{xml:"application/xml, text/xml",html:"text/html",script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},lastModified:{},etag:{},ajax:function(a){function b(){e.success&& -e.success.call(k,o,i,x);e.global&&f("ajaxSuccess",[x,e])}function d(){e.complete&&e.complete.call(k,x,i);e.global&&f("ajaxComplete",[x,e]);e.global&&!--c.active&&c.event.trigger("ajaxStop")}function f(q,p){(e.context?c(e.context):c.event).trigger(q,p)}var e=c.extend(true,{},c.ajaxSettings,a),j,i,o,k=a&&a.context||e,n=e.type.toUpperCase();if(e.data&&e.processData&&typeof e.data!=="string")e.data=c.param(e.data,e.traditional);if(e.dataType==="jsonp"){if(n==="GET")N.test(e.url)||(e.url+=(ka.test(e.url)? -"&":"?")+(e.jsonp||"callback")+"=?");else if(!e.data||!N.test(e.data))e.data=(e.data?e.data+"&":"")+(e.jsonp||"callback")+"=?";e.dataType="json"}if(e.dataType==="json"&&(e.data&&N.test(e.data)||N.test(e.url))){j=e.jsonpCallback||"jsonp"+sb++;if(e.data)e.data=(e.data+"").replace(N,"="+j+"$1");e.url=e.url.replace(N,"="+j+"$1");e.dataType="script";A[j]=A[j]||function(q){o=q;b();d();A[j]=w;try{delete A[j]}catch(p){}z&&z.removeChild(C)}}if(e.dataType==="script"&&e.cache===null)e.cache=false;if(e.cache=== -false&&n==="GET"){var r=J(),u=e.url.replace(wb,"$1_="+r+"$2");e.url=u+(u===e.url?(ka.test(e.url)?"&":"?")+"_="+r:"")}if(e.data&&n==="GET")e.url+=(ka.test(e.url)?"&":"?")+e.data;e.global&&!c.active++&&c.event.trigger("ajaxStart");r=(r=xb.exec(e.url))&&(r[1]&&r[1]!==location.protocol||r[2]!==location.host);if(e.dataType==="script"&&n==="GET"&&r){var z=s.getElementsByTagName("head")[0]||s.documentElement,C=s.createElement("script");C.src=e.url;if(e.scriptCharset)C.charset=e.scriptCharset;if(!j){var B= -false;C.onload=C.onreadystatechange=function(){if(!B&&(!this.readyState||this.readyState==="loaded"||this.readyState==="complete")){B=true;b();d();C.onload=C.onreadystatechange=null;z&&C.parentNode&&z.removeChild(C)}}}z.insertBefore(C,z.firstChild);return w}var E=false,x=e.xhr();if(x){e.username?x.open(n,e.url,e.async,e.username,e.password):x.open(n,e.url,e.async);try{if(e.data||a&&a.contentType)x.setRequestHeader("Content-Type",e.contentType);if(e.ifModified){c.lastModified[e.url]&&x.setRequestHeader("If-Modified-Since", -c.lastModified[e.url]);c.etag[e.url]&&x.setRequestHeader("If-None-Match",c.etag[e.url])}r||x.setRequestHeader("X-Requested-With","XMLHttpRequest");x.setRequestHeader("Accept",e.dataType&&e.accepts[e.dataType]?e.accepts[e.dataType]+", */*":e.accepts._default)}catch(ga){}if(e.beforeSend&&e.beforeSend.call(k,x,e)===false){e.global&&!--c.active&&c.event.trigger("ajaxStop");x.abort();return false}e.global&&f("ajaxSend",[x,e]);var g=x.onreadystatechange=function(q){if(!x||x.readyState===0||q==="abort"){E|| -d();E=true;if(x)x.onreadystatechange=c.noop}else if(!E&&x&&(x.readyState===4||q==="timeout")){E=true;x.onreadystatechange=c.noop;i=q==="timeout"?"timeout":!c.httpSuccess(x)?"error":e.ifModified&&c.httpNotModified(x,e.url)?"notmodified":"success";var p;if(i==="success")try{o=c.httpData(x,e.dataType,e)}catch(v){i="parsererror";p=v}if(i==="success"||i==="notmodified")j||b();else c.handleError(e,x,i,p);d();q==="timeout"&&x.abort();if(e.async)x=null}};try{var h=x.abort;x.abort=function(){x&&h.call(x); -g("abort")}}catch(l){}e.async&&e.timeout>0&&setTimeout(function(){x&&!E&&g("timeout")},e.timeout);try{x.send(n==="POST"||n==="PUT"||n==="DELETE"?e.data:null)}catch(m){c.handleError(e,x,null,m);d()}e.async||g();return x}},handleError:function(a,b,d,f){if(a.error)a.error.call(a.context||a,b,d,f);if(a.global)(a.context?c(a.context):c.event).trigger("ajaxError",[b,a,f])},active:0,httpSuccess:function(a){try{return!a.status&&location.protocol==="file:"||a.status>=200&&a.status<300||a.status===304||a.status=== -1223||a.status===0}catch(b){}return false},httpNotModified:function(a,b){var d=a.getResponseHeader("Last-Modified"),f=a.getResponseHeader("Etag");if(d)c.lastModified[b]=d;if(f)c.etag[b]=f;return a.status===304||a.status===0},httpData:function(a,b,d){var f=a.getResponseHeader("content-type")||"",e=b==="xml"||!b&&f.indexOf("xml")>=0;a=e?a.responseXML:a.responseText;e&&a.documentElement.nodeName==="parsererror"&&c.error("parsererror");if(d&&d.dataFilter)a=d.dataFilter(a,b);if(typeof a==="string")if(b=== -"json"||!b&&f.indexOf("json")>=0)a=c.parseJSON(a);else if(b==="script"||!b&&f.indexOf("javascript")>=0)c.globalEval(a);return a},param:function(a,b){function d(i,o){if(c.isArray(o))c.each(o,function(k,n){b||/\[\]$/.test(i)?f(i,n):d(i+"["+(typeof n==="object"||c.isArray(n)?k:"")+"]",n)});else!b&&o!=null&&typeof o==="object"?c.each(o,function(k,n){d(i+"["+k+"]",n)}):f(i,o)}function f(i,o){o=c.isFunction(o)?o():o;e[e.length]=encodeURIComponent(i)+"="+encodeURIComponent(o)}var e=[];if(b===w)b=c.ajaxSettings.traditional; -if(c.isArray(a)||a.jquery)c.each(a,function(){f(this.name,this.value)});else for(var j in a)d(j,a[j]);return e.join("&").replace(yb,"+")}});var la={},Ab=/toggle|show|hide/,Bb=/^([+-]=)?([\d+-.]+)(.*)$/,W,va=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]];c.fn.extend({show:function(a,b){if(a||a===0)return this.animate(K("show",3),a,b);else{a=0;for(b=this.length;a").appendTo("body");f=e.css("display");if(f==="none")f="block";e.remove();la[d]=f}c.data(this[a],"olddisplay",f)}}a=0;for(b=this.length;a=0;f--)if(d[f].elem===this){b&&d[f](true);d.splice(f,1)}});b||this.dequeue();return this}});c.each({slideDown:K("show",1),slideUp:K("hide",1),slideToggle:K("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"}},function(a,b){c.fn[a]=function(d,f){return this.animate(b,d,f)}});c.extend({speed:function(a,b,d){var f=a&&typeof a==="object"?a:{complete:d||!d&&b||c.isFunction(a)&&a,duration:a,easing:d&&b||b&&!c.isFunction(b)&&b};f.duration=c.fx.off?0:typeof f.duration=== -"number"?f.duration:c.fx.speeds[f.duration]||c.fx.speeds._default;f.old=f.complete;f.complete=function(){f.queue!==false&&c(this).dequeue();c.isFunction(f.old)&&f.old.call(this)};return f},easing:{linear:function(a,b,d,f){return d+f*a},swing:function(a,b,d,f){return(-Math.cos(a*Math.PI)/2+0.5)*f+d}},timers:[],fx:function(a,b,d){this.options=b;this.elem=a;this.prop=d;if(!b.orig)b.orig={}}});c.fx.prototype={update:function(){this.options.step&&this.options.step.call(this.elem,this.now,this);(c.fx.step[this.prop]|| -c.fx.step._default)(this);if((this.prop==="height"||this.prop==="width")&&this.elem.style)this.elem.style.display="block"},cur:function(a){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null))return this.elem[this.prop];return(a=parseFloat(c.css(this.elem,this.prop,a)))&&a>-10000?a:parseFloat(c.curCSS(this.elem,this.prop))||0},custom:function(a,b,d){function f(j){return e.step(j)}this.startTime=J();this.start=a;this.end=b;this.unit=d||this.unit||"px";this.now=this.start; -this.pos=this.state=0;var e=this;f.elem=this.elem;if(f()&&c.timers.push(f)&&!W)W=setInterval(c.fx.tick,13)},show:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.show=true;this.custom(this.prop==="width"||this.prop==="height"?1:0,this.cur());c(this.elem).show()},hide:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.hide=true;this.custom(this.cur(),0)},step:function(a){var b=J(),d=true;if(a||b>=this.options.duration+this.startTime){this.now= -this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;for(var f in this.options.curAnim)if(this.options.curAnim[f]!==true)d=false;if(d){if(this.options.display!=null){this.elem.style.overflow=this.options.overflow;a=c.data(this.elem,"olddisplay");this.elem.style.display=a?a:this.options.display;if(c.css(this.elem,"display")==="none")this.elem.style.display="block"}this.options.hide&&c(this.elem).hide();if(this.options.hide||this.options.show)for(var e in this.options.curAnim)c.style(this.elem, -e,this.options.orig[e]);this.options.complete.call(this.elem)}return false}else{e=b-this.startTime;this.state=e/this.options.duration;a=this.options.easing||(c.easing.swing?"swing":"linear");this.pos=c.easing[this.options.specialEasing&&this.options.specialEasing[this.prop]||a](this.state,e,0,1,this.options.duration);this.now=this.start+(this.end-this.start)*this.pos;this.update()}return true}};c.extend(c.fx,{tick:function(){for(var a=c.timers,b=0;b
"; -a.insertBefore(b,a.firstChild);d=b.firstChild;f=d.firstChild;e=d.nextSibling.firstChild.firstChild;this.doesNotAddBorder=f.offsetTop!==5;this.doesAddBorderForTableAndCells=e.offsetTop===5;f.style.position="fixed";f.style.top="20px";this.supportsFixedPosition=f.offsetTop===20||f.offsetTop===15;f.style.position=f.style.top="";d.style.overflow="hidden";d.style.position="relative";this.subtractsBorderForOverflowNotVisible=f.offsetTop===-5;this.doesNotIncludeMarginInBodyOffset=a.offsetTop!==j;a.removeChild(b); -c.offset.initialize=c.noop},bodyOffset:function(a){var b=a.offsetTop,d=a.offsetLeft;c.offset.initialize();if(c.offset.doesNotIncludeMarginInBodyOffset){b+=parseFloat(c.curCSS(a,"marginTop",true))||0;d+=parseFloat(c.curCSS(a,"marginLeft",true))||0}return{top:b,left:d}},setOffset:function(a,b,d){if(/static/.test(c.curCSS(a,"position")))a.style.position="relative";var f=c(a),e=f.offset(),j=parseInt(c.curCSS(a,"top",true),10)||0,i=parseInt(c.curCSS(a,"left",true),10)||0;if(c.isFunction(b))b=b.call(a, -d,e);d={top:b.top-e.top+j,left:b.left-e.left+i};"using"in b?b.using.call(a,d):f.css(d)}};c.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),d=this.offset(),f=/^body|html$/i.test(b[0].nodeName)?{top:0,left:0}:b.offset();d.top-=parseFloat(c.curCSS(a,"marginTop",true))||0;d.left-=parseFloat(c.curCSS(a,"marginLeft",true))||0;f.top+=parseFloat(c.curCSS(b[0],"borderTopWidth",true))||0;f.left+=parseFloat(c.curCSS(b[0],"borderLeftWidth",true))||0;return{top:d.top- -f.top,left:d.left-f.left}},offsetParent:function(){return this.map(function(){for(var a=this.offsetParent||s.body;a&&!/^body|html$/i.test(a.nodeName)&&c.css(a,"position")==="static";)a=a.offsetParent;return a})}});c.each(["Left","Top"],function(a,b){var d="scroll"+b;c.fn[d]=function(f){var e=this[0],j;if(!e)return null;if(f!==w)return this.each(function(){if(j=wa(this))j.scrollTo(!a?f:c(j).scrollLeft(),a?f:c(j).scrollTop());else this[d]=f});else return(j=wa(e))?"pageXOffset"in j?j[a?"pageYOffset": -"pageXOffset"]:c.support.boxModel&&j.document.documentElement[d]||j.document.body[d]:e[d]}});c.each(["Height","Width"],function(a,b){var d=b.toLowerCase();c.fn["inner"+b]=function(){return this[0]?c.css(this[0],d,false,"padding"):null};c.fn["outer"+b]=function(f){return this[0]?c.css(this[0],d,false,f?"margin":"border"):null};c.fn[d]=function(f){var e=this[0];if(!e)return f==null?null:this;if(c.isFunction(f))return this.each(function(j){var i=c(this);i[d](f.call(this,j,i[d]()))});return"scrollTo"in -e&&e.document?e.document.compatMode==="CSS1Compat"&&e.document.documentElement["client"+b]||e.document.body["client"+b]:e.nodeType===9?Math.max(e.documentElement["client"+b],e.body["scroll"+b],e.documentElement["scroll"+b],e.body["offset"+b],e.documentElement["offset"+b]):f===w?c.css(e,d):this.css(d,typeof f==="string"?f:f+"px")}});A.jQuery=A.$=c})(window); diff --git a/include/main.js b/include/main.js deleted file mode 100755 index f1c6cee1..00000000 --- a/include/main.js +++ /dev/null @@ -1,33 +0,0 @@ - - function openClose(theID) { - if(document.getElementById(theID).style.display == "block") { - document.getElementById(theID).style.display = "none" - } - else { - document.getElementById(theID).style.display = "block" - } - } - - function openMenu(theID) { - document.getElementById(theID).style.display = "block" - } - - function closeMenu(theID) { - document.getElementById(theID).style.display = "none" - } - - function commentOpen(obj,id) { - if(obj.value == 'Comment') { - obj.value = ''; - obj.className = "comment-edit-text-full"; - openMenu("comment-edit-submit-wrapper-" + id); - } - } - function commentClose(obj,id) { - if(obj.value == '') { - obj.value = 'Comment'; - obj.className="comment-edit-text-empty"; - closeMenu("comment-edit-submit-wrapper-" + id); - } - } - diff --git a/include/nav.php b/include/nav.php old mode 100755 new mode 100644 diff --git a/include/notifier.php b/include/notifier.php old mode 100755 new mode 100644 index 4e542e58..7972bd9a --- a/include/notifier.php +++ b/include/notifier.php @@ -1,312 +1,294 @@ set_baseurl(get_config('system','url')); +unset($db_host, $db_user, $db_pass, $db_data); - $cmd = $argv[1]; +require_once 'session.php'; +require_once 'datetime.php'; - switch($cmd) { - case 'mail': - default: - $item_id = intval($argv[2]); - if(! $item_id) - killme(); - break; - } +if ($argc < 3) { + exit; +} +$a->set_baseurl(get_config('system', 'url')); - $recipients = array(); +$cmd = $argv[1]; - if($cmd == 'mail') { - - $message = q("SELECT * FROM `mail` WHERE `id` = %d LIMIT 1", - intval($item_id) - ); - if(! count($message)) +switch ($cmd) { + case 'mail': + default: + $item_id = intval($argv[2]); + if (!$item_id) { killme(); - $recipients[] = $message[0]['contact-id']; - $item = $message[0]; + } + break; +} - } - else { - // find ancestors +$recipients = array(); - $r = q("SELECT `parent`, `edited` FROM `item` WHERE `id` = %d LIMIT 1", - intval($item_id) - ); - if(! count($r)) - killme(); +if ($cmd == 'mail') { - $parent = $r[0]['parent']; - $updated = $r[0]['edited']; - - $items = q("SELECT * FROM `item` WHERE `parent` = %d ORDER BY `id` ASC", - intval($parent) - ); - - if(! count($items)) - killme(); - } - - $r = q("SELECT * FROM `contact` WHERE `self` = 1 LIMIT 1"); - - if(count($r)) - $owner = $r[0]; - else + $message = q("SELECT * FROM `mail` WHERE `id` = %d LIMIT 1", intval($item_id)); + if (!count($message)) { killme(); + } + $recipients[] = $message[0]['contact-id']; + $item = $message[0]; +} else { + // find ancestors - if($cmd != 'mail') { - - require_once('include/group.php'); - - $parent = $items[0]; - - if($parent['type'] == 'remote') { - // local followup to remote post - $followup = true; - $conversant_str = dbesc($parent['contact-id']); - } - else { - $followup = false; - - $allow_people = expand_acl($parent['allow_cid']); - $allow_groups = expand_groups(expand_acl($parent['allow_gid'])); - $deny_people = expand_acl($parent['deny_cid']); - $deny_groups = expand_groups(expand_acl($parent['deny_gid'])); - - $conversants = array(); - - foreach($items as $item) { - $recipients[] = $item['contact-id']; - $conversants[] = $item['contact-id']; - } - - $conversants = array_unique($conversants,SORT_NUMERIC); - - - $recipients = array_unique(array_merge($recipients,$allow_people,$allow_groups),SORT_NUMERIC); - $deny = array_unique(array_merge($deny_people,$deny_groups),SORT_NUMERIC); - $recipients = array_diff($recipients,$deny); - - $conversant_str = dbesc(implode(', ',$conversants)); - } - - $r = q("SELECT * FROM `contact` WHERE `id` IN ( $conversant_str ) AND `blocked` = 0 AND `pending` = 0"); - - if( ! count($r)) - killme(); - - $contacts = $r; - - $tomb_template = file_get_contents('view/atom_tomb.tpl'); - $item_template = file_get_contents('view/atom_item.tpl'); - $cmnt_template = file_get_contents('view/atom_cmnt.tpl'); + $r = q("SELECT `parent`, `edited` FROM `item` WHERE `id` = %d LIMIT 1", intval($item_id)); + if (!count($r)) { + killme(); } - $feed_template = file_get_contents('view/atom_feed.tpl'); - $mail_template = file_get_contents('view/atom_mail.tpl'); + $parent = $r[0]['parent']; + $updated = $r[0]['edited']; - $atom = ''; + $items = q("SELECT * FROM `item` WHERE `parent` = %d ORDER BY `id` ASC", intval($parent)); + if (!count($items)) { + killme(); + } +} - $atom .= replace_macros($feed_template, array( - '$feed_id' => xmlify($a->get_baseurl()), - '$feed_title' => xmlify($owner['name']), - '$feed_updated' => xmlify(datetime_convert('UTC', 'UTC', - $updated . '+00:00' , 'Y-m-d\TH:i:s\Z')) , - '$name' => xmlify($owner['name']), - '$profile_page' => xmlify($owner['url']), - '$photo' => xmlify($owner['photo']), - '$thumb' => xmlify($owner['thumb']), - '$picdate' => xmlify(datetime_convert('UTC','UTC',$owner['avatar-date'] . '+00:00' , 'Y-m-d\TH:i:s\Z')) , - '$uridate' => xmlify(datetime_convert('UTC','UTC',$owner['uri-date'] . '+00:00' , 'Y-m-d\TH:i:s\Z')) , - '$namdate' => xmlify(datetime_convert('UTC','UTC',$owner['name-date'] . '+00:00' , 'Y-m-d\TH:i:s\Z')) +$r = q("SELECT * FROM `contact` WHERE `self` = 1 LIMIT 1"); + +if (count($r)) { + $owner = $r[0]; +} else { + killme(); +} + +if ($cmd != 'mail') { + + require_once 'include/group.php'; + + $parent = $items[0]; + + if ($parent['type'] == 'remote') { + // local followup to remote post + $followup = true; + $conversant_str = dbesc($parent['contact-id']); + } else { + $followup = false; + + $allow_people = expand_acl($parent['allow_cid']); + $allow_groups = expand_groups(expand_acl($parent['allow_gid'])); + $deny_people = expand_acl($parent['deny_cid']); + $deny_groups = expand_groups(expand_acl($parent['deny_gid'])); + + $conversants = array(); + + foreach ($items as $item) { + $recipients[] = $item['contact-id']; + $conversants[] = $item['contact-id']; + } + + $conversants = array_unique($conversants, SORT_NUMERIC); + + $recipients = array_unique(array_merge($recipients, $allow_people, $allow_groups), SORT_NUMERIC); + $deny = array_unique(array_merge($deny_people, $deny_groups), SORT_NUMERIC); + $recipients = array_diff($recipients, $deny); + + $conversant_str = dbesc(implode(', ', $conversants)); + } + + $r = q("SELECT * FROM `contact` WHERE `id` IN ( $conversant_str ) AND `blocked` = 0 AND `pending` = 0"); + + if (!count($r)) { + killme(); + } + + $contacts = $r; + + $tomb_template = file_get_contents('view/atom_tomb.tpl'); + $item_template = file_get_contents('view/atom_item.tpl'); + $cmnt_template = file_get_contents('view/atom_cmnt.tpl'); +} + +$feed_template = file_get_contents('view/atom_feed.tpl'); +$mail_template = file_get_contents('view/atom_mail.tpl'); + +$atom = ''; + +$atom .= replace_macros($feed_template, array( + '$feed_id' => xmlify($a->get_baseurl()), + '$feed_title' => xmlify($owner['name']), + '$feed_updated' => xmlify(datetime_convert('UTC', 'UTC', $updated . '+00:00', 'Y-m-d\TH:i:s\Z')), + '$name' => xmlify($owner['name']), + '$profile_page' => xmlify($owner['url']), + '$photo' => xmlify($owner['photo']), + '$thumb' => xmlify($owner['thumb']), + '$picdate' => xmlify(datetime_convert('UTC', 'UTC', $owner['avatar-date'] . '+00:00', 'Y-m-d\TH:i:s\Z')), + '$uridate' => xmlify(datetime_convert('UTC', 'UTC', $owner['uri-date'] . '+00:00', 'Y-m-d\TH:i:s\Z')), + '$namdate' => xmlify(datetime_convert('UTC', 'UTC', $owner['name-date'] . '+00:00', 'Y-m-d\TH:i:s\Z')) +)); + +if ($cmd == 'mail') { + $atom .= replace_macros($mail_template, array( + '$name' => xmlify($owner['name']), + '$profile_page' => xmlify($owner['url']), + '$thumb' => xmlify($owner['thumb']), + '$item_id' => xmlify($item['uri']), + '$subject' => xmlify($item['title']), + '$created' => xmlify(datetime_convert('UTC', 'UTC', $item['created'] . '+00:00', 'Y-m-d\TH:i:s\Z')), + '$content' => xmlify($item['body']), + '$parent_id' => xmlify($item['parent-uri']) )); - - if($cmd == 'mail') { - $atom .= replace_macros($mail_template, array( - '$name' => xmlify($owner['name']), - '$profile_page' => xmlify($owner['url']), - '$thumb' => xmlify($owner['thumb']), - '$item_id' => xmlify($item['uri']), - '$subject' => xmlify($item['title']), - '$created' => xmlify(datetime_convert('UTC', 'UTC', - $item['created'] . '+00:00' , 'Y-m-d\TH:i:s\Z')), - '$content' =>xmlify($item['body']), - '$parent_id' => xmlify($item['parent-uri']) - - )); - } - else { - - if($followup) { - foreach($items as $item) { - if($item['id'] == $item_id) { - $atom .= replace_macros($cmnt_template, array( - '$name' => xmlify($owner['name']), - '$profile_page' => xmlify($owner['url']), - '$thumb' => xmlify($owner['thumb']), - '$item_id' => xmlify($item['uri']), - '$title' => xmlify($item['title']), - '$published' => xmlify(datetime_convert('UTC', 'UTC', - $item['created'] . '+00:00' , 'Y-m-d\TH:i:s\Z')), - '$updated' => xmlify(datetime_convert('UTC', 'UTC', - $item['edited'] . '+00:00' , 'Y-m-d\TH:i:s\Z')), - '$content' =>xmlify($item['body']), - '$parent_id' => xmlify($item['parent-uri']), - '$comment_allow' => 0 - )); - } +} else { + if ($followup) { + foreach ($items as $item) { + if ($item['id'] == $item_id) { + $atom .= replace_macros($cmnt_template, array( + '$name' => xmlify($owner['name']), + '$profile_page' => xmlify($owner['url']), + '$thumb' => xmlify($owner['thumb']), + '$item_id' => xmlify($item['uri']), + '$title' => xmlify($item['title']), + '$published' => xmlify(datetime_convert('UTC', 'UTC', $item['created'] . '+00:00', 'Y-m-d\TH:i:s\Z')), + '$updated' => xmlify(datetime_convert('UTC', 'UTC', $item['edited'] . '+00:00', 'Y-m-d\TH:i:s\Z')), + '$content' => xmlify($item['body']), + '$parent_id' => xmlify($item['parent-uri']), + '$comment_allow' => 0 + )); } } - else { - foreach($items as $item) { - if($item['deleted']) { - $atom .= replace_macros($tomb_template, array( - '$id' => xmlify($item['uri']), - '$updated' => xmlify(datetime_convert('UTC', 'UTC', - $item['edited'] . '+00:00' , 'Y-m-d\TH:i:s\Z')) - )); - } - else { - foreach($contacts as $contact) { - if($item['contact-id'] == $contact['id']) { - if($item['parent'] == $item['id']) { - $atom .= replace_macros($item_template, array( - '$name' => xmlify($contact['name']), - '$profile_page' => xmlify($contact['url']), - '$thumb' => xmlify($contact['thumb']), - '$owner_name' => xmlify($item['owner-name']), - '$owner_profile_page' => xmlify($item['owner-link']), - '$owner_thumb' => xmlify($item['owner-avatar']), - '$item_id' => xmlify($item['uri']), - '$title' => xmlify($item['title']), - '$published' => xmlify(datetime_convert('UTC', 'UTC', - $item['created'] . '+00:00' , 'Y-m-d\TH:i:s\Z')), - '$updated' => xmlify(datetime_convert('UTC', 'UTC', - $item['edited'] . '+00:00' , 'Y-m-d\TH:i:s\Z')), - '$content' =>xmlify($item['body']), - '$comment_allow' => (($item['last-child'] && strlen($contact['dfrn-id'])) ? 1 : 0) - )); - } - else { - $atom .= replace_macros($cmnt_template, array( - '$name' => xmlify($contact['name']), - '$profile_page' => xmlify($contact['url']), - '$thumb' => xmlify($contact['thumb']), - '$item_id' => xmlify($item['uri']), - '$title' => xmlify($item['title']), - '$published' => xmlify(datetime_convert('UTC', 'UTC', - $item['created'] . '+00:00' , 'Y-m-d\TH:i:s\Z')), - '$updated' => xmlify(datetime_convert('UTC', 'UTC', - $item['edited'] . '+00:00' , 'Y-m-d\TH:i:s\Z')), - '$content' =>xmlify($item['body']), - '$parent_id' => xmlify($item['parent-uri']), - '$comment_allow' => (($item['last-child']) ? 1 : 0) - )); - } + } else { + foreach ($items as $item) { + if ($item['deleted']) { + $atom .= replace_macros($tomb_template, array( + '$id' => xmlify($item['uri']), + '$updated' => xmlify(datetime_convert('UTC', 'UTC', $item['edited'] . '+00:00', 'Y-m-d\TH:i:s\Z')) + )); + } else { + foreach ($contacts as $contact) { + if ($item['contact-id'] == $contact['id']) { + if ($item['parent'] == $item['id']) { + $atom .= replace_macros($item_template, array( + '$name' => xmlify($contact['name']), + '$profile_page' => xmlify($contact['url']), + '$thumb' => xmlify($contact['thumb']), + '$owner_name' => xmlify($item['owner-name']), + '$owner_profile_page' => xmlify($item['owner-link']), + '$owner_thumb' => xmlify($item['owner-avatar']), + '$item_id' => xmlify($item['uri']), + '$title' => xmlify($item['title']), + '$published' => xmlify(datetime_convert('UTC', 'UTC', $item['created'] . '+00:00', 'Y-m-d\TH:i:s\Z')), + '$updated' => xmlify(datetime_convert('UTC', 'UTC', $item['edited'] . '+00:00', 'Y-m-d\TH:i:s\Z')), + '$content' => xmlify($item['body']), + '$comment_allow' => (($item['last-child'] && strlen($contact['dfrn-id'])) ? 1 : 0) + )); + } else { + $atom .= replace_macros($cmnt_template, array( + '$name' => xmlify($contact['name']), + '$profile_page' => xmlify($contact['url']), + '$thumb' => xmlify($contact['thumb']), + '$item_id' => xmlify($item['uri']), + '$title' => xmlify($item['title']), + '$published' => xmlify(datetime_convert('UTC', 'UTC', $item['created'] . '+00:00', 'Y-m-d\TH:i:s\Z')), + '$updated' => xmlify(datetime_convert('UTC', 'UTC', $item['edited'] . '+00:00', 'Y-m-d\TH:i:s\Z')), + '$content' => xmlify($item['body']), + '$parent_id' => xmlify($item['parent-uri']), + '$comment_allow' => (($item['last-child']) ? 1 : 0) + )); } } } } } } - $atom .= "\r\n"; +} +$atom .= "\r\n"; - // create a clone of this feed but with comments disabled to send to those who can't respond. +// create a clone of this feed but with comments disabled to send to those who can't respond. - $atom_nowrite = str_replace('1','0',$atom); +$atom_nowrite = str_replace('1', '0', $atom); - if($followup) - $recip_str = $parent['contact-id']; - else - $recip_str = implode(', ', $recipients); +if ($followup) { + $recip_str = $parent['contact-id']; +} else { + $recip_str = implode(', ', $recipients); +} - $r = q("SELECT * FROM `contact` WHERE `id` IN ( %s ) ", - dbesc($recip_str) - ); - if(! count($r)) - killme(); +$r = q("SELECT * FROM `contact` WHERE `id` IN ( %s ) ", dbesc($recip_str)); +if (!count($r)) { + killme(); +} - // delivery loop +// delivery loop - foreach($r as $rr) { - if($rr['self']) - continue; - - if(! strlen($rr['dfrn-id'])) - continue; - - - $url = $rr['notify'] . '?dfrn_id=' . $rr['dfrn-id']; - - $xml = fetch_url($url); - - if(! $xml) - continue; - - $res = simplexml_load_string($xml); - - if((intval($res->status) != 0) || (! strlen($res->challenge)) || (! strlen($res->dfrn_id))) - continue; - - $postvars = array(); - $sent_dfrn_id = hex2bin($res->dfrn_id); - - $final_dfrn_id = ''; - openssl_public_decrypt($sent_dfrn_id,$final_dfrn_id,$rr['pubkey']); - $final_dfrn_id = substr($final_dfrn_id, 0, strpos($final_dfrn_id, '.')); - if($final_dfrn_id != $rr['dfrn-id']) { - // did not decode properly - cannot trust this site - continue; - } - - $postvars['dfrn_id'] = $rr['dfrn-id']; - - $challenge = hex2bin($res->challenge); - - openssl_public_decrypt($challenge,$postvars['challenge'],$rr['pubkey']); - - if($cmd == 'mail') { - $postvars['data'] = $atom; - } - elseif(strlen($rr['dfrn-id']) && (! ($rr['blocked']) || ($rr['readonly']))) { - $postvars['data'] = $atom; - } - else { - $postvars['data'] = $atom_nowrite; - } - - $xml = post_url($rr['notify'],$postvars); - - $res = simplexml_load_string($xml); - - // Currently there is no retry attempt for failed mail delivery. - // We need to handle this in the UI, report the non-deliverables and try again - - if(($cmd == 'mail') && (intval($res->status) == 0)) { - - $r = q("UPDATE `mail` SET `delivered` = 1 WHERE `id` = %d LIMIT 1", - intval($item_id) - ); - } +foreach ($r as $rr) { + if ($rr['self']) { + continue; } - killme(); + if (!strlen($rr['dfrn-id'])) { + continue; + } + $url = $rr['notify'] . '?dfrn_id=' . $rr['dfrn-id']; + + $xml = fetch_url($url); + + if (!$xml) { + continue; + } + + $res = simplexml_load_string($xml); + + if ((intval($res->status) != 0) || (!strlen($res->challenge)) || (!strlen($res->dfrn_id))) { + continue; + } + + $postvars = array(); + $sent_dfrn_id = hex2bin($res->dfrn_id); + + $final_dfrn_id = ''; + openssl_public_decrypt($sent_dfrn_id, $final_dfrn_id, $rr['pubkey']); + $final_dfrn_id = substr($final_dfrn_id, 0, strpos($final_dfrn_id, '.')); + if ($final_dfrn_id != $rr['dfrn-id']) { + // did not decode properly - cannot trust this site + continue; + } + + $postvars['dfrn_id'] = $rr['dfrn-id']; + + $challenge = hex2bin($res->challenge); + + openssl_public_decrypt($challenge, $postvars['challenge'], $rr['pubkey']); + + if ($cmd == 'mail') { + $postvars['data'] = $atom; + } elseif (strlen($rr['dfrn-id']) && (!($rr['blocked']) || ($rr['readonly']))) { + $postvars['data'] = $atom; + } else { + $postvars['data'] = $atom_nowrite; + } + + $xml = post_url($rr['notify'], $postvars); + + $res = simplexml_load_string($xml); + + // Currently there is no retry attempt for failed mail delivery. + // We need to handle this in the UI, report the non-deliverables and try again + + if (($cmd == 'mail') && (intval($res->status) == 0)) { + $r = q("UPDATE `mail` SET `delivered` = 1 WHERE `id` = %d LIMIT 1", intval($item_id)); + } +} + +killme(); diff --git a/include/poller.php b/include/poller.php old mode 100755 new mode 100644 index 2bf3629e..0e3092f5 --- a/include/poller.php +++ b/include/poller.php @@ -1,273 +1,269 @@ set_baseurl(get_config('system','url')); +$db = new dba($db_host, $db_user, $db_pass, $db_data); - $contacts = q("SELECT * FROM `contact` - WHERE `dfrn-id` != '' AND `self` = 0 AND `blocked` = 0 +unset($db_host, $db_user, $db_pass, $db_data); + +require_once 'session.php'; +require_once 'datetime.php'; +require_once 'simplepie/simplepie.inc'; +require_once 'include/items.php'; + +$a->set_baseurl(get_config('system', 'url')); + +$contacts = q("SELECT * FROM `contact` + WHERE `dfrn-id` != '' AND `self` = 0 AND `blocked` = 0 AND `readonly` = 0 ORDER BY RAND()"); - if(! count($contacts)) - killme(); +if (!count($contacts)) { + killme(); +} - foreach($contacts as $contact) { +foreach ($contacts as $contact) { + if ($contact['priority']) { + $update = false; + $t = $contact['last-update']; - if($contact['priority']) { - - $update = false; - $t = $contact['last-update']; - - switch ($contact['priority']) { - case 5: - if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', t . " + 1 month")) - $update = true; - break; - case 4: - if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', t . " + 1 week")) - $update = true; - break; - case 3: - if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', t . " + 1 day")) - $update = true; - break; - case 2: - if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', t . " + 12 hour")) - $update = true; - break; - case 1: - default: - if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', t . " + 1 hour")) - $update = true; - break; - } - if(! $update) - continue; + switch ($contact['priority']) { + case 5: + if (datetime_convert('UTC', 'UTC', 'now') > datetime_convert('UTC', 'UTC', t . " + 1 month")) + $update = true; + break; + case 4: + if (datetime_convert('UTC', 'UTC', 'now') > datetime_convert('UTC', 'UTC', t . " + 1 week")) + $update = true; + break; + case 3: + if (datetime_convert('UTC', 'UTC', 'now') > datetime_convert('UTC', 'UTC', t . " + 1 day")) + $update = true; + break; + case 2: + if (datetime_convert('UTC', 'UTC', 'now') > datetime_convert('UTC', 'UTC', t . " + 12 hour")) + $update = true; + break; + case 1: + default: + if (datetime_convert('UTC', 'UTC', 'now') > datetime_convert('UTC', 'UTC', t . " + 1 hour")) + $update = true; + break; } - - - $r = q("SELECT * FROM `contact` WHERE `self` = 1 LIMIT 1"); - if(! count($r)) - continue; - - $importer = $r[0]; - - $last_update = (($contact['last-update'] == '0000-00-00 00:00:00') - ? datetime_convert('UTC','UTC','now - 30 days','Y-m-d\TH:i:s\Z') - : datetime_convert('UTC','UTC',$contact['last-update'],'Y-m-d\TH:i:s\Z')); - - $url = $contact['poll'] . '?dfrn_id=' . $contact['dfrn-id'] . '&type=data&last_update=' . $last_update ; - - $xml = fetch_url($url); - if(! $xml) - continue; - - $res = simplexml_load_string($xml); - - if((intval($res->status) != 0) || (! strlen($res->challenge)) || (! strlen($res->dfrn_id))) - continue; - - $postvars = array(); - - $sent_dfrn_id = hex2bin($res->dfrn_id); - - $final_dfrn_id = ''; - openssl_public_decrypt($sent_dfrn_id,$final_dfrn_id,$contact['pubkey']); - $final_dfrn_id = substr($final_dfrn_id, 0, strpos($final_dfrn_id, '.')); - if($final_dfrn_id != $contact['dfrn-id']) { - // did not decode properly - cannot trust this site + if (!$update) { continue; } + } - $postvars['dfrn_id'] = $contact['dfrn-id']; - $challenge = hex2bin($res->challenge); + $r = q("SELECT * FROM `contact` WHERE `self` = 1 LIMIT 1"); + if (!count($r)) { + continue; + } - openssl_public_decrypt($challenge,$postvars['challenge'],$contact['pubkey']); + $importer = $r[0]; - $xml = post_url($contact['poll'],$postvars); + $last_update = (($contact['last-update'] == '0000-00-00 00:00:00') ? datetime_convert('UTC', 'UTC', 'now - 30 days', 'Y-m-d\TH:i:s\Z') : datetime_convert('UTC', 'UTC', $contact['last-update'], 'Y-m-d\TH:i:s\Z')); - if(! strlen($xml)) { - // an empty response may mean there's nothing new - record the fact that we checked - $r = q("UPDATE `contact` SET `last-update` = '%s' WHERE `id` = %d LIMIT 1", - dbesc(datetime_convert()), - intval($contact['id']) - ); - continue; - } + $url = $contact['poll'] . '?dfrn_id=' . $contact['dfrn-id'] . '&type=data&last_update=' . $last_update; - $feed = new SimplePie(); - $feed->set_raw_data($xml); - $feed->enable_order_by_date(false); - $feed->init(); + $xml = fetch_url($url); + if (!$xml) { + continue; + } - $photo_rawupdate = $feed->get_feed_tags(NAMESPACE_DFRN,'icon-updated'); - if($photo_rawupdate) { - $photo_timestamp = datetime_convert('UTC','UTC',$photo_rawupdate[0]['data']); - $photo_url = $feed->get_image_url(); - if(strlen($photo_url) && $photo_timestamp > $contact['avatar-date']) { + $res = simplexml_load_string($xml); - require_once("Photo.php"); + if ((intval($res->status) != 0) || (!strlen($res->challenge)) || (!strlen($res->dfrn_id))) { + continue; + } - $photo_failure = false; + $postvars = array(); - $r = q("SELECT `resource-id` FROM `photo` WHERE `contact-id` = %d LIMIT 1", - intval($contact['id']) - ); - if(count($r)) { - $resource_id = $r[0]['resource-id']; - $img_str = fetch_url($photo_url,true); - $img = new Photo($img_str); - if($img) { - q("DELETE FROM `photo` WHERE `resource-id` = '%s' AND contact-id` = %d ", - dbesc($resource_id), - intval($contact['id']) - ); + $sent_dfrn_id = hex2bin($res->dfrn_id); - $img->scaleImageSquare(175); - - $hash = $resource_id; + $final_dfrn_id = ''; + openssl_public_decrypt($sent_dfrn_id, $final_dfrn_id, $contact['pubkey']); + $final_dfrn_id = substr($final_dfrn_id, 0, strpos($final_dfrn_id, '.')); + if ($final_dfrn_id != $contact['dfrn-id']) { + // did not decode properly - cannot trust this site + continue; + } - $r = $img->store($contact['id'], $hash, basename($photo_url), t('Contact Photos') , 4); - - $img->scaleImage(80); - $r = $img->store($contact['id'], $hash, basename($photo_url), t('Contact Photos') , 5); - if($r) - q("UPDATE `contact` SET `avatar-date` = '%s' WHERE `id` = %d LIMIT 1", - dbesc(datetime_convert()), - intval($contact['id']) - ); - } - } - } - } + $postvars['dfrn_id'] = $contact['dfrn-id']; + $challenge = hex2bin($res->challenge); - - foreach($feed->get_items() as $item) { + openssl_public_decrypt($challenge, $postvars['challenge'], $contact['pubkey']); - $deleted = false; + $xml = post_url($contact['poll'], $postvars); - $rawdelete = $item->get_item_tags("http://purl.org/atompub/tombstones/1.0", 'deleted-entry'); - if(isset($rawdelete[0]['attribs']['']['ref'])) { - $uri = $rawthread[0]['attribs']['']['ref']; - $deleted = true; - if(isset($rawdelete[0]['attribs']['']['when'])) { - $when = $rawthread[0]['attribs']['']['when']; - $when = datetime_convert('UTC','UTC', $when, 'Y-m-d H:i:s'); - } - else - $when = datetime_convert('UTC','UTC','now','Y-m-d H:i:s'); - } - if($deleted) { - $r = q("SELECT * FROM `item` WHERE `uri` = '%s' LIMIT 1", - dbesc($uri) - ); - if(count($r)) { - if($r[0]['uri'] == $r[0]['parent-uri']) { - $r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', - `body` = '', `title` = '' - WHERE `parent-uri` = '%s'", - dbesc($when), - dbesc($r[0]['uri']) - ); - } - else { - $r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', - `body` = '', `title` = '' - WHERE `uri` = '%s' LIMIT 1", - dbesc($when), - dbesc($uri) - ); - } - } - continue; - } - - - $is_reply = false; - $item_id = $item->get_id(); - $rawthread = $item->get_item_tags("http://purl.org/syndication/thread/1.0",'in-reply-to'); - if(isset($rawthread[0]['attribs']['']['ref'])) { - $is_reply = true; - $parent_uri = $rawthread[0]['attribs']['']['ref']; - } - - - if($is_reply) { - - // Have we seen it? If not, import it. - - $item_id = $item->get_id(); - - $r = q("SELECT `last-child`, `edited` FROM `item` WHERE `uri` = '%s' LIMIT 1", - dbesc($item_id) - ); - // FIXME update content if 'updated' changes - if(count($r)) { - $allow = $item->get_item_tags( NAMESPACE_DFRN , 'comment-allow'); - if($allow && $allow[0]['data'] != $r[0]['last-child']) { - $r = q("UPDATE `item` SET `last-child` = %d WHERE `uri` = '%s' LIMIT 1", - intval($allow[0]['data']), - dbesc($item_id) - ); - } - continue; - } - $datarray = get_atom_elements($item); - $datarray['parent-uri'] = $parent_uri; - $datarray['contact-id'] = $contact['id']; - $r = post_remote($a,$datarray); - continue; - } - - else { - // Head post of a conversation. Have we seen it? If not, import it. - - $item_id = $item->get_id(); - $r = q("SELECT `last-child`, `edited` FROM `item` WHERE `uri` = '%s' LIMIT 1", - dbesc($item_id) - ); - if(count($r)) { - $allow = $item->get_item_tags( NAMESPACE_DFRN ,'comment-allow'); - if($allow && $allow[0]['data'] != $r[0]['last-child']) { - $r = q("UPDATE `item` SET `last-child` = %d WHERE `uri` = '%s' LIMIT 1", - intval($allow[0]['data']), - dbesc($item_id) - ); - } - continue; - } - - $datarray = get_atom_elements($item); - $datarray['parent-uri'] = $item_id; - $datarray['contact-id'] = $contact['id']; - $r = post_remote($a,$datarray); - continue; - - } - - } - - $r = q("UPDATE `contact` SET `last-update` = '%s' WHERE `id` = %d LIMIT 1", + if (!strlen($xml)) { + // an empty response may mean there's nothing new - record the fact that we checked + $r = q( + "UPDATE `contact` SET `last-update` = '%s' WHERE `id` = %d LIMIT 1", dbesc(datetime_convert()), intval($contact['id']) ); - + continue; } - - killme(); + $feed = new SimplePie(); + $feed->set_raw_data($xml); + $feed->enable_order_by_date(false); + $feed->init(); + $photo_rawupdate = $feed->get_feed_tags(NAMESPACE_DFRN, 'icon-updated'); + if ($photo_rawupdate) { + $photo_timestamp = datetime_convert('UTC', 'UTC', $photo_rawupdate[0]['data']); + $photo_url = $feed->get_image_url(); + + if (strlen($photo_url) && $photo_timestamp > $contact['avatar-date']) { + require_once 'Photo.php'; + + $photo_failure = false; + + $r = q("SELECT `resource-id` FROM `photo` WHERE `contact-id` = %d LIMIT 1", intval($contact['id'])); + + if (count($r)) { + $resource_id = $r[0]['resource-id']; + $img_str = fetch_url($photo_url, true); + $img = new Photo($img_str); + + if ($img) { + q("DELETE FROM `photo` WHERE `resource-id` = '%s' AND contact-id` = %d ", + dbesc($resource_id), + intval($contact['id']) + ); + + $img->scaleImageSquare(175); + + $hash = $resource_id; + + $r = $img->store($contact['id'], $hash, basename($photo_url), t('Contact Photos'), 4); + + $img->scaleImage(80); + $r = $img->store($contact['id'], $hash, basename($photo_url), t('Contact Photos'), 5); + if ($r) { + q("UPDATE `contact` SET `avatar-date` = '%s' WHERE `id` = %d LIMIT 1", + dbesc(datetime_convert()), + intval($contact['id']) + ); + } + } + } + } + } + + foreach ($feed->get_items() as $item) { + $deleted = false; + + $rawdelete = $item->get_item_tags("http://purl.org/atompub/tombstones/1.0", 'deleted-entry'); + + if (isset($rawdelete[0]['attribs']['']['ref'])) { + $uri = $rawthread[0]['attribs']['']['ref']; + $deleted = true; + + if (isset($rawdelete[0]['attribs']['']['when'])) { + $when = $rawthread[0]['attribs']['']['when']; + $when = datetime_convert('UTC', 'UTC', $when, 'Y-m-d H:i:s'); + } else { + $when = datetime_convert('UTC', 'UTC', 'now', 'Y-m-d H:i:s'); + } + } + + if ($deleted) { + $r = q("SELECT * FROM `item` WHERE `uri` = '%s' LIMIT 1", dbesc($uri)); + if (count($r)) { + if ($r[0]['uri'] == $r[0]['parent-uri']) { + $r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', + `body` = '', `title` = '' + WHERE `parent-uri` = '%s'", + dbesc($when), + dbesc($r[0]['uri']) + ); + } else { + $r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', + `body` = '', `title` = '' + WHERE `uri` = '%s' LIMIT 1", + dbesc($when), + dbesc($uri) + ); + } + } + continue; + } + + $is_reply = false; + $item_id = $item->get_id(); + $rawthread = $item->get_item_tags("http://purl.org/syndication/thread/1.0", 'in-reply-to'); + + if (isset($rawthread[0]['attribs']['']['ref'])) { + $is_reply = true; + $parent_uri = $rawthread[0]['attribs']['']['ref']; + } + + if ($is_reply) { + // Have we seen it? If not, import it. + $item_id = $item->get_id(); + + $r = q("SELECT `last-child`, `edited` FROM `item` WHERE `uri` = '%s' LIMIT 1", dbesc($item_id)); + + // FIXME update content if 'updated' changes + if (count($r)) { + $allow = $item->get_item_tags(NAMESPACE_DFRN, 'comment-allow'); + if ($allow && $allow[0]['data'] != $r[0]['last-child']) { + $r = q("UPDATE `item` SET `last-child` = %d WHERE `uri` = '%s' LIMIT 1", + intval($allow[0]['data']), + dbesc($item_id) + ); + } + continue; + } + + $datarray = get_atom_elements($item); + $datarray['parent-uri'] = $parent_uri; + $datarray['contact-id'] = $contact['id']; + $r = post_remote($a, $datarray); + + continue; + } else { + // Head post of a conversation. Have we seen it? If not, import it. + + $item_id = $item->get_id(); + $r = q("SELECT `last-child`, `edited` FROM `item` WHERE `uri` = '%s' LIMIT 1", dbesc($item_id)); + + if (count($r)) { + $allow = $item->get_item_tags(NAMESPACE_DFRN, 'comment-allow'); + if ($allow && $allow[0]['data'] != $r[0]['last-child']) { + $r = q("UPDATE `item` SET `last-child` = %d WHERE `uri` = '%s' LIMIT 1", + intval($allow[0]['data']), + dbesc($item_id) + ); + } + continue; + } + + $datarray = get_atom_elements($item); + $datarray['parent-uri'] = $item_id; + $datarray['contact-id'] = $contact['id']; + $r = post_remote($a, $datarray); + + continue; + } + } + + $r = q("UPDATE `contact` SET `last-update` = '%s' WHERE `id` = %d LIMIT 1", + dbesc(datetime_convert()), + intval($contact['id']) + ); +} + +killme(); diff --git a/include/rockstar.php b/include/rockstar.php old mode 100755 new mode 100644 index b1b35642..58009214 --- a/include/rockstar.php +++ b/include/rockstar.php @@ -1,166 +1,168 @@ set_baseurl(get_config('system','url')); +$db = new dba($db_host, $db_user, $db_pass, $db_data, $install); - $u = q("SELECT * FROM `user` WHERE 1 LIMIT 1"); - if(! count($u)) - killme(); +unset($db_host, $db_user, $db_pass, $db_data); - $uid = $u[0]['uid']; - $nickname = $u[0]['nickname']; +require_once 'session.php'; +require_once 'datetime.php'; - $intros = q("SELECT `intro`.*, `intro`.`id` AS `intro_id`, `contact`.* +$a->set_baseurl(get_config('system', 'url')); + +$u = q("SELECT * FROM `user` WHERE 1 LIMIT 1"); + +if (!count($u)) { + killme(); +} + +$uid = $u[0]['uid']; +$nickname = $u[0]['nickname']; + +$intros = q("SELECT `intro`.*, `intro`.`id` AS `intro_id`, `contact`.* FROM `intro` LEFT JOIN `contact` ON `contact`.`id` = `intro`.`contact-id` WHERE `intro`.`blocked` = 0 AND `intro`.`ignore` = 0"); - if(! count($intros)) - return; +if (!count($intros)) { + return; +} +foreach ($intros as $intro) { + $intro_id = intval($intro['intro_id']); - foreach($intros as $intro) { - - $intro_id = intval($intro['intro_id']); + $dfrn_id = $intro['issued-id']; + $contact_id = $intro['contact-id']; + $relation = $intro['rel']; + $site_pubkey = $intro['site-pubkey']; + $dfrn_confirm = $intro['confirm']; + $aes_allow = $intro['aes_allow']; - $dfrn_id = $intro['issued-id']; - $contact_id = $intro['contact-id']; - $relation = $intro['rel']; - $site_pubkey = $intro['site-pubkey']; - $dfrn_confirm = $intro['confirm']; - $aes_allow = $intro['aes_allow']; + $res = openssl_pkey_new(array( + 'digest_alg' => 'whirlpool', + 'private_key_bits' => 4096, + 'encrypt_key' => false)); - $res=openssl_pkey_new(array( - 'digest_alg' => 'whirlpool', - 'private_key_bits' => 4096, - 'encrypt_key' => false )); + $private_key = ''; - $private_key = ''; + openssl_pkey_export($res, $private_key); - openssl_pkey_export($res, $private_key); + $pubkey = openssl_pkey_get_details($res); + $public_key = $pubkey["key"]; - $pubkey = openssl_pkey_get_details($res); - $public_key = $pubkey["key"]; + $r = q("UPDATE `contact` SET `issued-pubkey` = '%s', `prvkey` = '%s' WHERE `id` = %d LIMIT 1", + dbesc($public_key), + dbesc($private_key), + intval($contact_id) + ); - $r = q("UPDATE `contact` SET `issued-pubkey` = '%s', `prvkey` = '%s' WHERE `id` = %d LIMIT 1", - dbesc($public_key), - dbesc($private_key), - intval($contact_id) - ); + $params = array(); - $params = array(); + $src_aes_key = random_string(); + $result = ""; - $src_aes_key = random_string(); - $result = ""; + openssl_private_encrypt($dfrn_id, $result, $u[0]['prvkey']); - openssl_private_encrypt($dfrn_id,$result,$u[0]['prvkey']); + $params['dfrn_id'] = $result; + $params['public_key'] = $public_key; - $params['dfrn_id'] = $result; - $params['public_key'] = $public_key; + $my_url = $a->get_baseurl() . '/profile/' . $nickname; - $my_url = $a->get_baseurl() . '/profile/' . $nickname ; - - openssl_public_encrypt($my_url, $params['source_url'], $site_pubkey); - - if($aes_allow && function_exists('openssl_encrypt')) { - openssl_public_encrypt($src_aes_key, $params['aes_key'], $site_pubkey); - $params['public_key'] = openssl_encrypt($public_key,'AES-256-CBC',$src_aes_key); - } - - $res = post_url($dfrn_confirm,$params); - - $xml = simplexml_load_string($res); - $status = (int) $xml->status; - switch($status) { - case 0: - break; - case 1: - // birthday paradox - generate new dfrn-id and fall through. - - $new_dfrn_id = random_string(); - $r = q("UPDATE contact SET `issued-id` = '%s' WHERE `id` = %d LIMIT 1", - dbesc($new_dfrn_id), - intval($contact_id) - ); - case 2: - break; - - case 3: - default: - break; - } - - if(($status == 0 || $status == 3) && ($intro_id)) { - - // delete the notification - - $r = q("DELETE FROM `intro` WHERE `id` = %d LIMIT 1", - intval($intro_id) - ); - } - if($status != 0) - killme(); - - require_once("Photo.php"); - - $photo_failure = false; - - - $filename = basename($intro['photo']); - $img_str = fetch_url($intro['photo'],true); - $img = new Photo($img_str); - if($img) { - - $img->scaleImageSquare(175); - $hash = hash('md5',uniqid(mt_rand(),true)); - - $r = $img->store($contact_id, $hash, $filename, t('Contact Photos'), 4 ); - - if($r === false) - $photo_failure = true; - $img->scaleImage(80); - - $r = $img->store($contact_id, $hash, $filename, t('Contact Photos'), 5 ); - - if($r === false) - $photo_failure = true; - - $photo = $a->get_baseurl() . '/photo/' . $hash . '-4.jpg'; - $thumb = $a->get_baseurl() . '/photo/' . $hash . '-5.jpg'; - } - else - $photo_failure = true; - - if($photo_failure) { - $photo = $a->get_baseurl() . '/images/default-profile.jpg'; - $thumb = $a->get_baseurl() . '/images/default-profile-sm.jpg'; - } - - $r = q("UPDATE `contact` SET `photo` = '%s', `thumb` = '%s', `rel` = %d, - `name-date` = '%s', `uri-date` = '%s', `avatar-date` = '%s', - `readonly` = %d, `profile-id` = %d, `blocked` = 0, `pending` = 0, - `network` = 'dfrn' WHERE `id` = %d LIMIT 1", - dbesc($photo), - dbesc($thumb), - intval(($relation == DIRECTION_OUT) ? DIRECTION_BOTH : DIRECTION_IN), - dbesc(datetime_convert()), - dbesc(datetime_convert()), - dbesc(datetime_convert()), - intval((x($a->config,'rockstar-readonly')) ? $a->config['rockstar-readonly'] : 0), - intval((x($a->config,'rockstar-profile')) ? $a->config['rockstar-profile'] : 0), - intval($contact_id) - ); + openssl_public_encrypt($my_url, $params['source_url'], $site_pubkey); + if ($aes_allow && function_exists('openssl_encrypt')) { + openssl_public_encrypt($src_aes_key, $params['aes_key'], $site_pubkey); + $params['public_key'] = openssl_encrypt($public_key, 'AES-256-CBC', $src_aes_key); } - killme(); + $res = post_url($dfrn_confirm, $params); + + $xml = simplexml_load_string($res); + $status = (int) $xml->status; + switch ($status) { + case 0: + break; + case 1: + // birthday paradox - generate new dfrn-id and fall through. + $new_dfrn_id = random_string(); + $r = q("UPDATE contact SET `issued-id` = '%s' WHERE `id` = %d LIMIT 1", + dbesc($new_dfrn_id), + intval($contact_id) + ); + case 2: + break; + + case 3: + default: + break; + } + + if (($status == 0 || $status == 3) && ($intro_id)) { + // delete the notification + $r = q("DELETE FROM `intro` WHERE `id` = %d LIMIT 1", intval($intro_id)); + } + + if ($status != 0) { + killme(); + } + + require_once 'Photo.php'; + + $photo_failure = false; + + $filename = basename($intro['photo']); + $img_str = fetch_url($intro['photo'], true); + $img = new Photo($img_str); + + if ($img) { + $img->scaleImageSquare(175); + $hash = hash('md5', uniqid(mt_rand(), true)); + + $r = $img->store($contact_id, $hash, $filename, t('Contact Photos'), 4); + + if ($r === false) { + $photo_failure = true; + } + $img->scaleImage(80); + + $r = $img->store($contact_id, $hash, $filename, t('Contact Photos'), 5); + + if ($r === false) { + $photo_failure = true; + } + + $photo = $a->get_baseurl() . '/photo/' . $hash . '-4.jpg'; + $thumb = $a->get_baseurl() . '/photo/' . $hash . '-5.jpg'; + } else { + $photo_failure = true; + } + + if ($photo_failure) { + $photo = $a->get_baseurl() . '/images/default-profile.jpg'; + $thumb = $a->get_baseurl() . '/images/default-profile-sm.jpg'; + } + + $r = q("UPDATE `contact` SET `photo` = '%s', `thumb` = '%s', `rel` = %d, + `name-date` = '%s', `uri-date` = '%s', `avatar-date` = '%s', + `readonly` = %d, `profile-id` = %d, `blocked` = 0, `pending` = 0, + `network` = 'dfrn' WHERE `id` = %d LIMIT 1", + dbesc($photo), + dbesc($thumb), + intval(($relation == DIRECTION_OUT) ? DIRECTION_BOTH : DIRECTION_IN), + dbesc(datetime_convert()), + dbesc(datetime_convert()), + dbesc(datetime_convert()), + intval((x($a->config, 'rockstar-readonly')) ? $a->config['rockstar-readonly'] : 0), + intval((x($a->config, 'rockstar-profile')) ? $a->config['rockstar-profile'] : 0), + intval($contact_id) + ); +} +killme(); diff --git a/include/security.php b/include/security.php old mode 100755 new mode 100644 diff --git a/include/session.php b/include/session.php old mode 100755 new mode 100644 diff --git a/include/site-health.php b/include/site-health.php index 6eadaf10..bf94ad35 100644 --- a/include/site-health.php +++ b/include/site-health.php @@ -29,7 +29,7 @@ function notice_site($url, $check_health=false) $entry = $result[0]; //If we are allowed to do health checks... - if(!!$check_health){ + if($check_health){ //And the site is in bad health currently, do a check now. //This is because you have a high certainty the site may perform better now. @@ -57,7 +57,7 @@ function notice_site($url, $check_health=false) ); //And in case we should probe now, do so. - if(!!$check_health){ + if($check_health){ $result = q( "SELECT * FROM `site-health` WHERE `base_url`= '%s' ORDER BY `id` ASC LIMIT 1", @@ -91,7 +91,13 @@ function parse_site_from_url($url) //Performs a ping to the given site ID //You may need to notice the site first before you know it's ID. -if(! function_exists('run_site_ping')){ +//TODO: Probe server location using IP address or using the info the friendica server provides (preferred). +// If IP needs to be used only provide country information. +//TODO: Check SSLLabs Grade +// Check needs to be asynchronous, meaning that the check at SSLLabs will be initiated in one run while +// the results must be fetched later. It might be good to mark sites, where a check has been inititated +// f.e. using the ssl_grade field. In the next run, results of these sites could be fetched. +if(! function_exists('run_site_probe')){ function run_site_probe($id, &$entry_out) { @@ -134,7 +140,7 @@ function run_site_probe($id, &$entry_out) CURLOPT_PROTOCOLS => CURLPROTO_HTTP | CURLPROTO_HTTPS, //Basic request - CURLOPT_USERAGENT => 'friendica-directory-probe-0.1', + CURLOPT_USERAGENT => 'friendica-directory-probe-1.0', CURLOPT_RETURNTRANSFER => true, CURLOPT_URL => $probe_location @@ -159,7 +165,7 @@ function run_site_probe($id, &$entry_out) //Probe again, without strict SSL. $options[CURLOPT_SSL_VERIFYPEER] = false; - //Replace the handler. + //Replace the handle. curl_close($handle); $handle = curl_init(); curl_setopt_array($handle, $options); @@ -178,13 +184,14 @@ function run_site_probe($id, &$entry_out) $time = round(($probe_end - $probe_start) * 1000); $status = curl_getinfo($handle, CURLINFO_HTTP_CODE); $type = curl_getinfo($handle, CURLINFO_CONTENT_TYPE); - $effective_url = curl_getinfo($handle, CURLINFO_EFFECTIVE_URL); + $info = curl_getinfo($handle); //Done with CURL now. curl_close($handle); #TODO: if the site redirects elsewhere, notice this site and record an issue. - $wrong_base_url = parse_site_from_url($effective_url) !== $entry['base_url']; + $effective_base_url = parse_site_from_url($info['url']); + $wrong_base_url = $effective_base_url !== $entry['base_url']; try{ $data = json_decode($probe_data); @@ -195,6 +202,18 @@ function run_site_probe($id, &$entry_out) $parse_failed = !$data; $parsedDataQuery = ''; + + logger('Effective Base URL: ' . $effective_base_url); + + if($wrong_base_url){ + $parsedDataQuery .= sprintf( + "`effective_base_url` = '%s',", + dbesc($effective_base_url) + ); + }else{ + $parsedDataQuery .= "`effective_base_url` = NULL,"; + } + if(!$parse_failed){ $given_base_url_match = $data->url == $base_url; @@ -208,7 +227,7 @@ function run_site_probe($id, &$entry_out) ); //Update any health calculations or otherwise processed data. - $parsedDataQuery = sprintf( + $parsedDataQuery .= sprintf( "`dt_last_seen` = NOW(), `name` = '%s', `version` = '%s', @@ -307,8 +326,8 @@ function health_score_after_probe($current, $probe_success, $time=null, $version $current = min($current, 30); } - //Older than 3.2.x? - elseif(intval($versionParts[1] < 2)){ + //Older than 3.3.x? + elseif(intval($versionParts[1] < 3)){ $current -= 5; //Somewhat outdated. } diff --git a/include/smoothing.js b/include/smoothing.js new file mode 100644 index 00000000..9f1d918d --- /dev/null +++ b/include/smoothing.js @@ -0,0 +1,81 @@ +(function(){ + + window.Smoothing = { + + /** + * Applies both a moving average bracket and and exponential smoothing. + * @param {array} raw The raw Y values. + * @param {float} factor The exponential smoothing factor to apply (between o and 1). + * @param {int} bracket The amount of datapoints to add to the backet on each side! (2 = 5 data points) + * @return {array} The smoothed Y values. + */ + exponentialMovingAverage: function(raw, factor, bracket){ + + var output = []; + var smoother = new ExponentialSmoother(factor); + + //Transform each data point with the smoother. + for (var i = 0; i < raw.length; i++){ + + var input = raw[i]; + + //See if we should bracket. + if(bracket > 0){ + + //Cap our start and end so it doesn't go out of bounds. + var start = Math.max(i-bracket, 0); + var end = Math.min(i+bracket, raw.length); + + //Push the range to our input. + input = []; + for(var j = start; j < end; j++){ + input.push(raw[j]); + } + + } + + output.push( + smoother.transform(input) + ); + }; + + return output; + + } + + }; + + // Exponential Smoother class. + var ExponentialSmoother = function(factor){ + this.currentValue = null; + this.smoothingFactor = factor || 1; + }; + + ExponentialSmoother.prototype.transform = function(input){ + + // In case our input is a bracket, first average it. + if(input.length){ + var len = input.length; + var sum = 0; + for (var i = input.length - 1; i >= 0; i--) + sum += input[i] + input = sum/len; + } + + // Start with our initial value. + if(this.currentValue === null){ + this.currentValue = input; + } + + // Our output is basically an updated value. + return this.currentValue = + + // Weigh our current value with the smoothing factor. + (this.currentValue * this.smoothingFactor) + + + // Add the input to it with the inverse value of the smoothing factor. + ( (1-this.smoothingFactor) * input ); + + }; + +})(); \ No newline at end of file diff --git a/include/submit.php b/include/submit.php index 00d5b983..255657b4 100644 --- a/include/submit.php +++ b/include/submit.php @@ -114,8 +114,6 @@ function run_submit($url) { `region` = '%s', `postal-code` = '%s', `country-name` = '%s', - `gender` = '%s', - `marital` = '%s', `homepage` = '%s', `nurl` = '%s', `comm` = %d, @@ -129,8 +127,6 @@ function run_submit($url) { $parms['region'], $parms['postal-code'], $parms['country-name'], - $parms['gender'], - $parms['marital'], dbesc($url), dbesc($nurl), intval($parms['comm']), @@ -142,7 +138,7 @@ function run_submit($url) { } else { - $r = q("INSERT INTO `profile` ( `name`, `pdesc`, `locality`, `region`, `postal-code`, `country-name`, `gender`, `marital`, `homepage`, `nurl`, `comm`, `tags`, `created`, `updated` ) + $r = q("INSERT INTO `profile` ( `name`, `pdesc`, `locality`, `region`, `postal-code`, `country-name`, `homepage`, `nurl`, `comm`, `tags`, `created`, `updated` ) VALUES ( '%s', '%s', '%s', '%s' , '%s', '%s', '%s', '%s', '%s', '%s', %d, '%s', '%s', '%s' )", $parms['fn'], $parms['pdesc'], @@ -150,8 +146,6 @@ function run_submit($url) { $parms['region'], $parms['postal-code'], $parms['country-name'], - $parms['gender'], - $parms['marital'], dbesc($url), dbesc($nurl), intval($parms['comm']), @@ -269,4 +263,4 @@ function nuke_record($url) { } } return; -} \ No newline at end of file +} diff --git a/include/sync.php b/include/sync.php index 54b29039..3d816cee 100644 --- a/include/sync.php +++ b/include/sync.php @@ -1,5 +1,7 @@ config['syncing']['enable_pulling']){ - q("INSERT INTO `sync-pull-queue` (`url`) VALUES ('%s')", dbesc($url)); - } - + global $a; + + //If we support it that is. + if ($a->config['syncing']['enable_pulling']) { + q("INSERT INTO `sync-pull-queue` (`url`) VALUES ('%s')", dbesc($url)); + } } /** @@ -24,16 +24,14 @@ function sync_pull($url) */ function sync_push($url) { - - global $a; - - //If we support it that is. - if($a->config['syncing']['enable_pushing']){ - q("INSERT INTO `sync-push-queue` (`url`) VALUES ('%s')", dbesc($url)); - } - - sync_mark($url); - + global $a; + + //If we support it that is. + if ($a->config['syncing']['enable_pushing']) { + q("INSERT INTO `sync-push-queue` (`url`) VALUES ('%s')", dbesc($url)); + } + + sync_mark($url); } /** @@ -44,21 +42,20 @@ function sync_push($url) */ function sync_mark($url) { - - global $a; - - //If we support it that is. - if(!$a->config['syncing']['enable_pulling']){ - return; - } - - $exists = count(q("SELECT * FROM `sync-timestamps` WHERE `url`='%s'", dbesc($url))); - - if(!$exists) - q("INSERT INTO `sync-timestamps` (`url`, `modified`) VALUES ('%s', NOW())", dbesc($url)); - else - q("UPDATE `sync-timestamps` SET `modified`=NOW() WHERE `url`='%s'", dbesc($url)); - + global $a; + + //If we support it that is. + if (!$a->config['syncing']['enable_pulling']) { + return; + } + + $exists = count(q("SELECT * FROM `sync-timestamps` WHERE `url`='%s'", dbesc($url))); + + if (!$exists) { + q("INSERT INTO `sync-timestamps` (`url`, `modified`) VALUES ('%s', NOW())", dbesc($url)); + } else { + q("UPDATE `sync-timestamps` SET `modified`=NOW() WHERE `url`='%s'", dbesc($url)); + } } /** @@ -70,27 +67,26 @@ function sync_mark($url) */ function push_worker($target, $batch) { - - //Lets be nice, we're only doing a background job here... - pcntl_setpriority(5); - - //Find our target's submit URL. - $submit = $target['base_url'].'/submit'; - - foreach($batch as $item){ - set_time_limit(30); //This should work for 1 submit. - msg("Submitting {$item['url']} to $submit"); - fetch_url($submit.'?url='.bin2hex($item['url'])); - } - + //Lets be nice, we're only doing a background job here... + pcntl_setpriority(5); + + //Find our target's submit URL. + $submit = $target['base_url'] . '/submit'; + + foreach ($batch as $item) { + set_time_limit(30); //This should work for 1 submit. + msg("Submitting {$item['url']} to $submit"); + fetch_url($submit . '?url=' . bin2hex($item['url'])); + } } /** * Gets an array of push targets. * @return array Push targets. */ -function get_push_targets(){ - return q("SELECT * FROM `sync-targets` WHERE `push`=b'1'"); +function get_push_targets() +{ + return q("SELECT * FROM `sync-targets` WHERE `push`=b'1'"); } /** @@ -98,8 +94,9 @@ function get_push_targets(){ * @param object $a The App instance. * @return array Batch of URL's. */ -function get_push_batch($a){ - return q("SELECT * FROM `sync-push-queue` LIMIT %u", intval($a->config['syncing']['max_push_items'])); +function get_push_batch(App $a) +{ + return q("SELECT * FROM `sync-push-queue` LIMIT %u", intval($a->config['syncing']['max_push_items'])); } /** @@ -107,37 +104,33 @@ function get_push_batch($a){ * @param object $a The App instance. * @return list($targets, $batch) A list of both the targets array and batch array. */ -function get_pushing_job($a) +function get_pushing_job(App $a) { - - //When pushing is requested... - if(!!$a->config['syncing']['enable_pushing']){ - - //Find our targets. - $targets = get_push_targets(); - - //No targets? - if(!count($targets)){ - msg('Pushing enabled, but no push targets.'); - $batch = array(); - } - - //If we have targets, get our batch. - else{ - $batch = get_push_batch($a); - if(!count($batch)) msg('Empty pushing queue.'); //No batch, means no work. - } - - } + //When pushing is requested... + if (!!$a->config['syncing']['enable_pushing']) { - //No pushing if it's disabled. - else{ - $targets = array(); - $batch = array(); - } - - return array($targets, $batch); - + //Find our targets. + $targets = get_push_targets(); + + //No targets? + if (!count($targets)) { + msg('Pushing enabled, but no push targets.'); + $batch = array(); + } + + //If we have targets, get our batch. + else { + $batch = get_push_batch($a); + if (!count($batch)) + msg('Empty pushing queue.'); //No batch, means no work. + } + } else { + //No pushing if it's disabled. + $targets = array(); + $batch = array(); + } + + return array($targets, $batch); } /** @@ -153,74 +146,76 @@ function get_pushing_job($a) */ function run_pushing_job($targets, $batch, $db_host, $db_user, $db_pass, $db_data, $install) { - - //Create a thread for each target we want to serve push messages to. - //Not good creating more, because it would stress their server too much. - $threadc = count($targets); - $threads = array(); - - //Do we only have 1 target? No need for threads. - if($threadc === 1){ - msg('No threads needed. Only one pushing target.'); - push_worker($targets[0], $batch); - } - - //When we need threads. - elseif($threadc > 1){ - - //POSIX threads only. - if(!function_exists('pcntl_fork')){ - msg('Error: no pcntl_fork support. Are you running a different OS? Report an issue please.', true); - } - - //Debug... - $items = count($batch); - msg("Creating $threadc push threads for $items items."); - - //Loop while we need more threads. - for($i = 0; $i < $threadc; $i++){ - - $pid = pcntl_fork(); - if($pid === -1) msg('Error: something went wrong with the fork. '.pcntl_strerror(), true); - - //You're a child, go do some labor! - if($pid === 0){push_worker($targets[$i], $batch); exit;} - - //Store the list of PID's. - if($pid > 0) $threads[] = $pid; - - } - - } - - //Wait for all child processes. - $theading_problems = false; - foreach($threads as $pid){ - pcntl_waitpid($pid, $status); - if($status !== 0){ - $theading_problems = true; - msg("Bad process return value $pid:$status"); - } - } - - //If we did not have any "threading" problems. - if(!$theading_problems){ - - //Reconnect - global $db; - $db = new dba($db_host, $db_user, $db_pass, $db_data, $install); - - //Create a query for deleting this queue. - $where = array(); - foreach($batch as $item) $where[] = dbesc($item['url']); - $where = "WHERE `url` IN ('".implode("', '", $where)."')"; - - //Remove the items from queue. - q("DELETE FROM `sync-push-queue` $where LIMIT %u", count($batch)); - msg('Removed items from push queue.'); - - } - + //Create a thread for each target we want to serve push messages to. + //Not good creating more, because it would stress their server too much. + $threadc = count($targets); + $threads = array(); + + //Do we only have 1 target? No need for threads. + if ($threadc === 1) { + msg('No threads needed. Only one pushing target.'); + push_worker($targets[0], $batch); + } elseif ($threadc > 1) { + //When we need threads. + + //POSIX threads only. + if (!function_exists('pcntl_fork')) { + msg('Error: no pcntl_fork support. Are you running a different OS? Report an issue please.', true); + } + + //Debug... + $items = count($batch); + msg("Creating $threadc push threads for $items items."); + + //Loop while we need more threads. + for ($i = 0; $i < $threadc; $i++) { + $pid = pcntl_fork(); + if ($pid === -1) + msg('Error: something went wrong with the fork. ' . pcntl_strerror(), true); + + //You're a child, go do some labor! + if ($pid === 0) { + push_worker($targets[$i], $batch); + exit; + } + + //Store the list of PID's. + if ($pid > 0) { + $threads[] = $pid; + } + } + } + + //Wait for all child processes. + $theading_problems = false; + + foreach ($threads as $pid) { + pcntl_waitpid($pid, $status); + + if ($status !== 0) { + $theading_problems = true; + msg("Bad process return value $pid:$status"); + } + } + + //If we did not have any "threading" problems. + if (!$theading_problems) { + //Reconnect + global $db; + + $db = new dba($db_host, $db_user, $db_pass, $db_data, $install); + + //Create a query for deleting this queue. + $where = array(); + foreach ($batch as $item) { + $where[] = dbesc($item['url']); + } + $where = "WHERE `url` IN ('" . implode("', '", $where) . "')"; + + //Remove the items from queue. + q("DELETE FROM `sync-push-queue` $where LIMIT %u", count($batch)); + msg('Removed items from push queue.'); + } } /** @@ -228,19 +223,21 @@ function run_pushing_job($targets, $batch, $db_host, $db_user, $db_pass, $db_dat * @param object $a The App instance. * @return array Batch of URL's. */ -function get_queued_pull_batch($a){ - //Randomize this, to prevent scraping the same servers too much or dead URL's. - $batch = q("SELECT * FROM `sync-pull-queue` ORDER BY RAND() LIMIT %u", intval($a->config['syncing']['max_pull_items'])); - msg(sprintf('Pulling %u items from queue.', count($batch))); - return $batch; +function get_queued_pull_batch(App $a) +{ + //Randomize this, to prevent scraping the same servers too much or dead URL's. + $batch = q("SELECT * FROM `sync-pull-queue` ORDER BY RAND() LIMIT %u", intval($a->config['syncing']['max_pull_items'])); + msg(sprintf('Pulling %u items from queue.', count($batch))); + return $batch; } /** * Gets an array of pull targets. * @return array Pull targets. */ -function get_pull_targets(){ - return q("SELECT * FROM `sync-targets` WHERE `pull`=b'1'"); +function get_pull_targets() +{ + return q("SELECT * FROM `sync-targets` WHERE `pull`=b'1'"); } /** @@ -248,59 +245,61 @@ function get_pull_targets(){ * @param object $a The App instance. * @return array Batch of URL's. */ -function get_remote_pull_batch($a) +function get_remote_pull_batch(App $a) { - - //Find our targets. - $targets = get_pull_targets(); - - msg(sprintf('Pulling from %u remote targets.', count($targets))); - - //No targets, means no batch. - if(!count($targets)) - return array(); - - //Pull a list of URL's from each target. - $urls = array(); - foreach($targets as $i => $target){ - - //First pull, or an update? - if(!$target['dt_last_pull']) - $url = $target['base_url'].'/sync/pull/all'; - else - $url = $target['base_url'].'/sync/pull/since/'.intval($target['dt_last_pull']); - - //Go for it :D - $targets[$i]['pull_data'] = json_decode(fetch_url($url), true); - - //If we didn't get any JSON. - if(!$targets[$i]['pull_data']){ - msg(sprintf('Failed to pull from "%s".', $url)); - continue; - } - - //Add all entries as keys, to remove duplicates. - foreach($targets[$i]['pull_data']['results'] as $url) - $urls[$url]=true; - - } - - //Now that we have our URL's. Store them in the queue. - foreach($urls as $url=>$bool){ - if($url) sync_pull($url); - } - - //Since this all worked out, mark each source with the timestamp of pulling. - foreach($targets as $target){ - if($target['pull_data'] && $target['pull_data']['now']){ - msg('New pull timestamp '.$target['pull_data']['now'].' for '.$target['base_url']); - q("UPDATE `sync-targets` SET `dt_last_pull`=%u WHERE `base_url`='%s'", $target['pull_data']['now'], dbesc($target['base_url'])); - } - } - - //Finally, return a batch of this. - return get_queued_pull_batch($a); - + //Find our targets. + $targets = get_pull_targets(); + + msg(sprintf('Pulling from %u remote targets.', count($targets))); + + //No targets, means no batch. + if (!count($targets)) { + return array(); + } + + //Pull a list of URL's from each target. + $urls = array(); + + foreach ($targets as $i => $target) { + //First pull, or an update? + if (!$target['dt_last_pull']) { + $url = $target['base_url'] . '/sync/pull/all'; + } else { + $url = $target['base_url'] . '/sync/pull/since/' . intval($target['dt_last_pull']); + } + + //Go for it :D + $targets[$i]['pull_data'] = json_decode(fetch_url($url), true); + + //If we didn't get any JSON. + if (!$targets[$i]['pull_data']) { + msg(sprintf('Failed to pull from "%s".', $url)); + continue; + } + + //Add all entries as keys, to remove duplicates. + foreach ($targets[$i]['pull_data']['results'] as $url) { + $urls[$url] = true; + } + } + + //Now that we have our URL's. Store them in the queue. + foreach ($urls as $url => $bool) { + if ($url) { + sync_pull($url); + } + } + + //Since this all worked out, mark each source with the timestamp of pulling. + foreach ($targets as $target) { + if ($target['pull_data'] && $target['pull_data']['now']) { + msg('New pull timestamp ' . $target['pull_data']['now'] . ' for ' . $target['base_url']); + q("UPDATE `sync-targets` SET `dt_last_pull`=%u WHERE `base_url`='%s'", $target['pull_data']['now'], dbesc($target['base_url'])); + } + } + + //Finally, return a batch of this. + return get_queued_pull_batch($a); } /** @@ -308,21 +307,24 @@ function get_remote_pull_batch($a) * @param object $a The App instance. * @return array URL's to scrape. */ -function get_pulling_job($a) +function get_pulling_job(App $a) { - - //No pulling today... - if(!$a->config['syncing']['enable_pulling']) - return array(); - - //Firstly, finish the items from our queue. - $batch = get_queued_pull_batch($a); - if(count($batch)) return $batch; - - //If that is empty, fill the queue with remote items and return a batch of that. - $batch = get_remote_pull_batch($a); - if(count($batch)) return $batch; - + //No pulling today... + if (!$a->config['syncing']['enable_pulling']) { + return array(); + } + + //Firstly, finish the items from our queue. + $batch = get_queued_pull_batch($a); + if (count($batch)) { + return $batch; + } + + //If that is empty, fill the queue with remote items and return a batch of that. + $batch = get_remote_pull_batch($a); + if (count($batch)) { + return $batch; + } } /** @@ -340,30 +342,28 @@ function get_pulling_job($a) */ function pull_worker($i, $threadc, $pull_batch, $db_host, $db_user, $db_pass, $db_data, $install) { - - //Lets be nice, we're only doing maintenance here... - pcntl_setpriority(5); - - //Get personal DBA's. - global $db; - $db = new dba($db_host, $db_user, $db_pass, $db_data, $install); - - //Get our (round-robin) workload from the batch. - $workload = array(); - while(isset($pull_batch[$i])){ - $entry = $pull_batch[$i]; - $workload[] = $entry; - $i+=$threadc; - } - - //While we've got work to do. - while(count($workload)){ - $entry = array_pop($workload); - set_time_limit(20); //This should work for 1 submit. - msg("Submitting ".$entry['url']); - run_submit($entry['url']); - } - + //Lets be nice, we're only doing maintenance here... + pcntl_setpriority(5); + + //Get personal DBA's. + global $db; + $db = new dba($db_host, $db_user, $db_pass, $db_data, $install); + + //Get our (round-robin) workload from the batch. + $workload = array(); + while (isset($pull_batch[$i])) { + $entry = $pull_batch[$i]; + $workload[] = $entry; + $i += $threadc; + } + + //While we've got work to do. + while (count($workload)) { + $entry = array_pop($workload); + set_time_limit(20); //This should work for 1 submit. + msg("Submitting " . $entry['url']); + run_submit($entry['url']); + } } /** @@ -377,64 +377,68 @@ function pull_worker($i, $threadc, $pull_batch, $db_host, $db_user, $db_pass, $d * @param mixed $install Maybe a boolean. * @return void */ -function run_pulling_job($a, $pull_batch, $db_host, $db_user, $db_pass, $db_data, $install) +function run_pulling_job(App $a, $pull_batch, $db_host, $db_user, $db_pass, $db_data, $install) { - - //We need the scraper. - require_once('include/submit.php'); - - //POSIX threads only. - if(!function_exists('pcntl_fork')){ - msg('Error: no pcntl_fork support. Are you running a different OS? Report an issue please.', true); - } - - //Create the threads we need. - $items = count($pull_batch); - $threadc = min($a->config['syncing']['pulling_threads'], $items); //Don't need more threads than items. - $threads = array(); - - msg("Creating $threadc pulling threads for $items profiles."); - - //Build the threads. - for($i = 0; $i < $threadc; $i++){ - - $pid = pcntl_fork(); - if($pid === -1) msg('Error: something went wrong with the fork. '.pcntl_strerror(), true); - - //You're a child, go do some labor! - if($pid === 0){pull_worker($i, $threadc, $pull_batch, $db_host, $db_user, $db_pass, $db_data, $install); exit;} - - //Store the list of PID's. - if($pid > 0) $threads[] = $pid; - - } - - //Wait for all child processes. - $theading_problems = false; - foreach($threads as $pid){ - pcntl_waitpid($pid, $status); - if($status !== 0){ - $theading_problems = true; - msg("Bad process return value $pid:$status"); - } - } - - //If we did not have any "threading" problems. - if(!$theading_problems){ - - //Reconnect - global $db; - $db = new dba($db_host, $db_user, $db_pass, $db_data, $install); - - //Create a query for deleting this queue. - $where = array(); - foreach($pull_batch as $item) $where[] = dbesc($item['url']); - $where = "WHERE `url` IN ('".implode("', '", $where)."')"; - - //Remove the items from queue. - q("DELETE FROM `sync-pull-queue` $where LIMIT %u", count($pull_batch)); - msg('Removed items from pull queue.'); - - } - -} \ No newline at end of file + //We need the scraper. + require_once 'include/submit.php'; + + //POSIX threads only. + if (!function_exists('pcntl_fork')) { + msg('Error: no pcntl_fork support. Are you running a different OS? Report an issue please.', true); + } + + //Create the threads we need. + $items = count($pull_batch); + $threadc = min($a->config['syncing']['pulling_threads'], $items); //Don't need more threads than items. + $threads = array(); + + msg("Creating $threadc pulling threads for $items profiles."); + + //Build the threads. + for ($i = 0; $i < $threadc; $i++) { + $pid = pcntl_fork(); + if ($pid === -1) { + msg('Error: something went wrong with the fork. ' . pcntl_strerror(), true); + } + + //You're a child, go do some labor! + if ($pid === 0) { + pull_worker($i, $threadc, $pull_batch, $db_host, $db_user, $db_pass, $db_data, $install); + exit; + } + + //Store the list of PID's. + if ($pid > 0) { + $threads[] = $pid; + } + } + + //Wait for all child processes. + $theading_problems = false; + foreach ($threads as $pid) { + pcntl_waitpid($pid, $status); + if ($status !== 0) { + $theading_problems = true; + msg("Bad process return value $pid:$status"); + } + } + + //If we did not have any "threading" problems. + if (!$theading_problems) { + //Reconnect + global $db; + + $db = new dba($db_host, $db_user, $db_pass, $db_data, $install); + + //Create a query for deleting this queue. + $where = array(); + foreach ($pull_batch as $item) { + $where[] = dbesc($item['url']); + } + $where = "WHERE `url` IN ('" . implode("', '", $where) . "')"; + + //Remove the items from queue. + q("DELETE FROM `sync-pull-queue` $where LIMIT %u", count($pull_batch)); + msg('Removed items from pull queue.'); + } +} diff --git a/include/system_unavailable.php b/include/system_unavailable.php old mode 100755 new mode 100644 index 48da8379..612ad2e7 --- a/include/system_unavailable.php +++ b/include/system_unavailable.php @@ -3,4 +3,4 @@ Apologies but this site is unavailable at the moment. Please try again later. - \ No newline at end of file + diff --git a/include/widget.php b/include/widget.php index 35ead569..65c793b5 100644 --- a/include/widget.php +++ b/include/widget.php @@ -1,41 +1,47 @@ '; $o .= '

' . t('Trending Interests') . '

'; $o .= ''; } return $o; } -function country_widget() { +function country_widget() +{ $o = ''; - $r = q("select distinct(`country-name`), count(`country-name`) as total from profile where `country-name` != '' group by `country-name` order by count(`country-name`) desc limit 20"); - if(count($r)) { + $r = q("SELECT `country-name`, COUNT(`country-name`) AS `total`" + . " FROM `profile`" + . " WHERE `country-name` != ''" + . " GROUP BY `country-name`" + . " ORDER BY COUNT(`country-name`) DESC" + . " LIMIT 20"); + if (count($r)) { $o .= '
'; $o .= '

' . t('Locations') . '

'; $o .= '
'; } return $o; } - -function get_taglist($limit = 50) { - $r = q("select distinct(term), count(term) as total from tag group by term order by count(term) desc limit %d", +function get_taglist($limit = 50) +{ + $r = q("SELECT DISTINCT(`term`), COUNT(`term`) AS `total` FROM `tag` GROUP BY `term` ORDER BY COUNT(`term`) DESC LIMIT %d", intval($limit) ); diff --git a/index.php b/index.php old mode 100755 new mode 100644 index e6fc910c..325d6208 --- a/index.php +++ b/index.php @@ -1,93 +1,95 @@ init_pagehead(); -$a->page['aside'] .= '
Your friends. Your web.
'; - -require_once("session.php"); +$a->page['aside'] = '
Your friends. Your web.
'; +require_once 'session.php'; session_start(); - -if((x($_SESSION,'authenticated')) || (x($_POST,'auth-params')) || ($a->module === 'login')) - require("auth.php"); - - +if ((x($_SESSION, 'authenticated')) || (x($_POST, 'auth-params')) || ($a->module === 'login')) { + require 'auth.php'; +} $dreamhost_error_hack = 1; - -if(x($_GET,'zrl')) { +if (x($_GET, 'zrl')) { $_SESSION['my_url'] = $_GET['zrl']; - $a->query_string = preg_replace('/[\?&]*zrl=(.*?)([\?&]|$)/is','',$a->query_string); + $a->query_string = preg_replace('/[\?&]*zrl=(.*?)([\?&]|$)/is', '', $a->query_string); } -if(strlen($a->module)) { - if(file_exists("mod/{$a->module}.php")) { +if (strlen($a->module)) { + if (file_exists("mod/{$a->module}.php")) { include("mod/{$a->module}.php"); $a->module_loaded = true; } - if(! $a->module_loaded) { - if((x($_SERVER,'QUERY_STRING')) && ($_SERVER['QUERY_STRING'] === 'q=internal_error.html') && isset($dreamhost_error_hack)) { + + if (!$a->module_loaded) { + if ((x($_SERVER, 'QUERY_STRING')) && ($_SERVER['QUERY_STRING'] === 'q=internal_error.html') && isset($dreamhost_error_hack)) { goaway($a->get_baseurl() . $_SERVER['REQUEST_URI']); } - header($_SERVER["SERVER_PROTOCOL"] . ' 404 ' . t('Not Found')); - notice( t('Page not found' ) . EOL); + header($_SERVER['SERVER_PROTOCOL'] . ' 404 ' . t('Not Found')); + notice(t('Page not found') . EOL); } } -if($a->module_loaded) { +if ($a->module_loaded) { $a->page['page_title'] = $a->module; - if(function_exists($a->module . '_init')) { + + if (function_exists($a->module . '_init')) { $func = $a->module . '_init'; $func($a); - } + } - if(($_SERVER['REQUEST_METHOD'] == 'POST') && (! $a->error) - && (function_exists($a->module . '_post')) - && (! x($_POST,'auth-params'))) { + if (($_SERVER['REQUEST_METHOD'] == 'POST') && (!$a->error) && (function_exists($a->module . '_post')) && (!x($_POST, 'auth-params'))) { $func = $a->module . '_post'; $func($a); } - if((! $a->error) && (function_exists($a->module . '_afterpost'))) { + if ((!$a->error) && (function_exists($a->module . '_afterpost'))) { $func = $a->module . '_afterpost'; $func($a); } - if((! $a->error) && (function_exists($a->module . '_content'))) { + if ((!$a->error) && (function_exists($a->module . '_content'))) { $func = $a->module . '_content'; - $a->page['content'] .= $func($a); + $a->page['content'] = $func($a); } - -} - -if(stristr($_SESSION['sysmsg'], t('Permission denied'))) { - header($_SERVER["SERVER_PROTOCOL"] . ' 403 ' . t('Permission denied.')); } // report anything important happening - -if(x($_SESSION,'sysmsg')) { - $a->page['content'] = '
' . $_SESSION['sysmsg'] . '
' . "\r\n" + +if (x($_SESSION, 'sysmsg')) { + if (stristr($_SESSION['sysmsg'], t('Permission denied'))) { + header($_SERVER['SERVER_PROTOCOL'] . ' 403 ' . t('Permission denied.')); + } + + if (!isset($a->page['content'])) { + $a->page['content'] = ''; + } + + $a->page['content'] = '
' . $_SESSION['sysmsg'] . '
' . PHP_EOL . $a->page['content']; unset($_SESSION['sysmsg']); } @@ -96,20 +98,23 @@ if(x($_SESSION,'sysmsg')) { $a->page['htmlhead'] = replace_macros($a->page['htmlhead'], array( '$stylesheet' => $a->get_baseurl() . '/view/theme/' - . ((x($_SESSION,'theme')) ? $_SESSION['theme'] : 'default') + . ((x($_SESSION, 'theme')) ? $_SESSION['theme'] : 'default') . '/style.css' -)); + )); - -$page = $a->page; +$page = $a->page; $profile = $a->profile; -header("Content-type: text/html; charset=utf-8"); -$template = "view/" - . ((x($a->page,'template')) ? $a->page['template'] : 'default' ) - . ".php"; +header('Content-type: text/html; charset=utf-8'); + +$template = 'view/' + . ((x($a->page, 'template')) ? $a->page['template'] : 'default' ) + . '.php'; + +require_once $template; -require_once($template); session_write_close(); + closedb(); + exit; diff --git a/include/ajaxupload.js b/js/ajaxupload.js old mode 100755 new mode 100644 similarity index 99% rename from include/ajaxupload.js rename to js/ajaxupload.js index ef872b52..56433966 --- a/include/ajaxupload.js +++ b/js/ajaxupload.js @@ -689,4 +689,4 @@ this._createInput(); } }; -})(); +})(); diff --git a/include/country.js b/js/country.js old mode 100755 new mode 100644 similarity index 99% rename from include/country.js rename to js/country.js index 701ec19e..b2c78751 --- a/include/country.js +++ b/js/country.js @@ -1,438 +1,438 @@ -// -aStates[49]="|Anjouan (Nzwani)|Domoni|Fomboni|Grande Comore (Njazidja)|Moheli (Mwali)|Moroni|Moutsamoudou"; -aStates[50]="|Bandundu|Bas-Congo|Equateur|Kasai-Occidental|Kasai-Oriental|Katanga|Kinshasa|Maniema|Nord-Kivu|Orientale|Sud-Kivu"; -aStates[51]="|Bouenza|Brazzaville|Cuvette|Kouilou|Lekoumou|Likouala|Niari|Plateaux|Pool|Sangha"; -aStates[52]="|Aitutaki|Atiu|Avarua|Mangaia|Manihiki|Manuae|Mauke|Mitiaro|Nassau Island|Palmerston|Penrhyn|Pukapuka|Rakahanga|Rarotonga|Suwarrow|Takutea"; -aStates[53]="|Alajuela|Cartago|Guanacaste|Heredia|Limon|Puntarenas|San Jose"; -aStates[54]="|Abengourou|Abidjan|Aboisso|Adiake'|Adzope|Agboville|Agnibilekrou|Ale'pe'|Bangolo|Beoumi|Biankouma|Bocanda|Bondoukou|Bongouanou|Bouafle|Bouake|Bouna|Boundiali|Dabakala|Dabon|Daloa|Danane|Daoukro|Dimbokro|Divo|Duekoue|Ferkessedougou|Gagnoa|Grand Bassam|Grand-Lahou|Guiglo|Issia|Jacqueville|Katiola|Korhogo|Lakota|Man|Mankono|Mbahiakro|Odienne|Oume|Sakassou|San-Pedro|Sassandra|Seguela|Sinfra|Soubre|Tabou|Tanda|Tiassale|Tiebissou|Tingrela|Touba|Toulepleu|Toumodi|Vavoua|Yamoussoukro|Zuenoula"; -aStates[55]="|Bjelovarsko-Bilogorska Zupanija|Brodsko-Posavska Zupanija|Dubrovacko-Neretvanska Zupanija|Istarska Zupanija|Karlovacka Zupanija|Koprivnicko-Krizevacka Zupanija|Krapinsko-Zagorska Zupanija|Licko-Senjska Zupanija|Medimurska Zupanija|Osjecko-Baranjska Zupanija|Pozesko-Slavonska Zupanija|Primorsko-Goranska Zupanija|Sibensko-Kninska Zupanija|Sisacko-Moslavacka Zupanija|Splitsko-Dalmatinska Zupanija|Varazdinska Zupanija|Viroviticko-Podravska Zupanija|Vukovarsko-Srijemska Zupanija|Zadarska Zupanija|Zagreb|Zagrebacka Zupanija"; -aStates[56]="|Camaguey|Ciego de Avila|Cienfuegos|Ciudad de La Habana|Granma|Guantanamo|Holguin|Isla de la Juventud|La Habana|Las Tunas|Matanzas|Pinar del Rio|Sancti Spiritus|Santiago de Cuba|Villa Clara"; -aStates[57]="|Famagusta|Kyrenia|Larnaca|Limassol|Nicosia|Paphos"; -aStates[58]="|Brnensky|Budejovicky|Jihlavsky|Karlovarsky|Kralovehradecky|Liberecky|Olomoucky|Ostravsky|Pardubicky|Plzensky|Praha|Stredocesky|Ustecky|Zlinsky"; -aStates[59]="|Arhus|Bornholm|Fredericksberg|Frederiksborg|Fyn|Kobenhavn|Kobenhavns|Nordjylland|Ribe|Ringkobing|Roskilde|Sonderjylland|Storstrom|Vejle|Vestsjalland|Viborg"; -aStates[60]="|'Ali Sabih|Dikhil|Djibouti|Obock|Tadjoura"; -aStates[61]="|Saint Andrew|Saint David|Saint George|Saint John|Saint Joseph|Saint Luke|Saint Mark|Saint Patrick|Saint Paul|Saint Peter"; -aStates[62]="|Azua|Baoruco|Barahona|Dajabon|Distrito Nacional|Duarte|El Seibo|Elias Pina|Espaillat|Hato Mayor|Independencia|La Altagracia|La Romana|La Vega|Maria Trinidad Sanchez|Monsenor Nouel|Monte Cristi|Monte Plata|Pedernales|Peravia|Puerto Plata|Salcedo|Samana|San Cristobal|San Juan|San Pedro de Macoris|Sanchez Ramirez|Santiago|Santiago Rodriguez|Valverde"; -// -aStates[63]="|Azuay|Bolivar|Canar|Carchi|Chimborazo|Cotopaxi|El Oro|Esmeraldas|Galapagos|Guayas|Imbabura|Loja|Los Rios|Manabi|Morona-Santiago|Napo|Orellana|Pastaza|Pichincha|Sucumbios|Tungurahua|Zamora-Chinchipe"; -aStates[64]="|Ad Daqahliyah|Al Bahr al Ahmar|Al Buhayrah|Al Fayyum|Al Gharbiyah|Al Iskandariyah|Al Isma'iliyah|Al Jizah|Al Minufiyah|Al Minya|Al Qahirah|Al Qalyubiyah|Al Wadi al Jadid|As Suways|Ash Sharqiyah|Aswan|Asyut|Bani Suwayf|Bur Sa'id|Dumyat|Janub Sina'|Kafr ash Shaykh|Matruh|Qina|Shamal Sina'|Suhaj"; -aStates[65]="|Ahuachapan|Cabanas|Chalatenango|Cuscatlan|La Libertad|La Paz|La Union|Morazan|San Miguel|San Salvador|San Vicente|Santa Ana|Sonsonate|Usulutan"; -aStates[66]="|Annobon|Bioko Norte|Bioko Sur|Centro Sur|Kie-Ntem|Litoral|Wele-Nzas"; -aStates[67]="|Akale Guzay|Barka|Denkel|Hamasen|Sahil|Semhar|Senhit|Seraye"; -aStates[68]="|Harjumaa (Tallinn)|Hiiumaa (Kardla)|Ida-Virumaa (Johvi)|Jarvamaa (Paide)|Jogevamaa (Jogeva)|Laane-Virumaa (Rakvere)|Laanemaa (Haapsalu)|Parnumaa (Parnu)|Polvamaa (Polva)|Raplamaa (Rapla)|Saaremaa (Kuessaare)|Tartumaa (Tartu)|Valgamaa (Valga)|Viljandimaa (Viljandi)|Vorumaa (Voru)" -aStates[69]="|Adis Abeba (Addis Ababa)|Afar|Amara|Dire Dawa|Gambela Hizboch|Hareri Hizb|Oromiya|Sumale|Tigray|YeDebub Biheroch Bihereseboch na Hizboch"; -aStates[70]="|Europa Island"; -aStates[71]="|Falkland Islands (Islas Malvinas)" -aStates[72]="|Bordoy|Eysturoy|Mykines|Sandoy|Skuvoy|Streymoy|Suduroy|Tvoroyri|Vagar"; -aStates[73]="|Central|Eastern|Northern|Rotuma|Western"; -aStates[74]="|Aland|Etela-Suomen Laani|Ita-Suomen Laani|Lansi-Suomen Laani|Lappi|Oulun Laani"; -aStates[75]="|Alsace|Aquitaine|Auvergne|Basse-Normandie|Bourgogne|Bretagne|Centre|Champagne-Ardenne|Corse|Franche-Comte|Haute-Normandie|Ile-de-France|Languedoc-Roussillon|Limousin|Lorraine|Midi-Pyrenees|Nord-Pas-de-Calais|Pays de la Loire|Picardie|Poitou-Charentes|Provence-Alpes-Cote d'Azur|Rhone-Alpes"; -aStates[76]="|French Guiana"; -aStates[77]="|Archipel des Marquises|Archipel des Tuamotu|Archipel des Tubuai|Iles du Vent|Iles Sous-le-Vent"; -aStates[78]="|Adelie Land|Ile Crozet|Iles Kerguelen|Iles Saint-Paul et Amsterdam"; -aStates[79]="|Estuaire|Haut-Ogooue|Moyen-Ogooue|Ngounie|Nyanga|Ogooue-Ivindo|Ogooue-Lolo|Ogooue-Maritime|Woleu-Ntem"; -aStates[80]="|Banjul|Central River|Lower River|North Bank|Upper River|Western"; -aStates[81]="|Gaza Strip"; -aStates[82]="|Abashis|Abkhazia or Ap'khazet'is Avtonomiuri Respublika (Sokhumi)|Adigenis|Ajaria or Acharis Avtonomiuri Respublika (Bat'umi)|Akhalgoris|Akhalk'alak'is|Akhalts'ikhis|Akhmetis|Ambrolauris|Aspindzis|Baghdat'is|Bolnisis|Borjomis|Ch'khorotsqus|Ch'okhatauris|Chiat'ura|Dedop'listsqaros|Dmanisis|Dushet'is|Gardabanis|Gori|Goris|Gurjaanis|Javis|K'arelis|K'ut'aisi|Kaspis|Kharagaulis|Khashuris|Khobis|Khonis|Lagodekhis|Lanch'khut'is|Lentekhis|Marneulis|Martvilis|Mestiis|Mts'khet'is|Ninotsmindis|Onis|Ozurget'is|P'ot'i|Qazbegis|Qvarlis|Rust'avi|Sach'kheris|Sagarejos|Samtrediis|Senakis|Sighnaghis|T'bilisi|T'elavis|T'erjolis|T'et'ritsqaros|T'ianet'is|Tqibuli|Ts'ageris|Tsalenjikhis|Tsalkis|Tsqaltubo|Vanis|Zestap'onis|Zugdidi|Zugdidis"; -aStates[83]="|Baden-Wuerttemberg|Bayern|Berlin|Brandenburg|Bremen|Hamburg|Hessen|Mecklenburg-Vorpommern|Niedersachsen|Nordrhein-Westfalen|Rheinland-Pfalz|Saarland|Sachsen|Sachsen-Anhalt|Schleswig-Holstein|Thueringen"; -aStates[84]="|Ashanti|Brong-Ahafo|Central|Eastern|Greater Accra|Northern|Upper East|Upper West|Volta|Western"; -aStates[85]="|Gibraltar"; -aStates[86]="|Ile du Lys|Ile Glorieuse"; -aStates[87]="|Aitolia kai Akarnania|Akhaia|Argolis|Arkadhia|Arta|Attiki|Ayion Oros (Mt. Athos)|Dhodhekanisos|Drama|Evritania|Evros|Evvoia|Florina|Fokis|Fthiotis|Grevena|Ilia|Imathia|Ioannina|Irakleion|Kardhitsa|Kastoria|Kavala|Kefallinia|Kerkyra|Khalkidhiki|Khania|Khios|Kikladhes|Kilkis|Korinthia|Kozani|Lakonia|Larisa|Lasithi|Lesvos|Levkas|Magnisia|Messinia|Pella|Pieria|Preveza|Rethimni|Rodhopi|Samos|Serrai|Thesprotia|Thessaloniki|Trikala|Voiotia|Xanthi|Zakinthos"; -aStates[88]="|Avannaa (Nordgronland)|Kitaa (Vestgronland)|Tunu (Ostgronland)" -aStates[89]="|Carriacou and Petit Martinique|Saint Andrew|Saint David|Saint George|Saint John|Saint Mark|Saint Patrick"; -aStates[90]="|Basse-Terre|Grande-Terre|Iles de la Petite Terre|Iles des Saintes|Marie-Galante"; -aStates[91]="|Guam"; -aStates[92]="|Alta Verapaz|Baja Verapaz|Chimaltenango|Chiquimula|El Progreso|Escuintla|Guatemala|Huehuetenango|Izabal|Jalapa|Jutiapa|Peten|Quetzaltenango|Quiche|Retalhuleu|Sacatepequez|San Marcos|Santa Rosa|Solola|Suchitepequez|Totonicapan|Zacapa"; -aStates[93]="|Castel|Forest|St. Andrew|St. Martin|St. Peter Port|St. Pierre du Bois|St. Sampson|St. Saviour|Torteval|Vale"; -aStates[94]="|Beyla|Boffa|Boke|Conakry|Coyah|Dabola|Dalaba|Dinguiraye|Dubreka|Faranah|Forecariah|Fria|Gaoual|Gueckedou|Kankan|Kerouane|Kindia|Kissidougou|Koubia|Koundara|Kouroussa|Labe|Lelouma|Lola|Macenta|Mali|Mamou|Mandiana|Nzerekore|Pita|Siguiri|Telimele|Tougue|Yomou"; -aStates[95]="|Bafata|Biombo|Bissau|Bolama-Bijagos|Cacheu|Gabu|Oio|Quinara|Tombali"; -aStates[96]="|Barima-Waini|Cuyuni-Mazaruni|Demerara-Mahaica|East Berbice-Corentyne|Essequibo Islands-West Demerara|Mahaica-Berbice|Pomeroon-Supenaam|Potaro-Siparuni|Upper Demerara-Berbice|Upper Takutu-Upper Essequibo"; -aStates[97]="|Artibonite|Centre|Grand'Anse|Nord|Nord-Est|Nord-Ouest|Ouest|Sud|Sud-Est"; -aStates[98]="|Heard Island and McDonald Islands"; -aStates[99]="|Holy See (Vatican City)" -aStates[100]="|Atlantida|Choluteca|Colon|Comayagua|Copan|Cortes|El Paraiso|Francisco Morazan|Gracias a Dios|Intibuca|Islas de la Bahia|La Paz|Lempira|Ocotepeque|Olancho|Santa Barbara|Valle|Yoro"; -aStates[101]="|Hong Kong"; -aStates[102]="|Howland Island"; -aStates[103]="|Bacs-Kiskun|Baranya|Bekes|Bekescsaba|Borsod-Abauj-Zemplen|Budapest|Csongrad|Debrecen|Dunaujvaros|Eger|Fejer|Gyor|Gyor-Moson-Sopron|Hajdu-Bihar|Heves|Hodmezovasarhely|Jasz-Nagykun-Szolnok|Kaposvar|Kecskemet|Komarom-Esztergom|Miskolc|Nagykanizsa|Nograd|Nyiregyhaza|Pecs|Pest|Somogy|Sopron|Szabolcs-Szatmar-Bereg|Szeged|Szekesfehervar|Szolnok|Szombathely|Tatabanya|Tolna|Vas|Veszprem|Veszprem|Zala|Zalaegerszeg"; -aStates[104]="|Akranes|Akureyri|Arnessysla|Austur-Bardhastrandarsysla|Austur-Hunavatnssysla|Austur-Skaftafellssysla|Borgarfjardharsysla|Dalasysla|Eyjafjardharsysla|Gullbringusysla|Hafnarfjordhur|Husavik|Isafjordhur|Keflavik|Kjosarsysla|Kopavogur|Myrasysla|Neskaupstadhur|Nordhur-Isafjardharsysla|Nordhur-Mulasys-la|Nordhur-Thingeyjarsysla|Olafsfjordhur|Rangarvallasysla|Reykjavik|Saudharkrokur|Seydhisfjordhur|Siglufjordhur|Skagafjardharsysla|Snaefellsnes-og Hnappadalssysla|Strandasysla|Sudhur-Mulasysla|Sudhur-Thingeyjarsysla|Vesttmannaeyjar|Vestur-Bardhastrandarsysla|Vestur-Hunavatnssysla|Vestur-Isafjardharsysla|Vestur-Skaftafellssysla"; -aStates[105]="|Andaman and Nicobar Islands|Andhra Pradesh|Arunachal Pradesh|Assam|Bihar|Chandigarh|Chhattisgarh|Dadra and Nagar Haveli|Daman and Diu|Delhi|Goa|Gujarat|Haryana|Himachal Pradesh|Jammu and Kashmir|Jharkhand|Karnataka|Kerala|Lakshadweep|Madhya Pradesh|Maharashtra|Manipur|Meghalaya|Mizoram|Nagaland|Orissa|Pondicherry|Punjab|Rajasthan|Sikkim|Tamil Nadu|Tripura|Uttar Pradesh|Uttaranchal|West Bengal"; -aStates[106]="|Aceh|Bali|Banten|Bengkulu|East Timor|Gorontalo|Irian Jaya|Jakarta Raya|Jambi|Jawa Barat|Jawa Tengah|Jawa Timur|Kalimantan Barat|Kalimantan Selatan|Kalimantan Tengah|Kalimantan Timur|Kepulauan Bangka Belitung|Lampung|Maluku|Maluku Utara|Nusa Tenggara Barat|Nusa Tenggara Timur|Riau|Sulawesi Selatan|Sulawesi Tengah|Sulawesi Tenggara|Sulawesi Utara|Sumatera Barat|Sumatera Selatan|Sumatera Utara|Yogyakarta"; -aStates[107]="|Ardabil|Azarbayjan-e Gharbi|Azarbayjan-e Sharqi|Bushehr|Chahar Mahall va Bakhtiari|Esfahan|Fars|Gilan|Golestan|Hamadan|Hormozgan|Ilam|Kerman|Kermanshah|Khorasan|Khuzestan|Kohgiluyeh va Buyer Ahmad|Kordestan|Lorestan|Markazi|Mazandaran|Qazvin|Qom|Semnan|Sistan va Baluchestan|Tehran|Yazd|Zanjan"; -aStates[108]="|Al Anbar|Al Basrah|Al Muthanna|Al Qadisiyah|An Najaf|Arbil|As Sulaymaniyah|At Ta'mim|Babil|Baghdad|Dahuk|Dhi Qar|Diyala|Karbala'|Maysan|Ninawa|Salah ad Din|Wasit"; -aStates[109]="|Carlow|Cavan|Clare|Cork|Donegal|Dublin|Galway|Kerry|Kildare|Kilkenny|Laois|Leitrim|Limerick|Longford|Louth|Mayo|Meath|Monaghan|Offaly|Roscommon|Sligo|Tipperary|Waterford|Westmeath|Wexford|Wicklow"; -aStates[110]="|Antrim|Ards|Armagh|Ballymena|Ballymoney|Banbridge|Belfast|Carrickfergus|Castlereagh|Coleraine|Cookstown|Craigavon|Derry|Down|Dungannon|Fermanagh|Larne|Limavady|Lisburn|Magherafelt|Moyle|Newry and Mourne|Newtownabbey|North Down|Omagh|Strabane"; -aStates[111]="|Central|Haifa|Jerusalem|Northern|Southern|Tel Aviv"; -aStates[112]="|Abruzzi|Basilicata|Calabria|Campania|Emilia-Romagna|Friuli-Venezia Giulia|Lazio|Liguria|Lombardia|Marche|Molise|Piemonte|Puglia|Sardegna|Sicilia|Toscana|Trentino-Alto Adige|Umbria|Valle d'Aosta|Veneto"; -aStates[113]="|Clarendon|Hanover|Kingston|Manchester|Portland|Saint Andrew|Saint Ann|Saint Catherine|Saint Elizabeth|Saint James|Saint Mary|Saint Thomas|Trelawny|Westmoreland"; -aStates[114]="|Jan Mayen"; -aStates[115]="|Aichi|Akita|Aomori|Chiba|Ehime|Fukui|Fukuoka|Fukushima|Gifu|Gumma|Hiroshima|Hokkaido|Hyogo|Ibaraki|Ishikawa|Iwate|Kagawa|Kagoshima|Kanagawa|Kochi|Kumamoto|Kyoto|Mie|Miyagi|Miyazaki|Nagano|Nagasaki|Nara|Niigata|Oita|Okayama|Okinawa|Osaka|Saga|Saitama|Shiga|Shimane|Shizuoka|Tochigi|Tokushima|Tokyo|Tottori|Toyama|Wakayama|Yamagata|Yamaguchi|Yamanashi"; -aStates[116]="|Jarvis Island"; -aStates[117]="|Jersey"; -aStates[118]="|Johnston Atoll"; -aStates[119]="|'Amman|Ajlun|Al 'Aqabah|Al Balqa'|Al Karak|Al Mafraq|At Tafilah|Az Zarqa'|Irbid|Jarash|Ma'an|Madaba"; -aStates[120]="|Juan de Nova Island"; -aStates[121]="|Almaty|Aqmola|Aqtobe|Astana|Atyrau|Batys Qazaqstan|Bayqongyr|Mangghystau|Ongtustik Qazaqstan|Pavlodar|Qaraghandy|Qostanay|Qyzylorda|Shyghys Qazaqstan|Soltustik Qazaqstan|Zhambyl"; -aStates[122]="|Central|Coast|Eastern|Nairobi Area|North Eastern|Nyanza|Rift Valley|Western"; -aStates[123]="|Abaiang|Abemama|Aranuka|Arorae|Banaba|Banaba|Beru|Butaritari|Central Gilberts|Gilbert Islands|Kanton|Kiritimati|Kuria|Line Islands|Line Islands|Maiana|Makin|Marakei|Nikunau|Nonouti|Northern Gilberts|Onotoa|Phoenix Islands|Southern Gilberts|Tabiteuea|Tabuaeran|Tamana|Tarawa|Tarawa|Teraina"; -aStates[124]="|Chagang-do (Chagang Province)|Hamgyong-bukto (North Hamgyong Province)|Hamgyong-namdo (South Hamgyong Province)|Hwanghae-bukto (North Hwanghae Province)|Hwanghae-namdo (South Hwanghae Province)|Kaesong-si (Kaesong City)|Kangwon-do (Kangwon Province)|Namp'o-si (Namp'o City)|P'yongan-bukto (North P'yongan Province)|P'yongan-namdo (South P'yongan Province)|P'yongyang-si (P'yongyang City)|Yanggang-do (Yanggang Province)" -aStates[125]="|Ch'ungch'ong-bukto|Ch'ungch'ong-namdo|Cheju-do|Cholla-bukto|Cholla-namdo|Inch'on-gwangyoksi|Kangwon-do|Kwangju-gwangyoksi|Kyonggi-do|Kyongsang-bukto|Kyongsang-namdo|Pusan-gwangyoksi|Soul-t'ukpyolsi|Taegu-gwangyoksi|Taejon-gwangyoksi|Ulsan-gwangyoksi"; -aStates[126]="|Al 'Asimah|Al Ahmadi|Al Farwaniyah|Al Jahra'|Hawalli"; -aStates[127]="|Batken Oblasty|Bishkek Shaary|Chuy Oblasty (Bishkek)|Jalal-Abad Oblasty|Naryn Oblasty|Osh Oblasty|Talas Oblasty|Ysyk-Kol Oblasty (Karakol)" -aStates[128]="|Attapu|Bokeo|Bolikhamxai|Champasak|Houaphan|Khammouan|Louangnamtha|Louangphabang|Oudomxai|Phongsali|Salavan|Savannakhet|Viangchan|Viangchan|Xaignabouli|Xaisomboun|Xekong|Xiangkhoang"; -aStates[129]="|Aizkraukles Rajons|Aluksnes Rajons|Balvu Rajons|Bauskas Rajons|Cesu Rajons|Daugavpils|Daugavpils Rajons|Dobeles Rajons|Gulbenes Rajons|Jekabpils Rajons|Jelgava|Jelgavas Rajons|Jurmala|Kraslavas Rajons|Kuldigas Rajons|Leipaja|Liepajas Rajons|Limbazu Rajons|Ludzas Rajons|Madonas Rajons|Ogres Rajons|Preilu Rajons|Rezekne|Rezeknes Rajons|Riga|Rigas Rajons|Saldus Rajons|Talsu Rajons|Tukuma Rajons|Valkas Rajons|Valmieras Rajons|Ventspils|Ventspils Rajons"; -aStates[130]="|Beyrouth|Ech Chimal|Ej Jnoub|El Bekaa|Jabal Loubnane"; -aStates[131]="|Berea|Butha-Buthe|Leribe|Mafeteng|Maseru|Mohales Hoek|Mokhotlong|Qacha's Nek|Quthing|Thaba-Tseka"; -aStates[132]="|Bomi|Bong|Grand Bassa|Grand Cape Mount|Grand Gedeh|Grand Kru|Lofa|Margibi|Maryland|Montserrado|Nimba|River Cess|Sinoe"; -aStates[133]="|Ajdabiya|Al 'Aziziyah|Al Fatih|Al Jabal al Akhdar|Al Jufrah|Al Khums|Al Kufrah|An Nuqat al Khams|Ash Shati'|Awbari|Az Zawiyah|Banghazi|Darnah|Ghadamis|Gharyan|Misratah|Murzuq|Sabha|Sawfajjin|Surt|Tarabulus|Tarhunah|Tubruq|Yafran|Zlitan"; -aStates[134]="|Balzers|Eschen|Gamprin|Mauren|Planken|Ruggell|Schaan|Schellenberg|Triesen|Triesenberg|Vaduz"; -aStates[135]="|Akmenes Rajonas|Alytaus Rajonas|Alytus|Anyksciu Rajonas|Birstonas|Birzu Rajonas|Druskininkai|Ignalinos Rajonas|Jonavos Rajonas|Joniskio Rajonas|Jurbarko Rajonas|Kaisiadoriu Rajonas|Kaunas|Kauno Rajonas|Kedainiu Rajonas|Kelmes Rajonas|Klaipeda|Klaipedos Rajonas|Kretingos Rajonas|Kupiskio Rajonas|Lazdiju Rajonas|Marijampole|Marijampoles Rajonas|Mazeikiu Rajonas|Moletu Rajonas|Neringa Pakruojo Rajonas|Palanga|Panevezio Rajonas|Panevezys|Pasvalio Rajonas|Plunges Rajonas|Prienu Rajonas|Radviliskio Rajonas|Raseiniu Rajonas|Rokiskio Rajonas|Sakiu Rajonas|Salcininku Rajonas|Siauliai|Siauliu Rajonas|Silales Rajonas|Silutes Rajonas|Sirvintu Rajonas|Skuodo Rajonas|Svencioniu Rajonas|Taurages Rajonas|Telsiu Rajonas|Traku Rajonas|Ukmerges Rajonas|Utenos Rajonas|Varenos Rajonas|Vilkaviskio Rajonas|Vilniaus Rajonas|Vilnius|Zarasu Rajonas"; -aStates[136]="|Diekirch|Grevenmacher|Luxembourg"; -aStates[137]="|Macau"; -aStates[138]="|Aracinovo|Bac|Belcista|Berovo|Bistrica|Bitola|Blatec|Bogdanci|Bogomila|Bogovinje|Bosilovo|Brvenica|Cair (Skopje)|Capari|Caska|Cegrane|Centar (Skopje)|Centar Zupa|Cesinovo|Cucer-Sandevo|Debar|Delcevo|Delogozdi|Demir Hisar|Demir Kapija|Dobrusevo|Dolna Banjica|Dolneni|Dorce Petrov (Skopje)|Drugovo|Dzepciste|Gazi Baba (Skopje)|Gevgelija|Gostivar|Gradsko|Ilinden|Izvor|Jegunovce|Kamenjane|Karbinci|Karpos (Skopje)|Kavadarci|Kicevo|Kisela Voda (Skopje)|Klecevce|Kocani|Konce|Kondovo|Konopiste|Kosel|Kratovo|Kriva Palanka|Krivogastani|Krusevo|Kuklis|Kukurecani|Kumanovo|Labunista|Lipkovo|Lozovo|Lukovo|Makedonska Kamenica|Makedonski Brod|Mavrovi Anovi|Meseista|Miravci|Mogila|Murtino|Negotino|Negotino-Poloska|Novaci|Novo Selo|Oblesevo|Ohrid|Orasac|Orizari|Oslomej|Pehcevo|Petrovec|Plasnia|Podares|Prilep|Probistip|Radovis|Rankovce|Resen|Rosoman|Rostusa|Samokov|Saraj|Sipkovica|Sopiste|Sopotnika|Srbinovo|Star Dojran|Staravina|Staro Nagoricane|Stip|Struga|Strumica|Studenicani|Suto Orizari (Skopje)|Sveti Nikole|Tearce|Tetovo|Topolcani|Valandovo|Vasilevo|Veles|Velesta|Vevcani|Vinica|Vitoliste|Vranestica|Vrapciste|Vratnica|Vrutok|Zajas|Zelenikovo|Zileno|Zitose|Zletovo|Zrnovci"; -aStates[139]="|Antananarivo|Antsiranana|Fianarantsoa|Mahajanga|Toamasina|Toliara"; -aStates[140]="|Balaka|Blantyre|Chikwawa|Chiradzulu|Chitipa|Dedza|Dowa|Karonga|Kasungu|Likoma|Lilongwe|Machinga (Kasupe)|Mangochi|Mchinji|Mulanje|Mwanza|Mzimba|Nkhata Bay|Nkhotakota|Nsanje|Ntcheu|Ntchisi|Phalombe|Rumphi|Salima|Thyolo|Zomba"; -aStates[141]="|Johor|Kedah|Kelantan|Labuan|Melaka|Negeri Sembilan|Pahang|Perak|Perlis|Pulau Pinang|Sabah|Sarawak|Selangor|Terengganu|Wilayah Persekutuan"; -aStates[142]="|Alifu|Baa|Dhaalu|Faafu|Gaafu Alifu|Gaafu Dhaalu|Gnaviyani|Haa Alifu|Haa Dhaalu|Kaafu|Laamu|Lhaviyani|Maale|Meemu|Noonu|Raa|Seenu|Shaviyani|Thaa|Vaavu"; -aStates[143]="|Gao|Kayes|Kidal|Koulikoro|Mopti|Segou|Sikasso|Tombouctou"; -aStates[144]="|Valletta"; -aStates[145]="|Man, Isle of"; -aStates[146]="|Ailinginae|Ailinglaplap|Ailuk|Arno|Aur|Bikar|Bikini|Bokak|Ebon|Enewetak|Erikub|Jabat|Jaluit|Jemo|Kili|Kwajalein|Lae|Lib|Likiep|Majuro|Maloelap|Mejit|Mili|Namorik|Namu|Rongelap|Rongrik|Toke|Ujae|Ujelang|Utirik|Wotho|Wotje"; -aStates[147]="|Martinique"; -aStates[148]="|Adrar|Assaba|Brakna|Dakhlet Nouadhibou|Gorgol|Guidimaka|Hodh Ech Chargui|Hodh El Gharbi|Inchiri|Nouakchott|Tagant|Tiris Zemmour|Trarza"; -aStates[149]="|Agalega Islands|Black River|Cargados Carajos Shoals|Flacq|Grand Port|Moka|Pamplemousses|Plaines Wilhems|Port Louis|Riviere du Rempart|Rodrigues|Savanne"; -aStates[150]="|Mayotte"; -aStates[151]="|Aguascalientes|Baja California|Baja California Sur|Campeche|Chiapas|Chihuahua|Coahuila de Zaragoza|Colima|Distrito Federal|Durango|Guanajuato|Guerrero|Hidalgo|Jalisco|Mexico|Michoacan de Ocampo|Morelos|Nayarit|Nuevo Leon|Oaxaca|Puebla|Queretaro de Arteaga|Quintana Roo|San Luis Potosi|Sinaloa|Sonora|Tabasco|Tamaulipas|Tlaxcala|Veracruz-Llave|Yucatan|Zacatecas"; -aStates[152]="|Chuuk (Truk)|Kosrae|Pohnpei|Yap"; -aStates[153]="|Midway Islands"; -aStates[154]="|Balti|Cahul|Chisinau|Chisinau|Dubasari|Edinet|Gagauzia|Lapusna|Orhei|Soroca|Tighina|Ungheni"; -aStates[155]="|Fontvieille|La Condamine|Monaco-Ville|Monte-Carlo"; -aStates[156]="|Arhangay|Bayan-Olgiy|Bayanhongor|Bulgan|Darhan|Dornod|Dornogovi|Dundgovi|Dzavhan|Erdenet|Govi-Altay|Hentiy|Hovd|Hovsgol|Omnogovi|Ovorhangay|Selenge|Suhbaatar|Tov|Ulaanbaatar|Uvs"; -aStates[157]="|Saint Anthony|Saint Georges|Saint Peter's"; -aStates[158]="|Agadir|Al Hoceima|Azilal|Ben Slimane|Beni Mellal|Boulemane|Casablanca|Chaouen|El Jadida|El Kelaa des Srarhna|Er Rachidia|Essaouira|Fes|Figuig|Guelmim|Ifrane|Kenitra|Khemisset|Khenifra|Khouribga|Laayoune|Larache|Marrakech|Meknes|Nador|Ouarzazate|Oujda|Rabat-Sale|Safi|Settat|Sidi Kacem|Tan-Tan|Tanger|Taounate|Taroudannt|Tata|Taza|Tetouan|Tiznit"; -aStates[159]="|Cabo Delgado|Gaza|Inhambane|Manica|Maputo|Nampula|Niassa|Sofala|Tete|Zambezia"; -aStates[160]="|Caprivi|Erongo|Hardap|Karas|Khomas|Kunene|Ohangwena|Okavango|Omaheke|Omusati|Oshana|Oshikoto|Otjozondjupa"; -aStates[161]="|Aiwo|Anabar|Anetan|Anibare|Baiti|Boe|Buada|Denigomodu|Ewa|Ijuw|Meneng|Nibok|Uaboe|Yaren"; -aStates[162]="|Bagmati|Bheri|Dhawalagiri|Gandaki|Janakpur|Karnali|Kosi|Lumbini|Mahakali|Mechi|Narayani|Rapti|Sagarmatha|Seti"; -aStates[163]="|Drenthe|Flevoland|Friesland|Gelderland|Groningen|Limburg|Noord-Brabant|Noord-Holland|Overijssel|Utrecht|Zeeland|Zuid-Holland"; -aStates[164]="|Netherlands Antilles"; -aStates[165]="|Iles Loyaute|Nord|Sud"; -aStates[166]="|Akaroa|Amuri|Ashburton|Bay of Islands|Bruce|Buller|Chatham Islands|Cheviot|Clifton|Clutha|Cook|Dannevirke|Egmont|Eketahuna|Ellesmere|Eltham|Eyre|Featherston|Franklin|Golden Bay|Great Barrier Island|Grey|Hauraki Plains|Hawera|Hawke's Bay|Heathcote|Hikurangi|Hobson|Hokianga|Horowhenua|Hurunui|Hutt|Inangahua|Inglewood|Kaikoura|Kairanga|Kiwitea|Lake|Mackenzie|Malvern|Manaia|Manawatu|Mangonui|Maniototo|Marlborough|Masterton|Matamata|Mount Herbert|Ohinemuri|Opotiki|Oroua|Otamatea|Otorohanga|Oxford|Pahiatua|Paparua|Patea|Piako|Pohangina|Raglan|Rangiora|Rangitikei|Rodney|Rotorua|Runanga|Saint Kilda|Silverpeaks|Southland|Stewart Island|Stratford|Strathallan|Taranaki|Taumarunui|Taupo|Tauranga|Thames-Coromandel|Tuapeka|Vincent|Waiapu|Waiheke|Waihemo|Waikato|Waikohu|Waimairi|Waimarino|Waimate|Waimate West|Waimea|Waipa|Waipawa|Waipukurau|Wairarapa South|Wairewa|Wairoa|Waitaki|Waitomo|Waitotara|Wallace|Wanganui|Waverley|Westland|Whakatane|Whangarei|Whangaroa|Woodville"; -aStates[167]="|Atlantico Norte|Atlantico Sur|Boaco|Carazo|Chinandega|Chontales|Esteli|Granada|Jinotega|Leon|Madriz|Managua|Masaya|Matagalpa|Nueva Segovia|Rio San Juan|Rivas"; -aStates[168]="|Agadez|Diffa|Dosso|Maradi|Niamey|Tahoua|Tillaberi|Zinder"; -aStates[169]="|Abia|Abuja Federal Capital Territory|Adamawa|Akwa Ibom|Anambra|Bauchi|Bayelsa|Benue|Borno|Cross River|Delta|Ebonyi|Edo|Ekiti|Enugu|Gombe|Imo|Jigawa|Kaduna|Kano|Katsina|Kebbi|Kogi|Kwara|Lagos|Nassarawa|Niger|Ogun|Ondo|Osun|Oyo|Plateau|Rivers|Sokoto|Taraba|Yobe|Zamfara"; -aStates[170]="|Niue"; -aStates[171]="|Norfolk Island"; -aStates[172]="|Northern Islands|Rota|Saipan|Tinian"; -aStates[173]="|Akershus|Aust-Agder|Buskerud|Finnmark|Hedmark|Hordaland|More og Romsdal|Nord-Trondelag|Nordland|Oppland|Oslo|Ostfold|Rogaland|Sogn og Fjordane|Sor-Trondelag|Telemark|Troms|Vest-Agder|Vestfold"; -aStates[174]="|Ad Dakhiliyah|Al Batinah|Al Wusta|Ash Sharqiyah|Az Zahirah|Masqat|Musandam|Zufar"; -aStates[175]="|Balochistan|Federally Administered Tribal Areas|Islamabad Capital Territory|North-West Frontier Province|Punjab|Sindh"; -aStates[176]="|Aimeliik|Airai|Angaur|Hatobohei|Kayangel|Koror|Melekeok|Ngaraard|Ngarchelong|Ngardmau|Ngatpang|Ngchesar|Ngeremlengui|Ngiwal|Palau Island|Peleliu|Sonsoral|Tobi"; -aStates[177]="|Bocas del Toro|Chiriqui|Cocle|Colon|Darien|Herrera|Los Santos|Panama|San Blas|Veraguas"; -aStates[178]="|Bougainville|Central|Chimbu|East New Britain|East Sepik|Eastern Highlands|Enga|Gulf|Madang|Manus|Milne Bay|Morobe|National Capital|New Ireland|Northern|Sandaun|Southern Highlands|West New Britain|Western|Western Highlands"; -aStates[179]="|Alto Paraguay|Alto Parana|Amambay|Asuncion (city)|Boqueron|Caaguazu|Caazapa|Canindeyu|Central|Concepcion|Cordillera|Guaira|Itapua|Misiones|Neembucu|Paraguari|Presidente Hayes|San Pedro"; -aStates[180]="|Amazonas|Ancash|Apurimac|Arequipa|Ayacucho|Cajamarca|Callao|Cusco|Huancavelica|Huanuco|Ica|Junin|La Libertad|Lambayeque|Lima|Loreto|Madre de Dios|Moquegua|Pasco|Piura|Puno|San Martin|Tacna|Tumbes|Ucayali"; -aStates[181]="|Abra|Agusan del Norte|Agusan del Sur|Aklan|Albay|Angeles|Antique|Aurora|Bacolod|Bago|Baguio|Bais|Basilan|Basilan City|Bataan|Batanes|Batangas|Batangas City|Benguet|Bohol|Bukidnon|Bulacan|Butuan|Cabanatuan|Cadiz|Cagayan|Cagayan de Oro|Calbayog|Caloocan|Camarines Norte|Camarines Sur|Camiguin|Canlaon|Capiz|Catanduanes|Cavite|Cavite City|Cebu|Cebu City|Cotabato|Dagupan|Danao|Dapitan|Davao City Davao|Davao del Sur|Davao Oriental|Dipolog|Dumaguete|Eastern Samar|General Santos|Gingoog|Ifugao|Iligan|Ilocos Norte|Ilocos Sur|Iloilo|Iloilo City|Iriga|Isabela|Kalinga-Apayao|La Carlota|La Union|Laguna|Lanao del Norte|Lanao del Sur|Laoag|Lapu-Lapu|Legaspi|Leyte|Lipa|Lucena|Maguindanao|Mandaue|Manila|Marawi|Marinduque|Masbate|Mindoro Occidental|Mindoro Oriental|Misamis Occidental|Misamis Oriental|Mountain|Naga|Negros Occidental|Negros Oriental|North Cotabato|Northern Samar|Nueva Ecija|Nueva Vizcaya|Olongapo|Ormoc|Oroquieta|Ozamis|Pagadian|Palawan|Palayan|Pampanga|Pangasinan|Pasay|Puerto Princesa|Quezon|Quezon City|Quirino|Rizal|Romblon|Roxas|Samar|San Carlos (in Negros Occidental)|San Carlos (in Pangasinan)|San Jose|San Pablo|Silay|Siquijor|Sorsogon|South Cotabato|Southern Leyte|Sultan Kudarat|Sulu|Surigao|Surigao del Norte|Surigao del Sur|Tacloban|Tagaytay|Tagbilaran|Tangub|Tarlac|Tawitawi|Toledo|Trece Martires|Zambales|Zamboanga|Zamboanga del Norte|Zamboanga del Sur"; -aStates[182]="|Pitcaim Islands"; -aStates[183]="|Dolnoslaskie|Kujawsko-Pomorskie|Lodzkie|Lubelskie|Lubuskie|Malopolskie|Mazowieckie|Opolskie|Podkarpackie|Podlaskie|Pomorskie|Slaskie|Swietokrzyskie|Warminsko-Mazurskie|Wielkopolskie|Zachodniopomorskie"; -aStates[184]="|Acores (Azores)|Aveiro|Beja|Braga|Braganca|Castelo Branco|Coimbra|Evora|Faro|Guarda|Leiria|Lisboa|Madeira|Portalegre|Porto|Santarem|Setubal|Viana do Castelo|Vila Real|Viseu"; -aStates[185]="|Adjuntas|Aguada|Aguadilla|Aguas Buenas|Aibonito|Anasco|Arecibo|Arroyo|Barceloneta|Barranquitas|Bayamon|Cabo Rojo|Caguas|Camuy|Canovanas|Carolina|Catano|Cayey|Ceiba|Ciales|Cidra|Coamo|Comerio|Corozal|Culebra|Dorado|Fajardo|Florida|Guanica|Guayama|Guayanilla|Guaynabo|Gurabo|Hatillo|Hormigueros|Humacao|Isabela|Jayuya|Juana Diaz|Juncos|Lajas|Lares|Las Marias|Las Piedras|Loiza|Luquillo|Manati|Maricao|Maunabo|Mayaguez|Moca|Morovis|Naguabo|Naranjito|Orocovis|Patillas|Penuelas|Ponce|Quebradillas|Rincon|Rio Grande|Sabana Grande|Salinas|San German|San Juan|San Lorenzo|San Sebastian|Santa Isabel|Toa Alta|Toa Baja|Trujillo Alto|Utuado|Vega Alta|Vega Baja|Vieques|Villalba|Yabucoa|Yauco"; -aStates[186]="|Ad Dawhah|Al Ghuwayriyah|Al Jumayliyah|Al Khawr|Al Wakrah|Ar Rayyan|Jarayan al Batinah|Madinat ash Shamal|Umm Salal"; -aStates[187]="|Reunion"; -aStates[188]="|Alba|Arad|Arges|Bacau|Bihor|Bistrita-Nasaud|Botosani|Braila|Brasov|Bucuresti|Buzau|Calarasi|Caras-Severin|Cluj|Constanta|Covasna|Dimbovita|Dolj|Galati|Giurgiu|Gorj|Harghita|Hunedoara|Ialomita|Iasi|Maramures|Mehedinti|Mures|Neamt|Olt|Prahova|Salaj|Satu Mare|Sibiu|Suceava|Teleorman|Timis|Tulcea|Vaslui|Vilcea|Vrancea"; -aStates[189]="|Adygeya (Maykop)|Aginskiy Buryatskiy (Aginskoye)|Altay (Gorno-Altaysk)|Altayskiy (Barnaul)|Amurskaya (Blagoveshchensk)|Arkhangel'skaya|Astrakhanskaya|Bashkortostan (Ufa)|Belgorodskaya|Bryanskaya|Buryatiya (Ulan-Ude)|Chechnya (Groznyy)|Chelyabinskaya|Chitinskaya|Chukotskiy (Anadyr')|Chuvashiya (Cheboksary)|Dagestan (Makhachkala)|Evenkiyskiy (Tura)|Ingushetiya (Nazran')|Irkutskaya|Ivanovskaya|Kabardino-Balkariya (Nal'chik)|Kaliningradskaya|Kalmykiya (Elista)|Kaluzhskaya|Kamchatskaya (Petropavlovsk-Kamchatskiy)|Karachayevo-Cherkesiya (Cherkessk)|Kareliya (Petrozavodsk)|Kemerovskaya|Khabarovskiy|Khakasiya (Abakan)|Khanty-Mansiyskiy (Khanty-Mansiysk)|Kirovskaya|Komi (Syktyvkar)|Komi-Permyatskiy (Kudymkar)|Koryakskiy (Palana)|Kostromskaya|Krasnodarskiy|Krasnoyarskiy|Kurganskaya|Kurskaya|Leningradskaya|Lipetskaya|Magadanskaya|Mariy-El (Yoshkar-Ola)|Mordoviya (Saransk)|Moskovskaya|Moskva (Moscow)|Murmanskaya|Nenetskiy (Nar'yan-Mar)|Nizhegorodskaya|Novgorodskaya|Novosibirskaya|Omskaya|Orenburgskaya|Orlovskaya (Orel)|Penzenskaya|Permskaya|Primorskiy (Vladivostok)|Pskovskaya|Rostovskaya|Ryazanskaya|Sakha (Yakutsk)|Sakhalinskaya (Yuzhno-Sakhalinsk)|Samarskaya|Sankt-Peterburg (Saint Petersburg)|Saratovskaya|Severnaya Osetiya-Alaniya [North Ossetia] (Vladikavkaz)|Smolenskaya|Stavropol'skiy|Sverdlovskaya (Yekaterinburg)|Tambovskaya|Tatarstan (Kazan')|Taymyrskiy (Dudinka)|Tomskaya|Tul'skaya|Tverskaya|Tyumenskaya|Tyva (Kyzyl)|Udmurtiya (Izhevsk)|Ul'yanovskaya|Ust'-Ordynskiy Buryatskiy (Ust'-Ordynskiy)|Vladimirskaya|Volgogradskaya|Vologodskaya|Voronezhskaya|Yamalo-Nenetskiy (Salekhard)|Yaroslavskaya|Yevreyskaya"; -aStates[190]="|Butare|Byumba|Cyangugu|Gikongoro|Gisenyi|Gitarama|Kibungo|Kibuye|Kigali Rurale|Kigali-ville|Ruhengeri|Umutara"; -aStates[191]="|Ascension|Saint Helena|Tristan da Cunha"; -aStates[192]="|Christ Church Nichola Town|Saint Anne Sandy Point|Saint George Basseterre|Saint George Gingerland|Saint James Windward|Saint John Capisterre|Saint John Figtree|Saint Mary Cayon|Saint Paul Capisterre|Saint Paul Charlestown|Saint Peter Basseterre|Saint Thomas Lowland|Saint Thomas Middle Island|Trinity Palmetto Point"; -aStates[193]="|Anse-la-Raye|Castries|Choiseul|Dauphin|Dennery|Gros Islet|Laborie|Micoud|Praslin|Soufriere|Vieux Fort"; -aStates[194]="|Miquelon|Saint Pierre"; -aStates[195]="|Charlotte|Grenadines|Saint Andrew|Saint David|Saint George|Saint Patrick"; -aStates[196]="|A'ana|Aiga-i-le-Tai|Atua|Fa'asaleleaga|Gaga'emauga|Gagaifomauga|Palauli|Satupa'itea|Tuamasaga|Va'a-o-Fonoti|Vaisigano"; -aStates[197]="|Acquaviva|Borgo Maggiore|Chiesanuova|Domagnano|Faetano|Fiorentino|Monte Giardino|San Marino|Serravalle"; -aStates[198]="|Principe|Sao Tome"; -aStates[199]="|'Asir|Al Bahah|Al Hudud ash Shamaliyah|Al Jawf|Al Madinah|Al Qasim|Ar Riyad|Ash Sharqiyah (Eastern Province)|Ha'il|Jizan|Makkah|Najran|Tabuk"; -aStates[200]="|Aberdeen City|Aberdeenshire|Angus|Argyll and Bute|City of Edinburgh|Clackmannanshire|Dumfries and Galloway|Dundee City|East Ayrshire|East Dunbartonshire|East Lothian|East Renfrewshire|Eilean Siar (Western Isles)|Falkirk|Fife|Glasgow City|Highland|Inverclyde|Midlothian|Moray|North Ayrshire|North Lanarkshire|Orkney Islands|Perth and Kinross|Renfrewshire|Shetland Islands|South Ayrshire|South Lanarkshire|Stirling|The Scottish Borders|West Dunbartonshire|West Lothian"; -aStates[201]="|Dakar|Diourbel|Fatick|Kaolack|Kolda|Louga|Saint-Louis|Tambacounda|Thies|Ziguinchor"; -aStates[202]="|Anse aux Pins|Anse Boileau|Anse Etoile|Anse Louis|Anse Royale|Baie Lazare|Baie Sainte Anne|Beau Vallon|Bel Air|Bel Ombre|Cascade|Glacis|Grand' Anse (on Mahe)|Grand' Anse (on Praslin)|La Digue|La Riviere Anglaise|Mont Buxton|Mont Fleuri|Plaisance|Pointe La Rue|Port Glaud|Saint Louis|Takamaka"; -aStates[203]="|Eastern|Northern|Southern|Western"; -aStates[204]="|Singapore"; -aStates[205]="|Banskobystricky|Bratislavsky|Kosicky|Nitriansky|Presovsky|Trenciansky|Trnavsky|Zilinsky"; -aStates[206]="|Ajdovscina|Beltinci|Bled|Bohinj|Borovnica|Bovec|Brda|Brezice|Brezovica|Cankova-Tisina|Celje|Cerklje na Gorenjskem|Cerknica|Cerkno|Crensovci|Crna na Koroskem|Crnomelj|Destrnik-Trnovska Vas|Divaca|Dobrepolje|Dobrova-Horjul-Polhov Gradec|Dol pri Ljubljani|Domzale|Dornava|Dravograd|Duplek|Gorenja Vas-Poljane|Gorisnica|Gornja Radgona|Gornji Grad|Gornji Petrovci|Grosuplje|Hodos Salovci|Hrastnik|Hrpelje-Kozina|Idrija|Ig|Ilirska Bistrica|Ivancna Gorica|Izola|Jesenice|Jursinci|Kamnik|Kanal|Kidricevo|Kobarid|Kobilje|Kocevje|Komen|Koper|Kozje|Kranj|Kranjska Gora|Krsko|Kungota|Kuzma|Lasko|Lenart|Lendava|Litija|Ljubljana|Ljubno|Ljutomer|Logatec|Loska Dolina|Loski Potok|Luce|Lukovica|Majsperk|Maribor|Medvode|Menges|Metlika|Mezica|Miren-Kostanjevica|Mislinja|Moravce|Moravske Toplice|Mozirje|Murska Sobota|Muta|Naklo|Nazarje|Nova Gorica|Novo Mesto|Odranci|Ormoz|Osilnica|Pesnica|Piran|Pivka|Podcetrtek|Podvelka-Ribnica|Postojna|Preddvor|Ptuj|Puconci|Race-Fram|Radece|Radenci|Radlje ob Dravi|Radovljica|Ravne-Prevalje|Ribnica|Rogasevci|Rogaska Slatina|Rogatec|Ruse|Semic|Sencur|Sentilj|Sentjernej|Sentjur pri Celju|Sevnica|Sezana|Skocjan|Skofja Loka|Skofljica|Slovenj Gradec|Slovenska Bistrica|Slovenske Konjice|Smarje pri Jelsah|Smartno ob Paki|Sostanj|Starse|Store|Sveti Jurij|Tolmin|Trbovlje|Trebnje|Trzic|Turnisce|Velenje|Velike Lasce|Videm|Vipava|Vitanje|Vodice|Vojnik|Vrhnika|Vuzenica|Zagorje ob Savi|Zalec|Zavrc|Zelezniki|Ziri|Zrece"; -aStates[207]="|Bellona|Central|Choiseul (Lauru)|Guadalcanal|Honiara|Isabel|Makira|Malaita|Rennell|Temotu|Western"; -aStates[208]="|Awdal|Bakool|Banaadir|Bari|Bay|Galguduud|Gedo|Hiiraan|Jubbada Dhexe|Jubbada Hoose|Mudug|Nugaal|Sanaag|Shabeellaha Dhexe|Shabeellaha Hoose|Sool|Togdheer|Woqooyi Galbeed"; -aStates[209]="|Eastern Cape|Free State|Gauteng|KwaZulu-Natal|Mpumalanga|North-West|Northern Cape|Northern Province|Western Cape"; -aStates[210]="|Bird Island|Bristol Island|Clerke Rocks|Montagu Island|Saunders Island|South Georgia|Southern Thule|Traversay Islands"; -aStates[211]="|Andalucia|Aragon|Asturias|Baleares (Balearic Islands)|Canarias (Canary Islands)|Cantabria|Castilla y Leon|Castilla-La Mancha|Cataluna|Ceuta|Communidad Valencian|Extremadura|Galicia|Islas Chafarinas|La Rioja|Madrid|Melilla|Murcia|Navarra|Pais Vasco (Basque Country)|Penon de Alhucemas|Penon de Velez de la Gomera"; -aStates[212]="|Spratly Islands"; -aStates[213]="|Central|Eastern|North Central|North Eastern|North Western|Northern|Sabaragamuwa|Southern|Uva|Western"; -aStates[214]="|A'ali an Nil|Al Bahr al Ahmar|Al Buhayrat|Al Jazirah|Al Khartum|Al Qadarif|Al Wahdah|An Nil al Abyad|An Nil al Azraq|Ash Shamaliyah|Bahr al Jabal|Gharb al Istiwa'iyah|Gharb Bahr al Ghazal|Gharb Darfur|Gharb Kurdufan|Janub Darfur|Janub Kurdufan|Junqali|Kassala|Nahr an Nil|Shamal Bahr al Ghazal|Shamal Darfur|Shamal Kurdufan|Sharq al Istiwa'iyah|Sinnar|Warab"; -aStates[215]="|Brokopondo|Commewijne|Coronie|Marowijne|Nickerie|Para|Paramaribo|Saramacca|Sipaliwini|Wanica"; -aStates[216]="|Barentsoya|Bjornoya|Edgeoya|Hopen|Kvitoya|Nordaustandet|Prins Karls Forland|Spitsbergen"; -aStates[217]="|Hhohho|Lubombo|Manzini|Shiselweni"; -aStates[218]="|Blekinge|Dalarnas|Gavleborgs|Gotlands|Hallands|Jamtlands|Jonkopings|Kalmar|Kronobergs|Norrbottens|Orebro|Ostergotlands|Skane|Sodermanlands|Stockholms|Uppsala|Varmlands|Vasterbottens|Vasternorrlands|Vastmanlands|Vastra Gotalands"; -aStates[219]="|Aargau|Ausser-Rhoden|Basel-Landschaft|Basel-Stadt|Bern|Fribourg|Geneve|Glarus|Graubunden|Inner-Rhoden|Jura|Luzern|Neuchatel|Nidwalden|Obwalden|Sankt Gallen|Schaffhausen|Schwyz|Solothurn|Thurgau|Ticino|Uri|Valais|Vaud|Zug|Zurich"; -aStates[220]="|Al Hasakah|Al Ladhiqiyah|Al Qunaytirah|Ar Raqqah|As Suwayda'|Dar'a|Dayr az Zawr|Dimashq|Halab|Hamah|Hims|Idlib|Rif Dimashq|Tartus"; -aStates[221]="|Chang-hua|Chi-lung|Chia-i|Chia-i|Chung-hsing-hsin-ts'un|Hsin-chu|Hsin-chu|Hua-lien|I-lan|Kao-hsiung|Kao-hsiung|Miao-li|Nan-t'ou|P'eng-hu|P'ing-tung|T'ai-chung|T'ai-chung|T'ai-nan|T'ai-nan|T'ai-pei|T'ai-pei|T'ai-tung|T'ao-yuan|Yun-lin"; -aStates[222]="|Viloyati Khatlon|Viloyati Leninobod|Viloyati Mukhtori Kuhistoni Badakhshon"; -aStates[223]="|Arusha|Dar es Salaam|Dodoma|Iringa|Kagera|Kigoma|Kilimanjaro|Lindi|Mara|Mbeya|Morogoro|Mtwara|Mwanza|Pemba North|Pemba South|Pwani|Rukwa|Ruvuma|Shinyanga|Singida|Tabora|Tanga|Zanzibar Central/South|Zanzibar North|Zanzibar Urban/West"; -aStates[224]="|Amnat Charoen|Ang Thong|Buriram|Chachoengsao|Chai Nat|Chaiyaphum|Chanthaburi|Chiang Mai|Chiang Rai|Chon Buri|Chumphon|Kalasin|Kamphaeng Phet|Kanchanaburi|Khon Kaen|Krabi|Krung Thep Mahanakhon (Bangkok)|Lampang|Lamphun|Loei|Lop Buri|Mae Hong Son|Maha Sarakham|Mukdahan|Nakhon Nayok|Nakhon Pathom|Nakhon Phanom|Nakhon Ratchasima|Nakhon Sawan|Nakhon Si Thammarat|Nan|Narathiwat|Nong Bua Lamphu|Nong Khai|Nonthaburi|Pathum Thani|Pattani|Phangnga|Phatthalung|Phayao|Phetchabun|Phetchaburi|Phichit|Phitsanulok|Phra Nakhon Si Ayutthaya|Phrae|Phuket|Prachin Buri|Prachuap Khiri Khan|Ranong|Ratchaburi|Rayong|Roi Et|Sa Kaeo|Sakon Nakhon|Samut Prakan|Samut Sakhon|Samut Songkhram|Sara Buri|Satun|Sing Buri|Sisaket|Songkhla|Sukhothai|Suphan Buri|Surat Thani|Surin|Tak|Trang|Trat|Ubon Ratchathani|Udon Thani|Uthai Thani|Uttaradit|Yala|Yasothon"; -aStates[225]="|Tobago"; -aStates[226]="|De La Kara|Des Plateaux|Des Savanes|Du Centre|Maritime"; -aStates[227]="|Atafu|Fakaofo|Nukunonu"; -aStates[228]="|Ha'apai|Tongatapu|Vava'u"; -aStates[229]="|Arima|Caroni|Mayaro|Nariva|Port-of-Spain|Saint Andrew|Saint David|Saint George|Saint Patrick|San Fernando|Victoria"; -aStates[230]="|Ariana|Beja|Ben Arous|Bizerte|El Kef|Gabes|Gafsa|Jendouba|Kairouan|Kasserine|Kebili|Mahdia|Medenine|Monastir|Nabeul|Sfax|Sidi Bou Zid|Siliana|Sousse|Tataouine|Tozeur|Tunis|Zaghouan"; -aStates[231]="|Adana|Adiyaman|Afyon|Agri|Aksaray|Amasya|Ankara|Antalya|Ardahan|Artvin|Aydin|Balikesir|Bartin|Batman|Bayburt|Bilecik|Bingol|Bitlis|Bolu|Burdur|Bursa|Canakkale|Cankiri|Corum|Denizli|Diyarbakir|Duzce|Edirne|Elazig|Erzincan|Erzurum|Eskisehir|Gaziantep|Giresun|Gumushane|Hakkari|Hatay|Icel|Igdir|Isparta|Istanbul|Izmir|Kahramanmaras|Karabuk|Karaman|Kars|Kastamonu|Kayseri|Kilis|Kirikkale|Kirklareli|Kirsehir|Kocaeli|Konya|Kutahya|Malatya|Manisa|Mardin|Mugla|Mus|Nevsehir|Nigde|Ordu|Osmaniye|Rize|Sakarya|Samsun|Sanliurfa|Siirt|Sinop|Sirnak|Sivas|Tekirdag|Tokat|Trabzon|Tunceli|Usak|Van|Yalova|Yozgat|Zonguldak"; -aStates[232]="|Ahal Welayaty|Balkan Welayaty|Dashhowuz Welayaty|Lebap Welayaty|Mary Welayaty"; -aStates[233]="|Tuvalu"; -aStates[234]="|Adjumani|Apac|Arua|Bugiri|Bundibugyo|Bushenyi|Busia|Gulu|Hoima|Iganga|Jinja|Kabale|Kabarole|Kalangala|Kampala|Kamuli|Kapchorwa|Kasese|Katakwi|Kibale|Kiboga|Kisoro|Kitgum|Kotido|Kumi|Lira|Luwero|Masaka|Masindi|Mbale|Mbarara|Moroto|Moyo|Mpigi|Mubende|Mukono|Nakasongola|Nebbi|Ntungamo|Pallisa|Rakai|Rukungiri|Sembabule|Soroti|Tororo"; -aStates[235]="|Avtonomna Respublika Krym (Simferopol')|Cherkas'ka (Cherkasy)|Chernihivs'ka (Chernihiv)|Chernivets'ka (Chernivtsi)|Dnipropetrovs'ka (Dnipropetrovs'k)|Donets'ka (Donets'k)|Ivano-Frankivs'ka (Ivano-Frankivs'k)|Kharkivs'ka (Kharkiv)|Khersons'ka (Kherson)|Khmel'nyts'ka (Khmel'nyts'kyy)|Kirovohrads'ka (Kirovohrad)|Kyyiv|Kyyivs'ka (Kiev)|L'vivs'ka (L'viv)|Luhans'ka (Luhans'k)|Mykolayivs'ka (Mykolayiv)|Odes'ka (Odesa)|Poltavs'ka (Poltava)|Rivnens'ka (Rivne)|Sevastopol'|Sums'ka (Sumy)|Ternopil's'ka (Ternopil')|Vinnyts'ka (Vinnytsya)|Volyns'ka (Luts'k)|Zakarpats'ka (Uzhhorod)|Zaporiz'ka (Zaporizhzhya)|Zhytomyrs'ka (Zhytomyr)" -aStates[236]="|'Ajman|Abu Zaby (Abu Dhabi)|Al Fujayrah|Ash Shariqah (Sharjah)|Dubayy (Dubai)|Ra's al Khaymah|Umm al Qaywayn"; -aStates[237]="|Barking and Dagenham|Barnet|Barnsley|Bath and North East Somerset|Bedfordshire|Bexley|Birmingham|Blackburn with Darwen|Blackpool|Bolton|Bournemouth|Bracknell Forest|Bradford|Brent|Brighton and Hove|Bromley|Buckinghamshire|Bury|Calderdale|Cambridgeshire|Camden|Cheshire|City of Bristol|City of Kingston upon Hull|City of London|Cornwall|Coventry|Croydon|Cumbria|Darlington|Derby|Derbyshire|Devon|Doncaster|Dorset|Dudley|Durham|Ealing|East Riding of Yorkshire|East Sussex|Enfield|Essex|Gateshead|Gloucestershire|Greenwich|Hackney|Halton|Hammersmith and Fulham|Hampshire|Haringey|Harrow|Hartlepool|Havering|Herefordshire|Hertfordshire|Hillingdon|Hounslow|Isle of Wight|Islington|Kensington and Chelsea|Kent|Kingston upon Thames|Kirklees|Knowsley|Lambeth|Lancashire|Leeds|Leicester|Leicestershire|Lewisham|Lincolnshire|Liverpool|Luton|Manchester|Medway|Merton|Middlesbrough|Milton Keynes|Newcastle upon Tyne|Newham|Norfolk|North East Lincolnshire|North Lincolnshire|North Somerset|North Tyneside|North Yorkshire|Northamptonshire|Northumberland|Nottingham|Nottinghamshire|Oldham|Oxfordshire|Peterborough|Plymouth|Poole|Portsmouth|Reading|Redbridge|Redcar and Cleveland|Richmond upon Thames|Rochdale|Rotherham|Rutland|Salford|Sandwell|Sefton|Sheffield|Shropshire|Slough|Solihull|Somerset|South Gloucestershire|South Tyneside|Southampton|Southend-on-Sea|Southwark|St. Helens|Staffordshire|Stockport|Stockton-on-Tees|Stoke-on-Trent|Suffolk|Sunderland|Surrey|Sutton|Swindon|Tameside|Telford and Wrekin|Thurrock|Torbay|Tower Hamlets|Trafford|Wakefield|Walsall|Waltham Forest|Wandsworth|Warrington|Warwickshire|West Berkshire|West Sussex|Westminster|Wigan|Wiltshire|Windsor and Maidenhead|Wirral|Wokingham|Wolverhampton|Worcestershire|York"; -aStates[238]="|Artigas|Canelones|Cerro Largo|Colonia|Durazno|Flores|Florida|Lavalleja|Maldonado|Montevideo|Paysandu|Rio Negro|Rivera|Rocha|Salto|San Jose|Soriano|Tacuarembo|Treinta y Tres"; -aStates[239]="|Alabama|Alaska|Arizona|Arkansas|California|Colorado|Connecticut|Delaware|District of Columbia|Florida|Georgia|Hawaii|Idaho|Illinois|Indiana|Iowa|Kansas|Kentucky|Louisiana|Maine|Maryland|Massachusetts|Michigan|Minnesota|Mississippi|Missouri|Montana|Nebraska|Nevada|New Hampshire|New Jersey|New Mexico|New York|North Carolina|North Dakota|Ohio|Oklahoma|Oregon|Pennsylvania|Rhode Island|South Carolina|South Dakota|Tennessee|Texas|Utah|Vermont|Virginia|Washington|West Virginia|Wisconsin|Wyoming"; -aStates[240]="|Andijon Wiloyati|Bukhoro Wiloyati|Farghona Wiloyati|Jizzakh Wiloyati|Khorazm Wiloyati (Urganch)|Namangan Wiloyati|Nawoiy Wiloyati|Qashqadaryo Wiloyati (Qarshi)|Qoraqalpoghiston (Nukus)|Samarqand Wiloyati|Sirdaryo Wiloyati (Guliston)|Surkhondaryo Wiloyati (Termiz)|Toshkent Shahri|Toshkent Wiloyati"; -aStates[241]="|Malampa|Penama|Sanma|Shefa|Tafea|Torba"; -aStates[242]="|Amazonas|Anzoategui|Apure|Aragua|Barinas|Bolivar|Carabobo|Cojedes|Delta Amacuro|Dependencias Federales|Distrito Federal|Falcon|Guarico|Lara|Merida|Miranda|Monagas|Nueva Esparta|Portuguesa|Sucre|Tachira|Trujillo|Vargas|Yaracuy|Zulia"; -aStates[243]="|An Giang|Ba Ria-Vung Tau|Bac Giang|Bac Kan|Bac Lieu|Bac Ninh|Ben Tre|Binh Dinh|Binh Duong|Binh Phuoc|Binh Thuan|Ca Mau|Can Tho|Cao Bang|Da Nang|Dac Lak|Dong Nai|Dong Thap|Gia Lai|Ha Giang|Ha Nam|Ha Noi|Ha Tay|Ha Tinh|Hai Duong|Hai Phong|Ho Chi Minh|Hoa Binh|Hung Yen|Khanh Hoa|Kien Giang|Kon Tum|Lai Chau|Lam Dong|Lang Son|Lao Cai|Long An|Nam Dinh|Nghe An|Ninh Binh|Ninh Thuan|Phu Tho|Phu Yen|Quang Binh|Quang Nam|Quang Ngai|Quang Ninh|Quang Tri|Soc Trang|Son La|Tay Ninh|Thai Binh|Thai Nguyen|Thanh Hoa|Thua Thien-Hue|Tien Giang|Tra Vinh|Tuyen Quang|Vinh Long|Vinh Phuc|Yen Bai"; -aStates[244]="|Saint Croix|Saint John|Saint Thomas"; -aStates[245]="|Blaenau Gwent|Bridgend|Caerphilly|Cardiff|Carmarthenshire|Ceredigion|Conwy|Denbighshire|Flintshire|Gwynedd|Isle of Anglesey|Merthyr Tydfil|Monmouthshire|Neath Port Talbot|Newport|Pembrokeshire|Powys|Rhondda Cynon Taff|Swansea|The Vale of Glamorgan|Torfaen|Wrexham"; -aStates[246]="|Alo|Sigave|Wallis"; -aStates[247]="|West Bank"; -aStates[248]="|Western Sahara"; -aStates[249]="|'Adan|'Ataq|Abyan|Al Bayda'|Al Hudaydah|Al Jawf|Al Mahrah|Al Mahwit|Dhamar|Hadhramawt|Hajjah|Ibb|Lahij|Ma'rib|Sa'dah|San'a'|Ta'izz"; -aStates[250]="|Kosovo|Montenegro|Serbia|Vojvodina"; -aStates[251]="|Central|Copperbelt|Eastern|Luapula|Lusaka|North-Western|Northern|Southern|Western"; -aStates[252]="|Bulawayo|Harare|ManicalandMashonaland Central|Mashonaland East|Mashonaland West|Masvingo|Matabeleland North|Matabeleland South|Midlands"; - -/* - * gArCountryInfo - * (0) Country name - * (1) Name length - * (2) Number of states - * (3) Max state length - */ -gLngNumberCountries = sCountryString.split("|").length; -//gArCountryInfo = new Array(gLngNumberCountries); -gArCountryInfo=sCountryString.split("|"); -/* - * gArStateInfo[country][statenames][namelengths] - * (0) Country - * (1) States (Multi-sized Array) - * (0) name - * (1) nameLength - */ -gArStateInfo = new Array(gLngNumberCountries); - -/* - * fInitgArStateInfo() - * purpose: build gArStateInfo array - * gArStateInfo[Country][States][1] - * (0) State name - * (1) State name length - * gArStateInfo[i] is an array of state names - * gArStateInfo[i][j]=state name, name length - */ -function fInitgArStateInfo() { - var i=0, j=0, sStateName="", iNumberOfStates=0; - var iMaxLength=0, iLength=0; - var oldNumber=0; - - for (i=0;iiMaxLength) { - iMaxLength=iLength; - gArStateInfo[i][j][0]=sStateName; - } - } - gArCountryInfo[i][3]=parseInt(iMaxLength); - } - Update_Globals(); - return; -} - -/* - * Working on this one. - * Fills in region from the arrays - * - */ -function xFillState() { - var i=0; - - // reset region - document.form1.region.options.length=0; - - // get selected country - gLngSelectedCountry=document.form1.country_name.selectedIndex; - - // get number of states for selected country - gLngNumberStates=gArCountryInfo[[gLngSelectedCountry][2]]; - - // update options in region - for (i=0;i +// +aStates[49]="|Anjouan (Nzwani)|Domoni|Fomboni|Grande Comore (Njazidja)|Moheli (Mwali)|Moroni|Moutsamoudou"; +aStates[50]="|Bandundu|Bas-Congo|Equateur|Kasai-Occidental|Kasai-Oriental|Katanga|Kinshasa|Maniema|Nord-Kivu|Orientale|Sud-Kivu"; +aStates[51]="|Bouenza|Brazzaville|Cuvette|Kouilou|Lekoumou|Likouala|Niari|Plateaux|Pool|Sangha"; +aStates[52]="|Aitutaki|Atiu|Avarua|Mangaia|Manihiki|Manuae|Mauke|Mitiaro|Nassau Island|Palmerston|Penrhyn|Pukapuka|Rakahanga|Rarotonga|Suwarrow|Takutea"; +aStates[53]="|Alajuela|Cartago|Guanacaste|Heredia|Limon|Puntarenas|San Jose"; +aStates[54]="|Abengourou|Abidjan|Aboisso|Adiake'|Adzope|Agboville|Agnibilekrou|Ale'pe'|Bangolo|Beoumi|Biankouma|Bocanda|Bondoukou|Bongouanou|Bouafle|Bouake|Bouna|Boundiali|Dabakala|Dabon|Daloa|Danane|Daoukro|Dimbokro|Divo|Duekoue|Ferkessedougou|Gagnoa|Grand Bassam|Grand-Lahou|Guiglo|Issia|Jacqueville|Katiola|Korhogo|Lakota|Man|Mankono|Mbahiakro|Odienne|Oume|Sakassou|San-Pedro|Sassandra|Seguela|Sinfra|Soubre|Tabou|Tanda|Tiassale|Tiebissou|Tingrela|Touba|Toulepleu|Toumodi|Vavoua|Yamoussoukro|Zuenoula"; +aStates[55]="|Bjelovarsko-Bilogorska Zupanija|Brodsko-Posavska Zupanija|Dubrovacko-Neretvanska Zupanija|Istarska Zupanija|Karlovacka Zupanija|Koprivnicko-Krizevacka Zupanija|Krapinsko-Zagorska Zupanija|Licko-Senjska Zupanija|Medimurska Zupanija|Osjecko-Baranjska Zupanija|Pozesko-Slavonska Zupanija|Primorsko-Goranska Zupanija|Sibensko-Kninska Zupanija|Sisacko-Moslavacka Zupanija|Splitsko-Dalmatinska Zupanija|Varazdinska Zupanija|Viroviticko-Podravska Zupanija|Vukovarsko-Srijemska Zupanija|Zadarska Zupanija|Zagreb|Zagrebacka Zupanija"; +aStates[56]="|Camaguey|Ciego de Avila|Cienfuegos|Ciudad de La Habana|Granma|Guantanamo|Holguin|Isla de la Juventud|La Habana|Las Tunas|Matanzas|Pinar del Rio|Sancti Spiritus|Santiago de Cuba|Villa Clara"; +aStates[57]="|Famagusta|Kyrenia|Larnaca|Limassol|Nicosia|Paphos"; +aStates[58]="|Brnensky|Budejovicky|Jihlavsky|Karlovarsky|Kralovehradecky|Liberecky|Olomoucky|Ostravsky|Pardubicky|Plzensky|Praha|Stredocesky|Ustecky|Zlinsky"; +aStates[59]="|Arhus|Bornholm|Fredericksberg|Frederiksborg|Fyn|Kobenhavn|Kobenhavns|Nordjylland|Ribe|Ringkobing|Roskilde|Sonderjylland|Storstrom|Vejle|Vestsjalland|Viborg"; +aStates[60]="|'Ali Sabih|Dikhil|Djibouti|Obock|Tadjoura"; +aStates[61]="|Saint Andrew|Saint David|Saint George|Saint John|Saint Joseph|Saint Luke|Saint Mark|Saint Patrick|Saint Paul|Saint Peter"; +aStates[62]="|Azua|Baoruco|Barahona|Dajabon|Distrito Nacional|Duarte|El Seibo|Elias Pina|Espaillat|Hato Mayor|Independencia|La Altagracia|La Romana|La Vega|Maria Trinidad Sanchez|Monsenor Nouel|Monte Cristi|Monte Plata|Pedernales|Peravia|Puerto Plata|Salcedo|Samana|San Cristobal|San Juan|San Pedro de Macoris|Sanchez Ramirez|Santiago|Santiago Rodriguez|Valverde"; +// +aStates[63]="|Azuay|Bolivar|Canar|Carchi|Chimborazo|Cotopaxi|El Oro|Esmeraldas|Galapagos|Guayas|Imbabura|Loja|Los Rios|Manabi|Morona-Santiago|Napo|Orellana|Pastaza|Pichincha|Sucumbios|Tungurahua|Zamora-Chinchipe"; +aStates[64]="|Ad Daqahliyah|Al Bahr al Ahmar|Al Buhayrah|Al Fayyum|Al Gharbiyah|Al Iskandariyah|Al Isma'iliyah|Al Jizah|Al Minufiyah|Al Minya|Al Qahirah|Al Qalyubiyah|Al Wadi al Jadid|As Suways|Ash Sharqiyah|Aswan|Asyut|Bani Suwayf|Bur Sa'id|Dumyat|Janub Sina'|Kafr ash Shaykh|Matruh|Qina|Shamal Sina'|Suhaj"; +aStates[65]="|Ahuachapan|Cabanas|Chalatenango|Cuscatlan|La Libertad|La Paz|La Union|Morazan|San Miguel|San Salvador|San Vicente|Santa Ana|Sonsonate|Usulutan"; +aStates[66]="|Annobon|Bioko Norte|Bioko Sur|Centro Sur|Kie-Ntem|Litoral|Wele-Nzas"; +aStates[67]="|Akale Guzay|Barka|Denkel|Hamasen|Sahil|Semhar|Senhit|Seraye"; +aStates[68]="|Harjumaa (Tallinn)|Hiiumaa (Kardla)|Ida-Virumaa (Johvi)|Jarvamaa (Paide)|Jogevamaa (Jogeva)|Laane-Virumaa (Rakvere)|Laanemaa (Haapsalu)|Parnumaa (Parnu)|Polvamaa (Polva)|Raplamaa (Rapla)|Saaremaa (Kuessaare)|Tartumaa (Tartu)|Valgamaa (Valga)|Viljandimaa (Viljandi)|Vorumaa (Voru)" +aStates[69]="|Adis Abeba (Addis Ababa)|Afar|Amara|Dire Dawa|Gambela Hizboch|Hareri Hizb|Oromiya|Sumale|Tigray|YeDebub Biheroch Bihereseboch na Hizboch"; +aStates[70]="|Europa Island"; +aStates[71]="|Falkland Islands (Islas Malvinas)" +aStates[72]="|Bordoy|Eysturoy|Mykines|Sandoy|Skuvoy|Streymoy|Suduroy|Tvoroyri|Vagar"; +aStates[73]="|Central|Eastern|Northern|Rotuma|Western"; +aStates[74]="|Aland|Etela-Suomen Laani|Ita-Suomen Laani|Lansi-Suomen Laani|Lappi|Oulun Laani"; +aStates[75]="|Alsace|Aquitaine|Auvergne|Basse-Normandie|Bourgogne|Bretagne|Centre|Champagne-Ardenne|Corse|Franche-Comte|Haute-Normandie|Ile-de-France|Languedoc-Roussillon|Limousin|Lorraine|Midi-Pyrenees|Nord-Pas-de-Calais|Pays de la Loire|Picardie|Poitou-Charentes|Provence-Alpes-Cote d'Azur|Rhone-Alpes"; +aStates[76]="|French Guiana"; +aStates[77]="|Archipel des Marquises|Archipel des Tuamotu|Archipel des Tubuai|Iles du Vent|Iles Sous-le-Vent"; +aStates[78]="|Adelie Land|Ile Crozet|Iles Kerguelen|Iles Saint-Paul et Amsterdam"; +aStates[79]="|Estuaire|Haut-Ogooue|Moyen-Ogooue|Ngounie|Nyanga|Ogooue-Ivindo|Ogooue-Lolo|Ogooue-Maritime|Woleu-Ntem"; +aStates[80]="|Banjul|Central River|Lower River|North Bank|Upper River|Western"; +aStates[81]="|Gaza Strip"; +aStates[82]="|Abashis|Abkhazia or Ap'khazet'is Avtonomiuri Respublika (Sokhumi)|Adigenis|Ajaria or Acharis Avtonomiuri Respublika (Bat'umi)|Akhalgoris|Akhalk'alak'is|Akhalts'ikhis|Akhmetis|Ambrolauris|Aspindzis|Baghdat'is|Bolnisis|Borjomis|Ch'khorotsqus|Ch'okhatauris|Chiat'ura|Dedop'listsqaros|Dmanisis|Dushet'is|Gardabanis|Gori|Goris|Gurjaanis|Javis|K'arelis|K'ut'aisi|Kaspis|Kharagaulis|Khashuris|Khobis|Khonis|Lagodekhis|Lanch'khut'is|Lentekhis|Marneulis|Martvilis|Mestiis|Mts'khet'is|Ninotsmindis|Onis|Ozurget'is|P'ot'i|Qazbegis|Qvarlis|Rust'avi|Sach'kheris|Sagarejos|Samtrediis|Senakis|Sighnaghis|T'bilisi|T'elavis|T'erjolis|T'et'ritsqaros|T'ianet'is|Tqibuli|Ts'ageris|Tsalenjikhis|Tsalkis|Tsqaltubo|Vanis|Zestap'onis|Zugdidi|Zugdidis"; +aStates[83]="|Baden-Wuerttemberg|Bayern|Berlin|Brandenburg|Bremen|Hamburg|Hessen|Mecklenburg-Vorpommern|Niedersachsen|Nordrhein-Westfalen|Rheinland-Pfalz|Saarland|Sachsen|Sachsen-Anhalt|Schleswig-Holstein|Thueringen"; +aStates[84]="|Ashanti|Brong-Ahafo|Central|Eastern|Greater Accra|Northern|Upper East|Upper West|Volta|Western"; +aStates[85]="|Gibraltar"; +aStates[86]="|Ile du Lys|Ile Glorieuse"; +aStates[87]="|Aitolia kai Akarnania|Akhaia|Argolis|Arkadhia|Arta|Attiki|Ayion Oros (Mt. Athos)|Dhodhekanisos|Drama|Evritania|Evros|Evvoia|Florina|Fokis|Fthiotis|Grevena|Ilia|Imathia|Ioannina|Irakleion|Kardhitsa|Kastoria|Kavala|Kefallinia|Kerkyra|Khalkidhiki|Khania|Khios|Kikladhes|Kilkis|Korinthia|Kozani|Lakonia|Larisa|Lasithi|Lesvos|Levkas|Magnisia|Messinia|Pella|Pieria|Preveza|Rethimni|Rodhopi|Samos|Serrai|Thesprotia|Thessaloniki|Trikala|Voiotia|Xanthi|Zakinthos"; +aStates[88]="|Avannaa (Nordgronland)|Kitaa (Vestgronland)|Tunu (Ostgronland)" +aStates[89]="|Carriacou and Petit Martinique|Saint Andrew|Saint David|Saint George|Saint John|Saint Mark|Saint Patrick"; +aStates[90]="|Basse-Terre|Grande-Terre|Iles de la Petite Terre|Iles des Saintes|Marie-Galante"; +aStates[91]="|Guam"; +aStates[92]="|Alta Verapaz|Baja Verapaz|Chimaltenango|Chiquimula|El Progreso|Escuintla|Guatemala|Huehuetenango|Izabal|Jalapa|Jutiapa|Peten|Quetzaltenango|Quiche|Retalhuleu|Sacatepequez|San Marcos|Santa Rosa|Solola|Suchitepequez|Totonicapan|Zacapa"; +aStates[93]="|Castel|Forest|St. Andrew|St. Martin|St. Peter Port|St. Pierre du Bois|St. Sampson|St. Saviour|Torteval|Vale"; +aStates[94]="|Beyla|Boffa|Boke|Conakry|Coyah|Dabola|Dalaba|Dinguiraye|Dubreka|Faranah|Forecariah|Fria|Gaoual|Gueckedou|Kankan|Kerouane|Kindia|Kissidougou|Koubia|Koundara|Kouroussa|Labe|Lelouma|Lola|Macenta|Mali|Mamou|Mandiana|Nzerekore|Pita|Siguiri|Telimele|Tougue|Yomou"; +aStates[95]="|Bafata|Biombo|Bissau|Bolama-Bijagos|Cacheu|Gabu|Oio|Quinara|Tombali"; +aStates[96]="|Barima-Waini|Cuyuni-Mazaruni|Demerara-Mahaica|East Berbice-Corentyne|Essequibo Islands-West Demerara|Mahaica-Berbice|Pomeroon-Supenaam|Potaro-Siparuni|Upper Demerara-Berbice|Upper Takutu-Upper Essequibo"; +aStates[97]="|Artibonite|Centre|Grand'Anse|Nord|Nord-Est|Nord-Ouest|Ouest|Sud|Sud-Est"; +aStates[98]="|Heard Island and McDonald Islands"; +aStates[99]="|Holy See (Vatican City)" +aStates[100]="|Atlantida|Choluteca|Colon|Comayagua|Copan|Cortes|El Paraiso|Francisco Morazan|Gracias a Dios|Intibuca|Islas de la Bahia|La Paz|Lempira|Ocotepeque|Olancho|Santa Barbara|Valle|Yoro"; +aStates[101]="|Hong Kong"; +aStates[102]="|Howland Island"; +aStates[103]="|Bacs-Kiskun|Baranya|Bekes|Bekescsaba|Borsod-Abauj-Zemplen|Budapest|Csongrad|Debrecen|Dunaujvaros|Eger|Fejer|Gyor|Gyor-Moson-Sopron|Hajdu-Bihar|Heves|Hodmezovasarhely|Jasz-Nagykun-Szolnok|Kaposvar|Kecskemet|Komarom-Esztergom|Miskolc|Nagykanizsa|Nograd|Nyiregyhaza|Pecs|Pest|Somogy|Sopron|Szabolcs-Szatmar-Bereg|Szeged|Szekesfehervar|Szolnok|Szombathely|Tatabanya|Tolna|Vas|Veszprem|Veszprem|Zala|Zalaegerszeg"; +aStates[104]="|Akranes|Akureyri|Arnessysla|Austur-Bardhastrandarsysla|Austur-Hunavatnssysla|Austur-Skaftafellssysla|Borgarfjardharsysla|Dalasysla|Eyjafjardharsysla|Gullbringusysla|Hafnarfjordhur|Husavik|Isafjordhur|Keflavik|Kjosarsysla|Kopavogur|Myrasysla|Neskaupstadhur|Nordhur-Isafjardharsysla|Nordhur-Mulasys-la|Nordhur-Thingeyjarsysla|Olafsfjordhur|Rangarvallasysla|Reykjavik|Saudharkrokur|Seydhisfjordhur|Siglufjordhur|Skagafjardharsysla|Snaefellsnes-og Hnappadalssysla|Strandasysla|Sudhur-Mulasysla|Sudhur-Thingeyjarsysla|Vesttmannaeyjar|Vestur-Bardhastrandarsysla|Vestur-Hunavatnssysla|Vestur-Isafjardharsysla|Vestur-Skaftafellssysla"; +aStates[105]="|Andaman and Nicobar Islands|Andhra Pradesh|Arunachal Pradesh|Assam|Bihar|Chandigarh|Chhattisgarh|Dadra and Nagar Haveli|Daman and Diu|Delhi|Goa|Gujarat|Haryana|Himachal Pradesh|Jammu and Kashmir|Jharkhand|Karnataka|Kerala|Lakshadweep|Madhya Pradesh|Maharashtra|Manipur|Meghalaya|Mizoram|Nagaland|Orissa|Pondicherry|Punjab|Rajasthan|Sikkim|Tamil Nadu|Tripura|Uttar Pradesh|Uttaranchal|West Bengal"; +aStates[106]="|Aceh|Bali|Banten|Bengkulu|East Timor|Gorontalo|Irian Jaya|Jakarta Raya|Jambi|Jawa Barat|Jawa Tengah|Jawa Timur|Kalimantan Barat|Kalimantan Selatan|Kalimantan Tengah|Kalimantan Timur|Kepulauan Bangka Belitung|Lampung|Maluku|Maluku Utara|Nusa Tenggara Barat|Nusa Tenggara Timur|Riau|Sulawesi Selatan|Sulawesi Tengah|Sulawesi Tenggara|Sulawesi Utara|Sumatera Barat|Sumatera Selatan|Sumatera Utara|Yogyakarta"; +aStates[107]="|Ardabil|Azarbayjan-e Gharbi|Azarbayjan-e Sharqi|Bushehr|Chahar Mahall va Bakhtiari|Esfahan|Fars|Gilan|Golestan|Hamadan|Hormozgan|Ilam|Kerman|Kermanshah|Khorasan|Khuzestan|Kohgiluyeh va Buyer Ahmad|Kordestan|Lorestan|Markazi|Mazandaran|Qazvin|Qom|Semnan|Sistan va Baluchestan|Tehran|Yazd|Zanjan"; +aStates[108]="|Al Anbar|Al Basrah|Al Muthanna|Al Qadisiyah|An Najaf|Arbil|As Sulaymaniyah|At Ta'mim|Babil|Baghdad|Dahuk|Dhi Qar|Diyala|Karbala'|Maysan|Ninawa|Salah ad Din|Wasit"; +aStates[109]="|Carlow|Cavan|Clare|Cork|Donegal|Dublin|Galway|Kerry|Kildare|Kilkenny|Laois|Leitrim|Limerick|Longford|Louth|Mayo|Meath|Monaghan|Offaly|Roscommon|Sligo|Tipperary|Waterford|Westmeath|Wexford|Wicklow"; +aStates[110]="|Antrim|Ards|Armagh|Ballymena|Ballymoney|Banbridge|Belfast|Carrickfergus|Castlereagh|Coleraine|Cookstown|Craigavon|Derry|Down|Dungannon|Fermanagh|Larne|Limavady|Lisburn|Magherafelt|Moyle|Newry and Mourne|Newtownabbey|North Down|Omagh|Strabane"; +aStates[111]="|Central|Haifa|Jerusalem|Northern|Southern|Tel Aviv"; +aStates[112]="|Abruzzi|Basilicata|Calabria|Campania|Emilia-Romagna|Friuli-Venezia Giulia|Lazio|Liguria|Lombardia|Marche|Molise|Piemonte|Puglia|Sardegna|Sicilia|Toscana|Trentino-Alto Adige|Umbria|Valle d'Aosta|Veneto"; +aStates[113]="|Clarendon|Hanover|Kingston|Manchester|Portland|Saint Andrew|Saint Ann|Saint Catherine|Saint Elizabeth|Saint James|Saint Mary|Saint Thomas|Trelawny|Westmoreland"; +aStates[114]="|Jan Mayen"; +aStates[115]="|Aichi|Akita|Aomori|Chiba|Ehime|Fukui|Fukuoka|Fukushima|Gifu|Gumma|Hiroshima|Hokkaido|Hyogo|Ibaraki|Ishikawa|Iwate|Kagawa|Kagoshima|Kanagawa|Kochi|Kumamoto|Kyoto|Mie|Miyagi|Miyazaki|Nagano|Nagasaki|Nara|Niigata|Oita|Okayama|Okinawa|Osaka|Saga|Saitama|Shiga|Shimane|Shizuoka|Tochigi|Tokushima|Tokyo|Tottori|Toyama|Wakayama|Yamagata|Yamaguchi|Yamanashi"; +aStates[116]="|Jarvis Island"; +aStates[117]="|Jersey"; +aStates[118]="|Johnston Atoll"; +aStates[119]="|'Amman|Ajlun|Al 'Aqabah|Al Balqa'|Al Karak|Al Mafraq|At Tafilah|Az Zarqa'|Irbid|Jarash|Ma'an|Madaba"; +aStates[120]="|Juan de Nova Island"; +aStates[121]="|Almaty|Aqmola|Aqtobe|Astana|Atyrau|Batys Qazaqstan|Bayqongyr|Mangghystau|Ongtustik Qazaqstan|Pavlodar|Qaraghandy|Qostanay|Qyzylorda|Shyghys Qazaqstan|Soltustik Qazaqstan|Zhambyl"; +aStates[122]="|Central|Coast|Eastern|Nairobi Area|North Eastern|Nyanza|Rift Valley|Western"; +aStates[123]="|Abaiang|Abemama|Aranuka|Arorae|Banaba|Banaba|Beru|Butaritari|Central Gilberts|Gilbert Islands|Kanton|Kiritimati|Kuria|Line Islands|Line Islands|Maiana|Makin|Marakei|Nikunau|Nonouti|Northern Gilberts|Onotoa|Phoenix Islands|Southern Gilberts|Tabiteuea|Tabuaeran|Tamana|Tarawa|Tarawa|Teraina"; +aStates[124]="|Chagang-do (Chagang Province)|Hamgyong-bukto (North Hamgyong Province)|Hamgyong-namdo (South Hamgyong Province)|Hwanghae-bukto (North Hwanghae Province)|Hwanghae-namdo (South Hwanghae Province)|Kaesong-si (Kaesong City)|Kangwon-do (Kangwon Province)|Namp'o-si (Namp'o City)|P'yongan-bukto (North P'yongan Province)|P'yongan-namdo (South P'yongan Province)|P'yongyang-si (P'yongyang City)|Yanggang-do (Yanggang Province)" +aStates[125]="|Ch'ungch'ong-bukto|Ch'ungch'ong-namdo|Cheju-do|Cholla-bukto|Cholla-namdo|Inch'on-gwangyoksi|Kangwon-do|Kwangju-gwangyoksi|Kyonggi-do|Kyongsang-bukto|Kyongsang-namdo|Pusan-gwangyoksi|Soul-t'ukpyolsi|Taegu-gwangyoksi|Taejon-gwangyoksi|Ulsan-gwangyoksi"; +aStates[126]="|Al 'Asimah|Al Ahmadi|Al Farwaniyah|Al Jahra'|Hawalli"; +aStates[127]="|Batken Oblasty|Bishkek Shaary|Chuy Oblasty (Bishkek)|Jalal-Abad Oblasty|Naryn Oblasty|Osh Oblasty|Talas Oblasty|Ysyk-Kol Oblasty (Karakol)" +aStates[128]="|Attapu|Bokeo|Bolikhamxai|Champasak|Houaphan|Khammouan|Louangnamtha|Louangphabang|Oudomxai|Phongsali|Salavan|Savannakhet|Viangchan|Viangchan|Xaignabouli|Xaisomboun|Xekong|Xiangkhoang"; +aStates[129]="|Aizkraukles Rajons|Aluksnes Rajons|Balvu Rajons|Bauskas Rajons|Cesu Rajons|Daugavpils|Daugavpils Rajons|Dobeles Rajons|Gulbenes Rajons|Jekabpils Rajons|Jelgava|Jelgavas Rajons|Jurmala|Kraslavas Rajons|Kuldigas Rajons|Leipaja|Liepajas Rajons|Limbazu Rajons|Ludzas Rajons|Madonas Rajons|Ogres Rajons|Preilu Rajons|Rezekne|Rezeknes Rajons|Riga|Rigas Rajons|Saldus Rajons|Talsu Rajons|Tukuma Rajons|Valkas Rajons|Valmieras Rajons|Ventspils|Ventspils Rajons"; +aStates[130]="|Beyrouth|Ech Chimal|Ej Jnoub|El Bekaa|Jabal Loubnane"; +aStates[131]="|Berea|Butha-Buthe|Leribe|Mafeteng|Maseru|Mohales Hoek|Mokhotlong|Qacha's Nek|Quthing|Thaba-Tseka"; +aStates[132]="|Bomi|Bong|Grand Bassa|Grand Cape Mount|Grand Gedeh|Grand Kru|Lofa|Margibi|Maryland|Montserrado|Nimba|River Cess|Sinoe"; +aStates[133]="|Ajdabiya|Al 'Aziziyah|Al Fatih|Al Jabal al Akhdar|Al Jufrah|Al Khums|Al Kufrah|An Nuqat al Khams|Ash Shati'|Awbari|Az Zawiyah|Banghazi|Darnah|Ghadamis|Gharyan|Misratah|Murzuq|Sabha|Sawfajjin|Surt|Tarabulus|Tarhunah|Tubruq|Yafran|Zlitan"; +aStates[134]="|Balzers|Eschen|Gamprin|Mauren|Planken|Ruggell|Schaan|Schellenberg|Triesen|Triesenberg|Vaduz"; +aStates[135]="|Akmenes Rajonas|Alytaus Rajonas|Alytus|Anyksciu Rajonas|Birstonas|Birzu Rajonas|Druskininkai|Ignalinos Rajonas|Jonavos Rajonas|Joniskio Rajonas|Jurbarko Rajonas|Kaisiadoriu Rajonas|Kaunas|Kauno Rajonas|Kedainiu Rajonas|Kelmes Rajonas|Klaipeda|Klaipedos Rajonas|Kretingos Rajonas|Kupiskio Rajonas|Lazdiju Rajonas|Marijampole|Marijampoles Rajonas|Mazeikiu Rajonas|Moletu Rajonas|Neringa Pakruojo Rajonas|Palanga|Panevezio Rajonas|Panevezys|Pasvalio Rajonas|Plunges Rajonas|Prienu Rajonas|Radviliskio Rajonas|Raseiniu Rajonas|Rokiskio Rajonas|Sakiu Rajonas|Salcininku Rajonas|Siauliai|Siauliu Rajonas|Silales Rajonas|Silutes Rajonas|Sirvintu Rajonas|Skuodo Rajonas|Svencioniu Rajonas|Taurages Rajonas|Telsiu Rajonas|Traku Rajonas|Ukmerges Rajonas|Utenos Rajonas|Varenos Rajonas|Vilkaviskio Rajonas|Vilniaus Rajonas|Vilnius|Zarasu Rajonas"; +aStates[136]="|Diekirch|Grevenmacher|Luxembourg"; +aStates[137]="|Macau"; +aStates[138]="|Aracinovo|Bac|Belcista|Berovo|Bistrica|Bitola|Blatec|Bogdanci|Bogomila|Bogovinje|Bosilovo|Brvenica|Cair (Skopje)|Capari|Caska|Cegrane|Centar (Skopje)|Centar Zupa|Cesinovo|Cucer-Sandevo|Debar|Delcevo|Delogozdi|Demir Hisar|Demir Kapija|Dobrusevo|Dolna Banjica|Dolneni|Dorce Petrov (Skopje)|Drugovo|Dzepciste|Gazi Baba (Skopje)|Gevgelija|Gostivar|Gradsko|Ilinden|Izvor|Jegunovce|Kamenjane|Karbinci|Karpos (Skopje)|Kavadarci|Kicevo|Kisela Voda (Skopje)|Klecevce|Kocani|Konce|Kondovo|Konopiste|Kosel|Kratovo|Kriva Palanka|Krivogastani|Krusevo|Kuklis|Kukurecani|Kumanovo|Labunista|Lipkovo|Lozovo|Lukovo|Makedonska Kamenica|Makedonski Brod|Mavrovi Anovi|Meseista|Miravci|Mogila|Murtino|Negotino|Negotino-Poloska|Novaci|Novo Selo|Oblesevo|Ohrid|Orasac|Orizari|Oslomej|Pehcevo|Petrovec|Plasnia|Podares|Prilep|Probistip|Radovis|Rankovce|Resen|Rosoman|Rostusa|Samokov|Saraj|Sipkovica|Sopiste|Sopotnika|Srbinovo|Star Dojran|Staravina|Staro Nagoricane|Stip|Struga|Strumica|Studenicani|Suto Orizari (Skopje)|Sveti Nikole|Tearce|Tetovo|Topolcani|Valandovo|Vasilevo|Veles|Velesta|Vevcani|Vinica|Vitoliste|Vranestica|Vrapciste|Vratnica|Vrutok|Zajas|Zelenikovo|Zileno|Zitose|Zletovo|Zrnovci"; +aStates[139]="|Antananarivo|Antsiranana|Fianarantsoa|Mahajanga|Toamasina|Toliara"; +aStates[140]="|Balaka|Blantyre|Chikwawa|Chiradzulu|Chitipa|Dedza|Dowa|Karonga|Kasungu|Likoma|Lilongwe|Machinga (Kasupe)|Mangochi|Mchinji|Mulanje|Mwanza|Mzimba|Nkhata Bay|Nkhotakota|Nsanje|Ntcheu|Ntchisi|Phalombe|Rumphi|Salima|Thyolo|Zomba"; +aStates[141]="|Johor|Kedah|Kelantan|Labuan|Melaka|Negeri Sembilan|Pahang|Perak|Perlis|Pulau Pinang|Sabah|Sarawak|Selangor|Terengganu|Wilayah Persekutuan"; +aStates[142]="|Alifu|Baa|Dhaalu|Faafu|Gaafu Alifu|Gaafu Dhaalu|Gnaviyani|Haa Alifu|Haa Dhaalu|Kaafu|Laamu|Lhaviyani|Maale|Meemu|Noonu|Raa|Seenu|Shaviyani|Thaa|Vaavu"; +aStates[143]="|Gao|Kayes|Kidal|Koulikoro|Mopti|Segou|Sikasso|Tombouctou"; +aStates[144]="|Valletta"; +aStates[145]="|Man, Isle of"; +aStates[146]="|Ailinginae|Ailinglaplap|Ailuk|Arno|Aur|Bikar|Bikini|Bokak|Ebon|Enewetak|Erikub|Jabat|Jaluit|Jemo|Kili|Kwajalein|Lae|Lib|Likiep|Majuro|Maloelap|Mejit|Mili|Namorik|Namu|Rongelap|Rongrik|Toke|Ujae|Ujelang|Utirik|Wotho|Wotje"; +aStates[147]="|Martinique"; +aStates[148]="|Adrar|Assaba|Brakna|Dakhlet Nouadhibou|Gorgol|Guidimaka|Hodh Ech Chargui|Hodh El Gharbi|Inchiri|Nouakchott|Tagant|Tiris Zemmour|Trarza"; +aStates[149]="|Agalega Islands|Black River|Cargados Carajos Shoals|Flacq|Grand Port|Moka|Pamplemousses|Plaines Wilhems|Port Louis|Riviere du Rempart|Rodrigues|Savanne"; +aStates[150]="|Mayotte"; +aStates[151]="|Aguascalientes|Baja California|Baja California Sur|Campeche|Chiapas|Chihuahua|Coahuila de Zaragoza|Colima|Distrito Federal|Durango|Guanajuato|Guerrero|Hidalgo|Jalisco|Mexico|Michoacan de Ocampo|Morelos|Nayarit|Nuevo Leon|Oaxaca|Puebla|Queretaro de Arteaga|Quintana Roo|San Luis Potosi|Sinaloa|Sonora|Tabasco|Tamaulipas|Tlaxcala|Veracruz-Llave|Yucatan|Zacatecas"; +aStates[152]="|Chuuk (Truk)|Kosrae|Pohnpei|Yap"; +aStates[153]="|Midway Islands"; +aStates[154]="|Balti|Cahul|Chisinau|Chisinau|Dubasari|Edinet|Gagauzia|Lapusna|Orhei|Soroca|Tighina|Ungheni"; +aStates[155]="|Fontvieille|La Condamine|Monaco-Ville|Monte-Carlo"; +aStates[156]="|Arhangay|Bayan-Olgiy|Bayanhongor|Bulgan|Darhan|Dornod|Dornogovi|Dundgovi|Dzavhan|Erdenet|Govi-Altay|Hentiy|Hovd|Hovsgol|Omnogovi|Ovorhangay|Selenge|Suhbaatar|Tov|Ulaanbaatar|Uvs"; +aStates[157]="|Saint Anthony|Saint Georges|Saint Peter's"; +aStates[158]="|Agadir|Al Hoceima|Azilal|Ben Slimane|Beni Mellal|Boulemane|Casablanca|Chaouen|El Jadida|El Kelaa des Srarhna|Er Rachidia|Essaouira|Fes|Figuig|Guelmim|Ifrane|Kenitra|Khemisset|Khenifra|Khouribga|Laayoune|Larache|Marrakech|Meknes|Nador|Ouarzazate|Oujda|Rabat-Sale|Safi|Settat|Sidi Kacem|Tan-Tan|Tanger|Taounate|Taroudannt|Tata|Taza|Tetouan|Tiznit"; +aStates[159]="|Cabo Delgado|Gaza|Inhambane|Manica|Maputo|Nampula|Niassa|Sofala|Tete|Zambezia"; +aStates[160]="|Caprivi|Erongo|Hardap|Karas|Khomas|Kunene|Ohangwena|Okavango|Omaheke|Omusati|Oshana|Oshikoto|Otjozondjupa"; +aStates[161]="|Aiwo|Anabar|Anetan|Anibare|Baiti|Boe|Buada|Denigomodu|Ewa|Ijuw|Meneng|Nibok|Uaboe|Yaren"; +aStates[162]="|Bagmati|Bheri|Dhawalagiri|Gandaki|Janakpur|Karnali|Kosi|Lumbini|Mahakali|Mechi|Narayani|Rapti|Sagarmatha|Seti"; +aStates[163]="|Drenthe|Flevoland|Friesland|Gelderland|Groningen|Limburg|Noord-Brabant|Noord-Holland|Overijssel|Utrecht|Zeeland|Zuid-Holland"; +aStates[164]="|Netherlands Antilles"; +aStates[165]="|Iles Loyaute|Nord|Sud"; +aStates[166]="|Akaroa|Amuri|Ashburton|Bay of Islands|Bruce|Buller|Chatham Islands|Cheviot|Clifton|Clutha|Cook|Dannevirke|Egmont|Eketahuna|Ellesmere|Eltham|Eyre|Featherston|Franklin|Golden Bay|Great Barrier Island|Grey|Hauraki Plains|Hawera|Hawke's Bay|Heathcote|Hikurangi|Hobson|Hokianga|Horowhenua|Hurunui|Hutt|Inangahua|Inglewood|Kaikoura|Kairanga|Kiwitea|Lake|Mackenzie|Malvern|Manaia|Manawatu|Mangonui|Maniototo|Marlborough|Masterton|Matamata|Mount Herbert|Ohinemuri|Opotiki|Oroua|Otamatea|Otorohanga|Oxford|Pahiatua|Paparua|Patea|Piako|Pohangina|Raglan|Rangiora|Rangitikei|Rodney|Rotorua|Runanga|Saint Kilda|Silverpeaks|Southland|Stewart Island|Stratford|Strathallan|Taranaki|Taumarunui|Taupo|Tauranga|Thames-Coromandel|Tuapeka|Vincent|Waiapu|Waiheke|Waihemo|Waikato|Waikohu|Waimairi|Waimarino|Waimate|Waimate West|Waimea|Waipa|Waipawa|Waipukurau|Wairarapa South|Wairewa|Wairoa|Waitaki|Waitomo|Waitotara|Wallace|Wanganui|Waverley|Westland|Whakatane|Whangarei|Whangaroa|Woodville"; +aStates[167]="|Atlantico Norte|Atlantico Sur|Boaco|Carazo|Chinandega|Chontales|Esteli|Granada|Jinotega|Leon|Madriz|Managua|Masaya|Matagalpa|Nueva Segovia|Rio San Juan|Rivas"; +aStates[168]="|Agadez|Diffa|Dosso|Maradi|Niamey|Tahoua|Tillaberi|Zinder"; +aStates[169]="|Abia|Abuja Federal Capital Territory|Adamawa|Akwa Ibom|Anambra|Bauchi|Bayelsa|Benue|Borno|Cross River|Delta|Ebonyi|Edo|Ekiti|Enugu|Gombe|Imo|Jigawa|Kaduna|Kano|Katsina|Kebbi|Kogi|Kwara|Lagos|Nassarawa|Niger|Ogun|Ondo|Osun|Oyo|Plateau|Rivers|Sokoto|Taraba|Yobe|Zamfara"; +aStates[170]="|Niue"; +aStates[171]="|Norfolk Island"; +aStates[172]="|Northern Islands|Rota|Saipan|Tinian"; +aStates[173]="|Akershus|Aust-Agder|Buskerud|Finnmark|Hedmark|Hordaland|More og Romsdal|Nord-Trondelag|Nordland|Oppland|Oslo|Ostfold|Rogaland|Sogn og Fjordane|Sor-Trondelag|Telemark|Troms|Vest-Agder|Vestfold"; +aStates[174]="|Ad Dakhiliyah|Al Batinah|Al Wusta|Ash Sharqiyah|Az Zahirah|Masqat|Musandam|Zufar"; +aStates[175]="|Balochistan|Federally Administered Tribal Areas|Islamabad Capital Territory|North-West Frontier Province|Punjab|Sindh"; +aStates[176]="|Aimeliik|Airai|Angaur|Hatobohei|Kayangel|Koror|Melekeok|Ngaraard|Ngarchelong|Ngardmau|Ngatpang|Ngchesar|Ngeremlengui|Ngiwal|Palau Island|Peleliu|Sonsoral|Tobi"; +aStates[177]="|Bocas del Toro|Chiriqui|Cocle|Colon|Darien|Herrera|Los Santos|Panama|San Blas|Veraguas"; +aStates[178]="|Bougainville|Central|Chimbu|East New Britain|East Sepik|Eastern Highlands|Enga|Gulf|Madang|Manus|Milne Bay|Morobe|National Capital|New Ireland|Northern|Sandaun|Southern Highlands|West New Britain|Western|Western Highlands"; +aStates[179]="|Alto Paraguay|Alto Parana|Amambay|Asuncion (city)|Boqueron|Caaguazu|Caazapa|Canindeyu|Central|Concepcion|Cordillera|Guaira|Itapua|Misiones|Neembucu|Paraguari|Presidente Hayes|San Pedro"; +aStates[180]="|Amazonas|Ancash|Apurimac|Arequipa|Ayacucho|Cajamarca|Callao|Cusco|Huancavelica|Huanuco|Ica|Junin|La Libertad|Lambayeque|Lima|Loreto|Madre de Dios|Moquegua|Pasco|Piura|Puno|San Martin|Tacna|Tumbes|Ucayali"; +aStates[181]="|Abra|Agusan del Norte|Agusan del Sur|Aklan|Albay|Angeles|Antique|Aurora|Bacolod|Bago|Baguio|Bais|Basilan|Basilan City|Bataan|Batanes|Batangas|Batangas City|Benguet|Bohol|Bukidnon|Bulacan|Butuan|Cabanatuan|Cadiz|Cagayan|Cagayan de Oro|Calbayog|Caloocan|Camarines Norte|Camarines Sur|Camiguin|Canlaon|Capiz|Catanduanes|Cavite|Cavite City|Cebu|Cebu City|Cotabato|Dagupan|Danao|Dapitan|Davao City Davao|Davao del Sur|Davao Oriental|Dipolog|Dumaguete|Eastern Samar|General Santos|Gingoog|Ifugao|Iligan|Ilocos Norte|Ilocos Sur|Iloilo|Iloilo City|Iriga|Isabela|Kalinga-Apayao|La Carlota|La Union|Laguna|Lanao del Norte|Lanao del Sur|Laoag|Lapu-Lapu|Legaspi|Leyte|Lipa|Lucena|Maguindanao|Mandaue|Manila|Marawi|Marinduque|Masbate|Mindoro Occidental|Mindoro Oriental|Misamis Occidental|Misamis Oriental|Mountain|Naga|Negros Occidental|Negros Oriental|North Cotabato|Northern Samar|Nueva Ecija|Nueva Vizcaya|Olongapo|Ormoc|Oroquieta|Ozamis|Pagadian|Palawan|Palayan|Pampanga|Pangasinan|Pasay|Puerto Princesa|Quezon|Quezon City|Quirino|Rizal|Romblon|Roxas|Samar|San Carlos (in Negros Occidental)|San Carlos (in Pangasinan)|San Jose|San Pablo|Silay|Siquijor|Sorsogon|South Cotabato|Southern Leyte|Sultan Kudarat|Sulu|Surigao|Surigao del Norte|Surigao del Sur|Tacloban|Tagaytay|Tagbilaran|Tangub|Tarlac|Tawitawi|Toledo|Trece Martires|Zambales|Zamboanga|Zamboanga del Norte|Zamboanga del Sur"; +aStates[182]="|Pitcaim Islands"; +aStates[183]="|Dolnoslaskie|Kujawsko-Pomorskie|Lodzkie|Lubelskie|Lubuskie|Malopolskie|Mazowieckie|Opolskie|Podkarpackie|Podlaskie|Pomorskie|Slaskie|Swietokrzyskie|Warminsko-Mazurskie|Wielkopolskie|Zachodniopomorskie"; +aStates[184]="|Acores (Azores)|Aveiro|Beja|Braga|Braganca|Castelo Branco|Coimbra|Evora|Faro|Guarda|Leiria|Lisboa|Madeira|Portalegre|Porto|Santarem|Setubal|Viana do Castelo|Vila Real|Viseu"; +aStates[185]="|Adjuntas|Aguada|Aguadilla|Aguas Buenas|Aibonito|Anasco|Arecibo|Arroyo|Barceloneta|Barranquitas|Bayamon|Cabo Rojo|Caguas|Camuy|Canovanas|Carolina|Catano|Cayey|Ceiba|Ciales|Cidra|Coamo|Comerio|Corozal|Culebra|Dorado|Fajardo|Florida|Guanica|Guayama|Guayanilla|Guaynabo|Gurabo|Hatillo|Hormigueros|Humacao|Isabela|Jayuya|Juana Diaz|Juncos|Lajas|Lares|Las Marias|Las Piedras|Loiza|Luquillo|Manati|Maricao|Maunabo|Mayaguez|Moca|Morovis|Naguabo|Naranjito|Orocovis|Patillas|Penuelas|Ponce|Quebradillas|Rincon|Rio Grande|Sabana Grande|Salinas|San German|San Juan|San Lorenzo|San Sebastian|Santa Isabel|Toa Alta|Toa Baja|Trujillo Alto|Utuado|Vega Alta|Vega Baja|Vieques|Villalba|Yabucoa|Yauco"; +aStates[186]="|Ad Dawhah|Al Ghuwayriyah|Al Jumayliyah|Al Khawr|Al Wakrah|Ar Rayyan|Jarayan al Batinah|Madinat ash Shamal|Umm Salal"; +aStates[187]="|Reunion"; +aStates[188]="|Alba|Arad|Arges|Bacau|Bihor|Bistrita-Nasaud|Botosani|Braila|Brasov|Bucuresti|Buzau|Calarasi|Caras-Severin|Cluj|Constanta|Covasna|Dimbovita|Dolj|Galati|Giurgiu|Gorj|Harghita|Hunedoara|Ialomita|Iasi|Maramures|Mehedinti|Mures|Neamt|Olt|Prahova|Salaj|Satu Mare|Sibiu|Suceava|Teleorman|Timis|Tulcea|Vaslui|Vilcea|Vrancea"; +aStates[189]="|Adygeya (Maykop)|Aginskiy Buryatskiy (Aginskoye)|Altay (Gorno-Altaysk)|Altayskiy (Barnaul)|Amurskaya (Blagoveshchensk)|Arkhangel'skaya|Astrakhanskaya|Bashkortostan (Ufa)|Belgorodskaya|Bryanskaya|Buryatiya (Ulan-Ude)|Chechnya (Groznyy)|Chelyabinskaya|Chitinskaya|Chukotskiy (Anadyr')|Chuvashiya (Cheboksary)|Dagestan (Makhachkala)|Evenkiyskiy (Tura)|Ingushetiya (Nazran')|Irkutskaya|Ivanovskaya|Kabardino-Balkariya (Nal'chik)|Kaliningradskaya|Kalmykiya (Elista)|Kaluzhskaya|Kamchatskaya (Petropavlovsk-Kamchatskiy)|Karachayevo-Cherkesiya (Cherkessk)|Kareliya (Petrozavodsk)|Kemerovskaya|Khabarovskiy|Khakasiya (Abakan)|Khanty-Mansiyskiy (Khanty-Mansiysk)|Kirovskaya|Komi (Syktyvkar)|Komi-Permyatskiy (Kudymkar)|Koryakskiy (Palana)|Kostromskaya|Krasnodarskiy|Krasnoyarskiy|Kurganskaya|Kurskaya|Leningradskaya|Lipetskaya|Magadanskaya|Mariy-El (Yoshkar-Ola)|Mordoviya (Saransk)|Moskovskaya|Moskva (Moscow)|Murmanskaya|Nenetskiy (Nar'yan-Mar)|Nizhegorodskaya|Novgorodskaya|Novosibirskaya|Omskaya|Orenburgskaya|Orlovskaya (Orel)|Penzenskaya|Permskaya|Primorskiy (Vladivostok)|Pskovskaya|Rostovskaya|Ryazanskaya|Sakha (Yakutsk)|Sakhalinskaya (Yuzhno-Sakhalinsk)|Samarskaya|Sankt-Peterburg (Saint Petersburg)|Saratovskaya|Severnaya Osetiya-Alaniya [North Ossetia] (Vladikavkaz)|Smolenskaya|Stavropol'skiy|Sverdlovskaya (Yekaterinburg)|Tambovskaya|Tatarstan (Kazan')|Taymyrskiy (Dudinka)|Tomskaya|Tul'skaya|Tverskaya|Tyumenskaya|Tyva (Kyzyl)|Udmurtiya (Izhevsk)|Ul'yanovskaya|Ust'-Ordynskiy Buryatskiy (Ust'-Ordynskiy)|Vladimirskaya|Volgogradskaya|Vologodskaya|Voronezhskaya|Yamalo-Nenetskiy (Salekhard)|Yaroslavskaya|Yevreyskaya"; +aStates[190]="|Butare|Byumba|Cyangugu|Gikongoro|Gisenyi|Gitarama|Kibungo|Kibuye|Kigali Rurale|Kigali-ville|Ruhengeri|Umutara"; +aStates[191]="|Ascension|Saint Helena|Tristan da Cunha"; +aStates[192]="|Christ Church Nichola Town|Saint Anne Sandy Point|Saint George Basseterre|Saint George Gingerland|Saint James Windward|Saint John Capisterre|Saint John Figtree|Saint Mary Cayon|Saint Paul Capisterre|Saint Paul Charlestown|Saint Peter Basseterre|Saint Thomas Lowland|Saint Thomas Middle Island|Trinity Palmetto Point"; +aStates[193]="|Anse-la-Raye|Castries|Choiseul|Dauphin|Dennery|Gros Islet|Laborie|Micoud|Praslin|Soufriere|Vieux Fort"; +aStates[194]="|Miquelon|Saint Pierre"; +aStates[195]="|Charlotte|Grenadines|Saint Andrew|Saint David|Saint George|Saint Patrick"; +aStates[196]="|A'ana|Aiga-i-le-Tai|Atua|Fa'asaleleaga|Gaga'emauga|Gagaifomauga|Palauli|Satupa'itea|Tuamasaga|Va'a-o-Fonoti|Vaisigano"; +aStates[197]="|Acquaviva|Borgo Maggiore|Chiesanuova|Domagnano|Faetano|Fiorentino|Monte Giardino|San Marino|Serravalle"; +aStates[198]="|Principe|Sao Tome"; +aStates[199]="|'Asir|Al Bahah|Al Hudud ash Shamaliyah|Al Jawf|Al Madinah|Al Qasim|Ar Riyad|Ash Sharqiyah (Eastern Province)|Ha'il|Jizan|Makkah|Najran|Tabuk"; +aStates[200]="|Aberdeen City|Aberdeenshire|Angus|Argyll and Bute|City of Edinburgh|Clackmannanshire|Dumfries and Galloway|Dundee City|East Ayrshire|East Dunbartonshire|East Lothian|East Renfrewshire|Eilean Siar (Western Isles)|Falkirk|Fife|Glasgow City|Highland|Inverclyde|Midlothian|Moray|North Ayrshire|North Lanarkshire|Orkney Islands|Perth and Kinross|Renfrewshire|Shetland Islands|South Ayrshire|South Lanarkshire|Stirling|The Scottish Borders|West Dunbartonshire|West Lothian"; +aStates[201]="|Dakar|Diourbel|Fatick|Kaolack|Kolda|Louga|Saint-Louis|Tambacounda|Thies|Ziguinchor"; +aStates[202]="|Anse aux Pins|Anse Boileau|Anse Etoile|Anse Louis|Anse Royale|Baie Lazare|Baie Sainte Anne|Beau Vallon|Bel Air|Bel Ombre|Cascade|Glacis|Grand' Anse (on Mahe)|Grand' Anse (on Praslin)|La Digue|La Riviere Anglaise|Mont Buxton|Mont Fleuri|Plaisance|Pointe La Rue|Port Glaud|Saint Louis|Takamaka"; +aStates[203]="|Eastern|Northern|Southern|Western"; +aStates[204]="|Singapore"; +aStates[205]="|Banskobystricky|Bratislavsky|Kosicky|Nitriansky|Presovsky|Trenciansky|Trnavsky|Zilinsky"; +aStates[206]="|Ajdovscina|Beltinci|Bled|Bohinj|Borovnica|Bovec|Brda|Brezice|Brezovica|Cankova-Tisina|Celje|Cerklje na Gorenjskem|Cerknica|Cerkno|Crensovci|Crna na Koroskem|Crnomelj|Destrnik-Trnovska Vas|Divaca|Dobrepolje|Dobrova-Horjul-Polhov Gradec|Dol pri Ljubljani|Domzale|Dornava|Dravograd|Duplek|Gorenja Vas-Poljane|Gorisnica|Gornja Radgona|Gornji Grad|Gornji Petrovci|Grosuplje|Hodos Salovci|Hrastnik|Hrpelje-Kozina|Idrija|Ig|Ilirska Bistrica|Ivancna Gorica|Izola|Jesenice|Jursinci|Kamnik|Kanal|Kidricevo|Kobarid|Kobilje|Kocevje|Komen|Koper|Kozje|Kranj|Kranjska Gora|Krsko|Kungota|Kuzma|Lasko|Lenart|Lendava|Litija|Ljubljana|Ljubno|Ljutomer|Logatec|Loska Dolina|Loski Potok|Luce|Lukovica|Majsperk|Maribor|Medvode|Menges|Metlika|Mezica|Miren-Kostanjevica|Mislinja|Moravce|Moravske Toplice|Mozirje|Murska Sobota|Muta|Naklo|Nazarje|Nova Gorica|Novo Mesto|Odranci|Ormoz|Osilnica|Pesnica|Piran|Pivka|Podcetrtek|Podvelka-Ribnica|Postojna|Preddvor|Ptuj|Puconci|Race-Fram|Radece|Radenci|Radlje ob Dravi|Radovljica|Ravne-Prevalje|Ribnica|Rogasevci|Rogaska Slatina|Rogatec|Ruse|Semic|Sencur|Sentilj|Sentjernej|Sentjur pri Celju|Sevnica|Sezana|Skocjan|Skofja Loka|Skofljica|Slovenj Gradec|Slovenska Bistrica|Slovenske Konjice|Smarje pri Jelsah|Smartno ob Paki|Sostanj|Starse|Store|Sveti Jurij|Tolmin|Trbovlje|Trebnje|Trzic|Turnisce|Velenje|Velike Lasce|Videm|Vipava|Vitanje|Vodice|Vojnik|Vrhnika|Vuzenica|Zagorje ob Savi|Zalec|Zavrc|Zelezniki|Ziri|Zrece"; +aStates[207]="|Bellona|Central|Choiseul (Lauru)|Guadalcanal|Honiara|Isabel|Makira|Malaita|Rennell|Temotu|Western"; +aStates[208]="|Awdal|Bakool|Banaadir|Bari|Bay|Galguduud|Gedo|Hiiraan|Jubbada Dhexe|Jubbada Hoose|Mudug|Nugaal|Sanaag|Shabeellaha Dhexe|Shabeellaha Hoose|Sool|Togdheer|Woqooyi Galbeed"; +aStates[209]="|Eastern Cape|Free State|Gauteng|KwaZulu-Natal|Mpumalanga|North-West|Northern Cape|Northern Province|Western Cape"; +aStates[210]="|Bird Island|Bristol Island|Clerke Rocks|Montagu Island|Saunders Island|South Georgia|Southern Thule|Traversay Islands"; +aStates[211]="|Andalucia|Aragon|Asturias|Baleares (Balearic Islands)|Canarias (Canary Islands)|Cantabria|Castilla y Leon|Castilla-La Mancha|Cataluna|Ceuta|Communidad Valencian|Extremadura|Galicia|Islas Chafarinas|La Rioja|Madrid|Melilla|Murcia|Navarra|Pais Vasco (Basque Country)|Penon de Alhucemas|Penon de Velez de la Gomera"; +aStates[212]="|Spratly Islands"; +aStates[213]="|Central|Eastern|North Central|North Eastern|North Western|Northern|Sabaragamuwa|Southern|Uva|Western"; +aStates[214]="|A'ali an Nil|Al Bahr al Ahmar|Al Buhayrat|Al Jazirah|Al Khartum|Al Qadarif|Al Wahdah|An Nil al Abyad|An Nil al Azraq|Ash Shamaliyah|Bahr al Jabal|Gharb al Istiwa'iyah|Gharb Bahr al Ghazal|Gharb Darfur|Gharb Kurdufan|Janub Darfur|Janub Kurdufan|Junqali|Kassala|Nahr an Nil|Shamal Bahr al Ghazal|Shamal Darfur|Shamal Kurdufan|Sharq al Istiwa'iyah|Sinnar|Warab"; +aStates[215]="|Brokopondo|Commewijne|Coronie|Marowijne|Nickerie|Para|Paramaribo|Saramacca|Sipaliwini|Wanica"; +aStates[216]="|Barentsoya|Bjornoya|Edgeoya|Hopen|Kvitoya|Nordaustandet|Prins Karls Forland|Spitsbergen"; +aStates[217]="|Hhohho|Lubombo|Manzini|Shiselweni"; +aStates[218]="|Blekinge|Dalarnas|Gavleborgs|Gotlands|Hallands|Jamtlands|Jonkopings|Kalmar|Kronobergs|Norrbottens|Orebro|Ostergotlands|Skane|Sodermanlands|Stockholms|Uppsala|Varmlands|Vasterbottens|Vasternorrlands|Vastmanlands|Vastra Gotalands"; +aStates[219]="|Aargau|Ausser-Rhoden|Basel-Landschaft|Basel-Stadt|Bern|Fribourg|Geneve|Glarus|Graubunden|Inner-Rhoden|Jura|Luzern|Neuchatel|Nidwalden|Obwalden|Sankt Gallen|Schaffhausen|Schwyz|Solothurn|Thurgau|Ticino|Uri|Valais|Vaud|Zug|Zurich"; +aStates[220]="|Al Hasakah|Al Ladhiqiyah|Al Qunaytirah|Ar Raqqah|As Suwayda'|Dar'a|Dayr az Zawr|Dimashq|Halab|Hamah|Hims|Idlib|Rif Dimashq|Tartus"; +aStates[221]="|Chang-hua|Chi-lung|Chia-i|Chia-i|Chung-hsing-hsin-ts'un|Hsin-chu|Hsin-chu|Hua-lien|I-lan|Kao-hsiung|Kao-hsiung|Miao-li|Nan-t'ou|P'eng-hu|P'ing-tung|T'ai-chung|T'ai-chung|T'ai-nan|T'ai-nan|T'ai-pei|T'ai-pei|T'ai-tung|T'ao-yuan|Yun-lin"; +aStates[222]="|Viloyati Khatlon|Viloyati Leninobod|Viloyati Mukhtori Kuhistoni Badakhshon"; +aStates[223]="|Arusha|Dar es Salaam|Dodoma|Iringa|Kagera|Kigoma|Kilimanjaro|Lindi|Mara|Mbeya|Morogoro|Mtwara|Mwanza|Pemba North|Pemba South|Pwani|Rukwa|Ruvuma|Shinyanga|Singida|Tabora|Tanga|Zanzibar Central/South|Zanzibar North|Zanzibar Urban/West"; +aStates[224]="|Amnat Charoen|Ang Thong|Buriram|Chachoengsao|Chai Nat|Chaiyaphum|Chanthaburi|Chiang Mai|Chiang Rai|Chon Buri|Chumphon|Kalasin|Kamphaeng Phet|Kanchanaburi|Khon Kaen|Krabi|Krung Thep Mahanakhon (Bangkok)|Lampang|Lamphun|Loei|Lop Buri|Mae Hong Son|Maha Sarakham|Mukdahan|Nakhon Nayok|Nakhon Pathom|Nakhon Phanom|Nakhon Ratchasima|Nakhon Sawan|Nakhon Si Thammarat|Nan|Narathiwat|Nong Bua Lamphu|Nong Khai|Nonthaburi|Pathum Thani|Pattani|Phangnga|Phatthalung|Phayao|Phetchabun|Phetchaburi|Phichit|Phitsanulok|Phra Nakhon Si Ayutthaya|Phrae|Phuket|Prachin Buri|Prachuap Khiri Khan|Ranong|Ratchaburi|Rayong|Roi Et|Sa Kaeo|Sakon Nakhon|Samut Prakan|Samut Sakhon|Samut Songkhram|Sara Buri|Satun|Sing Buri|Sisaket|Songkhla|Sukhothai|Suphan Buri|Surat Thani|Surin|Tak|Trang|Trat|Ubon Ratchathani|Udon Thani|Uthai Thani|Uttaradit|Yala|Yasothon"; +aStates[225]="|Tobago"; +aStates[226]="|De La Kara|Des Plateaux|Des Savanes|Du Centre|Maritime"; +aStates[227]="|Atafu|Fakaofo|Nukunonu"; +aStates[228]="|Ha'apai|Tongatapu|Vava'u"; +aStates[229]="|Arima|Caroni|Mayaro|Nariva|Port-of-Spain|Saint Andrew|Saint David|Saint George|Saint Patrick|San Fernando|Victoria"; +aStates[230]="|Ariana|Beja|Ben Arous|Bizerte|El Kef|Gabes|Gafsa|Jendouba|Kairouan|Kasserine|Kebili|Mahdia|Medenine|Monastir|Nabeul|Sfax|Sidi Bou Zid|Siliana|Sousse|Tataouine|Tozeur|Tunis|Zaghouan"; +aStates[231]="|Adana|Adiyaman|Afyon|Agri|Aksaray|Amasya|Ankara|Antalya|Ardahan|Artvin|Aydin|Balikesir|Bartin|Batman|Bayburt|Bilecik|Bingol|Bitlis|Bolu|Burdur|Bursa|Canakkale|Cankiri|Corum|Denizli|Diyarbakir|Duzce|Edirne|Elazig|Erzincan|Erzurum|Eskisehir|Gaziantep|Giresun|Gumushane|Hakkari|Hatay|Icel|Igdir|Isparta|Istanbul|Izmir|Kahramanmaras|Karabuk|Karaman|Kars|Kastamonu|Kayseri|Kilis|Kirikkale|Kirklareli|Kirsehir|Kocaeli|Konya|Kutahya|Malatya|Manisa|Mardin|Mugla|Mus|Nevsehir|Nigde|Ordu|Osmaniye|Rize|Sakarya|Samsun|Sanliurfa|Siirt|Sinop|Sirnak|Sivas|Tekirdag|Tokat|Trabzon|Tunceli|Usak|Van|Yalova|Yozgat|Zonguldak"; +aStates[232]="|Ahal Welayaty|Balkan Welayaty|Dashhowuz Welayaty|Lebap Welayaty|Mary Welayaty"; +aStates[233]="|Tuvalu"; +aStates[234]="|Adjumani|Apac|Arua|Bugiri|Bundibugyo|Bushenyi|Busia|Gulu|Hoima|Iganga|Jinja|Kabale|Kabarole|Kalangala|Kampala|Kamuli|Kapchorwa|Kasese|Katakwi|Kibale|Kiboga|Kisoro|Kitgum|Kotido|Kumi|Lira|Luwero|Masaka|Masindi|Mbale|Mbarara|Moroto|Moyo|Mpigi|Mubende|Mukono|Nakasongola|Nebbi|Ntungamo|Pallisa|Rakai|Rukungiri|Sembabule|Soroti|Tororo"; +aStates[235]="|Avtonomna Respublika Krym (Simferopol')|Cherkas'ka (Cherkasy)|Chernihivs'ka (Chernihiv)|Chernivets'ka (Chernivtsi)|Dnipropetrovs'ka (Dnipropetrovs'k)|Donets'ka (Donets'k)|Ivano-Frankivs'ka (Ivano-Frankivs'k)|Kharkivs'ka (Kharkiv)|Khersons'ka (Kherson)|Khmel'nyts'ka (Khmel'nyts'kyy)|Kirovohrads'ka (Kirovohrad)|Kyyiv|Kyyivs'ka (Kiev)|L'vivs'ka (L'viv)|Luhans'ka (Luhans'k)|Mykolayivs'ka (Mykolayiv)|Odes'ka (Odesa)|Poltavs'ka (Poltava)|Rivnens'ka (Rivne)|Sevastopol'|Sums'ka (Sumy)|Ternopil's'ka (Ternopil')|Vinnyts'ka (Vinnytsya)|Volyns'ka (Luts'k)|Zakarpats'ka (Uzhhorod)|Zaporiz'ka (Zaporizhzhya)|Zhytomyrs'ka (Zhytomyr)" +aStates[236]="|'Ajman|Abu Zaby (Abu Dhabi)|Al Fujayrah|Ash Shariqah (Sharjah)|Dubayy (Dubai)|Ra's al Khaymah|Umm al Qaywayn"; +aStates[237]="|Barking and Dagenham|Barnet|Barnsley|Bath and North East Somerset|Bedfordshire|Bexley|Birmingham|Blackburn with Darwen|Blackpool|Bolton|Bournemouth|Bracknell Forest|Bradford|Brent|Brighton and Hove|Bromley|Buckinghamshire|Bury|Calderdale|Cambridgeshire|Camden|Cheshire|City of Bristol|City of Kingston upon Hull|City of London|Cornwall|Coventry|Croydon|Cumbria|Darlington|Derby|Derbyshire|Devon|Doncaster|Dorset|Dudley|Durham|Ealing|East Riding of Yorkshire|East Sussex|Enfield|Essex|Gateshead|Gloucestershire|Greenwich|Hackney|Halton|Hammersmith and Fulham|Hampshire|Haringey|Harrow|Hartlepool|Havering|Herefordshire|Hertfordshire|Hillingdon|Hounslow|Isle of Wight|Islington|Kensington and Chelsea|Kent|Kingston upon Thames|Kirklees|Knowsley|Lambeth|Lancashire|Leeds|Leicester|Leicestershire|Lewisham|Lincolnshire|Liverpool|Luton|Manchester|Medway|Merton|Middlesbrough|Milton Keynes|Newcastle upon Tyne|Newham|Norfolk|North East Lincolnshire|North Lincolnshire|North Somerset|North Tyneside|North Yorkshire|Northamptonshire|Northumberland|Nottingham|Nottinghamshire|Oldham|Oxfordshire|Peterborough|Plymouth|Poole|Portsmouth|Reading|Redbridge|Redcar and Cleveland|Richmond upon Thames|Rochdale|Rotherham|Rutland|Salford|Sandwell|Sefton|Sheffield|Shropshire|Slough|Solihull|Somerset|South Gloucestershire|South Tyneside|Southampton|Southend-on-Sea|Southwark|St. Helens|Staffordshire|Stockport|Stockton-on-Tees|Stoke-on-Trent|Suffolk|Sunderland|Surrey|Sutton|Swindon|Tameside|Telford and Wrekin|Thurrock|Torbay|Tower Hamlets|Trafford|Wakefield|Walsall|Waltham Forest|Wandsworth|Warrington|Warwickshire|West Berkshire|West Sussex|Westminster|Wigan|Wiltshire|Windsor and Maidenhead|Wirral|Wokingham|Wolverhampton|Worcestershire|York"; +aStates[238]="|Artigas|Canelones|Cerro Largo|Colonia|Durazno|Flores|Florida|Lavalleja|Maldonado|Montevideo|Paysandu|Rio Negro|Rivera|Rocha|Salto|San Jose|Soriano|Tacuarembo|Treinta y Tres"; +aStates[239]="|Alabama|Alaska|Arizona|Arkansas|California|Colorado|Connecticut|Delaware|District of Columbia|Florida|Georgia|Hawaii|Idaho|Illinois|Indiana|Iowa|Kansas|Kentucky|Louisiana|Maine|Maryland|Massachusetts|Michigan|Minnesota|Mississippi|Missouri|Montana|Nebraska|Nevada|New Hampshire|New Jersey|New Mexico|New York|North Carolina|North Dakota|Ohio|Oklahoma|Oregon|Pennsylvania|Rhode Island|South Carolina|South Dakota|Tennessee|Texas|Utah|Vermont|Virginia|Washington|West Virginia|Wisconsin|Wyoming"; +aStates[240]="|Andijon Wiloyati|Bukhoro Wiloyati|Farghona Wiloyati|Jizzakh Wiloyati|Khorazm Wiloyati (Urganch)|Namangan Wiloyati|Nawoiy Wiloyati|Qashqadaryo Wiloyati (Qarshi)|Qoraqalpoghiston (Nukus)|Samarqand Wiloyati|Sirdaryo Wiloyati (Guliston)|Surkhondaryo Wiloyati (Termiz)|Toshkent Shahri|Toshkent Wiloyati"; +aStates[241]="|Malampa|Penama|Sanma|Shefa|Tafea|Torba"; +aStates[242]="|Amazonas|Anzoategui|Apure|Aragua|Barinas|Bolivar|Carabobo|Cojedes|Delta Amacuro|Dependencias Federales|Distrito Federal|Falcon|Guarico|Lara|Merida|Miranda|Monagas|Nueva Esparta|Portuguesa|Sucre|Tachira|Trujillo|Vargas|Yaracuy|Zulia"; +aStates[243]="|An Giang|Ba Ria-Vung Tau|Bac Giang|Bac Kan|Bac Lieu|Bac Ninh|Ben Tre|Binh Dinh|Binh Duong|Binh Phuoc|Binh Thuan|Ca Mau|Can Tho|Cao Bang|Da Nang|Dac Lak|Dong Nai|Dong Thap|Gia Lai|Ha Giang|Ha Nam|Ha Noi|Ha Tay|Ha Tinh|Hai Duong|Hai Phong|Ho Chi Minh|Hoa Binh|Hung Yen|Khanh Hoa|Kien Giang|Kon Tum|Lai Chau|Lam Dong|Lang Son|Lao Cai|Long An|Nam Dinh|Nghe An|Ninh Binh|Ninh Thuan|Phu Tho|Phu Yen|Quang Binh|Quang Nam|Quang Ngai|Quang Ninh|Quang Tri|Soc Trang|Son La|Tay Ninh|Thai Binh|Thai Nguyen|Thanh Hoa|Thua Thien-Hue|Tien Giang|Tra Vinh|Tuyen Quang|Vinh Long|Vinh Phuc|Yen Bai"; +aStates[244]="|Saint Croix|Saint John|Saint Thomas"; +aStates[245]="|Blaenau Gwent|Bridgend|Caerphilly|Cardiff|Carmarthenshire|Ceredigion|Conwy|Denbighshire|Flintshire|Gwynedd|Isle of Anglesey|Merthyr Tydfil|Monmouthshire|Neath Port Talbot|Newport|Pembrokeshire|Powys|Rhondda Cynon Taff|Swansea|The Vale of Glamorgan|Torfaen|Wrexham"; +aStates[246]="|Alo|Sigave|Wallis"; +aStates[247]="|West Bank"; +aStates[248]="|Western Sahara"; +aStates[249]="|'Adan|'Ataq|Abyan|Al Bayda'|Al Hudaydah|Al Jawf|Al Mahrah|Al Mahwit|Dhamar|Hadhramawt|Hajjah|Ibb|Lahij|Ma'rib|Sa'dah|San'a'|Ta'izz"; +aStates[250]="|Kosovo|Montenegro|Serbia|Vojvodina"; +aStates[251]="|Central|Copperbelt|Eastern|Luapula|Lusaka|North-Western|Northern|Southern|Western"; +aStates[252]="|Bulawayo|Harare|ManicalandMashonaland Central|Mashonaland East|Mashonaland West|Masvingo|Matabeleland North|Matabeleland South|Midlands"; + +/* + * gArCountryInfo + * (0) Country name + * (1) Name length + * (2) Number of states + * (3) Max state length + */ +gLngNumberCountries = sCountryString.split("|").length; +//gArCountryInfo = new Array(gLngNumberCountries); +gArCountryInfo=sCountryString.split("|"); +/* + * gArStateInfo[country][statenames][namelengths] + * (0) Country + * (1) States (Multi-sized Array) + * (0) name + * (1) nameLength + */ +gArStateInfo = new Array(gLngNumberCountries); + +/* + * fInitgArStateInfo() + * purpose: build gArStateInfo array + * gArStateInfo[Country][States][1] + * (0) State name + * (1) State name length + * gArStateInfo[i] is an array of state names + * gArStateInfo[i][j]=state name, name length + */ +function fInitgArStateInfo() { + var i=0, j=0, sStateName="", iNumberOfStates=0; + var iMaxLength=0, iLength=0; + var oldNumber=0; + + for (i=0;iiMaxLength) { + iMaxLength=iLength; + gArStateInfo[i][j][0]=sStateName; + } + } + gArCountryInfo[i][3]=parseInt(iMaxLength); + } + Update_Globals(); + return; +} + +/* + * Working on this one. + * Fills in region from the arrays + * + */ +function xFillState() { + var i=0; + + // reset region + document.form1.region.options.length=0; + + // get selected country + gLngSelectedCountry=document.form1.country_name.selectedIndex; + + // get number of states for selected country + gLngNumberStates=gArCountryInfo[[gLngSelectedCountry][2]]; + + // update options in region + for (i=0;i diff --git a/include/jquery.js b/js/jquery.js old mode 100755 new mode 100644 similarity index 100% rename from include/jquery.js rename to js/jquery.js diff --git a/js/main.js b/js/main.js new file mode 100644 index 00000000..343c9b9a --- /dev/null +++ b/js/main.js @@ -0,0 +1,32 @@ + +function openClose(theID) { + if (document.getElementById(theID).style.display == "block") { + document.getElementById(theID).style.display = "none" + } else { + document.getElementById(theID).style.display = "block" + } +} + +function openMenu(theID) { + document.getElementById(theID).style.display = "block" +} + +function closeMenu(theID) { + document.getElementById(theID).style.display = "none" +} + +function commentOpen(obj,id) { + if (obj.value == 'Comment') { + obj.value = ''; + obj.className = "comment-edit-text-full"; + openMenu("comment-edit-submit-wrapper-" + id); + } +} + +function commentClose(obj,id) { + if (obj.value == '') { + obj.value = 'Comment'; + obj.className="comment-edit-text-empty"; + closeMenu("comment-edit-submit-wrapper-" + id); + } +} diff --git a/include/g.line-min.js b/js/raphael/g_line.js similarity index 100% rename from include/g.line-min.js rename to js/raphael/g_line.js diff --git a/include/g.raphael.js b/js/raphael/g_rahael.js similarity index 100% rename from include/g.raphael.js rename to js/raphael/g_rahael.js diff --git a/include/raphael.js b/js/raphael/raphael.js similarity index 100% rename from include/raphael.js rename to js/raphael/raphael.js diff --git a/library/HTML5/Data.php b/library/HTML5/Data.php old mode 100755 new mode 100644 diff --git a/library/HTML5/InputStream.php b/library/HTML5/InputStream.php old mode 100755 new mode 100644 diff --git a/library/HTML5/Parser.php b/library/HTML5/Parser.php old mode 100755 new mode 100644 diff --git a/library/HTML5/Tokenizer.php b/library/HTML5/Tokenizer.php old mode 100755 new mode 100644 diff --git a/library/HTML5/TreeBuilder.php b/library/HTML5/TreeBuilder.php old mode 100755 new mode 100644 diff --git a/library/HTML5/named-character-references.ser b/library/HTML5/named-character-references.ser old mode 100755 new mode 100644 diff --git a/library/php-ssllabs-api/Readme.md b/library/php-ssllabs-api/Readme.md new file mode 100644 index 00000000..7bceeec2 --- /dev/null +++ b/library/php-ssllabs-api/Readme.md @@ -0,0 +1,237 @@ +# PHP-SSLLabs-API +This PHP library provides basic access to the SSL Labs API. + +It's build upon the official API documentation at https://github.com/ssllabs/ssllabs-scan/blob/master/ssllabs-api-docs.md +```PHP +fetchApiInfo()); + +?> +``` +## Methods +### fetchApiInfo() +No parameters needed + +Returns an Info object (see https://github.com/ssllabs/ssllabs-scan/blob/master/ssllabs-api-docs.md#info). + +### fetchStatusCodes() +No parameters needed + +Returns a StatusCodes instance (see https://github.com/ssllabs/ssllabs-scan/blob/master/ssllabs-api-docs.md#statuscodes). + +### fetchHostInformation() +See https://github.com/ssllabs/ssllabs-scan/blob/master/ssllabs-api-docs.md#invoke-assessment-and-check-progress for parameter description. + +| Parameter | Type | Default value | | +|---------------------|---------|---------------|----------| +| **host** | string | | Required | +| **publish** | boolean | false | | +| **startNew** | boolean | false | | +| **fromCache** | boolean | false | | +| **maxAge** | int | null | | +| **all** | string | null | | +| **ignoreMismatch** | boolean | false | | + +Returns a Host object (see https://github.com/ssllabs/ssllabs-scan/blob/master/ssllabs-api-docs.md#host). + +Make sure to check the 'status' attribute inside Host object. + +### fetchHostInformationCached() +You can also use fetchHostInformation() with the proper parameters, this is just a helper function. + +| Parameter | Type | Default value | | +|---------------------|---------|---------------|----------| +| **host** | string | | Required | +| **maxAge** | int | null | | +| **publish** | boolean | false | | +| **ignoreMismatch** | boolean | false | | + +Returns a Host object (see https://github.com/ssllabs/ssllabs-scan/blob/master/ssllabs-api-docs.md#host). + +Also make sure to check the 'status' attribute inside Host object. + +### fetchEndpointData() +See https://github.com/ssllabs/ssllabs-scan/blob/master/ssllabs-api-docs.md#retrieve-detailed-endpoint-information for parameter description. + +| Parameter | Type | Default value | | +|----------------|---------|---------------|----------| +| **host** | string | | Required | +| **s** | string | | Required | +| **fromCache** | boolean | false | | + +Returns an Endpoint object (see https://github.com/ssllabs/ssllabs-scan/blob/master/ssllabs-api-docs.md#endpoint). + +### Custom API calls +Use sendApiRequest() method to create custom API calls. + +| Parameter | Type | Default value | | +|-----------------|--------|---------------|----------| +| **apiCall** | string | | Required | +| **parameters** | array | | | + +```PHP +$api->sendApiRequest('apiCallName', array('p1' => 'p1_value', 'p2' => 'p2_value')); +``` + +### getReturnJsonObjects() +Getter for returnJsonObjects + +### setReturnJsonObjects() +Setter for returnJsonObjects + +| Parameter | Type | Default value | | +|-----------------------|---------|---------------|----------| +| **returnJsonObjects** | boolean | | Required | + +## Example output (as JSON strings) +### Get API information +```PHP +$api->fetchApiInfo(); +``` +```JSON +{ + "engineVersion": "1.15.1", + "criteriaVersion": "2009i", + "clientMaxAssessments": 25, + "maxAssessments": 25, + "currentAssessments": 0, + "messages": [ + "This assessment service is provided free of charge by Qualys SSL Labs, subject to our terms and conditions: https://www.ssllabs.com/about/terms.html" + ] +} +``` + +### Get host information +```PHP +$api->fetchHostInformation('https://www.google.de'); +``` +```JSON +{ + "host": "https://www.google.de", + "port": 443, + "protocol": "HTTP", + "isPublic": false, + "status": "READY", + "startTime": 1427195976527, + "testTime": 1427196284525, + "engineVersion": "1.15.1", + "criteriaVersion": "2009i", + "endpoints": [ + { + "ipAddress": "74.125.239.119", + "serverName": "nuq05s01-in-f23.1e100.net", + "statusMessage": "Ready", + "grade": "B", + "hasWarnings": false, + "isExceptional": false, + "progress": 100, + "duration": 77376, + "eta": 1610, + "delegation": 3 + }, + { + "ipAddress": "74.125.239.120", + "serverName": "nuq05s01-in-f24.1e100.net", + "statusMessage": "Ready", + "grade": "B", + "hasWarnings": false, + "isExceptional": false, + "progress": 100, + "duration": 76386, + "eta": 1609, + "delegation": 3 + }, + { + "ipAddress": "74.125.239.127", + "serverName": "nuq05s01-in-f31.1e100.net", + "statusMessage": "Ready", + "grade": "B", + "hasWarnings": false, + "isExceptional": false, + "progress": 100, + "duration": 76937, + "eta": 1608, + "delegation": 3 + }, + { + "ipAddress": "74.125.239.111", + "serverName": "nuq05s01-in-f15.1e100.net", + "statusMessage": "Ready", + "grade": "B", + "hasWarnings": false, + "isExceptional": false, + "progress": 100, + "duration": 77171, + "eta": 1606, + "delegation": 3 + } + ] +} +``` + +### Get endpoint information +```PHP +$api->fetchEndpointData('https://www.google.de', '74.125.239.111'); +``` + +(just an except of the entire JSON output) +```JSON +{ + "ipAddress": "74.125.239.111", + "serverName": "nuq05s01-in-f15.1e100.net", + "statusMessage": "Ready", + "grade": "B", + "hasWarnings": false, + "isExceptional": false, + "progress": 100, + "duration": 77171, + "eta": 1609, + "delegation": 3, + "details": { + "hostStartTime": 1427195976527, + "key": {}, + "cert": {}, + "chain": {}, + "protocols": [], + "suites": {}, + "serverSignature": "gws", + "prefixDelegation": true, + "nonPrefixDelegation": true, + "vulnBeast": false, + "renegSupport": 2, + "sessionResumption": 1, + "compressionMethods": 0, + "supportsNpn": true, + "npnProtocols": "h2-15 h2-14 spdy/3.1 spdy/3 http/1.1", + "sessionTickets": 1, + "ocspStapling": false, + "sniRequired": false, + "httpStatusCode": 200, + "supportsRc4": true, + "forwardSecrecy": 2, + "rc4WithModern": true, + "sims": {}, + "heartbleed": false, + "heartbeat": false, + "openSslCcs": 1, + "poodleTls": 1, + "fallbackScsv": true + } +} +``` + +# Terms and Conditions +As this is just a PHP library for SSL Labs API please refer to SSL Labs terms and conditions at https://www.ssllabs.com/about/terms.html diff --git a/library/php-ssllabs-api/ssllabsApi.php b/library/php-ssllabs-api/ssllabsApi.php new file mode 100644 index 00000000..32f3d4e4 --- /dev/null +++ b/library/php-ssllabs-api/ssllabsApi.php @@ -0,0 +1,216 @@ + + * @license GNU GENERAL PUBLIC LICENSE v3 + */ + +class sslLabsApi +{ + CONST API_URL = "https://api.ssllabs.com/api/v2"; + + private $returnJsonObjects; + + /** + * sslLabsApi::__construct() + */ + public function __construct($returnJsonObjects = false) + { + $this->returnJsonObjects = (boolean) $returnJsonObjects; + } + + /** + * sslLabsApi::fetchApiInfo() + * + * API Call: info + * @see https://github.com/ssllabs/ssllabs-scan/blob/master/ssllabs-api-docs.md + */ + public function fetchApiInfo() + { + return ($this->sendApiRequest('info')); + } + + /** + * sslLabsApi::fetchHostInformation() + * + * API Call: analyze + * @see https://github.com/ssllabs/ssllabs-scan/blob/master/ssllabs-api-docs.md + * + * @param string $host Hostname to analyze + * @param boolean $publish + * @param boolean $startNew + * @param boolean $fromCache + * @param int $maxAge + * @param string $all + * @param boolean $ignoreMismatch + */ + public function fetchHostInformation($host, $publish = false, $startNew = false, $fromCache = false, $maxAge = NULL, $all = NULL, $ignoreMismatch = false) + { + $apiRequest = $this->sendApiRequest + ( + 'analyze', + array + ( + 'host' => $host, + 'publish' => $publish, + 'startNew' => $startNew, + 'fromCache' => $fromCache, + 'maxAge' => $maxAge, + 'all' => $all, + 'ignoreMismatch' => $ignoreMismatch + ) + ); + + return ($apiRequest); + } + + /** + * sslLabsApi::fetchHostInformationCached() + * + * API Call: analyze + * Same as fetchHostInformation() but prefer to receive cached information + * + * @param string $host + * @param int $maxAge + * @param string $publish + * @param string $ignoreMismatch + */ + public function fetchHostInformationCached($host, $maxAge, $publish = false, $ignoreMismatch = false) + { + return($this->fetchHostInformation($host, $publish, false, true, $maxAge, 'done', $ignoreMismatch)); + } + + /** + * sslLabsApi::fetchEndpointData() + * + * API Call: getEndpointData + * @see https://github.com/ssllabs/ssllabs-scan/blob/master/ssllabs-api-docs.md + * + * @param string $host + * @param string $s + * @param string $fromCache + * @return string + */ + public function fetchEndpointData($host, $s, $fromCache = false) + { + $apiRequest = $this->sendApiRequest + ( + 'getEndpointData', + array + ( + 'host' => $host, + 's' => $s, + 'fromCache' => $fromCache + ) + ); + + return ($apiRequest); + } + + /** + * sslLabsApi::fetchStatusCodes() + * + * API Call: getStatusCodes + */ + public function fetchStatusCodes() + { + return ($this->sendApiRequest('getStatusCodes')); + } + + /** + * sslLabsApi::sendApiRequest() + * + * Send API request + * + * @param string $apiCall + * @param array $parameters + * @return string JSON from API + */ + public function sendApiRequest($apiCall, $parameters = array()) + { + //we also want content from failed api responses + $context = stream_context_create + ( + array + ( + 'http' => array + ( + 'ignore_errors' => true + ) + ) + ); + + $apiResponse = file_get_contents(self::API_URL . '/' . $apiCall . $this->buildGetParameterString($parameters), false, $context); + + if($this->returnJsonObjects) + { + return (json_decode($apiResponse)); + } + + return ($apiResponse); + } + + /** + * sslLabsApi::setReturnJsonObjects() + * + * Setter for returnJsonObjects + * Set true to return all API responses as JSON object, false returns it as simple JSON strings (default) + * + * @param boolean $returnJsonObjects + */ + public function setReturnJsonObjects($returnJsonObjects) + { + $this->returnJsonObjects = (boolean) $returnJsonObjects; + } + + /** + * sslLabsApi::getReturnJsonObjects() + * + * Getter for returnJsonObjects + * + * @return boolean true returns all API responses as JSON object, false returns it as simple JSON string + */ + public function getReturnJsonObjects() + { + return ($this->returnJsonObjects); + } + + /** + * sslLabsApi::buildGetParameterString() + * + * Helper function to build get parameter string for URL + * + * @param array $parameters + * @return string + */ + private function buildGetParameterString($parameters) + { + $string = ''; + + $counter = 0; + foreach($parameters as $name => $value) + { + if(!is_string($name) || (!is_string($value) && !is_bool($value) && !is_int($value))) + { + continue; + } + + if(is_bool($value)) + { + $value = ($value) ? 'on' : 'off'; + } + + $string .= ($counter == 0) ? '?' : '&'; + $string .= urlencode($name) . '=' . urlencode($value); + + $counter++; + } + + return ($string); + } +} \ No newline at end of file diff --git a/mod/admin.php b/mod/admin.php old mode 100755 new mode 100644 diff --git a/mod/directory.php b/mod/directory.php old mode 100755 new mode 100644 index 3a434f03..5ef83b3a --- a/mod/directory.php +++ b/mod/directory.php @@ -1,126 +1,82 @@ set_pager_itemspage(80); +require_once 'include/widget.php'; + +function directory_init(App $a) +{ + $a->set_pager_itemspage(30); $a->page['aside'] .= tags_widget(); $a->page['aside'] .= country_widget(); } -function directory_content(&$a) { - +function directory_content(App $a) +{ $forums = false; - if($a->argc == 2 && $a->argv[1] === 'forum') + if ($a->argc == 2 && $a->argv[1] === 'forum') { $forums = true; - - $alpha = false; - if($_GET['alpha'] == 1) - $alpha = true; - - - $search = ((x($_GET,'search')) ? notags(trim($_GET['search'])) : ''); - - if($_GET['submit'] === t('Clear')) { - goaway($a->get_baseurl()); } - if($search) + $alpha = false; + if (isset($_GET['alpha']) && $_GET['alpha'] == 1) { $alpha = true; + } + $tpl = file_get_contents('view/directory_header.tpl'); - $tpl .= file_get_contents('view/directory_header.tpl'); - - $o .= replace_macros($tpl, array( - '$search' => $search, - '$header' => t('Global Directory'), - '$submit' => t('Find'), - '$clear' => t('Clear'), - '$forum' => $a->get_baseurl() . (($forums) ? '' : '/directory/forum' ), - '$toggle' => (($forums) ? t('Show People') : t('Show Community Forums')), - '$alpha' => (($alpha) ? t('Updated order') : t('Alphabetic order')), - '$alink' => (($alpha) ? str_replace('&alpha=1','',$a->query_string) : $a->query_string . "&alpha=1"), - '$args' => (($forums) ? '/forum' : ''), - '$finding' => (strlen($search) ? '

' . t('Search for: ') . "'" . $search . "'" . '

' : "") + $o = replace_macros($tpl, array( + '$header' => t('Global Directory'), + '$submit' => t('Find'), + '$forum' => $a->get_baseurl() . (($forums) ? '' : '/directory/forum'), + '$toggle' => (($forums) ? t('Show People') : t('Show Community Forums')), + '$alpha' => (($alpha) ? t('Updated order') : t('Alphabetic order')), + '$alink' => (($alpha) ? str_replace('&alpha=1', '', $a->query_string) : $a->query_string . "&alpha=1"), + '$args' => (($forums) ? '/forum' : ''), )); - if($search) - $search = dbesc($search . '*'); - $sql_extra = ((strlen($search)) ? " AND MATCH (`name`, `pdesc`, `homepage`, `locality`, `region`, `country-name`, `gender`, `marital`, `tags` ) - AGAINST ('$search' IN BOOLEAN MODE) " : ""); + $sql_extra = ''; + if ($forums) { + $sql_extra .= ' AND `comm` = 1 '; + } - if($forums) - $sql_extra .= " and comm = 1 "; - - $sql_extra = str_replace('%','%%',$sql_extra); + $sql_extra = str_replace('%', '%%', $sql_extra); $r = q("SELECT COUNT(*) AS `total` FROM `profile` WHERE `censored` = 0 $sql_extra "); - if(count($r)) - $a->set_pager_total($r[0]['total']); - - if($alpha) - $order = " order by name asc "; - else - $order = " order by updated desc, id desc "; + if (count($r)) { + $total = $r[0]['total']; + $a->set_pager_total($total); + } + if ($alpha) { + $order = ' ORDER BY `name` ASC '; + } else { + $order = ' ORDER BY `updated` DESC, `id` DESC '; + } $r = q("SELECT * FROM `profile` WHERE `censored` = 0 $sql_extra $order LIMIT %d , %d ", intval($a->pager['start']), intval($a->pager['itemspage']) ); - if(count($r)) { + //Show results. + $view = new View('directory'); - $tpl = file_get_contents('view/directory_item.tpl'); + $view->addHelper('paginate', function() use ($a) { + return paginate($a); + }); + $view->addHelper('photoUrl', ProfileHelper::get('photoUrl')); + $view->addHelper('filterAllUrl', SearchHelper::get('filterAllUrl')); + $view->addHelper('filterPeopleUrl', SearchHelper::get('filterPeopleUrl')); + $view->addHelper('filterForumsUrl', SearchHelper::get('filterForumsUrl')); - foreach($r as $rr) { - - $pdesc = (($rr['pdesc']) ? $rr['pdesc'] . '
' : ''); - - $details = ''; - if(strlen($rr['locality'])) - $details .= $rr['locality']; - if(strlen($rr['region'])) { - if(strlen($rr['locality'])) - $details .= ', '; - $details .= $rr['region']; - } - if(strlen($rr['country-name'])) { - if(strlen($details)) - $details .= ', '; - $details .= $rr['country-name']; - } - - if(strlen($rr['gender'])) - $details .= '
' . t('Gender: ') . $rr['gender'] ; - - $o .= replace_macros($tpl,array( - '$id' => $rr['id'], - '$mod' => '
' . t('Flag this entry') . '
', - '$star' => (($rr['tags']) ? '
' : ''), - '$profile-link' => zrl($rr['homepage']), - '$photo' => $a->get_baseurl() . '/photo/' . $rr['id'], - -// '$photo' => (($rr['photo']) ? $rr['photo'] : $a->get_baseurl() . '/photo/' . $rr['id']), - '$alt-text' => $rr['name'] . ' ' . '(' . $rr['homepage'] . ')', - '$name' => $rr['name'], - '$pclass' => (($rr['comm']) ? ' group' : ''), - '$pgroup' => (($rr['comm']) ? '
' . t('[Public Group]') . '
' : ''), - '$details' => $pdesc . $details, - '$marital' => ((strlen($rr['marital'])) ? '
' . t('Status:') . ' ' . $rr['marital'] . '
' : '') - - - - )); - - } - $o .= "
\r\n"; - $o .= paginate($a); - - } - else - notice( t('No matching entries.') . EOL); - - return $o; -} \ No newline at end of file + $view->output(array( + 'total' => number_format($total), + 'results' => $r, + 'filter' => $forums ? 'forums' : '', + )); +} diff --git a/mod/flag.php b/mod/flag.php old mode 100755 new mode 100644 index 6dd437f4..0a088d66 --- a/mod/flag.php +++ b/mod/flag.php @@ -28,7 +28,7 @@ function flag_post(&$a) { ); $msg = "An entry ($id) has just been flagged for $reason."; - + mail('info@friendika.com',"Directory Flag action",$msg); } @@ -39,7 +39,7 @@ function flag_post(&$a) { ); } - notice("Entry has been flagged."); + notice("Entry has been flagged."); goaway($a->get_baseurl()); @@ -50,7 +50,7 @@ function flag_content(&$a) { if($a->argc > 1) $id = intval($a->argv[1]); - if(! id) { + if(! $id) { goaway($a->get_baseurl()); } @@ -62,7 +62,7 @@ $o .= <<< EOT You may flag profile listings for one of two reasons: inappropriate (adult) content, or if the link destination and therefore the profile entry is no longer valid. If you selected this form by mistake, please use your browser "Back" button to return to the Friendika directory.

-Your request will be verified and if it is deemed to be valid, the entry will be flagged/removed. Please allow 24-36 hours for this action to take place. +Your request will be verified and if it is deemed to be valid, the entry will be flagged/removed. Please allow 24-36 hours for this action to take place.



diff --git a/mod/health.php b/mod/health.php index 6f285326..243c4edf 100644 --- a/mod/health.php +++ b/mod/health.php @@ -45,6 +45,7 @@ function health_search(&$a, $search) ' '. '' . $site['base_url'] . ' '. '(' . $site['users'] . ')'. + ($site['effective_base_url'] ? ' -> '.$site['effective_base_url'].'' : ''). "
\r\n"; } @@ -70,7 +71,7 @@ function health_summary(&$a){ $sites = array(); //Find the user count per site. - $r = q("SELECT `homepage` FROM `profile` WHERE 1"); + $r = q("SELECT `homepage` FROM `profile`"); if(count($r)) { foreach($r as $rr) { $site = parse_site_from_url($rr['homepage']); @@ -82,11 +83,11 @@ function health_summary(&$a){ } } - //See if we have a health for them. + //See if we have a health for them AND they provide SSL. $sites_with_health = array(); $site_healths = array(); - $r = q("SELECT * FROM `site-health` WHERE `reg_policy`='REGISTER_OPEN'"); + $r = q("SELECT * FROM `site-health` WHERE `reg_policy`='REGISTER_OPEN' AND `ssl_state` = 1"); if(count($r)) { foreach($r as $rr) { $sites_with_health[$rr['base_url']] = (($sites[$rr['base_url']] / 100) + 10) * intval($rr['health_score']); @@ -106,7 +107,7 @@ function health_summary(&$a){ //Skip small sites. $users = $sites[$k]; - if($users < 10) continue; + if($users < 5) continue; $public_sites .= ' '. @@ -129,6 +130,42 @@ function health_summary(&$a){ function health_details($a, $id) { + //Max data age in MySQL date. + $maxDate = date('Y-m-d H:i:s', time()-($a->config['stats']['maxDataAge'])); + + //Include graphael line charts. + $a->page['htmlhead'] .= ''.PHP_EOL; + $a->page['htmlhead'] .= ''.PHP_EOL; + $a->page['htmlhead'] .= ''.PHP_EOL; + $a->page['htmlhead'] .= ''.PHP_EOL; + $a->page['htmlhead'] .= ''; + //The overall health status. $r = q( "SELECT * FROM `site-health` @@ -142,6 +179,22 @@ function health_details($a, $id) $site = $r[0]; + //Does it redirect to a known site? + $redirectStatement = ''; + if($site['effective_base_url']){ + + //The effective health status. + $r = q( + "SELECT * FROM `site-health` + WHERE `base_url`= '%s'", + dbesc($site['effective_base_url']) + ); + if(count($r)){ + $redirectStatement = 'Redirects to '.$site['effective_base_url'].''; + } + + } + //Figure out SSL state. $urlMeta = parse_url($site['base_url']); if($urlMeta['scheme'] !== 'https'){ @@ -169,8 +222,10 @@ function health_details($a, $id) //Get avg probe speed. $r = q( "SELECT AVG(`request_time`) as `avg_probe_time` FROM `site-probe` - WHERE `site_health_id` = %u", - intval($site['id']) + WHERE `site_health_id` = %u + AND `dt_performed` > '%s'", + intval($site['id']), + $maxDate ); if(count($r)){ $site['avg_probe_time'] = $r[0]['avg_probe_time']; @@ -184,8 +239,10 @@ function health_details($a, $id) AVG(`photo_time`) as `avg_photo_time`, AVG(`total_time`) as `avg_submit_time` FROM `site-scrape` - WHERE `site_health_id` = %u", - intval($site['id']) + WHERE `site_health_id` = %u + AND `dt_performed` > '%s'", + intval($site['id']), + $maxDate ); if(count($r)){ $site['avg_profile_time'] = $r[0]['avg_profile_time']; @@ -196,62 +253,18 @@ function health_details($a, $id) //Get probe speed data. $r = q( - "SELECT `request_time`, `dt_performed` FROM `site-probe` - WHERE `site_health_id` = %u", - intval($site['id']) + "SELECT AVG(`request_time`) as `avg_time`, date(`dt_performed`) as `date` FROM `site-probe` + WHERE `site_health_id` = %u + AND `dt_performed` > '%s' + GROUP BY `date`", + intval($site['id']), + $maxDate ); if(count($r)){ //Include graphael line charts. - $a->page['htmlhead'] .= ''.PHP_EOL; - $a->page['htmlhead'] .= ''.PHP_EOL; - $a->page['htmlhead'] .= ''; - $speeds = array(); - $times = array(); - $mintime = time(); - foreach($r as $row){ - $speeds[] = $row['request_time']; - $time = strtotime($row['dt_performed']); - $times[] = $time; - if($mintime > $time) $mintime = $time; - } - for($i=0; $i < count($times); $i++){ - $times[$i] -= $mintime; - $times[$i] = floor($times[$i] / (24*3600)); - } - $a->page['htmlhead'] .= - ''; - } - - //Get scrape speed data. - $r = q( - "SELECT AVG(`total_time`) as `avg_time`, date(`dt_performed`) as `date` FROM `site-scrape` - WHERE `site_health_id` = %u GROUP BY `date`", - intval($site['id']) - // date('Y-m-d H:i:s', time()-(3*24*3600)) //Max 3 days old. - ); - if($r && count($r)){ - //Include graphael line charts. - $a->page['htmlhead'] .= ''.PHP_EOL; - $a->page['htmlhead'] .= ''.PHP_EOL; - $a->page['htmlhead'] .= ''; + $a->page['htmlhead'] .= ''.PHP_EOL; + $a->page['htmlhead'] .= ''.PHP_EOL; + $a->page['htmlhead'] .= ''; $speeds = array(); $times = array(); $mintime = time(); @@ -267,23 +280,82 @@ function health_details($a, $id) } $a->page['htmlhead'] .= ''; + } + + //Get scrape speed data. + $r = q( + "SELECT AVG(`total_time`) as `avg_time`, date(`dt_performed`) as `date` FROM `site-scrape` + WHERE `site_health_id` = %u + AND `dt_performed` > '%s' + GROUP BY `date`", + intval($site['id']), + $maxDate + ); + if($r && count($r)){ + //Include graphael line charts. + $a->page['htmlhead'] .= ''.PHP_EOL; + $a->page['htmlhead'] .= ''.PHP_EOL; + $a->page['htmlhead'] .= ''; + $speeds = array(); + $times = array(); + $mintime = time(); + foreach($r as $row){ + $speeds[] = $row['avg_time']; + $time = strtotime($row['date']); + $times[] = $time; + if($mintime > $time) $mintime = $time; + } + for($i=0; $i < count($times); $i++){ + $times[$i] -= $mintime; + $times[$i] = floor($times[$i] / (24*3600)); + } + $a->page['htmlhead'] .= + ''; } @@ -298,6 +370,7 @@ function health_details($a, $id) $tpl .= file_get_contents('view/health_details.tpl'); return replace_macros($tpl, array( '$name' => $site['name'], + '$redirectStatement' => $redirectStatement, '$policy' => $policy, '$site_info' => $site['info'], '$base_url' => $site['base_url'], @@ -320,5 +393,3 @@ function health_details($a, $id) '$avg_photo_time' => round($site['avg_photo_time']), '$avg_submit_time' => round($site['avg_submit_time']) )); - -} \ No newline at end of file diff --git a/mod/help.php b/mod/help.php new file mode 100644 index 00000000..db14e7a6 --- /dev/null +++ b/mod/help.php @@ -0,0 +1,10 @@ +output(); + } +} + diff --git a/mod/home.php b/mod/home.php old mode 100755 new mode 100644 index 3c437657..28c9432c --- a/mod/home.php +++ b/mod/home.php @@ -1,14 +1,17 @@ get_baseurl() . "/profile/" . $r[0]['nickname'] ); - else - goaway( $a->get_baseurl() . "/register" ); +use Friendica\Directory\Rendering\View; +use Friendica\Directory\Helper\Profile as ProfileHelper; +if(! function_exists('home_content')) { +function home_content(&$a) { + + $profiles = q("SELECT * FROM profile WHERE comm=1 AND LENGTH(pdesc)>0 ORDER BY RAND() LIMIT 3"); + + $view = new View('homepage', 'minimal'); + $view->addHelper('photoUrl', ProfileHelper::get('photoUrl')); + $view->output(array( + 'profiles' => $profiles + )); + }} - - diff --git a/mod/login.php b/mod/login.php old mode 100755 new mode 100644 diff --git a/mod/lsearch.php b/mod/lsearch.php old mode 100755 new mode 100644 diff --git a/mod/moderate.php b/mod/moderate.php old mode 100755 new mode 100644 index 0d1b9879..52ffe94b --- a/mod/moderate.php +++ b/mod/moderate.php @@ -107,9 +107,6 @@ function moderate_content(&$a) { $details .= $rr['country-name']; } - if(strlen($rr['gender'])) - $details .= '
' . t('Gender: ') . t($rr['gender']) ; - $o .= replace_macros($tpl,array( '$id' => $rr['id'], '$mod' => '', @@ -120,8 +117,7 @@ function moderate_content(&$a) { '$star' => '', '$pclass' => (($rr['comm']) ? ' group' : ''), '$pgroup' => (($rr['comm']) ? '
' . t('[Public Group]') . '
' : ''), - '$details' => $pdesc . $details, - '$marital' => ((strlen($rr['marital'])) ? '
Status: ' . $rr['marital'] . '
' : '') + '$details' => $pdesc . $details diff --git a/mod/msearch.php b/mod/msearch.php old mode 100755 new mode 100644 diff --git a/mod/opensearch.php b/mod/opensearch.php old mode 100755 new mode 100644 diff --git a/mod/photo.php b/mod/photo.php old mode 100755 new mode 100644 index 31d8c6cc..c832a9e9 --- a/mod/photo.php +++ b/mod/photo.php @@ -1,9 +1,12 @@ argc) { +require_once 'datetime.php'; + +function photo_init(App $a) +{ + switch ($a->argc) { case 2: $photo = $a->argv[1]; break; @@ -14,18 +17,36 @@ function photo_init(&$a) { $profile_id = str_replace('.jpg', '', $photo); - $r = q("SELECT * FROM `photo` WHERE `profile-id` = %d LIMIT 1", - intval($profile_id) - ); - if(count($r)) { + $r = q('SELECT * FROM `photo` WHERE `profile-id` = %d LIMIT 1', intval($profile_id)); + + if (count($r)) { $data = $r[0]['data']; } - if(x($data) === false || (! strlen($data))) { - $data = file_get_contents('images/default-profile-sm.jpg'); + + if (x($data) === false || (!strlen($data))) { + $data = file_get_contents('images/default-profile-sm.jpg'); } - header("Content-type: image/jpeg"); - header('Expires: ' . datetime_convert('UTC','UTC', 'now + 1 week', 'D, d M Y H:i:s' . ' GMT')); + //Enable async process from here. + session_write_close(); + + //Try and cache our result. + $etag = md5($data); + header('Etag: ' . $etag); + header('Expires: ' . datetime_convert('UTC', 'UTC', 'now + 1 week', 'D, d M Y H:i:s' . ' GMT')); + header('Cache-Control: max-age=' . intval(7 * 24 * 3600)); + + if (function_exists('header_remove')) { + header_remove('Pragma'); + header_remove('pragma'); + } + + if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] == $etag) { + header('HTTP/1.1 304 Not Modified'); + exit; + } + + header('Content-type: image/jpeg'); echo $data; exit; -} \ No newline at end of file +} diff --git a/mod/pubsites.php b/mod/pubsites.php old mode 100755 new mode 100644 diff --git a/mod/redir.php b/mod/redir.php old mode 100755 new mode 100644 diff --git a/mod/search.php b/mod/search.php new file mode 100644 index 00000000..9847f14b --- /dev/null +++ b/mod/search.php @@ -0,0 +1,97 @@ +argc >= 2) { + $filter = $a->argv[1]; + switch ($filter) { + + case 'forums': + $community = 1; + break; + + case 'people': + $community = 0; + break; + + default: + $community = null; + $filter = null; + break; + } + } + + $alpha = false; + if (x($_GET, 'alpha') == 1) + $alpha = true; + + //Query + $search = ((x($_GET, 'query')) ? notags(trim($_GET['query'])) : ''); + + if (empty($search)) { + goaway('/home'); + } + + if ($search) { + $alpha = true; + } + + //Run our query. + if ($search) { + $search = dbesc($search . '*'); + } + + $sql_extra = ((strlen($search)) ? " AND MATCH (`name`, `pdesc`, `homepage`, `locality`, `region`, `country-name`, `tags` ) + AGAINST ('$search' IN BOOLEAN MODE) " : ''); + + if (!is_null($community)) { + $sql_extra .= ' AND `comm` = ' . intval($community) . ' '; + } + + $sql_extra = str_replace('%', '%%', $sql_extra); + + $total = 0; + $r = q("SELECT COUNT(*) AS `total` FROM `profile` WHERE `censored` = 0 $sql_extra "); + if (count($r)) { + $total = $r[0]['total']; + $a->set_pager_total($total); + } + + if ($alpha) { + $order = ' ORDER BY `name` ASC '; + } else { + $order = ' ORDER BY `updated` DESC, `id` DESC '; + } + + $r = q("SELECT * FROM `profile` WHERE `censored` = 0 $sql_extra $order LIMIT %d , %d ", + intval($a->pager['start']), + intval($a->pager['itemspage']) + ); + + //Show results. + $view = new View('search'); + + $view->addHelper('paginate', function() use ($a) { + return paginate($a); + }); + $view->addHelper('photoUrl', ProfileHelper::get('photoUrl')); + $view->addHelper('filterAllUrl', SearchHelper::get('filterAllUrl')); + $view->addHelper('filterPeopleUrl', SearchHelper::get('filterPeopleUrl')); + $view->addHelper('filterForumsUrl', SearchHelper::get('filterForumsUrl')); + + $view->output(array( + 'total' => number_format($total), + 'results' => $r, + 'filter' => $filter, + 'query' => x($_GET, 'query') ? $_GET['query'] : '' + )); +} diff --git a/mod/servers.php b/mod/servers.php new file mode 100644 index 00000000..8ad4776a --- /dev/null +++ b/mod/servers.php @@ -0,0 +1,127 @@ + $v) + { + + //Stop at unhealthy sites. + $site = $site_healths[$k]; + + if($site['health_score'] <= 20) break; + + //Skip small sites. + $users = $sites[$k]; + if($users < 5) continue; + + //Add health score name and user count. + $site['health_score_name'] = health_score_to_name($site['health_score']); + $site['users'] = $users; + + //Figure out what this server supports. + $plugins = explode("\r\n", $site['plugins']); + $site['plugins'] = $plugins; + $hasPlugin = function(array $input)use($plugins){ + return !!count(array_intersect($input, $plugins)); + }; + + $site['supports'] = array( + 'HTTPS' => $site['ssl_state'] == 1, + 'Twitter' => $hasPlugin(array('buffer', 'twitter')), + 'Facebook' => $hasPlugin(array('buffer')), + 'Google+' => $hasPlugin(array('buffer', 'gpluspost')), + 'RSS/Atom' => true, //Built-in. + 'Diaspora*' => $hasPlugin(array('diaspora')), + 'pump.io' => $hasPlugin(array('pumpio')), + 'StatusNet' => $hasPlugin(array('statusnet')), + 'Tumblr' => $hasPlugin(array('tumblr')), + 'Blogger' => $hasPlugin(array('blogger')), + 'Dreamwidth' => $hasPlugin(array('dwpost')), + 'Wordpress' => $hasPlugin(array('wppost')), + 'LiveJournal' => $hasPlugin(array('ljpost')), + 'Insanejournal' => $hasPlugin(array('ijpost')), + 'Libertree' => $hasPlugin(array('libertree')) + ); + + //Subset of the full support list, to show popular items. + $site['popular_supports'] = array( + 'HTTPS' => $site['supports']['HTTPS'], + 'Twitter' => $site['supports']['Twitter'], + 'Google+' => $site['supports']['Google+'], + 'Wordpress' => $site['supports']['Wordpress'] + ); + + //For practical usage. + $site['less_popular_supports'] = array_diff_assoc($site['supports'], $site['popular_supports']); + + //Get the difference. + $site['supports_more'] = 0; + foreach ($site['supports'] as $key => $value){ + if($value && !array_key_exists($key, $site['popular_supports'])){ + $site['supports_more']++; + } + } + + //Push to results. + $public_sites[] = $site; + + //Count the result. + $total ++; + + } + + //In case we asked for a surprise, pick a random one from the top 10! :D + if($a->argc > 1 && $a->argv[1] == 'surprise'){ + $max = min(count($public_sites), 10); + $i = mt_rand(0, $max-1); + $surpriseSite = $public_sites[$i]; + header('Location:'.$surpriseSite['base_url'].'/register'); + exit; + } + + + //Show results. + $view = new View('servers'); + + $view->output(array( + 'total' => number_format($total), + 'sites' => $public_sites + )); + +} diff --git a/mod/settings.php b/mod/settings.php old mode 100755 new mode 100644 diff --git a/mod/siteinfo.php b/mod/siteinfo.php old mode 100755 new mode 100644 diff --git a/mod/sites.php b/mod/sites.php old mode 100755 new mode 100644 diff --git a/mod/stats.php b/mod/stats.php new file mode 100644 index 00000000..866b33cd --- /dev/null +++ b/mod/stats.php @@ -0,0 +1,10 @@ +output(); + } +} + diff --git a/mod/submit.php b/mod/submit.php old mode 100755 new mode 100644 diff --git a/mod/updatesites.php b/mod/updatesites.php old mode 100755 new mode 100644 diff --git a/mod/viewcontacts.php b/mod/viewcontacts.php old mode 100755 new mode 100644 diff --git a/mod/wall_upload.php b/mod/wall_upload.php old mode 100755 new mode 100644 diff --git a/mod/xrd.php b/mod/xrd.php old mode 100755 new mode 100644 diff --git a/src/App.php b/src/App.php new file mode 100644 index 00000000..8540892a --- /dev/null +++ b/src/App.php @@ -0,0 +1,123 @@ +config = array(); + $this->page = array(); + $this->pager = array(); + + $this->scheme = ((isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'])) ? 'https' : 'http'); + $this->hostname = str_replace('www.', '', $_SERVER['SERVER_NAME']); + set_include_path(get_include_path() + . PATH_SEPARATOR . "include/$this->hostname" + . PATH_SEPARATOR . 'include' + . PATH_SEPARATOR . '.'); + + if (substr($_SERVER['QUERY_STRING'], 0, 2) == "q=") { + $_SERVER['QUERY_STRING'] = substr($_SERVER['QUERY_STRING'], 2); + } + + $this->query_string = $_SERVER['QUERY_STRING']; + + $q = isset($_GET['q']) ? $_GET['q'] : ''; + $this->cmd = trim($q, '/'); + + $this->argv = explode('/', $this->cmd); + $this->argc = count($this->argv); + if ((array_key_exists('0', $this->argv)) && strlen($this->argv[0])) { + $this->module = $this->argv[0]; + } else { + $this->module = 'directory'; + } + + $this->pager['page'] = ((x($_GET, 'page')) ? $_GET['page'] : 1); + $this->pager['itemspage'] = 50; + $this->pager['start'] = ($this->pager['page'] * $this->pager['itemspage']) - $this->pager['itemspage']; + $this->pager['total'] = 0; + } + + public function get_baseurl($ssl = false) + { + if (strlen($this->baseurl)) { + return $this->baseurl; + } + + $this->baseurl = (($ssl) ? 'https' : $this->scheme) . "://" . $this->hostname + . ((isset($this->path) && strlen($this->path)) ? '/' . $this->path : ''); + return $this->baseurl; + } + + public function set_baseurl($url) + { + $this->baseurl = $url; + $this->hostname = basename($url); + } + + public function get_hostname() + { + return $this->hostname; + } + + public function set_hostname($h) + { + $this->hostname = $h; + } + + public function set_path($p) + { + $this->path = ltrim(trim($p), '/'); + } + + public function get_path() + { + return $this->path; + } + + public function set_pager_total($n) + { + $this->pager['total'] = intval($n); + } + + public function set_pager_itemspage($n) + { + $this->pager['itemspage'] = intval($n); + $this->pager['start'] = ($this->pager['page'] * $this->pager['itemspage']) - $this->pager['itemspage']; + } + + public function init_pagehead() + { + if (file_exists("view/head.tpl")) { + $s = file_get_contents("view/head.tpl"); + } + $this->page['htmlhead'] = replace_macros($s, array( + '$baseurl' => $this->get_baseurl() + )); + } +} \ No newline at end of file diff --git a/src/Example/Hello.php b/src/Example/Hello.php new file mode 100644 index 00000000..d45fbf92 --- /dev/null +++ b/src/Example/Hello.php @@ -0,0 +1,10 @@ +{$name}; + } + + public function __construct() + { + global $a; + $this->app = $a; + } + + //Provides access to a wrapper for your helper functions. + public function __get($name) + { + if (!method_exists($this, $name)) { + throw new OutOfBoundsException("Helper method '$name' does not exist on " . get_class($this)); + } + + $helper = $this; + $method = new ReflectionMethod($this, $name); + return function()use($method, $helper) { + $arguments = func_get_args(); + return $method->invokeArgs($helper, $arguments); + }; + } +} diff --git a/src/Helper/Profile.php b/src/Helper/Profile.php new file mode 100644 index 00000000..7fca5366 --- /dev/null +++ b/src/Helper/Profile.php @@ -0,0 +1,16 @@ +app->get_baseurl() . '/photo/' . $profileId; + } + +} \ No newline at end of file diff --git a/src/Helper/Search.php b/src/Helper/Search.php new file mode 100644 index 00000000..f33ef552 --- /dev/null +++ b/src/Helper/Search.php @@ -0,0 +1,26 @@ +app->get_baseurl() . '/search?query=' . urlencode($query); + } + + public function filterPeopleUrl($query) + { + return $this->app->get_baseurl() . '/search/people?query=' . urlencode($query); + } + + public function filterForumsUrl($query) + { + return $this->app->get_baseurl() . '/search/forums?query=' . urlencode($query); + } + +} \ No newline at end of file diff --git a/src/Rendering/View.php b/src/Rendering/View.php new file mode 100644 index 00000000..5b6d87f7 --- /dev/null +++ b/src/Rendering/View.php @@ -0,0 +1,109 @@ +helpers; + } + + public function addHelper($name, Closure $helper) + { + $this->helpers[$name] = $helper; + } + + public function getView(){ + return $this->view; + } + + public function setView($value){ + $this->view = $value; + } + + public function getLayout(){ + return $this->layout; + } + + public function setLayout($value){ + $this->layout = $value; + } + + public function __construct($view=null, $layout="default") + { + + $this->view = $view; + $this->layout = $layout; + $this->helpers = array(); + + } + + public function render(array $data=array()) + { + + //First the outer view. + $view = self::getViewPath($this->view); + $viewContent = $this->encapsulatedRequire($view, $data); + + //Then the layout, including the view as $content. + $data['content'] = $viewContent; + $layout = self::getLayoutPath($this->layout); + return $this->encapsulatedRequire($layout, $data); + + } + + public function output(array $data=array()) + { + + header("Content-type: text/html; charset=utf-8"); + echo $this->render($data); + exit; + + } + + public function encapsulatedRequire($filename, array $data=null) + { + + //This will provide our variables on the global scope. + $call = function($__FILE__, $__VARS__){ + extract($__VARS__, EXTR_SKIP); + require $__FILE__; + }; + + //Use our current data as fallback. + if(!is_array($data)){ + $data = $this->currentData; + } + + //This will add the helper class to $this. + $helpers = new ViewHelpers($this, $data); + $call = $call->bindTo($helpers, get_class($helpers)); + + //Run and return the value. + ob_start(); + $call($filename, $data); + return ob_get_clean(); + + } + +} \ No newline at end of file diff --git a/src/Rendering/ViewHelpers.php b/src/Rendering/ViewHelpers.php new file mode 100644 index 00000000..1ee0c652 --- /dev/null +++ b/src/Rendering/ViewHelpers.php @@ -0,0 +1,59 @@ +view = $view; + $this->contextData = $contextData; + } + + public function view($name, array $overrides=null) + { + + $data = $this->contextData; + + if(is_array($overrides)){ + $data = array_merge($data, $overrides); + } + + return $this->view->encapsulatedRequire(View::getViewPath($name), $data); + + } + + public function layout($name, array $overrides=null) + { + + $data = $this->contextData; + + if(is_array($overrides)){ + $data = array_merge($data, $overrides); + } + + return $this->view->encapsulatedRequire(View::getLayoutPath($name), $data); + + } + + public function __call($name, $arguments) + { + + $helpers = $this->view->getHelpers(); + + if(array_key_exists($name, $helpers)){ + return call_user_func_array($helpers[$name], $arguments); + } + + throw new BadMethodCallException("Helper method '$name' does not exist or is not added."); + + } + +} \ No newline at end of file diff --git a/src/templates/layout/_navigation.php b/src/templates/layout/_navigation.php new file mode 100644 index 00000000..bddaf155 --- /dev/null +++ b/src/templates/layout/_navigation.php @@ -0,0 +1,10 @@ + + \ No newline at end of file diff --git a/src/templates/layout/_searcher.php b/src/templates/layout/_searcher.php new file mode 100644 index 00000000..baf1fe95 --- /dev/null +++ b/src/templates/layout/_searcher.php @@ -0,0 +1,7 @@ + +
+ + + +
+
diff --git a/src/templates/layout/_topBar.php b/src/templates/layout/_topBar.php new file mode 100644 index 00000000..3c698849 --- /dev/null +++ b/src/templates/layout/_topBar.php @@ -0,0 +1,14 @@ +
+ + +

+ Friendica    
    Directory +

+
+ + layout('_searcher'); ?> + + layout('_navigation'); ?> + +
+
\ No newline at end of file diff --git a/src/templates/layout/default.php b/src/templates/layout/default.php new file mode 100644 index 00000000..ccac1ae3 --- /dev/null +++ b/src/templates/layout/default.php @@ -0,0 +1,5 @@ +layout('minimal', array( + 'topBar' => $this->layout('_topBar') +)); diff --git a/src/templates/layout/minimal.php b/src/templates/layout/minimal.php new file mode 100644 index 00000000..8044d640 --- /dev/null +++ b/src/templates/layout/minimal.php @@ -0,0 +1,22 @@ + + + + + + + + Friendica Directory + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/templates/view/_profile.php b/src/templates/view/_profile.php new file mode 100644 index 00000000..46d143d0 --- /dev/null +++ b/src/templates/view/_profile.php @@ -0,0 +1,37 @@ +
+ +
+ +
+ +

+ +
+ + + + + + + +
+ +
+ + + + # + + +
+ +
+ +
\ No newline at end of file diff --git a/src/templates/view/_site.php b/src/templates/view/_site.php new file mode 100644 index 00000000..b5333b8f --- /dev/null +++ b/src/templates/view/_site.php @@ -0,0 +1,40 @@ +
+
+ + + + +
+ +   + + +
+
+ users, + admin: +
+

+
+
+ Features + $value): if(!$value) continue; ?> + +
+ , Grade:   √ +
+ + 0): ?> + + $value){ + if(!$value) continue; + $more .= $key.PHP_EOL; + } + ?> + + more + +
+
diff --git a/src/templates/view/directory.php b/src/templates/view/directory.php new file mode 100644 index 00000000..19d5f240 --- /dev/null +++ b/src/templates/view/directory.php @@ -0,0 +1,35 @@ + + +
+ +
+
+ + + view('_profile', array('profile' => $profile)); + } + ?> + + + + +

There were no results

+ + + +
+ paginate();?> +
+
diff --git a/src/templates/view/help.php b/src/templates/view/help.php new file mode 100644 index 00000000..d7f6cbe3 --- /dev/null +++ b/src/templates/view/help.php @@ -0,0 +1,9 @@ +
+
+

Help

+

Registering a Friendica account (with an existing server)

+

Setting up a Friendica server

+

Finding people - Getting new friends

+

More help

+
+
\ No newline at end of file diff --git a/src/templates/view/homepage.php b/src/templates/view/homepage.php new file mode 100644 index 00000000..a1d7f0c3 --- /dev/null +++ b/src/templates/view/homepage.php @@ -0,0 +1,25 @@ +layout('_navigation'); ?> + +
+ +

+ Friendica    
    Directory +

+ + layout('_searcher'); ?> + +

+ Friendica is a decentralized social network. + And this is a directory to find people on this network. + If you want to create your own account on a public server, have a look + on our Public servers listing. +

+ +
+

Random groups

+ view('_profile', array('profile'=>$profile)); + ?> +
+ +
diff --git a/src/templates/view/search.php b/src/templates/view/search.php new file mode 100644 index 00000000..f3cc544d --- /dev/null +++ b/src/templates/view/search.php @@ -0,0 +1,29 @@ + + +
+

Results for "" ()

+
+ + + view('_profile', array('profile' => $profile)); + } + ?> + + + + +

There were no results

+ + +
+ paginate();?> +
diff --git a/src/templates/view/servers.php b/src/templates/view/servers.php new file mode 100644 index 00000000..4cc8f6dc --- /dev/null +++ b/src/templates/view/servers.php @@ -0,0 +1,24 @@ +
+
+

Public servers

+

+ If you are not interested in hosting your own server, you can still use Friendica. + Here are some public server run by enthousiasts that you can join. + We recommend these based on their health. +

+

+ Keep in mind that different servers may support different features like communicating with additional networks besides Friendica. + It's best to pick the one that best suits your needs. +

+ + + +

Recommending public servers

+ view('_site', array('site'=>$site)); + ?> +
+
\ No newline at end of file diff --git a/src/templates/view/stats.php b/src/templates/view/stats.php new file mode 100644 index 00000000..a62a4e2c --- /dev/null +++ b/src/templates/view/stats.php @@ -0,0 +1,5 @@ +
+
+

Stats

+
+
diff --git a/tests/phpunit.xml b/tests/phpunit.xml new file mode 100644 index 00000000..36d1d950 --- /dev/null +++ b/tests/phpunit.xml @@ -0,0 +1,12 @@ + + + + unit/src + + + + + ../src + + + diff --git a/tests/unit/src/Example/HelloTest.php b/tests/unit/src/Example/HelloTest.php new file mode 100644 index 00000000..3e6c06a0 --- /dev/null +++ b/tests/unit/src/Example/HelloTest.php @@ -0,0 +1,23 @@ +sayHello(); + + //Check that it returns the message we expect. + $this->assertEquals("Hello world!", $output); + + } + +} \ No newline at end of file diff --git a/.htconfig.php b/util/htconfig.vagrant.php similarity index 90% rename from .htconfig.php rename to util/htconfig.vagrant.php index 6752b9cd..4c2d39fb 100644 --- a/.htconfig.php +++ b/util/htconfig.vagrant.php @@ -2,9 +2,9 @@ //MySQL host. $db_host = 'localhost'; -$db_user = 'friendica-dir'; -$db_pass = 'thisisyourpasswordbuddy'; -$db_data = 'friendica-dir'; +$db_user = 'root'; +$db_pass = 'root'; +$db_data = 'friendica_dir'; // Choose a legal default timezone. If you are unsure, use "America/Los_Angeles". // It can be changed later and only applies to timestamps for anonymous viewers. @@ -13,6 +13,14 @@ $default_timezone = 'Europe/Amsterdam'; // What is your site name? $a->config['sitename'] = "EXPERIMENTAL Friendica public directory"; +//Statistic display settings. +$a->config['stats'] = array( + + //For site health, the max age for which to display data. + 'maxDataAge' => 3600*24*30*4 //120 days = ~4 months + +); + //Settings related to the syncing feature. $a->config['syncing'] = array( @@ -46,7 +54,7 @@ $a->config['site-health'] = array( //Wait for at least ... before probing a site again. //The longer this value, the more "stable" site-healths will be over time. //Note: If a bad (negative) health site submits something, a probe will be performed regardless. - 'min_probe_delay' => 3*24*3600, // 3 days + 'min_probe_delay' => 24*3600, // 1 day //Probes get a simple /friendica/json file from the server. //Feel free to set this timeout to a very tight value. diff --git a/util/messages.po b/util/messages.po index 290c930e..e68df2ea 100644 --- a/util/messages.po +++ b/util/messages.po @@ -178,10 +178,6 @@ msgstr "" msgid "Search for: " msgstr "" -#: ../../mod/directory.php:96 ../../mod/moderate.php:109 -msgid "Gender: " -msgstr "" - #: ../../mod/directory.php:100 msgid "Flag this entry" msgstr "" diff --git a/util/run_xgettext.sh b/util/run_xgettext.sh old mode 100644 new mode 100755 diff --git a/util/vagrant_default_sync_servers.sql b/util/vagrant_default_sync_servers.sql new file mode 100644 index 00000000..4ed4e0e7 --- /dev/null +++ b/util/vagrant_default_sync_servers.sql @@ -0,0 +1,5 @@ +-- +-- Sync targets to poulate the development directory +-- +INSERT INTO `friendica_dir`.`sync-targets` (`base_url`, `pull`, `push`, `dt_last_pull`) VALUES ('dir.friendica.com', 1, 0, ''); +INSERT INTO `friendica_dir`.`sync-targets` (`base_url`, `pull`, `push`, `dt_last_pull`) VALUES ('dir.friendi.ca', 1, 0, ''); \ No newline at end of file diff --git a/util/vagrant_provision.sh b/util/vagrant_provision.sh new file mode 100644 index 00000000..d9013e92 --- /dev/null +++ b/util/vagrant_provision.sh @@ -0,0 +1,84 @@ +#!/bin/bash +#Script to setup the vagrant instance for running friendica +# +#DO NOT RUN on your physical machine as this won't be of any use +#and f.e. deletes your /var/www/ folder! +echo "Friendica configuration settings" +sudo apt-get update + +#Selfsigned cert +echo ">>> Installing *.xip.io self-signed SSL" +SSL_DIR="/etc/ssl/xip.io" +DOMAIN="*.xip.io" +PASSPHRASE="vaprobash" +SUBJ=" +C=US +ST=Connecticut +O=Vaprobash +localityName=New Haven +commonName=$DOMAIN +organizationalUnitName= +emailAddress= +" +sudo mkdir -p "$SSL_DIR" +sudo openssl genrsa -out "$SSL_DIR/xip.io.key" 4096 +sudo openssl req -new -subj "$(echo -n "$SUBJ" | tr "\n" "/")" -key "$SSL_DIR/xip.io.key" -out "$SSL_DIR/xip.io.csr" -passin pass:$PASSPHRASE +sudo openssl x509 -req -days 365 -in "$SSL_DIR/xip.io.csr" -signkey "$SSL_DIR/xip.io.key" -out "$SSL_DIR/xip.io.crt" + + +#Install apache2 +echo ">>> Installing Apache2 webserver" +sudo apt-get install -y apache2 +sudo a2enmod rewrite actions ssl +sudo cp /vagrant/util/vagrant_vhost.sh /usr/local/bin/vhost +sudo chmod guo+x /usr/local/bin/vhost +sudo vhost -s 192.168.33.10.xip.io -d /var/www -p /etc/ssl/xip.io -c xip.io -a friendica.dev +sudo a2dissite 000-default +sudo service apache2 restart + +#Install php +echo ">>> Installing PHP5" +sudo apt-get install -y php5 libapache2-mod-php5 php5-cli php5-mysql php5-curl php5-gd +sudo service apache2 restart + + +#Install mysql +echo ">>> Installing Mysql" +sudo debconf-set-selections <<< "mysql-server mysql-server/root_password password root" +sudo debconf-set-selections <<< "mysql-server mysql-server/root_password_again password root" +sudo apt-get install -qq mysql-server +# enable remote access +# setting the mysql bind-address to allow connections from everywhere +sed -i "s/bind-address.*/bind-address = 0.0.0.0/" /etc/mysql/my.cnf +# adding grant privileges to mysql root user from everywhere +# thx to http://stackoverflow.com/questions/7528967/how-to-grant-mysql-privileges-in-a-bash-script for this +MYSQL=`which mysql` +Q1="GRANT ALL ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;" +Q2="FLUSH PRIVILEGES;" +SQL="${Q1}${Q2}" +$MYSQL -uroot -proot -e "$SQL" +service mysql restart + +#make the vagrant directory the docroot +sudo rm -rf /var/www/ +sudo ln -fs /vagrant /var/www + +# initial config file for friendica in vagrant +cp /vagrant/util/htconfig.vagrant.php /vagrant/.htconfig.php + +# create the friendica database +echo "create database friendica_dir" | mysql -u root -proot +# import test database +$MYSQL -uroot -proot friendica_dir < /vagrant/dfrndir.sql +$MYSQL -uroot -proot friendica_dir < /vagrant/util/vagrant_default_sync_servers.sql + +#Install composer +cd /vagrant +curl -sS https://getcomposer.org/installer | php +php composer.phar install + +#create cronjob +echo "*/30 * * * * www-data cd /vagrant; php include/cron_maintain.php" >> friendicacron +echo "*/5 * * * * www-data cd /vagrant; php include/cron_sync.php" >> friendicacron +sudo crontab friendicacron +sudo rm friendicacron \ No newline at end of file diff --git a/util/vagrant_vhost.sh b/util/vagrant_vhost.sh new file mode 100644 index 00000000..f26d8e14 --- /dev/null +++ b/util/vagrant_vhost.sh @@ -0,0 +1,177 @@ +#!/usr/bin/env bash + +# Run this as sudo! +# I move this file to /usr/local/bin/vhost and run command 'vhost' from anywhere, using sudo. + +# +# Show Usage, Output to STDERR +# +function show_usage { +cat <<- _EOF_ + +Create a new vHost in Ubuntu Server +Assumes /etc/apache2/sites-available and /etc/apache2/sites-enabled setup used + + -d DocumentRoot - i.e. /var/www/yoursite + -h Help - Show this menu. + -s ServerName - i.e. example.com or sub.example.com + -a ServerAlias - i.e. *.example.com or another domain altogether + -p File path to the SSL certificate. Directories only, no file name. + If using an SSL Certificate, also creates a port :443 vhost as well. + This *ASSUMES* a .crt and a .key file exists + at file path /provided-file-path/your-server-or-cert-name.[crt|key]. + Otherwise you can except Apache errors when you reload Apache. + Ensure Apache's mod_ssl is enabled via "sudo a2enmod ssl". + -c Certificate filename. "xip.io" becomes "xip.io.key" and "xip.io.crt". + + Example Usage. Serve files from /var/www/xip.io at http(s)://192.168.33.10.xip.io + using ssl files from /etc/ssl/xip.io/xip.io.[key|crt] + sudo vhost -d /var/www/xip.io -s 192.168.33.10.xip.io -p /etc/ssl/xip.io -c xip.io + +_EOF_ +exit 1 +} + + +# +# Output vHost skeleton, fill with userinput +# To be outputted into new file +# +function create_vhost { +cat <<- _EOF_ + + ServerAdmin webmaster@localhost + ServerName $ServerName + $ServerAlias + + DocumentRoot $DocumentRoot + + + + Options Indexes FollowSymLinks MultiViews + AllowOverride All + Order allow,deny + allow from all + + + ErrorLog \${APACHE_LOG_DIR}/$ServerName-error.log + + # Possible values include: debug, info, notice, warn, error, crit, + # alert, emerg. + LogLevel warn + + CustomLog \${APACHE_LOG_DIR}/$ServerName-access.log combined + + + +_EOF_ +} + +function create_ssl_vhost { +cat <<- _EOF_ + + ServerAdmin webmaster@localhost + ServerName $ServerName + $ServerAlias + + DocumentRoot $DocumentRoot + + + Options Indexes FollowSymLinks MultiViews + AllowOverride All + Order allow,deny + allow from all + + + ErrorLog \${APACHE_LOG_DIR}/$ServerName-error.log + + # Possible values include: debug, info, notice, warn, error, crit, + # alert, emerg. + LogLevel warn + + CustomLog \${APACHE_LOG_DIR}/$ServerName-access.log combined + + SSLEngine on + + SSLCertificateFile $CertPath/$CertName.crt + SSLCertificateKeyFile $CertPath/$CertName.key + + + SSLOptions +StdEnvVars + + + BrowserMatch "MSIE [2-6]" \\ + nokeepalive ssl-unclean-shutdown \\ + downgrade-1.0 force-response-1.0 + # MSIE 7 and newer should be able to use keepalive + BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown + +_EOF_ +} + +#Sanity Check - are there two arguments with 2 values? +if [ "$#" -lt 4 ]; then + show_usage +fi + +CertPath="" + +#Parse flags +while getopts "d:s:a:p:c:h" OPTION; do + case $OPTION in + h) + show_usage + ;; + d) + DocumentRoot=$OPTARG + ;; + s) + ServerName=$OPTARG + ;; + a) + Alias=$OPTARG + ;; + p) + CertPath=$OPTARG + ;; + c) + CertName=$OPTARG + ;; + *) + show_usage + ;; + esac +done + +# If alias is set: +if [ "$Alias" != "" ]; then + ServerAlias="ServerAlias "$Alias +else + ServerAlias="" +fi + +# If CertName doesn't get set, set it to ServerName +if [ "$CertName" == "" ]; then + CertName=$ServerName +fi + +if [ ! -d $DocumentRoot ]; then + mkdir -p $DocumentRoot + #chown USER:USER $DocumentRoot #POSSIBLE IMPLEMENTATION, new flag -u ? +fi + +if [ -f "$DocumentRoot/$ServerName.conf" ]; then + echo 'vHost already exists. Aborting' + show_usage +else + create_vhost > /etc/apache2/sites-available/${ServerName}.conf + + # Add :443 handling + if [ "$CertPath" != "" ]; then + create_ssl_vhost >> /etc/apache2/sites-available/${ServerName}.conf + fi + + # Enable Site + cd /etc/apache2/sites-available/ && a2ensite ${ServerName}.conf + service apache2 reload +fi \ No newline at end of file diff --git a/view/#head.tpl# b/view/#head.tpl# deleted file mode 100755 index 4eb44e8c..00000000 --- a/view/#head.tpl# +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - diff --git a/view/acl_selectors.php b/view/acl_selectors.php old mode 100755 new mode 100644 diff --git a/view/album_edit.tpl b/view/album_edit.tpl old mode 100755 new mode 100644 diff --git a/view/atom_cmnt.tpl b/view/atom_cmnt.tpl old mode 100755 new mode 100644 diff --git a/view/atom_feed.tpl b/view/atom_feed.tpl old mode 100755 new mode 100644 diff --git a/view/atom_item.tpl b/view/atom_item.tpl old mode 100755 new mode 100644 diff --git a/view/atom_mail.tpl b/view/atom_mail.tpl old mode 100755 new mode 100644 diff --git a/view/atom_tomb.tpl b/view/atom_tomb.tpl old mode 100755 new mode 100644 diff --git a/view/cmnt_received_eml.tpl b/view/cmnt_received_eml.tpl old mode 100755 new mode 100644 diff --git a/view/comment_item.tpl b/view/comment_item.tpl old mode 100755 new mode 100644 diff --git a/view/contact_edit.tpl b/view/contact_edit.tpl old mode 100755 new mode 100644 diff --git a/view/contact_selectors.php b/view/contact_selectors.php old mode 100755 new mode 100644 diff --git a/view/contact_self.tpl b/view/contact_self.tpl old mode 100755 new mode 100644 diff --git a/view/contact_template.tpl b/view/contact_template.tpl old mode 100755 new mode 100644 diff --git a/view/contacts-top.tpl b/view/contacts-top.tpl old mode 100755 new mode 100644 diff --git a/view/cropbody.tpl b/view/cropbody.tpl old mode 100755 new mode 100644 diff --git a/view/crophead.tpl b/view/crophead.tpl old mode 100755 new mode 100644 diff --git a/view/custom_tinymce.css b/view/custom_tinymce.css old mode 100755 new mode 100644 diff --git a/view/default.php b/view/default.php old mode 100755 new mode 100644 index 25d8ea1d..7f86257a --- a/view/default.php +++ b/view/default.php @@ -1,15 +1,15 @@ - <?php echo $page['title'] ?> - + <?php echo isset($page['title']) ? $page['title'] : '' ?> + -
- - -
-
+
+ + +
+
diff --git a/view/dfrn_req_confirm.tpl b/view/dfrn_req_confirm.tpl old mode 100755 new mode 100644 diff --git a/view/dfrn_request.tpl b/view/dfrn_request.tpl old mode 100755 new mode 100644 diff --git a/view/directory_header.tpl b/view/directory_header.tpl old mode 100755 new mode 100644 index 1ac049a3..2431a5c4 --- a/view/directory_header.tpl +++ b/view/directory_header.tpl @@ -5,13 +5,11 @@ $finding -
-
- - - -
+
+ + +lear">$clear +
- diff --git a/view/directory_item.tpl b/view/directory_item.tpl old mode 100755 new mode 100644 index d840d29f..c4dc4ec3 --- a/view/directory_item.tpl +++ b/view/directory_item.tpl @@ -13,6 +13,5 @@ $star $pgroup
$details
-$marital
\ No newline at end of file diff --git a/view/group_drop.tpl b/view/group_drop.tpl old mode 100755 new mode 100644 diff --git a/view/group_edit.tpl b/view/group_edit.tpl old mode 100755 new mode 100644 diff --git a/view/group_new.tpl b/view/group_new.tpl old mode 100755 new mode 100644 diff --git a/view/head.tpl b/view/head.tpl old mode 100755 new mode 100644 index 0389e64f..6a6d9c86 --- a/view/head.tpl +++ b/view/head.tpl @@ -3,13 +3,14 @@ - + - - + + - - diff --git a/view/health_details.tpl b/view/health_details.tpl index 7d6f694e..45b5b057 100644 --- a/view/health_details.tpl +++ b/view/health_details.tpl @@ -1,12 +1,13 @@

$name
- $base_url + $base_url

« Back to index

General information

+
$redirectStatement
$users users
$policy registration policy
Friendica $version
@@ -23,13 +24,15 @@

Performance information

+

Based on the last 120 days.

Probe speed: $avg_probe_timems
Photo speed: $avg_photo_timems
Profile speed: $avg_profile_timems
Scrape speed: $avg_scrape_timems
Submit speed: $avg_submit_timems
- $no_scrape_support + $no_scrape_support
+ Toggle raw data
-
Probe speed
-
Submit speed
+
<- older   Probe speed in ms   newer ->
+
<- older   Submit speed in ms   newer ->
diff --git a/view/htconfig.tpl b/view/htconfig.tpl old mode 100755 new mode 100644 diff --git a/view/install_db.tpl b/view/install_db.tpl old mode 100755 new mode 100644 diff --git a/view/intro_complete_eml.tpl b/view/intro_complete_eml.tpl old mode 100755 new mode 100644 diff --git a/view/intros-top.tpl b/view/intros-top.tpl old mode 100755 new mode 100644 diff --git a/view/intros.tpl b/view/intros.tpl old mode 100755 new mode 100644 diff --git a/view/jot-header.tpl b/view/jot-header.tpl old mode 100755 new mode 100644 diff --git a/view/jot-plain.tpl b/view/jot-plain.tpl old mode 100755 new mode 100644 diff --git a/view/jot-save.tpl b/view/jot-save.tpl old mode 100755 new mode 100644 diff --git a/view/jot.tpl b/view/jot.tpl old mode 100755 new mode 100644 diff --git a/view/login.tpl b/view/login.tpl old mode 100755 new mode 100644 diff --git a/view/logout.tpl b/view/logout.tpl old mode 100755 new mode 100644 diff --git a/view/lostpass.tpl b/view/lostpass.tpl old mode 100755 new mode 100644 diff --git a/view/lostpass_eml.tpl b/view/lostpass_eml.tpl old mode 100755 new mode 100644 diff --git a/view/mail_conv.tpl b/view/mail_conv.tpl old mode 100755 new mode 100644 diff --git a/view/mail_head.tpl b/view/mail_head.tpl old mode 100755 new mode 100644 diff --git a/view/mail_list.tpl b/view/mail_list.tpl old mode 100755 new mode 100644 diff --git a/view/mail_received_eml.tpl b/view/mail_received_eml.tpl old mode 100755 new mode 100644 diff --git a/view/msg-header.tpl b/view/msg-header.tpl old mode 100755 new mode 100644 diff --git a/view/osearch.tpl b/view/osearch.tpl old mode 100755 new mode 100644 diff --git a/view/passchanged_eml.tpl b/view/passchanged_eml.tpl old mode 100755 new mode 100644 diff --git a/view/photo_album.tpl b/view/photo_album.tpl old mode 100755 new mode 100644 diff --git a/view/photo_edit.tpl b/view/photo_edit.tpl old mode 100755 new mode 100644 diff --git a/view/photo_item.tpl b/view/photo_item.tpl old mode 100755 new mode 100644 diff --git a/view/photo_top.tpl b/view/photo_top.tpl old mode 100755 new mode 100644 diff --git a/view/photos_upload.tpl b/view/photos_upload.tpl old mode 100755 new mode 100644 diff --git a/view/profed_head.tpl b/view/profed_head.tpl old mode 100755 new mode 100644 diff --git a/view/profile-hide-friends.tpl b/view/profile-hide-friends.tpl old mode 100755 new mode 100644 diff --git a/view/profile-in-directory.tpl b/view/profile-in-directory.tpl old mode 100755 new mode 100644 diff --git a/view/profile.php b/view/profile.php index 64f8f410..efaf6019 100644 --- a/view/profile.php +++ b/view/profile.php @@ -42,19 +42,11 @@ - -
Gender:
- - -
- -
Status:
-
Homepage:
diff --git a/view/profile_advanced.php b/view/profile_advanced.php old mode 100755 new mode 100644 index 73a15540..928fa313 --- a/view/profile_advanced.php +++ b/view/profile_advanced.php @@ -19,16 +19,6 @@ $o .= <<< EOT EOT; } -if($a->profile['gender']) { -$o .= <<< EOT -
-
Gender:
-
{$a->profile['gender']}
-
-
-EOT; -} - if($a->profile['dob']) { $o .= <<< EOT
@@ -57,16 +47,6 @@ $o .= <<< EOT EOT; } -if($a->profile['marital']) { -$o .= <<< EOT -
-
Status:
-
{$a->profile['marital']}
-
-
-EOT; -} - if($a->profile['sexual']) { $o .= <<< EOT
diff --git a/view/profile_edit.tpl b/view/profile_edit.tpl old mode 100755 new mode 100644 index 44ca3922..6f13b380 --- a/view/profile_edit.tpl +++ b/view/profile_edit.tpl @@ -29,12 +29,6 @@ $default
-
- -$gender -
-
-
@@ -94,12 +88,6 @@ $hide_friends
-
- -$marital -
-
-
$sexual diff --git a/view/profile_entry.tpl b/view/profile_entry.tpl old mode 100755 new mode 100644 diff --git a/view/profile_entry_default.tpl b/view/profile_entry_default.tpl old mode 100755 new mode 100644 diff --git a/view/profile_listing_header.tpl b/view/profile_listing_header.tpl old mode 100755 new mode 100644 diff --git a/view/profile_photo.tpl b/view/profile_photo.tpl old mode 100755 new mode 100644 diff --git a/view/profile_selectors.php b/view/profile_selectors.php old mode 100755 new mode 100644 index 03dd2aac..29f5320e --- a/view/profile_selectors.php +++ b/view/profile_selectors.php @@ -1,18 +1,6 @@ "; - foreach($select as $selection) { - $selected = (($selection == $current) ? ' selected="selected" ' : ''); - $o .= ""; - } - $o .= ''; - return $o; -} - function sexpref_selector($current="",$suffix="") { $select = array('', t('Males'), t('Females'), t('Bisexual'), t('Autosexual'), t('Abstinent'), t('Virgin'), t('Nonsexual')); @@ -23,17 +11,4 @@ function sexpref_selector($current="",$suffix="") { } $o .= ''; return $o; -} - - -function marital_selector($current="",$suffix="") { - $select = array('', t('Single'), t('Lonely'), t('Available'), t('Unavailable'), t('Dating'), t('Unfaithful'), t('Sex Addict'), t('Friends'), t('Friends/Benefits'), t('Casual'), t('Engaged'), t('Married'), t('Partners'), t('Cohabiting'), t('Happy'), t('Not Looking'), t('Swinger'), t('Betrayed'), t('Separated'), t('Unstable'), t('Divorced'), t('Widowed'), t('Uncertain'), t('Complicated'), t('Don\'t care'), t('Ask me') ); - - $o .= "'; - return $o; -} +} diff --git a/view/profile_tabs.tpl b/view/profile_tabs.tpl old mode 100755 new mode 100644 diff --git a/view/prv_message.tpl b/view/prv_message.tpl old mode 100755 new mode 100644 diff --git a/view/pwdreset.tpl b/view/pwdreset.tpl old mode 100755 new mode 100644 diff --git a/view/register-link.tpl b/view/register-link.tpl old mode 100755 new mode 100644 diff --git a/view/register.tpl b/view/register.tpl old mode 100755 new mode 100644 diff --git a/view/request_notify_eml.tpl b/view/request_notify_eml.tpl old mode 100755 new mode 100644 diff --git a/view/settings.tpl b/view/settings.tpl old mode 100755 new mode 100644 diff --git a/view/settings_nick_set.tpl b/view/settings_nick_set.tpl old mode 100755 new mode 100644 diff --git a/view/settings_nick_subdir.tpl b/view/settings_nick_subdir.tpl old mode 100755 new mode 100644 diff --git a/view/settings_nick_unset.tpl b/view/settings_nick_unset.tpl old mode 100755 new mode 100644 diff --git a/view/sidenote.tpl b/view/sidenote.tpl old mode 100755 new mode 100644 diff --git a/view/theme/default/style.css b/view/theme/default/style.css index e85116e5..5ca3e17c 100755 --- a/view/theme/default/style.css +++ b/view/theme/default/style.css @@ -544,14 +544,12 @@ input#dfrn-url { #profile-edit-profile-name-label, #profile-edit-name-label, -#profile-edit-gender-label, #profile-edit-dob-label, #profile-edit-address-label, #profile-edit-locality-label, #profile-edit-region-label, #profile-edit-postal-code-label, #profile-edit-country-name-label, -#profile-edit-marital-label, #profile-edit-sexual-label, #profile-edit-politic-label, #profile-edit-religion-label, @@ -562,14 +560,12 @@ input#dfrn-url { #profile-edit-profile-name, #profile-edit-name, -#gender-select, #profile-edit-dob, #profile-edit-address, #profile-edit-locality, #profile-edit-region, #profile-edit-postal-code, #profile-edit-country-name, -#marital-select, #sexual-select, #profile-edit-politic, #profile-edit-religion, @@ -597,14 +593,12 @@ input#dfrn-url { #profile-edit-profile-name-end, #profile-edit-name-end, -#profile-edit-gender-end, #profile-edit-dob-end, #profile-edit-address-end, #profile-edit-locality-end, #profile-edit-region-end, #profile-edit-postal-code-end, #profile-edit-country-name-end, -#profile-edit-marital-end, #profile-edit-sexual-end, #profile-edit-politic-end, #profile-edit-religion-end, @@ -619,8 +613,7 @@ input#dfrn-url { - -#gender-select, #marital-select, #sexual-select { +#sexual-select { width: 220px; } @@ -896,7 +889,7 @@ input#dfrn-url { margin-top: 10px; margin-left: 35px; } -.directory-details, .marital { +.directory-details { font-size: 0.7em; text-align: center; margin-left: 5px; @@ -956,10 +949,8 @@ input#dfrn-url { #advanced-profile-name-wrapper, -#advanced-profile-gender-wrapper, #advanced-profile-dob-wrapper, #advanced-profile-age-wrapper, -#advanced-profile-marital-wrapper, #advanced-profile-sexual-wrapper, #advanced-profile-homepage-wrapper, #advanced-profile-politic-wrapper, @@ -978,10 +969,8 @@ input#dfrn-url { } #advanced-profile-name-text, -#advanced-profile-gender-text, #advanced-profile-dob-text, #advanced-profile-age-text, -#advanced-profile-marital-text, #advanced-profile-sexual-text, #advanced-profile-homepage-text, #advanced-profile-politic-text, @@ -1001,10 +990,8 @@ input#dfrn-url { } #advanced-profile-name-end, -#advanced-profile-gender-end, #advanced-profile-dob-end, #advanced-profile-age-end, -#advanced-profile-marital-end, #advanced-profile-sexual-end, #advanced-profile-homepage-end, #advanced-profile-politic-end, @@ -1027,10 +1014,8 @@ input#dfrn-url { } #advanced-profile-name, -#advanced-profile-gender, #advanced-profile-dob, #advanced-profile-age, -#advanced-profile-marital, #advanced-profile-sexual, #advanced-profile-homepage, #advanced-profile-politic, diff --git a/view/viewcontact_template.tpl b/view/viewcontact_template.tpl old mode 100755 new mode 100644 diff --git a/view/wall_item.tpl b/view/wall_item.tpl old mode 100755 new mode 100644 diff --git a/view/wall_item_drop.tpl b/view/wall_item_drop.tpl old mode 100755 new mode 100644 diff --git a/view/wall_received_eml.tpl b/view/wall_received_eml.tpl old mode 100755 new mode 100644 diff --git a/view/wallwall_item.tpl b/view/wallwall_item.tpl old mode 100755 new mode 100644 diff --git a/view/xrd_host.tpl b/view/xrd_host.tpl old mode 100755 new mode 100644 diff --git a/view/xrd_person.tpl b/view/xrd_person.tpl old mode 100755 new mode 100644