fix line endings

This commit is contained in:
following
2013-01-28 13:34:15 +01:00
parent 6e2439648e
commit 112dbec4ae
17 changed files with 4964 additions and 4964 deletions

View File

@ -1,29 +1,29 @@
#!/usr/bin/php
<?php
/***************************************************************************
* For license information see doc/license.txt
*
* Unicode Reminder メモ
***************************************************************************/
/*
* update of static data and triggers in developer system
*
* Tables must be updated manually, see htdocs/doc/sql/db-changes.txt
*/
$rootpath = dirname(__FILE__) . '/../htdocs/';
require($rootpath . 'lib/settings.inc.php');
echo "importing data.sql ...\n";
system('cat ' . $rootpath . 'doc/sql/static-data/data.sql | mysql -h' . $dbserver . ' -u' . $dbusername . ' --password=' . $dbpasswd . ' ' . $dbname);
echo "importing triggers ...\n";
chdir ($rootpath . 'doc/sql/stored-proc');
system('php maintain.php');
echo "resettings webcache ...\n";
chdir ($rootpath . '../bin');
system('php clear-webcache.php');
#!/usr/bin/php
<?php
/***************************************************************************
* For license information see doc/license.txt
*
* Unicode Reminder メモ
***************************************************************************/
/*
* update of static data and triggers in developer system
*
* Tables must be updated manually, see htdocs/doc/sql/db-changes.txt
*/
$rootpath = dirname(__FILE__) . '/../htdocs/';
require($rootpath . 'lib/settings.inc.php');
echo "importing data.sql ...\n";
system('cat ' . $rootpath . 'doc/sql/static-data/data.sql | mysql -h' . $dbserver . ' -u' . $dbusername . ' --password=' . $dbpasswd . ' ' . $dbname);
echo "importing triggers ...\n";
chdir ($rootpath . 'doc/sql/stored-proc');
system('php maintain.php');
echo "resettings webcache ...\n";
chdir ($rootpath . '../bin');
system('php clear-webcache.php');
?>

View File

@ -1,229 +1,229 @@
<?php
/***************************************************************************
* For license information see doc/license.txt
*
* Unicode Reminder メモ
*
* Default settings for all locale options in settings.inc.php
* Do not modify this file - use settings.inc.php!
*
* ATTENTION: This file is also used in old template system.
* (this means any call to framework functions may be incompatible)
*
* Only set the following keys in $opt[]
*
* $opt['template']['locales']
* $opt['geokrety']['locales']
* $opt['locale']
***************************************************************************/
/* Locale definitions
*
*/
$opt['template']['locales']['DE']['show'] = true;
$opt['template']['locales']['DE']['flag'] = 'images/flag/DE.gif';
$opt['template']['locales']['DE']['name'] = 'Deutsch';
$opt['template']['locales']['FR']['show'] = true;
$opt['template']['locales']['FR']['flag'] = 'images/flag/FR.gif';
$opt['template']['locales']['FR']['name'] = 'Français';
$opt['template']['locales']['NL']['show'] = true;
$opt['template']['locales']['NL']['flag'] = 'images/flag/NL.gif';
$opt['template']['locales']['NL']['name'] = 'Nederlands';
$opt['template']['locales']['EN']['show'] = true;
$opt['template']['locales']['EN']['flag'] = 'images/flag/EN.gif';
$opt['template']['locales']['EN']['name'] = 'English';
$opt['template']['locales']['PL']['show'] = true;
$opt['template']['locales']['PL']['flag'] = 'images/flag/PL.gif';
$opt['template']['locales']['PL']['name'] = 'Polski';
$opt['template']['locales']['IT']['show'] = true;
$opt['template']['locales']['IT']['flag'] = 'images/flag/IT.gif';
$opt['template']['locales']['IT']['name'] = 'Italiano';
$opt['template']['locales']['RU']['show'] = true;
$opt['template']['locales']['RU']['flag'] = 'images/flag/RU.gif';
$opt['template']['locales']['RU']['name'] = 'Русский';
$opt['template']['locales']['ES']['show'] = true;
$opt['template']['locales']['ES']['flag'] = 'images/flag/ES.png';
$opt['template']['locales']['ES']['name'] = 'Español';
$opt['template']['locales']['SV']['show'] = true; // sv_SE
$opt['template']['locales']['SV']['flag'] = 'images/flag/SE.png';
$opt['template']['locales']['SV']['name'] = 'Svenska';
$opt['template']['locales']['NO']['show'] = true; // no_NO
$opt['template']['locales']['NO']['flag'] = 'images/flags/no.gif';
$opt['template']['locales']['NO']['name'] = 'Norsk';
$opt['template']['locales']['DA']['show'] = true; // da_DK
$opt['template']['locales']['DA']['flag'] = 'images/flags/dk.gif';
$opt['template']['locales']['DA']['name'] = 'Danske';
$opt['template']['locales']['PT']['show'] = true; // pt_PT
$opt['template']['locales']['PT']['flag'] = 'images/flags/pt.gif';
$opt['template']['locales']['PT']['name'] = 'Portuguesa';
$opt['template']['locales']['JA']['show'] = true; // ja_JP
$opt['template']['locales']['JA']['flag'] = 'images/flag/JP.gif';
$opt['template']['locales']['JA']['name'] = '日本語';
// geokrety language key association
$opt['geokrety']['locales']['DE'] = 'de_DE.UTF-8';
$opt['geokrety']['locales']['EN'] = 'en_EN';
$opt['geokrety']['locales']['FR'] = 'fr_FR.UTF-8';
$opt['geokrety']['locales']['NL'] = 'en_EN';
$opt['geokrety']['locales']['PL'] = 'pl_PL.UTF-8';
$opt['geokrety']['locales']['IT'] = 'en_EN';
$opt['geokrety']['locales']['RU'] = 'en_EN';
$opt['geokrety']['locales']['ES'] = 'es_ES.UTF-8';
$opt['geokrety']['locales']['SV'] = 'sv_SE.UTF-8';
$opt['geokrety']['locales']['NO'] = 'no_NO.UTF-8';
$opt['geokrety']['locales']['DA'] = 'da_DK.UTF-8';
$opt['geokrety']['locales']['PT'] = 'pt_PT.UTF-8';
$opt['geokrety']['locales']['JA'] = 'ja_JP.UTF-8';
$opt['locale']['DE']['locales'] = array('de_DE.utf8', 'de_DE@euro', 'de_DE', 'de', 'ge');
$opt['locale']['EN']['locales'] = array('en_US.utf8', 'en_US', 'en');
$opt['locale']['FR']['locales'] = array('fr_FR.utf8', 'fr_FR@euro', 'fr_FR', 'french', 'fr');
$opt['locale']['PL']['locales'] = array('pl_PL.utf8', 'pl_PL', 'pl');
$opt['locale']['NL']['locales'] = array('nl_NL.utf8', 'nl_NL', 'nl');
$opt['locale']['IT']['locales'] = array('it_IT.utf8', 'it_IT', 'it');
$opt['locale']['RU']['locales'] = array('ru_RU.utf8', 'ru_RU', 'ru');
$opt['locale']['ES']['locales'] = array('es_ES.utf8', 'es_ES', 'es');
$opt['locale']['SV']['locales'] = array('sv_SE.utf8', 'sv_SE', 'se');
$opt['locale']['NO']['locales'] = array('no_NO.utf8', 'no_NO', 'no');
$opt['locale']['DA']['locales'] = array('da_DK.utf8', 'da_DK', 'dk');
$opt['locale']['PT']['locales'] = array('pt_PT.utf8', 'pt_PT', 'pt');
$opt['locale']['JA']['locales'] = array('ja_JP.utf8', 'ja_JP', 'jp');
$opt['locale']['EN']['timezone'] = 'Europe/Berlin';
$opt['locale']['EN']['format']['date'] = '%x';
$opt['locale']['EN']['format']['datelong'] = '%d. %B %Y';
$opt['locale']['EN']['format']['datetime'] = '%x %I:%M %p';
$opt['locale']['EN']['format']['datetimesec'] = '%x %X';
$opt['locale']['EN']['format']['time'] = '%I:%M %p';
$opt['locale']['EN']['format']['timesec'] = '%X';
$opt['locale']['EN']['country'] = 'UK';
$opt['locale']['EN']['page']['subtitle1'] = 'Geocaching with Opencaching';
$opt['locale']['EN']['page']['subtitle2'] = '';
$opt['locale']['DE']['timezone'] = 'Europe/Berlin';
$opt['locale']['DE']['format']['date'] = '%x';
$opt['locale']['DE']['format']['datelong'] = '%d. %B %Y';
$opt['locale']['DE']['format']['datetime'] = '%x %H:%M';
$opt['locale']['DE']['format']['datetimesec'] = '%x %X';
$opt['locale']['DE']['format']['time'] = '%H:%M';
$opt['locale']['DE']['format']['timesec'] = '%X';
$opt['locale']['DE']['country'] = 'DE';
$opt['locale']['DE']['page']['subtitle1'] = 'Geocaching in Deutschland,';
$opt['locale']['DE']['page']['subtitle2'] = 'Österreich und der Schweiz';
$opt['locale']['FR']['timezone'] = 'Europe/Berlin';
$opt['locale']['FR']['format']['date'] = '%x';
$opt['locale']['FR']['format']['datelong'] = '%d. %B %Y';
$opt['locale']['FR']['format']['datetime'] = '%x %H:%M';
$opt['locale']['FR']['format']['datetimesec'] = '%x %X';
$opt['locale']['FR']['format']['time'] = '%H:%M';
$opt['locale']['FR']['format']['timesec'] = '%X';
$opt['locale']['FR']['country'] = 'FR';
$opt['locale']['PL']['timezone'] = 'Europe/Berlin';
$opt['locale']['PL']['format']['date'] = '%x';
$opt['locale']['PL']['format']['datelong'] = '%d. %B %Y';
$opt['locale']['PL']['format']['datetime'] = '%x %H:%M';
$opt['locale']['PL']['format']['datetimesec'] = '%x %X';
$opt['locale']['PL']['format']['time'] = '%H:%M';
$opt['locale']['PL']['format']['timesec'] = '%X';
$opt['locale']['PL']['country'] = 'PL';
$opt['locale']['NL']['timezone'] = 'Europe/Berlin';
$opt['locale']['NL']['format']['date'] = '%x';
$opt['locale']['NL']['format']['datelong'] = '%d. %B %Y';
$opt['locale']['NL']['format']['datetime'] = '%x %H:%M';
$opt['locale']['NL']['format']['datetimesec'] = '%x %X';
$opt['locale']['NL']['format']['time'] = '%H:%M';
$opt['locale']['NL']['format']['timesec'] = '%X';
$opt['locale']['NL']['page']['subtitle1'] = 'Geocaching met Opencaching';
$opt['locale']['NL']['page']['subtitle2'] = '';
$opt['locale']['NL']['country'] = 'NL';
$opt['locale']['IT']['timezone'] = 'Europe/Berlin';
$opt['locale']['IT']['format']['date'] = '%x';
$opt['locale']['IT']['format']['datelong'] = '%d. %B %Y';
$opt['locale']['IT']['format']['datetime'] = '%x %H:%M';
$opt['locale']['IT']['format']['datetimesec'] = '%x %X';
$opt['locale']['IT']['format']['time'] = '%H:%M';
$opt['locale']['IT']['format']['timesec'] = '%X';
$opt['locale']['IT']['country'] = 'IT';
$opt['locale']['IT']['page']['subtitle1'] = 'Geocaching con Opencaching';
$opt['locale']['IT']['page']['subtitle2'] = '';
$opt['locale']['RU']['timezone'] = 'Europe/Berlin';
$opt['locale']['RU']['format']['date'] = '%x';
$opt['locale']['RU']['format']['datelong'] = '%d. %B %Y';
$opt['locale']['RU']['format']['datetime'] = '%x %H:%M';
$opt['locale']['RU']['format']['datetimesec'] = '%x %X';
$opt['locale']['RU']['format']['time'] = '%H:%M';
$opt['locale']['RU']['format']['timesec'] = '%X';
$opt['locale']['RU']['country'] = 'RU';
$opt['locale']['ES']['timezone'] = 'Europe/Berlin';
$opt['locale']['ES']['format']['date'] = '%x';
$opt['locale']['ES']['format']['datelong'] = '%d. %B %Y';
$opt['locale']['ES']['format']['datetime'] = '%x %H:%M';
$opt['locale']['ES']['format']['datetimesec'] = '%x %X';
$opt['locale']['ES']['format']['time'] = '%H:%M';
$opt['locale']['ES']['format']['timesec'] = '%X';
$opt['locale']['ES']['country'] = 'ES';
$opt['locale']['ES']['page']['subtitle1'] = 'Geocaching con Opencaching';
$opt['locale']['ES']['page']['subtitle2'] = '';
$opt['locale']['SV']['timezone'] = 'Europe/Berlin';
$opt['locale']['SV']['format']['date'] = '%Y-%m-%d';
$opt['locale']['SV']['format']['datelong'] = '%Y-%m-%d';
$opt['locale']['SV']['format']['datetime'] = '%x %H:%M';
$opt['locale']['SV']['format']['datetimesec'] = '%x %X';
$opt['locale']['SV']['format']['time'] = '%H:%M';
$opt['locale']['SV']['format']['timesec'] = '%X';
$opt['locale']['SV']['country'] = 'SE';
$opt['locale']['SV']['page']['subtitle1'] = 'Geocaching med Opencaching';
$opt['locale']['SV']['page']['subtitle2'] = '';
$opt['locale']['NO']['timezone'] = 'Europe/Berlin';
$opt['locale']['NO']['format']['date'] = '%Y-%m-%d';
$opt['locale']['NO']['format']['datelong'] = '%Y-%m-%d';
$opt['locale']['NO']['format']['datetime'] = '%x %H:%M';
$opt['locale']['NO']['format']['datetimesec'] = '%x %X';
$opt['locale']['NO']['format']['time'] = '%H:%M';
$opt['locale']['NO']['format']['timesec'] = '%X';
$opt['locale']['NO']['country'] = 'NO';
$opt['locale']['NO']['page']['subtitle1'] = 'Geocaching med Opencaching';
$opt['locale']['NO']['page']['subtitle2'] = '';
$opt['locale']['DA']['timezone'] = 'Europe/Berlin';
$opt['locale']['DA']['format']['date'] = '%Y-%m-%d';
$opt['locale']['DA']['format']['datelong'] = '%Y-%m-%d';
$opt['locale']['DA']['format']['datetime'] = '%x %H:%M';
$opt['locale']['DA']['format']['datetimesec'] = '%x %X';
$opt['locale']['DA']['format']['time'] = '%H:%M';
$opt['locale']['DA']['format']['timesec'] = '%X';
$opt['locale']['DA']['country'] = 'DK';
$opt['locale']['DA']['page']['subtitle1'] = 'Geocaching med Opencaching';
$opt['locale']['DA']['page']['subtitle2'] = '';
$opt['locale']['PT']['timezone'] = 'Europe/Berlin';
$opt['locale']['PT']['format']['date'] = '%Y-%m-%d';
$opt['locale']['PT']['format']['datelong'] = '%Y-%m-%d';
$opt['locale']['PT']['format']['datetime'] = '%x %H:%M';
$opt['locale']['PT']['format']['datetimesec'] = '%x %X';
$opt['locale']['PT']['format']['time'] = '%H:%M';
$opt['locale']['PT']['format']['timesec'] = '%X';
$opt['locale']['PT']['country'] = 'PT';
$opt['locale']['PT']['page']['subtitle1'] = 'Geocaching com Opencaching';
$opt['locale']['PT']['page']['subtitle2'] = '';
$opt['locale']['JA']['timezone'] = 'Europe/Berlin';
$opt['locale']['JA']['format']['date'] = '%Y-%m-%d';
$opt['locale']['JA']['format']['datelong'] = '%Y-%m-%d';
$opt['locale']['JA']['format']['datetime'] = '%x %H:%M';
$opt['locale']['JA']['format']['datetimesec'] = '%x %X';
$opt['locale']['JA']['format']['time'] = '%H:%M';
$opt['locale']['JA']['format']['timesec'] = '%X';
$opt['locale']['JA']['country'] = 'JP';
$opt['locale']['JA']['page']['subtitle1'] = 'Opencachingとジオキャッシング';
$opt['locale']['JA']['page']['subtitle2'] = '';
<?php
/***************************************************************************
* For license information see doc/license.txt
*
* Unicode Reminder メモ
*
* Default settings for all locale options in settings.inc.php
* Do not modify this file - use settings.inc.php!
*
* ATTENTION: This file is also used in old template system.
* (this means any call to framework functions may be incompatible)
*
* Only set the following keys in $opt[]
*
* $opt['template']['locales']
* $opt['geokrety']['locales']
* $opt['locale']
***************************************************************************/
/* Locale definitions
*
*/
$opt['template']['locales']['DE']['show'] = true;
$opt['template']['locales']['DE']['flag'] = 'images/flag/DE.gif';
$opt['template']['locales']['DE']['name'] = 'Deutsch';
$opt['template']['locales']['FR']['show'] = true;
$opt['template']['locales']['FR']['flag'] = 'images/flag/FR.gif';
$opt['template']['locales']['FR']['name'] = 'Français';
$opt['template']['locales']['NL']['show'] = true;
$opt['template']['locales']['NL']['flag'] = 'images/flag/NL.gif';
$opt['template']['locales']['NL']['name'] = 'Nederlands';
$opt['template']['locales']['EN']['show'] = true;
$opt['template']['locales']['EN']['flag'] = 'images/flag/EN.gif';
$opt['template']['locales']['EN']['name'] = 'English';
$opt['template']['locales']['PL']['show'] = true;
$opt['template']['locales']['PL']['flag'] = 'images/flag/PL.gif';
$opt['template']['locales']['PL']['name'] = 'Polski';
$opt['template']['locales']['IT']['show'] = true;
$opt['template']['locales']['IT']['flag'] = 'images/flag/IT.gif';
$opt['template']['locales']['IT']['name'] = 'Italiano';
$opt['template']['locales']['RU']['show'] = true;
$opt['template']['locales']['RU']['flag'] = 'images/flag/RU.gif';
$opt['template']['locales']['RU']['name'] = 'Русский';
$opt['template']['locales']['ES']['show'] = true;
$opt['template']['locales']['ES']['flag'] = 'images/flag/ES.png';
$opt['template']['locales']['ES']['name'] = 'Español';
$opt['template']['locales']['SV']['show'] = true; // sv_SE
$opt['template']['locales']['SV']['flag'] = 'images/flag/SE.png';
$opt['template']['locales']['SV']['name'] = 'Svenska';
$opt['template']['locales']['NO']['show'] = true; // no_NO
$opt['template']['locales']['NO']['flag'] = 'images/flags/no.gif';
$opt['template']['locales']['NO']['name'] = 'Norsk';
$opt['template']['locales']['DA']['show'] = true; // da_DK
$opt['template']['locales']['DA']['flag'] = 'images/flags/dk.gif';
$opt['template']['locales']['DA']['name'] = 'Danske';
$opt['template']['locales']['PT']['show'] = true; // pt_PT
$opt['template']['locales']['PT']['flag'] = 'images/flags/pt.gif';
$opt['template']['locales']['PT']['name'] = 'Portuguesa';
$opt['template']['locales']['JA']['show'] = true; // ja_JP
$opt['template']['locales']['JA']['flag'] = 'images/flag/JP.gif';
$opt['template']['locales']['JA']['name'] = '日本語';
// geokrety language key association
$opt['geokrety']['locales']['DE'] = 'de_DE.UTF-8';
$opt['geokrety']['locales']['EN'] = 'en_EN';
$opt['geokrety']['locales']['FR'] = 'fr_FR.UTF-8';
$opt['geokrety']['locales']['NL'] = 'en_EN';
$opt['geokrety']['locales']['PL'] = 'pl_PL.UTF-8';
$opt['geokrety']['locales']['IT'] = 'en_EN';
$opt['geokrety']['locales']['RU'] = 'en_EN';
$opt['geokrety']['locales']['ES'] = 'es_ES.UTF-8';
$opt['geokrety']['locales']['SV'] = 'sv_SE.UTF-8';
$opt['geokrety']['locales']['NO'] = 'no_NO.UTF-8';
$opt['geokrety']['locales']['DA'] = 'da_DK.UTF-8';
$opt['geokrety']['locales']['PT'] = 'pt_PT.UTF-8';
$opt['geokrety']['locales']['JA'] = 'ja_JP.UTF-8';
$opt['locale']['DE']['locales'] = array('de_DE.utf8', 'de_DE@euro', 'de_DE', 'de', 'ge');
$opt['locale']['EN']['locales'] = array('en_US.utf8', 'en_US', 'en');
$opt['locale']['FR']['locales'] = array('fr_FR.utf8', 'fr_FR@euro', 'fr_FR', 'french', 'fr');
$opt['locale']['PL']['locales'] = array('pl_PL.utf8', 'pl_PL', 'pl');
$opt['locale']['NL']['locales'] = array('nl_NL.utf8', 'nl_NL', 'nl');
$opt['locale']['IT']['locales'] = array('it_IT.utf8', 'it_IT', 'it');
$opt['locale']['RU']['locales'] = array('ru_RU.utf8', 'ru_RU', 'ru');
$opt['locale']['ES']['locales'] = array('es_ES.utf8', 'es_ES', 'es');
$opt['locale']['SV']['locales'] = array('sv_SE.utf8', 'sv_SE', 'se');
$opt['locale']['NO']['locales'] = array('no_NO.utf8', 'no_NO', 'no');
$opt['locale']['DA']['locales'] = array('da_DK.utf8', 'da_DK', 'dk');
$opt['locale']['PT']['locales'] = array('pt_PT.utf8', 'pt_PT', 'pt');
$opt['locale']['JA']['locales'] = array('ja_JP.utf8', 'ja_JP', 'jp');
$opt['locale']['EN']['timezone'] = 'Europe/Berlin';
$opt['locale']['EN']['format']['date'] = '%x';
$opt['locale']['EN']['format']['datelong'] = '%d. %B %Y';
$opt['locale']['EN']['format']['datetime'] = '%x %I:%M %p';
$opt['locale']['EN']['format']['datetimesec'] = '%x %X';
$opt['locale']['EN']['format']['time'] = '%I:%M %p';
$opt['locale']['EN']['format']['timesec'] = '%X';
$opt['locale']['EN']['country'] = 'UK';
$opt['locale']['EN']['page']['subtitle1'] = 'Geocaching with Opencaching';
$opt['locale']['EN']['page']['subtitle2'] = '';
$opt['locale']['DE']['timezone'] = 'Europe/Berlin';
$opt['locale']['DE']['format']['date'] = '%x';
$opt['locale']['DE']['format']['datelong'] = '%d. %B %Y';
$opt['locale']['DE']['format']['datetime'] = '%x %H:%M';
$opt['locale']['DE']['format']['datetimesec'] = '%x %X';
$opt['locale']['DE']['format']['time'] = '%H:%M';
$opt['locale']['DE']['format']['timesec'] = '%X';
$opt['locale']['DE']['country'] = 'DE';
$opt['locale']['DE']['page']['subtitle1'] = 'Geocaching in Deutschland,';
$opt['locale']['DE']['page']['subtitle2'] = 'Österreich und der Schweiz';
$opt['locale']['FR']['timezone'] = 'Europe/Berlin';
$opt['locale']['FR']['format']['date'] = '%x';
$opt['locale']['FR']['format']['datelong'] = '%d. %B %Y';
$opt['locale']['FR']['format']['datetime'] = '%x %H:%M';
$opt['locale']['FR']['format']['datetimesec'] = '%x %X';
$opt['locale']['FR']['format']['time'] = '%H:%M';
$opt['locale']['FR']['format']['timesec'] = '%X';
$opt['locale']['FR']['country'] = 'FR';
$opt['locale']['PL']['timezone'] = 'Europe/Berlin';
$opt['locale']['PL']['format']['date'] = '%x';
$opt['locale']['PL']['format']['datelong'] = '%d. %B %Y';
$opt['locale']['PL']['format']['datetime'] = '%x %H:%M';
$opt['locale']['PL']['format']['datetimesec'] = '%x %X';
$opt['locale']['PL']['format']['time'] = '%H:%M';
$opt['locale']['PL']['format']['timesec'] = '%X';
$opt['locale']['PL']['country'] = 'PL';
$opt['locale']['NL']['timezone'] = 'Europe/Berlin';
$opt['locale']['NL']['format']['date'] = '%x';
$opt['locale']['NL']['format']['datelong'] = '%d. %B %Y';
$opt['locale']['NL']['format']['datetime'] = '%x %H:%M';
$opt['locale']['NL']['format']['datetimesec'] = '%x %X';
$opt['locale']['NL']['format']['time'] = '%H:%M';
$opt['locale']['NL']['format']['timesec'] = '%X';
$opt['locale']['NL']['page']['subtitle1'] = 'Geocaching met Opencaching';
$opt['locale']['NL']['page']['subtitle2'] = '';
$opt['locale']['NL']['country'] = 'NL';
$opt['locale']['IT']['timezone'] = 'Europe/Berlin';
$opt['locale']['IT']['format']['date'] = '%x';
$opt['locale']['IT']['format']['datelong'] = '%d. %B %Y';
$opt['locale']['IT']['format']['datetime'] = '%x %H:%M';
$opt['locale']['IT']['format']['datetimesec'] = '%x %X';
$opt['locale']['IT']['format']['time'] = '%H:%M';
$opt['locale']['IT']['format']['timesec'] = '%X';
$opt['locale']['IT']['country'] = 'IT';
$opt['locale']['IT']['page']['subtitle1'] = 'Geocaching con Opencaching';
$opt['locale']['IT']['page']['subtitle2'] = '';
$opt['locale']['RU']['timezone'] = 'Europe/Berlin';
$opt['locale']['RU']['format']['date'] = '%x';
$opt['locale']['RU']['format']['datelong'] = '%d. %B %Y';
$opt['locale']['RU']['format']['datetime'] = '%x %H:%M';
$opt['locale']['RU']['format']['datetimesec'] = '%x %X';
$opt['locale']['RU']['format']['time'] = '%H:%M';
$opt['locale']['RU']['format']['timesec'] = '%X';
$opt['locale']['RU']['country'] = 'RU';
$opt['locale']['ES']['timezone'] = 'Europe/Berlin';
$opt['locale']['ES']['format']['date'] = '%x';
$opt['locale']['ES']['format']['datelong'] = '%d. %B %Y';
$opt['locale']['ES']['format']['datetime'] = '%x %H:%M';
$opt['locale']['ES']['format']['datetimesec'] = '%x %X';
$opt['locale']['ES']['format']['time'] = '%H:%M';
$opt['locale']['ES']['format']['timesec'] = '%X';
$opt['locale']['ES']['country'] = 'ES';
$opt['locale']['ES']['page']['subtitle1'] = 'Geocaching con Opencaching';
$opt['locale']['ES']['page']['subtitle2'] = '';
$opt['locale']['SV']['timezone'] = 'Europe/Berlin';
$opt['locale']['SV']['format']['date'] = '%Y-%m-%d';
$opt['locale']['SV']['format']['datelong'] = '%Y-%m-%d';
$opt['locale']['SV']['format']['datetime'] = '%x %H:%M';
$opt['locale']['SV']['format']['datetimesec'] = '%x %X';
$opt['locale']['SV']['format']['time'] = '%H:%M';
$opt['locale']['SV']['format']['timesec'] = '%X';
$opt['locale']['SV']['country'] = 'SE';
$opt['locale']['SV']['page']['subtitle1'] = 'Geocaching med Opencaching';
$opt['locale']['SV']['page']['subtitle2'] = '';
$opt['locale']['NO']['timezone'] = 'Europe/Berlin';
$opt['locale']['NO']['format']['date'] = '%Y-%m-%d';
$opt['locale']['NO']['format']['datelong'] = '%Y-%m-%d';
$opt['locale']['NO']['format']['datetime'] = '%x %H:%M';
$opt['locale']['NO']['format']['datetimesec'] = '%x %X';
$opt['locale']['NO']['format']['time'] = '%H:%M';
$opt['locale']['NO']['format']['timesec'] = '%X';
$opt['locale']['NO']['country'] = 'NO';
$opt['locale']['NO']['page']['subtitle1'] = 'Geocaching med Opencaching';
$opt['locale']['NO']['page']['subtitle2'] = '';
$opt['locale']['DA']['timezone'] = 'Europe/Berlin';
$opt['locale']['DA']['format']['date'] = '%Y-%m-%d';
$opt['locale']['DA']['format']['datelong'] = '%Y-%m-%d';
$opt['locale']['DA']['format']['datetime'] = '%x %H:%M';
$opt['locale']['DA']['format']['datetimesec'] = '%x %X';
$opt['locale']['DA']['format']['time'] = '%H:%M';
$opt['locale']['DA']['format']['timesec'] = '%X';
$opt['locale']['DA']['country'] = 'DK';
$opt['locale']['DA']['page']['subtitle1'] = 'Geocaching med Opencaching';
$opt['locale']['DA']['page']['subtitle2'] = '';
$opt['locale']['PT']['timezone'] = 'Europe/Berlin';
$opt['locale']['PT']['format']['date'] = '%Y-%m-%d';
$opt['locale']['PT']['format']['datelong'] = '%Y-%m-%d';
$opt['locale']['PT']['format']['datetime'] = '%x %H:%M';
$opt['locale']['PT']['format']['datetimesec'] = '%x %X';
$opt['locale']['PT']['format']['time'] = '%H:%M';
$opt['locale']['PT']['format']['timesec'] = '%X';
$opt['locale']['PT']['country'] = 'PT';
$opt['locale']['PT']['page']['subtitle1'] = 'Geocaching com Opencaching';
$opt['locale']['PT']['page']['subtitle2'] = '';
$opt['locale']['JA']['timezone'] = 'Europe/Berlin';
$opt['locale']['JA']['format']['date'] = '%Y-%m-%d';
$opt['locale']['JA']['format']['datelong'] = '%Y-%m-%d';
$opt['locale']['JA']['format']['datetime'] = '%x %H:%M';
$opt['locale']['JA']['format']['datetimesec'] = '%x %X';
$opt['locale']['JA']['format']['time'] = '%H:%M';
$opt['locale']['JA']['format']['timesec'] = '%X';
$opt['locale']['JA']['country'] = 'JP';
$opt['locale']['JA']['page']['subtitle1'] = 'Opencachingとジオキャッシング';
$opt['locale']['JA']['page']['subtitle2'] = '';
?>

