moving local utils from /htdocs/util-local to /local
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
// For license information see doc/license.txt
|
||||
|
||||
$opt['rootpath'] = '../htdocs/';
|
||||
header('Content-type: text/html; charset=utf-8');
|
||||
require($opt['rootpath'] . 'lib2/web.inc.php');
|
||||
|
||||
|
||||
$rs = sql("SELECT email FROM user
|
||||
WHERE NOT ISNULL(email) AND is_active_flag!=0 AND email_problems=0
|
||||
ORDER BY user_id DESC");
|
||||
while ($r = sql_fetch_assoc($rs))
|
||||
{
|
||||
echo $r['email'] . "\n";
|
||||
}
|
||||
sql_free_result($rs);
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/***************************************************************************
|
||||
* send mailing
|
||||
*
|
||||
* For license information see doc/license.txt
|
||||
***************************************************************************/
|
||||
|
||||
// reads from addesses.txt
|
||||
// writes protocol sent.txt
|
||||
// sends email to all recipients from addresses.txt which are not contained in sent.txt
|
||||
//
|
||||
// may be resumed after interrupt
|
||||
|
||||
ini_set('memory_limit', '128M');
|
||||
|
||||
// read recipients' email addresses
|
||||
$addresses = file("addresses.txt");
|
||||
$protocol = @file("sent.txt");
|
||||
if ($protocol === false)
|
||||
$sendto = $addresses;
|
||||
else
|
||||
$sendto = array_diff($addresses,$protocol);
|
||||
|
||||
// read message text
|
||||
$message = file_get_contents("message.txt");
|
||||
if (empty($message)) die();
|
||||
|
||||
$total = count($sendto);
|
||||
$n = 0;
|
||||
echo "sending email to " . $total . " of " . count($addresses) . " recipients\n\n";
|
||||
|
||||
$subject = "....";
|
||||
$from_adr = "user@do.main";
|
||||
|
||||
$starttime = microtime(TRUE);
|
||||
|
||||
foreach($sendto as $receiver)
|
||||
{
|
||||
$receiver = trim($receiver);
|
||||
echo ++$n . "/$total: $receiver";
|
||||
mail($receiver,
|
||||
$subject,
|
||||
$message,
|
||||
"From: $from_adr\r\n" .
|
||||
"MIME-Version: 1.0\r\n" .
|
||||
"Content-Type: text/plain; charset=iso-8859-1\r\n" .
|
||||
"Content-Transfer-Encoding: 8bit");
|
||||
echo "\n";
|
||||
file_put_contents("sent.txt", "$receiver\n", FILE_APPEND);
|
||||
}
|
||||
|
||||
echo "Time needed: " . (microtime(TRUE) - $starttime) . "s\n";
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/***************************************************************************
|
||||
* For license information see doc/license.txt
|
||||
*
|
||||
* This script was used for adding nano queries when nano size was implemented.
|
||||
* It may be adopted for future additions of cache sizes or types.
|
||||
*
|
||||
* Unicode Reminder メモ
|
||||
***************************************************************************/
|
||||
|
||||
$opt['rootpath'] = '../htdocs/';
|
||||
require($opt['rootpath'] . 'lib2/web.inc.php');
|
||||
|
||||
$rs = sql("SELECT * FROM queries");
|
||||
while ($r = sql_fetch_array($rs))
|
||||
{
|
||||
$query = unserialize($r['options']);
|
||||
if (isset($query['cachesize']))
|
||||
{
|
||||
$cachesize = $query['cachesize'];
|
||||
|
||||
// add nano size to all queries that include micro or other
|
||||
if (preg_match('/[;][12][;]/', ';'.$cachesize.';') &&
|
||||
!preg_match('/[;][8][;]/', ';'.$cachesize.';'))
|
||||
{
|
||||
// echo $r['name'] . ": " . $cachesize . " -> " . $query['cachesize'] .= ";8\n";
|
||||
$query['cachesize'] .= ";8";
|
||||
$saveopt = serialize($query);
|
||||
// sql("UPDATE queries SET `options`='&1' WHERE `id`='&2'", $saveopt, $r['id']);
|
||||
// ^^ run this line only if you are absolutely sure what you are doing
|
||||
echo "added nano to query " . $r['id'] . "(" . $cachesize . ") of user " . $r['user_id'] . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sql_free_result($rs);
|
||||
?>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
// Unicode Reminder メモ
|
||||
|
||||
// safemode-unzip
|
||||
$opt['unzip'] = '/srv/www/htdocs/www.opencaching.de/html/util/safemode_zip/phpunzip.php';
|
||||
$opt['rel_tmpdir'] = 'util/ocxml11client/tmp';
|
||||
|
||||
// 2. DB z.B. als Backup einer sauberen DB
|
||||
$opt['db'][1]['name'] = 'ocdublette';
|
||||
$opt['db'][1]['username'] = $dbusername;
|
||||
$opt['db'][1]['passwd'] = $dbpasswd;
|
||||
$opt['db'][1]['server'] = $dbserver;
|
||||
|
||||
// Synchronisierungsoptionen
|
||||
$opt['sync']['user'] = 1;
|
||||
$opt['sync']['cache'] = 1;
|
||||
$opt['sync']['cachedesc'] = 1;
|
||||
$opt['sync']['cachelog'] = 1;
|
||||
$opt['sync']['picture'] = 1;
|
||||
$opt['sync']['picturefromcachelog'] = 1;
|
||||
$opt['sync']['removedobject'] = 1;
|
||||
|
||||
// Bilder downloaden?
|
||||
$opt['pictures']['download'] = 1;
|
||||
$opt['pictures']['directory'] = $rootpath . 'images/uploads/';
|
||||
$opt['pictures']['url'] = 'http://www.so-komm-ich-uebers-web-da.hin/www.opencaching.de/html/images/uploads/';
|
||||
|
||||
// Sessions verwenden?
|
||||
$opt['session'] = 1;
|
||||
$opt['zip'] = 'gzip'; // 0; zip; bzip2; gzip
|
||||
|
||||
// Gebietsauswahl nach Land
|
||||
$opt['bycountry'] = 0;
|
||||
$opt['country'] = 'DE';
|
||||
|
||||
// Gebietsauswahl nach Koordinaten
|
||||
$opt['bycoords'] = 0;
|
||||
$opt['lon'] = 50.12345;
|
||||
$opt['lat'] = 9.12345;
|
||||
$opt['distance'] = 150;
|
||||
|
||||
// sonstige Einstellungen
|
||||
$opt['tmpdir'] = 'tmp/';
|
||||
$opt['archivdir'] = 'data-files/';
|
||||
$opt['url'] = 'http://www.opencaching.de/xml/ocxml11.php?modifiedsince={modifiedsince}&user={user}&cache={cache}&cachedesc={cachedesc}&cachelog={cachelog}&picture={picture}&picturefromcachelog={picturefromcachelog}&removedobject={removedobject}&session={session}&zip={zip}&charset=utf-8';
|
||||
$opt['urlappend_country'] = '&country={country}';
|
||||
$opt['urlappend_coords'] = '&lon={lon}&lat={lat}&distance={distance}';
|
||||
$opt['url_getsession'] = 'http://www.opencaching.de/xml/ocxml11.php?sessionid={sessionid}&file={file}&zip={zip}&charset=utf-8';
|
||||
?>
|
||||
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
/***************************************************************************
|
||||
* For license information see doc/license.txt
|
||||
*
|
||||
* Unicode Reminder メモ
|
||||
***************************************************************************/
|
||||
|
||||
class xml2Array {
|
||||
|
||||
var $stack=array();
|
||||
var $stack_ref;
|
||||
var $arrOutput = array();
|
||||
var $resParser;
|
||||
var $strXmlData;
|
||||
|
||||
function push_pos(&$pos) {
|
||||
$this->stack[count($this->stack)]=&$pos;
|
||||
$this->stack_ref=&$pos;
|
||||
}
|
||||
|
||||
function pop_pos() {
|
||||
unset($this->stack[count($this->stack)-1]);
|
||||
$this->stack_ref=&$this->stack[count($this->stack)-1];
|
||||
}
|
||||
|
||||
function parse($strInputXML) {
|
||||
|
||||
$this->resParser = xml_parser_create("UTF-8");
|
||||
xml_set_object($this->resParser,$this);
|
||||
xml_set_element_handler($this->resParser, "tagOpen", "tagClosed");
|
||||
|
||||
xml_set_character_data_handler($this->resParser, "tagData");
|
||||
|
||||
$this->push_pos($this->arrOutput);
|
||||
|
||||
$this->strXmlData = xml_parse($this->resParser,$strInputXML );
|
||||
if(!$this->strXmlData) {
|
||||
die(sprintf("XML error: %s at line %d",
|
||||
xml_error_string(xml_get_error_code($this->resParser)),
|
||||
xml_get_current_line_number($this->resParser)));
|
||||
}
|
||||
|
||||
xml_parser_free($this->resParser);
|
||||
|
||||
return $this->arrOutput;
|
||||
}
|
||||
|
||||
function tagOpen($parser, $name, $attrs) {
|
||||
if (isset($this->stack_ref[$name])) {
|
||||
if (!isset($this->stack_ref[$name][0])) {
|
||||
$tmp=$this->stack_ref[$name];
|
||||
unset($this->stack_ref[$name]);
|
||||
$this->stack_ref[$name][0]=$tmp;
|
||||
}
|
||||
$cnt=count($this->stack_ref[$name]);
|
||||
$this->stack_ref[$name][$cnt]=array();
|
||||
if (isset($attrs))
|
||||
$this->stack_ref[$name][$cnt]=$attrs;
|
||||
$this->push_pos($this->stack_ref[$name][$cnt]);
|
||||
}
|
||||
else {
|
||||
$this->stack_ref[$name]=array();
|
||||
if (isset($attrs))
|
||||
$this->stack_ref[$name]=$attrs;
|
||||
$this->push_pos($this->stack_ref[$name]);
|
||||
}
|
||||
}
|
||||
|
||||
function tagData($parser, $tagData) {
|
||||
if(mb_trim($tagData)) {
|
||||
if(isset($this->stack_ref['DATA']))
|
||||
$this->stack_ref['DATA'] .= $tagData;
|
||||
else
|
||||
$this->stack_ref['DATA'] = $tagData;
|
||||
}
|
||||
}
|
||||
|
||||
function tagClosed($parser, $name) {
|
||||
$this->pop_pos();
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,2 @@
|
||||
This directory contains files which will reside outside the code directory tree
|
||||
on a production system.
|
||||
@@ -0,0 +1,88 @@
|
||||
#!/usr/bin/php -q
|
||||
<?php
|
||||
/***************************************************************************
|
||||
bin/phpzip.php
|
||||
-------------------
|
||||
begin : December 22 2005
|
||||
|
||||
For license information see doc/license.txt
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
|
||||
Wrapper for unix-utilities zip, gzip and bz2
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
$basedir = '/path/to/htdocs/download/zip/';
|
||||
|
||||
$zipper['zip'] = 'nice --adjustment=19 zip -j -q -1 {dst} {src}';
|
||||
$zipper['gzip'] = 'nice --adjustment=19 gzip -1 -c {src} > {dst}';
|
||||
$zipper['bzip2'] = 'nice --adjustment=19 bzip2 -1 -c {src} > {dst}';
|
||||
|
||||
if ($argv[1] == '--help')
|
||||
{
|
||||
echo $argv[0] . " --type=<ziptype> --src=<source> --dst=<destination>
|
||||
--type can be zip, gzip or bzip2
|
||||
--src relative* path to source file
|
||||
--dst relative* path to destination file
|
||||
|
||||
*relative to $basedir
|
||||
";
|
||||
exit;
|
||||
}
|
||||
|
||||
if ((substr($argv[1], 0, 7) != '--type=') || (substr($argv[2], 0, 6) != '--src=') || (substr($argv[3], 0, 6) != '--dst='))
|
||||
die("wrong paramter\nuse " . $argv[0] . " --help\n");
|
||||
|
||||
if (isset($argv[4]))
|
||||
die("wrong paramter\nuse " . $argv[0] . " --help\n");
|
||||
|
||||
$type = substr($argv[1], 7);
|
||||
$src = substr($argv[2], 6);
|
||||
$dst = substr($argv[3], 6);
|
||||
|
||||
if (!isset($zipper[$type]))
|
||||
die("invaild zip type\nuse " . $argv[0] . " --help\n");
|
||||
|
||||
if (checkpath($src) == false)
|
||||
die("invaild src\nuse " . $argv[0] . " --help\n");
|
||||
|
||||
if (checkpath($dst) == false)
|
||||
die("invaild dst\nuse " . $argv[0] . " --help\n");
|
||||
|
||||
$src = $basedir . $src;
|
||||
$dst = $basedir . $dst;
|
||||
|
||||
if (!file_exists($src))
|
||||
die("error: source not exist\nuse " . $argv[0] . " --help\n");
|
||||
|
||||
if (file_exists($dst))
|
||||
die("error: destination already exists\nuse " . $argv[0] . " --help\n");
|
||||
|
||||
$cmd = $zipper[$type];
|
||||
$cmd = str_replace('{src}', escapeshellcmd($src), $cmd);
|
||||
$cmd = str_replace('{dst}', escapeshellcmd($dst), $cmd);
|
||||
|
||||
system($cmd);
|
||||
|
||||
function checkpath($path)
|
||||
{
|
||||
$parts = explode('/', $path);
|
||||
|
||||
if ($parts[0] == '')
|
||||
return false;
|
||||
|
||||
for ($i = 0; $i < count($parts); $i++)
|
||||
{
|
||||
if (($parts[$i] == '..') || ($parts[$i] == '.'))
|
||||
return false;
|
||||
|
||||
if (!preg_match('/^[a-zA-Z0-9.-_]{1,}/', $parts[$i]))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/php -q
|
||||
<?php
|
||||
/***************************************************************************
|
||||
* You can find the license in the docs directory
|
||||
*
|
||||
* Cronjob to clean up master logs that we dont need any more for any
|
||||
* configured slave server. Run this script once every day.
|
||||
*
|
||||
* The user account given below needs SUPER privileges.
|
||||
* This is why you want to place this file outside PHP open_basedir
|
||||
* and restrict read access to the root user.
|
||||
***************************************************************************/
|
||||
|
||||
// begin configuration
|
||||
$dbserver = '';
|
||||
$dbname = '';
|
||||
$dbuser = '';
|
||||
$dbpassword = '';
|
||||
// end configuration
|
||||
|
||||
$dblink = @mysql_connect($dbserver, $dbuser, $dbpassword);
|
||||
if ($dblink === false)
|
||||
exit;
|
||||
|
||||
if (mysql_select_db($dbname, $dblink) == false)
|
||||
{
|
||||
mysql_close($dblink);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rs = mysql_query("SELECT COUNT(*) AS `c` FROM `sys_repl_slaves` WHERE (`active`=1 AND `online`=0) OR (`active`=1 AND `online`=1 AND `current_log_name`='')", $dblink);
|
||||
$r = mysql_fetch_array($rs);
|
||||
mysql_free_result($rs);
|
||||
|
||||
if ($r[0] == 0)
|
||||
{
|
||||
$rs = mysql_query("SELECT MIN(`current_log_name`) FROM `sys_repl_slaves` WHERE `active`=1 AND `online`=1", $dblink);
|
||||
$rLastLog = mysql_fetch_array($rs);
|
||||
mysql_free_result($rs);
|
||||
|
||||
mysql_query("PURGE MASTER LOGS TO '" . mysql_real_escape_string($rLastLog[0], $dblink) . "'", $dblink);
|
||||
}
|
||||
|
||||
mysql_close($dblink);
|
||||
?>
|
||||
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
/***************************************************************************
|
||||
* For license information see doc/license.txt
|
||||
*
|
||||
* Unicode Reminder メモ
|
||||
***************************************************************************/
|
||||
|
||||
// statistical data for cache and log activity map
|
||||
|
||||
chdir ("../htdocs");
|
||||
require('lib2/web.inc.php');
|
||||
|
||||
error_reporting(error_reporting() & ~E_NOTICE);
|
||||
|
||||
$grid = $_GET["grid"];
|
||||
if ($grid <= 0) $grid = 0.2;
|
||||
|
||||
// caches created by year
|
||||
$rs = sql("SELECT latitude, longitude, date_created FROM caches");
|
||||
while ($cache = sql_fetch_assoc($rs))
|
||||
{
|
||||
$lat = floor($cache["latitude"] / $grid);
|
||||
$long = floor($cache["longitude"] / $grid);
|
||||
$year = substr($cache["date_created"],0,4);
|
||||
if ($year >= 2005 && $year <= date("Y") && ($lat != 0 || $long != 0))
|
||||
{
|
||||
$years[$year] = true;
|
||||
$liste[$lat][$long]["caches"][$year]++;
|
||||
}
|
||||
}
|
||||
mysql_free_result($rs);
|
||||
|
||||
// logs per logdate by year
|
||||
get_logs("cache_logs");
|
||||
// get_logs("cache_logs_archived");
|
||||
|
||||
function get_logs($table)
|
||||
{
|
||||
global $grid, $liste, $years;
|
||||
|
||||
$rs = sql("SELECT latitude, longitude, date
|
||||
FROM $table
|
||||
INNER JOIN caches ON $table.cache_id=caches.cache_id");
|
||||
while ($cache = sql_fetch_assoc($rs))
|
||||
{
|
||||
$lat = floor($cache["latitude"] / $grid);
|
||||
$long = floor($cache["longitude"] / $grid);
|
||||
$year = substr($cache["date"],0,4);
|
||||
if ($year >= 2005 && $year <= date("Y") && ($lat != 0 || $long != 0))
|
||||
{
|
||||
$years[$year] = true;
|
||||
$liste[$lat][$long]["logs"][$year]++;
|
||||
}
|
||||
}
|
||||
mysql_free_result($rs);
|
||||
}
|
||||
|
||||
ksort($years);
|
||||
|
||||
// active caches and logs
|
||||
$rs = sql("SELECT latitude, longitude,
|
||||
(SELECT COUNT(*) FROM cache_logs WHERE cache_logs.cache_id=caches.cache_id) AS logs
|
||||
FROM caches WHERE status=1");
|
||||
while ($cache = sql_fetch_assoc($rs))
|
||||
{
|
||||
$lat = floor($cache["latitude"] / $grid);
|
||||
$long = floor($cache["longitude"] / $grid);
|
||||
$liste[$lat][$long]["caches"]["all"]++;
|
||||
$liste[$lat][$long]["logs"]["all"] += $cache["logs"];
|
||||
}
|
||||
mysql_free_result($rs);
|
||||
|
||||
ksort ($liste);
|
||||
$lats = array_keys($liste);
|
||||
foreach ($lats as $lat)
|
||||
ksort($liste[$lat]);
|
||||
|
||||
// create output CSV data
|
||||
header("Content-type: application/comma-separated-value");
|
||||
header('Content-Disposition: attachment; filename="cachestat.csv"');
|
||||
echo "latitude,longitude,caches,logs";
|
||||
foreach ($years as $year => $dummy)
|
||||
echo ",caches$year,logs$year";
|
||||
echo "\r\n";
|
||||
|
||||
foreach ($liste as $lat => $liste2)
|
||||
foreach ($liste2 as $long => $cachecounts)
|
||||
{
|
||||
echo ($lat*$grid + 0.5*$grid) . "," . ($long*$grid + 0.5*$grid) . "," .
|
||||
$cachecounts["caches"]["all"] . "," .
|
||||
$cachecounts["logs"]["all"];
|
||||
foreach ($years as $year => $dummy)
|
||||
echo "," . $cachecounts["caches"][$year] . "," . $cachecounts["logs"][$year];
|
||||
echo "\r\n";
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user