View File

@ -1,139 +1,139 @@
<?php
/***************************************************************************
* For license information see doc/license.txt
*
* Unicode Reminder メモ
*
* Default settings for OC.de developer system. See also
* - config2/settings-dist.inc.php for common settings
* - config2/settings.inc.php for local settings
* - lib/settings* for version-1-code settings
***************************************************************************/
/* PHP settings
*
* PHP_DEBUG_SKIP
*
* dont use ini_set()
*
* PHP_DEBUG_OFF
*
* use the following php.ini-settings
* display_errors = On
* error_reporting = E_ALL & ~E_NOTICE
* mysql.trace_mode = Off
*
* strongly recommended settings
* register_globals = Off
*
* PHP_DEBUG_ON
*
* use the following php.ini-settings
* display_errors = On
* error_reporting = E_ALL
* mysql.trace_mode = On
*/
$opt['php']['debug'] = PHP_DEBUG_ON;
/* settings for the template engine
*
*/
// ... how long a query can take without warning (0 <= disabled)
$opt['db']['warn']['time'] = 0;
$opt['db']['warn']['mail'] = 'root';
$opt['db']['warn']['subject'] = 'sql_warn';
// display mysql error messages on the website - not recommended for productive use!
$opt['db']['error']['display'] = true;
$opt['db']['error']['mail'] = 'root';
$opt['db']['error']['subject'] = 'sql_error';
/* cookie or session
*
* SAVE_COOKIE = only use cookies
* SAVE_SESSION = use php sessions
*
* to use SESSIONS set php.ini to session default values:
*
* session.auto_start = 0
* session.use_cookies = 1
* session.use_only_cookies = 0
* session.cookie_lifetime = 0
* session.cookie_path = "/"
* session.cookie_domain = ""
* session.cookie_secure = off
* session.use_trans_sid = 0
*
* other parameters may be customized
*/
$opt['session']['mode'] = SAVE_COOKIE;
$opt['session']['cookiename'] = 'oc_devel'; // only with SAVE_COOKIE
$opt['session']['path'] = '/';
$opt['session']['domain'] = ''; // may be overwritten by $opt['domain'][...]['cookiedomain']
/* If the Referer was sent by the client and the substring was not found,
* the embedded session id will be marked as invalid.
* Only used with session.mode = SAVE_SESSION
*/
$opt['session']['check_referer'] = true;
/* Debug level (combine with OR | )
* DEBUG_NO = productive use
* DEBUG_DEVELOPER = developer system
* DEBUG_TEMPLATES = no template caching
* DEBUG_OUTOFSERVICE = only admin login (includes DEBUG_TEMPLATES)
* DEBUG_TESTING = display warning (includes DEBUG_TEMPLATES)
* DEBUG_SQLDEBUGGER = sql debugger (use &sqldebug=1 when calling the site)
* DEBUG_TRANSLATE = read translate messages (use &trans=1 when calling the site)
* DEBUG_FORCE_TRANSLATE = force read of translate messages
* DEBUG_CLI = print debug messages of cli scripts
*/
$opt['debug'] = DEBUG_DEVELOPER|DEBUG_TEMPLATES|DEBUG_SQLDEBUGGER|DEBUG_TRANSLATE|DEBUG_FORCE_TRANSLATE;
//$opt['debug'] = DEBUG_DEVELOPER|DEBUG_TEMPLATES|DEBUG_SQLDEBUGGER;
//$opt['debug'] = DEBUG_DEVELOPER|DEBUG_SQLDEBUGGER;
// node ID
$opt['logic']['node']['id'] = 4;
/* other template options
*
*/
$opt['page']['absolute_url'] = $dev_baseurl;
$opt['mail']['from'] = 'root';
$opt['mail']['subject'] = '[local.opencaching.de] ';
/* location of uploaded images
*/
$opt['logic']['pictures']['dir'] = $dev_basepath . $dev_codepath . 'htdocs/images/uploads';
$opt['logic']['pictures']['url'] = $opt['page']['absolute_url'] . '/images/uploads';
$opt['logic']['pictures']['thumb_url'] = $opt['logic']['pictures']['url'] . '/thumbs';
/* cachemaps
*/
$opt['logic']['cachemaps']['wmsurl'] = 'http://www.opencaching.de/cachemaps.php?wp={wp_oc}';
/* E-Mail for notification about news (newstopic.php)
*/
$opt['news']['mail'] = 'root';
$opt['mail']['subject'] = '[local.opencaching.de] ';
/* 3rd party library options
* see https://my.garmin.com/api/communicator/key-generator.jsp
*/
$opt['lib']['garmin']['key'] = '00112233445566778899AABBCCDDEEFF00';
$opt['lib']['garmin']['url'] = 'http://www.site.org/';
$opt['template']['default']['style'] = 'ocstyle';
$opt['bin']['cs2cs'] = '/var/www/bin/cs2cs';
// other settings
$opt['logic']['enableHTMLInUserDescription'] = false;
$opt['page']['showdonations'] = true;
$opt['template']['locales']['SV']['show'] = false;
$opt['template']['locales']['NO']['show'] = false;
$opt['template']['locales']['DA']['show'] = false;
$opt['template']['locales']['PT']['show'] = false;
$opt['template']['locales']['JA']['show'] = false;
<?php
/***************************************************************************
* For license information see doc/license.txt
*
* Unicode Reminder メモ
*
* Default settings for OC.de developer system. See also
* - config2/settings-dist.inc.php for common settings
* - config2/settings.inc.php for local settings
* - lib/settings* for version-1-code settings
***************************************************************************/
/* PHP settings
*
* PHP_DEBUG_SKIP
*
* dont use ini_set()
*
* PHP_DEBUG_OFF
*
* use the following php.ini-settings
* display_errors = On
* error_reporting = E_ALL & ~E_NOTICE
* mysql.trace_mode = Off
*
* strongly recommended settings
* register_globals = Off
*
* PHP_DEBUG_ON
*
* use the following php.ini-settings
* display_errors = On
* error_reporting = E_ALL
* mysql.trace_mode = On
*/
$opt['php']['debug'] = PHP_DEBUG_ON;
/* settings for the template engine
*
*/
// ... how long a query can take without warning (0 <= disabled)
$opt['db']['warn']['time'] = 0;
$opt['db']['warn']['mail'] = 'root';
$opt['db']['warn']['subject'] = 'sql_warn';
// display mysql error messages on the website - not recommended for productive use!
$opt['db']['error']['display'] = true;
$opt['db']['error']['mail'] = 'root';
$opt['db']['error']['subject'] = 'sql_error';
/* cookie or session
*
* SAVE_COOKIE = only use cookies
* SAVE_SESSION = use php sessions
*
* to use SESSIONS set php.ini to session default values:
*
* session.auto_start = 0
* session.use_cookies = 1
* session.use_only_cookies = 0
* session.cookie_lifetime = 0
* session.cookie_path = "/"
* session.cookie_domain = ""
* session.cookie_secure = off
* session.use_trans_sid = 0
*
* other parameters may be customized
*/
$opt['session']['mode'] = SAVE_COOKIE;
$opt['session']['cookiename'] = 'oc_devel'; // only with SAVE_COOKIE
$opt['session']['path'] = '/';
$opt['session']['domain'] = ''; // may be overwritten by $opt['domain'][...]['cookiedomain']
/* If the Referer was sent by the client and the substring was not found,
* the embedded session id will be marked as invalid.
* Only used with session.mode = SAVE_SESSION
*/
$opt['session']['check_referer'] = true;
/* Debug level (combine with OR | )
* DEBUG_NO = productive use
* DEBUG_DEVELOPER = developer system
* DEBUG_TEMPLATES = no template caching
* DEBUG_OUTOFSERVICE = only admin login (includes DEBUG_TEMPLATES)
* DEBUG_TESTING = display warning (includes DEBUG_TEMPLATES)
* DEBUG_SQLDEBUGGER = sql debugger (use &sqldebug=1 when calling the site)
* DEBUG_TRANSLATE = read translate messages (use &trans=1 when calling the site)
* DEBUG_FORCE_TRANSLATE = force read of translate messages
* DEBUG_CLI = print debug messages of cli scripts
*/
$opt['debug'] = DEBUG_DEVELOPER|DEBUG_TEMPLATES|DEBUG_SQLDEBUGGER|DEBUG_TRANSLATE|DEBUG_FORCE_TRANSLATE;
//$opt['debug'] = DEBUG_DEVELOPER|DEBUG_TEMPLATES|DEBUG_SQLDEBUGGER;
//$opt['debug'] = DEBUG_DEVELOPER|DEBUG_SQLDEBUGGER;
// node ID
$opt['logic']['node']['id'] = 4;
/* other template options
*
*/
$opt['page']['absolute_url'] = $dev_baseurl;
$opt['mail']['from'] = 'root';
$opt['mail']['subject'] = '[local.opencaching.de] ';
/* location of uploaded images
*/
$opt['logic']['pictures']['dir'] = $dev_basepath . $dev_codepath . 'htdocs/images/uploads';
$opt['logic']['pictures']['url'] = $opt['page']['absolute_url'] . '/images/uploads';
$opt['logic']['pictures']['thumb_url'] = $opt['logic']['pictures']['url'] . '/thumbs';
/* cachemaps
*/
$opt['logic']['cachemaps']['wmsurl'] = 'http://www.opencaching.de/cachemaps.php?wp={wp_oc}';
/* E-Mail for notification about news (newstopic.php)
*/
$opt['news']['mail'] = 'root';
$opt['mail']['subject'] = '[local.opencaching.de] ';
/* 3rd party library options
* see https://my.garmin.com/api/communicator/key-generator.jsp
*/
$opt['lib']['garmin']['key'] = '00112233445566778899AABBCCDDEEFF00';
$opt['lib']['garmin']['url'] = 'http://www.site.org/';
$opt['template']['default']['style'] = 'ocstyle';
$opt['bin']['cs2cs'] = '/var/www/bin/cs2cs';
// other settings
$opt['logic']['enableHTMLInUserDescription'] = false;
$opt['page']['showdonations'] = true;
$opt['template']['locales']['SV']['show'] = false;
$opt['template']['locales']['NO']['show'] = false;
$opt['template']['locales']['DA']['show'] = false;
$opt['template']['locales']['PT']['show'] = false;
$opt['template']['locales']['JA']['show'] = false;
?>

View File

@ -1,24 +1,24 @@
Database changes since Version 3.0
master branch
date commit ID change
---- --------- --------
2012-08-06 1ba2be52 changed triggers sysTransBeforeInsert and sysTransTextBeforeInsert
2012-08-07 eda58c51 new field caches.is_publishdate; changed trigger cachesBeforeUpdate
2012-08-08 fc481334 changed trigger cachesBeforeInsert
2012-08-23 b7ae9cc1 increased caches.wp_oc length from 6 to 7 chars
2012-08-23 bdc79495 OKAPI will do these changes AUTOMATICALLY upon installation:
- add okapi_* tables
- add caches.okapi_syncbase, initialize it and add corresponding index
- add and initialize cache_logs(_archived).okapi_syncbase
See installation instructions at http://code.google.com/p/opencaching-api
2012-08-24 c32a4b06 added cache_rating.rating_date and index 'date'; must be initialized by:
UPDATE cache_rating SET rating_date = (SELECT MIN(`date`) FROM cache_logs WHERE cache_logs.cache_id=cache_rating.cache_id AND cache_logs.user_id=cache_rating.user_id AND cache_logs.type IN (1,7))
added trigger cacheRatingBeforeInsert
2012-08-27 9bc361c3 changed trigger cacheRatingBeforeInsert
2012-11-04 d6ae786 - new table cache_waypoint_pool
Database changes since Version 3.0
master branch
date commit ID change
---- --------- --------
2012-08-06 1ba2be52 changed triggers sysTransBeforeInsert and sysTransTextBeforeInsert
2012-08-07 eda58c51 new field caches.is_publishdate; changed trigger cachesBeforeUpdate
2012-08-08 fc481334 changed trigger cachesBeforeInsert
2012-08-23 b7ae9cc1 increased caches.wp_oc length from 6 to 7 chars
2012-08-23 bdc79495 OKAPI will do these changes AUTOMATICALLY upon installation:
- add okapi_* tables
- add caches.okapi_syncbase, initialize it and add corresponding index
- add and initialize cache_logs(_archived).okapi_syncbase
See installation instructions at http://code.google.com/p/opencaching-api
2012-08-24 c32a4b06 added cache_rating.rating_date and index 'date'; must be initialized by:
UPDATE cache_rating SET rating_date = (SELECT MIN(`date`) FROM cache_logs WHERE cache_logs.cache_id=cache_rating.cache_id AND cache_logs.user_id=cache_rating.user_id AND cache_logs.type IN (1,7))
added trigger cacheRatingBeforeInsert
2012-08-27 9bc361c3 changed trigger cacheRatingBeforeInsert
2012-11-04 d6ae786 - new table cache_waypoint_pool
- new stored functions WPTODEC() and DECTOWP()

File diff suppressed because it is too large Load Diff

View File

@ -1,49 +1,49 @@
<?php
/***************************************************************************
./lib/auth.inc.php
--------------------
begin : Fri September 16 2005
For license information see doc/license.txt
***************************************************************************/
/****************************************************************************
Unicode Reminder メモ
all login/logout related functions (reduced to auth_user, becuase
all other functions are handled by lib2/login.class.php)
Dont include this file by hand - it will be included from common.inc.php
****************************************************************************/
require($opt['rootpath'] . 'lib/login.class.php');
$autherr = 0;
define('AUTHERR_NOERROR', 0);
define('AUTHERR_TOOMUCHLOGINS', 1);
define('AUTHERR_INVALIDEMAIL', 2);
define('AUTHERR_WRONGAUTHINFO', 3);
define('AUTHERR_USERNOTACTIVE', 4);
/* auth_user - fills usr[]
* no return value
*/
function auth_user()
{
global $usr, $login;
$login->verify();
if ($login->userid != 0)
{
//set up $usr array
$usr['userid'] = $login->userid;
$usr['email'] = sqlValue("SELECT `email` FROM `user` WHERE `user_id`='" . sql_escape($login->userid) . "'", '');
$usr['username'] = $login->username;
}
else
$usr = false;
return;
}
<?php
/***************************************************************************
./lib/auth.inc.php
--------------------
begin : Fri September 16 2005
For license information see doc/license.txt
***************************************************************************/
/****************************************************************************
Unicode Reminder メモ
all login/logout related functions (reduced to auth_user, becuase
all other functions are handled by lib2/login.class.php)
Dont include this file by hand - it will be included from common.inc.php
****************************************************************************/
require($opt['rootpath'] . 'lib/login.class.php');
$autherr = 0;
define('AUTHERR_NOERROR', 0);
define('AUTHERR_TOOMUCHLOGINS', 1);
define('AUTHERR_INVALIDEMAIL', 2);
define('AUTHERR_WRONGAUTHINFO', 3);
define('AUTHERR_USERNOTACTIVE', 4);
/* auth_user - fills usr[]
* no return value
*/
function auth_user()
{
global $usr, $login;
$login->verify();
if ($login->userid != 0)
{
//set up $usr array
$usr['userid'] = $login->userid;
$usr['email'] = sqlValue("SELECT `email` FROM `user` WHERE `user_id`='" . sql_escape($login->userid) . "'", '');
$usr['username'] = $login->username;
}
else
$usr = false;
return;
}
?>

View File

@ -1,167 +1,167 @@
<?php
/***************************************************************************
* For license information see doc/license.txt
*
* Unicode Reminder メモ
*
* This class provides access to the login user data. Informations are
* stored in a cookie.
*
* Methods:
* verify() validate the login-session
*
* Properties:
* userid Integer 0 if no login, userid otherwise
* username String username or ''
*
***************************************************************************/
define('LOGIN_UNKNOWN_ERROR', -1); // unkown error occured
define('LOGIN_OK', 0); // login succeeded
define('LOGIN_BADUSERPW', 1); // bad username or password
define('LOGIN_TOOMUCHLOGINS', 2); // too many logins in short time
define('LOGIN_USERNOTACTIVE', 3); // the useraccount locked
define('LOGIN_EMPTY_USERPASSWORD', 4); // given username/password was empty
define('LOGIN_LOGOUT_OK', 5); // logout was successfull
// login times in seconds
define('LOGIN_TIME', 60*60);
define('LOGIN_TIME_PERMANENT', 90*24*60*60);
$login = new login();
class login
{
var $userid = 0;
var $username = '';
var $lastlogin = 0;
var $permanent = false;
var $sessionid = '';
var $verified = false;
var $admin = false;
function login()
{
global $cookie;
if ($cookie->is_set('userid') && $cookie->is_set('username'))
{
$this->userid = $cookie->get('userid')+0;
$this->username = $cookie->get('username');
$this->permanent = (($cookie->get('permanent')+0) == 1);
$this->lastlogin = $cookie->get('lastlogin');
$this->sessionid = $cookie->get('sessionid');
$this->admin = (($cookie->get('admin')+0) == 1);
$this->verified = false;
$this->verify();
}
else
$this->pClear();
}
function pClear()
{
// set to no valid login
$this->userid = 0;
$this->username = '';
$this->permanent = false;
$this->lastlogin = '';
$this->sessionid = '';
$this->admin = false;
$this->verified = true;
$this->pStoreCookie();
}
function pStoreCookie()
{
global $cookie;
$cookie->set('userid', $this->userid);
$cookie->set('username', $this->username);
$cookie->set('permanent', ($this->permanent==true ? 1 : 0));
$cookie->set('lastlogin', $this->lastlogin);
$cookie->set('sessionid', $this->sessionid);
$cookie->set('admin', ($this->admin==true ? 1 : 0));
}
function verify()
{
if ($this->verified == true)
return;
if ($this->userid == 0)
{
$this->pClear();
return;
}
if ($this->checkLoginsCount() == false)
{
$this->pClear();
return;
}
$min_lastlogin = date('Y-m-d H:i:s', time() - LOGIN_TIME);
$min_lastlogin_permanent = date('Y-m-d H:i:s', time() - LOGIN_TIME_PERMANENT);
$rs = sql("SELECT `sys_sessions`.`last_login`, `user`.`admin` FROM &db.`sys_sessions`, &db.`user` WHERE `sys_sessions`.`user_id`=`user`.`user_id` AND `user`.`is_active_flag`=1 AND `sys_sessions`.`uuid`='&1' AND `sys_sessions`.`user_id`='&2' AND ((`sys_sessions`.`permanent`=1 AND `sys_sessions`.`last_login`>'&3') OR (`sys_sessions`.`permanent`=0 AND `sys_sessions`.`last_login`>'&4'))", $this->sessionid, $this->userid, $min_lastlogin_permanent, $min_lastlogin);
if ($rUser = sql_fetch_assoc($rs))
{
if ((($this->permanent == true) && (strtotime($rUser['last_login']) + LOGIN_TIME/2 < time())) ||
(($this->permanent == false) && (strtotime($rUser['last_login']) + LOGIN_TIME_PERMANENT/2 < time())))
{
sql("UPDATE `sys_sessions` SET `sys_sessions`.`last_login`=NOW() WHERE `sys_sessions`.`uuid`='&1' AND `sys_sessions`.`user_id`='&2'", $this->sessionid, $this->userid);
$rUser['last_login'] = date('Y-m-d H:i:s');
}
// user.last_login is used for statics, so we keep it up2date
sql("UPDATE `user` SET `user`.`last_login`=NOW() WHERE `user`.`user_id`='&1'", $this->userid);
$this->lastlogin = $rUser['last_login'];
$this->admin = ($rUser['admin'] == 1);
$this->verified = true;
}
else
{
// prevent bruteforce
sql("INSERT INTO `sys_logins` (`remote_addr`, `success`) VALUES ('&1', 0)", $_SERVER['REMOTE_ADDR']);
$this->pClear();
}
sql_free_result($rs);
$this->pStoreCookie();
return;
}
public function hasAdminPriv($privilege = false)
{
global $cookie;
$this->verify();
if ($privilege === false)
return $this->admin != 0;
return ($this->admin & $privilege) == $privilege;
}
function checkLoginsCount()
{
global $opt;
// cleanup old entries
// (execute only every 50 search calls)
if (rand(1, 50) == 1)
sql("DELETE FROM `sys_logins` WHERE `date_created`<'&1'", date('Y-m-d H:i:s', time() - 3600));
// check the number of logins in the last hour ...
$logins_count = sqlValue("SELECT COUNT(*) `count` FROM `sys_logins` WHERE `remote_addr`='" . sql_escape($_SERVER['REMOTE_ADDR']) . "' AND `date_created`>'" . sql_escape(date('Y-m-d H:i:s', time() - 3600)) . "'", 0);
if ($logins_count > $opt['page']['max_logins_per_hour'])
return false;
else
return true;
}
}
<?php
/***************************************************************************
* For license information see doc/license.txt
*
* Unicode Reminder メモ
*
* This class provides access to the login user data. Informations are
* stored in a cookie.
*
* Methods:
* verify() validate the login-session
*
* Properties:
* userid Integer 0 if no login, userid otherwise
* username String username or ''
*
***************************************************************************/
define('LOGIN_UNKNOWN_ERROR', -1); // unkown error occured
define('LOGIN_OK', 0); // login succeeded
define('LOGIN_BADUSERPW', 1); // bad username or password
define('LOGIN_TOOMUCHLOGINS', 2); // too many logins in short time
define('LOGIN_USERNOTACTIVE', 3); // the useraccount locked
define('LOGIN_EMPTY_USERPASSWORD', 4); // given username/password was empty
define('LOGIN_LOGOUT_OK', 5); // logout was successfull
// login times in seconds
define('LOGIN_TIME', 60*60);
define('LOGIN_TIME_PERMANENT', 90*24*60*60);
$login = new login();
class login
{
var $userid = 0;
var $username = '';
var $lastlogin = 0;
var $permanent = false;
var $sessionid = '';
var $verified = false;
var $admin = false;
function login()
{
global $cookie;
if ($cookie->is_set('userid') && $cookie->is_set('username'))
{
$this->userid = $cookie->get('userid')+0;
$this->username = $cookie->get('username');
$this->permanent = (($cookie->get('permanent')+0) == 1);
$this->lastlogin = $cookie->get('lastlogin');
$this->sessionid = $cookie->get('sessionid');
$this->admin = (($cookie->get('admin')+0) == 1);
$this->verified = false;
$this->verify();
}
else
$this->pClear();
}
function pClear()
{
// set to no valid login
$this->userid = 0;
$this->username = '';
$this->permanent = false;
$this->lastlogin = '';
$this->sessionid = '';
$this->admin = false;
$this->verified = true;
$this->pStoreCookie();
}
function pStoreCookie()
{
global $cookie;
$cookie->set('userid', $this->userid);
$cookie->set('username', $this->username);
$cookie->set('permanent', ($this->permanent==true ? 1 : 0));
$cookie->set('lastlogin', $this->lastlogin);
$cookie->set('sessionid', $this->sessionid);
$cookie->set('admin', ($this->admin==true ? 1 : 0));
}
function verify()
{
if ($this->verified == true)
return;
if ($this->userid == 0)
{
$this->pClear();
return;
}
if ($this->checkLoginsCount() == false)
{
$this->pClear();
return;
}
$min_lastlogin = date('Y-m-d H:i:s', time() - LOGIN_TIME);
$min_lastlogin_permanent = date('Y-m-d H:i:s', time() - LOGIN_TIME_PERMANENT);
$rs = sql("SELECT `sys_sessions`.`last_login`, `user`.`admin` FROM &db.`sys_sessions`, &db.`user` WHERE `sys_sessions`.`user_id`=`user`.`user_id` AND `user`.`is_active_flag`=1 AND `sys_sessions`.`uuid`='&1' AND `sys_sessions`.`user_id`='&2' AND ((`sys_sessions`.`permanent`=1 AND `sys_sessions`.`last_login`>'&3') OR (`sys_sessions`.`permanent`=0 AND `sys_sessions`.`last_login`>'&4'))", $this->sessionid, $this->userid, $min_lastlogin_permanent, $min_lastlogin);
if ($rUser = sql_fetch_assoc($rs))
{
if ((($this->permanent == true) && (strtotime($rUser['last_login']) + LOGIN_TIME/2 < time())) ||
(($this->permanent == false) && (strtotime($rUser['last_login']) + LOGIN_TIME_PERMANENT/2 < time())))
{
sql("UPDATE `sys_sessions` SET `sys_sessions`.`last_login`=NOW() WHERE `sys_sessions`.`uuid`='&1' AND `sys_sessions`.`user_id`='&2'", $this->sessionid, $this->userid);
$rUser['last_login'] = date('Y-m-d H:i:s');
}
// user.last_login is used for statics, so we keep it up2date
sql("UPDATE `user` SET `user`.`last_login`=NOW() WHERE `user`.`user_id`='&1'", $this->userid);
$this->lastlogin = $rUser['last_login'];
$this->admin = ($rUser['admin'] == 1);
$this->verified = true;
}
else
{
// prevent bruteforce
sql("INSERT INTO `sys_logins` (`remote_addr`, `success`) VALUES ('&1', 0)", $_SERVER['REMOTE_ADDR']);
$this->pClear();
}
sql_free_result($rs);
$this->pStoreCookie();
return;
}
public function hasAdminPriv($privilege = false)
{
global $cookie;
$this->verify();
if ($privilege === false)
return $this->admin != 0;
return ($this->admin & $privilege) == $privilege;
}
function checkLoginsCount()
{
global $opt;
// cleanup old entries
// (execute only every 50 search calls)
if (rand(1, 50) == 1)
sql("DELETE FROM `sys_logins` WHERE `date_created`<'&1'", date('Y-m-d H:i:s', time() - 3600));
// check the number of logins in the last hour ...
$logins_count = sqlValue("SELECT COUNT(*) `count` FROM `sys_logins` WHERE `remote_addr`='" . sql_escape($_SERVER['REMOTE_ADDR']) . "' AND `date_created`>'" . sql_escape(date('Y-m-d H:i:s', time() - 3600)) . "'", 0);
if ($logins_count > $opt['page']['max_logins_per_hour'])
return false;
else
return true;
}
}
?>

View File

@ -1,430 +1,430 @@
<?php
/***************************************************************************
* For license information see doc/license.txt
*
* Unicode Reminder メモ
*
* get/set has to be commited with save
* add/remove etc. is executed instantly
***************************************************************************/
require_once($opt['rootpath'] . 'lib2/logic/rowEditor.class.php');
class cache
{
var $nCacheId = 0;
var $reCache;
static function cacheIdFromWP($wp)
{
$cacheid = 0;
if (mb_strtoupper(mb_substr($wp, 0, 2)) == 'GC')
{
$rs = sql("SELECT `cache_id` FROM `caches` WHERE `wp_gc`='&1'", $wp);
if (sql_num_rows($rs) != 1)
{
sql_free_result($rs);
return null;
}
$r = sql_fetch_assoc($rs);
sql_free_result($rs);
$cacheid = $r['cache_id'];
}
else if (mb_strtoupper(mb_substr($wp, 0, 1)) == 'N')
{
$rs = sql("SELECT `cache_id` FROM `caches` WHERE `wp_nc`='&1'", $wp);
if (sql_num_rows($rs) != 1)
{
sql_free_result($rs);
return null;
}
$r = sql_fetch_assoc($rs);
sql_free_result($rs);
$cacheid = $r['cache_id'];
}
else
{
$cacheid = sql_value("SELECT `cache_id` FROM `caches` WHERE `wp_oc`='&1'", 0, $wp);
}
return $cacheid;
}
static function fromWP($wp)
{
$cacheid = cache::cacheIdFromWP($wp);
if ($cacheid == 0)
return null;
return new cache($cacheid);
}
static function cacheIdFromUUID($uuid)
{
$cacheid = sql_value("SELECT `cache_id` FROM `caches` WHERE `uuid`='&1'", 0, $uuid);
return $cacheid;
}
static function fromUUID($uuid)
{
$cacheid = cache::cacheIdFromUUID($uuid);
if ($cacheid == 0)
return null;
return new cache($cacheid);
}
function __construct($nNewCacheId=ID_NEW)
{
$this->reCache = new rowEditor('caches');
$this->reCache->addPKInt('cache_id', null, false, RE_INSERT_AUTOINCREMENT);
$this->reCache->addString('uuid', '', false, RE_INSERT_AUTOUUID);
$this->reCache->addInt('node', 0, false);
$this->reCache->addDate('date_created', time(), true, RE_INSERT_IGNORE);
$this->reCache->addDate('last_modified', time(), true, RE_INSERT_IGNORE);
$this->reCache->addInt('user_id', 0, false);
$this->reCache->addString('name', '', false);
$this->reCache->addDouble('longitude', 0, false);
$this->reCache->addDouble('latitude', 0, false);
$this->reCache->addInt('type', 1, false);
$this->reCache->addInt('status', 5, false);
$this->reCache->addString('country', '', false);
$this->reCache->addDate('date_hidden', time(), false);
$this->reCache->addInt('size', 1, false);
$this->reCache->addFloat('difficulty', 1, false);
$this->reCache->addFloat('terrain', 1, false);
$this->reCache->addString('logpw', '', false);
$this->reCache->addFloat('search_time', 0, false);
$this->reCache->addFloat('way_length', 0, false);
$this->reCache->addString('wp_oc', null, true);
$this->reCache->addString('wp_gc', '', false);
$this->reCache->addString('wp_nc', '', false);
$this->reCache->addString('desc_languages', '', false, RE_INSERT_IGNORE);
$this->reCache->addString('default_desclang', '', false);
$this->reCache->addDate('date_activate', null, true);
$this->reCache->addInt('need_npa_recalc', 1, false, RE_INSERT_IGNORE);
$this->nCacheId = $nNewCacheId+0;
if ($nNewCacheId == ID_NEW)
{
$this->reCache->addNew(null);
}
else
{
$this->reCache->load($this->nCacheId);
}
}
function exist()
{
return $this->reCache->exist();
}
function getCacheId()
{
return $this->nCacheId;
}
function getStatus()
{
return $this->reCache->getValue('status');
}
function getType()
{
return $this->reCache->getValue('type');
}
function getName()
{
return $this->reCache->getValue('name');
}
function getLongitude()
{
return $this->reCache->getValue('longitude');
}
function getLatitude()
{
return $this->reCache->getValue('latitude');
}
function getUserId()
{
return $this->reCache->getValue('user_id');
}
function getUsername()
{
return sql_value("SELECT `username` FROM `user` WHERE `user_id`='&1'", '', $this->getUserId());
}
function getWPOC()
{
return $this->reCache->getValue('wp_oc');
}
function getWPGC()
{
return $this->reCache->getValue('wp_gc');
}
function getWPNC()
{
return $this->reCache->getValue('wp_nc');
}
function getUUID()
{
return $this->reCache->getValue('uuid');
}
function getLastModified()
{
return $this->reCache->getValue('last_modified');
}
function getDateCreated()
{
return $this->reCache->getValue('date_created');
}
function getNode()
{
return $this->reCache->getValue('node');
}
function setNode($value)
{
return $this->reCache->setValue('node', $value);
}
function setStatus($value)
{
if (sql_value("SELECT COUNT(*) FROM `cache_status` WHERE `id`='&1'", 0, $value) == 1)
{
return $this->reCache->setValue('status', $value);
}
else
{
return false;
}
}
function getAnyChanged()
{
return $this->reCache->getAnyChanged();
}
// return if successfull (with insert)
function save()
{
if ($this->reCache->save())
{
sql_slave_exclude();
return true;
}
else
return false;
}
function requireLogPW()
{
return $this->reCache->getValue('logpw') != '';
}
// TODO: use prepared one way hash
function validateLogPW($nLogType, $sLogPW)
{
if ($sLogPW == '')
return true;
if (sql_value("SELECT `require_password` FROM `log_types` WHERE `id`='&1'", 0, $nLogType) == 0)
return true;
return ($sLogPW == $this->reCache->getValue('logpw'));
}
static function visitCounter($nVisitUserId, $sRemoteAddr, $nCacheId)
{
// delete cache_visits older 1 day 60*60*24 = 86400
sql("DELETE FROM `cache_visits` WHERE `cache_id`='&1' AND `user_id_ip`!='0' AND NOW()-`last_modified`>86400", $nCacheId);
if ($nVisitUserId==0)
$sIdentifier = $sRemoteAddr;
else
$sIdentifier = $nVisitUserId;
// note the visit of this user
sql("INSERT INTO `cache_visits` (`cache_id`, `user_id_ip`, `count`) VALUES (&1, '&2', 1)
ON DUPLICATE KEY UPDATE `count`=`count`+1", $nCacheId, $sIdentifier);
// if the previous statement does an INSERT, it was the first visit for this user
if (sql_affected_rows() == 1)
{
if ($nVisitUserId != sql_value("SELECT `user_id` FROM `caches` WHERE `cache_id`='&1'", 0, $nCacheId))
{
// increment the counter for this cache
sql("INSERT INTO `cache_visits` (`cache_id`, `user_id_ip`, `count`) VALUES (&1, '0', 1)
ON DUPLICATE KEY UPDATE `count`=`count`+1", $nCacheId);
}
}
}
static function getLogsCount($cacheid)
{
//prepare the logs
$rsLogs = sql("SELECT COUNT(*) FROM `cache_logs` WHERE `cache_id`='&1'", $cacheid);
$rLog = sql_fetch_assoc($rsLogs);
sql_free_result($rsLogs);
return $rLog;
}
static function getLogsArray($cacheid, $start, $count)
{
//prepare the logs
$rsLogs = sql("
SELECT `cache_logs`.`user_id` AS `userid`,
`cache_logs`.`id` AS `id`,
`cache_logs`.`uuid` AS `uuid`,
`cache_logs`.`date` AS `date`,
`cache_logs`.`type` AS `type`,
`cache_logs`.`text` AS `text`,
`cache_logs`.`text_html` AS `texthtml`,
`cache_logs`.`picture`,
`user`.`username` AS `username`,
IF(ISNULL(`cache_rating`.`cache_id`), 0, `cache_logs`.`type` IN (1,7)) AS `recommended`
FROM `cache_logs`
INNER JOIN `user` ON `user`.`user_id` = `cache_logs`.`user_id`
LEFT JOIN `cache_rating` ON `cache_logs`.`cache_id`=`cache_rating`.`cache_id` AND `cache_logs`.`user_id`=`cache_rating`.`user_id`
WHERE `cache_logs`.`cache_id`='&1'
ORDER BY `cache_logs`.`date` DESC, `cache_logs`.`Id` DESC LIMIT &2, &3", $cacheid, $start+0, $count+0);
$logs = array();
while ($rLog = sql_fetch_assoc($rsLogs))
{
$pictures = array();
$rsPictures = sql("SELECT `url`, `title`, `uuid` FROM `pictures` WHERE `object_id`='&1' AND `object_type`=1", $rLog['id']);
while ($rPicture = sql_fetch_assoc($rsPictures))
$pictures[] = $rPicture;
sql_free_result($rsPictures);
$rLog['pictures'] = $pictures;
$logs[] = $rLog;
}
sql_free_result($rsLogs);
return $logs;
}
function report($userid, $reportreason, $reportnote)
{
sql("INSERT INTO cache_reports (`cacheid`, `userid`, `reason`, `note`)
VALUES(&1, &2, &3, '&4')",
$this->nCacheId, $userid, $reportreason, $reportnote);
return true;
}
function addAdoption($userid)
{
if ($this->allowEdit() == false)
return false;
if (sql_value("SELECT COUNT(*) FROM `user` WHERE `user_id`='&1' AND `is_active_flag`=1", 0, $userid) == 0)
return false;
// same user?
if ($this->getUserId() == $userid)
return false;
sql("INSERT IGNORE INTO `cache_adoption` (`cache_id`, `user_id`) VALUES ('&1', '&2')", $this->nCacheId, $userid);
return true;
}
function cancelAdoption($userid)
{
global $login;
if ($this->allowEdit() == false && $login->userid != $userid)
return false;
sql("DELETE FROM `cache_adoption` WHERE `user_id`='&1' AND `cache_id`='&2'", $userid, $this->nCacheId);
return true;
}
function commitAdoption($userid)
{
global $login;
// cache_adoption exists?
if (sql_value("SELECT COUNT(*) FROM `cache_adoption` WHERE `cache_id`='&1' AND `user_id`='&2'", 0, $this->nCacheId, $userid) == 0)
return false;
// new user active?
if (sql_value("SELECT `is_active_flag` FROM `user` WHERE `user_id`='&1'", 0, $userid) != 1)
return false;
sql("INSERT INTO `logentries` (`module`, `eventid`, `userid`, `objectid1`, `objectid2`, `logtext`)
VALUES ('cache', 5, '&1', '&2', '&3', '&4')",
$login->userid, $this->nCacheId, 0,
'Cache ' . sql_escape($this->nCacheId) . ' has changed the owner from userid ' . sql_escape($this->getUserId()) . ' to ' . sql_escape($userid) . ' by ' . sql_escape($login->userid));
sql("UPDATE `caches` SET `user_id`='&1' WHERE `cache_id`='&2'", $userid, $this->nCacheId);
sql("DELETE FROM `cache_adoption` WHERE `cache_id`='&1'", $this->nCacheId);
$this->reCache->setValue('user_id', $userid);
return true;
}
// true if anyone can view the cache
function isPublic()
{
return (sql_value("SELECT `allow_user_view` FROM `cache_status` WHERE `id`='&1'", 0, $this->getStatus()) == 1);
}
function allowView()
{
global $login;
if ($this->isPublic())
return true;
$login->verify();
if (($login->admin & ADMIN_USER) == ADMIN_USER)
return true;
else if ($this->getUserId() == $login->userid)
return true;
return false;
}
function allowEdit()
{
global $login;
$login->verify();
if ($this->getUserId() == $login->userid)
return true;
return false;
}
function allowLog()
{
global $login;
$login->verify();
if ($this->getUserId() == $login->userid)
return true;
return (sql_value("SELECT `allow_user_log` FROM `cache_status` WHERE `id`='&1'", 0, $this->getStatus()) == 1);
}
function isRecommendedByUser($nUserId)
{
return (sql_value("SELECT COUNT(*) FROM `cache_rating` WHERE `cache_id`='&1' AND `user_id`='&2'", 0, $this->nCacheId, $nUserId) > 0);
}
function addRecommendation($nUserId)
{
// rating_date will be set to NOW() by Insert-trigger
sql("INSERT IGNORE INTO `cache_rating` (`cache_id`, `user_id`) VALUES ('&1', '&2')", $this->nCacheId, $nUserId);
}
function removeRecommendation($nUserId)
{
sql("DELETE FROM `cache_rating` WHERE `cache_id`='&1' AND `user_id`='&2'", $this->nCacheId, $nUserId);
}
}
<?php
/***************************************************************************
* For license information see doc/license.txt
*
* Unicode Reminder メモ
*
* get/set has to be commited with save
* add/remove etc. is executed instantly
***************************************************************************/
require_once($opt['rootpath'] . 'lib2/logic/rowEditor.class.php');
class cache
{
var $nCacheId = 0;
var $reCache;
static function cacheIdFromWP($wp)
{
$cacheid = 0;
if (mb_strtoupper(mb_substr($wp, 0, 2)) == 'GC')
{
$rs = sql("SELECT `cache_id` FROM `caches` WHERE `wp_gc`='&1'", $wp);
if (sql_num_rows($rs) != 1)
{
sql_free_result($rs);
return null;
}
$r = sql_fetch_assoc($rs);
sql_free_result($rs);
$cacheid = $r['cache_id'];
}
else if (mb_strtoupper(mb_substr($wp, 0, 1)) == 'N')
{
$rs = sql("SELECT `cache_id` FROM `caches` WHERE `wp_nc`='&1'", $wp);
if (sql_num_rows($rs) != 1)
{
sql_free_result($rs);
return null;
}
$r = sql_fetch_assoc($rs);
sql_free_result($rs);
$cacheid = $r['cache_id'];
}
else
{
$cacheid = sql_value("SELECT `cache_id` FROM `caches` WHERE `wp_oc`='&1'", 0, $wp);
}
return $cacheid;
}
static function fromWP($wp)
{
$cacheid = cache::cacheIdFromWP($wp);
if ($cacheid == 0)
return null;
return new cache($cacheid);
}
static function cacheIdFromUUID($uuid)
{
$cacheid = sql_value("SELECT `cache_id` FROM `caches` WHERE `uuid`='&1'", 0, $uuid);
return $cacheid;
}
static function fromUUID($uuid)
{
$cacheid = cache::cacheIdFromUUID($uuid);
if ($cacheid == 0)
return null;
return new cache($cacheid);
}
function __construct($nNewCacheId=ID_NEW)
{
$this->reCache = new rowEditor('caches');
$this->reCache->addPKInt('cache_id', null, false, RE_INSERT_AUTOINCREMENT);
$this->reCache->addString('uuid', '', false, RE_INSERT_AUTOUUID);
$this->reCache->addInt('node', 0, false);
$this->reCache->addDate('date_created', time(), true, RE_INSERT_IGNORE);
$this->reCache->addDate('last_modified', time(), true, RE_INSERT_IGNORE);
$this->reCache->addInt('user_id', 0, false);
$this->reCache->addString('name', '', false);
$this->reCache->addDouble('longitude', 0, false);
$this->reCache->addDouble('latitude', 0, false);
$this->reCache->addInt('type', 1, false);
$this->reCache->addInt('status', 5, false);
$this->reCache->addString('country', '', false);
$this->reCache->addDate('date_hidden', time(), false);
$this->reCache->addInt('size', 1, false);
$this->reCache->addFloat('difficulty', 1, false);
$this->reCache->addFloat('terrain', 1, false);
$this->reCache->addString('logpw', '', false);
$this->reCache->addFloat('search_time', 0, false);
$this->reCache->addFloat('way_length', 0, false);
$this->reCache->addString('wp_oc', null, true);
$this->reCache->addString('wp_gc', '', false);
$this->reCache->addString('wp_nc', '', false);
$this->reCache->addString('desc_languages', '', false, RE_INSERT_IGNORE);
$this->reCache->addString('default_desclang', '', false);
$this->reCache->addDate('date_activate', null, true);
$this->reCache->addInt('need_npa_recalc', 1, false, RE_INSERT_IGNORE);
$this->nCacheId = $nNewCacheId+0;
if ($nNewCacheId == ID_NEW)
{
$this->reCache->addNew(null);
}
else
{
$this->reCache->load($this->nCacheId);
}
}
function exist()
{
return $this->reCache->exist();
}
function getCacheId()
{
return $this->nCacheId;
}
function getStatus()
{
return $this->reCache->getValue('status');
}
function getType()
{
return $this->reCache->getValue('type');
}
function getName()
{
return $this->reCache->getValue('name');
}
function getLongitude()
{
return $this->reCache->getValue('longitude');
}
function getLatitude()
{
return $this->reCache->getValue('latitude');
}
function getUserId()
{
return $this->reCache->getValue('user_id');
}
function getUsername()
{
return sql_value("SELECT `username` FROM `user` WHERE `user_id`='&1'", '', $this->getUserId());
}
function getWPOC()
{
return $this->reCache->getValue('wp_oc');
}
function getWPGC()
{
return $this->reCache->getValue('wp_gc');
}
function getWPNC()
{
return $this->reCache->getValue('wp_nc');
}
function getUUID()
{
return $this->reCache->getValue('uuid');
}
function getLastModified()
{
return $this->reCache->getValue('last_modified');
}
function getDateCreated()
{
return $this->reCache->getValue('date_created');
}
function getNode()
{
return $this->reCache->getValue('node');
}
function setNode($value)
{
return $this->reCache->setValue('node', $value);
}
function setStatus($value)
{
if (sql_value("SELECT COUNT(*) FROM `cache_status` WHERE `id`='&1'", 0, $value) == 1)
{
return $this->reCache->setValue('status', $value);
}
else
{
return false;
}
}
function getAnyChanged()
{
return $this->reCache->getAnyChanged();
}
// return if successfull (with insert)
function save()
{
if ($this->reCache->save())
{
sql_slave_exclude();
return true;
}
else
return false;
}
function requireLogPW()
{
return $this->reCache->getValue('logpw') != '';
}
// TODO: use prepared one way hash
function validateLogPW($nLogType, $sLogPW)
{
if ($sLogPW == '')
return true;
if (sql_value("SELECT `require_password` FROM `log_types` WHERE `id`='&1'", 0, $nLogType) == 0)
return true;
return ($sLogPW == $this->reCache->getValue('logpw'));
}
static function visitCounter($nVisitUserId, $sRemoteAddr, $nCacheId)
{
// delete cache_visits older 1 day 60*60*24 = 86400
sql("DELETE FROM `cache_visits` WHERE `cache_id`='&1' AND `user_id_ip`!='0' AND NOW()-`last_modified`>86400", $nCacheId);
if ($nVisitUserId==0)
$sIdentifier = $sRemoteAddr;
else
$sIdentifier = $nVisitUserId;
// note the visit of this user
sql("INSERT INTO `cache_visits` (`cache_id`, `user_id_ip`, `count`) VALUES (&1, '&2', 1)
ON DUPLICATE KEY UPDATE `count`=`count`+1", $nCacheId, $sIdentifier);
// if the previous statement does an INSERT, it was the first visit for this user
if (sql_affected_rows() == 1)
{
if ($nVisitUserId != sql_value("SELECT `user_id` FROM `caches` WHERE `cache_id`='&1'", 0, $nCacheId))
{
// increment the counter for this cache
sql("INSERT INTO `cache_visits` (`cache_id`, `user_id_ip`, `count`) VALUES (&1, '0', 1)
ON DUPLICATE KEY UPDATE `count`=`count`+1", $nCacheId);
}
}
}
static function getLogsCount($cacheid)
{
//prepare the logs
$rsLogs = sql("SELECT COUNT(*) FROM `cache_logs` WHERE `cache_id`='&1'", $cacheid);
$rLog = sql_fetch_assoc($rsLogs);
sql_free_result($rsLogs);
return $rLog;
}
static function getLogsArray($cacheid, $start, $count)
{
//prepare the logs
$rsLogs = sql("
SELECT `cache_logs`.`user_id` AS `userid`,
`cache_logs`.`id` AS `id`,
`cache_logs`.`uuid` AS `uuid`,
`cache_logs`.`date` AS `date`,
`cache_logs`.`type` AS `type`,
`cache_logs`.`text` AS `text`,
`cache_logs`.`text_html` AS `texthtml`,
`cache_logs`.`picture`,
`user`.`username` AS `username`,
IF(ISNULL(`cache_rating`.`cache_id`), 0, `cache_logs`.`type` IN (1,7)) AS `recommended`
FROM `cache_logs`
INNER JOIN `user` ON `user`.`user_id` = `cache_logs`.`user_id`
LEFT JOIN `cache_rating` ON `cache_logs`.`cache_id`=`cache_rating`.`cache_id` AND `cache_logs`.`user_id`=`cache_rating`.`user_id`
WHERE `cache_logs`.`cache_id`='&1'
ORDER BY `cache_logs`.`date` DESC, `cache_logs`.`Id` DESC LIMIT &2, &3", $cacheid, $start+0, $count+0);
$logs = array();
while ($rLog = sql_fetch_assoc($rsLogs))
{
$pictures = array();
$rsPictures = sql("SELECT `url`, `title`, `uuid` FROM `pictures` WHERE `object_id`='&1' AND `object_type`=1", $rLog['id']);
while ($rPicture = sql_fetch_assoc($rsPictures))
$pictures[] = $rPicture;
sql_free_result($rsPictures);
$rLog['pictures'] = $pictures;
$logs[] = $rLog;
}
sql_free_result($rsLogs);
return $logs;
}
function report($userid, $reportreason, $reportnote)
{
sql("INSERT INTO cache_reports (`cacheid`, `userid`, `reason`, `note`)
VALUES(&1, &2, &3, '&4')",
$this->nCacheId, $userid, $reportreason, $reportnote);
return true;
}
function addAdoption($userid)
{
if ($this->allowEdit() == false)
return false;
if (sql_value("SELECT COUNT(*) FROM `user` WHERE `user_id`='&1' AND `is_active_flag`=1", 0, $userid) == 0)
return false;
// same user?
if ($this->getUserId() == $userid)
return false;
sql("INSERT IGNORE INTO `cache_adoption` (`cache_id`, `user_id`) VALUES ('&1', '&2')", $this->nCacheId, $userid);
return true;
}
function cancelAdoption($userid)
{
global $login;
if ($this->allowEdit() == false && $login->userid != $userid)
return false;
sql("DELETE FROM `cache_adoption` WHERE `user_id`='&1' AND `cache_id`='&2'", $userid, $this->nCacheId);
return true;
}
function commitAdoption($userid)
{
global $login;
// cache_adoption exists?
if (sql_value("SELECT COUNT(*) FROM `cache_adoption` WHERE `cache_id`='&1' AND `user_id`='&2'", 0, $this->nCacheId, $userid) == 0)
return false;
// new user active?
if (sql_value("SELECT `is_active_flag` FROM `user` WHERE `user_id`='&1'", 0, $userid) != 1)
return false;
sql("INSERT INTO `logentries` (`module`, `eventid`, `userid`, `objectid1`, `objectid2`, `logtext`)
VALUES ('cache', 5, '&1', '&2', '&3', '&4')",
$login->userid, $this->nCacheId, 0,
'Cache ' . sql_escape($this->nCacheId) . ' has changed the owner from userid ' . sql_escape($this->getUserId()) . ' to ' . sql_escape($userid) . ' by ' . sql_escape($login->userid));
sql("UPDATE `caches` SET `user_id`='&1' WHERE `cache_id`='&2'", $userid, $this->nCacheId);
sql("DELETE FROM `cache_adoption` WHERE `cache_id`='&1'", $this->nCacheId);
$this->reCache->setValue('user_id', $userid);
return true;
}
// true if anyone can view the cache
function isPublic()
{
return (sql_value("SELECT `allow_user_view` FROM `cache_status` WHERE `id`='&1'", 0, $this->getStatus()) == 1);
}
function allowView()
{
global $login;
if ($this->isPublic())
return true;
$login->verify();
if (($login->admin & ADMIN_USER) == ADMIN_USER)
return true;
else if ($this->getUserId() == $login->userid)
return true;
return false;
}
function allowEdit()
{
global $login;
$login->verify();
if ($this->getUserId() == $login->userid)
return true;
return false;
}
function allowLog()
{
global $login;
$login->verify();
if ($this->getUserId() == $login->userid)
return true;
return (sql_value("SELECT `allow_user_log` FROM `cache_status` WHERE `id`='&1'", 0, $this->getStatus()) == 1);
}
function isRecommendedByUser($nUserId)
{
return (sql_value("SELECT COUNT(*) FROM `cache_rating` WHERE `cache_id`='&1' AND `user_id`='&2'", 0, $this->nCacheId, $nUserId) > 0);
}
function addRecommendation($nUserId)
{
// rating_date will be set to NOW() by Insert-trigger
sql("INSERT IGNORE INTO `cache_rating` (`cache_id`, `user_id`) VALUES ('&1', '&2')", $this->nCacheId, $nUserId);
}
function removeRecommendation($nUserId)
{
sql("DELETE FROM `cache_rating` WHERE `cache_id`='&1' AND `user_id`='&2'", $this->nCacheId, $nUserId);
}
}
?>

View File

@ -1,121 +1,121 @@
<?php
/***************************************************************************
* For license information see doc/license.txt
*
* Unicode Reminder メモ
*
* get/set has to be commited with save
* add/remove etc. is executed instantly
***************************************************************************/
require_once($opt['rootpath'] . 'lib2/logic/rowEditor.class.php');
class user
{
var $nCacheDescId = 0;
var $reCacheDesc;
function __construct($nNewCacheDescId=ID_NEW)
{
$this->reUser = new rowEditor('cache_desc');
$this->reUser->addPKInt('id', null, false, RE_INSERT_AUTOINCREMENT);
$this->reUser->addString('uuid', '', false, RE_INSERT_AUTOUUID);
$this->reUser->addInt('node', 0, false);
$this->reUser->addDate('date_created', time(), true, RE_INSERT_IGNORE);
$this->reUser->addDate('last_modified', time(), true, RE_INSERT_IGNORE);
$this->reUser->addInt('cache_id', 0, false);
$this->reUser->addString('language', '', false);
$this->reUser->addString('desc', '', false);
$this->reUser->addInt('desc_html', 0, false);
$this->reUser->addInt('desc_htmledit', 0, false);
$this->reUser->addString('hint', '', false);
$this->reUser->addString('short_desc', '', false);
$this->nCacheDescId = $nNewCacheDescId+0;
if ($nNewCacheDescId == ID_NEW)
{
$this->reCacheDesc->addNew(null);
}
else
{
$this->reCacheDesc->load($this->nCacheDescId);
}
}
function exist()
{
return $this->reCacheDesc->exist();
}
function getId()
{
return $this->reCacheDesc->getValue('id');
}
function getUUID()
{
return $this->reCacheDesc->getValue('uuid');
}
function getNode()
{
return $this->reCacheDesc->getValue('node');
}
function setNode($value)
{
return $this->reCacheDesc->setValue('node', $value);
}
function getDateCreated()
{
return $this->reCacheDesc->getValue('date_created');
}
function getLastModified()
{
return $this->reCacheDesc->getValue('last_modified');
}
function getCacheId()
{
return $this->reCacheDesc->getValue('cache_id');
}
function getLanguage()
{
return $this->reCacheDesc->getValue('language');
}
function getDescAsHtml()
{
return $this->reCacheDesc->getValue('desc');
}
function getIsDescHtml()
{
return ($this->reCacheDesc->getValue('desc_html')!=0);
}
function getDescHtmlEdit()
{
return ($this->reCacheDesc->getValue('desc_htmledit')!=0);
}
function getHint()
{
return $this->reCacheDesc->getValue('hint');
}
function getShortDesc()
{
return $this->reCacheDesc->getValue('short_desc');
}
function getAnyChanged()
{
return $this->reCacheDesc->getAnyChanged();
}
// return if successfull (with insert)
function save()
{
sql_slave_exclude();
return $this->reCacheDesc->save();
}
function reload()
{
$this->reCacheDesc->reload();
}
}
<?php
/***************************************************************************
* For license information see doc/license.txt
*
* Unicode Reminder メモ
*
* get/set has to be commited with save
* add/remove etc. is executed instantly
***************************************************************************/
require_once($opt['rootpath'] . 'lib2/logic/rowEditor.class.php');
class user
{
var $nCacheDescId = 0;
var $reCacheDesc;
function __construct($nNewCacheDescId=ID_NEW)
{
$this->reUser = new rowEditor('cache_desc');
$this->reUser->addPKInt('id', null, false, RE_INSERT_AUTOINCREMENT);
$this->reUser->addString('uuid', '', false, RE_INSERT_AUTOUUID);
$this->reUser->addInt('node', 0, false);
$this->reUser->addDate('date_created', time(), true, RE_INSERT_IGNORE);
$this->reUser->addDate('last_modified', time(), true, RE_INSERT_IGNORE);
$this->reUser->addInt('cache_id', 0, false);
$this->reUser->addString('language', '', false);
$this->reUser->addString('desc', '', false);
$this->reUser->addInt('desc_html', 0, false);
$this->reUser->addInt('desc_htmledit', 0, false);
$this->reUser->addString('hint', '', false);
$this->reUser->addString('short_desc', '', false);
$this->nCacheDescId = $nNewCacheDescId+0;
if ($nNewCacheDescId == ID_NEW)
{
$this->reCacheDesc->addNew(null);
}
else
{
$this->reCacheDesc->load($this->nCacheDescId);
}
}
function exist()
{
return $this->reCacheDesc->exist();
}
function getId()
{
return $this->reCacheDesc->getValue('id');
}
function getUUID()
{
return $this->reCacheDesc->getValue('uuid');
}
function getNode()
{
return $this->reCacheDesc->getValue('node');
}
function setNode($value)
{
return $this->reCacheDesc->setValue('node', $value);
}
function getDateCreated()
{
return $this->reCacheDesc->getValue('date_created');
}
function getLastModified()
{
return $this->reCacheDesc->getValue('last_modified');
}
function getCacheId()
{
return $this->reCacheDesc->getValue('cache_id');
}
function getLanguage()
{
return $this->reCacheDesc->getValue('language');
}
function getDescAsHtml()
{
return $this->reCacheDesc->getValue('desc');
}
function getIsDescHtml()
{
return ($this->reCacheDesc->getValue('desc_html')!=0);
}
function getDescHtmlEdit()
{
return ($this->reCacheDesc->getValue('desc_htmledit')!=0);
}
function getHint()
{
return $this->reCacheDesc->getValue('hint');
}
function getShortDesc()
{
return $this->reCacheDesc->getValue('short_desc');
}
function getAnyChanged()
{
return $this->reCacheDesc->getAnyChanged();
}
// return if successfull (with insert)
function save()
{
sql_slave_exclude();
return $this->reCacheDesc->save();
}
function reload()
{
$this->reCacheDesc->reload();
}
}
?>

View File

@ -1,225 +1,225 @@
<?php
/***************************************************************************
* For license information see doc/license.txt
*
* Unicode Reminder メモ
*
* get/set has to be commited with save
* add/remove etc. is executed instantly
***************************************************************************/
require_once($opt['rootpath'] . 'lib2/logic/rowEditor.class.php');
require_once($opt['rootpath'] . 'lib2/logic/cache.class.php');
class cachelog
{
var $nLogId = 0;
var $reCacheLog;
static function logIdFromUUID($uuid)
{
$cacheid = sql_value("SELECT `id` FROM `cache_logs` WHERE `uuid`='&1'", 0, $uuid);
return $cacheid;
}
static function fromUUID($uuid)
{
$logid = cachelog::logIdFromUUID($uuid);
if ($logid == 0)
return null;
return new cachelog($logid);
}
static function createNew($nCacheId, $nUserId)
{
// check if user is allowed to log this cache!
$cache = new cache($nCacheId);
if ($cache->exist() == false)
return false;
if ($cache->allowLog() == false)
return false;
$oCacheLog = new cachelog(ID_NEW);
$oCacheLog->setUserId($nUserId);
$oCacheLog->setCacheId($nCacheId);
return $oCacheLog;
}
function __construct($nNewLogId=ID_NEW)
{
$this->reCacheLog = new rowEditor('cache_logs');
$this->reCacheLog->addPKInt('id', null, false, RE_INSERT_AUTOINCREMENT);
$this->reCacheLog->addString('uuid', '', false, RE_INSERT_AUTOUUID);
$this->reCacheLog->addInt('node', 0, false);
$this->reCacheLog->addDate('date_created', time(), true, RE_INSERT_IGNORE);
$this->reCacheLog->addDate('last_modified', time(), true, RE_INSERT_IGNORE);
$this->reCacheLog->addInt('cache_id', 0, false);
$this->reCacheLog->addInt('user_id', 0, false);
$this->reCacheLog->addInt('type', 0, false);
$this->reCacheLog->addDate('date', time(), false);
$this->reCacheLog->addString('text', '', false);
$this->reCacheLog->addInt('text_html', 0, false);
$this->reCacheLog->addInt('text_htmledit', 0, false);
$this->reCacheLog->addInt('owner_notified', 0, false);
$this->reCacheLog->addInt('picture', 0, false);
$this->nLogId = $nNewLogId+0;
if ($nNewLogId == ID_NEW)
{
$this->reCacheLog->addNew(null);
}
else
{
$this->reCacheLog->load($this->nLogId);
}
}
function exist()
{
return $this->reCacheLog->exist();
}
function getLogId()
{
return $this->nLogId;
}
function getUserId()
{
return $this->reCacheLog->getValue('user_id');
}
function setUserId($value)
{
return $this->reCacheLog->setValue('user_id', $value);
}
function getCacheId()
{
return $this->reCacheLog->getValue('cache_id');
}
function setCacheId($value)
{
return $this->reCacheLog->setValue('cache_id', $value);
}
function getType()
{
return $this->reCacheLog->getValue('type');
}
function setType($value)
{
$nValidLogTypes = $this->getValidLogTypes();
if (array_search($value, $nValidLogTypes) === false)
return false;
return $this->reCacheLog->setValue('type', $value);
}
function getDate()
{
return $this->reCacheLog->getValue('date');
}
function setDate($value)
{
return $this->reCacheLog->setValue('date', $value);
}
function getText()
{
return $this->reCacheLog->getValue('text');
}
function setText($value)
{
return $this->reCacheLog->setValue('text', $value);
}
function getTextHtml()
{
return $this->reCacheLog->getValue('text_html');
}
function setTextHtml($value)
{
return $this->reCacheLog->setValue('text_html', $value);
}
function getTextHtmlEdit()
{
return $this->reCacheLog->getValue('text_html');
}
function setTextHtmlEdit($value)
{
return $this->reCacheLog->setValue('text_htmledit', $value);
}
function getUUID()
{
return $this->reCacheLog->getValue('uuid');
}
function getLastModified()
{
return $this->reCacheLog->getValue('last_modified');
}
function getDateCreated()
{
return $this->reCacheLog->getValue('date_created');
}
function getNode()
{
return $this->reCacheLog->getValue('node');
}
function setNode($value)
{
return $this->reCacheLog->setValue('node', $value);
}
function getAnyChanged()
{
return $this->reCacheLog->getAnyChanged();
}
// return if successfull (with insert)
function save()
{
sql_slave_exclude();
return $this->reCacheLog->save();
}
function allowView()
{
global $login;
$login->verify();
if (sql_value("SELECT `cache_status`.`allow_user_view` FROM `caches` INNER JOIN `cache_status` ON `caches`.`status`=`cache_status`.`id` WHERE `caches`.`cache_id`='&1'", 0, $this->getCacheId()) == 1)
return true;
else if ($login->userid == sql_value("SELECT `user_id` FROM `caches` WHERE `cache_id`='&1'", 0, $this->getCacheId()))
return true;
return false;
}
function allowEdit()
{
global $login;
$login->verify();
if ($this->getUserId() == $login->userid)
return true;
return false;
}
/* will depend on userid in future e.g. maintainance-logs etc. */
function getValidLogTypes()
{
$cache = new cache($this->getCacheId());
if ($cache->exist() == false)
return array();
if ($cache->allowLog() == false)
return array();
$nTypes = array();
$rs = sql("SELECT `log_type_id` FROM `cache_logtype` WHERE `cache_type_id`='&1'", $cache->getType());
while ($r = sql_fetch_assoc($rs))
$nTypes[] = $r['log_type_id'];
sql_free_result($rs);
return $nTypes;
}
}
<?php
/***************************************************************************
* For license information see doc/license.txt
*
* Unicode Reminder メモ
*
* get/set has to be commited with save
* add/remove etc. is executed instantly
***************************************************************************/
require_once($opt['rootpath'] . 'lib2/logic/rowEditor.class.php');
require_once($opt['rootpath'] . 'lib2/logic/cache.class.php');
class cachelog
{
var $nLogId = 0;
var $reCacheLog;
static function logIdFromUUID($uuid)
{
$cacheid = sql_value("SELECT `id` FROM `cache_logs` WHERE `uuid`='&1'", 0, $uuid);
return $cacheid;
}
static function fromUUID($uuid)
{
$logid = cachelog::logIdFromUUID($uuid);
if ($logid == 0)
return null;
return new cachelog($logid);
}
static function createNew($nCacheId, $nUserId)
{
// check if user is allowed to log this cache!
$cache = new cache($nCacheId);
if ($cache->exist() == false)
return false;
if ($cache->allowLog() == false)
return false;
$oCacheLog = new cachelog(ID_NEW);
$oCacheLog->setUserId($nUserId);
$oCacheLog->setCacheId($nCacheId);
return $oCacheLog;
}
function __construct($nNewLogId=ID_NEW)
{
$this->reCacheLog = new rowEditor('cache_logs');
$this->reCacheLog->addPKInt('id', null, false, RE_INSERT_AUTOINCREMENT);
$this->reCacheLog->addString('uuid', '', false, RE_INSERT_AUTOUUID);
$this->reCacheLog->addInt('node', 0, false);
$this->reCacheLog->addDate('date_created', time(), true, RE_INSERT_IGNORE);
$this->reCacheLog->addDate('last_modified', time(), true, RE_INSERT_IGNORE);
$this->reCacheLog->addInt('cache_id', 0, false);
$this->reCacheLog->addInt('user_id', 0, false);
$this->reCacheLog->addInt('type', 0, false);
$this->reCacheLog->addDate('date', time(), false);
$this->reCacheLog->addString('text', '', false);
$this->reCacheLog->addInt('text_html', 0, false);
$this->reCacheLog->addInt('text_htmledit', 0, false);
$this->reCacheLog->addInt('owner_notified', 0, false);
$this->reCacheLog->addInt('picture', 0, false);
$this->nLogId = $nNewLogId+0;
if ($nNewLogId == ID_NEW)
{
$this->reCacheLog->addNew(null);
}
else
{
$this->reCacheLog->load($this->nLogId);
}
}
function exist()
{
return $this->reCacheLog->exist();
}
function getLogId()
{
return $this->nLogId;
}
function getUserId()
{
return $this->reCacheLog->getValue('user_id');
}
function setUserId($value)
{
return $this->reCacheLog->setValue('user_id', $value);
}
function getCacheId()
{
return $this->reCacheLog->getValue('cache_id');
}
function setCacheId($value)
{
return $this->reCacheLog->setValue('cache_id', $value);
}
function getType()
{
return $this->reCacheLog->getValue('type');
}
function setType($value)
{
$nValidLogTypes = $this->getValidLogTypes();
if (array_search($value, $nValidLogTypes) === false)
return false;
return $this->reCacheLog->setValue('type', $value);
}
function getDate()
{
return $this->reCacheLog->getValue('date');
}
function setDate($value)
{
return $this->reCacheLog->setValue('date', $value);
}
function getText()
{
return $this->reCacheLog->getValue('text');
}
function setText($value)
{
return $this->reCacheLog->setValue('text', $value);
}
function getTextHtml()
{
return $this->reCacheLog->getValue('text_html');
}
function setTextHtml($value)
{
return $this->reCacheLog->setValue('text_html', $value);
}
function getTextHtmlEdit()
{
return $this->reCacheLog->getValue('text_html');
}
function setTextHtmlEdit($value)
{
return $this->reCacheLog->setValue('text_htmledit', $value);
}
function getUUID()
{
return $this->reCacheLog->getValue('uuid');
}
function getLastModified()
{
return $this->reCacheLog->getValue('last_modified');
}
function getDateCreated()
{
return $this->reCacheLog->getValue('date_created');
}
function getNode()
{
return $this->reCacheLog->getValue('node');
}
function setNode($value)
{
return $this->reCacheLog->setValue('node', $value);
}
function getAnyChanged()
{
return $this->reCacheLog->getAnyChanged();
}
// return if successfull (with insert)
function save()
{
sql_slave_exclude();
return $this->reCacheLog->save();
}
function allowView()
{
global $login;
$login->verify();
if (sql_value("SELECT `cache_status`.`allow_user_view` FROM `caches` INNER JOIN `cache_status` ON `caches`.`status`=`cache_status`.`id` WHERE `caches`.`cache_id`='&1'", 0, $this->getCacheId()) == 1)
return true;
else if ($login->userid == sql_value("SELECT `user_id` FROM `caches` WHERE `cache_id`='&1'", 0, $this->getCacheId()))
return true;
return false;
}
function allowEdit()
{
global $login;
$login->verify();
if ($this->getUserId() == $login->userid)
return true;
return false;
}
/* will depend on userid in future e.g. maintainance-logs etc. */
function getValidLogTypes()
{
$cache = new cache($this->getCacheId());
if ($cache->exist() == false)
return array();
if ($cache->allowLog() == false)
return array();
$nTypes = array();
$rs = sql("SELECT `log_type_id` FROM `cache_logtype` WHERE `cache_type_id`='&1'", $cache->getType());
while ($r = sql_fetch_assoc($rs))
$nTypes[] = $r['log_type_id'];
sql_free_result($rs);
return $nTypes;
}
}
?>

View File

@ -1,49 +1,49 @@
<?php
/***************************************************************************
* For license information see doc/license.txt
*
* Unicode Reminder メモ
*
* Business layer constant definitions
***************************************************************************/
define('ID_NEW', -1);
define('RE_TYPE_INT', 1);
define('RE_TYPE_STRING', 2);
define('RE_TYPE_BOOLEAN', 3);
define('RE_TYPE_DATE', 4);
define('RE_TYPE_FLOAT', 5);
define('RE_TYPE_DOUBLE', 6);
define('RE_INSERT_NOTHING', 0); //
define('RE_INSERT_OVERWRITE', 1); // ignore given values and use function
define('RE_INSERT_IGNORE', 2); // dont use this column on insert
define('RE_INSERT_AUTOINCREMENT', 4); // column is an auto increment column
define('RE_INSERT_AUTOUUID', 8); // if empty, UUID is generated by before insert trigger (not supported for primary key fields)
define('RE_INSERT_NOW', 16); // NOW()
define('REGEX_USERNAME', '^[a-zA-Z0-9\.\-_@äüöÄÜÖ=)(\/\\\&*+~#][a-zA-Z0-9\.\-_ @äüöÄÜÖ=)(\/\\\&*+~#]{1,58}[a-zA-Z0-9\.\-_@äüöÄÜÖ=)(\/\\\&*+~#]$'); // min. 4 -> 3 chars -- following 2012-8-6
define('REGEX_PASSWORD', '^[a-zA-Z0-9\.\-_ @äüöÄÜÖ=)(\/\\\&*+~#]{3,60}$');
define('REGEX_LAST_NAME', '^[a-zA-Z][a-zA-Z0-9\.\- äüöÄÜÖ]{1,59}$');
define('REGEX_FIRST_NAME', '^[a-zA-Z][a-zA-Z0-9\.\- äüöÄÜÖ]{1,59}$');
define('REGEX_STATPIC_TEXT', '^[a-zA-Z0-9\.\-_ @äüöÄÜÖß=)(\/\\\&*\$+~#!§%;,-?:\[\]{}¹²³\'\"`\|µ°\%]{0,30}$');
define('ADMIN_TRANSLATE', 1); // edit translation
define('ADMIN_MAINTAINANCE', 2); // check table etc.
define('ADMIN_USER', 4); // drop users, caches etc.
define('ADMIN_NEWS', 8); // approve news entries
define('ADMIN_ROOT', 128 | 127); // root + all previous rights
define('ATTRIB_SELECTED', 1);
define('ATTRIB_UNSELECTED', 2);
define('ATTRIB_UNDEF', 3);
define('OBJECT_CACHELOG', 1);
define('OBJECT_CACHE', 2);
define('OBJECT_CACHEDESC', 3);
define('OBJECT_USER', 4);
define('OBJECT_TRAVELER', 5);
define('OBJECT_PICTURE', 6);
define('OBJECT_REMOVEDOBJECT', 7);
<?php
/***************************************************************************
* For license information see doc/license.txt
*
* Unicode Reminder メモ
*
* Business layer constant definitions
***************************************************************************/
define('ID_NEW', -1);
define('RE_TYPE_INT', 1);
define('RE_TYPE_STRING', 2);
define('RE_TYPE_BOOLEAN', 3);
define('RE_TYPE_DATE', 4);
define('RE_TYPE_FLOAT', 5);
define('RE_TYPE_DOUBLE', 6);
define('RE_INSERT_NOTHING', 0); //
define('RE_INSERT_OVERWRITE', 1); // ignore given values and use function
define('RE_INSERT_IGNORE', 2); // dont use this column on insert
define('RE_INSERT_AUTOINCREMENT', 4); // column is an auto increment column
define('RE_INSERT_AUTOUUID', 8); // if empty, UUID is generated by before insert trigger (not supported for primary key fields)
define('RE_INSERT_NOW', 16); // NOW()
define('REGEX_USERNAME', '^[a-zA-Z0-9\.\-_@äüöÄÜÖ=)(\/\\\&*+~#][a-zA-Z0-9\.\-_ @äüöÄÜÖ=)(\/\\\&*+~#]{1,58}[a-zA-Z0-9\.\-_@äüöÄÜÖ=)(\/\\\&*+~#]$'); // min. 4 -> 3 chars -- following 2012-8-6
define('REGEX_PASSWORD', '^[a-zA-Z0-9\.\-_ @äüöÄÜÖ=)(\/\\\&*+~#]{3,60}$');
define('REGEX_LAST_NAME', '^[a-zA-Z][a-zA-Z0-9\.\- äüöÄÜÖ]{1,59}$');
define('REGEX_FIRST_NAME', '^[a-zA-Z][a-zA-Z0-9\.\- äüöÄÜÖ]{1,59}$');
define('REGEX_STATPIC_TEXT', '^[a-zA-Z0-9\.\-_ @äüöÄÜÖß=)(\/\\\&*\$+~#!§%;,-?:\[\]{}¹²³\'\"`\|µ°\%]{0,30}$');
define('ADMIN_TRANSLATE', 1); // edit translation
define('ADMIN_MAINTAINANCE', 2); // check table etc.
define('ADMIN_USER', 4); // drop users, caches etc.
define('ADMIN_NEWS', 8); // approve news entries
define('ADMIN_ROOT', 128 | 127); // root + all previous rights
define('ATTRIB_SELECTED', 1);
define('ATTRIB_UNSELECTED', 2);
define('ATTRIB_UNDEF', 3);
define('OBJECT_CACHELOG', 1);
define('OBJECT_CACHE', 2);
define('OBJECT_CACHEDESC', 3);
define('OBJECT_USER', 4);
define('OBJECT_TRAVELER', 5);
define('OBJECT_PICTURE', 6);
define('OBJECT_REMOVEDOBJECT', 7);
?>

View File

@ -1,315 +1,315 @@
<?php
/***************************************************************************
* For license information see doc/license.txt
*
* Unicode Reminder メモ
*
* get/set has to be commited with save
* add/remove etc. is executed instantly
***************************************************************************/
require_once($opt['rootpath'] . 'lib2/logic/rowEditor.class.php');
require_once($opt['rootpath'] . 'lib2/logic/const.inc.php');
class picture
{
var $nPictureId = 0;
var $rePicture;
var $sFileExtension = '';
var $bFilenamesSet = false;
static function pictureIdFromUUID($uuid)
{
$pictureid = sql_value("SELECT `id` FROM `pictures` WHERE `uuid`='&1'", 0, $uuid);
return $pictureid;
}
static function fromUUID($uuid)
{
$pictureid = picture::pictureIdFromUUID($uuid);
if ($pictureid == 0)
return null;
return new picture($pictureid);
}
function __construct($nNewPictureId=ID_NEW)
{
global $opt;
$this->rePicture = new rowEditor('pictures');
$this->rePicture->addPKInt('id', null, false, RE_INSERT_AUTOINCREMENT);
$this->rePicture->addString('uuid', '', false, RE_INSERT_AUTOUUID);
$this->rePicture->addInt('node', 0, false);
$this->rePicture->addDate('date_created', time(), true, RE_INSERT_IGNORE);
$this->rePicture->addDate('last_modified', time(), true, RE_INSERT_IGNORE);
$this->rePicture->addString('url', '', false);
$this->rePicture->addString('title', '', false);
$this->rePicture->addDate('last_url_check', 0, true);
$this->rePicture->addInt('object_id', null, false);
$this->rePicture->addInt('object_type', null, false);
$this->rePicture->addString('thumb_url', '', false);
$this->rePicture->addDate('thumb_last_generated', 0, false);
$this->rePicture->addInt('spoiler', 0, false);
$this->rePicture->addInt('local', 0, false);
$this->rePicture->addInt('unknown_format', 0, false);
$this->rePicture->addInt('display', 1, false);
$this->nPictureId = $nNewPictureId+0;
if ($nNewPictureId == ID_NEW)
{
$this->rePicture->addNew(null);
$sUUID = mb_strtoupper(sql_value("SELECT UUID()", ''));
$this->rePicture->setValue('uuid', $sUUID);
$this->rePicture->setValue('node', $opt['logic']['node']['id']);
}
else
{
$this->rePicture->load($this->nPictureId);
$sFilename = $this->getFilename();
$fna = mb_split('\\.', $sFilename);
$this->sFileExtension = mb_strtolower($fna[count($fna) - 1]);
$this->bFilenamesSet = true;
}
}
function exist()
{
return $this->rePicture->exist();
}
static function allowedExtension($sFilename)
{
global $opt;
if (strpos($sFilename, ';') !== false)
return false;
if (strpos($sFilename, '.') === false)
return false;
$sExtension = mb_strtolower(substr($sFilename, strrpos($sFilename, '.') + 1));
if (strpos(';' . $opt['logic']['pictures']['extensions'] . ';', ';' . $sExtension . ';') !== false)
return true;
else
return false;
}
function setFilenames($sFilename)
{
global $opt;
if ($this->bFilenamesSet == true)
return;
if (strpos($sFilename, '.') === false)
return;
$sExtension = mb_strtolower(substr($sFilename, strrpos($sFilename, '.') + 1));
$sUUID = $this->getUUID();
$this->sFileExtension = $sExtension;
$this->setUrl($opt['logic']['pictures']['url'] . $sUUID . '.' . $sExtension);
//$this->setThumbUrl($opt['logic']['pictures']['thumb_url'] . substr($sUUID, 0, 1) . '/' . substr($sUUID, 1, 1) . '/' . $sUUID . '.' . $sExtension);
$this->bFilenamesSet = true;
}
function getPictureId()
{
return $this->nPictureId;
}
function delete()
{
global $opt;
// delete record, image and thumb
@unlink($this->getFilename());
@unlink($this->getThumbFilename());
sql("DELETE FROM `pictures` WHERE `id`='&1'", $this->nPictureId);
return true;
}
function getUrl()
{
return $this->rePicture->getValue('url');
}
function setUrl($value)
{
return $this->rePicture->setValue('url', $value);
}
function getThumbUrl()
{
return $this->rePicture->getValue('thumb_url');
}
function setThumbUrl($value)
{
return $this->rePicture->setValue('thumb_url', $value);
}
function getTitle()
{
return $this->rePicture->getValue('title');
}
function setTitle($value)
{
if ($value != '')
return $this->rePicture->setValue('title', $value);
else
return false;
}
function getSpoiler()
{
return $this->rePicture->getValue('spoiler')!=0;
}
function setSpoiler($value)
{
return $this->rePicture->setValue('spoiler', $value ? 1 : 0);
}
function getLocal()
{
return $this->rePicture->getValue('local')!=0;
}
function setLocal($value)
{
return $this->rePicture->setValue('local', $value ? 1 : 0);
}
function getDisplay()
{
return $this->rePicture->getValue('display')!=0;
}
function setDisplay($value)
{
return $this->rePicture->setValue('display', $value ? 1 : 0);
}
function getFilename()
{
global $opt;
if (mb_substr($opt['logic']['pictures']['dir'], -1, 1) != '/')
$opt['logic']['pictures']['dir'] .= '/';
$uuid = $this->getUUID();
$url = $this->getUrl();
$fna = mb_split('\\.', $url);
$extension = mb_strtolower($fna[count($fna) - 1]);
return $opt['logic']['pictures']['dir'] . $uuid . '.' . $extension;
}
function getThumbFilename()
{
global $opt;
if (mb_substr($opt['logic']['pictures']['thumb_dir'], -1, 1) != '/')
$opt['logic']['pictures']['thumb_dir'] .= '/';
$uuid = $this->getUUID();
$url = $this->getUrl();
$fna = mb_split('\\.', $url);
$extension = mb_strtolower($fna[count($fna) - 1]);
$dir1 = mb_strtoupper(mb_substr($uuid, 0, 1));
$dir2 = mb_strtoupper(mb_substr($uuid, 1, 1));
return $opt['logic']['pictures']['thumb_dir'] . $dir1 . '/' . $dir2 . '/' . $uuid . '.' . $extension;
}
function getLogId()
{
if ($this->getObjectType() == OBJECT_CACHELOG)
return $this->getObjectId();
else
return false;
}
function getCacheId()
{
if ($this->getObjectType() == OBJECT_CACHELOG)
return sql_value("SELECT `cache_id` FROM `cache_logs` WHERE `id`='&1'", false, $this->getObjectId());
else if ($this->getObjectType() == OBJECT_CACHE)
return $this->getObjectId();
else
return false;
}
function getObjectId()
{
return $this->rePicture->getValue('object_id');
}
function setObjectId($value)
{
return $this->rePicture->setValue('object_id', $value+0);
}
function getObjectType()
{
return $this->rePicture->getValue('object_type');
}
function setObjectType($value)
{
return $this->rePicture->setValue('object_type', $value+0);
}
function getUserId()
{
if ($this->getObjectType() == OBJECT_CACHE)
return sql_value("SELECT `caches`.`user_id` FROM `caches` WHERE `caches`.`cache_id`='&1'", false, $this->getObjectId());
else if ($this->getObjectType() == OBJECT_CACHELOG)
return sql_value("SELECT `cache_logs`.`user_id` FROM `cache_logs` WHERE `cache_logs`.`id`='&1'", false, $this->getObjectId());
else
return false;
}
function getNode()
{
return $this->rePicture->getValue('node');
}
function setNode($value)
{
return $this->rePicture->setValue('node', $value);
}
function getUUID()
{
return $this->rePicture->getValue('uuid');
}
function getLastModified()
{
return $this->rePicture->getValue('last_modified');
}
function getDateCreated()
{
return $this->rePicture->getValue('date_created');
}
function getAnyChanged()
{
return $this->rePicture->getAnyChanged();
}
// return if successfull (with insert)
function save()
{
if ($this->bFilenamesSet == false)
return false;
$bRetVal = $this->rePicture->save();
if ($bRetVal)
sql_slave_exclude();
return $bRetVal;
}
function allowEdit()
{
global $login;
$login->verify();
if (sql_value("SELECT COUNT(*) FROM `caches` INNER JOIN `cache_status` ON `caches`.`status`=`cache_status`.`id` WHERE (`cache_status`.`allow_user_view`=1 OR `caches`.`user_id`='&1') AND `caches`.`cache_id`='&2'", 0, $login->userid, $this->getCacheId()) == 0)
return false;
else if ($this->getUserId() == $login->userid)
return true;
return false;
}
}
<?php
/***************************************************************************
* For license information see doc/license.txt
*
* Unicode Reminder メモ
*
* get/set has to be commited with save
* add/remove etc. is executed instantly
***************************************************************************/
require_once($opt['rootpath'] . 'lib2/logic/rowEditor.class.php');
require_once($opt['rootpath'] . 'lib2/logic/const.inc.php');
class picture
{
var $nPictureId = 0;
var $rePicture;
var $sFileExtension = '';
var $bFilenamesSet = false;
static function pictureIdFromUUID($uuid)
{
$pictureid = sql_value("SELECT `id` FROM `pictures` WHERE `uuid`='&1'", 0, $uuid);
return $pictureid;
}
static function fromUUID($uuid)
{
$pictureid = picture::pictureIdFromUUID($uuid);
if ($pictureid == 0)
return null;
return new picture($pictureid);
}
function __construct($nNewPictureId=ID_NEW)
{
global $opt;
$this->rePicture = new rowEditor('pictures');
$this->rePicture->addPKInt('id', null, false, RE_INSERT_AUTOINCREMENT);
$this->rePicture->addString('uuid', '', false, RE_INSERT_AUTOUUID);
$this->rePicture->addInt('node', 0, false);
$this->rePicture->addDate('date_created', time(), true, RE_INSERT_IGNORE);
$this->rePicture->addDate('last_modified', time(), true, RE_INSERT_IGNORE);
$this->rePicture->addString('url', '', false);
$this->rePicture->addString('title', '', false);
$this->rePicture->addDate('last_url_check', 0, true);
$this->rePicture->addInt('object_id', null, false);
$this->rePicture->addInt('object_type', null, false);
$this->rePicture->addString('thumb_url', '', false);
$this->rePicture->addDate('thumb_last_generated', 0, false);
$this->rePicture->addInt('spoiler', 0, false);
$this->rePicture->addInt('local', 0, false);
$this->rePicture->addInt('unknown_format', 0, false);
$this->rePicture->addInt('display', 1, false);
$this->nPictureId = $nNewPictureId+0;
if ($nNewPictureId == ID_NEW)
{
$this->rePicture->addNew(null);
$sUUID = mb_strtoupper(sql_value("SELECT UUID()", ''));
$this->rePicture->setValue('uuid', $sUUID);
$this->rePicture->setValue('node', $opt['logic']['node']['id']);
}
else
{
$this->rePicture->load($this->nPictureId);
$sFilename = $this->getFilename();
$fna = mb_split('\\.', $sFilename);
$this->sFileExtension = mb_strtolower($fna[count($fna) - 1]);
$this->bFilenamesSet = true;
}
}
function exist()
{
return $this->rePicture->exist();
}
static function allowedExtension($sFilename)
{
global $opt;
if (strpos($sFilename, ';') !== false)
return false;
if (strpos($sFilename, '.') === false)
return false;
$sExtension = mb_strtolower(substr($sFilename, strrpos($sFilename, '.') + 1));
if (strpos(';' . $opt['logic']['pictures']['extensions'] . ';', ';' . $sExtension . ';') !== false)
return true;
else
return false;
}
function setFilenames($sFilename)
{
global $opt;
if ($this->bFilenamesSet == true)
return;
if (strpos($sFilename, '.') === false)
return;
$sExtension = mb_strtolower(substr($sFilename, strrpos($sFilename, '.') + 1));
$sUUID = $this->getUUID();
$this->sFileExtension = $sExtension;
$this->setUrl($opt['logic']['pictures']['url'] . $sUUID . '.' . $sExtension);
//$this->setThumbUrl($opt['logic']['pictures']['thumb_url'] . substr($sUUID, 0, 1) . '/' . substr($sUUID, 1, 1) . '/' . $sUUID . '.' . $sExtension);
$this->bFilenamesSet = true;
}
function getPictureId()
{
return $this->nPictureId;
}
function delete()
{
global $opt;
// delete record, image and thumb
@unlink($this->getFilename());
@unlink($this->getThumbFilename());
sql("DELETE FROM `pictures` WHERE `id`='&1'", $this->nPictureId);
return true;
}
function getUrl()
{
return $this->rePicture->getValue('url');
}
function setUrl($value)
{
return $this->rePicture->setValue('url', $value);
}
function getThumbUrl()
{
return $this->rePicture->getValue('thumb_url');
}
function setThumbUrl($value)
{
return $this->rePicture->setValue('thumb_url', $value);
}
function getTitle()
{
return $this->rePicture->getValue('title');
}
function setTitle($value)
{
if ($value != '')
return $this->rePicture->setValue('title', $value);
else
return false;
}
function getSpoiler()
{
return $this->rePicture->getValue('spoiler')!=0;
}
function setSpoiler($value)
{
return $this->rePicture->setValue('spoiler', $value ? 1 : 0);
}
function getLocal()
{
return $this->rePicture->getValue('local')!=0;
}
function setLocal($value)
{
return $this->rePicture->setValue('local', $value ? 1 : 0);
}
function getDisplay()
{
return $this->rePicture->getValue('display')!=0;
}
function setDisplay($value)
{
return $this->rePicture->setValue('display', $value ? 1 : 0);
}
function getFilename()
{
global $opt;
if (mb_substr($opt['logic']['pictures']['dir'], -1, 1) != '/')
$opt['logic']['pictures']['dir'] .= '/';
$uuid = $this->getUUID();
$url = $this->getUrl();
$fna = mb_split('\\.', $url);
$extension = mb_strtolower($fna[count($fna) - 1]);
return $opt['logic']['pictures']['dir'] . $uuid . '.' . $extension;
}
function getThumbFilename()
{
global $opt;
if (mb_substr($opt['logic']['pictures']['thumb_dir'], -1, 1) != '/')
$opt['logic']['pictures']['thumb_dir'] .= '/';
$uuid = $this->getUUID();
$url = $this->getUrl();
$fna = mb_split('\\.', $url);
$extension = mb_strtolower($fna[count($fna) - 1]);
$dir1 = mb_strtoupper(mb_substr($uuid, 0, 1));
$dir2 = mb_strtoupper(mb_substr($uuid, 1, 1));
return $opt['logic']['pictures']['thumb_dir'] . $dir1 . '/' . $dir2 . '/' . $uuid . '.' . $extension;
}
function getLogId()
{
if ($this->getObjectType() == OBJECT_CACHELOG)
return $this->getObjectId();
else
return false;
}
function getCacheId()
{
if ($this->getObjectType() == OBJECT_CACHELOG)
return sql_value("SELECT `cache_id` FROM `cache_logs` WHERE `id`='&1'", false, $this->getObjectId());
else if ($this->getObjectType() == OBJECT_CACHE)
return $this->getObjectId();
else
return false;
}
function getObjectId()
{
return $this->rePicture->getValue('object_id');
}
function setObjectId($value)
{
return $this->rePicture->setValue('object_id', $value+0);
}
function getObjectType()
{
return $this->rePicture->getValue('object_type');
}
function setObjectType($value)
{
return $this->rePicture->setValue('object_type', $value+0);
}
function getUserId()
{
if ($this->getObjectType() == OBJECT_CACHE)
return sql_value("SELECT `caches`.`user_id` FROM `caches` WHERE `caches`.`cache_id`='&1'", false, $this->getObjectId());
else if ($this->getObjectType() == OBJECT_CACHELOG)
return sql_value("SELECT `cache_logs`.`user_id` FROM `cache_logs` WHERE `cache_logs`.`id`='&1'", false, $this->getObjectId());
else
return false;
}
function getNode()
{
return $this->rePicture->getValue('node');
}
function setNode($value)
{
return $this->rePicture->setValue('node', $value);
}
function getUUID()
{
return $this->rePicture->getValue('uuid');
}
function getLastModified()
{
return $this->rePicture->getValue('last_modified');
}
function getDateCreated()
{
return $this->rePicture->getValue('date_created');
}
function getAnyChanged()
{
return $this->rePicture->getAnyChanged();
}
// return if successfull (with insert)
function save()
{
if ($this->bFilenamesSet == false)
return false;
$bRetVal = $this->rePicture->save();
if ($bRetVal)
sql_slave_exclude();
return $bRetVal;
}
function allowEdit()
{
global $login;
$login->verify();
if (sql_value("SELECT COUNT(*) FROM `caches` INNER JOIN `cache_status` ON `caches`.`status`=`cache_status`.`id` WHERE (`cache_status`.`allow_user_view`=1 OR `caches`.`user_id`='&1') AND `caches`.`cache_id`='&2'", 0, $login->userid, $this->getCacheId()) == 0)
return false;
else if ($this->getUserId() == $login->userid)
return true;
return false;
}
}
?>

File diff suppressed because it is too large Load Diff

View File

@ -1,324 +1,324 @@
<?php
/***************************************************************************
* For license information see doc/license.txt
*
* Unicode Reminder メモ
*
* This class provides access to the login user data. Informations are
* stored in a cookie.
*
* Methods:
* verify() validate the login-session (automatically invoked)
* try_login() try to login with the given user/password
* logout() logout the user
*
* Properties:
* userid Integer 0 if no login, userid otherwise
* username String username or ''
*
***************************************************************************/
define('LOGIN_UNKNOWN_ERROR', -1); // unkown error occured
define('LOGIN_OK', 0); // login succeeded
define('LOGIN_BADUSERPW', 1); // bad username or password
define('LOGIN_TOOMUCHLOGINS', 2); // too many logins in short time
define('LOGIN_USERNOTACTIVE', 3); // the useraccount locked
define('LOGIN_EMPTY_USERPASSWORD', 4); // given username/password was empty
define('LOGIN_LOGOUT_OK', 5); // logout was successfull
// login times in seconds
define('LOGIN_TIME', 60*60);
define('LOGIN_TIME_PERMANENT', 90*24*60*60);
$login = new login();
class login
{
var $userid = 0;
var $username = '';
var $lastlogin = 0;
var $permanent = false;
var $sessionid = '';
var $verified = false;
var $admin = 0;
function login()
{
global $cookie;
if ($cookie->is_set('userid') && $cookie->is_set('username'))
{
$this->userid = $cookie->get('userid')+0;
$this->username = $cookie->get('username');
$this->permanent = (($cookie->get('permanent')+0) == 1);
$this->lastlogin = $cookie->get('lastlogin');
$this->sessionid = $cookie->get('sessionid');
$this->admin = $cookie->get('admin')+0;
$this->verified = false;
$this->verify();
}
else
$this->pClear();
}
// return true on success
function restoreSession($sid)
{
$min_lastlogin = date('Y-m-d H:i:s', time() - LOGIN_TIME);
if ($this->checkLoginsCount() == false)
{
$this->pClear();
return false;
}
$rs = sqlf("SELECT `sys_sessions`.`uuid` `sid`, `user`.`user_id`, `sys_sessions`.`last_login`, `user`.`admin`, `user`.`username` FROM &db.`sys_sessions`, &db.`user` WHERE `sys_sessions`.`user_id`=`user`.`user_id` AND `user`.`is_active_flag`=1 AND `sys_sessions`.`uuid`='&1' AND `sys_sessions`.`permanent`=0 AND `sys_sessions`.`last_login`>'&2'", $sid, $min_lastlogin);
$r = sql_fetch_assoc($rs);
sql_free_result($rs);
if ($r)
{
sqlf("UPDATE `sys_sessions` SET `sys_sessions`.`last_login`=NOW() WHERE `sys_sessions`.`uuid`='&1' AND `sys_sessions`.`user_id`='&2'", $r['sid'], $r['user_id']);
sqlf("UPDATE `user` SET `user`.`last_login`=NOW() WHERE `user`.`user_id`='&1'", $r['user_id']);
$this->userid = $r['user_id'];
$this->username = $r['username'];
$this->permanent = false;
$this->lastlogin = $r['last_login'];
$this->sessionid = $r['sid'];
$this->admin = $r['admin'];
$this->verified = true;
return true;
}
else
{
// prevent bruteforce
sql("INSERT INTO `sys_logins` (`remote_addr`, `success`) VALUES ('&1', 0)", $_SERVER['REMOTE_ADDR']);
return false;
}
}
function pClear()
{
// set to no valid login
$this->userid = 0;
$this->username = '';
$this->permanent = false;
$this->lastlogin = '';
$this->sessionid = '';
$this->admin = 0;
$this->verified = true;
$this->pStoreCookie();
}
function pStoreCookie()
{
global $cookie;
$cookie->set('userid', $this->userid);
$cookie->set('username', $this->username);
$cookie->set('permanent', ($this->permanent==true ? 1 : 0));
$cookie->set('lastlogin', $this->lastlogin);
$cookie->set('sessionid', $this->sessionid);
$cookie->set('admin', $this->admin);
}
function verify()
{
if ($this->verified == true)
return;
if ($this->userid == 0)
{
$this->pClear();
return;
}
if ($this->checkLoginsCount() == false)
{
$this->pClear();
return;
}
$min_lastlogin = date('Y-m-d H:i:s', time() - LOGIN_TIME);
$min_lastlogin_permanent = date('Y-m-d H:i:s', time() - LOGIN_TIME_PERMANENT);
$rs = sqlf("SELECT `sys_sessions`.`last_login`, `user`.`admin`, `user`.`username` FROM &db.`sys_sessions`, &db.`user` WHERE `sys_sessions`.`user_id`=`user`.`user_id` AND `user`.`is_active_flag`=1 AND `sys_sessions`.`uuid`='&1' AND `sys_sessions`.`user_id`='&2' AND ((`sys_sessions`.`permanent`=1 AND `sys_sessions`.`last_login`>'&3') OR (`sys_sessions`.`permanent`=0 AND `sys_sessions`.`last_login`>'&4'))", $this->sessionid, $this->userid, $min_lastlogin_permanent, $min_lastlogin);
if ($rUser = sql_fetch_assoc($rs))
{
if ((($this->permanent == true) && (strtotime($rUser['last_login']) + LOGIN_TIME/2 < time())) ||
(($this->permanent == false) && (strtotime($rUser['last_login']) + LOGIN_TIME_PERMANENT/2 < time())))
{
sqlf("UPDATE `sys_sessions` SET `sys_sessions`.`last_login`=NOW() WHERE `sys_sessions`.`uuid`='&1' AND `sys_sessions`.`user_id`='&2'", $this->sessionid, $this->userid);
$rUser['last_login'] = date('Y-m-d H:i:s');
}
// user.last_login is used for statics, so we keep it up2date
sqlf("UPDATE `user` SET `user`.`last_login`=NOW() WHERE `user`.`user_id`='&1'", $this->userid);
$this->lastlogin = $rUser['last_login'];
$this->username = $rUser['username'];
$this->admin = $rUser['admin'];
$this->verified = true;
}
else
{
// prevent bruteforce
sql("INSERT INTO `sys_logins` (`remote_addr`, `success`) VALUES ('&1', 0)", $_SERVER['REMOTE_ADDR']);
$this->pClear();
}
sql_free_result($rs);
$this->pStoreCookie();
return;
}
function try_login($user, $password, $permanent)
{
global $opt;
if ($password == '')
return LOGIN_EMPTY_USERPASSWORD;
$pwmd5 = md5($password);
if ($opt['logic']['password_hash'])
$pwmd5 = hash('sha512', $pwmd5);
return $this->try_login_md5($user, $pwmd5, $permanent);
}
function checkLoginsCount()
{
global $opt;
// cleanup old entries
// (execute only every 50 search calls)
if (rand(1, 50) == 1)
sqlf("DELETE FROM `sys_logins` WHERE `date_created`<'&1'", date('Y-m-d H:i:s', time() - 3600));
// check the number of logins in the last hour ...
$logins_count = sqlf_value("SELECT COUNT(*) `count` FROM `sys_logins` WHERE `remote_addr`='&1' AND `date_created`>'&2'", 0, $_SERVER['REMOTE_ADDR'], date('Y-m-d H:i:s', time() - 3600));
if ($logins_count > $opt['page']['max_logins_per_hour'])
return false;
else
return true;
}
function try_login_md5($user, $pwmd5, $permanent)
{
global $opt;
$this->pClear();
if ($user == '' || $pwmd5 == '')
return LOGIN_EMPTY_USERPASSWORD;
if ($this->checkLoginsCount() == false)
return LOGIN_TOOMUCHLOGINS;
// delete old sessions
$min_lastlogin_permanent = date('Y-m-d H:i:s', time() - LOGIN_TIME_PERMANENT);
sqlf("DELETE FROM `sys_sessions` WHERE `last_login`<'&1'", $min_lastlogin_permanent);
// compare $user with email and username, if both matches use email
$rsUser = sqlf("SELECT `user_id`, `username`, 2 AS `prio`, `is_active_flag`, `permanent_login_flag`, `admin` FROM `user` WHERE `username`='&1' AND `password`='&2' UNION
SELECT `user_id`, `username`, 1 AS `prio`, `is_active_flag`, `permanent_login_flag`, `admin` FROM `user` WHERE `email`='&1' AND `password`='&2' ORDER BY `prio` ASC LIMIT 1", $user, $pwmd5);
$rUser = sql_fetch_assoc($rsUser);
sql_free_result($rsUser);
if ($permanent == null)
$permanent = ($rUser['permanent_login_flag'] == 1);
if ($rUser)
{
// ok, there is a valid login
if ($rUser['is_active_flag'] != 0)
{
// begin session
$uuid = self::create_sessionid();
sqlf("INSERT INTO `sys_sessions` (`uuid`, `user_id`, `permanent`) VALUES ('&1', '&2', '&3')", $uuid, $rUser['user_id'], ($permanent!=false ? 1 : 0));
$this->userid = $rUser['user_id'];
$this->username = $rUser['username'];
$this->permanent = $permanent;
$this->lastlogin = date('Y-m-d H:i:s');
$this->sessionid = $uuid;
$this->admin = $rUser['admin'];
$this->verified = true;
$retval = LOGIN_OK;
}
else
$retval = LOGIN_USERNOTACTIVE;
}
else
{
// sorry, bad login
$retval = LOGIN_BADUSERPW;
}
sqlf("INSERT INTO `sys_logins` (`remote_addr`, `success`) VALUES ('&1', '&2')", $_SERVER['REMOTE_ADDR'], ($rUser===false ? 0 : 1));
// store to cookie
$this->pStoreCookie();
return $retval;
}
private static function create_sessionid()
{
return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
mt_rand(0, 0xffff), mt_rand(0, 0xffff),
mt_rand(0, 0xffff),
mt_rand(0, 0xffff),
mt_rand(0, 0xffff),
mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff)
);
}
function getUserCountry()
{
global $opt, $cookie;
// language specified in cookie?
if ($cookie->is_set('usercountry'))
{
$sCountry = $cookie->get('usercountry', null);
if ($sCountry != null)
return $sCountry;
}
// user specified a language?
if ($this->userid != 0)
{
$sCountry = sql_value("SELECT `country` FROM `user` WHERE `user_id`='&1'", null, $this->userid);
if ($sCountry != null)
return $sCountry;
}
// default country of this language
if (isset($opt['locale'][$opt['template']['locale']]['country']))
return $opt['locale'][$opt['template']['locale']]['country'];
// default country of installation (or domain)
return $opt['template']['default']['country'];
}
function logout()
{
if ($this->userid != 0)
sqlf("DELETE FROM `sys_sessions` WHERE `uuid`='&1' AND `user_id`='&2'", $this->sessionid, $this->userid);
$this->pClear();
}
public function hasAdminPriv($privilege = false)
{
if ($privilege === false)
return $this->admin != 0;
return ($this->admin & $privilege) == $privilege;
}
}
?>
<?php
/***************************************************************************
* For license information see doc/license.txt
*
* Unicode Reminder メモ
*
* This class provides access to the login user data. Informations are
* stored in a cookie.
*
* Methods:
* verify() validate the login-session (automatically invoked)
* try_login() try to login with the given user/password
* logout() logout the user
*
* Properties:
* userid Integer 0 if no login, userid otherwise
* username String username or ''
*
***************************************************************************/
define('LOGIN_UNKNOWN_ERROR', -1); // unkown error occured
define('LOGIN_OK', 0); // login succeeded
define('LOGIN_BADUSERPW', 1); // bad username or password
define('LOGIN_TOOMUCHLOGINS', 2); // too many logins in short time
define('LOGIN_USERNOTACTIVE', 3); // the useraccount locked
define('LOGIN_EMPTY_USERPASSWORD', 4); // given username/password was empty
define('LOGIN_LOGOUT_OK', 5); // logout was successfull
// login times in seconds
define('LOGIN_TIME', 60*60);
define('LOGIN_TIME_PERMANENT', 90*24*60*60);
$login = new login();
class login
{
var $userid = 0;
var $username = '';
var $lastlogin = 0;
var $permanent = false;
var $sessionid = '';
var $verified = false;
var $admin = 0;
function login()
{
global $cookie;
if ($cookie->is_set('userid') && $cookie->is_set('username'))
{
$this->userid = $cookie->get('userid')+0;
$this->username = $cookie->get('username');
$this->permanent = (($cookie->get('permanent')+0) == 1);
$this->lastlogin = $cookie->get('lastlogin');
$this->sessionid = $cookie->get('sessionid');
$this->admin = $cookie->get('admin')+0;
$this->verified = false;
$this->verify();
}
else
$this->pClear();
}
// return true on success
function restoreSession($sid)
{
$min_lastlogin = date('Y-m-d H:i:s', time() - LOGIN_TIME);
if ($this->checkLoginsCount() == false)
{
$this->pClear();
return false;
}
$rs = sqlf("SELECT `sys_sessions`.`uuid` `sid`, `user`.`user_id`, `sys_sessions`.`last_login`, `user`.`admin`, `user`.`username` FROM &db.`sys_sessions`, &db.`user` WHERE `sys_sessions`.`user_id`=`user`.`user_id` AND `user`.`is_active_flag`=1 AND `sys_sessions`.`uuid`='&1' AND `sys_sessions`.`permanent`=0 AND `sys_sessions`.`last_login`>'&2'", $sid, $min_lastlogin);
$r = sql_fetch_assoc($rs);
sql_free_result($rs);
if ($r)
{
sqlf("UPDATE `sys_sessions` SET `sys_sessions`.`last_login`=NOW() WHERE `sys_sessions`.`uuid`='&1' AND `sys_sessions`.`user_id`='&2'", $r['sid'], $r['user_id']);
sqlf("UPDATE `user` SET `user`.`last_login`=NOW() WHERE `user`.`user_id`='&1'", $r['user_id']);
$this->userid = $r['user_id'];
$this->username = $r['username'];
$this->permanent = false;
$this->lastlogin = $r['last_login'];
$this->sessionid = $r['sid'];
$this->admin = $r['admin'];
$this->verified = true;
return true;
}
else
{
// prevent bruteforce
sql("INSERT INTO `sys_logins` (`remote_addr`, `success`) VALUES ('&1', 0)", $_SERVER['REMOTE_ADDR']);
return false;
}
}
function pClear()
{
// set to no valid login
$this->userid = 0;
$this->username = '';
$this->permanent = false;
$this->lastlogin = '';
$this->sessionid = '';
$this->admin = 0;
$this->verified = true;
$this->pStoreCookie();
}
function pStoreCookie()
{
global $cookie;
$cookie->set('userid', $this->userid);
$cookie->set('username', $this->username);
$cookie->set('permanent', ($this->permanent==true ? 1 : 0));
$cookie->set('lastlogin', $this->lastlogin);
$cookie->set('sessionid', $this->sessionid);
$cookie->set('admin', $this->admin);
}
function verify()
{
if ($this->verified == true)
return;
if ($this->userid == 0)
{
$this->pClear();
return;
}
if ($this->checkLoginsCount() == false)
{
$this->pClear();
return;
}
$min_lastlogin = date('Y-m-d H:i:s', time() - LOGIN_TIME);
$min_lastlogin_permanent = date('Y-m-d H:i:s', time() - LOGIN_TIME_PERMANENT);
$rs = sqlf("SELECT `sys_sessions`.`last_login`, `user`.`admin`, `user`.`username` FROM &db.`sys_sessions`, &db.`user` WHERE `sys_sessions`.`user_id`=`user`.`user_id` AND `user`.`is_active_flag`=1 AND `sys_sessions`.`uuid`='&1' AND `sys_sessions`.`user_id`='&2' AND ((`sys_sessions`.`permanent`=1 AND `sys_sessions`.`last_login`>'&3') OR (`sys_sessions`.`permanent`=0 AND `sys_sessions`.`last_login`>'&4'))", $this->sessionid, $this->userid, $min_lastlogin_permanent, $min_lastlogin);
if ($rUser = sql_fetch_assoc($rs))
{
if ((($this->permanent == true) && (strtotime($rUser['last_login']) + LOGIN_TIME/2 < time())) ||
(($this->permanent == false) && (strtotime($rUser['last_login']) + LOGIN_TIME_PERMANENT/2 < time())))
{
sqlf("UPDATE `sys_sessions` SET `sys_sessions`.`last_login`=NOW() WHERE `sys_sessions`.`uuid`='&1' AND `sys_sessions`.`user_id`='&2'", $this->sessionid, $this->userid);
$rUser['last_login'] = date('Y-m-d H:i:s');
}
// user.last_login is used for statics, so we keep it up2date
sqlf("UPDATE `user` SET `user`.`last_login`=NOW() WHERE `user`.`user_id`='&1'", $this->userid);
$this->lastlogin = $rUser['last_login'];
$this->username = $rUser['username'];
$this->admin = $rUser['admin'];
$this->verified = true;
}
else
{
// prevent bruteforce
sql("INSERT INTO `sys_logins` (`remote_addr`, `success`) VALUES ('&1', 0)", $_SERVER['REMOTE_ADDR']);
$this->pClear();
}
sql_free_result($rs);
$this->pStoreCookie();
return;
}
function try_login($user, $password, $permanent)
{
global $opt;
if ($password == '')
return LOGIN_EMPTY_USERPASSWORD;
$pwmd5 = md5($password);
if ($opt['logic']['password_hash'])
$pwmd5 = hash('sha512', $pwmd5);
return $this->try_login_md5($user, $pwmd5, $permanent);
}
function checkLoginsCount()
{
global $opt;
// cleanup old entries
// (execute only every 50 search calls)
if (rand(1, 50) == 1)
sqlf("DELETE FROM `sys_logins` WHERE `date_created`<'&1'", date('Y-m-d H:i:s', time() - 3600));
// check the number of logins in the last hour ...
$logins_count = sqlf_value("SELECT COUNT(*) `count` FROM `sys_logins` WHERE `remote_addr`='&1' AND `date_created`>'&2'", 0, $_SERVER['REMOTE_ADDR'], date('Y-m-d H:i:s', time() - 3600));
if ($logins_count > $opt['page']['max_logins_per_hour'])
return false;
else
return true;
}
function try_login_md5($user, $pwmd5, $permanent)
{
global $opt;
$this->pClear();
if ($user == '' || $pwmd5 == '')
return LOGIN_EMPTY_USERPASSWORD;
if ($this->checkLoginsCount() == false)
return LOGIN_TOOMUCHLOGINS;
// delete old sessions
$min_lastlogin_permanent = date('Y-m-d H:i:s', time() - LOGIN_TIME_PERMANENT);
sqlf("DELETE FROM `sys_sessions` WHERE `last_login`<'&1'", $min_lastlogin_permanent);
// compare $user with email and username, if both matches use email
$rsUser = sqlf("SELECT `user_id`, `username`, 2 AS `prio`, `is_active_flag`, `permanent_login_flag`, `admin` FROM `user` WHERE `username`='&1' AND `password`='&2' UNION
SELECT `user_id`, `username`, 1 AS `prio`, `is_active_flag`, `permanent_login_flag`, `admin` FROM `user` WHERE `email`='&1' AND `password`='&2' ORDER BY `prio` ASC LIMIT 1", $user, $pwmd5);
$rUser = sql_fetch_assoc($rsUser);
sql_free_result($rsUser);
if ($permanent == null)
$permanent = ($rUser['permanent_login_flag'] == 1);
if ($rUser)
{
// ok, there is a valid login
if ($rUser['is_active_flag'] != 0)
{
// begin session
$uuid = self::create_sessionid();
sqlf("INSERT INTO `sys_sessions` (`uuid`, `user_id`, `permanent`) VALUES ('&1', '&2', '&3')", $uuid, $rUser['user_id'], ($permanent!=false ? 1 : 0));
$this->userid = $rUser['user_id'];
$this->username = $rUser['username'];
$this->permanent = $permanent;
$this->lastlogin = date('Y-m-d H:i:s');
$this->sessionid = $uuid;
$this->admin = $rUser['admin'];
$this->verified = true;
$retval = LOGIN_OK;
}
else
$retval = LOGIN_USERNOTACTIVE;
}
else
{
// sorry, bad login
$retval = LOGIN_BADUSERPW;
}
sqlf("INSERT INTO `sys_logins` (`remote_addr`, `success`) VALUES ('&1', '&2')", $_SERVER['REMOTE_ADDR'], ($rUser===false ? 0 : 1));
// store to cookie
$this->pStoreCookie();
return $retval;
}
private static function create_sessionid()
{
return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
mt_rand(0, 0xffff), mt_rand(0, 0xffff),
mt_rand(0, 0xffff),
mt_rand(0, 0xffff),
mt_rand(0, 0xffff),
mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff)
);
}
function getUserCountry()
{
global $opt, $cookie;
// language specified in cookie?
if ($cookie->is_set('usercountry'))
{
$sCountry = $cookie->get('usercountry', null);
if ($sCountry != null)
return $sCountry;
}
// user specified a language?
if ($this->userid != 0)
{
$sCountry = sql_value("SELECT `country` FROM `user` WHERE `user_id`='&1'", null, $this->userid);
if ($sCountry != null)
return $sCountry;
}
// default country of this language
if (isset($opt['locale'][$opt['template']['locale']]['country']))
return $opt['locale'][$opt['template']['locale']]['country'];
// default country of installation (or domain)
return $opt['template']['default']['country'];
}
function logout()
{
if ($this->userid != 0)
sqlf("DELETE FROM `sys_sessions` WHERE `uuid`='&1' AND `user_id`='&2'", $this->sessionid, $this->userid);
$this->pClear();
}
public function hasAdminPriv($privilege = false)
{
if ($privilege === false)
return $this->admin != 0;
return ($this->admin & $privilege) == $privilege;
}
}
?>

View File

@ -1,352 +1,352 @@
<?php
/***************************************************************************
./log.php
-------------------
begin : July 4 2004
For license information see doc/license.txt
*****************************************************************************/
/****************************************************************************
Unicode Reminder メモ
log a cache visit
used template(s): log
GET Parameter: cacheid
****************************************************************************/
//prepare the templates and include all neccessary
require_once('./lib/common.inc.php');
require($stylepath.'/smilies.inc.php');
require_once($opt['rootpath'] . '../lib/htmlpurifier-4.2.0/library/HTMLPurifier.auto.php');
$no_tpl_build = false;
//Preprocessing
if ($error == false)
{
//cacheid
$cache_id = 0;
if (isset($_REQUEST['wp']))
{
$cache_id = sqlValue("SELECT `cache_id` FROM `caches` WHERE `wp_oc`='" . sql_escape($_REQUEST['wp']) . "'", 0);
}
else if (isset($_REQUEST['cacheid']))
{
$cache_id = $_REQUEST['cacheid'];
}
if ($usr === false)
{
$tplname = 'login';
tpl_set_var('username', '');
tpl_set_var('target', 'log.php?cacheid=' . urlencode($cache_id));
tpl_set_var('message', $login_required);
tpl_set_var('message_start', '');
tpl_set_var('message_end', '');
}
else
{
//set here the template to process
$tplname = 'log_cache';
require($stylepath . '/log_cache.inc.php');
require($stylepath.'/rating.inc.php');
$cachename = '';
if ($cache_id != 0)
{
//get cachename
$rs = sql("SELECT `caches`.`name`, `caches`.`user_id`, `caches`.`logpw`, `caches`.`wp_gc`, `caches`.`wp_nc`, `caches`.`type`, `caches`.`status` FROM `caches` INNER JOIN `cache_status` ON `caches`.`status`=`cache_status`.`id` WHERE (`cache_status`.`allow_user_log`=1 OR `caches`.`user_id`='&1') AND `caches`.`cache_id`='&2'", $usr['userid'], $cache_id);
if (mysql_num_rows($rs) == 0)
{
$cache_id = 0;
}
else
{
$record = sql_fetch_array($rs);
// only the owner is allowed to make logs to not published caches
if ($record['user_id'] == $usr['userid'] || $record['status'] != 5)
{
$cachename = $record['name'];
$cache_user_id = $record['user_id'];
$use_log_pw = (($record['logpw'] == NULL) || ($record['logpw'] == '')) ? false : true;
if ($use_log_pw) $log_pw = $record['logpw'];
$wp_gc = $record['wp_gc'];
$wp_nc = $record['wp_nc'];
$cache_type = $record['type'];
}
else
{
$cache_id = 0;
}
}
sql_free_result($rs);
}
if ($cache_id != 0)
{
$all_ok = false;
$log_text = isset($_POST['logtext']) ? ($_POST['logtext']) : '';
$log_type = isset($_POST['logtype']) ? ($_POST['logtype']+0) : 1;
$log_date_day = isset($_POST['logday']) ? ($_POST['logday']+0) : date('d');
$log_date_month = isset($_POST['logmonth']) ? ($_POST['logmonth']+0) : date('m');
$log_date_year = isset($_POST['logyear']) ? ($_POST['logyear']+0) : date('Y');
$top_option = isset($_POST['ratingoption']) ? $_POST['ratingoption']+0 : 0;
$top_cache = isset($_POST['rating']) ? $_POST['rating']+0 : 0;
// check if user has exceeded his top5% limit
$user_founds = sqlValue("SELECT IFNULL(`stat_user`.`found`, 0) FROM `user` LEFT JOIN `stat_user` ON `user`.`user_id`=`stat_user`.`user_id` WHERE `user`.`user_id`='" . sql_escape($usr['userid']) . "'", 0);
$user_tops = sqlValue("SELECT COUNT(`user_id`) FROM `cache_rating` WHERE `user_id`='" . sql_escape($usr['userid']) . "'", 0);
if ($user_tops < floor($user_founds * rating_percentage/100))
{
// initialize checkbox with value of past recommandation for this cache (if one exists)
$recommended = sqlValue("SELECT COUNT(`user_id`) FROM `cache_rating` WHERE `user_id`='" . sql_escape($usr['userid']) . "' AND `cache_id`='" . sql_escape($cache_id) . "'", 0);
$rating_msg = mb_ereg_replace('{chk_sel}', $recommended ? 'checked' : '', $rating_allowed.'<br />'.$rating_stat);
$rating_msg = mb_ereg_replace('{max}', floor($user_founds * rating_percentage/100), $rating_msg);
$rating_msg = mb_ereg_replace('{curr}', $user_tops, $rating_msg);
}
else
{
$anzahl = ($user_tops + 1 - ($user_founds * rating_percentage/100)) / (rating_percentage/100);
if ($anzahl > 1)
$rating_msg = mb_ereg_replace('{anzahl}', $anzahl, $rating_too_few_founds);
else
$rating_msg = mb_ereg_replace('{anzahl}', $anzahl, $rating_too_few_founds);
if ($user_tops)
$rating_msg .= '<br />'.$rating_maywithdraw;
}
tpl_set_var('rating_message', mb_ereg_replace('{rating_msg}', $rating_msg, $rating_tpl));
// descMode auslesen, falls nicht gesetzt aus dem Profil laden
if (isset($_POST['descMode']))
$descMode = $_POST['descMode']+0;
else
{
if (sqlValue("SELECT `no_htmledit_flag` FROM `user` WHERE `user_id`='" . sql_escape($usr['userid']) . "'", 1) == 1)
$descMode = 1;
else
$descMode = 3;
}
if (($descMode < 1) || ($descMode > 3)) $descMode = 3;
// fuer alte Versionen von OCProp
if ((isset($_POST['submit']) || isset($_POST['submitform'])) && !isset($_POST['version3']))
{
die('Your client may be outdated!');
}
if ($descMode != 1)
{
// Filter Input
$purifier = new HTMLPurifier();
$log_text = $purifier->purify($log_text);
}
else
{
// escape text
$log_text = nl2br(htmlspecialchars($log_text, ENT_COMPAT, 'UTF-8'));
}
//validate data
if (is_numeric($log_date_month) && is_numeric($log_date_day) && is_numeric($log_date_year))
{
$date_ok = checkdate($log_date_month, $log_date_day, $log_date_year)
&& ($log_date_year >= 2000);
if ($date_ok)
if (isset($_POST['submitform']))
if (mktime(0, 0, 0, $log_date_month, $log_date_day, $log_date_year) >= mktime())
$date_ok = false;
}
else
$date_ok = false;
$logtype_ok = sqlValue("SELECT COUNT(*) FROM cache_logtype WHERE cache_type_id='" . sql_escape($cache_type) . "' AND log_type_id='" . sql_escape($log_type) . "'", 0) > 0;
// not a found log? then ignore the rating
if ($log_type != 1 && $log_type != 7)
$top_option = 0;
$pw_ok = true;
if (isset($_POST['submitform']))
{
$all_ok = $date_ok && $logtype_ok;
if ($all_ok && $use_log_pw && $log_type == 1)
if (!isset($_POST['log_pw']) ||
mb_strtolower($log_pw) != mb_strtolower($_POST['log_pw']))
{
$pw_ok = false;
$all_ok = false;
}
}
if (isset($_POST['submitform']) && ($all_ok == true))
{
$log_date = date('Y-m-d', mktime(0, 0, 0, $log_date_month, $log_date_day, $log_date_year));
//add logentry to db
sql("INSERT INTO `cache_logs` (`id`, `cache_id`, `user_id`, `type`, `date`, `text`, `text_html`, `text_htmledit`, `node`)
VALUES ('', '&1', '&2', '&3', '&4', '&5', '&6', '&7', '&8')",
$cache_id, $usr['userid'], $log_type, $log_date, $log_text, (($descMode != 1) ? 1 : 0), (($descMode == 3) ? 1 : 0), $oc_nodeid);
// do not use slave server for the next time ...
db_slave_exclude();
// update cache_status
$rs = sql("SELECT `log_types`.`cache_status` FROM `log_types` WHERE `id`='&1'", $log_type);
if ($record = sql_fetch_array($rs))
{
$cache_status = $record['cache_status'];
if ($cache_status != 0)
{
$rs = sql("UPDATE `caches` SET `status`='&1' WHERE `cache_id`='&2'", $cache_status, $cache_id);
}
}
else
{
die("OPS!");
}
// update top-list
if ($top_option)
if ($top_cache)
sql("INSERT IGNORE INTO `cache_rating` (`user_id`, `cache_id`, `rating_date`) VALUES('&1', '&2', '&3')", $usr['userid'], $cache_id, $log_date);
else
sql("DELETE FROM `cache_rating` WHERE `user_id`='&1' AND `cache_id`='&2'", $usr['userid'], $cache_id);
//call eventhandler
require_once($rootpath . 'lib/eventhandler.inc.php');
event_new_log($cache_id, $usr['userid']+0);
//redirect to viewcache
$no_tpl_build = true;
//include('viewcache.php');
tpl_redirect('viewcache.php?cacheid=' . $cache_id);
}
else
{
//build logtypeoptions
$logtypeoptions = '';
if ($cache_type == 6) // event
$logtypeorder = 'DESC';
else
$logtypeorder = 'ASC';
$rsLogTypes = sql("SELECT `log_types`.`id`, IFNULL(`sys_trans_text`.`text`, `log_types`.`name`) AS `name`
FROM `caches`
INNER JOIN `cache_type` ON `caches`.`type`=`cache_type`.`id`
INNER JOIN `cache_logtype` ON `cache_type`.`id`=`cache_logtype`.`cache_type_id`
INNER JOIN `log_types` ON `cache_logtype`.`log_type_id`=`log_types`.`id`
LEFT JOIN `sys_trans` ON `log_types`.`trans_id`=`sys_trans`.`id`
LEFT JOIN `sys_trans_text` ON `sys_trans`.`id`=`sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang`='" . sql_escape($locale) . "'
WHERE `caches`.`cache_id`='" . ($cache_id+0) . "'
ORDER BY `log_types`.`id` " . $logtypeorder);
while ($rLogTypes = sql_fetch_assoc($rsLogTypes))
{
$sSelected = ($rLogTypes['id'] == $log_type) ? ' selected="selected"' : '';
$logtypeoptions .= '<option value="' . $rLogTypes['id'] . '"' . $sSelected . '>' . htmlspecialchars($rLogTypes['name'], ENT_COMPAT, 'UTF-8') . '</option>' . "\n";
}
sql_free_result($rsLogTypes);
//set tpl vars
tpl_set_var('cachename', htmlspecialchars($cachename, ENT_COMPAT, 'UTF-8'));
tpl_set_var('cacheid', htmlspecialchars($cache_id, ENT_COMPAT, 'UTF-8'));
tpl_set_var('logday', htmlspecialchars($log_date_day, ENT_COMPAT, 'UTF-8'));
tpl_set_var('logmonth', htmlspecialchars($log_date_month, ENT_COMPAT, 'UTF-8'));
tpl_set_var('logyear', htmlspecialchars($log_date_year, ENT_COMPAT, 'UTF-8'));
tpl_set_var('logtypeoptions', $logtypeoptions);
tpl_set_var('reset', $reset);
tpl_set_var('submit', $submit);
tpl_set_var('date_message', '');
// Text / normal HTML / HTML editor
tpl_set_var('use_tinymce', (($descMode == 3) ? 1 : 0));
if ($descMode == 1)
tpl_set_var('descMode', 1);
else if ($descMode == 2)
tpl_set_var('descMode', 2);
else
{
// TinyMCE
$headers = tpl_get_var('htmlheaders') . "\n";
$headers .= '<script language="javascript" type="text/javascript" src="resource2/tinymce/tiny_mce_gzip.js"></script>' . "\n";
$headers .= '<script language="javascript" type="text/javascript" src="resource2/tinymce/config/log.js.php?logid=0"></script>' . "\n";
tpl_set_var('htmlheaders', $headers);
tpl_set_var('descMode', 3);
}
if ($descMode != 1)
tpl_set_var('logtext', htmlspecialchars($log_text, ENT_COMPAT, 'UTF-8'), true);
else
tpl_set_var('logtext', $log_text);
$listed_on = array();
if ($wp_gc > "")
$listed_on[] = '<a href="http://www.geocaching.com/seek/cache_details.aspx?wp='.$wp_gc.'" target="_blank">geocaching.com</a> <a href="http://www.geocaching.com/seek/log.aspx?wp='.$wp_gc.'" target="_blank">(loggen)</a>';
if ($wp_nc > "")
$listed_on[] = 'navicache.com';
if (sizeof($listed_on))
{
tpl_set_var('listed_start', "");
tpl_set_var('listed_end', "");
tpl_set_var('listed_on', sizeof($listed_on) == 0 ? $listed_only_oc : implode(", ", $listed_on));
}
else
{
tpl_set_var('listed_start', "<!--");
tpl_set_var('listed_end', "-->");
}
if ($use_log_pw == true)
if (!$pw_ok == true)
tpl_set_var('log_pw_field', $log_pw_field_pw_not_ok);
else
tpl_set_var('log_pw_field', $log_pw_field);
else
tpl_set_var('log_pw_field', '');
if (!$date_ok)
tpl_set_var('date_message', $date_message);
// build smilies
$smilies = '';
if ($descMode != 3)
{
for ($i=0; $i<count($smileyshow); $i++)
{
if ($smileyshow[$i] == '1')
{
$tmp_smiley = $smiley_link;
$tmp_smiley = mb_ereg_replace('{smiley_image}', $smileyimage[$i], $tmp_smiley);
$smilies = $smilies . mb_ereg_replace('{smiley_text}', ' '.$smileytext[$i].' ', $tmp_smiley) . '&nbsp;';
}
}
}
tpl_set_var('smilies', $smilies);
}
}
else
{
// no cache found
$no_tpl_build = true;
}
}
}
if ($no_tpl_build == false)
{
//make the template and send it out
tpl_BuildTemplate(false);
}
?>
<?php
/***************************************************************************
./log.php
-------------------
begin : July 4 2004
For license information see doc/license.txt
*****************************************************************************/
/****************************************************************************
Unicode Reminder メモ
log a cache visit
used template(s): log
GET Parameter: cacheid
****************************************************************************/
//prepare the templates and include all neccessary
require_once('./lib/common.inc.php');
require($stylepath.'/smilies.inc.php');
require_once($opt['rootpath'] . '../lib/htmlpurifier-4.2.0/library/HTMLPurifier.auto.php');
$no_tpl_build = false;
//Preprocessing
if ($error == false)
{
//cacheid
$cache_id = 0;
if (isset($_REQUEST['wp']))
{
$cache_id = sqlValue("SELECT `cache_id` FROM `caches` WHERE `wp_oc`='" . sql_escape($_REQUEST['wp']) . "'", 0);
}
else if (isset($_REQUEST['cacheid']))
{
$cache_id = $_REQUEST['cacheid'];
}
if ($usr === false)
{
$tplname = 'login';
tpl_set_var('username', '');
tpl_set_var('target', 'log.php?cacheid=' . urlencode($cache_id));
tpl_set_var('message', $login_required);
tpl_set_var('message_start', '');
tpl_set_var('message_end', '');
}
else
{
//set here the template to process
$tplname = 'log_cache';
require($stylepath . '/log_cache.inc.php');
require($stylepath.'/rating.inc.php');
$cachename = '';
if ($cache_id != 0)
{
//get cachename
$rs = sql("SELECT `caches`.`name`, `caches`.`user_id`, `caches`.`logpw`, `caches`.`wp_gc`, `caches`.`wp_nc`, `caches`.`type`, `caches`.`status` FROM `caches` INNER JOIN `cache_status` ON `caches`.`status`=`cache_status`.`id` WHERE (`cache_status`.`allow_user_log`=1 OR `caches`.`user_id`='&1') AND `caches`.`cache_id`='&2'", $usr['userid'], $cache_id);
if (mysql_num_rows($rs) == 0)
{
$cache_id = 0;
}
else
{
$record = sql_fetch_array($rs);
// only the owner is allowed to make logs to not published caches
if ($record['user_id'] == $usr['userid'] || $record['status'] != 5)
{
$cachename = $record['name'];
$cache_user_id = $record['user_id'];
$use_log_pw = (($record['logpw'] == NULL) || ($record['logpw'] == '')) ? false : true;
if ($use_log_pw) $log_pw = $record['logpw'];
$wp_gc = $record['wp_gc'];
$wp_nc = $record['wp_nc'];
$cache_type = $record['type'];
}
else
{
$cache_id = 0;
}
}
sql_free_result($rs);
}
if ($cache_id != 0)
{
$all_ok = false;
$log_text = isset($_POST['logtext']) ? ($_POST['logtext']) : '';
$log_type = isset($_POST['logtype']) ? ($_POST['logtype']+0) : 1;
$log_date_day = isset($_POST['logday']) ? ($_POST['logday']+0) : date('d');
$log_date_month = isset($_POST['logmonth']) ? ($_POST['logmonth']+0) : date('m');
$log_date_year = isset($_POST['logyear']) ? ($_POST['logyear']+0) : date('Y');
$top_option = isset($_POST['ratingoption']) ? $_POST['ratingoption']+0 : 0;
$top_cache = isset($_POST['rating']) ? $_POST['rating']+0 : 0;
// check if user has exceeded his top5% limit
$user_founds = sqlValue("SELECT IFNULL(`stat_user`.`found`, 0) FROM `user` LEFT JOIN `stat_user` ON `user`.`user_id`=`stat_user`.`user_id` WHERE `user`.`user_id`='" . sql_escape($usr['userid']) . "'", 0);
$user_tops = sqlValue("SELECT COUNT(`user_id`) FROM `cache_rating` WHERE `user_id`='" . sql_escape($usr['userid']) . "'", 0);
if ($user_tops < floor($user_founds * rating_percentage/100))
{
// initialize checkbox with value of past recommandation for this cache (if one exists)
$recommended = sqlValue("SELECT COUNT(`user_id`) FROM `cache_rating` WHERE `user_id`='" . sql_escape($usr['userid']) . "' AND `cache_id`='" . sql_escape($cache_id) . "'", 0);
$rating_msg = mb_ereg_replace('{chk_sel}', $recommended ? 'checked' : '', $rating_allowed.'<br />'.$rating_stat);
$rating_msg = mb_ereg_replace('{max}', floor($user_founds * rating_percentage/100), $rating_msg);
$rating_msg = mb_ereg_replace('{curr}', $user_tops, $rating_msg);
}
else
{
$anzahl = ($user_tops + 1 - ($user_founds * rating_percentage/100)) / (rating_percentage/100);
if ($anzahl > 1)
$rating_msg = mb_ereg_replace('{anzahl}', $anzahl, $rating_too_few_founds);
else
$rating_msg = mb_ereg_replace('{anzahl}', $anzahl, $rating_too_few_founds);
if ($user_tops)
$rating_msg .= '<br />'.$rating_maywithdraw;
}
tpl_set_var('rating_message', mb_ereg_replace('{rating_msg}', $rating_msg, $rating_tpl));
// descMode auslesen, falls nicht gesetzt aus dem Profil laden
if (isset($_POST['descMode']))
$descMode = $_POST['descMode']+0;
else
{
if (sqlValue("SELECT `no_htmledit_flag` FROM `user` WHERE `user_id`='" . sql_escape($usr['userid']) . "'", 1) == 1)
$descMode = 1;
else
$descMode = 3;
}
if (($descMode < 1) || ($descMode > 3)) $descMode = 3;
// fuer alte Versionen von OCProp
if ((isset($_POST['submit']) || isset($_POST['submitform'])) && !isset($_POST['version3']))
{
die('Your client may be outdated!');
}
if ($descMode != 1)
{
// Filter Input
$purifier = new HTMLPurifier();
$log_text = $purifier->purify($log_text);
}
else
{
// escape text
$log_text = nl2br(htmlspecialchars($log_text, ENT_COMPAT, 'UTF-8'));
}
//validate data
if (is_numeric($log_date_month) && is_numeric($log_date_day) && is_numeric($log_date_year))
{
$date_ok = checkdate($log_date_month, $log_date_day, $log_date_year)
&& ($log_date_year >= 2000);
if ($date_ok)
if (isset($_POST['submitform']))
if (mktime(0, 0, 0, $log_date_month, $log_date_day, $log_date_year) >= mktime())
$date_ok = false;
}
else
$date_ok = false;
$logtype_ok = sqlValue("SELECT COUNT(*) FROM cache_logtype WHERE cache_type_id='" . sql_escape($cache_type) . "' AND log_type_id='" . sql_escape($log_type) . "'", 0) > 0;
// not a found log? then ignore the rating
if ($log_type != 1 && $log_type != 7)
$top_option = 0;
$pw_ok = true;
if (isset($_POST['submitform']))
{
$all_ok = $date_ok && $logtype_ok;
if ($all_ok && $use_log_pw && $log_type == 1)
if (!isset($_POST['log_pw']) ||
mb_strtolower($log_pw) != mb_strtolower($_POST['log_pw']))
{
$pw_ok = false;
$all_ok = false;
}
}
if (isset($_POST['submitform']) && ($all_ok == true))
{
$log_date = date('Y-m-d', mktime(0, 0, 0, $log_date_month, $log_date_day, $log_date_year));
//add logentry to db
sql("INSERT INTO `cache_logs` (`id`, `cache_id`, `user_id`, `type`, `date`, `text`, `text_html`, `text_htmledit`, `node`)
VALUES ('', '&1', '&2', '&3', '&4', '&5', '&6', '&7', '&8')",
$cache_id, $usr['userid'], $log_type, $log_date, $log_text, (($descMode != 1) ? 1 : 0), (($descMode == 3) ? 1 : 0), $oc_nodeid);
// do not use slave server for the next time ...
db_slave_exclude();
// update cache_status
$rs = sql("SELECT `log_types`.`cache_status` FROM `log_types` WHERE `id`='&1'", $log_type);
if ($record = sql_fetch_array($rs))
{
$cache_status = $record['cache_status'];
if ($cache_status != 0)
{
$rs = sql("UPDATE `caches` SET `status`='&1' WHERE `cache_id`='&2'", $cache_status, $cache_id);
}
}
else
{
die("OPS!");
}
// update top-list
if ($top_option)
if ($top_cache)
sql("INSERT IGNORE INTO `cache_rating` (`user_id`, `cache_id`, `rating_date`) VALUES('&1', '&2', '&3')", $usr['userid'], $cache_id, $log_date);
else
sql("DELETE FROM `cache_rating` WHERE `user_id`='&1' AND `cache_id`='&2'", $usr['userid'], $cache_id);
//call eventhandler
require_once($rootpath . 'lib/eventhandler.inc.php');
event_new_log($cache_id, $usr['userid']+0);
//redirect to viewcache
$no_tpl_build = true;
//include('viewcache.php');
tpl_redirect('viewcache.php?cacheid=' . $cache_id);
}
else
{
//build logtypeoptions
$logtypeoptions = '';
if ($cache_type == 6) // event
$logtypeorder = 'DESC';
else
$logtypeorder = 'ASC';
$rsLogTypes = sql("SELECT `log_types`.`id`, IFNULL(`sys_trans_text`.`text`, `log_types`.`name`) AS `name`
FROM `caches`
INNER JOIN `cache_type` ON `caches`.`type`=`cache_type`.`id`
INNER JOIN `cache_logtype` ON `cache_type`.`id`=`cache_logtype`.`cache_type_id`
INNER JOIN `log_types` ON `cache_logtype`.`log_type_id`=`log_types`.`id`
LEFT JOIN `sys_trans` ON `log_types`.`trans_id`=`sys_trans`.`id`
LEFT JOIN `sys_trans_text` ON `sys_trans`.`id`=`sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang`='" . sql_escape($locale) . "'
WHERE `caches`.`cache_id`='" . ($cache_id+0) . "'
ORDER BY `log_types`.`id` " . $logtypeorder);
while ($rLogTypes = sql_fetch_assoc($rsLogTypes))
{
$sSelected = ($rLogTypes['id'] == $log_type) ? ' selected="selected"' : '';
$logtypeoptions .= '<option value="' . $rLogTypes['id'] . '"' . $sSelected . '>' . htmlspecialchars($rLogTypes['name'], ENT_COMPAT, 'UTF-8') . '</option>' . "\n";
}
sql_free_result($rsLogTypes);
//set tpl vars
tpl_set_var('cachename', htmlspecialchars($cachename, ENT_COMPAT, 'UTF-8'));
tpl_set_var('cacheid', htmlspecialchars($cache_id, ENT_COMPAT, 'UTF-8'));
tpl_set_var('logday', htmlspecialchars($log_date_day, ENT_COMPAT, 'UTF-8'));
tpl_set_var('logmonth', htmlspecialchars($log_date_month, ENT_COMPAT, 'UTF-8'));
tpl_set_var('logyear', htmlspecialchars($log_date_year, ENT_COMPAT, 'UTF-8'));
tpl_set_var('logtypeoptions', $logtypeoptions);
tpl_set_var('reset', $reset);
tpl_set_var('submit', $submit);
tpl_set_var('date_message', '');
// Text / normal HTML / HTML editor
tpl_set_var('use_tinymce', (($descMode == 3) ? 1 : 0));
if ($descMode == 1)
tpl_set_var('descMode', 1);
else if ($descMode == 2)
tpl_set_var('descMode', 2);
else
{
// TinyMCE
$headers = tpl_get_var('htmlheaders') . "\n";
$headers .= '<script language="javascript" type="text/javascript" src="resource2/tinymce/tiny_mce_gzip.js"></script>' . "\n";
$headers .= '<script language="javascript" type="text/javascript" src="resource2/tinymce/config/log.js.php?logid=0"></script>' . "\n";
tpl_set_var('htmlheaders', $headers);
tpl_set_var('descMode', 3);
}
if ($descMode != 1)
tpl_set_var('logtext', htmlspecialchars($log_text, ENT_COMPAT, 'UTF-8'), true);
else
tpl_set_var('logtext', $log_text);
$listed_on = array();
if ($wp_gc > "")
$listed_on[] = '<a href="http://www.geocaching.com/seek/cache_details.aspx?wp='.$wp_gc.'" target="_blank">geocaching.com</a> <a href="http://www.geocaching.com/seek/log.aspx?wp='.$wp_gc.'" target="_blank">(loggen)</a>';
if ($wp_nc > "")
$listed_on[] = 'navicache.com';
if (sizeof($listed_on))
{
tpl_set_var('listed_start', "");
tpl_set_var('listed_end', "");
tpl_set_var('listed_on', sizeof($listed_on) == 0 ? $listed_only_oc : implode(", ", $listed_on));
}
else
{
tpl_set_var('listed_start', "<!--");
tpl_set_var('listed_end', "-->");
}
if ($use_log_pw == true)
if (!$pw_ok == true)
tpl_set_var('log_pw_field', $log_pw_field_pw_not_ok);
else
tpl_set_var('log_pw_field', $log_pw_field);
else
tpl_set_var('log_pw_field', '');
if (!$date_ok)
tpl_set_var('date_message', $date_message);
// build smilies
$smilies = '';
if ($descMode != 3)
{
for ($i=0; $i<count($smileyshow); $i++)
{
if ($smileyshow[$i] == '1')
{
$tmp_smiley = $smiley_link;
$tmp_smiley = mb_ereg_replace('{smiley_image}', $smileyimage[$i], $tmp_smiley);
$smilies = $smilies . mb_ereg_replace('{smiley_text}', ' '.$smileytext[$i].' ', $tmp_smiley) . '&nbsp;';
}
}
}
tpl_set_var('smilies', $smilies);
}
}
else
{
// no cache found
$no_tpl_build = true;
}
}
}
if ($no_tpl_build == false)
{
//make the template and send it out
tpl_BuildTemplate(false);
}
?>

View File

@ -1,237 +1,237 @@
<?php
/***************************************************************************
./newdesc.php
-------------------
begin : July 7 2004
For license information see doc/license.txt
****************************************************************************/
/****************************************************************************
Unicode Reminder メモ
add a cache description to a cache
used template(s): newdesc
****************************************************************************/
//prepare the templates and include all neccessary
require_once('./lib/common.inc.php');
require_once($opt['rootpath'] . '../lib/htmlpurifier-4.2.0/library/HTMLPurifier.auto.php');
//Preprocessing
if ($error == false)
{
$cache_id = 0;
if (isset($_REQUEST['cacheid']))
{
$cache_id = $_REQUEST['cacheid'];
}
//must be logged in
if ($usr === false)
{
$tplname = 'login';
tpl_set_var('username', '');
tpl_set_var('target', htmlspecialchars('newdesc.php?cacheid=' . urlencode($cache_id), ENT_COMPAT, 'UTF-8'));
tpl_set_var('message', $login_required);
}
else
{
//user must be the owner of the cache
$cache_rs = sql("SELECT `user_id`, `name` FROM `caches` WHERE `cache_id`='&1'", $cache_id);
if (mysql_num_rows($cache_rs) > 0)
{
$cache_record = sql_fetch_array($cache_rs);
mysql_free_result($cache_rs);
if ($cache_record['user_id'] == $usr['userid'])
{
$tplname = 'newdesc';
require($stylepath . '/newdesc.inc.php');
//get the posted data
$show_all_langs = isset($_POST['show_all_langs']) ? $_POST['show_all_langs'] : 0;
$short_desc = isset($_POST['short_desc']) ? $_POST['short_desc'] : '';
$hints = isset($_POST['hints']) ? $_POST['hints'] : '';
$sel_lang = isset($_POST['desc_lang']) ? $_POST['desc_lang'] : $default_lang;
$desc = isset($_POST['desc']) ? $_POST['desc'] : '';
$descMode = isset($_POST['descMode']) ? ($_POST['descMode']+0) : 3;
if (($descMode < 1) || ($descMode > 3)) $descMode = 3;
// fuer alte Versionen von OCProp
if (isset($_POST['submit']) && !isset($_POST['version2']))
{
$descMode = (isset($_POST['desc_html']) && ($_POST['desc_html']==1)) ? 2 : 1;
$_POST['submitform'] = $_POST['submit'];
$desc = iconv("ISO-8859-1", "UTF-8", $desc);
$short_desc = iconv("ISO-8859-1", "UTF-8", $short_desc);
$hints = iconv("ISO-8859-1", "UTF-8", $hints);
}
if ($descMode != 1)
{
// Filter Input
$purifier = new HTMLPurifier();
$desc = $purifier->purify($desc);
}
$desc_lang_exists = false;
//save to db?
if (isset($_POST['submitform']))
{
//check if the entered language already exists
$desc_rs = sql("SELECT `id` FROM `cache_desc` WHERE `cache_id`='&1' AND `language`='&2'", $cache_id, $sel_lang);
$desc_lang_exists = (mysql_num_rows($desc_rs) > 0);
mysql_free_result($desc_rs);
if ($desc_lang_exists == false)
{
//add to DB
if ($descMode != 1)
{
sql("INSERT INTO `cache_desc` (
`id`,
`cache_id`,
`language`,
`desc`,
`desc_html`,
`desc_htmledit`,
`hint`,
`short_desc`,
`last_modified`,
`node`
) VALUES ('', '&1', '&2', '&3', 1, '&4', '&5', '&6', NOW(), '&7')",
$cache_id,
$sel_lang,
$desc,
($descMode == 3) ? '1' : '0',
nl2br(htmlspecialchars($hints, ENT_COMPAT, 'UTF-8')),
$short_desc,
$oc_nodeid);
}
else
{
sql("INSERT INTO `cache_desc` (
`id`,
`cache_id`,
`language`,
`desc`,
`desc_html`,
`desc_htmledit`,
`hint`,
`short_desc`,
`last_modified`,
`node`
) VALUES ('', '&1', '&2', '&3', 0, 0, '&4', '&5', NOW(), '&6')",
$cache_id,
$sel_lang,
nl2br(htmlspecialchars($desc, ENT_COMPAT, 'UTF-8')),
nl2br(htmlspecialchars($hints, ENT_COMPAT, 'UTF-8')),
$short_desc,
$oc_nodeid);
}
// do not use slave server for the next time ...
db_slave_exclude();
tpl_redirect('editcache.php?cacheid=' . urlencode($cache_id));
exit;
}
}
elseif (isset($_POST['show_all_langs_submit']))
{
$show_all_langs = 1;
}
// check if any default language is available
if ($show_all_langs == 0)
{
if (sqlValue("SELECT COUNT(*)
FROM `languages_list_default`
LEFT JOIN `cache_desc` ON `languages_list_default`.`show`=`cache_desc`.`language` AND `cache_desc`.`cache_id`='" . sql_escape($cache_id) . "'
WHERE `languages_list_default`.`lang`='" . sql_escape($locale) . "' AND ISNULL(`cache_desc`.`cache_id`)", 0) == 0)
{
$show_all_langs = 1;
}
}
//build langslist
$langoptions = '';
$rsLanguages = sql("SELECT `short`, IFNULL(`sys_trans_text`.`text`, `languages`.`name`) AS `name`
FROM `languages`
LEFT JOIN `languages_list_default` ON `languages`.`short`=`languages_list_default`.`show` AND `languages_list_default`.`lang`='&1'
LEFT JOIN `sys_trans` ON `languages`.`trans_id`=`sys_trans`.`id`
LEFT JOIN `sys_trans_text` ON `sys_trans`.`id`=`sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang`='&1'
WHERE `languages`.`short` NOT IN (SELECT `language` FROM `cache_desc` WHERE `cache_id`='&3') AND
('&2'=1 OR `languages_list_default`.`show`=`languages`.`short`)
ORDER BY `name` ASC",
$locale,
(($show_all_langs == 1) ? 1 : 0),
$cache_id);
while ($rLanguage = sql_fetch_assoc($rsLanguages))
{
$sSelected = ($rLanguage['short'] == $sel_lang) ? ' selected="selected"' : '';
$langoptions .= '<option value="' . htmlspecialchars($rLanguage['short'], ENT_COMPAT, 'UTF-8') . '"' . $sSelected . '>' . htmlspecialchars($rLanguage['name'], ENT_COMPAT, 'UTF-8') . '</option>' . "\n";
}
sql_free_result($rsLanguages);
tpl_set_var('langoptions', $langoptions);
//here we set the template vars
tpl_set_var('name', htmlspecialchars($cache_record['name'], ENT_COMPAT, 'UTF-8'));
tpl_set_var('cacheid', htmlspecialchars($cache_id, ENT_COMPAT, 'UTF-8'));
tpl_set_var('lang_message', $desc_lang_exists ? $lang_message : '');
tpl_set_var('show_all_langs', $show_all_langs);
tpl_set_var('show_all_langs_submit', ($show_all_langs == 0) ? $show_all_langs_submit : '');
tpl_set_var('short_desc', htmlspecialchars($short_desc, ENT_COMPAT, 'UTF-8'));
tpl_set_var('desc', htmlspecialchars($desc, ENT_COMPAT, 'UTF-8'));
tpl_set_var('hints', htmlspecialchars($hints, ENT_COMPAT, 'UTF-8'));
// Text / normal HTML / HTML editor
tpl_set_var('use_tinymce', (($descMode == 3) ? 1 : 0));
if ($descMode == 1)
tpl_set_var('descMode', 1);
else if ($descMode == 2)
tpl_set_var('descMode', 2);
else
{
// TinyMCE
$headers = tpl_get_var('htmlheaders') . "\n";
$headers .= '<script language="javascript" type="text/javascript" src="resource2/tinymce/tiny_mce_gzip.js"></script>' . "\n";
$headers .= '<script language="javascript" type="text/javascript" src="resource2/tinymce/config/desc.js.php?cacheid=' . ($cache_id+0) . '&lang=' . strtolower($locale) . '"></script>' . "\n";
tpl_set_var('htmlheaders', $headers);
tpl_set_var('descMode', 3);
}
tpl_set_var('reset', $reset);
tpl_set_var('submit', $submit);
}
else
{
//TODO: not the owner
}
}
else
{
mysql_free_result($cache_rs);
//TODO: cache not exist
}
}
}
//make the template and send it out
tpl_BuildTemplate();
?>
<?php
/***************************************************************************
./newdesc.php
-------------------
begin : July 7 2004
For license information see doc/license.txt
****************************************************************************/
/****************************************************************************
Unicode Reminder メモ
add a cache description to a cache
used template(s): newdesc
****************************************************************************/
//prepare the templates and include all neccessary
require_once('./lib/common.inc.php');
require_once($opt['rootpath'] . '../lib/htmlpurifier-4.2.0/library/HTMLPurifier.auto.php');
//Preprocessing
if ($error == false)
{
$cache_id = 0;
if (isset($_REQUEST['cacheid']))
{
$cache_id = $_REQUEST['cacheid'];
}
//must be logged in
if ($usr === false)
{
$tplname = 'login';
tpl_set_var('username', '');
tpl_set_var('target', htmlspecialchars('newdesc.php?cacheid=' . urlencode($cache_id), ENT_COMPAT, 'UTF-8'));
tpl_set_var('message', $login_required);
}
else
{
//user must be the owner of the cache
$cache_rs = sql("SELECT `user_id`, `name` FROM `caches` WHERE `cache_id`='&1'", $cache_id);
if (mysql_num_rows($cache_rs) > 0)
{
$cache_record = sql_fetch_array($cache_rs);
mysql_free_result($cache_rs);
if ($cache_record['user_id'] == $usr['userid'])
{
$tplname = 'newdesc';
require($stylepath . '/newdesc.inc.php');
//get the posted data
$show_all_langs = isset($_POST['show_all_langs']) ? $_POST['show_all_langs'] : 0;
$short_desc = isset($_POST['short_desc']) ? $_POST['short_desc'] : '';
$hints = isset($_POST['hints']) ? $_POST['hints'] : '';
$sel_lang = isset($_POST['desc_lang']) ? $_POST['desc_lang'] : $default_lang;
$desc = isset($_POST['desc']) ? $_POST['desc'] : '';
$descMode = isset($_POST['descMode']) ? ($_POST['descMode']+0) : 3;
if (($descMode < 1) || ($descMode > 3)) $descMode = 3;
// fuer alte Versionen von OCProp
if (isset($_POST['submit']) && !isset($_POST['version2']))
{
$descMode = (isset($_POST['desc_html']) && ($_POST['desc_html']==1)) ? 2 : 1;
$_POST['submitform'] = $_POST['submit'];
$desc = iconv("ISO-8859-1", "UTF-8", $desc);
$short_desc = iconv("ISO-8859-1", "UTF-8", $short_desc);
$hints = iconv("ISO-8859-1", "UTF-8", $hints);
}
if ($descMode != 1)
{
// Filter Input
$purifier = new HTMLPurifier();
$desc = $purifier->purify($desc);
}
$desc_lang_exists = false;
//save to db?
if (isset($_POST['submitform']))
{
//check if the entered language already exists
$desc_rs = sql("SELECT `id` FROM `cache_desc` WHERE `cache_id`='&1' AND `language`='&2'", $cache_id, $sel_lang);
$desc_lang_exists = (mysql_num_rows($desc_rs) > 0);
mysql_free_result($desc_rs);
if ($desc_lang_exists == false)
{
//add to DB
if ($descMode != 1)
{
sql("INSERT INTO `cache_desc` (
`id`,
`cache_id`,
`language`,
`desc`,
`desc_html`,
`desc_htmledit`,
`hint`,
`short_desc`,
`last_modified`,
`node`
) VALUES ('', '&1', '&2', '&3', 1, '&4', '&5', '&6', NOW(), '&7')",
$cache_id,
$sel_lang,
$desc,
($descMode == 3) ? '1' : '0',
nl2br(htmlspecialchars($hints, ENT_COMPAT, 'UTF-8')),
$short_desc,
$oc_nodeid);
}
else
{
sql("INSERT INTO `cache_desc` (
`id`,
`cache_id`,
`language`,
`desc`,
`desc_html`,
`desc_htmledit`,
`hint`,
`short_desc`,
`last_modified`,
`node`
) VALUES ('', '&1', '&2', '&3', 0, 0, '&4', '&5', NOW(), '&6')",
$cache_id,
$sel_lang,
nl2br(htmlspecialchars($desc, ENT_COMPAT, 'UTF-8')),
nl2br(htmlspecialchars($hints, ENT_COMPAT, 'UTF-8')),
$short_desc,
$oc_nodeid);
}
// do not use slave server for the next time ...
db_slave_exclude();
tpl_redirect('editcache.php?cacheid=' . urlencode($cache_id));
exit;
}
}
elseif (isset($_POST['show_all_langs_submit']))
{
$show_all_langs = 1;
}
// check if any default language is available
if ($show_all_langs == 0)
{
if (sqlValue("SELECT COUNT(*)
FROM `languages_list_default`
LEFT JOIN `cache_desc` ON `languages_list_default`.`show`=`cache_desc`.`language` AND `cache_desc`.`cache_id`='" . sql_escape($cache_id) . "'
WHERE `languages_list_default`.`lang`='" . sql_escape($locale) . "' AND ISNULL(`cache_desc`.`cache_id`)", 0) == 0)
{
$show_all_langs = 1;
}
}
//build langslist
$langoptions = '';
$rsLanguages = sql("SELECT `short`, IFNULL(`sys_trans_text`.`text`, `languages`.`name`) AS `name`
FROM `languages`
LEFT JOIN `languages_list_default` ON `languages`.`short`=`languages_list_default`.`show` AND `languages_list_default`.`lang`='&1'
LEFT JOIN `sys_trans` ON `languages`.`trans_id`=`sys_trans`.`id`
LEFT JOIN `sys_trans_text` ON `sys_trans`.`id`=`sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang`='&1'
WHERE `languages`.`short` NOT IN (SELECT `language` FROM `cache_desc` WHERE `cache_id`='&3') AND
('&2'=1 OR `languages_list_default`.`show`=`languages`.`short`)
ORDER BY `name` ASC",
$locale,
(($show_all_langs == 1) ? 1 : 0),
$cache_id);
while ($rLanguage = sql_fetch_assoc($rsLanguages))
{
$sSelected = ($rLanguage['short'] == $sel_lang) ? ' selected="selected"' : '';
$langoptions .= '<option value="' . htmlspecialchars($rLanguage['short'], ENT_COMPAT, 'UTF-8') . '"' . $sSelected . '>' . htmlspecialchars($rLanguage['name'], ENT_COMPAT, 'UTF-8') . '</option>' . "\n";
}
sql_free_result($rsLanguages);
tpl_set_var('langoptions', $langoptions);
//here we set the template vars
tpl_set_var('name', htmlspecialchars($cache_record['name'], ENT_COMPAT, 'UTF-8'));
tpl_set_var('cacheid', htmlspecialchars($cache_id, ENT_COMPAT, 'UTF-8'));
tpl_set_var('lang_message', $desc_lang_exists ? $lang_message : '');
tpl_set_var('show_all_langs', $show_all_langs);
tpl_set_var('show_all_langs_submit', ($show_all_langs == 0) ? $show_all_langs_submit : '');
tpl_set_var('short_desc', htmlspecialchars($short_desc, ENT_COMPAT, 'UTF-8'));
tpl_set_var('desc', htmlspecialchars($desc, ENT_COMPAT, 'UTF-8'));
tpl_set_var('hints', htmlspecialchars($hints, ENT_COMPAT, 'UTF-8'));
// Text / normal HTML / HTML editor
tpl_set_var('use_tinymce', (($descMode == 3) ? 1 : 0));
if ($descMode == 1)
tpl_set_var('descMode', 1);
else if ($descMode == 2)
tpl_set_var('descMode', 2);
else
{
// TinyMCE
$headers = tpl_get_var('htmlheaders') . "\n";
$headers .= '<script language="javascript" type="text/javascript" src="resource2/tinymce/tiny_mce_gzip.js"></script>' . "\n";
$headers .= '<script language="javascript" type="text/javascript" src="resource2/tinymce/config/desc.js.php?cacheid=' . ($cache_id+0) . '&lang=' . strtolower($locale) . '"></script>' . "\n";
tpl_set_var('htmlheaders', $headers);
tpl_set_var('descMode', 3);
}
tpl_set_var('reset', $reset);
tpl_set_var('submit', $submit);
}
else
{
//TODO: not the owner
}
}
else
{
mysql_free_result($cache_rs);
//TODO: cache not exist
}
}
}
//make the template and send it out
tpl_BuildTemplate();
?>

View File

@ -1,302 +1,302 @@
<?php
/***************************************************************************
* For license information see doc/license.txt
*
* Unicode Reminder メモ
*
* TODO: use cache() class at all
***************************************************************************/
require('./lib2/web.inc.php');
require_once('./lib2/logic/labels.inc.php');
require_once('./lib2/logic/cache.class.php');
require_once('./lib2/logic/attribute.class.php');
require_once('./lib2/logic/coordinate.class.php');
require_once($opt['rootpath'] . 'lib2/logic/useroptions.class.php');
$login->verify();
function getChildWaypoints($cacheid)
{
$wphandler = new ChildWp_Handler();
$waypoints = $wphandler->getChildWps($cacheid);
$count = count($waypoints);
if ($count > 0)
{
$formatter = new Coordinate_Formatter();
for ($i = 0; $i < $count; $i++)
{
$waypoints[$i]['coordinateHtml'] = $formatter->formatHtml($waypoints[$i]['coordinate'], '<br />');
}
}
return $waypoints;
}
$tpl->name = 'viewcache';
$tpl->menuitem = MNU_CACHES_SEARCH_VIEWCACHE;
$tpl->assign('use_tooltiplib', true);
// get cacheid
$cacheid = 0;
if (isset($_REQUEST['cacheid']))
$cacheid = $_REQUEST['cacheid']+0;
else if (isset($_REQUEST['uuid']))
$cacheid = cache::cacheIdFromUUID($_REQUEST['uuid']);
else if (isset($_REQUEST['wp']))
$cacheid = cache::cacheIdFromWP($_REQUEST['wp']);
$cache = new cache($cacheid);
if ($cache->exist() == false)
$tpl->error(ERROR_CACHE_NOT_EXISTS);
if ($cache->allowView() == false)
$tpl->error(ERROR_NO_ACCESS);
if (isset($_REQUEST['visitcounter']) && $_REQUEST['visitcounter'] == 1)
{
cache::visitCounter($login->userid, $_SERVER["REMOTE_ADDR"], $cacheid);
exit;
}
$bCrypt = !isset($_REQUEST['nocrypt']) || ($_REQUEST['nocrypt'] != 1);
$tpl->assign('crypt', $bCrypt);
if (isset($_REQUEST['desclang']))
$sPreferedDescLang = $_REQUEST['desclang'] . ',' . $opt['template']['locale'] . ',EN';
else
$sPreferedDescLang = $opt['template']['locale'] . ',EN';
//$tpl->caching = true;
//$tpl->cache_lifetime = 31*24*60*60;
//$tpl->cache_id = $cacheid . '|' . $sPreferedDescLang;
if ($login->userid!=0)
{
$tpl->assign('ignored', sql_value("SELECT 1 FROM `cache_ignore` WHERE `cache_id`='&1' AND `user_id`='&2'", 0, $cacheid, $login->userid));
$tpl->assign('watched', sql_value("SELECT 1 FROM `cache_watches` WHERE `cache_id`='&1' AND `user_id`='&2'", 0, $cacheid, $login->userid));
}
//get cache record
$rs = sql("SELECT `caches`.`cache_id` AS `cacheid`,
`caches`.`user_id` AS `userid`,
`caches`.`status` AS `status`,
`caches`.`latitude` AS `latitude`,
`caches`.`longitude` AS `longitude`,
`caches`.`name` AS `name`,
`caches`.`type` AS `type`,
`caches`.`size` AS `size`,
`caches`.`search_time` AS `searchtime`,
`caches`.`way_length` AS `waylength`,
`caches`.`country` AS `countryCode`,
IFNULL(`ttCountry`.`text`, `countries`.`name`) AS `country`,
`caches`.`logpw` AS `logpw`,
`caches`.`date_hidden` AS `datehidden`,
`caches`.`wp_oc` AS `wpoc`,
`caches`.`wp_gc` AS `wpgc`,
`caches`.`wp_nc` AS `wpnc`,
`caches`.`date_created` AS `datecreated`,
`caches`.`is_publishdate` AS `is_publishdate`,
`caches`.`difficulty` AS `difficulty`,
`caches`.`terrain` AS `terrain`,
`cache_desc`.`language` AS `desclanguage`,
`cache_desc`.`short_desc` AS `shortdesc`,
`cache_desc`.`desc` AS `desc`,
`cache_desc`.`hint` AS `hint`,
`cache_desc`.`desc_html` AS `deschtml`,
`cache_status`.`allow_user_log`=1 OR `caches`.`user_id`='&4' AS `log_allowed`,
IFNULL(`stat_caches`.`found`, 0) AS `found`,
IFNULL(`stat_caches`.`notfound`, 0) AS `notfound`,
IFNULL(`stat_caches`.`note`, 0) AS `note`,
IFNULL(`stat_caches`.`will_attend`, 0) AS `willattend`,
IFNULL(`stat_caches`.`watch`, 0) AS `watcher`,
`caches`.`desc_languages` AS `desclanguages`,
IFNULL(`stat_caches`.`ignore`, 0) AS `ignorercount`,
IFNULL(`stat_caches`.`toprating`, 0) AS `topratings`,
IFNULL(`cache_visits`.`count`, 0) AS `visits`,
`user`.`username` AS `username`,
IFNULL(`cache_location`.`code1`, '') AS `code1`,
IFNULL(`cache_location`.`adm1`, '') AS `adm1`,
IFNULL(`cache_location`.`adm2`, '') AS `adm2`,
IFNULL(`cache_location`.`adm3`, '') AS `adm3`,
IFNULL(`cache_location`.`adm4`, '') AS `adm4`
FROM `caches`
INNER JOIN `user` ON `caches`.`user_id`=`user`.`user_id`
INNER JOIN `cache_desc` ON `caches`.`cache_id`=`cache_desc`.`cache_id` AND `cache_desc`.`language`=PREFERED_LANG(`caches`.`desc_languages`, '&3')
INNER JOIN `cache_status` ON `caches`.`status`=`cache_status`.`id`
LEFT JOIN `countries` ON `caches`.`country`=`countries`.`short`
LEFT JOIN `sys_trans` AS `tCountry` ON `countries`.`trans_id`=`tCountry`.`id` AND `countries`.`name`=`tCountry`.`text`
LEFT JOIN `sys_trans_text` AS `ttCountry` ON `tCountry`.`id`=`ttCountry`.`trans_id` AND `ttCountry`.`lang`='&2'
LEFT JOIN `cache_visits` ON `cache_visits`.`cache_id`=`caches`.`cache_id` AND `user_id_ip`='0'
LEFT JOIN `stat_caches` ON `caches`.`cache_id`=`stat_caches`.`cache_id`
LEFT JOIN `cache_location` ON `caches`.`cache_id` = `cache_location`.`cache_id`
WHERE `caches`.`cache_id`='&1'", $cacheid, $opt['template']['locale'], $sPreferedDescLang, $login->userid);
$rCache = sql_fetch_assoc($rs);
sql_free_result($rs);
if ($rCache === false)
$tpl->error(ERROR_CACHE_NOT_EXISTS);
// not published?
if ($rCache['status'] == 5)
{
$tpl->caching = false;
$login->verify();
if ($rCache['userid'] != $login->userid)
$tpl->error(ERROR_CACHE_NOT_PUBLISHED);
}
$rCache['lastmodified'] = sql_value("SELECT MAX(`last_modified`) `last_modified` FROM
(SELECT `last_modified` FROM `caches` WHERE `cache_id` ='&1'
UNION SELECT `last_modified` FROM `cache_desc` WHERE `cache_id` ='&1') `tmp_result`",
null, $cacheid);
$rCache['desclanguages'] = explode(',', $rCache['desclanguages']);
$rCache['sizeName'] = labels::getLabelValue('cache_size', $rCache['size']);
$rCache['statusName'] = labels::getLabelValue('cache_status', $rCache['status']);
$rCache['typeName'] = labels::getLabelValue('cache_type', $rCache['type']);
$rCache['userhasfound'] = false;
if ($login->userid != 0)
$rCache['userhasfound'] = (sql_value("SELECT COUNT(*) FROM `cache_logs` WHERE `cache_id`='&1' AND `user_id`='&2' AND `type` IN (1,7)", 0, $cacheid, $login->userid) > 0);
$tpl->assign('cache', $rCache);
$tpl->title = $rCache['wpoc'] . ' ' . $rCache['name'];
$coord = new coordinate($rCache['latitude'], $rCache['longitude']);
$tpl->assign('coordinates', $coord->getDecimalMinutes());
// pictures
$rs = sql("SELECT `id`, `uuid`, `url`, `title`, `thumb_url`, `spoiler`, `display` FROM `pictures` WHERE `object_type`=2 AND `object_id`='&1' AND `display`!=0 ORDER BY `date_created` ASC", $cacheid);
$tpl->assign_rs('pictures', $rs);
sql_free_result($rs);
$tpl->assign('childWaypoints', getChildWaypoints($cacheid));
if ($login->userid != 0)
{
$cacheNotePresenter = new CacheNote_Presenter(new Http_Request(), new Language_Translator());
$cacheNotePresenter->init(new CacheNote_Handler(), $login->userid, $cacheid);
if (isset($_POST['submit_cache_note']) && $cacheNotePresenter->validate())
{
$cacheNotePresenter->doSubmit();
}
$cacheNotePresenter->prepare($tpl);
}
$tpl->assign('enableCacheNote', $login->userid != 0);
/* Logentries */
/* begin insertion/change Uwe 20091215 for printing purposes
reworked on 20100106 for better performance after Olivers intervention
rewritten 2012-07-22 following for bugfix, first log was lost in print
*/
$rscount = 5;
if (isset($_REQUEST['log']))
switch ($_REQUEST['log'])
{
case 'N': $rscount = 0;
break;
case 'A': $rscount = current(cache::getLogsCount($cacheid));
break;
default: if ($_REQUEST['log'] > 0)
$rscount = $_REQUEST['log'] + 0;
}
$logs = cache::getLogsArray($cacheid, 0, $rscount+1);
if (isset($logs[$rscount]))
{
unset($logs[$rscount]);
$tpl->assign('showalllogs', true);
}
$loganz = sizeof($logs);
$tpl->assign('logs', $logs);
$tpl->assign('loganz', $loganz);
/*end insertion Uwe 20091215*/
/* nature protection areas
*/
$rs = sql("SELECT `npa_areas`.`id` AS `npaId`, `npa_areas`.`type_id` AS `npaType`, `npa_areas`.`name` AS `npaName`, `npa_types`.`name` AS `npaTypeName`
FROM `cache_npa_areas`
INNER JOIN `npa_areas` ON `cache_npa_areas`.`npa_id`=`npa_areas`.`id`
INNER JOIN `npa_types` ON `npa_areas`.`type_id`=`npa_types`.`id`
WHERE `cache_npa_areas`.`cache_id`='&1' AND `npa_types`.`no_warning`=0
GROUP BY `npa_areas`.`type_id`, `npa_areas`.`name`
ORDER BY `npa_types`.`ordinal` ASC",
$cacheid);
$tpl->assign_rs('npaareasWarning', $rs);
sql_free_result($rs);
$rs = sql("SELECT `npa_areas`.`id` AS `npaId`, `npa_areas`.`type_id` AS `npaType`, `npa_areas`.`name` AS `npaName`, `npa_types`.`name` AS `npaTypeName`
FROM `cache_npa_areas`
INNER JOIN `npa_areas` ON `cache_npa_areas`.`npa_id`=`npa_areas`.`id`
INNER JOIN `npa_types` ON `npa_areas`.`type_id`=`npa_types`.`id`
WHERE `cache_npa_areas`.`cache_id`='&1' AND `npa_types`.`no_warning`=1
GROUP BY `npa_areas`.`type_id`, `npa_areas`.`name`
ORDER BY `npa_types`.`ordinal` ASC",
$cacheid);
$tpl->assign_rs('npaareasNoWarning', $rs);
sql_free_result($rs);
/* attributes
*/
$tpl->assign('attributes', attribute::getAttrbutesListArrayByCacheId($cacheid));
/* geokrets
*/
$rsGeoKret = sql("SELECT `gk_item`.`id`, `gk_item`.`name` AS `itemname`, `gk_user`.`name` AS `username` FROM `gk_item` INNER JOIN `gk_item_waypoint` ON `gk_item`.`id`=`gk_item_waypoint`.`id` INNER JOIN `gk_user` ON `gk_item`.`userid`=`gk_user`.`id` INNER JOIN `caches` ON `gk_item_waypoint`.`wp`=`caches`.`wp_oc` WHERE `caches`.`cache_id`='&1' AND `gk_item`.`typeid`!=2 AND `gk_item`.`stateid` IN (0, 3) AND `gk_item_waypoint`.`wp`!='' UNION
SELECT `gk_item`.`id`, `gk_item`.`name` AS `itemname`, `gk_user`.`name` AS `username` FROM `gk_item` INNER JOIN `gk_item_waypoint` ON `gk_item`.`id`=`gk_item_waypoint`.`id` INNER JOIN `gk_user` ON `gk_item`.`userid`=`gk_user`.`id` INNER JOIN `caches` ON `gk_item_waypoint`.`wp`=`caches`.`wp_gc` WHERE `caches`.`cache_id`='&1' AND `gk_item`.`typeid`!=2 AND `gk_item`.`stateid` IN (0, 3) AND `gk_item_waypoint`.`wp`!='' UNION
SELECT `gk_item`.`id`, `gk_item`.`name` AS `itemname`, `gk_user`.`name` AS `username` FROM `gk_item` INNER JOIN `gk_item_waypoint` ON `gk_item`.`id`=`gk_item_waypoint`.`id` INNER JOIN `gk_user` ON `gk_item`.`userid`=`gk_user`.`id` INNER JOIN `caches` ON `gk_item_waypoint`.`wp`=`caches`.`wp_nc` WHERE `caches`.`cache_id`='&1' AND `gk_item`.`typeid`!=2 AND `gk_item`.`stateid` IN (0, 3) AND `gk_item_waypoint`.`wp`!='' ORDER BY `itemname`", $cacheid);
$tpl->assign_rs('geokret', $rsGeoKret);
$tpl->assign('geokret_count', sql_num_rows($rsGeoKret));
sql_free_result($rsGeoKret);
if(isset($_REQUEST['print']) && $_REQUEST['print'] == 'y')
{
$tpl->popup = 1;
$tpl->assign('print', true);
$tpl->name = 'viewcache_print';
$tpl->assign('log', $_REQUEST['log']);
}
/* process the cachmap options
*/
$userzoom = 11;
if ($login->userid > 0)
{
$useropt = new useroptions($login->userid);
$userzoom = $useropt->getOptValue(USR_OPT_GMZOOM);
}
$tpl->assign('userzoom', $userzoom);
// get the correct mapkey
$sHost = strtolower($_SERVER['HTTP_HOST']);
$sGMKey = '';
if (isset($opt['lib']['google']['mapkey'][$sHost]))
$sGMKey = $opt['lib']['google']['mapkey'][$sHost];
$cachemap['iframe'] = $opt['logic']['cachemaps']['iframe'];
$url = $opt['logic']['cachemaps']['url'];
$url = str_replace('{userzoom}', $userzoom, $url);
$url = str_replace('{latitude}', $rCache['latitude'], $url);
$url = str_replace('{longitude}', $rCache['longitude'], $url);
$url = str_replace('{gmkey}', $sGMKey, $url);
$cachemap['url'] = $url;
$tpl->assign('cachemap', $cachemap);
// display the page
$tpl->display();
<?php
/***************************************************************************
* For license information see doc/license.txt
*
* Unicode Reminder メモ
*
* TODO: use cache() class at all
***************************************************************************/
require('./lib2/web.inc.php');
require_once('./lib2/logic/labels.inc.php');
require_once('./lib2/logic/cache.class.php');
require_once('./lib2/logic/attribute.class.php');
require_once('./lib2/logic/coordinate.class.php');
require_once($opt['rootpath'] . 'lib2/logic/useroptions.class.php');
$login->verify();
function getChildWaypoints($cacheid)
{
$wphandler = new ChildWp_Handler();
$waypoints = $wphandler->getChildWps($cacheid);
$count = count($waypoints);
if ($count > 0)
{
$formatter = new Coordinate_Formatter();
for ($i = 0; $i < $count; $i++)
{
$waypoints[$i]['coordinateHtml'] = $formatter->formatHtml($waypoints[$i]['coordinate'], '<br />');
}
}
return $waypoints;
}
$tpl->name = 'viewcache';
$tpl->menuitem = MNU_CACHES_SEARCH_VIEWCACHE;
$tpl->assign('use_tooltiplib', true);
// get cacheid
$cacheid = 0;
if (isset($_REQUEST['cacheid']))
$cacheid = $_REQUEST['cacheid']+0;
else if (isset($_REQUEST['uuid']))
$cacheid = cache::cacheIdFromUUID($_REQUEST['uuid']);
else if (isset($_REQUEST['wp']))
$cacheid = cache::cacheIdFromWP($_REQUEST['wp']);
$cache = new cache($cacheid);
if ($cache->exist() == false)
$tpl->error(ERROR_CACHE_NOT_EXISTS);
if ($cache->allowView() == false)
$tpl->error(ERROR_NO_ACCESS);
if (isset($_REQUEST['visitcounter']) && $_REQUEST['visitcounter'] == 1)
{
cache::visitCounter($login->userid, $_SERVER["REMOTE_ADDR"], $cacheid);
exit;
}
$bCrypt = !isset($_REQUEST['nocrypt']) || ($_REQUEST['nocrypt'] != 1);
$tpl->assign('crypt', $bCrypt);
if (isset($_REQUEST['desclang']))
$sPreferedDescLang = $_REQUEST['desclang'] . ',' . $opt['template']['locale'] . ',EN';
else
$sPreferedDescLang = $opt['template']['locale'] . ',EN';
//$tpl->caching = true;
//$tpl->cache_lifetime = 31*24*60*60;
//$tpl->cache_id = $cacheid . '|' . $sPreferedDescLang;
if ($login->userid!=0)
{
$tpl->assign('ignored', sql_value("SELECT 1 FROM `cache_ignore` WHERE `cache_id`='&1' AND `user_id`='&2'", 0, $cacheid, $login->userid));
$tpl->assign('watched', sql_value("SELECT 1 FROM `cache_watches` WHERE `cache_id`='&1' AND `user_id`='&2'", 0, $cacheid, $login->userid));
}
//get cache record
$rs = sql("SELECT `caches`.`cache_id` AS `cacheid`,
`caches`.`user_id` AS `userid`,
`caches`.`status` AS `status`,
`caches`.`latitude` AS `latitude`,
`caches`.`longitude` AS `longitude`,
`caches`.`name` AS `name`,
`caches`.`type` AS `type`,
`caches`.`size` AS `size`,
`caches`.`search_time` AS `searchtime`,
`caches`.`way_length` AS `waylength`,
`caches`.`country` AS `countryCode`,
IFNULL(`ttCountry`.`text`, `countries`.`name`) AS `country`,
`caches`.`logpw` AS `logpw`,
`caches`.`date_hidden` AS `datehidden`,
`caches`.`wp_oc` AS `wpoc`,
`caches`.`wp_gc` AS `wpgc`,
`caches`.`wp_nc` AS `wpnc`,
`caches`.`date_created` AS `datecreated`,
`caches`.`is_publishdate` AS `is_publishdate`,
`caches`.`difficulty` AS `difficulty`,
`caches`.`terrain` AS `terrain`,
`cache_desc`.`language` AS `desclanguage`,
`cache_desc`.`short_desc` AS `shortdesc`,
`cache_desc`.`desc` AS `desc`,
`cache_desc`.`hint` AS `hint`,
`cache_desc`.`desc_html` AS `deschtml`,
`cache_status`.`allow_user_log`=1 OR `caches`.`user_id`='&4' AS `log_allowed`,
IFNULL(`stat_caches`.`found`, 0) AS `found`,
IFNULL(`stat_caches`.`notfound`, 0) AS `notfound`,
IFNULL(`stat_caches`.`note`, 0) AS `note`,
IFNULL(`stat_caches`.`will_attend`, 0) AS `willattend`,
IFNULL(`stat_caches`.`watch`, 0) AS `watcher`,
`caches`.`desc_languages` AS `desclanguages`,
IFNULL(`stat_caches`.`ignore`, 0) AS `ignorercount`,
IFNULL(`stat_caches`.`toprating`, 0) AS `topratings`,
IFNULL(`cache_visits`.`count`, 0) AS `visits`,
`user`.`username` AS `username`,
IFNULL(`cache_location`.`code1`, '') AS `code1`,
IFNULL(`cache_location`.`adm1`, '') AS `adm1`,
IFNULL(`cache_location`.`adm2`, '') AS `adm2`,
IFNULL(`cache_location`.`adm3`, '') AS `adm3`,
IFNULL(`cache_location`.`adm4`, '') AS `adm4`
FROM `caches`
INNER JOIN `user` ON `caches`.`user_id`=`user`.`user_id`
INNER JOIN `cache_desc` ON `caches`.`cache_id`=`cache_desc`.`cache_id` AND `cache_desc`.`language`=PREFERED_LANG(`caches`.`desc_languages`, '&3')
INNER JOIN `cache_status` ON `caches`.`status`=`cache_status`.`id`
LEFT JOIN `countries` ON `caches`.`country`=`countries`.`short`
LEFT JOIN `sys_trans` AS `tCountry` ON `countries`.`trans_id`=`tCountry`.`id` AND `countries`.`name`=`tCountry`.`text`
LEFT JOIN `sys_trans_text` AS `ttCountry` ON `tCountry`.`id`=`ttCountry`.`trans_id` AND `ttCountry`.`lang`='&2'
LEFT JOIN `cache_visits` ON `cache_visits`.`cache_id`=`caches`.`cache_id` AND `user_id_ip`='0'
LEFT JOIN `stat_caches` ON `caches`.`cache_id`=`stat_caches`.`cache_id`
LEFT JOIN `cache_location` ON `caches`.`cache_id` = `cache_location`.`cache_id`
WHERE `caches`.`cache_id`='&1'", $cacheid, $opt['template']['locale'], $sPreferedDescLang, $login->userid);
$rCache = sql_fetch_assoc($rs);
sql_free_result($rs);
if ($rCache === false)
$tpl->error(ERROR_CACHE_NOT_EXISTS);
// not published?
if ($rCache['status'] == 5)
{
$tpl->caching = false;
$login->verify();
if ($rCache['userid'] != $login->userid)
$tpl->error(ERROR_CACHE_NOT_PUBLISHED);
}
$rCache['lastmodified'] = sql_value("SELECT MAX(`last_modified`) `last_modified` FROM
(SELECT `last_modified` FROM `caches` WHERE `cache_id` ='&1'
UNION SELECT `last_modified` FROM `cache_desc` WHERE `cache_id` ='&1') `tmp_result`",
null, $cacheid);
$rCache['desclanguages'] = explode(',', $rCache['desclanguages']);
$rCache['sizeName'] = labels::getLabelValue('cache_size', $rCache['size']);
$rCache['statusName'] = labels::getLabelValue('cache_status', $rCache['status']);
$rCache['typeName'] = labels::getLabelValue('cache_type', $rCache['type']);
$rCache['userhasfound'] = false;
if ($login->userid != 0)
$rCache['userhasfound'] = (sql_value("SELECT COUNT(*) FROM `cache_logs` WHERE `cache_id`='&1' AND `user_id`='&2' AND `type` IN (1,7)", 0, $cacheid, $login->userid) > 0);
$tpl->assign('cache', $rCache);
$tpl->title = $rCache['wpoc'] . ' ' . $rCache['name'];
$coord = new coordinate($rCache['latitude'], $rCache['longitude']);
$tpl->assign('coordinates', $coord->getDecimalMinutes());
// pictures
$rs = sql("SELECT `id`, `uuid`, `url`, `title`, `thumb_url`, `spoiler`, `display` FROM `pictures` WHERE `object_type`=2 AND `object_id`='&1' AND `display`!=0 ORDER BY `date_created` ASC", $cacheid);
$tpl->assign_rs('pictures', $rs);
sql_free_result($rs);
$tpl->assign('childWaypoints', getChildWaypoints($cacheid));
if ($login->userid != 0)
{
$cacheNotePresenter = new CacheNote_Presenter(new Http_Request(), new Language_Translator());
$cacheNotePresenter->init(new CacheNote_Handler(), $login->userid, $cacheid);
if (isset($_POST['submit_cache_note']) && $cacheNotePresenter->validate())
{
$cacheNotePresenter->doSubmit();
}
$cacheNotePresenter->prepare($tpl);
}
$tpl->assign('enableCacheNote', $login->userid != 0);
/* Logentries */
/* begin insertion/change Uwe 20091215 for printing purposes
reworked on 20100106 for better performance after Olivers intervention
rewritten 2012-07-22 following for bugfix, first log was lost in print
*/
$rscount = 5;
if (isset($_REQUEST['log']))
switch ($_REQUEST['log'])
{
case 'N': $rscount = 0;
break;
case 'A': $rscount = current(cache::getLogsCount($cacheid));
break;
default: if ($_REQUEST['log'] > 0)
$rscount = $_REQUEST['log'] + 0;
}
$logs = cache::getLogsArray($cacheid, 0, $rscount+1);
if (isset($logs[$rscount]))
{
unset($logs[$rscount]);
$tpl->assign('showalllogs', true);
}
$loganz = sizeof($logs);
$tpl->assign('logs', $logs);
$tpl->assign('loganz', $loganz);
/*end insertion Uwe 20091215*/
/* nature protection areas
*/
$rs = sql("SELECT `npa_areas`.`id` AS `npaId`, `npa_areas`.`type_id` AS `npaType`, `npa_areas`.`name` AS `npaName`, `npa_types`.`name` AS `npaTypeName`
FROM `cache_npa_areas`
INNER JOIN `npa_areas` ON `cache_npa_areas`.`npa_id`=`npa_areas`.`id`
INNER JOIN `npa_types` ON `npa_areas`.`type_id`=`npa_types`.`id`
WHERE `cache_npa_areas`.`cache_id`='&1' AND `npa_types`.`no_warning`=0
GROUP BY `npa_areas`.`type_id`, `npa_areas`.`name`
ORDER BY `npa_types`.`ordinal` ASC",
$cacheid);
$tpl->assign_rs('npaareasWarning', $rs);
sql_free_result($rs);
$rs = sql("SELECT `npa_areas`.`id` AS `npaId`, `npa_areas`.`type_id` AS `npaType`, `npa_areas`.`name` AS `npaName`, `npa_types`.`name` AS `npaTypeName`
FROM `cache_npa_areas`
INNER JOIN `npa_areas` ON `cache_npa_areas`.`npa_id`=`npa_areas`.`id`
INNER JOIN `npa_types` ON `npa_areas`.`type_id`=`npa_types`.`id`
WHERE `cache_npa_areas`.`cache_id`='&1' AND `npa_types`.`no_warning`=1
GROUP BY `npa_areas`.`type_id`, `npa_areas`.`name`
ORDER BY `npa_types`.`ordinal` ASC",
$cacheid);
$tpl->assign_rs('npaareasNoWarning', $rs);
sql_free_result($rs);
/* attributes
*/
$tpl->assign('attributes', attribute::getAttrbutesListArrayByCacheId($cacheid));
/* geokrets
*/
$rsGeoKret = sql("SELECT `gk_item`.`id`, `gk_item`.`name` AS `itemname`, `gk_user`.`name` AS `username` FROM `gk_item` INNER JOIN `gk_item_waypoint` ON `gk_item`.`id`=`gk_item_waypoint`.`id` INNER JOIN `gk_user` ON `gk_item`.`userid`=`gk_user`.`id` INNER JOIN `caches` ON `gk_item_waypoint`.`wp`=`caches`.`wp_oc` WHERE `caches`.`cache_id`='&1' AND `gk_item`.`typeid`!=2 AND `gk_item`.`stateid` IN (0, 3) AND `gk_item_waypoint`.`wp`!='' UNION
SELECT `gk_item`.`id`, `gk_item`.`name` AS `itemname`, `gk_user`.`name` AS `username` FROM `gk_item` INNER JOIN `gk_item_waypoint` ON `gk_item`.`id`=`gk_item_waypoint`.`id` INNER JOIN `gk_user` ON `gk_item`.`userid`=`gk_user`.`id` INNER JOIN `caches` ON `gk_item_waypoint`.`wp`=`caches`.`wp_gc` WHERE `caches`.`cache_id`='&1' AND `gk_item`.`typeid`!=2 AND `gk_item`.`stateid` IN (0, 3) AND `gk_item_waypoint`.`wp`!='' UNION
SELECT `gk_item`.`id`, `gk_item`.`name` AS `itemname`, `gk_user`.`name` AS `username` FROM `gk_item` INNER JOIN `gk_item_waypoint` ON `gk_item`.`id`=`gk_item_waypoint`.`id` INNER JOIN `gk_user` ON `gk_item`.`userid`=`gk_user`.`id` INNER JOIN `caches` ON `gk_item_waypoint`.`wp`=`caches`.`wp_nc` WHERE `caches`.`cache_id`='&1' AND `gk_item`.`typeid`!=2 AND `gk_item`.`stateid` IN (0, 3) AND `gk_item_waypoint`.`wp`!='' ORDER BY `itemname`", $cacheid);
$tpl->assign_rs('geokret', $rsGeoKret);
$tpl->assign('geokret_count', sql_num_rows($rsGeoKret));
sql_free_result($rsGeoKret);
if(isset($_REQUEST['print']) && $_REQUEST['print'] == 'y')
{
$tpl->popup = 1;
$tpl->assign('print', true);
$tpl->name = 'viewcache_print';
$tpl->assign('log', $_REQUEST['log']);
}
/* process the cachmap options
*/
$userzoom = 11;
if ($login->userid > 0)
{
$useropt = new useroptions($login->userid);
$userzoom = $useropt->getOptValue(USR_OPT_GMZOOM);
}
$tpl->assign('userzoom', $userzoom);
// get the correct mapkey
$sHost = strtolower($_SERVER['HTTP_HOST']);
$sGMKey = '';
if (isset($opt['lib']['google']['mapkey'][$sHost]))
$sGMKey = $opt['lib']['google']['mapkey'][$sHost];
$cachemap['iframe'] = $opt['logic']['cachemaps']['iframe'];
$url = $opt['logic']['cachemaps']['url'];
$url = str_replace('{userzoom}', $userzoom, $url);
$url = str_replace('{latitude}', $rCache['latitude'], $url);
$url = str_replace('{longitude}', $rCache['longitude'], $url);
$url = str_replace('{gmkey}', $sGMKey, $url);
$cachemap['url'] = $url;
$tpl->assign('cachemap', $cachemap);
// display the page
$tpl->display();
?>