140 Commits

Author SHA1 Message Date
dc995501bd Merge remote-tracking branch 'upstream/master' into code-upgrade 2015-05-31 22:45:13 +02:00
2ff320965e Merge pull request #176 from Bananeweizen/patch-1
fix typos
2015-05-31 16:21:25 +02:00
4e0dd29277 fix typos 2015-05-31 08:44:39 +02:00
dff6f495a3 Smarty is now on GitHub. Updated composer.json. 2015-05-31 00:53:07 +02:00
f6550ba3f7 Fix broken merge. 2015-05-31 00:18:32 +02:00
1ec05ba62d Merge remote-tracking branch 'upstream/master' into code-upgrade 2015-05-31 00:00:26 +02:00
f3ae08230c added English changelog for v3.0.12 2015-05-30 12:29:05 +02:00
0c2440391d set wayoint input fields to upper case; updates #334 2015-05-30 12:07:35 +02:00
e10164f55b Merge remote-tracking branch 'upstream/master' into code-upgrade 2015-05-29 23:32:11 +02:00
8de3d2d6ac changelog update 2015-05-28 16:36:59 +02:00
f1f4d1f616 changlog update 2015-05-28 16:16:52 +02:00
9384124daf added German v3.0.12 changelog 2015-05-28 16:04:58 +02:00
6e4cbc6576 fixed send-email-address default option; updates #333 2015-05-28 15:30:46 +02:00
62b6a3c4e2 Merge pull request #174 from 4Vs/patch-8
NO REV REQ: Warnung eingefügt bzgl. HTML tags
2015-05-28 12:05:35 +02:00
139c5da4d9 Merge pull request #173 from 4Vs/patch-7
NO REV REQ: Warnung wegen falscher Angaben eingefügt
2015-05-28 12:05:08 +02:00
4Vs
132e12378e Warnung eingefügt bzgl. HTML tags 2015-05-28 11:48:38 +02:00
4Vs
927f44a360 Warnung wegen falscher Angaben eingefügt 2015-05-28 11:46:00 +02:00
fa0f3c73d6 Merge pull request #172 from 4Vs/master
Sry, nochmal Links aktualisiert :)
2015-05-28 01:12:07 +02:00
9dea9e0ab8 Merge branch '240-removed-logs-info' 2015-05-28 01:08:58 +02:00
6fd3c3ddf6 added log date and type to remove-log notification email; updates #240 2015-05-28 01:08:38 +02:00
84e027369e merged branch 334-gc-waypoints 2015-05-28 01:05:23 +02:00
e3af6ec2ee validate GC waypoints; added explanations for waypoints; updates #334 2015-05-28 01:01:33 +02:00
e5236141de Merge branch '169-save-note' 2015-05-28 00:55:59 +02:00
1321fe6566 better handling of bad personal-note-coordinate input; updates #169 2015-05-28 00:54:44 +02:00
208fb008a2 added waypoint link to 'duplicate cache' error message 2015-05-28 00:50:37 +02:00
0a011ddeed merged 76-duplicate-listings branch 2015-05-28 00:32:57 +02:00
31bca18727 merged "more events" branch; resolved merge conflict 2015-05-27 23:54:29 +02:00
e32f482f66 added 'more events' link on start page; update #208 2015-05-27 23:50:27 +02:00
08aaff331b Merge pull request #166 from following5/703-fix-language-switch
added workaround for bad REQUEST_URIs; updates #166
2015-05-27 23:49:53 +02:00
94a3603328 added workaround for bad REQUEST_URIs; updates #703 2015-05-27 23:48:34 +02:00
b89232ee56 Merge branch '710-w3w-mapsearch' 2015-05-27 23:46:29 +02:00
0a02baaae3 narrowed w3w mapsearch regex; updates #710 2015-05-27 23:46:07 +02:00
1542643b7a Merge pull request #164 from following5/333-send-email-address-default
added profile setting for default of 'send my e-mail address'; updates #333
2015-05-27 23:44:49 +02:00
8fe2d4e0c2 added profile setting for default of 'send my e-mail address', updates #333 2015-05-27 23:43:17 +02:00
f984a452dd Merge pull request #163 from following5/365-usermail-address
fixed sender email address in usercontactmail template; updates #365
2015-05-27 23:42:46 +02:00
3c19e9137a fixed sender email address in usercontactmail template; updates #365 2015-05-27 23:41:45 +02:00
d5272d1e66 Merge pull request #162 from following5/704-default-logdate
added expiration time for default log date cookie; updates #704
2015-05-27 23:38:54 +02:00
96fd24d761 added expiration time for default log date cookie; updates #704 2015-05-27 23:37:49 +02:00
5cc74499c4 Merge pull request #161 from following5/368-archive-events
enabled auto-archiving of disabled event caches
2015-05-27 23:32:37 +02:00
df2ccd2448 enabled auto-archiving of disabled event caches, update #386 2015-05-27 23:31:23 +02:00
4Vs
b5fb2e8bf0 NO REVIEW REQUIRED: Linkanpassung und Target -> blank 2015-05-27 08:49:29 +02:00
4Vs
b406e261cd NO REVIEW REQUIRED: Linkanpassung und Target -> blank 2015-05-27 08:47:30 +02:00
73afab7840 Merge branch 'stable' 2015-05-26 20:41:45 +02:00
3529cc5865 added disable option and another error check for what3words api 2015-05-26 20:32:00 +02:00
5604b2b176 update #76: catch new caches with duplicate coordinates 2015-05-25 15:20:36 +02:00
1df52c4914 team list update 2015-05-25 11:53:25 +02:00
a2e5271349 updated teamlist
This reverts commit c6e084f590.
2015-05-25 11:51:07 +02:00
40511db4ab added what3words coordinat search to map 2015-05-24 22:42:18 +02:00
89d4645e17 OKAPI update, revision 1075 2015-05-22 14:55:37 +02:00
891d2349bd Merge pull request #160 from following5/license-update
added license info for garmin api
2015-05-21 14:11:10 +02:00
14aac6eb77 Merge pull request #159 from following5/w3w-windowsize
increased 'other coordinate systems' window and enabled scrollbars, for W3W coords
2015-05-21 14:10:51 +02:00
ea0191b808 Merge pull request #158 from 4Vs/master
Broken Links gefixt für Satzung und Beitritt
2015-05-21 14:10:09 +02:00
526226ae3b Merge pull request #157 from 4Vs/patch-6
Änderung Kassenwart
2015-05-21 14:09:32 +02:00
c793315702 Merge pull request #156 from 4Vs/patch-5
Kassenwart im Team geändert
2015-05-21 14:09:12 +02:00
d06dbb6f79 improved w3w error handling 2015-05-21 12:04:28 +02:00
63d66b2611 added license info for garmin api 2015-05-21 00:55:26 +02:00
0b8c3f0c4d increased 'other coordinate systems' window to accomodate for new W3W links, and enabled automatic scrollbars 2015-05-20 22:41:06 +02:00
4Vs
03d6a3737f Links zur Satzung und zum Beitrittsformular geändert 2015-05-20 09:53:48 +02:00
4Vs
783c3a2f71 Link zur Satzung und Beitrittsformular geändert 2015-05-20 09:52:38 +02:00
4Vs
da4e7673cb Änderung Kassenwart 2015-05-17 23:51:29 +02:00
4Vs
2f4b5d328a Kassenwart im Team geändert 2015-05-17 23:50:03 +02:00
d7544a0321 Put constants into RowEditor class. 2015-02-13 00:32:24 +01:00
ea3179d144 Removed redundant code from RowEditor. 2015-02-13 00:00:15 +01:00
f069afe5d4 Converted class RowEditor into PSR4. 2015-02-12 23:27:23 +01:00
fe550657b4 Froze Symfony versions. Updated Smarty to latest 2.x branch. 2015-01-26 15:20:22 +01:00
87a0c48b45 Enlarged coordinates popup to accomodate what3words entries. 2015-01-22 01:12:07 +01:00
7379bf60b5 Merge remote-tracking branch 'upstream/master' into code-upgrade
Conflicts:
	htdocs/coordinates.php
	htdocs/lib2/logic/coordinate.class.php
2015-01-22 01:11:18 +01:00
5c81dd4d01 Merge pull request #155 from mbirth/add-what3words-coordinate-output
Add what3words coordinate output
2015-01-21 21:13:51 +01:00
7655f53d7c Typo fix. 2015-01-20 23:58:36 +01:00
aa0bf49cb2 Moved what3words API Key to settings.inc.php. Added links. 2015-01-20 23:41:47 +01:00
905e5783e1 Merge pull request #154 from mbirth/add-what3words-coordinate-output
Added what3words.com support in coordinates output
2015-01-19 20:23:23 +01:00
ad039dd69b Added what3words.com support in coordinates output. API key was
registered for Opencaching.de.
2015-01-12 01:55:36 +01:00
ec2f4640f8 Merge remote-tracking branch 'upstream/master' into code-upgrade 2015-01-11 22:07:28 +01:00
5dcd9edf6d Merge pull request #153 from 4Vs/patch-4
Change of treasurer
2014-11-28 12:10:05 +01:00
2ee0326328 Merge pull request #152 from 4Vs/patch-3
Änderung des Kassenwartes
2014-11-28 12:09:39 +01:00
4Vs
103a375893 Change of treasurer 2014-11-26 13:12:21 +01:00
4Vs
97609e814b Änderung des Kassenwartes 2014-11-26 13:10:18 +01:00
4eaf502091 Merge remote-tracking branch 'upstream/master' into code-upgrade 2014-11-25 12:13:08 +01:00
8f3797f2ac Changed menu to use split-up translate.inc instead of .class. 2014-11-22 20:18:38 +01:00
85ebe576c2 Indentation. 2014-11-22 15:07:20 +01:00
756b429efc Updated packages. 2014-11-22 15:00:54 +01:00
826966ba40 Merge remote-tracking branch 'upstream/master' into code-upgrade 2014-11-22 14:28:43 +01:00
859df34de6 Rewrote Cookie handling to new Global Class. 2014-09-23 13:39:47 +02:00
ca5bb8be8d Updated Composer packages. 2014-09-23 13:39:35 +02:00
c43b308be0 Merge remote-tracking branch 'upstream/master' into code-upgrade 2014-09-18 23:01:50 +02:00
6194bed59e Merge remote-tracking branch 'upstream/master' into code-upgrade
Conflicts:
	htdocs/lib2/logic/picture.class.php
	htdocs/newevents.php
	htdocs/picture.php
	htdocs/viewlogs.php
2014-04-28 00:15:58 +02:00
324dc5ec79 Fixed/beautified code. 2014-03-07 00:49:53 +01:00
a1d00393d6 Made pager.class.php PSR4. 2014-03-06 22:17:48 +01:00
98d773db4c Made mail.class.php PSR4. 2014-03-06 22:17:12 +01:00
7de378fee0 Removed obsolete rss.class.php. 2014-03-06 22:15:29 +01:00
d49616a74a Updated Composer packages. 2014-03-06 21:00:57 +01:00
a4f9c75cd6 RSSParser to PSR4. 2014-03-06 20:59:52 +01:00
bfb918e697 Integrated constants into class. PSR-2. 2014-02-16 00:11:18 +01:00
48601832f8 Merge remote-tracking branch 'upstream/master' into code-upgrade 2014-02-07 22:40:25 +01:00
c769f2c6fe Merge remote-tracking branch 'upstream/master' into code-upgrade 2014-02-06 19:46:57 +01:00
d2a1979e98 More Tabs to Spaces. NO CODE CHANGE. 2014-01-24 01:44:31 +01:00
2573424763 libse Tabs to Spaces. NO CODE CHANGES. 2014-01-24 01:40:18 +01:00
f0fdf92d7a lib2 Tabs to Spaces. NO CODE CHANGES. 2014-01-24 01:38:21 +01:00
5050c43a3a Tabs to Spaces. NO CODE CHANGE. 2014-01-24 01:31:04 +01:00
1d34a14faa Removed duplicate Cbench class. Removed eventhandler.inc.php in favor of statpic class. 2014-01-24 01:24:21 +01:00
4d278f33b7 Logging for thumbs.php. 2014-01-24 00:53:44 +01:00
24857d0d64 Remove calculation.inc.php include. 2014-01-24 00:53:29 +01:00
456259185a Use geomath class instead of lib1 include. 2014-01-24 00:52:37 +01:00
40952683d2 More info in config.yml, remove global $config from core.php. 2014-01-24 00:51:58 +01:00
53596abf61 Replaced $opt['rootpath'] by ocde.config service. Tabs to Spaces. 2014-01-23 01:17:24 +01:00
2a2ee05ba4 Removed ununsed cachedesc.class.php (class user). 2014-01-23 01:17:04 +01:00
0002c05915 Moved ss_zip to new structure as SsZip. Should be replaced by native ZipArchive methods later. 2014-01-19 22:27:01 +01:00
b00b14ce10 Fixed Syntax Error in search.php. Cleanup. 2014-01-19 14:12:07 +01:00
a7be1288ee Replaced last occurrences of $login by new Login service. 2014-01-19 03:35:44 +01:00
907f4835a8 Replaced $login by new Login service for rest of main PHP files. 2014-01-19 03:21:21 +01:00
41a027417d Switched various files to new Login service. 2014-01-19 03:11:59 +01:00
9954387e90 Removed redundant lib2/cookie.inc.php, changed all uses to new Cookie service. Except lib1 - should be phased out anyway. 2014-01-19 02:48:49 +01:00
0a727eecfa Fixed Login for login.php and myhome.php. 2014-01-19 02:33:51 +01:00
ba296ed691 Moved Crypt class. 2014-01-19 02:32:39 +01:00
fca7b1918e Removed redundant classes. THIS BREAKS LOGIN. WILL BE FIXED IN NEXT COMMITS. 2014-01-19 02:31:51 +01:00
b015efa99a Added LoggingInterface for switching between loggers. Refactored Login and Cookie classes. 2014-01-19 02:29:57 +01:00
6a487c218d Removed loading login.class.php from lib2/common.inc.php. So no $login variable is propagated anymore (for lib2).
Fixed all calls in index.php and included files. DID NOT YET FIX OTHER PAGES! THEY WILL BREAK!
N.B.: Instead of $login->..., you now have to do $GLOBALS['container']->get('ocde.login')->...
2014-01-18 23:50:39 +01:00
e811723d71 Removed RFC822-method from common.inc.php and util.inc.php. It's now loaded via Composer. 2014-01-17 22:07:41 +01:00
327a46a777 Added custom Composer package for iamcal/rfc822 (formerly RFC(2)822 Email Parser). Not yet used. 2014-01-16 02:13:48 +01:00
5fe40d0d62 Prepared Login and Cookie services. 2014-01-16 01:45:16 +01:00
5af15744c2 Replaced static html2text class by Composer package. Replaced some more $rootpaths by our Config class. 2014-01-16 01:05:49 +01:00
15f91e2ffc Removed obsolete HTMLPurifier from Repo. 2014-01-16 00:36:35 +01:00
203ffe8846 Removed remaining references to old HTMLPurifier. 2014-01-15 02:47:03 +01:00
eeb1e659d3 Renamed login and cookie classes in lib2 to login2 and cookie2. Updated autoloader. More autoloading optimizations. 2014-01-14 01:33:46 +01:00
c2e063dd7b Started phasing out $opt['rootpath']. Replaced by Config class. Also optimized some class files (cookie, template). Minor changes. 2014-01-14 01:10:43 +01:00
658730c846 Added YamlConfigLoader and Config service for global configuration. 2014-01-13 02:21:39 +01:00
42a96aa6a0 Added Console-Logger. Load different services config for CLI or Web. 2014-01-12 17:17:03 +01:00
753997ea55 Added Dependency Injection (DI) method from Symfony framework. Added ChromePhp logger and some dummy loggers. These signature is somewhat compatible to Monolog which Symfony uses. Added Config service skeleton - to be used via DI.
Signed-off-by: Markus Birth <mbirth@gmail.com>
2014-01-12 05:37:30 +01:00
d8dfe69821 Use core.php to load Autoloader and initialise everything.
Signed-off-by: Markus Birth <mbirth@gmail.com>
2014-01-12 05:37:24 +01:00
1c26ec4db0 Fixed file permissions.
Signed-off-by: Markus Birth <mbirth@gmail.com>
2014-01-12 05:37:20 +01:00
8f779cb357 Renamed root namespace to "OpencachingDE".
Signed-off-by: Markus Birth <mbirth@gmail.com>
2014-01-12 05:37:13 +01:00
498c8903fc Removed comments from locale JSON. Added error logging (/tmp/ocde.log) to locale parser.
Signed-off-by: Markus Birth <mbirth@gmail.com>
2014-01-12 05:37:07 +01:00
8331395431 Switched PSR-0 to PSR-4 (our new code is already PSR-4 compatible) in Composer.
Run ./composer.phar dumpautoload after pull!

Signed-off-by: Markus Birth <mbirth@gmail.com>
2014-01-12 05:37:00 +01:00
ed0f99ddaf Separated locale settings into one file per locale. Backwards compatible!
Signed-off-by: Markus Birth <mbirth@gmail.com>
2014-01-12 05:36:54 +01:00
396d0f5f30 Consolidated coordinate calculation methods into Conversions namespace.
Signed-off-by: Markus Birth <mbirth@gmail.com>
2014-01-12 05:36:43 +01:00
1c302e373c Tabs to spaces (no code change).
Signed-off-by: Markus Birth <mbirth@gmail.com>
2014-01-12 05:36:17 +01:00
9b135f9881 Changed PSR-0-path to lib/, added OKAPI SVN for checkout.
Signed-off-by: Markus Birth <mbirth@gmail.com>
2014-01-12 05:36:12 +01:00
a7dfbd510b Missed some autoload-code in old lib. Replaced by composer autoloader.
Signed-off-by: Markus Birth <mbirth@gmail.com>
2014-01-12 05:36:06 +01:00
d1cc408c11 Fixed ocde label in composer.json.
Signed-off-by: Markus Birth <mbirth@gmail.com>
2014-01-12 05:35:52 +01:00
f8a58c18a3 Added Composer to manage autoloads and HTMLPurifier and Smarty.
Install by doing (from htdocs):
$ curl -sS https://getcomposer.org/installer | php
$ ./composer.phar install

If you want to update autoloader:
$ ./composer.phar dumpautoload

Signed-off-by: Markus Birth <mbirth@gmail.com>
2014-01-12 05:35:35 +01:00
1540 changed files with 32450 additions and 132167 deletions

4
.gitignore vendored
View File

@ -20,6 +20,10 @@
/htdocs/util/mysql_root/.htaccess
/htdocs/util/search_index/.htaccess
# external libs (to be installed by Composer)
/htdocs/composer.phar
/htdocs/vendor/*
# other data
/htdocs/cache/*
/htdocs/cache2/*

View File

@ -365,6 +365,14 @@
}
}
function dbv_122() // add user profile flag for default setting of send-my-email option
{
if (!sql_field_exists('user','usermail_send_addr'))
{
sql("ALTER TABLE `user` ADD COLUMN `usermail_send_addr` tinyint(1) NOT NULL default '0' AFTER `accept_mailing`");
}
}
// When adding new mutations, take care that they behave well if run multiple
// times. This improves robustness of database versioning.

View File

@ -156,6 +156,11 @@ JavaScript libraries
Path : htdocs/resource2/tinymce/
URI : http://tinymce.moxiecode.com/
License : LGPL 2.1
6. Garmin Communicator Plugin API
Path : htdocs/resource2/ocstyle/js/communicator-api/
URI : http://www.garmindeveloper.com/web-device/garmin-communicator-plugin/
License : Apache 2.0
Icons

View File

@ -5,85 +5,85 @@
* Unicode Reminder メモ
***************************************************************************/
require('lib2/web.inc.php');
require('lib2/logic/logpics.inc.php');
require('lib2/web.inc.php');
require('lib2/logic/logpics.inc.php');
$sUserCountry = $login->getUserCountry();
$sUserCountry = $GLOBALS['container']->get('ocde.login')->getUserCountry();
// create object for "newest" information
$getNew = new getNew($sUserCountry);
// create object for "newest" information
$getNew = new getNew($sUserCountry);
$tpl->main_template = 'sys_oc404';
$tpl->name = 'sys_oc404';
$tpl->main_template = 'sys_oc404';
$tpl->name = 'sys_oc404';
$tpl->caching = true;
$tpl->cache_lifetime = 300;
$tpl->cache_id = $sUserCountry;
// test for redirection to this page
$isRedirect404 = isset($_SERVER['REDIRECT_URL']);
$tpl->assign('isRedirect404', $isRedirect404);
$tpl->caching = true;
$tpl->cache_lifetime = 300;
$tpl->cache_id = $sUserCountry;
// test for redirection to this page
$isRedirect404 = isset($_SERVER['REDIRECT_URL']);
$tpl->assign('isRedirect404', $isRedirect404);
// determine website url, if is 404 redirection
if ($isRedirect404)
{
// check length
$uril = 70;
$uri = 'http://'.strtolower($_SERVER['SERVER_NAME']).$_SERVER['REQUEST_URI'];
// limit to $uril
if (strlen($uri) > $uril) {
$uri = substr($uri,0,$uril-3).'...';
}
// assign uri
$tpl->assign('website',$uri);
}
else
$tpl->assign('website','');
// set feeds and options
$feeds = array('blog', 'forum', 'wiki');
$options = $feeds;
array_push($options, 'newcaches');
// simplify $opt
foreach ($options as $option)
{
if (isset($opt['page']['404'][$_SERVER['SERVER_NAME']][$option]))
$opt404[$option] = $opt['page']['404'][$_SERVER['SERVER_NAME']][$option];
else
$opt404[$option] = $opt['page']['404']['www.opencaching.de'][$option];
if ($opt404[$option]['urlname'] == '')
$opt404[$option]['urlname'] = parse_url($opt404[$option]['url'], PHP_URL_HOST);
}
// get feeds from $feeds array
foreach ($feeds as $feed)
{
if ($isRedirect404)
{
if ($opt404[$feed]['show'])
$tpl->assign($feed, $getNew->feedForSmarty($feed,3,$opt404[$feed]['feedurl']));
}
else
$tpl->assign($feed, $getNew->feedForSmarty($feed,3));
}
// get newest caches
if ($isRedirect404)
{
if ($opt404['newcaches']['show'])
$tpl->assign_rs('newcaches', $getNew->rsForSmarty('cache',array($sUserCountry, $opt['template']['locale'],3)));
}
else
$tpl->assign_rs('newcaches', $getNew->rsForSmarty('cache',array($sUserCountry, $opt['template']['locale'],3)));
// determine website url, if is 404 redirection
if ($isRedirect404)
{
// check length
$uril = 70;
$uri = 'http://'.strtolower($_SERVER['SERVER_NAME']).$_SERVER['REQUEST_URI'];
// limit to $uril
if (strlen($uri) > $uril) {
$uri = substr($uri,0,$uril-3).'...';
}
// assign uri
$tpl->assign('website',$uri);
}
else
$tpl->assign('website','');
// set feeds and options
$feeds = array('blog', 'forum', 'wiki');
$options = $feeds;
array_push($options, 'newcaches');
// simplify $opt
foreach ($options as $option)
{
if (isset($opt['page']['404'][$_SERVER['SERVER_NAME']][$option]))
$opt404[$option] = $opt['page']['404'][$_SERVER['SERVER_NAME']][$option];
else
$opt404[$option] = $opt['page']['404']['www.opencaching.de'][$option];
if ($opt404[$option]['urlname'] == '')
$opt404[$option]['urlname'] = parse_url($opt404[$option]['url'], PHP_URL_HOST);
}
// get feeds from $feeds array
foreach ($feeds as $feed)
{
if ($isRedirect404)
{
if ($opt404[$feed]['show'])
$tpl->assign($feed, $getNew->feedForSmarty($feed,3,$opt404[$feed]['feedurl']));
}
else
$tpl->assign($feed, $getNew->feedForSmarty($feed,3));
}
// get newest caches
if ($isRedirect404)
{
if ($opt404['newcaches']['show'])
$tpl->assign_rs('newcaches', $getNew->rsForSmarty('cache',array($sUserCountry, $opt['template']['locale'],3)));
}
else
$tpl->assign_rs('newcaches', $getNew->rsForSmarty('cache',array($sUserCountry, $opt['template']['locale'],3)));
// assign $opt404
$tpl->assign('opt404', $opt404);
// assign contact
$tpl->assign('contact', $opt['mail']['contact']);
// assign $opt404
$tpl->assign('opt404', $opt404);
// assign contact
$tpl->assign('contact', $opt['mail']['contact']);
// show page
$tpl->display();
// show page
$tpl->display();
?>

View File

@ -7,6 +7,6 @@
* Activation page shortcut to keep URLs in activation Emails short
***************************************************************************/
require "activation.php";
require "activation.php";
?>

View File

@ -5,59 +5,59 @@
* Unicode Reminder メモ
***************************************************************************/
$disable_verifyemail = true;
require('./lib2/web.inc.php');
$disable_verifyemail = true;
require('./lib2/web.inc.php');
$tpl->name = 'activation';
$tpl->menuitem = MNU_START_REGISTER_ACTIVATION;
$tpl->name = 'activation';
$tpl->menuitem = MNU_START_REGISTER_ACTIVATION;
// We use short param codes 'u' and 'c' to generate short-enough activation
// url that will not be wrapped in plain-text emails.
// We use short param codes 'u' and 'c' to generate short-enough activation
// url that will not be wrapped in plain-text emails.
$code = isset($_REQUEST['code']) ? trim($_REQUEST['code']) :
(isset($_REQUEST['c']) ? trim($_REQUEST['c']) : '');
$email = isset($_REQUEST['email']) ? trim($_REQUEST['email']) :
(isset($_REQUEST['e']) ? trim($_REQUEST['e']) : '');
$code = isset($_REQUEST['code']) ? trim($_REQUEST['code']) :
(isset($_REQUEST['c']) ? trim($_REQUEST['c']) : '');
$email = isset($_REQUEST['email']) ? trim($_REQUEST['email']) :
(isset($_REQUEST['e']) ? trim($_REQUEST['e']) : '');
$tpl->assign('errorEMail', false);
$tpl->assign('errorCode', false);
$tpl->assign('errorAlreadyActivated', false);
$tpl->assign('sucess', false);
$tpl->assign('errorEMail', false);
$tpl->assign('errorCode', false);
$tpl->assign('errorAlreadyActivated', false);
$tpl->assign('sucess', false);
if (isset($_REQUEST['submit']) || ($code != '' && $email != ''))
{
$email_not_ok = is_valid_email_address($email) ? false : true;
if (isset($_REQUEST['submit']) || ($code != '' && $email != ''))
{
$email_not_ok = is_valid_email_address($email) ? false : true;
if ($email_not_ok == false)
{
$rs = sql("SELECT `user_id` `id`, `activation_code` `code` FROM `user` WHERE `email`='&1'", $email);
if ($email_not_ok == false)
{
$rs = sql("SELECT `user_id` `id`, `activation_code` `code` FROM `user` WHERE `email`='&1'", $email);
if ($r = sql_fetch_array($rs))
{
if (($r['code'] == $code) && ($code != ''))
{
// ok, account aktivieren
sql("UPDATE `user` SET `is_active_flag`=1, `activation_code`='' WHERE `user_id`='&1'", $r['id']);
$tpl->assign('sucess', true);
}
else
{
if ($r['code'] == '')
$tpl->assign('errorAlreadyActivated', true);
else
$tpl->assign('errorCode', true);
}
}
else
$tpl->assign('errorCode', true);
sql_free_result($rs);
}
else
$tpl->assign('errorEMail', true);
}
if ($r = sql_fetch_array($rs))
{
if (($r['code'] == $code) && ($code != ''))
{
// ok, account aktivieren
sql("UPDATE `user` SET `is_active_flag`=1, `activation_code`='' WHERE `user_id`='&1'", $r['id']);
$tpl->assign('sucess', true);
}
else
{
if ($r['code'] == '')
$tpl->assign('errorAlreadyActivated', true);
else
$tpl->assign('errorCode', true);
}
}
else
$tpl->assign('errorCode', true);
sql_free_result($rs);
}
else
$tpl->assign('errorEMail', true);
}
$tpl->assign('email', $email);
$tpl->assign('code', $code);
$tpl->assign('email', $email);
$tpl->assign('code', $code);
$tpl->display();
$tpl->display();
?>

View File

@ -5,37 +5,37 @@
* Unicode Reminder メモ
***************************************************************************/
require('./lib2/web.inc.php');
require_once('./lib2/logic/cache.class.php');
require('./lib2/web.inc.php');
require_once('./lib2/logic/cache.class.php');
$tpl->name = 'adminhistory';
$tpl->menuitem = MNU_ADMIN_HISTORY;
$tpl->name = 'adminhistory';
$tpl->menuitem = MNU_ADMIN_HISTORY;
$login->verify();
if ($login->userid == 0)
$tpl->redirect_login();
$GLOBALS['container']->get('ocde.login')->verify();
if ($GLOBALS['container']->get('ocde.login')->getUserId() == 0)
$tpl->redirect_login();
if (($login->admin & ADMIN_USER) != ADMIN_USER)
$tpl->error(ERROR_NO_ACCESS);
if (($GLOBALS['container']->get('ocde.login')->isAdmin() & ADMIN_USER) != ADMIN_USER)
$tpl->error(ERROR_NO_ACCESS);
if (isset($_REQUEST['wp']))
$cache_id = sql_value("SELECT `cache_id` FROM `caches` WHERE `wp_oc`='&1'", 0, $_REQUEST['wp']);
else
$cache_id = isset($_REQUEST['cacheid']) ? $_REQUEST['cacheid']+0 : -1;
if (isset($_REQUEST['wp']))
$cache_id = sql_value("SELECT `cache_id` FROM `caches` WHERE `wp_oc`='&1'", 0, $_REQUEST['wp']);
else
$cache_id = isset($_REQUEST['cacheid']) ? $_REQUEST['cacheid']+0 : -1;
$showhistory = false;
$error = '';
$showhistory = false;
$error = '';
if ($cache_id>=0 && sql_value("SELECT COUNT(*) FROM `caches` WHERE `cache_id`='&1'", 0, $cache_id) <> 1)
$error = $translate->t('Cache not found', '', '', 0);
else if ($cache_id > 0)
{
$showhistory = true;
$cache = new Cache($cache_id);
$cache->setTplHistoryData(0);
}
if ($cache_id>=0 && sql_value("SELECT COUNT(*) FROM `caches` WHERE `cache_id`='&1'", 0, $cache_id) <> 1)
$error = $translate->t('Cache not found', '', '', 0);
else if ($cache_id > 0)
{
$showhistory = true;
$cache = new Cache($cache_id);
$cache->setTplHistoryData(0);
}
$tpl->assign('showhistory', $showhistory);
$tpl->assign('error', $error);
$tpl->display();
$tpl->assign('showhistory', $showhistory);
$tpl->assign('error', $error);
$tpl->display();
?>

View File

@ -5,166 +5,166 @@
* Unicode Reminder メモ
***************************************************************************/
require('./lib2/web.inc.php');
require_once('./lib2/logic/cache.class.php');
require('./lib2/web.inc.php');
require_once('./lib2/logic/cache.class.php');
$tpl->name = 'adminreports';
$tpl->menuitem = MNU_ADMIN_REPORTS;
$tpl->name = 'adminreports';
$tpl->menuitem = MNU_ADMIN_REPORTS;
$error = 0;
$error = 0;
$login->verify();
if ($login->userid == 0)
$tpl->redirect_login();
$GLOBALS['container']->get('ocde.login')->verify();
if ($GLOBALS['container']->get('ocde.login')->getUserId() == 0)
$tpl->redirect_login();
if (($login->admin & ADMIN_USER) != ADMIN_USER)
$tpl->error(ERROR_NO_ACCESS);
if (($GLOBALS['container']->get('ocde.login')->isAdmin() & ADMIN_USER) != ADMIN_USER)
$tpl->error(ERROR_NO_ACCESS);
$id = isset($_REQUEST['id']) ? $_REQUEST['id']+0 : 0;
$id = isset($_REQUEST['id']) ? $_REQUEST['id']+0 : 0;
$rid = isset($_REQUEST['rid']) ? $_REQUEST['rid']+0 : 0;
$cacheid = isset($_REQUEST['cacheid']) ? $_REQUEST['cacheid']+0 : 0;
$ownerid = isset($_REQUEST['ownerid']) ? $_REQUEST['ownerid']+0 : 0;
$reporterid =sql_value("SELECT `userid` FROM `cache_reports` WHERE `id`=&1", 0, $rid);
$adminid = sql_value("SELECT `adminid` FROM `cache_reports` WHERE `id`=&1", 0, $rid);
$age = sql_value("SELECT DATEDIFF(NOW(),`lastmodified`) FROM `cache_reports` WHERE `id`=&1", 0, $rid);
$rid = isset($_REQUEST['rid']) ? $_REQUEST['rid']+0 : 0;
$cacheid = isset($_REQUEST['cacheid']) ? $_REQUEST['cacheid']+0 : 0;
$ownerid = isset($_REQUEST['ownerid']) ? $_REQUEST['ownerid']+0 : 0;
$reporterid =sql_value("SELECT `userid` FROM `cache_reports` WHERE `id`=&1", 0, $rid);
$adminid = sql_value("SELECT `adminid` FROM `cache_reports` WHERE `id`=&1", 0, $rid);
$age = sql_value("SELECT DATEDIFF(NOW(),`lastmodified`) FROM `cache_reports` WHERE `id`=&1", 0, $rid);
if (isset($_REQUEST['assign']) && $rid > 0 &&
($adminid == 0 || ($adminid != $login->userid && $age >= 14)))
{
sql("UPDATE `cache_reports` SET `status`=2, `adminid`=&2 WHERE `id`=&1", $rid, $login->userid);
$tpl->redirect('adminreports.php?id='.$rid);
}
elseif (isset($_REQUEST['contact']) && $ownerid > 0)
{
$tpl->redirect('mailto.php?userid=' . urlencode($ownerid));
}
elseif (isset($_REQUEST['contact_reporter']) && $reporterid > 0)
{
$tpl->redirect('mailto.php?userid=' . urlencode($reporterid));
}
elseif (isset($_REQUEST['done']) && $adminid == $login->userid)
{
sql("UPDATE `cache_reports` SET `status`=3 WHERE `id`=&1", $rid);
$tpl->redirect('adminreports.php?id='.$rid);
}
elseif (isset($_REQUEST['assign']) && ($adminid == 0 || $adminid != $login->userid))
{
$error = 1;
if ($rid > 0)
{
$id = $rid;
}
else
{
$id = 0;
}
}
elseif (isset($_REQUEST['assign']) && $adminid == $login->userid)
{
$error = 2;
$id = $rid;
}
elseif (isset($_REQUEST['statusActive']) ||
isset($_REQUEST['statusTNA']) ||
isset($_REQUEST['statusArchived']) ||
isset($_REQUEST['done']) ||
isset($_REQUEST['statusLockedVisible']) ||
isset($_REQUEST['statusLockedInvisible']))
{
if ($adminid == 0)
{
$id = $rid;
$error = 4;
}
elseif ($adminid != $login->userid)
{
$id = $rid;
$error = 3;
}
}
if (isset($_REQUEST['assign']) && $rid > 0 &&
($adminid == 0 || ($adminid != $GLOBALS['container']->get('ocde.login')->getUserId() && $age >= 14)))
{
sql("UPDATE `cache_reports` SET `status`=2, `adminid`=&2 WHERE `id`=&1", $rid, $GLOBALS['container']->get('ocde.login')->getUserId());
$tpl->redirect('adminreports.php?id='.$rid);
}
elseif (isset($_REQUEST['contact']) && $ownerid > 0)
{
$tpl->redirect('mailto.php?userid=' . urlencode($ownerid));
}
elseif (isset($_REQUEST['contact_reporter']) && $reporterid > 0)
{
$tpl->redirect('mailto.php?userid=' . urlencode($reporterid));
}
elseif (isset($_REQUEST['done']) && $adminid == $GLOBALS['container']->get('ocde.login')->getUserId())
{
sql("UPDATE `cache_reports` SET `status`=3 WHERE `id`=&1", $rid);
$tpl->redirect('adminreports.php?id='.$rid);
}
elseif (isset($_REQUEST['assign']) && ($adminid == 0 || $adminid != $GLOBALS['container']->get('ocde.login')->getUserId()))
{
$error = 1;
if ($rid > 0)
{
$id = $rid;
}
else
{
$id = 0;
}
}
elseif (isset($_REQUEST['assign']) && $adminid == $GLOBALS['container']->get('ocde.login')->getUserId())
{
$error = 2;
$id = $rid;
}
elseif (isset($_REQUEST['statusActive']) ||
isset($_REQUEST['statusTNA']) ||
isset($_REQUEST['statusArchived']) ||
isset($_REQUEST['done']) ||
isset($_REQUEST['statusLockedVisible']) ||
isset($_REQUEST['statusLockedInvisible']))
{
if ($adminid == 0)
{
$id = $rid;
$error = 4;
}
elseif ($adminid != $GLOBALS['container']->get('ocde.login')->getUserId())
{
$id = $rid;
$error = 3;
}
}
if ($id == 0)
{
// no details, show list of reported caches
$rs = sql("SELECT `cr`.`id`,
IF(`cr`.`status`=1,'(*) ', '') AS `new`,
`c`.`name`,
`u2`.`username` AS `ownernick`,
`u`.`username`,
IF(LENGTH(`u3`.`username`)>10, CONCAT(LEFT(`u3`.`username`,9),'.'),`u3`.`username`) AS `adminname`,
`cr`.`lastmodified`,
`cr`.`adminid` IS NOT NULL AND `cr`.`adminid`!=&1 AS otheradmin
FROM `cache_reports` `cr`
INNER JOIN `caches` `c` ON `c`.`cache_id` = `cr`.`cacheid`
INNER JOIN `user` `u` ON `u`.`user_id` = `cr`.`userid`
INNER JOIN `user` AS `u2` ON `u2`.`user_id`=`c`.`user_id`
LEFT JOIN `user` AS `u3` ON `u3`.`user_id`=`cr`.`adminid`
WHERE `cr`.`status` < 3 " .
// AND (`cr`.`adminid` IS NULL OR `cr`.`adminid`=&1)
"ORDER BY (`cr`.`adminid` IS NULL OR `cr`.`adminid`=&1) DESC,
`cr`.`status` ASC,
`cr`.`lastmodified` ASC",
$login->userid);
if ($id == 0)
{
// no details, show list of reported caches
$rs = sql("SELECT `cr`.`id`,
IF(`cr`.`status`=1,'(*) ', '') AS `new`,
`c`.`name`,
`u2`.`username` AS `ownernick`,
`u`.`username`,
IF(LENGTH(`u3`.`username`)>10, CONCAT(LEFT(`u3`.`username`,9),'.'),`u3`.`username`) AS `adminname`,
`cr`.`lastmodified`,
`cr`.`adminid` IS NOT NULL AND `cr`.`adminid`!=&1 AS otheradmin
FROM `cache_reports` `cr`
INNER JOIN `caches` `c` ON `c`.`cache_id` = `cr`.`cacheid`
INNER JOIN `user` `u` ON `u`.`user_id` = `cr`.`userid`
INNER JOIN `user` AS `u2` ON `u2`.`user_id`=`c`.`user_id`
LEFT JOIN `user` AS `u3` ON `u3`.`user_id`=`cr`.`adminid`
WHERE `cr`.`status` < 3 " .
// AND (`cr`.`adminid` IS NULL OR `cr`.`adminid`=&1)
"ORDER BY (`cr`.`adminid` IS NULL OR `cr`.`adminid`=&1) DESC,
`cr`.`status` ASC,
`cr`.`lastmodified` ASC",
$GLOBALS['container']->get('ocde.login')->getUserId());
$tpl->assign_rs('reportedcaches', $rs);
sql_free_result($rs);
$tpl->assign('list', true);
}
else
{
// show details of a report
$rs = sql("SELECT `cr`.`id`, `cr`.`cacheid`, `cr`.`userid`,
`u1`.`username` AS `usernick`,
IFNULL(`cr`.`adminid`, 0) AS `adminid`,
IFNULL(`u2`.`username`, '') AS `adminnick`,
IFNULL(`tt2`.`text`, `crr`.`name`) AS `reason`,
`cr`.`note`,
IFNULL(tt.text, crs.name) AS `status`,
`cr`.`date_created`, `cr`.`lastmodified`,
`c`.`name` AS `cachename`,
`c`.`user_id` AS `ownerid`
FROM `cache_reports` AS `cr`
LEFT JOIN `cache_report_reasons` AS `crr` ON `cr`.`reason`=`crr`.`id`
LEFT JOIN `caches` AS `c` ON `c`.`cache_id`=`cr`.`cacheid`
LEFT JOIN `user` AS `u1` ON `u1`.`user_id`=`cr`.`userid`
LEFT JOIN `user` AS `u2` ON `u2`.`user_id`=`cr`.`adminid`
LEFT JOIN `cache_report_status` AS `crs` ON `cr`.`status`=`crs`.`id`
LEFT JOIN `sys_trans_text` AS `tt` ON `crs`.`trans_id`=`tt`.`trans_id` AND `tt`.`lang`='&2'
LEFT JOIN `sys_trans_text` AS `tt2` ON `crr`.`trans_id`=`tt2`.`trans_id` AND `tt2`.`lang`='&2'
WHERE `cr`.`id`=&1",
$id, $opt['template']['locale']);
$tpl->assign_rs('reportedcaches', $rs);
sql_free_result($rs);
$tpl->assign('list', true);
}
else
{
// show details of a report
$rs = sql("SELECT `cr`.`id`, `cr`.`cacheid`, `cr`.`userid`,
`u1`.`username` AS `usernick`,
IFNULL(`cr`.`adminid`, 0) AS `adminid`,
IFNULL(`u2`.`username`, '') AS `adminnick`,
IFNULL(`tt2`.`text`, `crr`.`name`) AS `reason`,
`cr`.`note`,
IFNULL(tt.text, crs.name) AS `status`,
`cr`.`date_created`, `cr`.`lastmodified`,
`c`.`name` AS `cachename`,
`c`.`user_id` AS `ownerid`
FROM `cache_reports` AS `cr`
LEFT JOIN `cache_report_reasons` AS `crr` ON `cr`.`reason`=`crr`.`id`
LEFT JOIN `caches` AS `c` ON `c`.`cache_id`=`cr`.`cacheid`
LEFT JOIN `user` AS `u1` ON `u1`.`user_id`=`cr`.`userid`
LEFT JOIN `user` AS `u2` ON `u2`.`user_id`=`cr`.`adminid`
LEFT JOIN `cache_report_status` AS `crs` ON `cr`.`status`=`crs`.`id`
LEFT JOIN `sys_trans_text` AS `tt` ON `crs`.`trans_id`=`tt`.`trans_id` AND `tt`.`lang`='&2'
LEFT JOIN `sys_trans_text` AS `tt2` ON `crr`.`trans_id`=`tt2`.`trans_id` AND `tt2`.`lang`='&2'
WHERE `cr`.`id`=&1",
$id, $opt['template']['locale']);
if ($record = sql_fetch_assoc($rs))
{
$tpl->assign('id', $record['id']);
$tpl->assign('cacheid', $record['cacheid']);
$tpl->assign('userid', $record['userid']);
$tpl->assign('usernick', $record['usernick']);
$tpl->assign('adminid', $record['adminid']);
$tpl->assign('adminnick', $record['adminnick']);
$tpl->assign('reason', $record['reason']);
$tpl->assign('note', trim($record['note']));
$tpl->assign('status', $record['status']);
$tpl->assign('created', $record['date_created']);
$tpl->assign('lastmodified', $record['lastmodified']);
$tpl->assign('cachename', $record['cachename']);
$tpl->assign('ownerid', $record['ownerid']);
if (isset($opt['logic']['adminreports']['cachexternal']))
$tpl->assign('cachexternal', $opt['logic']['adminreports']['cachexternal']);
else
$tpl->assign('cachexternal', array());
}
sql_free_result($rs);
if ($record = sql_fetch_assoc($rs))
{
$tpl->assign('id', $record['id']);
$tpl->assign('cacheid', $record['cacheid']);
$tpl->assign('userid', $record['userid']);
$tpl->assign('usernick', $record['usernick']);
$tpl->assign('adminid', $record['adminid']);
$tpl->assign('adminnick', $record['adminnick']);
$tpl->assign('reason', $record['reason']);
$tpl->assign('note', trim($record['note']));
$tpl->assign('status', $record['status']);
$tpl->assign('created', $record['date_created']);
$tpl->assign('lastmodified', $record['lastmodified']);
$tpl->assign('cachename', $record['cachename']);
$tpl->assign('ownerid', $record['ownerid']);
if (isset($opt['logic']['adminreports']['cachexternal']))
$tpl->assign('cachexternal', $opt['logic']['adminreports']['cachexternal']);
else
$tpl->assign('cachexternal', array());
}
sql_free_result($rs);
$tpl->assign('list', false);
$tpl->assign('otheradmin',$record['adminid']>0 && $record['adminid'] != $login->userid);
$tpl->assign('ownreport',$record['adminid'] == $login->userid);
$tpl->assign('list', false);
$tpl->assign('otheradmin',$record['adminid']>0 && $record['adminid'] != $GLOBALS['container']->get('ocde.login')->getUserId());
$tpl->assign('ownreport',$record['adminid'] == $GLOBALS['container']->get('ocde.login')->getUserId());
$cache = new cache($record['cacheid']);
$cache->setTplHistoryData($id);
}
$cache = new cache($record['cacheid']);
$cache->setTplHistoryData($id);
}
$tpl->assign('error', $error);
$tpl->display();
$tpl->assign('error', $error);
$tpl->display();
?>

View File

@ -5,39 +5,39 @@
* Unicode Reminder メモ
***************************************************************************/
require('./lib2/web.inc.php');
require_once('./lib2/logic/user.class.php');
require('./lib2/web.inc.php');
require_once('./lib2/logic/user.class.php');
$tpl->name = 'admins';
$tpl->menuitem = MNU_ADMIN_ADMINS;
$tpl->name = 'admins';
$tpl->menuitem = MNU_ADMIN_ADMINS;
$error = 0;
$error = 0;
$login->verify();
if ($login->userid == 0)
$tpl->redirect_login();
$GLOBALS['container']->get('ocde.login')->verify();
if ($GLOBALS['container']->get('ocde.login')->getUserId() == 0)
$tpl->redirect_login();
if ($login->admin == 0)
$tpl->error(ERROR_NO_ACCESS);
if ($GLOBALS['container']->get('ocde.login')->isAdmin() == 0)
$tpl->error(ERROR_NO_ACCESS);
$rs = sql("SELECT `user_id`,`username`,`admin` FROM `user` WHERE `admin` ORDER BY username");
while ($record = sql_fetch_assoc($rs))
{
$admin['id'] = $record['user_id'];
$admin['name'] = $record['username'];
$rights = array();
if ($record['admin'] & ADMIN_TRANSLATE) $rights[] = "translate";
if ($record['admin'] & ADMIN_MAINTAINANCE) $rights[] = "dbmaint";
if ($record['admin'] & ADMIN_USER) $rights[] = "user/caches";
if ($record['admin'] & ADMIN_NEWS) $rights[] = "newsapprove";
if ($record['admin'] & ADMIN_RESTORE) $rights[] = "vand.restore";
if ($record['admin'] & 128) $rights[] = "root";
if ($record['admin'] & ADMIN_LISTING) $rights[] = "listing";
$admin['rights'] = implode(", ", $rights);
$admins[] = $admin;
}
sql_free_result($rs);
$rs = sql("SELECT `user_id`,`username`,`admin` FROM `user` WHERE `admin` ORDER BY username");
while ($record = sql_fetch_assoc($rs))
{
$admin['id'] = $record['user_id'];
$admin['name'] = $record['username'];
$rights = array();
if ($record['admin'] & ADMIN_TRANSLATE) $rights[] = "translate";
if ($record['admin'] & ADMIN_MAINTAINANCE) $rights[] = "dbmaint";
if ($record['admin'] & ADMIN_USER) $rights[] = "user/caches";
if ($record['admin'] & ADMIN_NEWS) $rights[] = "newsapprove";
if ($record['admin'] & ADMIN_RESTORE) $rights[] = "vand.restore";
if ($record['admin'] & 128) $rights[] = "root";
if ($record['admin'] & ADMIN_LISTING) $rights[] = "listing";
$admin['rights'] = implode(", ", $rights);
$admins[] = $admin;
}
sql_free_result($rs);
$tpl->assign('admins',$admins);
$tpl->display();
$tpl->assign('admins',$admins);
$tpl->display();
?>

View File

@ -5,144 +5,144 @@
* Unicode Reminder メモ
***************************************************************************/
require('./lib2/web.inc.php');
require('./lib2/logic/user.class.php');
require('./lib2/web.inc.php');
require('./lib2/logic/user.class.php');
$tpl->name = 'adminuser';
$tpl->menuitem = MNU_ADMIN_USER;
$tpl->name = 'adminuser';
$tpl->menuitem = MNU_ADMIN_USER;
$login->verify();
if ($login->userid == 0)
$tpl->redirect_login();
$GLOBALS['container']->get('ocde.login')->verify();
if ($GLOBALS['container']->get('ocde.login')->getUserId() == 0)
$tpl->redirect_login();
if (($login->admin & ADMIN_USER) != ADMIN_USER)
$tpl->error(ERROR_NO_ACCESS);
if (isset($_REQUEST['success']) && $_REQUEST['success'])
$tpl->assign('success','1');
if (($GLOBALS['container']->get('ocde.login')->isAdmin() & ADMIN_USER) != ADMIN_USER)
$tpl->error(ERROR_NO_ACCESS);
if (isset($_REQUEST['success']) && $_REQUEST['success'])
$tpl->assign('success','1');
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'display';
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'display';
if ($action == 'searchuser')
{
searchUser();
}
else if ($action == 'sendcode')
{
sendCode();
}
else if ($action == 'formaction')
{
formAction();
}
else if ($action == 'display')
$tpl->display();
if ($action == 'searchuser')
{
searchUser();
}
else if ($action == 'sendcode')
{
sendCode();
}
else if ($action == 'formaction')
{
formAction();
}
else if ($action == 'display')
$tpl->display();
$tpl->error(ERROR_UNKNOWN);
$tpl->error(ERROR_UNKNOWN);
function sendCode()
{
global $tpl;
global $tpl;
$userid = isset($_REQUEST['userid']) ? $_REQUEST['userid']+0 : 0;
$userid = isset($_REQUEST['userid']) ? $_REQUEST['userid']+0 : 0;
$user = new user($userid);
if ($user->exist() == false)
$tpl->error(ERROR_UNKNOWN);
$user = new user($userid);
if ($user->exist() == false)
$tpl->error(ERROR_UNKNOWN);
// send a new confirmation
$user->sendRegistrationCode();
// send a new confirmation
$user->sendRegistrationCode();
$tpl->redirect('adminuser.php?action=searchuser&msg=sendcodecommit&username=' . urlencode($user->getUsername()));
$tpl->redirect('adminuser.php?action=searchuser&msg=sendcodecommit&username=' . urlencode($user->getUsername()));
}
function formAction()
{
global $tpl, $login, $translate;
global $tpl, $translate;
$commit = isset($_REQUEST['chkcommit']) ? $_REQUEST['chkcommit']+0 : 0;
$delete = isset($_REQUEST['chkdelete']) ? $_REQUEST['chkdelete']+0 : 0;
$disable = isset($_REQUEST['chkdisable']) ? $_REQUEST['chkdisable']+0 : 0;
$emailproblem = isset($_REQUEST['chkemail']) ? $_REQUEST['chkemail']+0 : 0;
$datalicense = isset($_REQUEST['chkdl']) ? $_REQUEST['chkdl']+0 : 0;
$userid = isset($_REQUEST['userid']) ? $_REQUEST['userid']+0 : 0;
$disduelicense = isset($_REQUEST['chkdisduelicense']) ? $_REQUEST['chkdisduelicense']+0 : 0;
$commit = isset($_REQUEST['chkcommit']) ? $_REQUEST['chkcommit']+0 : 0;
$delete = isset($_REQUEST['chkdelete']) ? $_REQUEST['chkdelete']+0 : 0;
$disable = isset($_REQUEST['chkdisable']) ? $_REQUEST['chkdisable']+0 : 0;
$emailproblem = isset($_REQUEST['chkemail']) ? $_REQUEST['chkemail']+0 : 0;
$datalicense = isset($_REQUEST['chkdl']) ? $_REQUEST['chkdl']+0 : 0;
$userid = isset($_REQUEST['userid']) ? $_REQUEST['userid']+0 : 0;
$disduelicense = isset($_REQUEST['chkdisduelicense']) ? $_REQUEST['chkdisduelicense']+0 : 0;
$user = new user($userid);
if ($user->exist() == false)
$tpl->error(ERROR_UNKNOWN);
$username = $user->getUsername();
$user = new user($userid);
if ($user->exist() == false)
$tpl->error(ERROR_UNKNOWN);
$username = $user->getUsername();
if ($delete + $disable + $disduelicense > 1)
$tpl->error($translate->t('Please select only one of the delete/disable options!','','',0));
if ($delete + $disable + $disduelicense > 1)
$tpl->error($translate->t('Please select only one of the delete/disable options!','','',0));
if ($commit == 0)
$tpl->error($translate->t('You have to check that you are sure!','','',0));
if ($commit == 0)
$tpl->error($translate->t('You have to check that you are sure!','','',0));
if ($disduelicense == 1)
{
$errmesg = $user->disduelicense();
if ($errmesg !== true)
$tpl->error($errmesg);
}
else if ($disable == 1)
{
if ($user->disable() == false)
$tpl->error(ERROR_UNKNOWN);
}
else if ($delete == 1)
{
if ($user->delete() == false)
$tpl->error(ERROR_UNKNOWN);
}
else if ($emailproblem == 1)
{
$user->addEmailProblem($datalicense);
}
$tpl->redirect('adminuser.php?action=searchuser&username=' . urlencode($username) .
'&success=' . ($disduelicense + $disable));
if ($disduelicense == 1)
{
$errmesg = $user->disduelicense();
if ($errmesg !== true)
$tpl->error($errmesg);
}
else if ($disable == 1)
{
if ($user->disable() == false)
$tpl->error(ERROR_UNKNOWN);
}
else if ($delete == 1)
{
if ($user->delete() == false)
$tpl->error(ERROR_UNKNOWN);
}
else if ($emailproblem == 1)
{
$user->addEmailProblem($datalicense);
}
$tpl->redirect('adminuser.php?action=searchuser&username=' . urlencode($username) .
'&success=' . ($disduelicense + $disable));
}
function searchUser()
{
global $tpl, $opt;
global $tpl, $opt;
$username = isset($_REQUEST['username']) ? $_REQUEST['username'] : '';
$msg = isset($_REQUEST['msg']) ? $_REQUEST['msg'] : '';
$username = isset($_REQUEST['username']) ? $_REQUEST['username'] : '';
$msg = isset($_REQUEST['msg']) ? $_REQUEST['msg'] : '';
$tpl->assign('username', $username);
$tpl->assign('msg', $msg);
$rs = sql("SELECT `user_id`, `username`, `email`, `email_problems`, `date_created`, `last_modified`, `is_active_flag`, `activation_code`, `first_name`, `last_name`, `data_license`='&2' AS `license_declined` FROM `user` WHERE `username`='&1' OR `email`='&1'", $username, NEW_DATA_LICENSE_ACTIVELY_DECLINED);
$r = sql_fetch_assoc($rs);
sql_free_result($rs);
if ($r == false)
{
$tpl->assign('error', 'userunknown');
$tpl->display();
}
$tpl->assign('username', $username);
$tpl->assign('msg', $msg);
$rs = sql("SELECT `user_id`, `username`, `email`, `email_problems`, `date_created`, `last_modified`, `is_active_flag`, `activation_code`, `first_name`, `last_name`, `data_license`='&2' AS `license_declined` FROM `user` WHERE `username`='&1' OR `email`='&1'", $username, NEW_DATA_LICENSE_ACTIVELY_DECLINED);
$r = sql_fetch_assoc($rs);
sql_free_result($rs);
if ($r == false)
{
$tpl->assign('error', 'userunknown');
$tpl->display();
}
$tpl->assign('showdetails', true);
$tpl->assign('showdetails', true);
$r['hidden'] = sql_value("SELECT COUNT(*) FROM `caches` WHERE `user_id`='&1'", 0, $r['user_id']);
$r['hidden_active'] = sql_value("SELECT COUNT(*) FROM `caches` WHERE `user_id`='&1' AND `status`=1", 0, $r['user_id']);
$r['logentries'] = sql_value("SELECT COUNT(*) FROM `cache_logs` WHERE `user_id`='&1'", 0, $r['user_id']);
$r['deleted_logentries'] = sql_value("SELECT COUNT(*) FROM `cache_logs_archived` WHERE `user_id`='&1'", 0, $r['user_id']);
$r['reports'] = sql_value("SELECT COUNT(*) FROM `cache_reports` WHERE `userid`='&1'", 0, $r['user_id']);
$r['last_known_login'] = sql_value("SELECT MAX(`last_login`) FROM `sys_sessions` WHERE `user_id`='&1'", 0, $r['user_id']);
$r['hidden'] = sql_value("SELECT COUNT(*) FROM `caches` WHERE `user_id`='&1'", 0, $r['user_id']);
$r['hidden_active'] = sql_value("SELECT COUNT(*) FROM `caches` WHERE `user_id`='&1' AND `status`=1", 0, $r['user_id']);
$r['logentries'] = sql_value("SELECT COUNT(*) FROM `cache_logs` WHERE `user_id`='&1'", 0, $r['user_id']);
$r['deleted_logentries'] = sql_value("SELECT COUNT(*) FROM `cache_logs_archived` WHERE `user_id`='&1'", 0, $r['user_id']);
$r['reports'] = sql_value("SELECT COUNT(*) FROM `cache_reports` WHERE `userid`='&1'", 0, $r['user_id']);
$r['last_known_login'] = sql_value("SELECT MAX(`last_login`) FROM `sys_sessions` WHERE `user_id`='&1'", 0, $r['user_id']);
$tpl->assign('user', $r);
$tpl->assign('user', $r);
$user = new user($r['user_id']);
if (!$user->exist())
$tpl->error(ERROR_UNKNOWN);
$tpl->assign('candisable', $user->canDisable());
$tpl->assign('candelete', $user->canDelete());
$tpl->assign('cansetemail', !$user->missedDataLicenseMail() && $r['email'] != "");
$tpl->assign('licensefunctions', $opt['logic']['license']['admin']);
$user = new user($r['user_id']);
if (!$user->exist())
$tpl->error(ERROR_UNKNOWN);
$tpl->assign('candisable', $user->canDisable());
$tpl->assign('candelete', $user->canDelete());
$tpl->assign('cansetemail', !$user->missedDataLicenseMail() && $r['email'] != "");
$tpl->assign('licensefunctions', $opt['logic']['license']['admin']);
$tpl->display();
$tpl->display();
}
?>

View File

@ -5,197 +5,197 @@
* Unicode Reminder メモ
***************************************************************************/
require('./lib2/web.inc.php');
require_once('./lib2/logic/cache.class.php');
$tpl->name = 'adoptcache';
$tpl->menuitem = MNU_CACHES_ADOPT;
require('./lib2/web.inc.php');
require_once('./lib2/logic/cache.class.php');
$tpl->name = 'adoptcache';
$tpl->menuitem = MNU_CACHES_ADOPT;
$login->verify();
if ($login->userid == 0)
$tpl->redirect_login();
$GLOBALS['container']->get('ocde.login')->verify();
if ($GLOBALS['container']->get('ocde.login')->getUserId() == 0)
$tpl->redirect_login();
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'listbyuser';
$tpl->assign('action', $action);
$tpl->assign('error', '');
if (isset($_REQUEST['cacheid']))
$tpl->assign('cacheid', $_REQUEST['cacheid']+0);
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'listbyuser';
$tpl->assign('action', $action);
$tpl->assign('error', '');
if (isset($_REQUEST['cacheid']))
$tpl->assign('cacheid', $_REQUEST['cacheid']+0);
if ($action == 'listbycache')
{
$cacheid = isset($_REQUEST['cacheid']) ? $_REQUEST['cacheid']+0 : 0;
listRequestsByCacheId($cacheid);
}
else if ($action == 'add')
{
$tpl->assign('action', 'listbycache');
if ($action == 'listbycache')
{
$cacheid = isset($_REQUEST['cacheid']) ? $_REQUEST['cacheid']+0 : 0;
listRequestsByCacheId($cacheid);
}
else if ($action == 'add')
{
$tpl->assign('action', 'listbycache');
$cacheid = isset($_REQUEST['cacheid']) ? $_REQUEST['cacheid']+0 : 0;
$tou = isset($_REQUEST['tou']) ? $_REQUEST['tou']+0 : 0;
$submit = isset($_REQUEST['submit']) ? $_REQUEST['submit']+0 : 0;
$username = isset($_REQUEST['username']) ? $_REQUEST['username'] : '';
$tpl->assign('adoptusername', $username);
$cacheid = isset($_REQUEST['cacheid']) ? $_REQUEST['cacheid']+0 : 0;
$tou = isset($_REQUEST['tou']) ? $_REQUEST['tou']+0 : 0;
$submit = isset($_REQUEST['submit']) ? $_REQUEST['submit']+0 : 0;
$username = isset($_REQUEST['username']) ? $_REQUEST['username'] : '';
$tpl->assign('adoptusername', $username);
if ($submit == 1)
{
$userid = sql_value("SELECT `user_id` FROM `user` WHERE `username`='&1'", 0, $username);
if ($userid == 0)
$tpl->assign('error', 'userunknown');
else if ($tou != 1)
$tpl->assign('error', 'tou');
else
addRequest($cacheid, $userid);
}
if ($submit == 1)
{
$userid = sql_value("SELECT `user_id` FROM `user` WHERE `username`='&1'", 0, $username);
if ($userid == 0)
$tpl->assign('error', 'userunknown');
else if ($tou != 1)
$tpl->assign('error', 'tou');
else
addRequest($cacheid, $userid);
}
listRequestsByCacheId($cacheid);
}
else if ($action == 'cancel')
{
$cacheid = isset($_REQUEST['cacheid']) ? $_REQUEST['cacheid']+0 : 0;
$userid = isset($_REQUEST['userid']) ? $_REQUEST['userid']+0 : 0;
cancelRequest($cacheid, $userid);
}
else if ($action == 'commit')
{
$cacheid = isset($_REQUEST['cacheid']) ? $_REQUEST['cacheid']+0 : 0;
$submit = isset($_REQUEST['submit']) ? $_REQUEST['submit']+0 : 0;
$tou = isset($_REQUEST['tou']) ? $_REQUEST['tou']+0 : 0;
listRequestsByCacheId($cacheid);
}
else if ($action == 'cancel')
{
$cacheid = isset($_REQUEST['cacheid']) ? $_REQUEST['cacheid']+0 : 0;
$userid = isset($_REQUEST['userid']) ? $_REQUEST['userid']+0 : 0;
cancelRequest($cacheid, $userid);
}
else if ($action == 'commit')
{
$cacheid = isset($_REQUEST['cacheid']) ? $_REQUEST['cacheid']+0 : 0;
$submit = isset($_REQUEST['submit']) ? $_REQUEST['submit']+0 : 0;
$tou = isset($_REQUEST['tou']) ? $_REQUEST['tou']+0 : 0;
if ($submit == 1 && $tou == 1)
commitRequest($cacheid);
else
showAdoptScreen($cacheid, $submit);
}
else // if ($action == 'listbyuser')
{
$tpl->assign('action', 'listbyuser');
listRequestsByUserId();
}
if ($submit == 1 && $tou == 1)
commitRequest($cacheid);
else
showAdoptScreen($cacheid, $submit);
}
else // if ($action == 'listbyuser')
{
$tpl->assign('action', 'listbyuser');
listRequestsByUserId();
}
$tpl->error(ERROR_UNKNOWN);
$tpl->error(ERROR_UNKNOWN);
function showAdoptScreen($cacheid, $touerror)
{
global $tpl, $login;
global $tpl;
$rs = sql("SELECT `caches`.`name`, `user`.`username`, `cache_adoption`.`date_created`
FROM `caches`
INNER JOIN `user` ON `caches`.`user_id`=`user`.`user_id`
INNER JOIN `cache_adoption` ON `caches`.`cache_id`=`cache_adoption`.`cache_id`
WHERE `caches`.`cache_id`='&1'
AND `cache_adoption`.`user_id`='&2'",
$cacheid, $login->userid);
$r = sql_fetch_assoc($rs);
if ($r === false)
$tpl->error(ERROR_NO_ACCESS);
$rs = sql("SELECT `caches`.`name`, `user`.`username`, `cache_adoption`.`date_created`
FROM `caches`
INNER JOIN `user` ON `caches`.`user_id`=`user`.`user_id`
INNER JOIN `cache_adoption` ON `caches`.`cache_id`=`cache_adoption`.`cache_id`
WHERE `caches`.`cache_id`='&1'
AND `cache_adoption`.`user_id`='&2'",
$cacheid, $GLOBALS['container']->get('ocde.login')->getUserId());
$r = sql_fetch_assoc($rs);
if ($r === false)
$tpl->error(ERROR_NO_ACCESS);
$tpl->assign('cache', $r);
sql_free_result($rs);
$tpl->assign('cache', $r);
sql_free_result($rs);
if ($touerror != 0)
$tpl->assign('error', 'tou');
if ($touerror != 0)
$tpl->assign('error', 'tou');
$tpl->display();
$tpl->display();
}
function listRequestsByCacheId($cacheid)
{
global $tpl, $login;
global $tpl;
// cache exists?
$cache = new cache($cacheid);
if ($cache->exist() == false)
$tpl->error(ERROR_CACHE_NOT_EXISTS);
// cache exists?
$cache = new cache($cacheid);
if ($cache->exist() == false)
$tpl->error(ERROR_CACHE_NOT_EXISTS);
// is the current user the owner of the cache?
if ($cache->getUserId() != $login->userid)
$tpl->error(ERROR_NO_ACCESS);
// is the current user the owner of the cache?
if ($cache->getUserId() != $GLOBALS['container']->get('ocde.login')->getUserId())
$tpl->error(ERROR_NO_ACCESS);
$rs = sql("SELECT `caches`.`cache_id` AS `id`, `user`.`user_id` AS `userid`, `user`.`username` AS `username`, `cache_adoption`.`date_created`
FROM `caches`
INNER JOIN `cache_adoption` ON `caches`.`cache_id` = `cache_adoption`.`cache_id`
INNER JOIN `user` ON `cache_adoption`.`user_id`=`user`.`user_id`
WHERE `caches`.`cache_id`='&1'",
$cacheid);
$tpl->assign_rs('adoptions', $rs);
sql_free_result($rs);
$rs = sql("SELECT `caches`.`cache_id` AS `id`, `user`.`user_id` AS `userid`, `user`.`username` AS `username`, `cache_adoption`.`date_created`
FROM `caches`
INNER JOIN `cache_adoption` ON `caches`.`cache_id` = `cache_adoption`.`cache_id`
INNER JOIN `user` ON `cache_adoption`.`user_id`=`user`.`user_id`
WHERE `caches`.`cache_id`='&1'",
$cacheid);
$tpl->assign_rs('adoptions', $rs);
sql_free_result($rs);
$tpl->assign('cachename', $cache->getName());
$tpl->assign('cachename', $cache->getName());
$tpl->display();
$tpl->display();
}
function listRequestsByUserId()
{
global $tpl, $login;
global $tpl;
$tpl->menuitem = MNU_MYPROFILE_ADOPT;
$tpl->menuitem = MNU_MYPROFILE_ADOPT;
$rs = sql("SELECT `caches`.`cache_id` AS `id`, `caches`.`name` AS `cachename`, `user`.`user_id` AS `ownerid`, `user`.`username` AS `ownername`, `cache_adoption`.`date_created`
FROM `caches`
INNER JOIN `cache_adoption` ON `caches`.`cache_id` = `cache_adoption`.`cache_id`
INNER JOIN `user` ON `caches`.`user_id`=`user`.`user_id`
WHERE `cache_adoption`.`user_id`='&1'",
$login->userid);
$tpl->assign_rs('adoptions', $rs);
sql_free_result($rs);
$rs = sql("SELECT `caches`.`cache_id` AS `id`, `caches`.`name` AS `cachename`, `user`.`user_id` AS `ownerid`, `user`.`username` AS `ownername`, `cache_adoption`.`date_created`
FROM `caches`
INNER JOIN `cache_adoption` ON `caches`.`cache_id` = `cache_adoption`.`cache_id`
INNER JOIN `user` ON `caches`.`user_id`=`user`.`user_id`
WHERE `cache_adoption`.`user_id`='&1'",
$GLOBALS['container']->get('ocde.login')->getUserId());
$tpl->assign_rs('adoptions', $rs);
sql_free_result($rs);
$tpl->display();
$tpl->display();
}
function addRequest($cacheid, $userid)
{
global $tpl;
global $tpl;
// cache exists?
$cache = new cache($cacheid);
if ($cache->exist() == false)
$tpl->error(ERROR_CACHE_NOT_EXISTS);
// cache exists?
$cache = new cache($cacheid);
if ($cache->exist() == false)
$tpl->error(ERROR_CACHE_NOT_EXISTS);
$adopt_result = $cache->addAdoption($userid);
if ($adopt_result === true)
$tpl->redirect('adoptcache.php?action=listbycache&cacheid=' . $cacheid);
else
{
$tpl->assign('error',$adopt_result);
listRequestsByCacheId($cacheid);
}
$adopt_result = $cache->addAdoption($userid);
if ($adopt_result === true)
$tpl->redirect('adoptcache.php?action=listbycache&cacheid=' . $cacheid);
else
{
$tpl->assign('error',$adopt_result);
listRequestsByCacheId($cacheid);
}
}
function commitRequest($cacheid)
{
global $tpl, $login;
global $tpl;
// cache exists?
$cache = new cache($cacheid);
if ($cache->exist() == false)
$tpl->error(ERROR_CACHE_NOT_EXISTS);
// cache exists?
$cache = new cache($cacheid);
if ($cache->exist() == false)
$tpl->error(ERROR_CACHE_NOT_EXISTS);
if ($cache->commitAdoption($login->userid) == false)
$tpl->error(ERROR_UNKNOWN);
if ($cache->commitAdoption($GLOBALS['container']->get('ocde.login')->getUserId()) == false)
$tpl->error(ERROR_UNKNOWN);
$tpl->redirect('viewcache.php?cacheid=' . $cacheid);
$tpl->redirect('viewcache.php?cacheid=' . $cacheid);
}
function cancelRequest($cacheid, $userid)
{
global $tpl, $login;
global $tpl;
// cache exists?
$cache = new cache($cacheid);
if ($cache->exist() == false)
$tpl->error(ERROR_CACHE_NOT_EXISTS);
// cache exists?
$cache = new cache($cacheid);
if ($cache->exist() == false)
$tpl->error(ERROR_CACHE_NOT_EXISTS);
if ($cache->allowEdit() == false && $login->userid != $userid)
$tpl->error(ERROR_NO_ACCESS);
if ($cache->allowEdit() == false && $GLOBALS['container']->get('ocde.login')->getUserId() != $userid)
$tpl->error(ERROR_NO_ACCESS);
if ($cache->cancelAdoption($userid) == false)
$tpl->error(ERROR_UNKNOWN);
if ($cache->cancelAdoption($userid) == false)
$tpl->error(ERROR_UNKNOWN);
if ($userid == $login->userid)
$tpl->redirect('adoptcache.php');
else
$tpl->redirect('adoptcache.php?action=listbycache&cacheid=' . $cacheid);
if ($userid == $GLOBALS['container']->get('ocde.login')->getUserId())
$tpl->redirect('adoptcache.php');
else
$tpl->redirect('adoptcache.php?action=listbycache&cacheid=' . $cacheid);
}
?>

View File

@ -5,87 +5,87 @@
* Unicode Reminder メモ
***************************************************************************/
require('./lib2/web.inc.php');
require('./lib2/web.inc.php');
//get the article name to display
$article = '';
$language = $opt['template']['locale'];
if (isset($_REQUEST['page']) &&
(mb_strpos($_REQUEST['page'], '.') === false) &&
(mb_strpos($_REQUEST['page'], '/') === false) &&
(mb_strpos($_REQUEST['page'], '\\') === false))
{
$article = $_REQUEST['page'];
}
if ($article == '')
{
//no article specified
$tpl->redirect('index.php');
}
else if (!file_exists($opt['stylepath'] . '/articles/' . $language . '/' . $article . '.tpl'))
{
// does article exist in default-language?
if (file_exists($opt['stylepath'] . '/articles/' . $opt['template']['default']['article_locale'] . '/' . $article . '.tpl'))
{
$language = $opt['template']['default']['article_locale'];
}
elseif (file_exists($opt['stylepath'] . '/articles/EN/' . $article . '.tpl'))
{
$language = 'EN';
}
else
{
// use any
$language = false;
if ($hDir = opendir($opt['stylepath'] . '/articles/'))
{
while ((($sFile = readdir($hDir)) !== false) && ($language === false))
{
if (($sFile != '.') && ($sFile != '..') && (is_dir($opt['stylepath'] . '/articles/' . $sFile)))
{
if (file_exists($opt['stylepath'] . '/articles/' . $sFile . '/' . $article . '.tpl'))
{
$language = $sFile;
}
}
}
closedir($hDir);
}
//get the article name to display
$article = '';
$language = $opt['template']['locale'];
if (isset($_REQUEST['page']) &&
(mb_strpos($_REQUEST['page'], '.') === false) &&
(mb_strpos($_REQUEST['page'], '/') === false) &&
(mb_strpos($_REQUEST['page'], '\\') === false))
{
$article = $_REQUEST['page'];
}
if ($article == '')
{
//no article specified
$tpl->redirect('index.php');
}
else if (!file_exists($opt['stylepath'] . '/articles/' . $language . '/' . $article . '.tpl'))
{
// does article exist in default-language?
if (file_exists($opt['stylepath'] . '/articles/' . $opt['template']['default']['article_locale'] . '/' . $article . '.tpl'))
{
$language = $opt['template']['default']['article_locale'];
}
elseif (file_exists($opt['stylepath'] . '/articles/EN/' . $article . '.tpl'))
{
$language = 'EN';
}
else
{
// use any
$language = false;
if ($hDir = opendir($opt['stylepath'] . '/articles/'))
{
while ((($sFile = readdir($hDir)) !== false) && ($language === false))
{
if (($sFile != '.') && ($sFile != '..') && (is_dir($opt['stylepath'] . '/articles/' . $sFile)))
{
if (file_exists($opt['stylepath'] . '/articles/' . $sFile . '/' . $article . '.tpl'))
{
$language = $sFile;
}
}
}
closedir($hDir);
}
//article doesn't exists
if ($language === false)
{
$tpl->redirect('index.php');
}
}
}
//article doesn't exists
if ($language === false)
{
$tpl->redirect('index.php');
}
}
}
$tpl->name = 'articles';
$tpl->name = 'articles';
$tpl->caching = true;
$tpl->cache_id = 'articles|' . $language . '|' . $article;
$tpl->cache_lifetime = 43200;
$tpl->caching = true;
$tpl->cache_id = 'articles|' . $language . '|' . $article;
$tpl->cache_lifetime = 43200;
$tpl->menuitem = sql_value("SELECT `id` FROM `sys_menu` WHERE `href`='&1' LIMIT 1", 0, 'articles.php?page=' . urlencode($article));
if ($tpl->menuitem == 0)
$tpl->redirect('index.php');
$tpl->menuitem = sql_value("SELECT `id` FROM `sys_menu` WHERE `href`='&1' LIMIT 1", 0, 'articles.php?page=' . urlencode($article));
if ($tpl->menuitem == 0)
$tpl->redirect('index.php');
if (!$tpl->is_cached())
{
if (!$tpl->is_cached())
{
$tpl->assign('article', $article);
$tpl->assign('language', $language);
$tpl->assign('article', $article);
$tpl->assign('language', $language);
/* prepare smarty vars for special pages ...
*/
if ($article == 'cacheinfo')
{
require_once($opt['rootpath'] . 'lib2/logic/attribute.class.php');
$attributes = attribute::getSelectableAttrbutesListArray(true);
$tpl->assign('attributes', $attributes);
}
}
/* prepare smarty vars for special pages ...
*/
if ($article == 'cacheinfo')
{
require_once($opt['rootpath'] . 'lib2/logic/attribute.class.php');
$attributes = attribute::getSelectableAttrbutesListArray(true);
$tpl->assign('attributes', $attributes);
}
}
$tpl->display();
$tpl->display();
?>

View File

@ -5,67 +5,67 @@
* Unicode Reminder メモ
***************************************************************************/
require('./lib2/web.inc.php');
redirect_na();
require('./lib2/web.inc.php');
redirect_na();
exit;
$wp = isset($_REQUEST['wp']) ? mb_trim($_REQUEST['wp']) : '';
$rs = sql("SELECT `caches`.`cache_id` `cache_id`, `caches`.`wp_oc` `wp_oc`, `caches`.`longitude` `longitude`, `caches`.`latitude` `latitude`, IF(ISNULL(`cache_maps`.`cache_id`) OR `caches`.`last_modified`>`cache_maps`.`last_refresh`, 1, 0) AS `refresh` FROM `caches` INNER JOIN `cache_status` ON `caches`.`status`=`cache_status`.`id` LEFT JOIN `cache_maps` ON `caches`.`cache_id`=`cache_maps`.`cache_id` WHERE `cache_status`.`allow_user_view`=1 AND `caches`.`wp_oc`='&1'", $wp);
$r = sql_fetch_assoc($rs);
sql_free_result($rs);
$wp = isset($_REQUEST['wp']) ? mb_trim($_REQUEST['wp']) : '';
$rs = sql("SELECT `caches`.`cache_id` `cache_id`, `caches`.`wp_oc` `wp_oc`, `caches`.`longitude` `longitude`, `caches`.`latitude` `latitude`, IF(ISNULL(`cache_maps`.`cache_id`) OR `caches`.`last_modified`>`cache_maps`.`last_refresh`, 1, 0) AS `refresh` FROM `caches` INNER JOIN `cache_status` ON `caches`.`status`=`cache_status`.`id` LEFT JOIN `cache_maps` ON `caches`.`cache_id`=`cache_maps`.`cache_id` WHERE `cache_status`.`allow_user_view`=1 AND `caches`.`wp_oc`='&1'", $wp);
$r = sql_fetch_assoc($rs);
sql_free_result($rs);
if ($r !== false)
{
if ($r !== false)
{
$d1 = mb_substr($r['wp_oc'], 2, 1);
$d2 = mb_substr($r['wp_oc'], 3, 1);
$file = $opt['logic']['cachemaps']['dir'] . $d1 . '/' . $d2 . '/' . $r['wp_oc'] . '.jpg';
if (($r['refresh'] == 1) || !is_file($file))
{
$url = $opt['logic']['cachemaps']['wmsurl'];
$url = mb_ereg_replace('{min_lon}', $r['longitude'] - $opt['logic']['cachemaps']['size']['lon'] / 2, $url);
$url = mb_ereg_replace('{max_lon}', $r['longitude'] + $opt['logic']['cachemaps']['size']['lon'] / 2, $url);
$url = mb_ereg_replace('{min_lat}', $r['latitude'] - $opt['logic']['cachemaps']['size']['lat'] / 2, $url);
$url = mb_ereg_replace('{max_lat}', $r['latitude'] + $opt['logic']['cachemaps']['size']['lat'] / 2, $url);
$url = mb_ereg_replace('{wp_oc}', $r['wp_oc'], $url);
if (($r['refresh'] == 1) || !is_file($file))
{
$url = $opt['logic']['cachemaps']['wmsurl'];
$url = mb_ereg_replace('{min_lon}', $r['longitude'] - $opt['logic']['cachemaps']['size']['lon'] / 2, $url);
$url = mb_ereg_replace('{max_lon}', $r['longitude'] + $opt['logic']['cachemaps']['size']['lon'] / 2, $url);
$url = mb_ereg_replace('{min_lat}', $r['latitude'] - $opt['logic']['cachemaps']['size']['lat'] / 2, $url);
$url = mb_ereg_replace('{max_lat}', $r['latitude'] + $opt['logic']['cachemaps']['size']['lat'] / 2, $url);
$url = mb_ereg_replace('{wp_oc}', $r['wp_oc'], $url);
if (!is_dir($opt['logic']['cachemaps']['dir'] . $d1)) mkdir($opt['logic']['cachemaps']['dir'] . $d1);
if (!is_dir($opt['logic']['cachemaps']['dir'] . $d1 . '/' . $d2)) mkdir($opt['logic']['cachemaps']['dir'] . $d1 . '/' . $d2);
if (!is_dir($opt['logic']['cachemaps']['dir'] . $d1)) mkdir($opt['logic']['cachemaps']['dir'] . $d1);
if (!is_dir($opt['logic']['cachemaps']['dir'] . $d1 . '/' . $d2)) mkdir($opt['logic']['cachemaps']['dir'] . $d1 . '/' . $d2);
if (@copy($url, $file))
{
$im = imagecreatefromjpeg($file);
if (!$im) redirect_na(); // bild ist kein lesbares jpg
if (@copy($url, $file))
{
$im = imagecreatefromjpeg($file);
if (!$im) redirect_na(); // bild ist kein lesbares jpg
$white = imagecolorallocate($im, 255, 255, 255);
$green = imagecolorallocate($im, 100, 255, 100);
$white = imagecolorallocate($im, 255, 255, 255);
$green = imagecolorallocate($im, 100, 255, 100);
imageline($im, ($opt['logic']['cachemaps']['pixel']['x'] / 2) - 10, ($opt['logic']['cachemaps']['pixel']['y'] / 2) - 1, ($opt['logic']['cachemaps']['pixel']['x'] / 2) + 10, ($opt['logic']['cachemaps']['pixel']['y'] / 2) - 1, $green);
imageline($im, ($opt['logic']['cachemaps']['pixel']['x'] / 2) - 1, ($opt['logic']['cachemaps']['pixel']['y'] / 2) - 10, ($opt['logic']['cachemaps']['pixel']['x'] / 2) - 1, ($opt['logic']['cachemaps']['pixel']['y'] / 2) + 10, $green);
imageline($im, ($opt['logic']['cachemaps']['pixel']['x'] / 2) - 10, ($opt['logic']['cachemaps']['pixel']['y'] / 2) - 1, ($opt['logic']['cachemaps']['pixel']['x'] / 2) + 10, ($opt['logic']['cachemaps']['pixel']['y'] / 2) - 1, $green);
imageline($im, ($opt['logic']['cachemaps']['pixel']['x'] / 2) - 1, ($opt['logic']['cachemaps']['pixel']['y'] / 2) - 10, ($opt['logic']['cachemaps']['pixel']['x'] / 2) - 1, ($opt['logic']['cachemaps']['pixel']['y'] / 2) + 10, $green);
imageline($im, ($opt['logic']['cachemaps']['pixel']['x'] / 2), ($opt['logic']['cachemaps']['pixel']['y'] / 2) - 10, ($opt['logic']['cachemaps']['pixel']['x'] / 2), ($opt['logic']['cachemaps']['pixel']['y'] / 2) + 10, $white);
imageline($im, ($opt['logic']['cachemaps']['pixel']['x'] / 2) - 10, ($opt['logic']['cachemaps']['pixel']['y'] / 2), ($opt['logic']['cachemaps']['pixel']['x'] / 2) + 10, ($opt['logic']['cachemaps']['pixel']['y'] / 2), $white);
imageline($im, ($opt['logic']['cachemaps']['pixel']['x'] / 2), ($opt['logic']['cachemaps']['pixel']['y'] / 2) - 10, ($opt['logic']['cachemaps']['pixel']['x'] / 2), ($opt['logic']['cachemaps']['pixel']['y'] / 2) + 10, $white);
imageline($im, ($opt['logic']['cachemaps']['pixel']['x'] / 2) - 10, ($opt['logic']['cachemaps']['pixel']['y'] / 2), ($opt['logic']['cachemaps']['pixel']['x'] / 2) + 10, ($opt['logic']['cachemaps']['pixel']['y'] / 2), $white);
imagecolordeallocate($im, $white);
imagecolordeallocate($im, $green);
imagecolordeallocate($im, $white);
imagecolordeallocate($im, $green);
imagejpeg($im, $file);
imagedestroy($im);
imagejpeg($im, $file);
imagedestroy($im);
sql("INSERT INTO `cache_maps` (`cache_id`, `last_refresh`) VALUES ('&1', NOW()) ON DUPLICATE KEY UPDATE `last_refresh`=NOW()", $r['cache_id']);
}
else
redirect_na(); // download fehlgeschlagen
}
sql("INSERT INTO `cache_maps` (`cache_id`, `last_refresh`) VALUES ('&1', NOW()) ON DUPLICATE KEY UPDATE `last_refresh`=NOW()", $r['cache_id']);
}
else
redirect_na(); // download fehlgeschlagen
}
$tpl->redirect($opt['logic']['cachemaps']['url'] . $d1 . '/' . $d2 . '/' . $r['wp_oc'] . '.jpg');
}
else
redirect_na(); // wp existiert nicht
$tpl->redirect($opt['logic']['cachemaps']['url'] . $d1 . '/' . $d2 . '/' . $r['wp_oc'] . '.jpg');
}
else
redirect_na(); // wp existiert nicht
function redirect_na()
{
global $tpl;
$tpl->redirect('images/cachemaps/na.gif');
global $tpl;
$tpl->redirect('images/cachemaps/na.gif');
}
?>

View File

@ -5,54 +5,54 @@
* Unicode Reminder メモ
***************************************************************************/
require('./lib2/web.inc.php');
require_once('./lib2/logic/statpic.class.php');
require('./lib2/web.inc.php');
require_once('./lib2/logic/statpic.class.php');
$login->verify();
$tpl->name = 'change_statpic';
$tpl->menuitem = MNU_MYPROFILE_DATA_STATPIC;
$GLOBALS['container']->get('ocde.login')->verify();
$tpl->name = 'change_statpic';
$tpl->menuitem = MNU_MYPROFILE_DATA_STATPIC;
if ($login->userid == 0)
$tpl->redirect('login.php?target=change_statpic.php');
if ($GLOBALS['container']->get('ocde.login')->getUserId() == 0)
$tpl->redirect('login.php?target=change_statpic.php');
if (isset($_REQUEST['cancel']))
$tpl->redirect('mystatpic.php');
if (isset($_REQUEST['cancel']))
$tpl->redirect('mystatpic.php');
$sp = new statpic($login->userid);
$sp = new statpic($GLOBALS['container']->get('ocde.login')->getUserId());
if (isset($_REQUEST['ok']))
{
$bError = false;
if (isset($_REQUEST['ok']))
{
$bError = false;
if (isset($_REQUEST['statpic_text']))
{
if (!$sp->setText($_REQUEST['statpic_text']))
{
$bError = true;
$tpl->assign('statpic_text_error', 1);
}
}
if (isset($_REQUEST['statpic_text']))
{
if (!$sp->setText($_REQUEST['statpic_text']))
{
$bError = true;
$tpl->assign('statpic_text_error', 1);
}
}
if (isset($_REQUEST['statpic_style']))
$sp->setStyle($_REQUEST['statpic_style']);
if (isset($_REQUEST['statpic_style']))
$sp->setStyle($_REQUEST['statpic_style']);
if (!$bError)
{
$sp->save();
$tpl->redirect('mystatpic.php');
}
}
if (!$bError)
{
$sp->save();
$tpl->redirect('mystatpic.php');
}
}
$tpl->assign('statpic_text', isset($_REQUEST['statpic_text']) ? $_REQUEST['statpic_text'] : $sp->getText());
$tpl->assign('statpic_style', isset($_REQUEST['statpic_style']) ? $_REQUEST['statpic_style'] : $sp->getStyle());
$tpl->assign('statpic_text', isset($_REQUEST['statpic_text']) ? $_REQUEST['statpic_text'] : $sp->getText());
$tpl->assign('statpic_style', isset($_REQUEST['statpic_style']) ? $_REQUEST['statpic_style'] : $sp->getStyle());
$rs = sql("SELECT `statpics`.`id`, `statpics`.`previewpath`, IFNULL(`sys_trans_text`.`text`, `statpics`.`description`) AS `description`
FROM `statpics`
LEFT JOIN `sys_trans_text` ON `statpics`.`trans_id`=`sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang`='&1'
ORDER BY `statpics`.`id` ASC",
$opt['template']['locale']);
$tpl->assign_rs('statpics', $rs);
sql_free_result($rs);
$rs = sql("SELECT `statpics`.`id`, `statpics`.`previewpath`, IFNULL(`sys_trans_text`.`text`, `statpics`.`description`) AS `description`
FROM `statpics`
LEFT JOIN `sys_trans_text` ON `statpics`.`trans_id`=`sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang`='&1'
ORDER BY `statpics`.`id` ASC",
$opt['template']['locale']);
$tpl->assign_rs('statpics', $rs);
sql_free_result($rs);
$tpl->display();
$tpl->display();
?>

View File

@ -10,9 +10,9 @@
$tpl->name = 'childwp';
$tpl->menuitem = MNU_CACHES_HIDE;
$login->verify();
$GLOBALS['container']->get('ocde.login')->verify();
if ($login->userid == 0)
if ($GLOBALS['container']->get('ocde.login')->getUserId() == 0)
$tpl->redirect_login();
$isSubmit = isset($_POST['submitform']);

52
htdocs/composer.json Normal file
View File

@ -0,0 +1,52 @@
{
"name": "opencaching.de",
"description": "opencaching.de source code",
"require": {
"php": ">=5.3.0",
"ezyang/htmlpurifier": "4.5.0",
"smarty/smarty": "~2.6",
"ocpl/okapi": "dev-master",
"symfony/dependency-injection": "~2.6",
"symfony/yaml": "~2.6",
"symfony/config": "~2.6",
"ccampbell/chromephp": "~4.1",
"html2text/html2text": "~2.0",
"iamcal/rfc822": "dev-master"
},
"autoload": {
"psr-4": { "": "lib/" },
"classmap": [ "lib2/", "lib2/logic/", "libse/" ]
},
"repositories": [
{
"type": "package",
"package": {
"name": "iamcal/rfc822",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/iamcal/rfc822",
"reference": "master"
}
},
"autoload": {
"files": [ "rfc822.php" ]
}
},
{
"type": "package",
"package": {
"name": "ocpl/okapi",
"version": "dev-master",
"source": {
"type": "svn",
"url": "http://opencaching-api.googlecode.com/svn/",
"reference": "trunk/okapi/"
},
"autoload": {
"classmap": [ "./" ]
}
}
}
]
}

434
htdocs/composer.lock generated Normal file
View File

@ -0,0 +1,434 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "5967a734e8be910baa0de260646778ef",
"packages": [
{
"name": "ccampbell/chromephp",
"version": "4.1.0",
"source": {
"type": "git",
"url": "https://github.com/ccampbell/chromephp.git",
"reference": "c3c297615d48ae5b2a86a82311152d1ed095fcef"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ccampbell/chromephp/zipball/c3c297615d48ae5b2a86a82311152d1ed095fcef",
"reference": "c3c297615d48ae5b2a86a82311152d1ed095fcef",
"shasum": ""
},
"require": {
"php": ">=5.0.0"
},
"type": "library",
"autoload": {
"psr-0": {
"ChromePhp": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"Apache-2.0"
],
"authors": [
{
"name": "Craig Campbell",
"email": "iamcraigcampbell@gmail.com",
"homepage": "http://craig.is",
"role": "Developer"
}
],
"description": "Log variables to the Chrome console (via Chrome Logger Google Chrome extension).",
"homepage": "http://github.com/ccampbell/chromephp",
"keywords": [
"log",
"logging"
],
"time": "2013-06-26 03:44:33"
},
{
"name": "ezyang/htmlpurifier",
"version": "v4.5.0",
"source": {
"type": "git",
"url": "https://github.com/ezyang/htmlpurifier.git",
"reference": "d516e2f8de435ea78cc6152abc425d3ff2c4d289"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ezyang/htmlpurifier/zipball/d516e2f8de435ea78cc6152abc425d3ff2c4d289",
"reference": "d516e2f8de435ea78cc6152abc425d3ff2c4d289",
"shasum": ""
},
"require": {
"php": ">=5.2"
},
"type": "library",
"autoload": {
"psr-0": {
"HTMLPurifier": "library/"
},
"files": [
"library/HTMLPurifier.composer.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL"
],
"authors": [
{
"name": "Edward Z. Yang",
"email": "admin@htmlpurifier.org",
"homepage": "http://ezyang.com",
"role": "Developer"
}
],
"description": "Standards compliant HTML filter written in PHP",
"homepage": "http://htmlpurifier.org/",
"keywords": [
"html"
],
"time": "2013-02-18 00:04:08"
},
{
"name": "html2text/html2text",
"version": "2.0.1",
"source": {
"type": "git",
"url": "https://github.com/mtibben/html2text.git",
"reference": "1ff30ba6b0905fc1714385f747e0228d6bfcab15"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/mtibben/html2text/zipball/1ff30ba6b0905fc1714385f747e0228d6bfcab15",
"reference": "1ff30ba6b0905fc1714385f747e0228d6bfcab15",
"shasum": ""
},
"require-dev": {
"phpunit/phpunit": "~4"
},
"type": "library",
"autoload": {
"psr-4": {
"Html2Text\\": [
"src/",
"test/"
]
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"GPLv2"
],
"description": "Converts HTML to formatted plain text",
"time": "2015-01-28 23:10:17"
},
{
"name": "iamcal/rfc822",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/iamcal/rfc822",
"reference": "master"
},
"type": "library",
"autoload": {
"files": [
"rfc822.php"
]
},
"time": "2011-06-13 20:24:53"
},
{
"name": "ocpl/okapi",
"version": "dev-master",
"source": {
"type": "svn",
"url": "http://opencaching-api.googlecode.com/svn/",
"reference": "trunk/okapi/"
},
"type": "library",
"autoload": {
"classmap": [
"./"
]
}
},
{
"name": "smarty/smarty",
"version": "v2.6.28",
"source": {
"type": "git",
"url": "https://github.com/smarty-php/smarty.git",
"reference": "0ecdd6c41d0de08cba846087abd02a9adb5218e5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/smarty-php/smarty/zipball/0ecdd6c41d0de08cba846087abd02a9adb5218e5",
"reference": "0ecdd6c41d0de08cba846087abd02a9adb5218e5",
"shasum": ""
},
"require": {
"php": ">=5.2"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.6.x-dev"
}
},
"autoload": {
"classmap": [
"libs/Smarty.class.php",
"libs/Smarty_Compiler.class.php",
"libs/Config_File.class.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL-3.0"
],
"authors": [
{
"name": "Monte Ohrt",
"email": "monte@ohrt.com"
},
{
"name": "Uwe Tews",
"email": "uwe.tews@googlemail.com"
}
],
"description": "Smarty - the compiling PHP template engine",
"homepage": "http://www.smarty.net",
"keywords": [
"templating"
],
"time": "2014-10-31 00:07:20"
},
{
"name": "symfony/config",
"version": "v2.7.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/Config.git",
"reference": "537e9912063e66aa70cbcddd7d6e6e8db61d98e4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Config/zipball/537e9912063e66aa70cbcddd7d6e6e8db61d98e4",
"reference": "537e9912063e66aa70cbcddd7d6e6e8db61d98e4",
"shasum": ""
},
"require": {
"php": ">=5.3.9",
"symfony/filesystem": "~2.3"
},
"require-dev": {
"symfony/phpunit-bridge": "~2.7"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.7-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\Config\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Config Component",
"homepage": "https://symfony.com",
"time": "2015-05-15 13:33:16"
},
{
"name": "symfony/dependency-injection",
"version": "v2.7.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/DependencyInjection.git",
"reference": "137bf489c5151c7eb1e4b7dd34a123f9a74b966d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/DependencyInjection/zipball/137bf489c5151c7eb1e4b7dd34a123f9a74b966d",
"reference": "137bf489c5151c7eb1e4b7dd34a123f9a74b966d",
"shasum": ""
},
"require": {
"php": ">=5.3.9"
},
"conflict": {
"symfony/expression-language": "<2.6"
},
"require-dev": {
"symfony/config": "~2.2",
"symfony/expression-language": "~2.6",
"symfony/phpunit-bridge": "~2.7",
"symfony/yaml": "~2.1"
},
"suggest": {
"symfony/config": "",
"symfony/proxy-manager-bridge": "Generate service proxies to lazy load them",
"symfony/yaml": ""
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.7-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\DependencyInjection\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony DependencyInjection Component",
"homepage": "https://symfony.com",
"time": "2015-05-29 14:44:44"
},
{
"name": "symfony/filesystem",
"version": "v2.7.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/Filesystem.git",
"reference": "ae4551fd6d4d4f51f2e7390fbc902fbd67f3b7ba"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Filesystem/zipball/ae4551fd6d4d4f51f2e7390fbc902fbd67f3b7ba",
"reference": "ae4551fd6d4d4f51f2e7390fbc902fbd67f3b7ba",
"shasum": ""
},
"require": {
"php": ">=5.3.9"
},
"require-dev": {
"symfony/phpunit-bridge": "~2.7"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.7-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\Filesystem\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Filesystem Component",
"homepage": "https://symfony.com",
"time": "2015-05-15 13:33:16"
},
{
"name": "symfony/yaml",
"version": "v2.7.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/Yaml.git",
"reference": "4a29a5248aed4fb45f626a7bbbd330291492f5c3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Yaml/zipball/4a29a5248aed4fb45f626a7bbbd330291492f5c3",
"reference": "4a29a5248aed4fb45f626a7bbbd330291492f5c3",
"shasum": ""
},
"require": {
"php": ">=5.3.9"
},
"require-dev": {
"symfony/phpunit-bridge": "~2.7"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.7-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\Yaml\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Yaml Component",
"homepage": "https://symfony.com",
"time": "2015-05-02 15:21:08"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": {
"ocpl/okapi": 20,
"iamcal/rfc822": 20
},
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
"php": ">=5.3.0"
},
"platform-dev": []
}

14
htdocs/config/config.yml Normal file
View File

@ -0,0 +1,14 @@
ocde:
web:
domain: opencaching.de
base_url: "http://www.opencaching.de"
database:
server: localhost
username: oc
password: developer
database: opencaching
tmpdb: octmp
maintenance:
username: oc
password: developer
pconnect: false

View File

@ -0,0 +1,2 @@
imports:
- { resource: config.yml }

View File

@ -0,0 +1,2 @@
imports:
- { resource: config.yml }

View File

@ -0,0 +1,42 @@
{
"template": {
"locales": {
"DE": {
"show": true,
"flag": "images/flag/DE.png",
"name": "Deutsch"
}
}
},
"geokrety": {
"locales": {
"DE": "de_DE.UTF-8"
}
},
"locale": {
"DE": {
"country": "DE",
"format": {
"dm": "%d.%m.",
"dateshort": "%d.%m.%y",
"date": "%x",
"datelong": "%d. %B %Y",
"datetime": "%x %H:%M",
"datetimesec": "%x %X",
"time": "%H:%M",
"timesec": "%X",
"phpdate": "d.m.Y"
},
"page": {
"subtitle1": "Geocaching mit Opencaching",
"subtitle2": "",
"license_url": "http://creativecommons.org/licenses/by-nc-nd/3.0/de/",
"license": "<a rel=\"license\" href=\"%1\"><img alt=\"Creative Commons Lizenzvertrag\" style=\"border-width: 0;\" src=\"http://i.creativecommons.org/l/by-nc-nd/3.0/de/88x31.png\" /></a><div style=\"text-align: center; margin: 8px 0 0 6px;\">Die <a href=\"articles.php?page=impressum#datalicense\">Inhalte</a> von Opencaching.de stehen unter der Creative-Commons-Lizenz <a rel=\"license\" href=\"%1\">BY-NC-ND 3.0 DE</a>.</div>"
},
"helpwiki": "http://wiki.opencaching.de/index.php/",
"locales": [ "de_DE.utf8", "de_DE@euro", "de_DE", "de", "ge" ]
}
}
}

View File

@ -0,0 +1,39 @@
{
"template": {
"locales": {
"DA": {
"show": true,
"flag": "images/flag/dk.png",
"name": "Danske"
}
}
},
"geokrety": {
"locales": {
"DA": "da_DK.UTF-8"
}
},
"locale": {
"DA": {
"country": "DK",
"format": {
"dm": "%d.%m.",
"dateshort": "%d.%m.%y",
"date": "%Y-%m-%d",
"datelong": "%Y-%m-%d",
"datetime": "%x %H:%M",
"datetimesec": "%x %X",
"time": "%H:%M",
"timesec": "%X",
"phpdate": "d-m-Y"
},
"page": {
"subtitle1": "Geocaching med Opencaching",
"subtitle2": ""
},
"locales": [ "da_DK.utf8", "da_DK", "dk" ]
}
}
}

View File

@ -0,0 +1,42 @@
{
"template": {
"locales": {
"EN": {
"show": true,
"flag": "images/flag/EN.png",
"name": "English"
}
}
},
"geokrety": {
"locales": {
"EN": "en_EN"
}
},
"locale": {
"EN": {
"country": "UK",
"format": {
"dm": "%m/%d",
"dateshort": "%m/%d/%y",
"date": "%x",
"datelong": "%B %d, %Y",
"datetime": "%x %I:%M %p",
"datetimesec": "%x %X",
"time": "%I:%M %p",
"timesec": "%X",
"phpdate": "m/d/Y",
"dot1000": ","
},
"page": {
"subtitle1": "Geocaching with Opencaching",
"subtitle2": "",
"license_url": "http://creativecommons.org/licenses/by-nc-nd/3.0/de/deed.en",
"license": "<a rel=\"license\" href=\"%1\"><img alt=\"Creative Commons License Terms\" style=\"border-width: 0;\" src=\"http://i.creativecommons.org/l/by-nc-nd/3.0/de/88x31.png\" /></a><div style=\"text-align: center; margin: 8px 0 0 6px;\">The Opencaching.de <a href=\"articles.php?page=impressum#datalicense\">content</a> is licensed under Creative Commons <a rel=\"license\" href=\"%1\" target=\"_blank\">BY-BC-ND 3.0 DE</a>.</div>"
},
"locales": [ "en_US.utf8", "en_US", "en" ]
}
}
}

View File

@ -0,0 +1,41 @@
{
"template": {
"locales": {
"ES": {
"show": true,
"flag": "images/flag/ES.png",
"name": "Español"
}
}
},
"geokrety": {
"locales": {
"ES": "es_ES.UTF-8"
}
},
"locale": {
"ES": {
"country": "ES",
"format": {
"dm": "%d/%m",
"dateshort": "%d/%m/%y",
"date": "%x",
"datelong": "%d. %B %Y",
"datetime": "%x %H:%M",
"datetimesec": "%x %X",
"time": "%H:%M",
"timesec": "%X",
"phpdate": "d/m/Y"
},
"page": {
"subtitle1": "Geocaching con Opencaching",
"subtitle2": "",
"license_url": "http://creativecommons.org/licenses/by-nc-nd/3.0/de/deed.es_ES",
"license": "<a rel=\"license\" href=\"%1\" target=\"_blank\"><img alt=\"Creative Commons License Terms\" style=\"border-width: 0;\" src=\"http://i.creativecommons.org/l/by-nc-nd/3.0/de/88x31.png\" /></a><div style=\"text-align: center; margin: 8px 0 0 6px;\">El <a href=\"articles.php?page=impressum#datalicense\">contenido</a> está disponible bajo Creative Commons <a rel=\"license\" href=\"%1\" target=\"_blank\">BY-NC-ND 3.0 DE</a> licencia.</div>"
},
"locales": [ "es_ES.utf8", "es_ES", "es" ]
}
}
}

View File

@ -0,0 +1,35 @@
{
"template": {
"locales": {
"FR": {
"show": true,
"flag": "images/flag/FR.png",
"name": "Français"
}
}
},
"geokrety": {
"locales": {
"FR": "fr_FR.UTF-8"
}
},
"locale": {
"FR": {
"country": "FR",
"format": {
"dm": "%d.%m.",
"dateshort": "%d.%m.%y",
"date": "%x",
"datelong": "%d. %B %Y",
"datetime": "%x %H:%M",
"datetimesec": "%x %X",
"time": "%H:%M",
"timesec": "%X",
"phpdate": "d-m-Y"
},
"locales": [ "fr_FR.utf8", "fr_FR@euro", "fr_FR", "french", "fr" ]
}
}
}

View File

@ -0,0 +1,41 @@
{
"template": {
"locales": {
"IT": {
"show": true,
"flag": "images/flag/IT.png",
"name": "Italiano"
}
}
},
"geokrety": {
"locales": {
"IT": "en_EN"
}
},
"locale": {
"IT": {
"country": "IT",
"format": {
"dm": "%d/%m",
"dateshort": "%d/%m/%y",
"date": "%x",
"datelong": "%d. %B %Y",
"datetime": "%x %H:%M",
"datetimesec": "%x %X",
"time": "%H:%M",
"timesec": "%X",
"phpdate": "d/m/Y"
},
"page": {
"subtitle1": "Geocaching con Opencaching",
"subtitle2": "",
"license_url": "http://creativecommons.org/licenses/by-nc-nd/3.0/de/deed.it",
"license": "<a rel=\"license\" href=\"%1\" target=\"_blank\"><img alt=\"Creative Commons License Terms\" style=\"border-width: 0;\" src=\"http://i.creativecommons.org/l/by-nc-nd/3.0/de/88x31.png\" /></a><div style=\"text-align: center; margin: 8px 0 0 6px;\">Il <a href=\"articles.php?page=impressum#datalicense\">contenuto</a> di Opencaching.de è rilasciato sotto licenza Creative Commons <a rel=\"license\" href=\"%1\" target=\"_blank\">BY-NC-ND 3.0 DE</a>.</div>"
},
"locales": [ "it_IT.utf8", "it_IT", "it" ]
}
}
}

View File

@ -0,0 +1,39 @@
{
"template": {
"locales": {
"JA": {
"show": true,
"flag": "images/flag/JP.png",
"name": "日本語"
}
}
},
"geokrety": {
"locales": {
"JA": "ja_JP.UTF-8"
}
},
"locale": {
"JA": {
"country": "JP",
"format": {
"dm": "%d.%m.",
"dateshort": "%d.%m.%y",
"date": "%Y-%m-%d",
"datelong": "%Y-%m-%d",
"datetime": "%x %H:%M",
"datetimesec": "%x %X",
"time": "%H:%M",
"timesec": "%X",
"phpdate": "d-m-Y"
},
"page": {
"subtitle1": "Opencachingとジオキャッシング",
"subtitle2": ""
},
"locales": [ "ja_JP.utf8", "ja_JP", "jp" ]
}
}
}

View File

@ -0,0 +1,39 @@
{
"template": {
"locales": {
"NL": {
"show": true,
"flag": "images/flag/NL.png",
"name": "Nederlands"
}
}
},
"geokrety": {
"locales": {
"NL": "en_EN"
}
},
"locale": {
"NL": {
"country": "NL",
"format": {
"dm": "%d.%m.",
"dateshort": "%d.%m.%y",
"date": "%x",
"datelong": "%d. %B %Y",
"datetime": "%x %H:%M",
"datetimesec": "%x %X",
"time": "%H:%M",
"timesec": "%X",
"phpdate": "d-m-Y"
},
"page": {
"subtitle1": "Geocaching met Opencaching",
"subtitle2": ""
},
"locales": [ "nl_NL.utf8", "nl_NL", "nl" ]
}
}
}

View File

@ -0,0 +1,39 @@
{
"template": {
"locales": {
"NO": {
"show": true,
"flag": "images/flag/NO.png",
"name": "Norsk"
}
}
},
"geokrety": {
"locales": {
"NO": "no_NO.UTF-8"
}
},
"locale": {
"NO": {
"country": "NO",
"format": {
"dm": "%d.%m.",
"dateshort": "%d.%m.%y",
"date": "%x",
"datelong": "%x",
"datetime": "%x %H:%M",
"datetimesec": "%x %X",
"time": "%H:%M",
"timesec": "%X",
"phpdate": "d.m.Y"
},
"page": {
"subtitle1": "Geocaching med Opencaching",
"subtitle2": ""
},
"locales": [ "no_NO.utf8", "no_NO", "no" ]
}
}
}

View File

@ -0,0 +1,35 @@
{
"template": {
"locales": {
"PL": {
"show": true,
"flag": "images/flag/PL.png",
"name": "Polski"
}
}
},
"geokrety": {
"locales": {
"PL": "pl_PL.UTF-8"
}
},
"locale": {
"PL": {
"country": "PL",
"format": {
"dm": "%d.%m.",
"dateshort": "%d.%m.%y",
"date": "%x",
"datelong": "%d. %B %Y",
"datetime": "%x %H:%M",
"datetimesec": "%x %X",
"time": "%H:%M",
"timesec": "%X",
"phpdate": "d-m-Y"
},
"locales": [ "pl_PL.utf8", "pl_PL", "pl" ]
}
}
}

View File

@ -0,0 +1,39 @@
{
"template": {
"locales": {
"PT": {
"show": true,
"flag": "images/flag/pt.png",
"name": "Portuguesa"
}
}
},
"geokrety": {
"locales": {
"PT": "pt_PT.UTF-8"
}
},
"locale": {
"PT": {
"country": "PT",
"format": {
"dm": "%d.%m.",
"dateshort": "%d.%m.%y",
"date": "%Y-%m-%d",
"datelong": "%Y-%m-%d",
"datetime": "%x %H:%M",
"datetimesec": "%x %X",
"time": "%H:%M",
"timesec": "%X",
"phpdate": "d-m-Y"
},
"page": {
"subtitle1": "Geocaching com Opencaching",
"subtitle2": ""
},
"locales": [ "pt_PT.utf8", "pt_PT", "pt" ]
}
}
}

View File

@ -0,0 +1,35 @@
{
"template": {
"locales": {
"RU": {
"show": true,
"flag": "images/flag/RU.png",
"name": "Русский"
}
}
},
"geokrety": {
"locales": {
"RU": "en_EN"
}
},
"locale": {
"RU": {
"country": "RU",
"format": {
"dm": "%d.%m.",
"dateshort": "%d.%m.%y",
"date": "%x",
"datelong": "%d. %B %Y",
"datetime": "%x %H:%M",
"datetimesec": "%x %X",
"time": "%H:%M",
"timesec": "%X",
"phpdate": "d-m-Y"
},
"locales": [ "ru_RU.utf8", "ru_RU", "ru" ]
}
}
}

View File

@ -0,0 +1,39 @@
{
"template": {
"locales": {
"SV": {
"show": true,
"flag": "images/flag/SE.png",
"name": "Svenska"
}
}
},
"geokrety": {
"locales": {
"SV": "sv_SE.UTF-8"
}
},
"locale": {
"SV": {
"country": "SE",
"format": {
"dm": "%d/%m",
"dateshort": "%y-%m-%d",
"date": "%Y-%m-%d",
"datelong": "%Y-%m-%d",
"datetime": "%x %H:%M",
"datetimesec": "%x %X",
"time": "%H:%M",
"timesec": "%X",
"phpdate": "Y-m-d"
},
"page": {
"subtitle1": "Geocaching med Opencaching",
"subtitle2": ""
},
"locales": [ "sv_SE.utf8", "sv_SE", "se" ]
}
}
}

View File

@ -0,0 +1,11 @@
parameters:
ocde.config.class: OpencachingDE\Config\Config
ocde.logging.class: OpencachingDE\Logging\ChromePhp
services:
ocde.config:
class: "%ocde.config.class%"
# Monolog/Symfony compatible name
logger:
class: "%ocde.logging.class%"

View File

@ -0,0 +1,5 @@
imports:
- { resource: services.yml }
parameters:
ocde.logging.class: OpencachingDE\Logging\Console

View File

@ -0,0 +1,18 @@
imports:
- { resource: services.yml }
parameters:
ocde.cookie.class: OpencachingDE\Util\Cookie
ocde.login.class: OpencachingDE\Auth\Login
services:
ocde.cookie:
class: "%ocde.cookie.class%"
arguments:
- @logger
ocde.login:
class: "%ocde.login.class%"
arguments:
- @ocde.cookie
- @logger

View File

@ -17,252 +17,29 @@
* $opt['locale']
***************************************************************************/
/* Locale definitions
*
*/
$opt['template']['locales']['DE']['show'] = true;
$opt['template']['locales']['DE']['flag'] = 'images/flag/DE.png';
$opt['template']['locales']['DE']['name'] = 'Deutsch';
$opt['template']['locales']['EN']['show'] = true;
$opt['template']['locales']['EN']['flag'] = 'images/flag/EN.png';
$opt['template']['locales']['EN']['name'] = 'English';
$opt['template']['locales']['IT']['show'] = true;
$opt['template']['locales']['IT']['flag'] = 'images/flag/IT.png';
$opt['template']['locales']['IT']['name'] = 'Italiano';
$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/flag/NO.png';
$opt['template']['locales']['NO']['name'] = 'Norsk';
if (!isset($opt)) {
$opt = array();
}
$opt['template']['locales']['FR']['show'] = true;
$opt['template']['locales']['FR']['flag'] = 'images/flag/FR.png';
$opt['template']['locales']['FR']['name'] = 'Français';
$opt['template']['locales']['NL']['show'] = true;
$opt['template']['locales']['NL']['flag'] = 'images/flag/NL.png';
$opt['template']['locales']['NL']['name'] = 'Nederlands';
$opt['template']['locales']['PL']['show'] = true;
$opt['template']['locales']['PL']['flag'] = 'images/flag/PL.png';
$opt['template']['locales']['PL']['name'] = 'Polski';
$opt['template']['locales']['RU']['show'] = true;
$opt['template']['locales']['RU']['flag'] = 'images/flag/RU.png';
$opt['template']['locales']['RU']['name'] = 'Русский';
$opt['template']['locales']['DA']['show'] = true; // da_DK
$opt['template']['locales']['DA']['flag'] = 'images/flags/dk.png';
$opt['template']['locales']['DA']['name'] = 'Danske';
$opt['template']['locales']['PT']['show'] = true; // pt_PT
$opt['template']['locales']['PT']['flag'] = 'images/flags/pt.png';
$opt['template']['locales']['PT']['name'] = 'Portuguesa';
$opt['template']['locales']['JA']['show'] = true; // ja_JP
$opt['template']['locales']['JA']['flag'] = 'images/flag/JP.png';
$opt['template']['locales']['JA']['name'] = '日本語';
// backwards compatibility
// geokrety language key association
$opt['geokrety']['locales']['DE'] = 'de_DE.UTF-8';
$opt['geokrety']['locales']['EN'] = 'en_EN';
$opt['geokrety']['locales']['IT'] = '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';
$locale_files = glob(__DIR__ . '/../config/locales/*.json', GLOB_NOSORT);
$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']['RU'] = 'en_EN';
$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']['IT']['locales'] = array('it_IT.utf8', 'it_IT', 'it');
$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']['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']['RU']['locales'] = array('ru_RU.utf8', 'ru_RU', 'ru');
$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']['format']['dm'] = '%m/%d';
$opt['locale']['EN']['format']['dateshort'] = '%m/%d/%y';
$opt['locale']['EN']['format']['date'] = '%x';
$opt['locale']['EN']['format']['datelong'] = '%B %d, %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']['format']['phpdate'] = 'm/d/Y';
$opt['locale']['EN']['format']['dot1000'] = ',';
$opt['locale']['EN']['country'] = 'UK';
$opt['locale']['EN']['page']['subtitle1'] = 'Geocaching with Opencaching';
$opt['locale']['EN']['page']['subtitle2'] = '';
$opt['locale']['EN']['page']['license_url'] = 'http://creativecommons.org/licenses/by-nc-nd/3.0/de/deed.en';
$opt['locale']['EN']['page']['license'] = '<a rel="license" href="%1"><img alt="Creative Commons License Terms" style="border-width:0" src="http://i.creativecommons.org/l/by-nc-nd/3.0/de/88x31.png" /></a><div style="text-align:center; margin:8px 0 0 6px;">The Opencaching.de <a href="articles.php?page=impressum#datalicense">content</a> is licensed under Creative Commons <a rel="license" href="%1" target="_blank">BY-BC-ND 3.0 DE</a>.</div>';
$opt['locale']['DE']['format']['dm'] = '%d.%m.';
$opt['locale']['DE']['format']['dateshort'] = '%d.%m.%y';
$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']['format']['phpdate'] = 'd.m.Y';
$opt['locale']['DE']['country'] = 'DE';
$opt['locale']['DE']['page']['subtitle1'] = 'Geocaching mit Opencaching';
$opt['locale']['DE']['page']['subtitle2'] = '';
$opt['locale']['DE']['page']['license_url'] = 'http://creativecommons.org/licenses/by-nc-nd/3.0/de/';
$opt['locale']['DE']['page']['license'] = '<a rel="license" href="%1"><img alt="Creative Commons Lizenzvertrag" style="border-width:0" src="http://i.creativecommons.org/l/by-nc-nd/3.0/de/88x31.png" /></a><div style="text-align:center; margin:8px 0 0 6px;">Die <a href="articles.php?page=impressum#datalicense">Inhalte</a> von Opencaching.de stehen unter der Creative-Commons-Lizenz <a rel="license" href="%1">BY-NC-ND 3.0 DE</a>.</div>';
$opt['locale']['DE']['helpwiki'] = "http://wiki.opencaching.de/index.php/";
$opt['locale']['IT']['format']['dateshort'] = '%d/%m/%y';
$opt['locale']['IT']['format']['dm'] = '%d/%m';
$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']['format']['phpdate'] = 'd/m/Y';
$opt['locale']['IT']['country'] = 'IT';
$opt['locale']['IT']['page']['subtitle1'] = 'Geocaching con Opencaching';
$opt['locale']['IT']['page']['subtitle2'] = '';
$opt['locale']['IT']['page']['license_url'] = 'http://creativecommons.org/licenses/by-nc-nd/3.0/de/deed.it';
$opt['locale']['IT']['page']['license'] = '<a rel="license" href="%1" target="_blank"><img alt="Creative Commons License Terms" style="border-width:0" src="http://i.creativecommons.org/l/by-nc-nd/3.0/de/88x31.png" /></a><div style="text-align:center; margin:8px 0 0 6px;">Il <a href="articles.php?page=impressum#datalicense">contenuto</a> di Opencaching.de è rilasciato sotto licenza Creative Commons <a rel="license" href="%1" target="_blank">BY-NC-ND 3.0 DE</a>.</div>';
$opt['locale']['ES']['format']['dateshort'] = '%d/%m/%y';
$opt['locale']['ES']['format']['dm'] = '%d/%m';
$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']['format']['phpdate'] = 'd/m/Y';
$opt['locale']['ES']['country'] = 'ES';
$opt['locale']['ES']['page']['subtitle1'] = 'Geocaching con Opencaching';
$opt['locale']['ES']['page']['subtitle2'] = '';
$opt['locale']['ES']['page']['license_url'] = 'http://creativecommons.org/licenses/by-nc-nd/3.0/de/deed.es_ES';
$opt['locale']['ES']['page']['license'] = '<a rel="license" href="%1" target="_blank"><img alt="Creative Commons License Terms" style="border-width:0" src="http://i.creativecommons.org/l/by-nc-nd/3.0/de/88x31.png" /></a><div style="text-align:center; margin:8px 0 0 6px;">El <a href="articles.php?page=impressum#datalicense">contenido</a> está disponible bajo Creative Commons <a rel="license" href="%1" target="_blank">BY-NC-ND 3.0 DE</a> licencia.</div>';
$opt['locale']['SV']['format']['dateshort'] = '%y-%m-%d';
$opt['locale']['SV']['format']['dm'] = '%d/%m';
$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']['format']['phpdate'] = 'Y-m-d';
$opt['locale']['SV']['country'] = 'SE';
$opt['locale']['SV']['page']['subtitle1'] = 'Geocaching med Opencaching';
$opt['locale']['SV']['page']['subtitle2'] = '';
$opt['locale']['NO']['format']['dateshort'] = '%d.%m.%y';
$opt['locale']['NO']['format']['dm'] = '%d.%m.';
$opt['locale']['NO']['format']['date'] = '%x';
$opt['locale']['NO']['format']['datelong'] = '%x';
$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']['format']['phpdate'] = 'd.m.Y';
$opt['locale']['NO']['country'] = 'NO';
$opt['locale']['NO']['page']['subtitle1'] = 'Geocaching med Opencaching';
$opt['locale']['NO']['page']['subtitle2'] = '';
$opt['locale']['FR']['format']['dm'] = '%d.%m.';
$opt['locale']['FR']['format']['dateshort'] = '%d.%m.%y';
$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']['format']['phpdate'] = 'd-m-Y';
$opt['locale']['FR']['country'] = 'FR';
$opt['locale']['PL']['format']['dm'] = '%d.%m.';
$opt['locale']['PL']['format']['dateshort'] = '%d.%m.%y';
$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']['format']['phpdate'] = 'd-m-Y';
$opt['locale']['PL']['country'] = 'PL';
$opt['locale']['NL']['format']['dm'] = '%d.%m.';
$opt['locale']['NL']['format']['dateshort'] = '%d.%m.%y';
$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']['format']['phpdate'] = 'd-m-Y';
$opt['locale']['NL']['page']['subtitle1'] = 'Geocaching met Opencaching';
$opt['locale']['NL']['page']['subtitle2'] = '';
$opt['locale']['NL']['country'] = 'NL';
$opt['locale']['RU']['format']['dateshort'] = '%d.%m.%y';
$opt['locale']['RU']['format']['dm'] = '%d.%m.';
$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']['format']['phpdate'] = 'd-m-Y';
$opt['locale']['RU']['country'] = 'RU';
$opt['locale']['DA']['format']['dateshort'] = '%d.%m.%y';
$opt['locale']['DA']['format']['dm'] = '%d.%m.';
$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']['format']['phpdate'] = 'd-m-Y';
$opt['locale']['DA']['country'] = 'DK';
$opt['locale']['DA']['page']['subtitle1'] = 'Geocaching med Opencaching';
$opt['locale']['DA']['page']['subtitle2'] = '';
$opt['locale']['PT']['format']['dateshort'] = '%d.%m.%y';
$opt['locale']['PT']['format']['dm'] = '%d.%m.';
$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']['format']['phpdate'] = 'd-m-Y';
$opt['locale']['PT']['country'] = 'PT';
$opt['locale']['PT']['page']['subtitle1'] = 'Geocaching com Opencaching';
$opt['locale']['PT']['page']['subtitle2'] = '';
$opt['locale']['JA']['format']['dateshort'] = '%d.%m.%y';
$opt['locale']['JA']['format']['dm'] = '%d.%m.';
$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']['format']['phpdate'] = 'd-m-Y';
$opt['locale']['JA']['country'] = 'JP';
$opt['locale']['JA']['page']['subtitle1'] = 'Opencachingとジオキャッシング';
$opt['locale']['JA']['page']['subtitle2'] = '';
?>
foreach ($locale_files as $locale_file) {
$json_data = file_get_contents($locale_file);
if (!is_string($json_data)) {
file_put_contents('/tmp/ocde.log', 'Contents of file "' . $locale_file . '" could not be read!', FILE_APPEND);
continue;
}
$data = json_decode($json_data, true);
if (!is_array($data)) {
file_put_contents('/tmp/ocde.log', 'Contents of file "' . $locale_file . '" is no JSON (Error ' . json_last_error() . ')!' . PHP_EOL . $json_data, FILE_APPEND);
continue;
}
$pre_opt = array_merge_recursive($opt, $data);
if (!is_array($pre_opt)) {
file_put_contents('/tmp/ocde.log', 'Contents of file "' . $locale_file . '" could not be merged!', FILE_APPEND);
continue;
}
$opt = $pre_opt;
}

View File

@ -110,6 +110,9 @@
$opt['lib']['garmin']['url'] = 'http://local.opencaching.de/';
$opt['lib']['garmin']['redirect'] = $opt['lib']['garmin']['url'] . 'garmin.php?redirect=1&cacheid={cacheid}';
// developer.what3words.com API Key
$opt['lib']['w3w']['apikey'] = 'YOURAPIKEY';
// other settings
$opt['page']['showdonations'] = true;
$opt['page']['showsocialmedia'] = true;

View File

@ -581,6 +581,9 @@
// (e.g. domain called without www. prefix) - must match domain of $opt['lib']['garmin']['url']
$opt['lib']['garmin']['redirect'] = 'http://www.site.org/garmin.php?redirect=1&cacheid={cacheid}';
// developer.what3words.com API key
$opt['lib']['w3w']['apikey'] = 'YOURAPIKEY';
// Google Maps API key
// http://code.google.com/intl/de/apis/maps/signup.html
$opt['lib']['google']['mapkey'] = array();

View File

@ -141,6 +141,9 @@
$opt['lib']['garmin']['key'] = '00112233445566778899AABBCCDDEEFF00';
$opt['lib']['garmin']['url'] = 'http://www.site.org/';
// developer.what3words.com API Key
$opt['lib']['w3w']['apikey'] = 'YOURAPIKEY';
$opt['logic']['node']['id'] = 4;
// Google Maps API key

View File

@ -5,45 +5,47 @@
* Unicode Reminder メモ
***************************************************************************/
require('./lib2/web.inc.php');
require_once('./lib2/logic/coordinate.class.php');
use \OpencachingDE\Conversions\Coordinate;
$tpl->name = 'coordinates';
$tpl->popup = true;
require('./lib2/web.inc.php');
$lat_float = 0;
if (isset($_REQUEST['lat']))
$lat_float += $_REQUEST['lat'];
$tpl->name = 'coordinates';
$tpl->popup = true;
$lon_float = 0;
if (isset($_REQUEST['lon']))
$lon_float += $_REQUEST['lon'];
$lat_float = 0;
if (isset($_REQUEST['lat'])) {
$lat_float += $_REQUEST['lat'];
}
$coord = new coordinate($lat_float, $lon_float);
$lon_float = 0;
if (isset($_REQUEST['lon'])) {
$lon_float += $_REQUEST['lon'];
}
$tpl->assign('coordDeg', $coord->getDecimal());
$tpl->assign('coordDegMin', $coord->getDecimalMinutes());
$tpl->assign('coordDegMinSec', $coord->getDecimalMinutesSeconds());
$tpl->assign('coordUTM', $coord->getUTM());
$tpl->assign('coordGK', $coord->getGK());
$tpl->assign('coordRD', $coord->getRD());
$tpl->assign('showRD', ($coord->nLat >= 45 && $coord->nLat <= 57 && $coord->nLon >= 0 && $coord->nLon <= 15));
$tpl->assign('coordQTH', $coord->getQTH());
$tpl->assign('coordSwissGrid', $coord->getSwissGrid());
$coord = new Coordinate($lat_float, $lon_float);
// wp gesetzt?
$wp = isset($_REQUEST['wp']) ? $_REQUEST['wp'] : '';
if ($wp != '')
{
$rs = sql("SELECT `caches`.`name`, `user`.`username` FROM `caches` INNER JOIN `cache_status` ON `caches`.`status`=`cache_status`.`id` INNER JOIN `user` ON `user`.`user_id`=`caches`.`user_id` WHERE `cache_status`.`allow_user_view`=1 AND `caches`.`wp_oc`='&1'", $wp);
if ($r = sql_fetch_array($rs))
{
$tpl->assign('owner', $r['username']);
$tpl->assign('cachename', $r['name']);
}
sql_free_result($rs);
}
$tpl->assign('wp', $wp);
$tpl->assign('coordDeg', $coord->getDecimal());
$tpl->assign('coordDegMin', $coord->getDecimalMinutes());
$tpl->assign('coordDegMinSec', $coord->getDecimalMinutesSeconds());
$tpl->assign('coordUTM', $coord->getUTM());
$tpl->assign('coordGK', $coord->getGK());
$tpl->assign('coordRD', $coord->getRD());
$tpl->assign('showRD', ($coord->nLat >= 45 && $coord->nLat <= 57 && $coord->nLon >= 0 && $coord->nLon <= 15));
$tpl->assign('coordQTH', $coord->getQTH());
$tpl->assign('coordSwissGrid', $coord->getSwissGrid());
$tpl->assign('coordW3Wde', $coord->getW3W('de'));
$tpl->assign('coordW3Wen', $coord->getW3W('en'));
$tpl->display();
?>
// wp gesetzt?
$wp = isset($_REQUEST['wp']) ? $_REQUEST['wp'] : '';
if ($wp != '') {
$rs = sql("SELECT `caches`.`name`, `user`.`username` FROM `caches` INNER JOIN `cache_status` ON `caches`.`status`=`cache_status`.`id` INNER JOIN `user` ON `user`.`user_id`=`caches`.`user_id` WHERE `cache_status`.`allow_user_view`=1 AND `caches`.`wp_oc`='&1'", $wp);
if ($r = sql_fetch_array($rs)) {
$tpl->assign('owner', $r['username']);
$tpl->assign('cachename', $r['name']);
}
sql_free_result($rs);
}
$tpl->assign('wp', $wp);
$tpl->display();

View File

@ -5,75 +5,75 @@
* Unicode Reminder メモ
***************************************************************************/
require('./lib2/web.inc.php');
$tpl->name = 'dbmaintain';
$tpl->menuitem = MNU_ADMIN_DBMAINTAIN;
require('./lib2/web.inc.php');
$tpl->name = 'dbmaintain';
$tpl->menuitem = MNU_ADMIN_DBMAINTAIN;
$login->verify();
if ($login->userid == 0)
$tpl->redirect('login.php?target=dbmaintain.php');
$GLOBALS['container']->get('ocde.login')->verify();
if ($GLOBALS['container']->get('ocde.login')->getUserId() == 0)
$tpl->redirect('login.php?target=dbmaintain.php');
if (($login->admin & ADMIN_MAINTAINANCE) != ADMIN_MAINTAINANCE)
$tpl->error(ERROR_NO_ACCESS);
if (($GLOBALS['container']->get('ocde.login')->isAdmin() & ADMIN_MAINTAINANCE) != ADMIN_MAINTAINANCE)
$tpl->error(ERROR_NO_ACCESS);
$procedures = array();
$procedures[] = 'sp_updateall_caches_descLanguages';
$procedures[] = 'sp_updateall_logstat';
$procedures[] = 'sp_updateall_hiddenstat';
$procedures[] = 'sp_updateall_watchstat';
$procedures[] = 'sp_updateall_ignorestat';
$procedures[] = 'sp_updateall_topratingstat';
$procedures[] = 'sp_updateall_cache_picturestat';
$procedures[] = 'sp_updateall_cachelog_picturestat';
$procedures[] = 'sp_updateall_cache_listingdates';
$procedures[] = 'sp_updateall_cachelog_logdates';
$procedures[] = 'sp_updateall_rating_dates';
$procedures = array();
$procedures[] = 'sp_updateall_caches_descLanguages';
$procedures[] = 'sp_updateall_logstat';
$procedures[] = 'sp_updateall_hiddenstat';
$procedures[] = 'sp_updateall_watchstat';
$procedures[] = 'sp_updateall_ignorestat';
$procedures[] = 'sp_updateall_topratingstat';
$procedures[] = 'sp_updateall_cache_picturestat';
$procedures[] = 'sp_updateall_cachelog_picturestat';
$procedures[] = 'sp_updateall_cache_listingdates';
$procedures[] = 'sp_updateall_cachelog_logdates';
$procedures[] = 'sp_updateall_rating_dates';
$tpl->assign('procedures', $procedures);
$tpl->assign('procedures', $procedures);
if (isset($_REQUEST['ok']))
{
$proc = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
if (isset($_REQUEST['ok']))
{
$proc = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
// if (sql_connect_maintenance() == false)
// $tpl->error(ERROR_DB_NO_ROOT);
// if (sql_connect_maintenance() == false)
// $tpl->error(ERROR_DB_NO_ROOT);
$bError = false;
if ($proc == 'sp_updateall_caches_descLanguages')
sql("CALL sp_updateall_caches_descLanguages(@c)");
else if ($proc == 'sp_updateall_logstat')
sql("CALL sp_updateall_logstat(@c)");
else if ($proc == 'sp_updateall_hiddenstat')
sql("CALL sp_updateall_hiddenstat(@c)");
else if ($proc == 'sp_updateall_watchstat')
sql("CALL sp_updateall_watchstat(@c)");
else if ($proc == 'sp_updateall_ignorestat')
sql("CALL sp_updateall_ignorestat(@c)");
else if ($proc == 'sp_updateall_topratingstat')
sql("CALL sp_updateall_topratingstat(@c)");
else if ($proc == 'sp_updateall_cache_picturestat')
sql("CALL sp_updateall_cache_picturestat(@c)");
else if ($proc == 'sp_updateall_cachelog_picturestat')
sql("CALL sp_updateall_cachelog_picturestat(@c)");
else if ($proc == 'sp_updateall_cache_listingdates')
sql("CALL sp_updateall_cache_listingdates(@c)");
else if ($proc == 'sp_updateall_cachelog_logdates')
sql("CALL sp_updateall_cachelog_logdates(@c)");
else if ($proc == 'sp_updateall_rating_dates')
sql("CALL sp_updateall_rating_dates(@c)");
else
{
$bError = true;
}
$bError = false;
if ($proc == 'sp_updateall_caches_descLanguages')
sql("CALL sp_updateall_caches_descLanguages(@c)");
else if ($proc == 'sp_updateall_logstat')
sql("CALL sp_updateall_logstat(@c)");
else if ($proc == 'sp_updateall_hiddenstat')
sql("CALL sp_updateall_hiddenstat(@c)");
else if ($proc == 'sp_updateall_watchstat')
sql("CALL sp_updateall_watchstat(@c)");
else if ($proc == 'sp_updateall_ignorestat')
sql("CALL sp_updateall_ignorestat(@c)");
else if ($proc == 'sp_updateall_topratingstat')
sql("CALL sp_updateall_topratingstat(@c)");
else if ($proc == 'sp_updateall_cache_picturestat')
sql("CALL sp_updateall_cache_picturestat(@c)");
else if ($proc == 'sp_updateall_cachelog_picturestat')
sql("CALL sp_updateall_cachelog_picturestat(@c)");
else if ($proc == 'sp_updateall_cache_listingdates')
sql("CALL sp_updateall_cache_listingdates(@c)");
else if ($proc == 'sp_updateall_cachelog_logdates')
sql("CALL sp_updateall_cachelog_logdates(@c)");
else if ($proc == 'sp_updateall_rating_dates')
sql("CALL sp_updateall_rating_dates(@c)");
else
{
$bError = true;
}
if ($bError == false)
{
$count = sql_value("SELECT @c", 0);
$tpl->assign('executed', true);
$tpl->assign('proc', $proc);
$tpl->assign('count', $count);
}
}
if ($bError == false)
{
$count = sql_value("SELECT @c", 0);
$tpl->assign('executed', true);
$tpl->assign('proc', $proc);
$tpl->assign('count', $count);
}
}
$tpl->display();
$tpl->display();
?>

View File

@ -1567,7 +1567,7 @@ INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('687', 'Send E-M
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('688', 'You have to enter a subject!', '2010-08-28 11:48:04');
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('689', 'You have to enter a content!', '2010-08-28 11:48:04');
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('690', 'Send my E-Mail address with this message', '2010-08-28 11:48:04');
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('691', 'This enables the receiver to answer your E-Mail directly with his E-Mail agent.', '2010-08-28 11:48:04');
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('691', 'This enables the receiver to answer your E-Mail directly with his E-Mail agent. You may enable this option by default in your <a href=\"myprofile.php\">user profile</a>.', '2010-08-28 11:48:04');
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('692', 'To protect you and us from abuse:', '2010-08-28 11:48:04');
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('693', 'Only E-Mail that regards Geocaching are allowed. Spaming is not allowed!', '2010-08-28 11:48:04');
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('694', 'All relevant informations will be logged (date/time, sender/receiver and IP address)', '2010-08-28 11:48:04');
@ -2599,6 +2599,10 @@ INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2171', 'Please
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2172', 'Yes, I want to recieve mailings about news and actions on opencaching.de. (max. 2-5 per year)', '2013-11-03 10:09:14');
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2173', 'No, I dont\'t want any mailings about news and actions on opencaching.de.', '2013-11-03 10:09:14');
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2174', 'Newsletter:', '2013-11-03 10:09:14');
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2175', 'Disclose my e-mail address by default when sending e-mails to other users.', '2015-05-25 19:50:00');
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2176', 'Planned events', '2013-11-03 10:09:14');
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2177', 'Another cache (<a href=\"viewcache.php?wp=%1\">%1</a>) exists at these coords. Maybe you pressed \"submit cache\" twice. To publish a cache with identical coords, enter other coords first, then edit the listing and change coords.', '2013-11-03 10:09:14');
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2178', 'GC waypoint is invalid, must be GCXXX...', '2013-11-03 10:09:14');
-- Table sys_trans_ref
SET NAMES 'utf8';
@ -5656,7 +5660,7 @@ INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUE
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('688', 'DE', 'Du musst einen Betreff angeben!', '2010-08-28 11:48:06');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('689', 'DE', 'Du musst einen Inhalt eingeben!', '2010-08-28 11:48:06');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('690', 'DE', 'Meine E-Mail-Adresse soll mit dieser E-Mail mitgesendet werden', '2010-08-28 11:48:06');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('691', 'DE', 'Damit kennt der Empfänger deine E-Mail-Adresse und hat die Möglichkeit, direkt auf die E-Mail zu antworten.', '2010-08-28 11:48:06');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('691', 'DE', 'Damit kennt der Empfänger deine E-Mail-Adresse und hat die Möglichkeit, direkt auf die E-Mail zu antworten. Diese Option kannst du in deinem <a href=\"myprofile.php\">Benutzerprofil</a> standardmäßig einschalten.', '2010-08-28 11:48:06');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('692', 'DE', 'Um Missbrauch zu verhindern, müssen wir zu eurem und auch unserem Schutz folgende Maßnahmen treffen:', '2010-08-28 11:48:06');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('693', 'DE', 'Es dürfen nur Emails zum Thema versendet werden; jede Form nicht notwendiger Belästigung \&ndash; z.B. Spam \&ndash; ist nicht erlaubt.', '2010-08-28 11:48:06');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('694', 'DE', 'Es werden alle relevanten Informationen protokolliert (Datum/Uhrzeit, Absender/Empfänger und IP-Adresse).', '2010-08-28 11:48:06');
@ -6687,6 +6691,10 @@ INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUE
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2172', 'DE', 'Ja, ich möchte Informationen zu Neuigkeiten und Aktionen auf opencaching.de per Email erhalten. (max. 2-5 pro Jahr)', '2013-11-03 10:09:14');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2173', 'DE', 'Nein, ich möchte keine Informationen zu Neuigkeiten und Aktionen auf opencaching.de per Email erhalten.', '2013-11-03 10:09:14');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2174', 'DE', 'Newsletter:', '2013-11-03 10:09:14');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2175', 'DE', 'Wenn ich andere Benutzer anschreibe, wird standardmäßig meine E-Mail-Adresse mitgeschickt.', '2015-05-25 19:50:00');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2176', 'DE', 'Geplante Events', '2013-11-03 10:09:14');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2177', 'DE', 'An diesen Koordinaten befindet sich bereits der Cache <a href=\"viewcache.php?wp=%1\">%1</a>. Vielleicht hast du mehrfach auf \"Cache senden\" geklickt. Wenn du tatsächlich einen weiteren Cache mit identischen Koordinaten veröffentlichen möchtest, lege ihn zunächst mit abweichenden Koordinaten an, bearbeite dann das Listing und ändere die Koordinaten.', '2013-11-03 10:09:14');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2178', 'DE', 'ungültiger GC-Wegpunkt, Format ist GCXXX...', '2013-11-03 10:09:14');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('1', 'EN', 'Reorder IDs', '2010-09-02 00:15:30');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2', 'EN', 'The database could not be reconnected.', '2010-08-28 11:48:07');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('3', 'EN', 'Testing please do not login', '2010-08-28 11:48:07');
@ -7347,7 +7355,7 @@ INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUE
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('688', 'EN', 'You have to enter a subject!', '2010-08-28 11:48:08');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('689', 'EN', 'You have to enter a content!', '2010-08-28 11:48:08');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('690', 'EN', 'Send my e-mail address with this message', '2010-08-28 11:48:08');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('691', 'EN', 'This enables the receiver to answer your e-mail directly using his e-mail client.', '2010-08-28 11:48:08');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('691', 'EN', 'This enables the receiver to answer your e-mail directly using his e-mail client. You may enable this option by default in your <a href="myprofile.php">user profile</a>.', '2010-08-28 11:48:08');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('692', 'EN', 'To protect you and us from abuse:', '2010-08-28 11:48:08');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('693', 'EN', 'Only e-mails concerning geocaching are allowed. Spamming is prohibited!', '2010-08-28 11:48:08');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('694', 'EN', 'All relevant information will be logged (date/time, sender/receiver and IP address).', '2010-08-28 11:48:08');
@ -8345,6 +8353,7 @@ INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUE
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2150', 'EN', 'This geocache is probably placed within the following protection areas:', '2011-05-23 22:19:23');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2151', 'EN', 'Also listed as', '2011-05-23 22:19:23');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2162', 'EN', 'Your log entries', '2010-08-28 11:48:07');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2175', 'EN', 'Disclose my e-mail address by default when sending e-mails to other users.', '2015-05-25 19:50:00');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('1', 'ES', 'Reordenar ID', '2010-12-09 00:17:55');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2', 'ES', 'La base de datos no se pudo conectar.', '2010-12-09 00:17:55');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('3', 'ES', 'En pruebas - por favor, no entre.', '2010-12-09 00:17:55');

View File

@ -15,6 +15,7 @@ CREATE TABLE `user` (
`last_email_problem` datetime default NULL,
`mailing_problems` int(10) unsigned NOT NULL default '0',
`accept_mailing` tinyint(1) NOT NULL default '1',
`usermail_send_addr` tinyint(1) unsigned NOT NULL default '0',
`latitude` double NOT NULL,
`longitude` double NOT NULL,
`is_active_flag` tinyint(1) NOT NULL,

File diff suppressed because it is too large Load Diff

View File

@ -1,308 +1,307 @@
<?php
/***************************************************************************
./editdesc.php
-------------------
begin : July 7 2004
./editdesc.php
-------------------
begin : July 7 2004
For license information see doc/license.txt
For license information see doc/license.txt
*****************************************************************************/
/****************************************************************************
Unicode Reminder メモ
edit a cache listing
used template(s): editcache
GET/POST Parameter: cacheid, desclang
edit a cache listing
used template(s): editcache
GET/POST Parameter: cacheid, desclang
****************************************************************************/
//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)
{
require($stylepath . '/editdesc.inc.php');
//prepare the templates and include all neccessary
require_once('./lib/common.inc.php');
//Preprocessing
if ($error == false)
{
require($stylepath . '/editdesc.inc.php');
// check for old-style parameters
if (isset($_REQUEST['cacheid']) && isset($_REQUEST['desclang']) && !isset($_REQUEST['descid'])) // Ocprop
{
$cache_id = $_REQUEST['cacheid']; // Ocprop
$desc_lang = $_REQUEST['desclang']; // Ocprop
// check for old-style parameters
if (isset($_REQUEST['cacheid']) && isset($_REQUEST['desclang']) && !isset($_REQUEST['descid'])) // Ocprop
{
$cache_id = $_REQUEST['cacheid']; // Ocprop
$desc_lang = $_REQUEST['desclang']; // Ocprop
$rs = sql("SELECT `id` FROM `cache_desc` WHERE `cache_id`='&1' AND `language`='&2'", $cache_id, $desc_lang);
if (mysql_num_rows($rs) == 1)
{
$r = sql_fetch_array($rs);
$descid = $r['id'];
}
else
{
tpl_errorMsg('editdesc', $error_desc_not_found);
}
sql_free_result($rs);
}
else
{
$descid = isset($_REQUEST['descid']) ? $_REQUEST['descid'] : 0;
if (is_numeric($descid) == false)
$descid = 0;
}
$rs = sql("SELECT `id` FROM `cache_desc` WHERE `cache_id`='&1' AND `language`='&2'", $cache_id, $desc_lang);
if (mysql_num_rows($rs) == 1)
{
$r = sql_fetch_array($rs);
$descid = $r['id'];
}
else
{
tpl_errorMsg('editdesc', $error_desc_not_found);
}
sql_free_result($rs);
}
else
{
$descid = isset($_REQUEST['descid']) ? $_REQUEST['descid'] : 0;
if (is_numeric($descid) == false)
$descid = 0;
}
if ($usr === false)
{
$tplname = 'login';
tpl_set_var('username', '');
tpl_set_var('target', htmlspecialchars('editdesc.php?descid=' . urlencode($descid), ENT_COMPAT, 'UTF-8'));
tpl_set_var('message_start', "");
tpl_set_var('message_end', "");
tpl_set_var('message', $login_required);
}
else
{
if ($usr === false)
{
$tplname = 'login';
tpl_set_var('username', '');
tpl_set_var('target', htmlspecialchars('editdesc.php?descid=' . urlencode($descid), ENT_COMPAT, 'UTF-8'));
tpl_set_var('message_start', "");
tpl_set_var('message_end', "");
tpl_set_var('message', $login_required);
}
else
{
$desc_rs = sql("SELECT `cache_desc`.`cache_id` `cache_id`, `cache_desc`.`node` `node`, `cache_desc`.`language` `language`, `caches`.`name` `name`, `caches`.`user_id` `user_id`, `caches`.`wp_oc`, `cache_desc`.`desc` `desc`, `cache_desc`.`hint` `hint`, `cache_desc`.`short_desc` `short_desc`, `cache_desc`.`desc_html` `desc_html`, `cache_desc`.`desc_htmledit` `desc_htmledit` FROM `caches`, `cache_desc` WHERE (`caches`.`cache_id` = `cache_desc`.`cache_id`) AND `cache_desc`.`id`='&1'", $descid);
$desc_record = sql_fetch_array($desc_rs);
sql_free_result($desc_rs);
$desc_rs = sql("SELECT `cache_desc`.`cache_id` `cache_id`, `cache_desc`.`node` `node`, `cache_desc`.`language` `language`, `caches`.`name` `name`, `caches`.`user_id` `user_id`, `caches`.`wp_oc`, `cache_desc`.`desc` `desc`, `cache_desc`.`hint` `hint`, `cache_desc`.`short_desc` `short_desc`, `cache_desc`.`desc_html` `desc_html`, `cache_desc`.`desc_htmledit` `desc_htmledit` FROM `caches`, `cache_desc` WHERE (`caches`.`cache_id` = `cache_desc`.`cache_id`) AND `cache_desc`.`id`='&1'", $descid);
$desc_record = sql_fetch_array($desc_rs);
sql_free_result($desc_rs);
if ($desc_record !== false)
{
$desc_lang = $desc_record['language'];
$cache_id = $desc_record['cache_id'];
if ($desc_record !== false)
{
$desc_lang = $desc_record['language'];
$cache_id = $desc_record['cache_id'];
if ($desc_record['node'] != $oc_nodeid)
{
tpl_errorMsg('editdesc', $error_wrong_node);
exit;
}
if ($desc_record['node'] != $oc_nodeid)
{
tpl_errorMsg('editdesc', $error_wrong_node);
exit;
}
if ($desc_record['user_id'] == $usr['userid'] || $login->listingAdmin())
{
$tplname = 'editdesc';
if ($desc_record['user_id'] == $usr['userid'] || $GLOBALS['container']->get('ocde.login')->listingAdmin())
{
$tplname = 'editdesc';
tpl_set_var('desc_err', '');
$show_all_langs = false;
tpl_set_var('desc_err', '');
$show_all_langs = false;
//save to DB?
if (isset($_POST['post'])) // Ocprop
{
//here we read all used information from the form if submitted
$descMode = isset($_POST['descMode']) ? $_POST['descMode'] : 1; // Ocprop
//save to DB?
if (isset($_POST['post'])) // Ocprop
{
//here we read all used information from the form if submitted
$descMode = isset($_POST['descMode']) ? $_POST['descMode'] : 1; // Ocprop
// 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'];
}
// 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'];
}
switch ($descMode)
{
case 2:
$desc_htmledit = 0;
$desc_html = 1;
break;
case 3:
$desc_htmledit = 1;
$desc_html = 1;
break;
default:
$desc_htmledit = 0;
$desc_html = 0;
break;
}
$short_desc = $_POST['short_desc']; // Ocprop
$hint = htmlspecialchars($_POST['hints'], ENT_COMPAT, 'UTF-8');
$desclang = $_POST['desclang'];
$show_all_langs = isset($_POST['show_all_langs_value']) ? $_POST['show_all_langs_value'] : 0;
if (!is_numeric($show_all_langs)) $show_all_langs = 0;
switch ($descMode)
{
case 2:
$desc_htmledit = 0;
$desc_html = 1;
break;
case 3:
$desc_htmledit = 1;
$desc_html = 1;
break;
default:
$desc_htmledit = 0;
$desc_html = 0;
break;
}
$short_desc = $_POST['short_desc']; // Ocprop
$hint = htmlspecialchars($_POST['hints'], ENT_COMPAT, 'UTF-8');
$desclang = $_POST['desclang'];
$show_all_langs = isset($_POST['show_all_langs_value']) ? $_POST['show_all_langs_value'] : 0;
if (!is_numeric($show_all_langs)) $show_all_langs = 0;
// fuer alte Versionen von OCProp
if (isset($_POST['submit']) && !isset($_POST['version2']))
{
$short_desc = iconv("ISO-8859-1", "UTF-8", $short_desc);
$hint = iconv("ISO-8859-1", "UTF-8", $hint);
}
// fuer alte Versionen von OCProp
if (isset($_POST['submit']) && !isset($_POST['version2']))
{
$short_desc = iconv("ISO-8859-1", "UTF-8", $short_desc);
$hint = iconv("ISO-8859-1", "UTF-8", $hint);
}
if ($desc_html == 1)
{
// Text from textarea
$desc = $_POST['desc']; // Ocprop
// fuer alte Versionen von OCProp
if (isset($_POST['submit']) && !isset($_POST['version2']))
{
$desc = iconv("ISO-8859-1", "UTF-8", $desc);
}
if ($desc_html == 1)
{
// Text from textarea
$desc = $_POST['desc']; // Ocprop
// fuer alte Versionen von OCProp
if (isset($_POST['submit']) && !isset($_POST['version2']))
{
$desc = iconv("ISO-8859-1", "UTF-8", $desc);
}
// Filter Input
$purifier = new HTMLPurifier();
$desc = $purifier->purify($desc);
}
else
{
// escape text
$desc = htmlspecialchars($_POST['desc'], ENT_COMPAT, 'UTF-8');
// Filter Input
$purifier = new HTMLPurifier();
$desc = $purifier->purify($desc);
}
else
{
// escape text
$desc = htmlspecialchars($_POST['desc'], ENT_COMPAT, 'UTF-8');
// fuer alte Versionen von OCProp
if (isset($_POST['submit']) && !isset($_POST['version2']))
{
$desc = iconv("ISO-8859-1", "UTF-8", $desc);
}
}
// fuer alte Versionen von OCProp
if (isset($_POST['submit']) && !isset($_POST['version2']))
{
$desc = iconv("ISO-8859-1", "UTF-8", $desc);
}
}
if (isset($_POST['submitform'])) // Ocprop
{
// prüfen, ob sprache nicht schon vorhanden
$rs = sql("SELECT COUNT(*) `count` FROM `cache_desc` WHERE `cache_id`='&1' AND `id` != '&2' AND `language`='&3'", $desc_record['cache_id'], $descid, $desclang);
$r = sql_fetch_array($rs);
if ($r['count'] > 0)
tpl_errorMsg('editdesc', $error_desc_exists);
mysql_free_result($rs);
sql("UPDATE `cache_desc` SET
`desc_html`='&1',
`desc_htmledit`='&2',
`desc`='&3',
`short_desc`='&4',
`hint`='&5',
`language`='&6'
WHERE `id`='&7'",
(($desc_html == 1) ? '1' : '0'),
(($desc_htmledit == 1) ? '1' : '0'),
(($desc_html == 1) ? $desc : nl2br($desc)),
$short_desc,
nl2br($hint),
$desclang,
$descid);
if (isset($_POST['submitform'])) // Ocprop
{
// prüfen, ob sprache nicht schon vorhanden
$rs = sql("SELECT COUNT(*) `count` FROM `cache_desc` WHERE `cache_id`='&1' AND `id` != '&2' AND `language`='&3'", $desc_record['cache_id'], $descid, $desclang);
$r = sql_fetch_array($rs);
if ($r['count'] > 0)
tpl_errorMsg('editdesc', $error_desc_exists);
mysql_free_result($rs);
sql("UPDATE `cache_desc` SET
`desc_html`='&1',
`desc_htmledit`='&2',
`desc`='&3',
`short_desc`='&4',
`hint`='&5',
`language`='&6'
WHERE `id`='&7'",
(($desc_html == 1) ? '1' : '0'),
(($desc_htmledit == 1) ? '1' : '0'),
(($desc_html == 1) ? $desc : nl2br($desc)),
$short_desc,
nl2br($hint),
$desclang,
$descid);
// send notification on admin intervention
if ($desc_record['user_id'] != $usr['userid'] &&
$opt['logic']['admin']['listingadmin_notification'] != '')
{
mail(
$opt['logic']['admin']['listingadmin_notification'],
mb_ereg_replace('{occode}', $desc_record['wp_oc'],
mb_ereg_replace('{username}', $usr['username'],
t('The cache description of {occode} has been modified by {username}'))),
'');
}
// send notification on admin intervention
if ($desc_record['user_id'] != $usr['userid'] &&
$opt['logic']['admin']['listingadmin_notification'] != '')
{
mail(
$opt['logic']['admin']['listingadmin_notification'],
mb_ereg_replace('{occode}', $desc_record['wp_oc'],
mb_ereg_replace('{username}', $usr['username'],
t('The cache description of {occode} has been modified by {username}'))),
'');
}
// do not use slave server for the next time ...
db_slave_exclude();
// do not use slave server for the next time ...
db_slave_exclude();
// redirect to cachepage
tpl_redirect('editcache.php?cacheid=' . urlencode($desc_record['cache_id']));
exit;
}
else if (isset($_POST['show_all_langs']))
{
$show_all_langs = true;
}
}
else
{
//here we read all used information from the DB
$short_desc = strip_tags($desc_record['short_desc']);
$hint = strip_tags($desc_record['hint']);
$desc_htmledit = $desc_record['desc_htmledit'];
$desc_html = $desc_record['desc_html'];
$desc_lang = $desc_record['language'];
// redirect to cachepage
tpl_redirect('editcache.php?cacheid=' . urlencode($desc_record['cache_id']));
exit;
}
else if (isset($_POST['show_all_langs']))
{
$show_all_langs = true;
}
}
else
{
//here we read all used information from the DB
$short_desc = strip_tags($desc_record['short_desc']);
$hint = strip_tags($desc_record['hint']);
$desc_htmledit = $desc_record['desc_htmledit'];
$desc_html = $desc_record['desc_html'];
$desc_lang = $desc_record['language'];
if ($desc_html == 1)
$desc = $desc_record['desc'];
else{
$desc = strip_tags($desc_record['desc']);
}
}
//here we only set up the template variables
if ($desc_html == 1)
tpl_set_var('desc', htmlspecialchars($desc, ENT_COMPAT, 'UTF-8'), true);
else
tpl_set_var('desc', $desc, true);
// ok ... die desclang zusammenbauen
if ($show_all_langs == false)
{
$rs = sql("SELECT `show` FROM `languages_list_default` WHERE `show`='&1' AND `lang`='&2'", $desc_lang, $locale);
if (mysql_num_rows($rs) == 0) $show_all_langs = true;
sql_free_result($rs);
}
if ($desc_html == 1)
$desc = $desc_record['desc'];
else{
$desc = strip_tags($desc_record['desc']);
}
}
//here we only set up the template variables
if ($desc_html == 1)
tpl_set_var('desc', htmlspecialchars($desc, ENT_COMPAT, 'UTF-8'), true);
else
tpl_set_var('desc', $desc, true);
// ok ... die desclang zusammenbauen
if ($show_all_langs == false)
{
$rs = sql("SELECT `show` FROM `languages_list_default` WHERE `show`='&1' AND `lang`='&2'", $desc_lang, $locale);
if (mysql_num_rows($rs) == 0) $show_all_langs = true;
sql_free_result($rs);
}
$languages = '';
$rsLanguages = sql("SELECT `languages`.`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`='&3'
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`='&3'
WHERE `languages`.`short`
NOT IN (SELECT `language` FROM `cache_desc` WHERE `cache_id`='&1' AND `language`!='&2') AND
('&4'=1 OR `languages_list_default`.`show`=`languages`.`short`)
ORDER BY `name` ASC",
$desc_record['cache_id'],
$desc_lang,
$locale,
($show_all_langs == true) ? 1 : 0);
while ($rLanguage = sql_fetch_assoc($rsLanguages))
{
$sSelected = ($rLanguage['short'] == $desc_lang) ? ' selected="selected"' : '';
$languages .= '<option value="' . $rLanguage['short'] . '"' . $sSelected . '>' . htmlspecialchars($rLanguage['name'], ENT_COMPAT, 'UTF-8') . '</option>' . "\n";
}
sql_free_result($rsLanguages);
$languages = '';
$rsLanguages = sql("SELECT `languages`.`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`='&3'
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`='&3'
WHERE `languages`.`short`
NOT IN (SELECT `language` FROM `cache_desc` WHERE `cache_id`='&1' AND `language`!='&2') AND
('&4'=1 OR `languages_list_default`.`show`=`languages`.`short`)
ORDER BY `name` ASC",
$desc_record['cache_id'],
$desc_lang,
$locale,
($show_all_langs == true) ? 1 : 0);
while ($rLanguage = sql_fetch_assoc($rsLanguages))
{
$sSelected = ($rLanguage['short'] == $desc_lang) ? ' selected="selected"' : '';
$languages .= '<option value="' . $rLanguage['short'] . '"' . $sSelected . '>' . htmlspecialchars($rLanguage['name'], ENT_COMPAT, 'UTF-8') . '</option>' . "\n";
}
sql_free_result($rsLanguages);
tpl_set_var('desclangs', $languages);
if ($show_all_langs == false)
tpl_set_var('show_all_langs_submit', $show_all_langs_submit);
else
tpl_set_var('show_all_langs_submit', '');
tpl_set_var('show_all_langs_value', (($show_all_langs == false) ? 0 : 1));
tpl_set_var('short_desc', htmlspecialchars($short_desc, ENT_COMPAT, 'UTF-8'));
tpl_set_var('hints', $hint);
tpl_set_var('descid', $descid);
tpl_set_var('cacheid', htmlspecialchars($desc_record['cache_id'], ENT_COMPAT, 'UTF-8'));
tpl_set_var('desclang', htmlspecialchars($desc_lang, ENT_COMPAT, 'UTF-8'));
tpl_set_var('desclang_name', htmlspecialchars(db_LanguageFromShort($desc_lang), ENT_COMPAT, 'UTF-8'));
tpl_set_var('cachename', htmlspecialchars($desc_record['name'], ENT_COMPAT, 'UTF-8'));
tpl_set_var('reset', $reset); // obsolete
tpl_set_var('submit', $submit);
tpl_set_var('desclangs', $languages);
if ($show_all_langs == false)
tpl_set_var('show_all_langs_submit', $show_all_langs_submit);
else
tpl_set_var('show_all_langs_submit', '');
tpl_set_var('show_all_langs_value', (($show_all_langs == false) ? 0 : 1));
tpl_set_var('short_desc', htmlspecialchars($short_desc, ENT_COMPAT, 'UTF-8'));
tpl_set_var('hints', $hint);
tpl_set_var('descid', $descid);
tpl_set_var('cacheid', htmlspecialchars($desc_record['cache_id'], ENT_COMPAT, 'UTF-8'));
tpl_set_var('desclang', htmlspecialchars($desc_lang, ENT_COMPAT, 'UTF-8'));
tpl_set_var('desclang_name', htmlspecialchars(db_LanguageFromShort($desc_lang), ENT_COMPAT, 'UTF-8'));
tpl_set_var('cachename', htmlspecialchars($desc_record['name'], ENT_COMPAT, 'UTF-8'));
tpl_set_var('reset', $reset); // obsolete
tpl_set_var('submit', $submit);
// Text / normal HTML / HTML editor
tpl_set_var('use_tinymce', (($desc_htmledit == 1) ? 1 : 0));
// Text / normal HTML / HTML editor
tpl_set_var('use_tinymce', (($desc_htmledit == 1) ? 1 : 0));
if (($desc_html == 1) && ($desc_htmledit == 1))
{
// TinyMCE
$headers = tpl_get_var('htmlheaders') . "\n";
$headers .= '<script language="javascript" type="text/javascript" src="resource2/tinymce/tiny_mce_gzip.js"></script>' . "\n";
if (($desc_html == 1) && ($desc_htmledit == 1))
{
// 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=' . ($desc_record['cache_id']+0) . '&lang=' . strtolower($locale) . '"></script>' . "\n";
tpl_set_var('htmlheaders', $headers);
tpl_set_var('htmlheaders', $headers);
tpl_set_var('descMode', 3);
}
else if ($desc_html == 1)
tpl_set_var('descMode', 2);
else
tpl_set_var('descMode', 1);
}
else
{
//TODO: not the owner
}
}
else
tpl_errorMsg('editdesc', $error_desc_not_found);
}
}
//make the template and send it out
tpl_BuildTemplate();
tpl_set_var('descMode', 3);
}
else if ($desc_html == 1)
tpl_set_var('descMode', 2);
else
tpl_set_var('descMode', 1);
}
else
{
//TODO: not the owner
}
}
else
tpl_errorMsg('editdesc', $error_desc_not_found);
}
}
//make the template and send it out
tpl_BuildTemplate();
?>

View File

@ -1,401 +1,399 @@
<?php
/***************************************************************************
./editlog.php
-------------------
begin : July 5 2004
./editlog.php
-------------------
begin : July 5 2004
For license information see doc/license.txt
For license information see doc/license.txt
*****************************************************************************/
/****************************************************************************
Unicode Reminder メモ
edit a log listing
edit a log listing
used template(s): editlog
used template(s): editlog
GET/POST Parameter: logid
Note: when changing recommendation, the last_modified-date of log-record
has to be updated to trigger resync via xml-interface
GET/POST Parameter: logid
Note: when changing recommendation, the last_modified-date of log-record
has to be updated to trigger resync via xml-interface
****************************************************************************/
//prepare the templates and include all neccessary
require_once('./lib/common.inc.php');
require_once('./lib2/logic/logtypes.inc.php');
require($stylepath.'/smilies.inc.php');
require_once($opt['rootpath'] . '../lib/htmlpurifier-4.2.0/library/HTMLPurifier.auto.php');
require_once('./lib/recommendation.inc.php');
require_once('./lib/common.inc.php');
require_once('./lib2/logic/logtypes.inc.php');
require($stylepath.'/smilies.inc.php');
require_once('./lib/recommendation.inc.php');
//Preprocessing
if ($error == false)
{
//logid
$log_id = 0;
if (isset($_REQUEST['logid'])) // Ocprop
{
$log_id = $_REQUEST['logid'];
}
//Preprocessing
if ($error == false)
{
//logid
$log_id = 0;
if (isset($_REQUEST['logid'])) // Ocprop
{
$log_id = $_REQUEST['logid'];
}
if ($usr === false)
{
$tplname = 'login';
if ($usr === false)
{
$tplname = 'login';
tpl_set_var('username', '');
tpl_set_var('message_start', '');
tpl_set_var('message_end', '');
tpl_set_var('target', 'editlog.php?logid=' . urlencode($log_id));
tpl_set_var('message', $login_required);
}
else
{
$useradmin = ($login->admin & ADMIN_USER) ? 1 : 0;
tpl_set_var('username', '');
tpl_set_var('message_start', '');
tpl_set_var('message_end', '');
tpl_set_var('target', 'editlog.php?logid=' . urlencode($log_id));
tpl_set_var('message', $login_required);
}
else
{
$useradmin = ($GLOBALS['container']->get('ocde.login')->isAdmin() & ADMIN_USER) ? 1 : 0;
//does log with this logid exist?
$log_rs = sql("SELECT `cache_logs`.`cache_id` AS `cache_id`,
`cache_logs`.`node` AS `node`,
`cache_logs`.`text` AS `text`,
`cache_logs`.`date` AS `date`,
`cache_logs`.`user_id` AS `user_id`,
`cache_logs`.`type` AS `logtype`,
`cache_logs`.`oc_team_comment` AS `oc_team_comment`,
`cache_logs`.`text_html` AS `text_html`,
`cache_logs`.`text_htmledit` AS `text_htmledit`,
`caches`.`name` AS `cachename`,
`caches`.`type` AS `cachetype`,
`caches`.`user_id` AS `cache_user_id`,
`caches`.`logpw` as `logpw`,
`caches`.`status` as `status`
FROM `cache_logs`
INNER JOIN `caches` ON (`caches`.`cache_id`=`cache_logs`.`cache_id`) WHERE `id`='&1'",
$log_id);
$log_record = sql_fetch_array($log_rs);
sql_free_result($log_rs);
//does log with this logid exist?
$log_rs = sql("SELECT `cache_logs`.`cache_id` AS `cache_id`,
`cache_logs`.`node` AS `node`,
`cache_logs`.`text` AS `text`,
`cache_logs`.`date` AS `date`,
`cache_logs`.`user_id` AS `user_id`,
`cache_logs`.`type` AS `logtype`,
`cache_logs`.`oc_team_comment` AS `oc_team_comment`,
`cache_logs`.`text_html` AS `text_html`,
`cache_logs`.`text_htmledit` AS `text_htmledit`,
`caches`.`name` AS `cachename`,
`caches`.`type` AS `cachetype`,
`caches`.`user_id` AS `cache_user_id`,
`caches`.`logpw` as `logpw`,
`caches`.`status` as `status`
FROM `cache_logs`
INNER JOIN `caches` ON (`caches`.`cache_id`=`cache_logs`.`cache_id`) WHERE `id`='&1'",
$log_id);
$log_record = sql_fetch_array($log_rs);
sql_free_result($log_rs);
if ($log_record !== false &&
(($log_record['status'] != 6 || ($log_record['cache_user_id'] == $login->userid && $log_record['user_id'] == $login->userid)) &&
$log_record['status'] != 7) || $useradmin)
{
require($stylepath . '/editlog.inc.php');
require($stylepath.'/rating.inc.php');
if ($log_record !== false &&
(($log_record['status'] != 6 || ($log_record['cache_user_id'] == $GLOBALS['container']->get('ocde.login')->getUserId() && $log_record['user_id'] == $GLOBALS['container']->get('ocde.login')->getUserId())) &&
$log_record['status'] != 7) || $useradmin)
{
require($stylepath . '/editlog.inc.php');
require($stylepath.'/rating.inc.php');
if ($log_record['node'] != $oc_nodeid)
{
tpl_errorMsg('editlog', $error_wrong_node);
exit;
}
if ($log_record['node'] != $oc_nodeid)
{
tpl_errorMsg('editlog', $error_wrong_node);
exit;
}
//is this log from this user?
if ($log_record['user_id'] == $usr['userid'])
{
$tplname = 'editlog';
//is this log from this user?
if ($log_record['user_id'] == $usr['userid'])
{
$tplname = 'editlog';
//load settings
$cache_name = $log_record['cachename'];
$cache_type = $log_record['cachetype'];
$cache_user_id = $log_record['cache_user_id'];
//load settings
$cache_name = $log_record['cachename'];
$cache_type = $log_record['cachetype'];
$cache_user_id = $log_record['cache_user_id'];
// Ocprop:
// logtype, logday, logmonth, logyear, rating, submitform
// Ocprop:
// logtype, logday, logmonth, logyear, rating, submitform
$log_type = isset($_POST['logtype']) ? $_POST['logtype'] : $log_record['logtype'];
$log_date_day = isset($_POST['logday']) ? trim($_POST['logday']) : date('d', strtotime($log_record['date']));
$log_date_month = isset($_POST['logmonth']) ? trim($_POST['logmonth']) : date('m', strtotime($log_record['date']));
$log_date_year = isset($_POST['logyear']) ? trim($_POST['logyear']) : date('Y', strtotime($log_record['date']));
$log_time_hour = isset($_POST['loghour']) ? trim($_POST['loghour']) : (substr($log_record['date'],11) == "00:00:00" ? "" : date('H', strtotime($log_record['date'])));
$log_time_minute = isset($_POST['logminute']) ? trim($_POST['logminute']) : (substr($log_record['date'],11) == "00:00:00" ? "" : date('i', strtotime($log_record['date'])));
$top_option = isset($_POST['ratingoption']) ? $_POST['ratingoption']+0 : 0;
$top_cache = isset($_POST['rating']) ? $_POST['rating']+0 : 0;
$oc_team_comment = isset($_POST['submitform']) ? @$_POST['teamcomment']+0 : ($log_record['oc_team_comment'] == 1);
$log_type = isset($_POST['logtype']) ? $_POST['logtype'] : $log_record['logtype'];
$log_date_day = isset($_POST['logday']) ? trim($_POST['logday']) : date('d', strtotime($log_record['date']));
$log_date_month = isset($_POST['logmonth']) ? trim($_POST['logmonth']) : date('m', strtotime($log_record['date']));
$log_date_year = isset($_POST['logyear']) ? trim($_POST['logyear']) : date('Y', strtotime($log_record['date']));
$log_time_hour = isset($_POST['loghour']) ? trim($_POST['loghour']) : (substr($log_record['date'],11) == "00:00:00" ? "" : date('H', strtotime($log_record['date'])));
$log_time_minute = isset($_POST['logminute']) ? trim($_POST['logminute']) : (substr($log_record['date'],11) == "00:00:00" ? "" : date('i', strtotime($log_record['date'])));
$top_option = isset($_POST['ratingoption']) ? $_POST['ratingoption']+0 : 0;
$top_cache = isset($_POST['rating']) ? $_POST['rating']+0 : 0;
$oc_team_comment = isset($_POST['submitform']) ? @$_POST['teamcomment']+0 : ($log_record['oc_team_comment'] == 1);
$log_pw = '';
$use_log_pw = (($log_record['logpw'] == NULL) || ($log_record['logpw'] == '')) ? false : true;
if (($use_log_pw) && $log_record['logtype']==1)
$use_log_pw = false;
$log_pw = '';
$use_log_pw = (($log_record['logpw'] == NULL) || ($log_record['logpw'] == '')) ? false : true;
if (($use_log_pw) && $log_record['logtype']==1)
$use_log_pw = false;
if ($use_log_pw)
$log_pw = $log_record['logpw'];
if ($use_log_pw)
$log_pw = $log_record['logpw'];
// check if user has exceeded his top 10% limit
$is_top = sqlValue("SELECT COUNT(`cache_id`) FROM `cache_rating` WHERE `user_id`='" . sql_escape($usr['userid']) . "' AND `cache_id`='" . sql_escape($log_record['cache_id']) . "'", 0);
$user_founds = sqlValue("SELECT IFNULL(`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);
// check if user has exceeded his top 10% limit
$is_top = sqlValue("SELECT COUNT(`cache_id`) FROM `cache_rating` WHERE `user_id`='" . sql_escape($usr['userid']) . "' AND `cache_id`='" . sql_escape($log_record['cache_id']) . "'", 0);
$user_founds = sqlValue("SELECT IFNULL(`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 ($is_top || ($user_tops < floor($user_founds * rating_percentage/100)))
{
$rating_msg = mb_ereg_replace('{chk_sel}', ($is_top ? '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 ($is_top || ($user_tops < floor($user_founds * rating_percentage/100)))
{
$rating_msg = mb_ereg_replace('{chk_sel}', ($is_top ? '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;
}
if ($user_tops)
$rating_msg .= '<br />'.$rating_maywithdraw;
}
tpl_set_var('rating_message', mb_ereg_replace('{rating_msg}', $rating_msg, $rating_tpl));
tpl_set_var('rating_message', mb_ereg_replace('{rating_msg}', $rating_msg, $rating_tpl));
if (isset($_POST['descMode'])) // Ocprop: 2
{
$descMode = $_POST['descMode']+0;
if (($descMode < 1) || ($descMode > 3)) $descMode = 3;
}
else
{
if ($log_record['text_html'] == 1)
if ($log_record['text_htmledit'] == 1)
$descMode = 3;
else
$descMode = 2;
else
$descMode = 1;
}
if (isset($_POST['descMode'])) // Ocprop: 2
{
$descMode = $_POST['descMode']+0;
if (($descMode < 1) || ($descMode > 3)) $descMode = 3;
}
else
{
if ($log_record['text_html'] == 1)
if ($log_record['text_htmledit'] == 1)
$descMode = 3;
else
$descMode = 2;
else
$descMode = 1;
}
// fuer alte Versionen von OCProp
if (isset($_POST['submit']) && !isset($_POST['version2']))
{
$descMode = 1;
$_POST['submitform'] = $_POST['submit'];
}
// fuer alte Versionen von OCProp
if (isset($_POST['submit']) && !isset($_POST['version2']))
{
$descMode = 1;
$_POST['submitform'] = $_POST['submit'];
}
if ($descMode != 1)
{
// Text from textarea; Ocprop
$log_text = isset($_POST['logtext']) ? ($_POST['logtext']) : ($log_record['text']);
if ($descMode != 1)
{
// Text from textarea; Ocprop
$log_text = isset($_POST['logtext']) ? ($_POST['logtext']) : ($log_record['text']);
// fuer alte Versionen von OCProp
if (isset($_POST['submit']) && !isset($_POST['version2']))
{
$log_text = iconv("ISO-8859-1", "UTF-8", $log_text);
}
// fuer alte Versionen von OCProp
if (isset($_POST['submit']) && !isset($_POST['version2']))
{
$log_text = iconv("ISO-8859-1", "UTF-8", $log_text);
}
// check input
$purifier = new HTMLPurifier();
$log_text = $purifier->purify($log_text);
}
else
{
// escape text
$log_text = isset($_POST['logtext']) ? htmlspecialchars($_POST['logtext'], ENT_COMPAT, 'UTF-8') : strip_tags($log_record['text']);
// check input
$purifier = new HTMLPurifier();
$log_text = $purifier->purify($log_text);
}
else
{
// escape text
$log_text = isset($_POST['logtext']) ? htmlspecialchars($_POST['logtext'], ENT_COMPAT, 'UTF-8') : strip_tags($log_record['text']);
// fuer alte Versionen von OCProp
if (isset($_POST['submit']) && !isset($_POST['version2']))
{
$log_text = iconv("ISO-8859-1", "UTF-8", $log_text);
}
}
// fuer alte Versionen von OCProp
if (isset($_POST['submit']) && !isset($_POST['version2']))
{
$log_text = iconv("ISO-8859-1", "UTF-8", $log_text);
}
}
//validate date
$date_ok = false;
if (is_numeric($log_date_month) && is_numeric($log_date_day) && is_numeric($log_date_year) &&
("$log_time_hour$log_time_minute"=="" || is_numeric($log_time_hour)) &&
($log_time_minute=="" || is_numeric($log_time_minute)))
{
$date_ok = checkdate($log_date_month, $log_date_day, $log_date_year)
&& ($log_date_year >= 2000)
&& ($log_time_hour>=0) && ($log_time_hour<=23)
&& ($log_time_minute>=0) && ($log_time_minute<=59);
if ($date_ok)
if (isset($_POST['submitform']))
if (mktime($log_time_hour+0, $log_time_minute+0, 0,
$log_date_month, $log_date_day, $log_date_year) >= mktime())
$date_ok = false;
}
//validate date
$date_ok = false;
if (is_numeric($log_date_month) && is_numeric($log_date_day) && is_numeric($log_date_year) &&
("$log_time_hour$log_time_minute"=="" || is_numeric($log_time_hour)) &&
($log_time_minute=="" || is_numeric($log_time_minute)))
{
$date_ok = checkdate($log_date_month, $log_date_day, $log_date_year)
&& ($log_date_year >= 2000)
&& ($log_time_hour>=0) && ($log_time_hour<=23)
&& ($log_time_minute>=0) && ($log_time_minute<=59);
if ($date_ok)
if (isset($_POST['submitform']))
if (mktime($log_time_hour+0, $log_time_minute+0, 0,
$log_date_month, $log_date_day, $log_date_year) >= mktime())
$date_ok = false;
}
$logtype_ok = logtype_ok($log_record['cache_id'], $log_type, $log_record['logtype']);
$logtype_ok = logtype_ok($log_record['cache_id'], $log_type, $log_record['logtype']);
// not a found log? then ignore the rating
if ($log_type != 1 && $log_type != 7)
$top_option = 0;
// not a found log? then ignore the rating
if ($log_type != 1 && $log_type != 7)
$top_option = 0;
$pw_ok = true;
if ($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;
}
$pw_ok = true;
if ($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;
}
// ignore unauthorized team comments
if (!teamcomment_allowed($log_record['cache_id'], $log_type, $log_record['oc_team_comment']))
$oc_team_comment = 0;
// ignore unauthorized team comments
if (!teamcomment_allowed($log_record['cache_id'], $log_type, $log_record['oc_team_comment']))
$oc_team_comment = 0;
//store?
if (isset($_POST['submitform']) && $date_ok && $logtype_ok && $pw_ok) // Ocprop
{
// 00:00:01 = "00:00 was logged"
// 00:00:00 = "no time was logged"
if ("$log_time_hour$log_time_minute" != "" &&
$log_time_hour == 0 && $log_time_minute == 0)
$log_time_second = 1;
else
$log_time_second = 0;
//store?
if (isset($_POST['submitform']) && $date_ok && $logtype_ok && $pw_ok) // Ocprop
{
// 00:00:01 = "00:00 was logged"
// 00:00:00 = "no time was logged"
if ("$log_time_hour$log_time_minute" != "" &&
$log_time_hour == 0 && $log_time_minute == 0)
$log_time_second = 1;
else
$log_time_second = 0;
$log_date = date('Y-m-d H:i:s', mktime($log_time_hour+0, $log_time_minute+0, $log_time_second, $log_date_month, $log_date_day, $log_date_year));
$log_date = date('Y-m-d H:i:s', mktime($log_time_hour+0, $log_time_minute+0, $log_time_second, $log_date_month, $log_date_day, $log_date_year));
// evtl. discard cache recommendation if the log type was changed from
// 'found' or 'attended' to something else
if (!$top_option)
{
discard_recommendation($log_id);
}
// evtl. discard cache recommendation if the log type was changed from
// 'found' or 'attended' to something else
if (!$top_option)
{
discard_recommendation($log_id);
}
// store changed data
sql("UPDATE `cache_logs` SET `type`='&1',
`oc_team_comment`='&2',
`date`='&3',
`text`='&4',
`text_html`='&5',
`text_htmledit`='&6'
WHERE `id`='&7'",
$log_type,
$oc_team_comment,
$log_date,
(($descMode != 1) ? $log_text : nl2br($log_text)),
(($descMode != 1) ? 1 : 0),
(($descMode == 3) ? 1 : 0),
$log_id);
// store changed data
sql("UPDATE `cache_logs` SET `type`='&1',
`oc_team_comment`='&2',
`date`='&3',
`text`='&4',
`text_html`='&5',
`text_htmledit`='&6'
WHERE `id`='&7'",
$log_type,
$oc_team_comment,
$log_date,
(($descMode != 1) ? $log_text : nl2br($log_text)),
(($descMode != 1) ? 1 : 0),
(($descMode == 3) ? 1 : 0),
$log_id);
//update user-stat if type changed
if ($log_record['logtype'] != $log_type)
{
//call eventhandler
require_once($opt['rootpath'] . 'lib/eventhandler.inc.php');
event_change_log_type($log_record['cache_id'], $usr['userid']+0);
}
//update user-stat if type changed
if ($log_record['logtype'] != $log_type)
{
// delete statpic
$statpic = new statpic($usr['userid']);
$statpic->deleteFile();
}
// update top-list
if ($top_option)
{
if ($top_cache)
{
sql("INSERT INTO `cache_rating` (`user_id`, `cache_id`, `rating_date`)
VALUES('&1','&2','&3')
ON DUPLICATE KEY UPDATE `rating_date`='&3'",
$usr['userid'], $log_record['cache_id'], $log_date);
// cache_rating.rating_date is updated when it already exists, so that
// it stays consistent with cache_logs.date when editing a log date.
// update top-list
if ($top_option)
{
if ($top_cache)
{
sql("INSERT INTO `cache_rating` (`user_id`, `cache_id`, `rating_date`)
VALUES('&1','&2','&3')
ON DUPLICATE KEY UPDATE `rating_date`='&3'",
$usr['userid'], $log_record['cache_id'], $log_date);
// cache_rating.rating_date is updated when it already exists, so that
// it stays consistent with cache_logs.date when editing a log date.
// When editing one of multiple found logs, this will move rating_date
// to the last edited record. While this may not always be what the user
// expects, it makes sense for two reasons:
// 1. It is a safeguard for the case that the log date and rating_date
// have gotten out of sync for some reason (which has happend in the
// past, probably due to a log-deletion related bug).
// 2. It can be used as a tweak to control which log's date is relevant
// for the rating, e.g. when logging a second found on a recycled or
// renewed cache [listing].
}
else
sql("DELETE FROM `cache_rating` WHERE `user_id`='&1' AND `cache_id`='&2'", $usr['userid'], $log_record['cache_id']);
}
// When editing one of multiple found logs, this will move rating_date
// to the last edited record. While this may not always be what the user
// expects, it makes sense for two reasons:
// 1. It is a safeguard for the case that the log date and rating_date
// have gotten out of sync for some reason (which has happend in the
// past, probably due to a log-deletion related bug).
// 2. It can be used as a tweak to control which log's date is relevant
// for the rating, e.g. when logging a second found on a recycled or
// renewed cache [listing].
}
else
sql("DELETE FROM `cache_rating` WHERE `user_id`='&1' AND `cache_id`='&2'", $usr['userid'], $log_record['cache_id']);
}
// do not use slave server for the next time ...
db_slave_exclude();
// do not use slave server for the next time ...
db_slave_exclude();
//display cache page
tpl_redirect('viewcache.php?cacheid=' . urlencode($log_record['cache_id']));
exit;
}
//display cache page
tpl_redirect('viewcache.php?cacheid=' . urlencode($log_record['cache_id']));
exit;
}
// build logtype options
$logtype_names = get_logtype_names();
$allowed_logtypes = get_cache_log_types($log_record['cache_id'], $log_record['logtype']);
$logtypeoptions = '';
foreach ($allowed_logtypes as $logtype)
{
$selected = ($log_record['logtype'] == $logtype ? ' selected="selected"' : '');
$logtypeoptions .= '<option value="' . $logtype . '"' . $selected . '>' . htmlspecialchars($logtype_names[$logtype], ENT_COMPAT, 'UTF-8') . '</option>' . "\n";
}
if (teamcomment_allowed($log_record['cache_id'], 3, $log_record['oc_team_comment']))
tpl_set_var('teamcommentoption',
mb_ereg_replace('{chk_sel}', ($oc_team_comment ? 'checked' : ''), $teamcomment_field));
else
tpl_set_var('teamcommentoption', '');
// build logtype options
$logtype_names = get_logtype_names();
$allowed_logtypes = get_cache_log_types($log_record['cache_id'], $log_record['logtype']);
$logtypeoptions = '';
foreach ($allowed_logtypes as $logtype)
{
$selected = ($log_record['logtype'] == $logtype ? ' selected="selected"' : '');
$logtypeoptions .= '<option value="' . $logtype . '"' . $selected . '>' . htmlspecialchars($logtype_names[$logtype], ENT_COMPAT, 'UTF-8') . '</option>' . "\n";
}
if (teamcomment_allowed($log_record['cache_id'], 3, $log_record['oc_team_comment']))
tpl_set_var('teamcommentoption',
mb_ereg_replace('{chk_sel}', ($oc_team_comment ? 'checked' : ''), $teamcomment_field));
else
tpl_set_var('teamcommentoption', '');
//set template vars
tpl_set_var('cachename', htmlspecialchars($cache_name, ENT_COMPAT, 'UTF-8'));
tpl_set_var('logtypeoptions', $logtypeoptions);
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('loghour', htmlspecialchars($log_time_hour, ENT_COMPAT, 'UTF-8'));
tpl_set_var('logminute', htmlspecialchars($log_time_minute, ENT_COMPAT, 'UTF-8'));
tpl_set_var('cachename', htmlspecialchars($cache_name, ENT_COMPAT, 'UTF-8'));
tpl_set_var('cacheid', $log_record['cache_id']);
tpl_set_var('reset', $reset); // obsolete
tpl_set_var('submit', $submit);
tpl_set_var('logid', $log_id);
tpl_set_var('date_message', !$date_ok ? $date_message : '');
//set template vars
tpl_set_var('cachename', htmlspecialchars($cache_name, ENT_COMPAT, 'UTF-8'));
tpl_set_var('logtypeoptions', $logtypeoptions);
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('loghour', htmlspecialchars($log_time_hour, ENT_COMPAT, 'UTF-8'));
tpl_set_var('logminute', htmlspecialchars($log_time_minute, ENT_COMPAT, 'UTF-8'));
tpl_set_var('cachename', htmlspecialchars($cache_name, ENT_COMPAT, 'UTF-8'));
tpl_set_var('cacheid', $log_record['cache_id']);
tpl_set_var('reset', $reset); // obsolete
tpl_set_var('submit', $submit);
tpl_set_var('logid', $log_id);
tpl_set_var('date_message', !$date_ok ? $date_message : '');
if ($descMode != 1)
tpl_set_var('logtext', htmlspecialchars($log_text, ENT_COMPAT, 'UTF-8'), true);
else
tpl_set_var('logtext', $log_text);
if ($descMode != 1)
tpl_set_var('logtext', htmlspecialchars($log_text, ENT_COMPAT, 'UTF-8'), true);
else
tpl_set_var('logtext', $log_text);
// Text / normal HTML / HTML editor
tpl_set_var('use_tinymce', (($descMode == 3) ? 1 : 0));
// 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&lang='.strtolower($locale).'"></script>' . "\n";
tpl_set_var('htmlheaders', $headers);
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&lang='.strtolower($locale).'"></script>' . "\n";
tpl_set_var('htmlheaders', $headers);
tpl_set_var('descMode', 3);
}
tpl_set_var('descMode', 3);
}
if ($use_log_pw == true && $log_pw != '')
if (!$pw_ok && isset($_POST['submitform']))
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 ($use_log_pw == true && $log_pw != '')
if (!$pw_ok && isset($_POST['submitform']))
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', '');
// 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
{
//TODO: show error
}
}
else
{
//TODO: show error
}
}
}
// 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
{
//TODO: show error
}
}
else
{
//TODO: show error
}
}
}
//make the template and send it out
tpl_BuildTemplate();
?>
//make the template and send it out
tpl_BuildTemplate();

View File

@ -5,36 +5,36 @@
* Unicode Reminder メモ
***************************************************************************/
require('./lib2/web.inc.php');
$tpl->name = 'event_attendance';
$tpl->popup = true;
require('./lib2/web.inc.php');
$tpl->name = 'event_attendance';
$tpl->popup = true;
// id gesetzt?
$cache_id = isset($_REQUEST['id']) ? $_REQUEST['id']+0 : 0;
if ($cache_id != 0)
{
$rs = sql("SELECT `caches`.`name`, `user`.`username`, `caches`.`date_hidden`
FROM `caches`
INNER JOIN `cache_status` ON `caches`.`status`=`cache_status`.`id`
INNER JOIN `user` ON `user`.`user_id`=`caches`.`user_id`
WHERE `cache_status`.`allow_user_view`=1 AND
`caches`.`cache_id`='&1'", $cache_id);
if ($r = sql_fetch_assoc($rs))
{
$tpl->assign('owner', $r['username']);
$tpl->assign('cachename', $r['name']);
$tpl->assign('event_date', $r['date_hidden']);
}
sql_free_result($rs);
// id gesetzt?
$cache_id = isset($_REQUEST['id']) ? $_REQUEST['id']+0 : 0;
if ($cache_id != 0)
{
$rs = sql("SELECT `caches`.`name`, `user`.`username`, `caches`.`date_hidden`
FROM `caches`
INNER JOIN `cache_status` ON `caches`.`status`=`cache_status`.`id`
INNER JOIN `user` ON `user`.`user_id`=`caches`.`user_id`
WHERE `cache_status`.`allow_user_view`=1 AND
`caches`.`cache_id`='&1'", $cache_id);
if ($r = sql_fetch_assoc($rs))
{
$tpl->assign('owner', $r['username']);
$tpl->assign('cachename', $r['name']);
$tpl->assign('event_date', $r['date_hidden']);
}
sql_free_result($rs);
$rs = sql("SELECT DISTINCT `user`.`username` FROM `cache_logs` INNER JOIN `caches` ON `cache_logs`.`cache_id`=`caches`.`cache_id` INNER JOIN `cache_status` ON `caches`.`status`=`cache_status`.`id` INNER JOIN `user` ON `user`.`user_id`=`cache_logs`.`user_id` WHERE `cache_status`.`allow_user_view`=1 AND `cache_logs`.`type`=8 AND `cache_logs`.`cache_id`='&1' ORDER BY `user`.`username`", $cache_id);
$tpl->assign_rs('willattend', $rs);
sql_free_result($rs);
$rs = sql("SELECT DISTINCT `user`.`username` FROM `cache_logs` INNER JOIN `caches` ON `cache_logs`.`cache_id`=`caches`.`cache_id` INNER JOIN `cache_status` ON `caches`.`status`=`cache_status`.`id` INNER JOIN `user` ON `user`.`user_id`=`cache_logs`.`user_id` WHERE `cache_status`.`allow_user_view`=1 AND `cache_logs`.`type`=8 AND `cache_logs`.`cache_id`='&1' ORDER BY `user`.`username`", $cache_id);
$tpl->assign_rs('willattend', $rs);
sql_free_result($rs);
$rs = sql("SELECT DISTINCT `user`.`username` FROM `cache_logs` INNER JOIN `caches` ON `cache_logs`.`cache_id`=`caches`.`cache_id` INNER JOIN `cache_status` ON `caches`.`status`=`cache_status`.`id` INNER JOIN `user` ON `user`.`user_id`=`cache_logs`.`user_id` WHERE `cache_status`.`allow_user_view`=1 AND `cache_logs`.`type`=7 AND `cache_logs`.`cache_id`='&1' ORDER BY `user`.`username`", $cache_id);
$tpl->assign_rs('attended', $rs);
sql_free_result($rs);
}
$rs = sql("SELECT DISTINCT `user`.`username` FROM `cache_logs` INNER JOIN `caches` ON `cache_logs`.`cache_id`=`caches`.`cache_id` INNER JOIN `cache_status` ON `caches`.`status`=`cache_status`.`id` INNER JOIN `user` ON `user`.`user_id`=`cache_logs`.`user_id` WHERE `cache_status`.`allow_user_view`=1 AND `cache_logs`.`type`=7 AND `cache_logs`.`cache_id`='&1' ORDER BY `user`.`username`", $cache_id);
$tpl->assign_rs('attended', $rs);
sql_free_result($rs);
}
$tpl->display();
$tpl->display();
?>

View File

@ -5,120 +5,120 @@
Unicode Reminder メモ
****************************************************************************/
require('./lib2/web.inc.php');
require_once('./lib2/logic/labels.inc.php');
require_once('./lib2/logic/cache.class.php');
require('./lib2/web.inc.php');
require_once('./lib2/logic/labels.inc.php');
require_once('./lib2/logic/cache.class.php');
$tpl->name = 'garmin';
$tpl->popup = 1;
$tpl->assign('popup', true);
$tpl->assign('garmin', true);
$tpl->name = 'garmin';
$tpl->popup = 1;
$tpl->assign('popup', true);
$tpl->assign('garmin', 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']);
// 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']);
// important: when the domain does not fit the api key, you must be redirected to the correct domain
if (($opt['lib']['garmin']['domain'] != $_SERVER['HTTP_HOST']) && !isset($_REQUEST['redirect']))
{
$redirect = $opt['lib']['garmin']['redirect'];
$redirect = str_replace('{cacheid}', $cacheid, $redirect);
$tpl->redirect($redirect);
exit;
}
// important: when the domain does not fit the api key, you must be redirected to the correct domain
if (($opt['lib']['garmin']['domain'] != $_SERVER['HTTP_HOST']) && !isset($_REQUEST['redirect']))
{
$redirect = $opt['lib']['garmin']['redirect'];
$redirect = str_replace('{cacheid}', $cacheid, $redirect);
$tpl->redirect($redirect);
exit;
}
$cache = new cache($cacheid);
$cache = new cache($cacheid);
if ($cache->exist() == false)
$tpl->error(ERROR_CACHE_NOT_EXISTS);
if ($cache->exist() == false)
$tpl->error(ERROR_CACHE_NOT_EXISTS);
if ($cache->allowView() == false)
$tpl->error(ERROR_NO_ACCESS);
if ($cache->allowView() == false)
$tpl->error(ERROR_NO_ACCESS);
$bCrypt = isset($_REQUEST['nocrypt']) ? ($_REQUEST['nocrypt']!=1) : true;
$tpl->assign('crypt', $bCrypt);
$bCrypt = isset($_REQUEST['nocrypt']) ? ($_REQUEST['nocrypt']!=1) : true;
$tpl->assign('crypt', $bCrypt);
if (isset($_REQUEST['desclang']))
$sPreferedDescLang = $_REQUEST['desclang'] . ',' . $opt['template']['locale'] . ',EN';
else
$sPreferedDescLang = $opt['template']['locale'] . ',EN';
if (isset($_REQUEST['desclang']))
$sPreferedDescLang = $_REQUEST['desclang'] . ',' . $opt['template']['locale'] . ',EN';
else
$sPreferedDescLang = $opt['template']['locale'] . ',EN';
//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`.`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`,
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')
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);
//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`.`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`,
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')
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, $GLOBALS['container']->get('ocde.login')->getUserId());
$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);
}
// not published?
if ($rCache['status'] == 5)
{
$tpl->caching = false;
$GLOBALS['container']->get('ocde.login')->verify();
if ($rCache['userid'] != $GLOBALS['container']->get('ocde.login')->getUserId())
$tpl->error(ERROR_CACHE_NOT_PUBLISHED);
}
$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['sizeName'] = labels::getLabelValue('cache_size', $rCache['size']);
$rCache['statusName'] = labels::getLabelValue('cache_status', $rCache['status']);
$rCache['typeName'] = labels::getLabelValue('cache_type', $rCache['type']);
$tpl->assign('cache', $rCache);
$tpl->title = $rCache['name'];
$tpl->assign('cache', $rCache);
$tpl->title = $rCache['name'];
$tpl->display();
$tpl->display();
?>

View File

@ -7,44 +7,44 @@
* Display some status information about the server and Opencaching
***************************************************************************/
require('./lib2/web.inc.php');
require('./lib2/web.inc.php');
$cache_id = isset($_GET['cacheid']) ? $_GET['cacheid']+0 : 0;
$action = isset($_GET['action']) ? $_GET['action'] : '';
$cache_id = isset($_GET['cacheid']) ? $_GET['cacheid']+0 : 0;
$action = isset($_GET['action']) ? $_GET['action'] : '';
$login->verify();
$GLOBALS['container']->get('ocde.login')->verify();
// user valid
if ($login->userid == 0)
$tpl->redirect('login.php?target=ignore.php');
// user valid
if ($GLOBALS['container']->get('ocde.login')->getUserId() == 0)
$tpl->redirect('login.php?target=ignore.php');
// cache_id valid?
if (sql_value("SELECT COUNT(*) FROM `caches` WHERE `cache_id`='&1'", 0, $cache_id) == 0)
$tpl->error(ERROR_CACHE_NOT_EXISTS);
// cache_id valid?
if (sql_value("SELECT COUNT(*) FROM `caches` WHERE `cache_id`='&1'", 0, $cache_id) == 0)
$tpl->error(ERROR_CACHE_NOT_EXISTS);
// action valid
if (($action != 'addignore') && ($action != 'removeignore'))
$tpl->error(ERROR_INVALID_OPERATION);
// action valid
if (($action != 'addignore') && ($action != 'removeignore'))
$tpl->error(ERROR_INVALID_OPERATION);
switch ($action)
{
case 'addignore':
sql("INSERT IGNORE INTO `cache_ignore` (`cache_id`, `user_id`) VALUES ('&1', '&2')", $cache_id, $login->userid);
break;
case 'removeignore':
sql("DELETE FROM `cache_ignore` WHERE `cache_id`='&1' AND `user_id`='&2'", $cache_id, $login->userid);
break;
}
switch ($action)
{
case 'addignore':
sql("INSERT IGNORE INTO `cache_ignore` (`cache_id`, `user_id`) VALUES ('&1', '&2')", $cache_id, $GLOBALS['container']->get('ocde.login')->getUserId());
break;
case 'removeignore':
sql("DELETE FROM `cache_ignore` WHERE `cache_id`='&1' AND `user_id`='&2'", $cache_id, $GLOBALS['container']->get('ocde.login')->getUserId());
break;
}
// clear cached map result, so that the change directly appears on the map
$map_result_id = sql_value("SELECT `result_id` FROM `map2_result`
WHERE INSTR(sqlquery,\"`user_id`='" . sql_escape($login->userid) . "'\")
LIMIT 1", 0);
if ($map_result_id)
{
sql("DELETE FROM `map2_result` WHERE `result_id`='&1'", $map_result_id);
sql("DELETE FROM `map2_data` WHERE `result_id`='&1'", $map_result_id);
}
// clear cached map result, so that the change directly appears on the map
$map_result_id = sql_value("SELECT `result_id` FROM `map2_result`
WHERE INSTR(sqlquery,\"`user_id`='" . sql_escape($GLOBALS['container']->get('ocde.login')->getUserId()) . "'\")
LIMIT 1", 0);
if ($map_result_id)
{
sql("DELETE FROM `map2_result` WHERE `result_id`='&1'", $map_result_id);
sql("DELETE FROM `map2_data` WHERE `result_id`='&1'", $map_result_id);
}
$tpl->redirect('viewcache.php?cacheid=' . ($cache_id+0));
$tpl->redirect('viewcache.php?cacheid=' . ($cache_id+0));
?>

View File

@ -7,28 +7,28 @@
* Display some status information about the server and Opencaching
***************************************************************************/
require('./lib2/web.inc.php');
$tpl->name = 'imagebrowser';
$tpl->popup = true;
require('./lib2/web.inc.php');
$tpl->name = 'imagebrowser';
$tpl->popup = true;
$login->verify();
$GLOBALS['container']->get('ocde.login')->verify();
$cacheid = isset($_REQUEST['cacheid']) ? $_REQUEST['cacheid']+0 : 0;
$cacheid = isset($_REQUEST['cacheid']) ? $_REQUEST['cacheid']+0 : 0;
$rs = sql("SELECT `caches`.`name` FROM `caches` INNER JOIN `cache_status` ON `caches`.`status`=`cache_status`.`id` WHERE `caches`.`user_id`='&1' AND `cache_id`='&2'", $login->userid, $cacheid);
$r = sql_fetch_assoc($rs);
sql_free_result($rs);
$rs = sql("SELECT `caches`.`name` FROM `caches` INNER JOIN `cache_status` ON `caches`.`status`=`cache_status`.`id` WHERE `caches`.`user_id`='&1' AND `cache_id`='&2'", $GLOBALS['container']->get('ocde.login')->getUserId(), $cacheid);
$r = sql_fetch_assoc($rs);
sql_free_result($rs);
if ($r === false)
$tpl->error(ERROR_NO_ACCESS);
if ($r === false)
$tpl->error(ERROR_NO_ACCESS);
$tpl->assign('cachename', $r['name']);
$tpl->assign('cachename', $r['name']);
$rsPictures = sql('SELECT `uuid`, `url`, `title` FROM `pictures` WHERE `object_id`=&1 AND `object_type`=2', $cacheid);
$tpl->assign_rs('pictures', $rsPictures);
sql_free_result($rsPictures);
$rsPictures = sql('SELECT `uuid`, `url`, `title` FROM `pictures` WHERE `object_id`=&1 AND `object_type`=2', $cacheid);
$tpl->assign_rs('pictures', $rsPictures);
sql_free_result($rsPictures);
$tpl->assign('thumbwidth', $opt['logic']['pictures']['thumb_max_width']);
$tpl->assign('thumbwidth', $opt['logic']['pictures']['thumb_max_width']);
$tpl->display();
$tpl->display();
?>

View File

@ -7,138 +7,147 @@
* Display some status information about the server and Opencaching
***************************************************************************/
require('./lib2/web.inc.php');
require('./lib2/logic/logpics.inc.php');
$sUserCountry = $login->getUserCountry();
// create object for "newest" information
$getNew = new getNew($sUserCountry);
require_once __DIR__ . '/lib/core.php';
$tpl->name = 'start';
$tpl->menuitem = MNU_START;
require('./lib2/web.inc.php');
require('./lib2/logic/logpics.inc.php');
$sUserCountry = $GLOBALS['container']->get('ocde.login')->getUserCountry();
// create object for "newest" information
$getNew = new getNew($sUserCountry);
$tpl->caching = true;
$tpl->cache_lifetime = 300;
$tpl->cache_id = $sUserCountry;
$tpl->name = 'start';
$tpl->menuitem = MNU_START;
if (!$tpl->is_cached())
{
// welcome message
if (isset ($opt['page']['message']))
$tpl->assign('message',$opt['page']['message']);
else
$tpl->assign('message',$translate->t('You can find everything you need to go Geocaching ...', '', '', 0));
$tpl->caching = true;
$tpl->cache_lifetime = 300;
$tpl->cache_id = $sUserCountry;
// pictures
$tpl->assign('pictures', get_logpics(LOGPICS_FOR_STARTPAGE_GALLERY));
if (!$tpl->is_cached())
{
if (!isset($translate) || $translate === null) {
require_once $GLOBALS['container']->get('ocde.config')->getBaseDir() . '/lib2/translate.inc.php';
}
// news entries
$tpl->assign('news_onstart', $opt['news']['onstart'] );
// welcome message
if (isset ($opt['page']['message']))
$tpl->assign('message',$opt['page']['message']);
else
$tpl->assign('message',$translate->t('You can find everything you need to go Geocaching ...', '', '', 0));
if ($opt['news']['include'] == '')
{
$news = array();
$rs = sql_slave('SELECT `news`.`date_created` `date`, `news`.`content` `content`, `news_topics`.`name` `topic` FROM `news` INNER JOIN `news_topics` ON (`news`.`topic` = `news_topics`.`id`) WHERE `news`.`display`=1 ORDER BY `news`.`date_created` DESC LIMIT 0, 6');
$tpl->assign_rs('news', $rs);
sql_free_result($rs);
$tpl->assign('extern_news', false);
}
else
{
/*
* changed by bohrsty to fix error in displaying news from blog
* requires $opt['news']['count'] in settings for number of blog-items
* $opt['news']['include'] needs to be the RSS-URL of the blog
*
$url = $opt['news']['include'];
$url = str_replace('{style}', $opt['template']['style'], $url);
$newscontent = read_file($url, $opt['news']['maxsize']);
*/
// get newest blog entries
$tpl->assign('news', $getNew->feedForSmarty('blog'));
$tpl->assign('newsfeed', $opt['news']['include']);
$tpl->assign('extern_news', true);
}
// pictures
$tpl->assign('pictures', get_logpics(LOGPICS_FOR_STARTPAGE_GALLERY));
// news entries
$tpl->assign('news_onstart', $opt['news']['onstart'] );
if ($opt['news']['include'] == '')
{
$news = array();
$rs = sql_slave('SELECT `news`.`date_created` `date`, `news`.`content` `content`, `news_topics`.`name` `topic` FROM `news` INNER JOIN `news_topics` ON (`news`.`topic` = `news_topics`.`id`) WHERE `news`.`display`=1 ORDER BY `news`.`date_created` DESC LIMIT 0, 6');
$tpl->assign_rs('news', $rs);
sql_free_result($rs);
$tpl->assign('extern_news', false);
}
else
{
/*
* changed by bohrsty to fix error in displaying news from blog
* requires $opt['news']['count'] in settings for number of blog-items
* $opt['news']['include'] needs to be the RSS-URL of the blog
*
$url = $opt['news']['include'];
$url = str_replace('{style}', $opt['template']['style'], $url);
$newscontent = read_file($url, $opt['news']['maxsize']);
*/
// get newest blog entries
$tpl->assign('news', $getNew->feedForSmarty('blog'));
$tpl->assign('newsfeed', $opt['news']['include']);
$tpl->assign('extern_news', true);
}
/*
// forum entries
if (file_exists($opt['rootpath'] . 'cache2/phpbb.inc.php'))
require_once($opt['rootpath'] . 'cache2/phpbb.inc.php');
else
// forum entries
if (file_exists($opt['rootpath'] . 'cache2/phpbb.inc.php'))
require_once($opt['rootpath'] . 'cache2/phpbb.inc.php');
else
*/
if ($opt['forum']['url'] != '')
{
/*
* changed by bohrsty to add lastest forum-entries using RSS-feed
* requires $opt['forum']['count'] in settings for number of lastest forum-posts
* requires $opt['forum']['url'] in settings: RSS-feed-URL of the forum
*/
// get newest forum posts
$tpl->assign('phpbb_enabled', true);
$tpl->assign('forum',$getNew->feedForSmarty('forum'));
/*
* changed by bohrsty to add lastest forum-entries using RSS-feed
* requires $opt['forum']['count'] in settings for number of lastest forum-posts
* requires $opt['forum']['url'] in settings: RSS-feed-URL of the forum
*/
// get newest forum posts
$tpl->assign('phpbb_enabled', true);
$tpl->assign('forum',$getNew->feedForSmarty('forum'));
}
else
{
$tpl->assign('phpbb_enabled', false);
$tpl->assign('forum', '');
$tpl->assign('phpbb_enabled', false);
$tpl->assign('forum', '');
}
$phpbb_topics = array();
$tpl->assign('phpbb_topics', $phpbb_topics);
// $tpl->assign('phpbb_enabled', ($opt['cron']['phpbbtopics']['url'] != ''));
$tpl->assign('phpbb_name', $opt['cron']['phpbbtopics']['name']);
$tpl->assign('phpbb_link', $opt['cron']['phpbbtopics']['link']);
$phpbb_topics = array();
$tpl->assign('phpbb_topics', $phpbb_topics);
// $tpl->assign('phpbb_enabled', ($opt['cron']['phpbbtopics']['url'] != ''));
$tpl->assign('phpbb_name', $opt['cron']['phpbbtopics']['name']);
$tpl->assign('phpbb_link', $opt['cron']['phpbbtopics']['link']);
// current cache and log-counters
$tpl->assign('count_hiddens', number1000(sql_value_slave('SELECT COUNT(*) AS `hiddens` FROM `caches` WHERE `status`=1', 0)));
$tpl->assign('count_founds', number1000(sql_value_slave('SELECT COUNT(*) AS `founds` FROM `cache_logs` WHERE `type`=1', 0)));
$tpl->assign('count_users', number1000(sql_value_slave('SELECT COUNT(*) AS `users` FROM (SELECT DISTINCT `user_id` FROM `cache_logs` UNION DISTINCT SELECT DISTINCT `user_id` FROM `caches`) AS `t`', 0)));
// current cache and log-counters
$tpl->assign('count_hiddens', number1000(sql_value_slave('SELECT COUNT(*) AS `hiddens` FROM `caches` WHERE `status`=1', 0)));
$tpl->assign('count_founds', number1000(sql_value_slave('SELECT COUNT(*) AS `founds` FROM `cache_logs` WHERE `type`=1', 0)));
$tpl->assign('count_users', number1000(sql_value_slave('SELECT COUNT(*) AS `users` FROM (SELECT DISTINCT `user_id` FROM `cache_logs` UNION DISTINCT SELECT DISTINCT `user_id` FROM `caches`) AS `t`', 0)));
// get newest events
$tpl->assign_rs('events', $getNew->rsForSmarty('event'));
// get newest events
$tpl->assign_rs('events', $getNew->rsForSmarty('event'));
// get total event count for all countries
$tpl->assign('total_events', sql_value_slave(
"SELECT COUNT(*) FROM `caches` WHERE `type`=6 AND `date_hidden` >= curdate() AND `status`=1", 0));
// get newest caches
$tpl->assign_rs('newcaches', $getNew->rsForSmarty('cache'));
// enable minimap for new caches if url is set
if ($opt['logic']['minimapurl'] != '')
{
// get the correct api key for google maps
$gmkey = '';
$sHost = strtolower($_SERVER['HTTP_HOST']);
if (isset($opt['lib']['google']['mapkey'][$sHost]))
$gmkey = $opt['lib']['google']['mapkey'][$sHost];
// build static maps url by inserting api key
$url = $opt['logic']['minimapurl'];
$url = mb_ereg_replace('{gmkey}', $gmkey, $url);
// put into template
$tpl->assign('minimap_url', $url);
$tpl->assign('minimap_enabled', true);
}
else
{
$tpl->assign('minimap_enabled', false);
}
// last 30 days' top ratings
$tpl->assign_rs('topratings', $getNew->rsForSmarty('rating'));
$tpl->assign('toprating_days', $getNew->ratingDays());
// get newest caches
$tpl->assign_rs('newcaches', $getNew->rsForSmarty('cache'));
// enable minimap for new caches if url is set
if ($opt['logic']['minimapurl'] != '')
{
// get the correct api key for google maps
$gmkey = '';
$sHost = strtolower($_SERVER['HTTP_HOST']);
if (isset($opt['lib']['google']['mapkey'][$sHost]))
$gmkey = $opt['lib']['google']['mapkey'][$sHost];
// build static maps url by inserting api key
$url = $opt['logic']['minimapurl'];
$url = mb_ereg_replace('{gmkey}', $gmkey, $url);
// put into template
$tpl->assign('minimap_url', $url);
$tpl->assign('minimap_enabled', true);
}
else
{
$tpl->assign('minimap_enabled', false);
}
// last 30 days' top ratings
$tpl->assign_rs('topratings', $getNew->rsForSmarty('rating'));
$tpl->assign('toprating_days', $getNew->ratingDays());
// country and language parameters
$sUserCountryName = sql_value("SELECT IFNULL(`sys_trans_text`.`text`, `countries`.`name`)
FROM `countries`
LEFT JOIN `sys_trans` ON `countries`.`trans_id`=`sys_trans`.`id`
LEFT JOIN `sys_trans_text` ON `sys_trans`.`id`=`sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang`='&2'
WHERE `countries`.`short`='&1'", '', $sUserCountry, $opt['template']['locale']);
$tpl->assign('usercountry', $sUserCountryName);
$tpl->assign('usercountryCode', $sUserCountry);
if ($opt['template']['locale'] == $opt['page']['main_locale'])
$tpl->assign('sections', array('news', 'events', 'logpics', 'recommendations', 'forum', 'newcaches'));
else
$tpl->assign('sections', array('events', 'recommendations', 'newcaches', 'logpics', 'forum', 'news'));
}
// country and language parameters
$sUserCountryName = sql_value("SELECT IFNULL(`sys_trans_text`.`text`, `countries`.`name`)
FROM `countries`
LEFT JOIN `sys_trans` ON `countries`.`trans_id`=`sys_trans`.`id`
LEFT JOIN `sys_trans_text` ON `sys_trans`.`id`=`sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang`='&2'
WHERE `countries`.`short`='&1'", '', $sUserCountry, $opt['template']['locale']);
$tpl->assign('usercountry', $sUserCountryName);
$tpl->assign('usercountryCode', $sUserCountry);
if ($opt['template']['locale'] == $opt['page']['main_locale'])
$tpl->assign('sections', array('news', 'events', 'logpics', 'recommendations', 'forum', 'newcaches'));
else
$tpl->assign('sections', array('events', 'recommendations', 'newcaches', 'logpics', 'forum', 'news'));
}
$tpl->display();
$tpl->display();
?>

View File

@ -33,6 +33,7 @@
$status_change = '<br /><div style="margin-top:6px"><img src="lang/de/ocstyle/images/misc/hint.gif" border="0" width="15" height="11" >' . t('To change the state, you need to <a href="log.php?cacheid=%1">log</a> the new state.') . '</div>';
$diff_not_ok_message = '&nbsp;<span class="errormsg">' . t('Choose both valuations!') . '</span>';
$safari_not_allowed_message = '<span class="errormsg">' . t('Only virtual caches can be safari caches.') . '</span>';
$bad_wpgc_message = '<span class="errormsg">' . t('GC waypoint is invalid, must be GCXXX...') . '</span>';
$nopictures = '<tr><td colspan="2">' . t('No pictures available') . '</td></tr>';
$pictureline = '<tr><td colspan="2"><a href="{link}">{title}</a> [<a href="picture.php?action=edit&uuid={uuid}">' . t('Edit') . '</a>] [<a href="picture.php?action=delete&uuid={uuid}">' . t('Delete') . '</a>]</td></tr>';
// Ocprop: <a href=\"http://.*?\.opencaching\.de/images/uploads/.*?\">(.*?)<\/a>.*?\[<a href=\"picture\.php\?action=[a-z]*?\&uuid=(.*?)\">

View File

@ -224,8 +224,9 @@ function toggleAttr(id)
<tr>
<td>{t}Waypoints (optional):{/t}</td>
<!-- allow wp_gc copy&paste with leading spaces; will be trimmed later -->
<td>geocaching.com: <input type="text" name="wp_gc" value="{wp_gc}" maxlength="12" class="input50" />
navicache.com: <input type="text" name="wp_nc" value="{wp_nc}" maxlength="6" class="input50" />
<td>geocaching.com: <input type="text" name="wp_gc" value="{wp_gc}" maxlength="12" class="input70" style="text-transform: uppercase;" />
{wpgc_message}
navicache.com: <input type="text" name="wp_nc" value="{wp_nc}" maxlength="6" class="input50" style="text-transform: uppercase" />
</td>
</tr>
<tr>

View File

@ -3,6 +3,8 @@ Hallo %log_owner%,
%cache_owner% hat deinen Logeintrag für den Cache "%cache_name%" gelöscht
(http://opencaching.de/%cache_wp%).
%log_date%: %log_type%
%log_text%
%comment%

View File

@ -25,6 +25,7 @@
$error_general = "<tr><td class='error' colspan='2'><b>" . t('Some errors occured, please check the marked fields.') . "</b></td></tr>";
$error_coords_not_ok = '<span class="errormsg">' . t('Your chosen coordinated are invalid') . '</span>';
$error_duplicate_coords = '<span class="errormsg">' . t('Another cache (<a href="viewcache.php?wp=%1">%1</a>) exists at these coords. Maybe you pressed "submit cache" twice. To publish a cache with identical coords, enter other coords first, then edit the listing and change coords.') . '</span>';
$time_not_ok_message = '<span class="errormsg">' . t('The entered time is invalid.') . '</span>';
$way_length_not_ok_message = '<span class="errormsg">' . t('The entered distance is invalid, Format: aa.aaa') . '</span>';
$date_not_ok_message = '<span class="errormsg">' . t('Invalid date, format:DD-MM-JJJJ') . '</span>';
@ -35,6 +36,7 @@
$diff_not_ok_message = '&nbsp;<span class="errormsg">' . t('Choose both valuations!') . '</span>';
$sizemismatch_message = '&nbsp;<span class="errormsg">' . t('For virtual and webcam caches, the cache size has to be -no container-!') . '</span>';
$safari_not_allowed_message = '<span class="errormsg">' . t('Only virtual caches can be safari caches.') . '</span>';
$bad_wpgc_message = '<span class="errormsg">' . t('GC waypoint is invalid, must be GCXXX...') . '</span>';
$cache_submitted = t('Your cache is successfully added to the database. You will be redirected to the cache page, now.');

View File

@ -221,8 +221,9 @@ function toggleAttr(id)
<tr>
<td>{t}Waypoints:{/t}</td>
<!-- allow wp_gc copy&paste with leading spaces; will be trimmed later -->
<td>geocaching.com: <input type="text" name="wp_gc" value="{wp_gc}" maxlength="12" class="input50" />
navicache.com: <input type="text" name="wp_nc" value="{wp_nc}" maxlength="6" class="input50" />
<td>geocaching.com: <input type="text" name="wp_gc" value="{wp_gc}" maxlength="12" class="input70" style="text-transform: uppercase" />
{wpgc_message}
navicache.com: <input type="text" name="wp_nc" value="{wp_nc}" maxlength="6" class="input50" style="text-transform: uppercase" />
</td>
</tr>
<tr>

View File

@ -0,0 +1,38 @@
<?php
/****************************************************************************
_ _ _
___ _ __ ___ _ _ __ __ _ __| |_ (_)_ _ __ _ __| |___
/ _ \ '_ \/ -_) ' \/ _/ _` / _| ' \| | ' \/ _` |_/ _` / -_)
\___/ .__/\___|_||_\__\__,_\__|_||_|_|_||_\__, (_)__,_\___|
|_| |___/
For license information see doc/license.txt --- Unicode Reminder メモ
****************************************************************************/
namespace OpencachingDE\Auth;
class Crypt
{
public static function encryptPassword($password)
{
// Calls the password encryption chained
$pwmd5 = self::firstStagePasswordEncryption($password);
return self::secondStagePasswordEncryption($pwmd5);
}
private static function firstStagePasswordEncryption($password)
{
return md5($password);
}
private static function secondStagePasswordEncryption($password)
{
global $opt;
if ($opt['logic']['password_hash']) {
return hash_hmac('sha512', $password, $opt['logic']['password_salt']);
}
return $password;
}
}

View File

@ -0,0 +1,356 @@
<?php
/****************************************************************************
_ _ _
___ _ __ ___ _ _ __ __ _ __| |_ (_)_ _ __ _ __| |___
/ _ \ '_ \/ -_) ' \/ _/ _` / _| ' \| | ' \/ _` |_/ _` / -_)
\___/ .__/\___|_||_\__\__,_\__|_||_|_|_||_\__, (_)__,_\___|
|_| |___/
For license information see doc/license.txt --- Unicode Reminder メモ
****************************************************************************/
namespace OpencachingDE\Auth;
use OpencachingDE\Logging\LoggingInterface;
use OpencachingDE\Util\Cookie;
// SMARTY COMPATIBILITY
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
class Login
{
const UNKNOWN_ERROR = -1; // unkown error occured
const OK = 0; // login succeeded
const BADUSERPW = 1; // bad username or password
const TOOMUCHLOGINS = 2; // too many logins in short time
const USERNOTACTIVE = 3; // the useraccount locked
const EMPTY_USERPASSWORD = 4; // given username/password was empty
const LOGOUT_OK = 5; // logout was successfull
private $cookie = null;
private $loginTime;
private $loginTimePermanent;
private $logger = null;
private $userid = 0;
private $username = '';
private $lastlogin = 0;
private $permanent = false;
private $sessionid = '';
private $verified = false;
private $admin = 0;
public function __construct(Cookie $cookie, LoggingInterface $logger, $loginTime = 3600, $loginTimePermanent = 7776000)
{
$this->cookie = $cookie;
$this->loginTime = $loginTime;
$this->loginTimePermanent = $loginTimePermanent;
$this->logger = $logger;
if ($this->cookie->is_set('userid') && $this->cookie->is_set('username')) {
$this->userid = (int)$this->cookie->get('userid');
$this->username = $this->cookie->get('username');
$this->logger->debug('Cookie has fields userid:' . $this->userid . ' and username:' . $this->username);
$this->permanent = (($this->cookie->get('permanent')+0) == 1);
$this->lastlogin = $this->cookie->get('lastlogin');
$this->sessionid = $this->cookie->get('sessionid');
// $this->admin = $this->cookie->get('admin')+0; nonsense
$this->verified = false;
$this->verify();
} else {
$this->pClear();
}
}
public function getUserId()
{
$this->logger->info('UserId requested, result:' . $this->userid);
return $this->userid;
}
public function getUsername()
{
return $this->username;
}
public function isAdmin($override_value = false)
{
if ($override_value !== false) {
$this->admin = $override_value;
}
return $this->admin;
}
private function pClear()
{
$this->logger->info('pClear called!');
// 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();
}
private function pStoreCookie()
{
$this->cookie->set('userid', $this->userid);
$this->cookie->set('username', $this->username);
$this->cookie->set('permanent', ($this->permanent==true ? 1 : 0));
$this->cookie->set('lastlogin', $this->lastlogin);
$this->cookie->set('sessionid', $this->sessionid);
// $this->cookie->set('admin', $this->admin); nonsense
}
public function verify()
{
if ($this->verified == true) {
$this->logger->debug('VERIFY: Already verified.');
return;
}
if ($this->userid == 0) {
$this->logger->warning('VERIFY: UserId is 0 - session will be deleted.');
$this->pClear();
return;
}
if ($this->checkLoginsCount() == false) {
$this->logger->warning('VERIFY: checkLoginsCount returned FALSE - session will be deleted.');
$this->pClear();
return;
}
$min_lastlogin = date('Y-m-d H:i:s', time() - $this->loginTime);
$min_lastlogin_perm = date('Y-m-d H:i:s', time() - $this->loginTimePermanent);
$rs = sqlf("SELECT s.`last_login`, u.`admin`, u.`username` FROM &db.`sys_sessions` s, &db.`user` u WHERE s.`user_id`=u.`user_id` AND u.`is_active_flag`=1 AND s.`uuid`='&1' AND s.`user_id`='&2' AND ((s.`permanent`=1 AND s.`last_login`>'&3') OR (s.`permanent`=0 AND s.`last_login`>'&4'))", $this->sessionid, $this->userid, $min_lastlogin_perm, $min_lastlogin);
if ($rUser = sql_fetch_assoc($rs)) {
if (
(($this->permanent == true) && (strtotime($rUser['last_login']) + $this->loginTime/2 < time()))
|| (($this->permanent == false) && (strtotime($rUser['last_login']) + $this->loginTimePermanent/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->logger->warning('SQL query did not return user record (sessionid:' . $this->sessionid . '|userid:' . $this->userid . '|min_lastlogin_perm:' . $min_lastlogin_perm . '|min_lastlogin:' . $min_lastlogin .')');
$this->pClear();
}
sql_free_result($rs);
$this->pStoreCookie();
return;
}
public function tryLogin($user, $password, $permanent)
{
if ($password == '') {
$this->logger->error('tryLogin: Empty password.');
return static::EMPTY_USERPASSWORD;
}
$encryptedPassword = Crypt::encryptPassword($password);
return $this->tryLoginEncrypted($user, $encryptedPassword, $permanent);
}
private 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;
}
}
private function tryLoginEncrypted($user, $encryptedPassword, $permanent)
{
$this->pClear();
if ($user == '' || $encryptedPassword == '') {
$this->logger->error('tryLoginEncrypted: Empty Password given.');
return static::EMPTY_USERPASSWORD;
}
if ($this->checkLoginsCount() == false) {
$this->logger->error('tryLoginEncrypted: checkLoginsCount() returned false.');
return static::TOOMUCHLOGINS;
}
// delete old sessions
$min_lastlogin_perm = date('Y-m-d H:i:s', time() - $this->loginTimePermanent);
sqlf("DELETE FROM `sys_sessions` WHERE `last_login`<'&1'", $min_lastlogin_perm);
// 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,
$encryptedPassword
);
$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::createSessionId();
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;
$this->logger->info('tryLoginEncrypted: Login OK.');
$retval = static::OK;
} else {
$this->logger->error('tryLoginEncrypted: User is_active_flag is 0.');
$retval = static::USERNOTACTIVE;
}
} else {
// sorry, bad login
$this->logger->error('tryLoginEncrypted: Bad Password.');
$retval = static::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;
}
// login for cronjobs, command line tools ...
public function systemLogin($username)
{
$this->pClear();
if ($username != "") {
$rs = sql("SELECT `user_id`,`username`,`admin` FROM `user` WHERE `username`='&1' AND `is_active_flag`", $username);
if ($rUser = sql_fetch_assoc($rs)) {
$this->username = $rUser['username'];
$this->userid = $rUser['user_id'];
$this->admin = $rUser['admin'];
$this->verified = true;
sqlf("UPDATE `user` SET `user`.`last_login`=NOW() WHERE `user`.`user_id`='&1'", $this->userid);
}
sql_free_result($rs);
}
return ($this->userid > 0);
}
private static function createSessionId()
{
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)
);
}
public function getUserCountry()
{
global $opt;
// language specified in cookie?
if ($this->cookie->is_set('usercountry')) {
$sCountry = $this->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'];
}
public 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;
}
public function listingAdmin()
{
global $opt;
return $this->hasAdminPriv(ADMIN_LISTING) && $opt['logic']['admin']['enable_listing_admins'];
}
public function logged_in()
{
return $this->userid > 0;
}
}

View File

@ -0,0 +1,64 @@
<?php
/****************************************************************************
_ _ _
___ _ __ ___ _ _ __ __ _ __| |_ (_)_ _ __ _ __| |___
/ _ \ '_ \/ -_) ' \/ _/ _` / _| ' \| | ' \/ _` |_/ _` / -_)
\___/ .__/\___|_||_\__\__,_\__|_||_|_|_||_\__, (_)__,_\___|
|_| |___/
For license information see doc/license.txt --- Unicode Reminder メモ
****************************************************************************/
namespace OpencachingDE\Config;
use OpencachingDE\Config\YamlConfigLoader;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
class Config
{
private $container;
public function __construct()
{
$logger = $GLOBALS['container']->get('logger');
$logger->debug('Hello world!');
$this->container = new ContainerBuilder();
$loader = new YamlConfigLoader($this->container, new FileLocator($this->getBaseDir() . '/config/'));
if (php_sapi_name() == 'cli') {
$loader->load('config_cli.yml');
} else {
$loader->load('config_web.yml');
}
// Example:
// $domain = $this->get('ocde.web.domain');
}
public function get($key)
{
return $this->container->getParameter($key);
}
public function set($key, $value)
{
if (is_array($value)) {
foreach ($value as $subkey => $subvalue) {
$this->set($key.'.'.$subkey, $subvalue);
}
}
$this->container->setParameter($key, $value);
}
public function getBaseDir()
{
$curdir = __DIR__;
$dirparts = explode(DIRECTORY_SEPARATOR, $curdir);
$basedirParts = array_slice($dirparts, 0, -3);
return implode(DIRECTORY_SEPARATOR, $basedirParts);
}
}

View File

@ -0,0 +1,128 @@
<?php
/****************************************************************************
_ _ _
___ _ __ ___ _ _ __ __ _ __| |_ (_)_ _ __ _ __| |___
/ _ \ '_ \/ -_) ' \/ _/ _` / _| ' \| | ' \/ _` |_/ _` / -_)
\___/ .__/\___|_||_\__\__,_\__|_||_|_|_||_\__, (_)__,_\___|
|_| |___/
For license information see doc/license.txt --- Unicode Reminder メモ
****************************************************************************/
namespace OpencachingDE\Config;
use Symfony\Component\Config\Exception\FileLoaderLoadException;
use Symfony\Component\Config\FileLocatorInterface;
use Symfony\Component\Config\Loader\FileLoader;
use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Yaml\Parser as YamlParser;
class YamlConfigLoader extends FileLoader
{
private $yamlParser;
protected $container;
/**
* Constructor.
*
* @param ContainerBuilder $container A ContainerBuilder instance
* @param FileLocatorInterface $locator A FileLocator instance
*/
public function __construct(ContainerBuilder $container, FileLocatorInterface $locator)
{
$this->container = $container;
parent::__construct($locator);
}
public function load($file, $type = null)
{
$path = $this->locator->locate($file);
$content = $this->loadFile($path);
$this->container->addResource(new FileResource($path));
// empty file
if (null === $content) {
return;
}
// imports
$this->parseImports($content, $file);
// config data
foreach ($content as $key => $value) {
if ($key == 'imports') {
continue;
}
$this->addValue($key, $value);
}
}
protected function addValue($key, $value)
{
if (is_array($value)) {
foreach ($value as $subkey => $subvalue) {
$this->addValue($key.'.'.$subkey, $subvalue);
}
}
$this->container->setParameter($key, $value);
}
/**
* Loads a YAML file.
*
* @param string $file
* @return array The file content
*/
protected function loadFile($file)
{
if (!stream_is_local($file)) {
throw new FileLoaderLoadException(sprintf('This is not a local file "%s".', $file));
}
if (!file_exists($file)) {
throw new FileLoaderLoadException(sprintf('The service file "%s" is not valid.', $file));
}
if (null === $this->yamlParser) {
$this->yamlParser = new YamlParser();
}
return $this->yamlParser->parse(file_get_contents($file));
}
/**
* Parses all imports
*
* @param array $content
* @param string $file
*/
private function parseImports($content, $file)
{
if (!isset($content['imports'])) {
return;
}
foreach ($content['imports'] as $import) {
$this->setCurrentDir(dirname($file));
$this->import($import['resource'], null, isset($import['ignore_errors']) ? (Boolean) $import['ignore_errors'] : false, $file);
}
}
/**
* Returns true if this class supports the given resource.
*
* @param mixed $resource A resource
* @param string $type The resource type
*
* @return Boolean true if this class supports the given resource, false otherwise
*/
public function supports($resource, $type = null)
{
return is_string($resource) && 'yml' === pathinfo($resource, PATHINFO_EXTENSION);
}
}

View File

@ -0,0 +1,635 @@
<?php
/****************************************************************************
_ _ _
___ _ __ ___ _ _ __ __ _ __| |_ (_)_ _ __ _ __| |___
/ _ \ '_ \/ -_) ' \/ _/ _` / _| ' \| | ' \/ _` |_/ _` / -_)
\___/ .__/\___|_||_\__\__,_\__|_||_|_|_||_\__, (_)__,_\___|
|_| |___/
For license information see doc/license.txt --- Unicode Reminder メモ
****************************************************************************/
namespace OpencachingDE\Conversions;
// TODO: Use https://github.com/mjaschen/phpgeo for conversions
class Coordinate
{
public $nLat = 0;
public $nLon = 0;
public function __construct($nNewLat, $nNewLon)
{
$this->nLat = $nNewLat;
$this->nLon = $nNewLon;
}
/* get-Functions return array([lat] => string, [lon] => string)
*/
public function getFloat()
{
return array(
'lat' => $this->nLat,
'lon' => $this->nLon,
);
}
// d.ddddd°
public function getDecimal()
{
if ($this->nLat < 0) {
$sLat = 'S ' . sprintf('%08.5f', -$this->nLat) . '°';
} else {
$sLat = 'N ' . sprintf('%08.5f', $this->nLat) . '°';
}
if ($this->nLon < 0) {
$sLon = 'W ' . sprintf('%09.5f', -$this->nLon) . '°';
} else {
$sLon = 'E ' . sprintf('%09.5f', $this->nLon) . '°';
}
return array(
'lat' => $sLat,
'lon' => $sLon,
);
}
// d° mm.mmm
public function getDecimalMinutes()
{
// Ocprop: ([N|S].*?)&#039;
$nLat = $this->nLat;
$bLatN = ($nLat >= 0);
if (!$bLatN) {
$nLat = -$nLat;
}
$nLatDeg = floor($nLat);
$nLatMin = ($nLat - $nLatDeg) * 60;
if ($bLatN) {
$sLat = 'N ' . sprintf("%02d", $nLatDeg) . '° ' . sprintf("%06.3f", $nLatMin) . '\'';
} else {
$sLat = 'S ' . sprintf("%02d", $nLatDeg) . '° ' . sprintf("%06.3f", $nLatMin) . '\'';
}
// Ocprop: ([E|W].*?)&#039;
$nLon = $this->nLon;
$bLonE = ($nLon < 0) ? false : true;
if (!$bLonE) {
$nLon = -$nLon;
}
$nLonDeg = floor($nLon);
$nLonMin = ($nLon - $nLonDeg) * 60;
if ($bLonE) {
$sLon = 'E ' . sprintf("%03d", $nLonDeg) . '° ' . sprintf("%06.3f", $nLonMin) . '\'';
} else {
$sLon = 'W ' . sprintf("%03d", $nLonDeg) . '° ' . sprintf("%06.3f", $nLonMin) . '\'';
}
return array(
'lat' => $sLat,
'lon' => $sLon,
);
}
// d° mm ss
public function getDecimalMinutesSeconds()
{
$nLat = $this->nLat;
$bLatN = ($nLat >= 0);
if (!$bLatN) {
$nLat = -$nLat;
}
$nLatDeg = floor($nLat);
$nLatMin = ($nLat - $nLatDeg) * 60;
$nLatSec = $nLatMin - floor($nLatMin);
$nLatMin = ($nLatMin - $nLatSec);
$nLatSec = $nLatSec * 60;
if ($bLatN) {
$sLat = 'N ' . sprintf("%02d", $nLatDeg) . '° ' . sprintf("%02d", $nLatMin) . '\' ' . sprintf("%02d", $nLatSec) . '\'\'';
} else {
$sLat = 'S ' . sprintf("%02d", $nLatDeg) . '° ' . sprintf("%02d", $nLatMin) . '\' ' . sprintf("%02d", $nLatSec) . '\'\'';
}
$nLon = $this->nLon;
$bLonE = ($nLon < 0) ? false : true;
if (!$bLonE) {
$nLon = -$nLon;
}
$nLonDeg = floor($nLon);
$nLonMin = ($nLon - $nLonDeg) * 60;
$nLonSec = $nLonMin - floor($nLonMin);
$nLonMin = ($nLonMin - $nLonSec);
$nLonSec = $nLonSec * 60;
if ($bLonE) {
$sLon = 'E ' . sprintf("%03d", $nLonDeg) . '° ' . sprintf("%02d", $nLonMin) . '\' ' . sprintf("%02d", $nLonSec) . '\'\'';
} else {
$sLon = 'W ' . sprintf("%03d", $nLonDeg) . '° ' . sprintf("%02d", $nLonMin) . '\' ' . sprintf("%02d", $nLonSec) . '\'\'';
}
return array(
'lat' => $sLat,
'lon' => $sLon,
);
}
// array(zone, letter, north, east)
public function getUTM()
{
/* Copyright (c) 2006, HELMUT H. HEIMEIER
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.*/
/* Die Funktion wandelt geographische Koordinaten in UTM Koordinaten
um. Geographische Länge lw und Breite bw müssen im WGS84 Datum
gegeben sein. Berechnet werden UTM Zone, Ostwert ew und Nordwert nw.*/
//Geographische Länge lw und Breite bw im WGS84 Datum
if ($this->nLon == 0 || $this->nLat == 0) {
return array(
'zone' => "",
'letter' => "",
'north' => 'N ' . 0,
'east' => 'E ' . 0,
);
}
if ($this->nLon <= -180 || $this->nLon > 180 || $this->nLat <= -80 || $this->nLat >= 84) {
// Werte nicht im Bereich des UTM Systems -180° <= nLon < +180°, -80° < nLat < 84° N
return array("", "", 0, 0);
}
$lw = doubleval($this->nLon);
$bw = doubleval($this->nLat);
//WGS84 Datum
//Große Halbachse a und Abplattung f
$a = 6378137.000;
$f = 3.35281068e-3;
$b_sel = 'CDEFGHJKLMNPQRSTUVWXX';
//Polkrümmungshalbmesser c
$c = $a / (1 - $f);
//Quadrat der zweiten numerischen Exzentrizität
$ex2 = (2 * $f - $f * $f) / ((1 - $f) * (1 - $f));
$ex4 = $ex2 * $ex2;
$ex6 = $ex4 * $ex2;
$ex8 = $ex4 * $ex4;
//Koeffizienten zur Berechnung der Meridianbogenlänge
$e0 = $c * (pi() / 180) * (1 - 3 * $ex2 / 4 + 45 * $ex4 / 64 - 175 * $ex6 / 256 + 11025 * $ex8 / 16384);
$e2 = $c * (-3 * $ex2 / 8 + 15 * $ex4 / 32 - 525 * $ex6 / 1024 + 2205 * $ex8 / 4096);
$e4 = $c * (15 * $ex4 / 256 - 105 * $ex6 / 1024 + 2205 * $ex8 / 16384);
$e6 = $c * (-35 * $ex6 / 3072 + 315 * $ex8 / 12288);
//Längenzone lz und Breitenzone (Band) bz
$lzn = intval(($lw + 180) / 6) + 1;
if ($bw >= 56.0 && $bw < 64.0 && $lw >= 3.0 && $lw < 12.0) {
$lzn = 32;
}
// Special zones for Svalbard.
if ($bw >= 72.0 && $bw < 84.0) {
if ($lw >= 0.0 && $lw < 9.0) {
$lzn = 31;
} elseif ($lw >= 9.0 && $lw < 21.0) {
$lzn = 33;
} else if ($lw >= 21.0 && $lw < 33.0) {
$lzn = 35;
} else if ($lw >= 33.0 && $lw < 42.0) {
$lzn = 37;
}
}
$lz = (string)$lzn;
if ($lzn < 10) {
$lz = "0" . $lzn;
}
$bd = intval(1 + ($bw + 80) / 8);
$bz = substr($b_sel, $bd - 1, 1);
//Geographische Breite in Radianten br
$br = $bw * pi() / 180;
$tan1 = tan($br);
$tan2 = $tan1 * $tan1;
$tan4 = $tan2 * $tan2;
$cos1 = cos($br);
$cos2 = $cos1 * $cos1;
$cos4 = $cos2 * $cos2;
$cos3 = $cos2 * $cos1;
$cos5 = $cos4 * $cos1;
$etasq = $ex2 * $cos2;
//Querkrümmungshalbmesser nd
$nd = $c / sqrt(1 + $etasq);
//Meridianbogenlänge g aus gegebener geographischer Breite bw
$g = ($e0 * $bw) + ($e2 * sin(2 * $br)) + ($e4 * sin(4 * $br)) + ($e6 * sin(6 * $br));
//Längendifferenz dl zum Bezugsmeridian lh
$lh = ($lzn - 30) * 6 - 3;
$dl = ($lw - $lh) * pi() / 180;
$dl2 = $dl * $dl;
$dl4 = $dl2 * $dl2;
$dl3 = $dl2 * $dl;
$dl5 = $dl4 * $dl;
//Maßstabsfaktor auf dem Bezugsmeridian bei UTM Koordinaten m = 0.9996
//Nordwert nw und Ostwert ew als Funktion von geographischer Breite und Länge
if ($bw < 0) {
$nw = 10e6 + 0.9996 * ($g + $nd * $cos2 * $tan1 * $dl2 / 2 + $nd * $cos4 * $tan1 * (5 - $tan2 + 9 * $etasq) * $dl4 / 24);
} else {
$nw = 0.9996 * ($g + $nd * $cos2 * $tan1 * $dl2 / 2 + $nd * $cos4 * $tan1 * (5 - $tan2 + 9 * $etasq) * $dl4 / 24);
}
$ew = 0.9996 * ($nd * $cos1 * $dl + $nd * $cos3 * (1 - $tan2 + $etasq) * $dl3 / 6 + $nd * $cos5 * (5 - 18 * $tan2 + $tan4) * $dl5 / 120) + 500000;
$nk = $nw - (int)$nw;
if ($nk < 0.5) {
$nw = "" . (int)$nw;
} else {
$nw = "" . ((int)$nw + 1);
}
while (strlen($nw) < 7) {
$nw = "0" . $nw;
}
$nk = $ew - (int)$ew;
if ($nk < 0.5) {
$ew = "0" . (int)$ew;
} else {
$ew = "0" . (int)($ew + 1);
}
return array(
'zone' => $lz,
'letter' => $bz,
'north' => 'N ' . floor($nw),
'east' => 'E ' . floor($ew),
);
}
// return string
public function getGK()
{
$pdResult = $this->wgs2pot($this->nLat, $this->nLon);
$result = $this->geo2gk($pdResult[1], $pdResult[0]);
return 'R ' . floor($result[0]) . ' H ' . floor($result[1]);
}
public function wgs2pot($bw, $lw)
{
/* Copyright (c) 2006, HELMUT H. HEIMEIER
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.*/
/* Die Funktion verschiebt das Kartenbezugssystem (map datum) vom
WGS84 Datum (World Geodetic System 84) zum in Deutschland
gebräuchlichen Potsdam-Datum. Geographische Länge lw und Breite
bw gemessen in grad auf dem WGS84 Ellipsoid müssen
gegeben sein. Ausgegeben werden geographische Länge lp
und Breite bp (in grad) auf dem Bessel-Ellipsoid.
Bei der Transformation werden die Ellipsoidachsen parallel
verschoben um dx = -606 m, dy = -23 m und dz = -413 m.*/
// Geographische Länge lw und Breite bw im WGS84 Datum
if ($lw == "" || $bw == "") {
return array(0, 0);
}
$lw = doubleval($lw);
$bw = doubleval($bw);
// Quellsystem WGS 84 Datum
// Große Halbachse a und Abplattung fq
$a = 6378137.000;
$fq = 3.35281066e-3;
// Zielsystem Potsdam Datum
// Abplattung f
$f = $fq - 1.003748e-5;
// Parameter für datum shift
$dx = -606;
$dy = -23;
$dz = -413;
// Quadrat der ersten numerischen Exzentrizität in Quell- und Zielsystem
$e2q = (2 * $fq - $fq * $fq);
$e2 = (2 * $f - $f * $f);
// Breite und Länge in Radianten
$b1 = $bw * (pi() / 180);
$l1 = $lw * (pi() / 180);
// Querkrümmungshalbmesser nd
$nd = $a / sqrt(1 - $e2q * sin($b1) * sin($b1));
// Kartesische Koordinaten des Quellsystems WGS84
$xw = $nd * cos($b1) * cos($l1);
$yw = $nd * cos($b1) * sin($l1);
$zw = (1 - $e2q) * $nd * sin($b1);
// Kartesische Koordinaten des Zielsystems (datum shift) Potsdam
$x = $xw + $dx;
$y = $yw + $dy;
$z = $zw + $dz;
// Berechnung von Breite und Länge im Zielsystem
$rb = sqrt($x * $x + $y * $y);
$b2 = (180 / pi()) * atan(($z / $rb) / (1 - $e2));
if ($x > 0) {
$l2 = (180 / pi()) * atan($y / $x);
} else if ($x < 0 && $y > 0) {
$l2 = (180 / pi()) * atan($y / $x) + 180;
} else {
$l2 = (180 / pi()) * atan($y / $x) - 180;
}
return array($l2, $b2);
}
public function geo2gk($bp, $lp)
{
/* Copyright (c) 2006, HELMUT H. HEIMEIER
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.*/
/* Die Funktion wandelt geographische Koordinaten in GK Koordinaten
um. Geographische Länge lp und Breite bp müssen im Potsdam Datum
gegeben sein. Berechnet werden Rechtswert rw und Hochwert hw.*/
//Geographische Länge lp und Breite bp im Potsdam Datum
if ($lp == "" || $bp == "") {
return array(0, 0);
}
$lp = doubleval($lp);
$bp = doubleval($bp);
// Potsdam Datum
// Große Halbachse a und Abplattung f
$a = 6377397.155; // + $falseeasting;
$f = 3.34277321e-3;
// Polkrümmungshalbmesser c
$c = $a / (1 - $f);
// Quadrat der zweiten numerischen Exzentrizität
$ex2 = (2 * $f - $f * $f) / ((1 - $f) * (1 - $f));
$ex4 = $ex2 * $ex2;
$ex6 = $ex4 * $ex2;
$ex8 = $ex4 * $ex4;
// Koeffizienten zur Berechnung der Meridianbogenlänge
$e0 = $c * (pi() / 180) * (1 - 3 * $ex2 / 4 + 45 * $ex4 / 64 - 175 * $ex6 / 256 + 11025 * $ex8 / 16384);
$e2 = $c * (-3 * $ex2 / 8 + 15 * $ex4 / 32 - 525 * $ex6 / 1024 + 2205 * $ex8 / 4096);
$e4 = $c * (15 * $ex4 / 256 - 105 * $ex6 / 1024 + 2205 * $ex8 / 16384);
$e6 = $c * (-35 * $ex6 / 3072 + 315 * $ex8 / 12288);
// Breite in Radianten
$br = $bp * pi() / 180;
$tan1 = tan($br);
$tan2 = $tan1 * $tan1;
$tan4 = $tan2 * $tan2;
$cos1 = cos($br);
$cos2 = $cos1 * $cos1;
$cos4 = $cos2 * $cos2;
$cos3 = $cos2 * $cos1;
$cos5 = $cos4 * $cos1;
$etasq = $ex2 * $cos2;
// Querkrümmungshalbmesser nd
$nd = $c / sqrt(1 + $etasq);
// Meridianbogenlänge g aus gegebener geographischer Breite bp
$g = $e0 * $bp + $e2 * sin(2 * $br) + $e4 * sin(4 * $br) + $e6 * sin(6 * $br);
// Längendifferenz dl zum Bezugsmeridian lh
$kz = round($lp / 3);
$lh = $kz * 3;
$dl = ($lp - $lh) * pi() / 180;
$dl2 = $dl * $dl;
$dl4 = $dl2 * $dl2;
$dl3 = $dl2 * $dl;
$dl5 = $dl4 * $dl;
// Hochwert hw und Rechtswert rw als Funktion von geographischer Breite und Länge
$hw = ($g + $nd * $cos2 * $tan1 * $dl2 / 2 + $nd * $cos4 * $tan1 * (5 - $tan2 + 9 * $etasq)
* $dl4 / 24);
$rw = ($nd * $cos1 * $dl + $nd * $cos3 * (1 - $tan2 + $etasq) * $dl3 / 6 +
$nd * $cos5 * (5 - 18 * $tan2 + $tan4) * $dl5 / 120 + $kz * 1e6 + 500000);
$nk = $hw - (int)$hw;
if ($nk < 0.5) {
$hw = (int)$hw;
} else {
$hw = (int)$hw + 1;
}
$nk = $rw - (int)$rw;
if ($nk < 0.5) {
$rw = (int)$rw;
} else {
$rw = (int)($rw + 1);
}
return array($rw, $hw);
}
// return string
public function getRD()
{
// X0,Y0 Base RD coordinates Amersfoort
$rdx_base = 155000;
$rdy_base = 463000;
// ?0, ?0 Same base, but as wgs84 coordinates
$lat_base = 52.15517440;
$lon_base = 5.38720621;
for ($i = 0; $i <= 6; $i++) {
for ($j = 0; $j <= 5; $j++) {
$rpq[$i][$j] = 0;
$spq[$i][$j] = 0;
}
}
//#coefficients
$rpq[0][1] = 190094.945;
$rpq[1][1] = -11832.228;
$rpq[2][1] = -114.221;
$rpq[0][3] = -32.391;
$rpq[1][0] = -0.705;
$rpq[3][1] = -2.340;
$rpq[1][3] = -0.608;
$rpq[0][2] = -0.008;
$rpq[2][3] = 0.148;
$spq[1][0] = 309056.544;
$spq[0][2] = 3638.893;
$spq[2][0] = 73.077;
$spq[1][2] = -157.984;
$spq[3][0] = 59.788;
$spq[0][1] = 0.433;
$spq[2][2] = -6.439;
$spq[1][1] = -0.032;
$spq[0][4] = 0.092;
$spq[1][4] = -0.054;
// Calculate X, Y of origin
$latDiff = $this->nLat - $lat_base;
$dlat = 0.36 * $latDiff;
$lonDiff = $this->nLon - $lon_base;
$dlon = 0.36 * $lonDiff;
$xOrigin = 0;
$yOrigin = 0;
for ($q = 0; $q <= 5; $q++) {
for ($p = 0; $p <= 6; $p++) {
$xOrigin = $xOrigin + ($rpq[$p][$q] * ((pow($dlat, $p)) * (pow($dlon, $q))));
$yOrigin = $yOrigin + ($spq[$p][$q] * ((pow($dlat, $p)) * (pow($dlon, $q))));
}
}
$xOrigin = $xOrigin + $rdx_base;
$yOrigin = $yOrigin + $rdy_base;
return 'X ' . floor($xOrigin) . ' Y ' . floor($yOrigin);
}
// returns string
public function getQTH()
{
$lon = $this->nLon;
$lat = $this->nLat;
$lon += 180;
$l[0] = floor($lon/20);
$lon -= 20*$l[0];
$l[2] = floor($lon/2);
$lon -= 2 *$l[2];
$l[4] = floor($lon*60/5);
$lat += 90;
$l[1] = floor($lat/10);
$lat -= 10*$l[1];
$l[3] = floor($lat);
$lat -= $l[3];
$l[5] = floor($lat*120/5);
return sprintf("%c%c%c%c%c%c", $l[0]+65, $l[1]+65, $l[2]+48, $l[3]+48, $l[4]+65, $l[5]+65);
}
// return string
public function getSwissGrid()
{
$nLat = $this->nLat * 3600;
$nLon = $this->nLon * 3600;
// Quelle: http://www.swisstopo.admin.ch/internet/swisstopo/de/home/apps/calc.html
// Hilfsgrössen
$b = ($nLat - 169028.66) / 10000.0;
$l = ($nLon - 26782.5) / 10000.0;
// Nord x
$x = 200147.07 + 308807.95 * $b + 3745.25 * $l * $l + 76.63 * $b * $b + 119.79 * $b * $b * $b - 194.56 * $b * $l * $l;
$x = floor($x);
// Ost y
$y = 600072.37 + 211455.93 * $l - 10938.51 * $l * $b - 0.36 * $l * $b * $b - 44.54 * $l * $l * $l;
$y = floor($y);
// Namen: "CH1903", "Schweizer Landeskoordinaten" oder "Swiss Grid"
$swissgrid = "$y / $x";
// Karten Links
$mapplus = "<a href=\"http://www.mapplus.ch/frame.php?map=&x=$y&y=$x&zl=13\" target=\"_blank\">MapPlus</a>";
$mapsearch = "<a href=\"http://map.search.ch/$y,$x\" target=\"_blank\">map.search.ch</a>";
return array('coord' => $swissgrid, $mapplus, $mapsearch);
}
public static function parseRequestLat($name)
{
if (!isset($_REQUEST[$name . 'NS']) || !isset($_REQUEST[$name . 'Lat']) || !isset($_REQUEST[$name . 'LatMin'])) {
return false;
}
$coordNS = $_REQUEST[$name . 'NS'];
$coordLat = $_REQUEST[$name . 'Lat']+0;
$coordLatMin = str_replace(',', '.', $_REQUEST[$name . 'LatMin'])+0;
$lat = $coordLat + $coordLatMin/60;
if ($coordNS == 'S') {
$lat = -$lat;
}
return $lat;
}
public static function parseRequestLon($name)
{
if (!isset($_REQUEST[$name . 'EW']) || !isset($_REQUEST[$name . 'Lon']) || !isset($_REQUEST[$name . 'LonMin'])) {
return false;
}
$coordEW = $_REQUEST[$name . 'EW'];
$coordLon = $_REQUEST[$name . 'Lon']+0;
$coordLonMin = str_replace(',', '.', $_REQUEST[$name . 'LonMin'])+0;
$lon = $coordLon + $coordLonMin/60;
if ($coordEW == 'W') {
$lon = -$lon;
}
return $lon;
}
public function getW3W($language = "de")
{
$params = array(
'key' => $GLOBALS['container']->get('ocde.config')->get('ocde.what3words.apikey'),
'position' => sprintf('%f,%f', $this->nLat, $this->nLon),
'lang' => $language,
);
$params_str = http_build_query($params);
$context = stream_context_create(array(
'http' => array(
'method' => 'POST',
'header' => "Content-Type: application/x-www-form-urlencoded\r\n" .
"Content-Length: " . strlen($params_str) . "\r\n",
'content' => $params_str,
),
));
$result = @file_get_contents('http://api.what3words.com/position', false, $context);
if ($result === false) {
return false;
}
$json = json_decode($result, true);
return implode('.', $json['words']);
}
}

View File

@ -0,0 +1,135 @@
<?php
/****************************************************************************
_ _ _
___ _ __ ___ _ _ __ __ _ __| |_ (_)_ _ __ _ __| |___
/ _ \ '_ \/ -_) ' \/ _/ _` / _| ' \| | ' \/ _` |_/ _` / -_)
\___/ .__/\___|_||_\__\__,_\__|_||_|_|_||_\__, (_)__,_\___|
|_| |___/
For license information see doc/license.txt --- Unicode Reminder メモ
****************************************************************************/
namespace OpencachingDE\Conversions;
class Coordinates
{
// decimal longitude to string E/W hhh°mm.mmm
public static function lonToDegreeStr($lon)
{
if ($lon < 0) {
$retval = 'W ';
$lon = -$lon;
} else {
$retval = 'E ';
}
$retval = $retval . sprintf("%03d", floor($lon)) . '° ';
$lon = $lon - floor($lon);
$retval = $retval . sprintf("%06.3f", round($lon * 60, 3)) . '\'';
return $retval;
}
// decimal latitude to string N/S hh°mm.mmm
public static function latToDegreeStr($lat)
{
if ($lat < 0) {
$retval = 'S ';
$lat = -$lat;
} else {
$retval = 'N ';
}
$retval = $retval . sprintf("%02d", floor($lat)) . '° ';
$lat = $lat - floor($lat);
$retval = $retval . sprintf("%06.3f", round($lat * 60, 3)) . '\'';
return $retval;
}
// decimal longitude to array(direction, h, min)
public static function lonToArray($lon)
{
if ($lon < 0) {
$dir = 'W';
$lon = -$lon;
} else {
$dir = 'E';
}
$h = sprintf("%02d", floor($lon));
$lon = $lon - floor($lon);
$min = sprintf("%06.3f", round($lon * 60, 3));
return array($dir, $h, $min);
}
// decimal longitude to array(direction, h_int, min_int, sec_int, min_float)
public static function lonToArray2($lon)
{
list($dir, $lon_h_int, $lon_min_float) = self::lonToArray($lon);
$lon_min_int = sprintf("%02d", floor($lon_min_float));
$lon_min_frac = $lon_min_float - $lon_min_int;
$lon_sec_int = sprintf("%02d", round($lon_min_frac * 60));
return array($dir, $lon_h_int, $lon_min_int, $lon_sec_int, $lon_min_float);
}
// decimal latitude to array(direction, h, min)
public static function latToArray($lat)
{
if ($lat < 0) {
$dir = 'S';
$lat = -$lat;
} else {
$dir = 'N';
}
$h = sprintf("%02d", floor($lat));
$lat = $lat - floor($lat);
$min = sprintf("%06.3f", round($lat * 60, 3));
return array($dir, $h, $min);
}
// decimal latitude to array(direction, h_int, min_int, sec_int, min_float)
public static function latToArray2($lat)
{
list($dir, $lat_h_int, $lat_min_float) = self::latToArray($lat);
$lat_min_int = sprintf("%02d", floor($lat_min_float));
$lat_min_frac = $lat_min_float - $lat_min_int;
$lat_sec_int = sprintf("%02d", round($lat_min_frac * 60));
return array($dir, $lat_h_int, $lat_min_int, $lat_sec_int, $lat_min_float);
}
// create qth locator
public function latlongToQTH($lat, $lon)
{
$lon += 180;
$l[0] = floor($lon/20);
$lon -= 20*$l[0];
$l[2] = floor($lon/2);
$lon -= 2 *$l[2];
$l[4] = floor($lon*60/5);
$lat += 90;
$l[1] = floor($lat/10);
$lat -= 10*$l[1];
$l[3] = floor($lat);
$lat -= $l[3];
$l[5] = floor($lat*120/5);
return sprintf("%c%c%c%c%c%c", $l[0]+65, $l[1]+65, $l[2]+48, $l[3]+48, $l[4]+65, $l[5]+65);
}
}

View File

@ -0,0 +1,565 @@
<?php
/****************************************************************************
_ _ _
___ _ __ ___ _ _ __ __ _ __| |_ (_)_ _ __ _ __| |___
/ _ \ '_ \/ -_) ' \/ _/ _` / _| ' \| | ' \/ _` |_/ _` / -_)
\___/ .__/\___|_||_\__\__,_\__|_||_|_|_||_\__, (_)__,_\___|
|_| |___/
For license information see doc/license.txt --- Unicode Reminder メモ
****************************************************************************/
namespace OpencachingDE\Data;
class RowEditor
{
const TYPE_INT = 1;
const TYPE_STRING = 2;
const TYPE_BOOLEAN = 3;
const TYPE_DATE = 4;
const TYPE_FLOAT = 5;
const TYPE_DOUBLE = 6;
const INSERT_NOTHING = 0; //
const INSERT_OVERWRITE = 1; // ignore given values and use function
const INSERT_IGNORE = 2; // dont use this column on insert
const INSERT_AUTOINCREMENT = 4; // column is an auto increment column
const INSERT_AUTOUUID = 8; // if empty, UUID is generated by before insert trigger (not supported for primary key fields)
const INSERT_NOW = 16; // NOW()
private $sTable;
private $sAutoIncrementField = null;
private $pk; // (idx:name; type, default, nullable, value, insertfunction)
private $fields; // (idx:name; type, default, nullable, value, changed, insertfunction)
// status var
private $bLoaded = false;
private $bExist = false;
private $bAddNew = false;
/* primaryKey may be an array
*/
public function __construct($sTable)
{
$this->pk = array();
$this->fields = array();
$this->sTable = $sTable;
}
private function addPK($sField, $type, $default, $bNullable, $nInsertFunction = RowEditor::INSERT_NOTHING)
{
$this->pk[$sField] = array(
'type' => $type,
'default' => $default,
'nullable' => $bNullable,
'value' => $default,
'insertfunction' => $nInsertFunction,
);
}
public function addPKInt($sField, $nDefault, $bNullable, $nInsertFunction = RowEditor::INSERT_NOTHING)
{
$this->addPK($sField, static::TYPE_INT, $nDefault, $bNullable, $nInsertFunction);
if (($nInsertFunction & static::INSERT_AUTOINCREMENT) == static::INSERT_AUTOINCREMENT) {
$this->sAutoIncrementField = $sField;
}
}
public function addPKFloat($sField, $nDefault, $bNullable, $nInsertFunction = RowEditor::INSERT_NOTHING)
{
$this->addPK($sField, static::TYPE_FLOAT, $nDefault, $bNullable, $nInsertFunction);
}
public function addPKDouble($sField, $nDefault, $bNullable, $nInsertFunction = RowEditor::INSERT_NOTHING)
{
$this->addPK($sField, static::TYPE_DOUBLE, $nDefault, $bNullable, $nInsertFunction);
}
public function addPKString($sField, $sDefault, $bNullable, $nInsertFunction = RowEditor::INSERT_NOTHING)
{
if (($nInsertFunction & static::INSERT_AUTOUUID) == static::INSERT_AUTOUUID) {
die('RowEditor: RowEditor::INSERT_AUTOUUID not supported for primary key fields');
}
$this->addPK($sField, static::TYPE_STRING, $sDefault, $bNullable, $nInsertFunction);
}
public function addPKBoolean($sField, $bDefault, $bNullable, $nInsertFunction = RowEditor::INSERT_NOTHING)
{
$this->addPK($sField, static::TYPE_BOOLEAN, $bDefault, $bNullable, $nInsertFunction);
}
public function addPKDate($sField, $dDefault, $bNullable, $nInsertFunction = RowEditor::INSERT_NOTHING)
{
$this->addPK($sField, static::TYPE_DATE, $dDefault, $bNullable, $nInsertFunction);
}
private function addField($sField, $type, $default, $bNullable, $nInsertFunction = RowEditor::INSERT_NOTHING)
{
$this->fields[$sField] = array(
'type' => $type,
'default' => $default,
'nullable' => $bNullable,
'value' => $default,
'changed' => false,
'insertfunction' => $nInsertFunction,
);
}
public function addInt($sField, $nDefault, $bNullable, $nInsertFunction = RowEditor::INSERT_NOTHING)
{
$this->addField($sField, static::TYPE_INT, $nDefault, $bNullable, $nInsertFunction);
}
public function addFloat($sField, $nDefault, $bNullable, $nInsertFunction = RowEditor::INSERT_NOTHING)
{
$this->addField($sField, static::TYPE_FLOAT, $nDefault, $bNullable, $nInsertFunction);
}
public function addDouble($sField, $nDefault, $bNullable, $nInsertFunction = RowEditor::INSERT_NOTHING)
{
$this->addField($sField, static::TYPE_DOUBLE, $nDefault, $bNullable, $nInsertFunction);
}
public function addString($sField, $sDefault, $bNullable, $nInsertFunction = RowEditor::INSERT_NOTHING)
{
$this->addField($sField, static::TYPE_STRING, $sDefault, $bNullable, $nInsertFunction);
}
public function addBoolean($sField, $bDefault, $bNullable, $nInsertFunction = RowEditor::INSERT_NOTHING)
{
$this->addField($sField, static::TYPE_BOOLEAN, $bDefault, $bNullable, $nInsertFunction);
}
public function addDate($sField, $dDefault, $bNullable, $nInsertFunction = RowEditor::INSERT_NOTHING)
{
$this->addField($sField, static::TYPE_DATE, $dDefault, $bNullable, $nInsertFunction);
}
public function removePK($sField)
{
unset($this->pk[$sField]);
}
public function removeField($sField)
{
unset($this->fields[$sField]);
}
/* PKValues may be an string, indized or ordered array
*/
public function load($PKValues)
{
$this->pSetPK($PKValues);
$this->bLoaded = true;
$this->bAddNew = false;
$this->bExist = false;
$rs = sql($this->pBuildSelect());
if (!$r = sql_fetch_assoc($rs)) {
$this->bExist = false;
return false;
}
// assign values
foreach ($this->fields as $k => $field) {
$this->fields[$k]['value'] = $this->pFormatValue($this->fields[$k]['type'], $r[$k]);
$this->fields[$k]['changed'] = false;
}
$this->bExist = true;
return true;
}
public function addNew($PKValues)
{
$this->pSetPK($PKValues);
$this->bLoaded = true;
$this->bExist = false;
$this->bAddNew = true;
}
public function exist()
{
return $this->bExist;
}
public function pSetPK($PKValues)
{
$this->pResetValues();
foreach ($this->pk as $k => $field) {
$this->pk[$k]['value'] = $field['default'];
}
if (is_array($PKValues)) {
foreach ($PKValues as $k => $v) {
$pkKey = $this->pGetPKKey($k);
$this->pk[$pkKey]['value'] = $this->pFormatValue($this->pk[$pkKey]['type'], $v);
}
} else {
$pkKey = $this->pGetPKKey(0);
$this->pk[$pkKey]['value'] = $this->pFormatValue($this->pk[$pkKey]['type'], $PKValues);
}
}
public function pGetPKKey($index)
{
if (isset($this->pk[$index])) {
return $index;
}
$i = 0;
foreach ($this->pk as $k => $v) {
if ($i == $index) {
return $k;
}
$i++;
}
}
public function pResetValues()
{
foreach ($this->fields as $k => $field) {
$this->fields[$k]['value'] = $field['default'];
$this->fields[$k]['changed'] = false;
}
}
public function pFormatValue($type, $value)
{
if ($value === null) {
return null;
}
switch ($type) {
case static::TYPE_INT:
$value = (int)$value+0;
break;
case static::TYPE_FLOAT:
case static::TYPE_DOUBLE:
$value = $value+0.0;
break;
case static::TYPE_BOOLEAN:
$value = (($value+0) != 0);
break;
case static::TYPE_DATE:
if (!is_numeric($value)) {
$value = strtotime($value);
}
break;
}
return $value;
}
public function pFormatValueSql($type, $value)
{
switch ($type) {
case static::TYPE_INT:
$value = (int)$value+0;
break;
case static::TYPE_FLOAT:
case static::TYPE_DOUBLE:
$value = $value+0.0;
break;
case static::TYPE_BOOLEAN:
$value = (($value+0) != 0) ? 1 : 0;
break;
case static::TYPE_DATE:
if (!is_numeric($value)) {
$value = strtotime($value);
}
$value = strftime(DB_DATE_FORMAT, $value);
break;
}
return $value;
}
public function pBuildSelect()
{
$fselect = array();
$sql = 'SELECT ';
foreach ($this->fields as $k => $field) {
$fselect[] = '`' . sql_escape($k) . '`';
}
$sql .= join(', ', $fselect);
$sql .= ' FROM `' . sql_escape($this->sTable) . '`';
$sql .= ' WHERE ' . $this->pBuildPK();
return $sql;
}
public function pBuildPK()
{
$fwhere = array();
foreach ($this->pk as $k => $field) {
if ($field['value'] === null) {
$fwhere[] = 'ISNULL(`' . sql_escape($k) . '`)';
} else {
$fwhere[] = '`' . sql_escape($k) . '`=\'' . sql_escape($field['value']) . '\'';
}
}
return join(' AND ', $fwhere);
}
public function getValue($sField)
{
if (isset($this->pk[$sField])) {
return $this->pk[$sField]['value'];
}
return $this->fields[$sField]['value'];
}
public function getDefault($sField)
{
return $this->fields[$sField]['default'];
}
public function getChanged($sField)
{
return $this->fields[$sField]['changed'];
}
public function getAnyChanged()
{
foreach ($this->fields as $field) {
if ($field['changed'] == true) {
return true;
}
}
}
public function setValue($sField, $sValue)
{
if ($this->bLoaded == false || ($this->bAddNew == false && $this->bExist == false)) {
return false;
}
$sFormatedValue = $this->pFormatValue($this->fields[$sField]['type'], $sValue);
if ($this->fields[$sField]['type'] == static::TYPE_FLOAT) {
// Direct float comparison is deprecated and can result in last-digit errors.
// Floats in OC database are only used for reasonably large numbers like coordinates,
// waylengths and time estimates, so using a fixed epsilon threshold is safe:
$changed = (abs($sFormatedValue - $this->fields[$sField]['value']) >= 1e-12);
} else {
$changed = ($sFormatedValue != $this->fields[$sField]['value']);
}
if ($changed) {
$this->fields[$sField]['value'] = $sFormatedValue;
$this->fields[$sField]['changed'] = true;
}
return true;
}
public function save()
{
if ($this->bLoaded == false || ($this->bAddNew == false && $this->bExist == false)) {
return false;
}
if ($this->bAddNew == true) {
// INSERT
$sql = $this->pBuildInsert();
if ($sql != '') {
sql($sql);
if (sql_affected_rows() == 0) {
return false;
}
} else {
return true;
}
if ($this->sAutoIncrementField != null) {
$nInsertId = sql_insert_id();
$this->pk[$this->sAutoIncrementField]['value'] = $nInsertId;
if (isset($this->fields[$this->sAutoIncrementField])) {
$this->fields[$this->sAutoIncrementField]['value'] = $nInsertId;
}
}
/* reload the record to get the actual stored values
* (inserted values maybe truncated by mysql or trigger could modify values)
*/
$pkv = array();
foreach ($this->pk as $k => $v) {
$pkv[$k] = $this->pk[$k]['value'];
}
$this->load($pkv);
return true;
} else {
// UPDATE
$sql = $this->pBuildUpdate();
if ($sql != '') {
$rs = sql($sql);
if (sql_affected_rows($rs) == 0) {
return false;
}
} else {
return true;
}
foreach ($this->fields as $k => $field) {
$this->fields[$k]['changed'] = false;
}
return true;
}
}
public function reload()
{
$pkv = array();
foreach ($this->pk as $k => $v) {
$pkv[$k] = $this->pk[$k]['value'];
}
$this->load($pkv);
}
public function pBuildInsert()
{
$sql = 'INSERT IGNORE INTO `' . sql_escape($this->sTable) . '` (';
$sFields = array();
$sValues = array();
foreach ($this->pk as $k => $field) {
if (isset($this->fields[$k])) {
continue;
}
if ($this->sAutoIncrementField == $k) {
continue;
}
if (($field['insertfunction'] & static::INSERT_IGNORE) == static::INSERT_IGNORE) {
continue;
}
$sFields[] = '`' . sql_escape($k) . '`';
if ((($field['insertfunction'] & static::INSERT_OVERWRITE) == static::INSERT_OVERWRITE) || (($field['changed'] == false) && ($field['insertfunction'] != static::INSERT_NOTHING))) {
if (($field['insertfunction'] & static::INSERT_NOW) == static::INSERT_NOW) {
$sValues[] = 'NOW()';
} else {
$sValues[] = 'NULL';
}
} else {
if ($field['value'] === null) {
$sValues[] = 'NULL';
} else {
$sValues[] = '\'' . sql_escape($this->pFormatValueSql($field['type'], $field['value'])) . '\'';
}
}
}
foreach ($this->fields as $k => $field) {
if (($field['insertfunction'] & static::INSERT_IGNORE) == static::INSERT_IGNORE) {
continue;
}
$sFields[] = '`' . sql_escape($k) . '`';
if ((($field['insertfunction'] & static::INSERT_OVERWRITE) == static::INSERT_OVERWRITE) || (($field['changed'] == false) && ($field['insertfunction'] != static::INSERT_NOTHING))) {
if (($field['insertfunction'] & static::INSERT_NOW) == static::INSERT_NOW) {
$sValues[] = 'NOW()';
} else {
$sValues[] = 'NULL';
}
} else {
if ($field['value'] === null) {
$sValues[] = 'NULL';
} else {
$sValues[] = '\'' . sql_escape($this->pFormatValueSql($field['type'], $field['value'])) . '\'';
}
}
}
$sql .= join(', ', $sFields);
$sql .= ') VALUES (';
$sql .= join(', ', $sValues);
$sql .= ')';
return $sql;
}
public function pBuildUpdate()
{
$sql = 'UPDATE IGNORE `' . sql_escape($this->sTable) . '` SET ';
$sSet = '';
foreach ($this->fields as $k => $field) {
if ($field['changed'] == true) {
if ($sSet != '') {
$sSet .= ', ';
}
if ($field['value'] === null) {
$sSet .= '`' . sql_escape($k) . '`=NULL';
} else {
$sSet .= '`' . sql_escape($k) . '`=\'' . sql_escape($this->pFormatValueSql($field['type'], $field['value'])) . '\'';
}
}
}
if ($sSet == '') {
return '';
}
$sql .= $sSet;
$sql .= ' WHERE ';
$sql .= $this->pBuildPK();
return $sql;
}
public function saveField($field)
{
if ($this->bLoaded == false || $this->bExist == false || $this->bAddNew == true) {
return false;
}
if ($this->fields[$field]['changed'] == false) {
return true;
}
if ($this->fields[$field]['value'] === null) {
$sSet = '`' . sql_escape($field) . '`=NULL';
} else {
$sSet = '`' . sql_escape($field) . '`=\'' . sql_escape($this->pFormatValueSql($this->fields[$field]['type'], $this->fields[$field]['value'])) . '\'';
}
$sql = 'UPDATE `' . sql_escape($this->sTable) . '` SET ' . $sSet;
$sql .= ' WHERE ';
$sql .= $this->pBuildPK();
sql($sql);
if (sql_affected_rows() == 0) {
return false;
}
$this->fields[$field]['changed'] = false;
return true;
}
}

View File

@ -0,0 +1,151 @@
<?php
/****************************************************************************
_ _ _
___ _ __ ___ _ _ __ __ _ __| |_ (_)_ _ __ _ __| |___
/ _ \ '_ \/ -_) ' \/ _/ _` / _| ' \| | ' \/ _` |_/ _` / -_)
\___/ .__/\___|_||_\__\__,_\__|_||_|_|_||_\__, (_)__,_\___|
|_| |___/
For license information see doc/license.txt --- Unicode Reminder メモ
****************************************************************************/
namespace OpencachingDE\Generator;
class Mail extends \Smarty
{
public $name = 'sys_nothing';
public $main_template = 'sys_main';
public $compile_id = null;
public $from = '';
public $to = '';
public $subject = '';
public $replyTo = null;
public $returnPath = null;
public $headers = array();
public function __construct()
{
global $opt;
$this->template_dir = $GLOBALS['container']->get('ocde.config')->getBaseDir() . '/templates2/mail/';
$this->compile_dir = $GLOBALS['container']->get('ocde.config')->getBaseDir() . '/cache2/smarty/compiled/';
$this->plugins_dir = array('plugins', 'ocplugins');
// disable caching ...
$this->caching = false;
// register additional functions
$this->load_filter('pre', 't');
// cache control
if (($opt['debug'] & DEBUG_TEMPLATES) == DEBUG_TEMPLATES) {
$this->force_compile = true;
}
$this->from = $opt['mail']['from'];
}
public function get_compile_id()
{
global $opt;
return 'mail|' . $opt['template']['locale'] . '|' . $this->compile_id;
}
public function assign_rs($name, $rs)
{
$items = array();
while ($row = sql_fetch_assoc($rs)) {
$items[] = $row;
}
$this->assign($name, $items);
}
function send()
{
global $tpl, $opt;
if (!$this->template_exists($this->name . '.tpl')) {
$tpl->error(ERROR_MAIL_TEMPLATE_NOT_FOUND);
}
$this->assign('template', $this->name);
$optn['mail']['contact'] = $opt['mail']['contact'];
$optn['page']['absolute_url'] = $opt['page']['absolute_url'];
$optn['format'] = $opt['locale'][$opt['template']['locale']]['format'];
$this->assign('opt', $optn);
$this->assign('to', $this->to);
$this->assign('from', $this->from);
$this->assign('subject', $this->subject);
$llogin['username'] = $GLOBALS['container']->get('ocde.login')->getUsername();
$this->assign('login', $llogin);
$body = $this->fetch($this->main_template . '.tpl', '', $this->get_compile_id());
// check if the target domain exists if the domain does not
// exist, the mail is sent to the own domain (?!)
$domain = mail::getToMailDomain($this->to);
if (mail::is_existent_maildomain($domain) == false) {
return false;
}
$aAddHeaders = array();
$aAddHeaders[] = 'From: "' . $this->from . '" <' . $this->from . '>';
if ($this->replyTo !== null) {
$aAddHeaders[] = 'Reply-To: ' . $this->replyTo;
}
if ($this->returnPath !== null) {
$aAddHeaders[] = 'Return-Path: ' . $this->returnPath;
}
$mailheaders = implode("\n", array_merge($aAddHeaders, $this->headers));
return mb_send_mail($this->to, $opt['mail']['subject'] . $this->subject, $body, $mailheaders);
}
public static function is_existent_maildomain($domain)
{
if ($domain == "localhost") {
return true; // allow maintenance mails e.g. to root
}
$smtp_serverlist = array();
$smtp_serverweight = array();
if (getmxrr($domain, $smtp_serverlist, $smtp_serverweight) != false) {
if (count($smtp_serverlist)>0) {
return true;
}
}
// check if A exists
$a = dns_get_record($domain, DNS_A);
if (count($a) > 0) {
return true;
}
return false;
}
public static function getToMailDomain($mail)
{
if ($mail == '') {
return '';
}
if (strrpos($mail, '@') === false) {
$domain = 'localhost';
} else {
$domain = substr($mail, strrpos($mail, '@') + 1);
}
return $domain;
}
}

View File

@ -0,0 +1,115 @@
<?php
/****************************************************************************
_ _ _
___ _ __ ___ _ _ __ __ _ __| |_ (_)_ _ __ _ __| |___
/ _ \ '_ \/ -_) ' \/ _/ _` / _| ' \| | ' \/ _` |_/ _` / -_)
\___/ .__/\___|_||_\__\__,_\__|_||_|_|_||_\__, (_)__,_\___|
|_| |___/
For license information see doc/license.txt --- Unicode Reminder メモ
****************************************************************************/
/*
Set template variables for displaying a page browser control.
Output is formatted by templates2/<style>/res_pager.tpl.
*/
namespace OpencachingDE\Generator;
class Pager
{
private $link_url;
private $min_pages_shown;
private $max_pages_shown;
// Use {page} in link_url als placeholder for the selected page number
// and/or {offset} for the 0-based data offset of the selected page.
public function __construct($link_url, $min_pages_shown = 2, $max_pages_shown = 15)
{
global $tpl;
$this->link_url = $link_url;
$this->min_pages_shown = $min_pages_shown;
if (($max_pages_shown % 2) == 0) {
$tpl->error("pager: max pages shown must be odd");
}
$this->max_pages_shown = $max_pages_shown;
}
public function make_from_pagenr($current_page, $total_pages, $page_size = false)
{
global $tpl;
if (mb_strpos($this->link_url, '{offset}') && $page_size === false) {
$tpl->error('page size is not set for offset paging');
} elseif ($total_pages < $this->min_pages_shown) {
// not enough pages - disable pager
$tpl->assign('pages_list', false);
} else {
$first_page = 1;
$last_page = $total_pages;
$current_page = min(max($current_page, $first_page), $last_page);
if ($current_page == $first_page) {
$tpl->assign('pages_first_link', false);
$tpl->assign('pages_prev_link', false);
} else {
$tpl->assign('pages_first_link', $this->pagelink($first_page, $page_size));
$tpl->assign('pages_prev_link', $this->pagelink($current_page-1, $page_size));
}
$pages = array();
$lrspan = ($this->max_pages_shown-1) / 2;
$from_page = max($first_page, $current_page-$lrspan);
$to_page = min($last_page, max($first_page, $current_page-$lrspan) + $this->max_pages_shown - 1);
$from_page = max($first_page, $to_page - $this->max_pages_shown + 1);
for ($page = $from_page; $page <= $to_page; $page++) {
if ($page == $current_page) {
$pages[$page] = false;
} else {
$pages[$page] = $this->pagelink($page, $page_size);
}
}
$tpl->assign('pages_list', $pages);
if ($current_page == $last_page) {
$tpl->assign('pages_next_link', false);
$tpl->assign('pages_last_link', false);
} else {
$tpl->assign('pages_next_link', $this->pagelink($current_page+1, $page_size));
$tpl->assign('pages_last_link', $this->pagelink($last_page, $page_size));
}
if ($last_page-$first_page < 2) {
$tpl->assign('pages_first_link', null);
$tpl->assign('pages_last_link', null);
}
}
}
public function make_from_offset($current_offset, $total_items, $page_size)
{
$this->make_from_pagenr(
floor($current_offset/$page_size) + 1,
ceil($total_items/$page_size),
$page_size
);
}
private function pagelink($page, $page_size)
{
return mb_ereg_replace(
'{page}',
$page,
mb_ereg_replace('{offset}', ($page-1) * $page_size, $this->link_url)
);
}
}

View File

@ -0,0 +1,270 @@
<?php
/** SS_ZIP class is designed to work with ZIP archives
@author Yuriy Horobey, smiledsoft.com
@email info@smiledsoft.com
Unicode Reminder メモ
*/
namespace OpencachingDE\Legacy
class SsZip
{
/** contains whole zipfile
@see ss_zip::archive()
@see ss_zip::ss_zip()
*/
var $zipfile="";
/** compression level */
var $complevel=6;
/** entry counter */
var $cnt=0;
/** current offset in zipdata segment */
var $offset=0;
/** index of current entry
@see ss_zip::read()
*/
var $idx=0;
/**
ZipData segment, each element of this array contains local file header plus zipped data
*/
var $zipdata=array();
/** central directory array */
var $cdir=array();
/** constructor
@param string zipfile if not empty must contain path to valid zip file, ss_zip will try to open and parse it.
If this parameter is empty, the new empty zip archive is created. This parameter has no meaning in LIGHT verion, please upgrade to PROfessional version.
@param int complevel compression level, 1-minimal compression, 9-maximal, default is 6
*/
function ss_zip($zipfile="",$complevel=6){
$this->clear();
if($complevel<1)$complevel=1;
if($complevel>9)$complevel=9;
$this->complevel=$complevel;
$this->open($zipfile);
}
/**Resets the objec, clears all the structures
*/
function clear(){
$this->zipfile="";
$this->complevel=6;
$this->cnt=0;
$this->offset=0;
$this->idx=0;
$this->zipdata=array();
$this->cdir=array();
}
/**opens zip file.
<center><hr nashade>*** This functionality is available in PRO version only. ***<br><a href='http://smiledsoft.com/demos/phpzip/' target='_blank'>please upgrade </a><hr nashade></center>
This function opens file pointed by zipfile parameter and creates all necessary structures
@param str zipfile path to the file
@param bool append if true the newlly opened archive will be appended to existing object structure
*/
function open($zipfile, $append=false){}
/**saves to the disc or sends zipfile to the browser.
@param str zipfile path under which to store the file on the server or file name under which the browser will receive it.
If you are saving to the server, you are responsible to obtain appropriate write permissions for this operation.
@param char where indicates where should the file be sent
<ul>
<li>'f' -- filesystem </li>
<li>'b' -- browser</li>
<li>'r' -- raw</li>
</ul>
Please remember that there should not be any other output before you call this function. The only exception is
that other headers may be sent. See <a href='http://php.net/header' target='_blank'>http://php.net/header</a>
*/
function save($zipfile, $where='f'){
if(!$this->zipfile)$this->archive();
$zipfile=trim($zipfile);
if(strtolower(trim($where))=='f'){
$this->_write($zipfile,$this->zipfile);
}elseif(strtolower(trim($where))=='r'){
$zipfile = basename($zipfile);
print $this->archive();
}else{
$zipfile = basename($zipfile);
header("Content-type: application/octet-stream");
header("Content-disposition: attachment; filename=\"$zipfile\"");
print $this->archive();
}
}
/** adds data to zip file
@param str filename path under which the content of data parameter will be stored into the zip archive
@param str data content to be stored under name given by path parameter
@see ss_zip::add_file()
*/
function add_data($filename,$data=null){
$filename=trim($filename);
$filename=str_replace('\\', '/', $filename);
if($filename[0]=='/') $filename=substr($filename,1);
if( ($attr=(($datasize = strlen($data))?32:16))==32 ){
$crc = crc32($data);
$gzdata = gzdeflate($data,$this->complevel);
$gzsize = strlen($gzdata);
$dir=dirname($filename);
// if($dir!=".") $this->add_data("$dir/");
}else{
$crc = 0;
$gzdata = "";
$gzsize = 0;
}
$fnl=strlen($filename);
$fh = "\x14\x00"; // ver needed to extract
$fh .= "\x00\x00"; // gen purpose bit flag
$fh .= "\x08\x00"; // compression method
$fh .= "\x00\x00\x00\x00"; // last mod time and date
$fh .=pack("V3v2",
$crc, //crc
$gzsize,//c size
$datasize,//unc size
$fnl, //fname lenght
0 //extra field length
);
//local file header
$lfh="PK\x03\x04";
$lfh .= $fh.$filename;
$zipdata = $lfh;
$zipdata .= $gzdata;
$zipdata .= pack("V3",$crc,$gzsize,$datasize);
$this->zipdata[]=$zipdata;
//Central Directory Record
$cdir="PK\x01\x02";
$cdir.=pack("va*v3V2",
0,
$fh,
0, // file comment length
0, // disk number start
0, // internal file attributes
$attr, // external file attributes - 'archive/directory' bit set
$this->offset
).$filename;
$this->offset+= 42+$fnl+$gzsize;
$this->cdir[]=$cdir;
$this->cnt++;
$this->idx = $this->cnt-1;
}
/** adds a file to the archive
@param str filename contains valid path to file to be stored in the arcive.
@param str storedasname the path under which the file will be stored to the archive. If empty, the file will be stored under path given by filename parameter
@see ss_zip::add_data()
*/
function add_file($filename, $storedasname=""){
$fh= fopen($filename,"r");
$data=fread($fh,filesize($filename));
if(!trim($storedasname))$storedasname=$filename;
return $this->add_data($storedasname, $data);
}
/** compile the arcive.
This function produces ZIP archive and returns it.
@return str string with zipfile
*/
function archive(){
if(!$this->zipdata) return "";
$zds=implode('',$this->zipdata);
$cds=implode('',$this->cdir);
$zdsl=strlen($zds);
$cdsl=strlen($cds);
$this->zipfile=
$zds
.$cds
."PK\x05\x06\x00\x00\x00\x00"
.pack('v2V2v'
,$this->cnt // total # of entries "on this disk"
,$this->cnt // total # of entries overall
,$cdsl // size of central dir
,$zdsl // offset to start of central dir
,0); // .zip file comment length
return $this->zipfile;
}
/** changes pointer to current entry.
Most likely you will always use it to 'rewind' the archive and then using read()
Checks for bopundaries, so will not allow index to be set to values < 0 ro > last element
@param int idx the new index to which you want to rewind the archive curent pointer
@return int idx the index to which the curent pointer was actually set
@see ss_zip::read()
*/
function seek_idx($idx){
if($idx<0)$idx=0;
if($idx>=$this->cnt)$idx=$this->cnt-1;
$this->idx=$idx;
return $idx;
}
/** Reads an entry from the arcive which is pointed by inner index pointer.
<center><hr nashade>*** This functionality is available in PRO version only. ***<br><a href='http://smiledsoft.com/demos/phpzip/' target='_blank'>please upgrade </a><hr nashade></center>
The curent index can be changed by seek_idx() method.
@return array Returns associative array of the following structure
<ul>
<li>'idx'=> index of the entry </li>
<li>'name'=>full path to the entry </li>
<li>'attr'=>integer file attribute of the entry </li>
<li>'attrstr'=>string file attribute of the entry <br>
This can be:
<ul>
<li>'file' if the integer attribute was 32</li>
<li>'dir' if the integer attribute was 16 or 48</li>
<li>'unknown' for other values</li>
</ul>
</li>
</ul>
@see ss_zip::seek_idx()
*/
function read(){}
/** Removes entry from the archive.
please be very carefull with this function, there is no undo after you save the archive
@return bool true on success or false on failure
@param int idx
*/
function remove($idx){}
/** extracts data from the archive and return it as a string.
<center><hr nashade>*** This functionality is available in PRO version only. ***<br><a href='http://smiledsoft.com/demos/phpzip/' target='_blank'>please upgrade </a><hr nashade></center>
This function returns data identified by idx parameter.
@param int idx index of the entry
@return array returns associative array of the folloving structure:
<ul>
<li>'file' path under which the entry is stored in the archive</li>
<li>'data' In case if the entry was file, contain its data. For directory entry this is empty</li>
<li>'size' size of the data</li>
<li>'error' the error if any has happened. The bit 0 indicates incorect datasize, bit 1 indicates CRC error</li>
</ul>
@see ss_zip::extract_file
*/
function extract_data($idx){}
/** extracts the entry and creates it in the file system.
<center><hr nashade>*** This functionality is available in PRO version only. ***<br><a href='http://smiledsoft.com/demos/phpzip/' target='_blank'>please upgrade </a><hr nashade></center>
@param int idx Index of the entry
@param string path the first part of the path where the entry will be stored. So if this
is '/my/server/path' and entry is arhived/file/path/file.txt then the function will attempt to
store it under /my/server/path/arhived/file/path/file.txt You are responsible to ensure that you
have write permissions for this operation under your operation system.
*/
function extract_file($idx,$path="."){}
function _check_idx($idx){
return $idx>=0 and $idx<$this->cnt;
}
function _write($name,$data){
$fp=fopen($name,"w");
fwrite($fp,$data);
fclose($fp);
}
}

View File

@ -0,0 +1,58 @@
<?php
/****************************************************************************
_ _ _
___ _ __ ___ _ _ __ __ _ __| |_ (_)_ _ __ _ __| |___
/ _ \ '_ \/ -_) ' \/ _/ _` / _| ' \| | ' \/ _` |_/ _` / -_)
\___/ .__/\___|_||_\__\__,_\__|_||_|_|_||_\__, (_)__,_\___|
|_| |___/
For license information see doc/license.txt --- Unicode Reminder メモ
****************************************************************************/
namespace OpencachingDE\Logging;
// Keep a loose Monolog compatibility to make it easier to replace it later
class ChromePhp implements LoggingInterface
{
public function __construct()
{
}
public function debug($message, array $context = array())
{
\ChromePhp::log($message);
}
public function info($message, array $context = array())
{
\ChromePhp::info($message);
}
public function notice($message, array $context = array())
{
\ChromePhp::info($message);
}
public function warning($message, array $context = array())
{
\ChromePhp::warn($message);
}
public function error($message, array $context = array())
{
\ChromePhp::error($message);
}
public function critical($message, array $context = array())
{
\ChromePhp::error($message);
}
public function emergency($message, array $context = array())
{
\ChromePhp::error($message);
}
}

View File

@ -0,0 +1,63 @@
<?php
/****************************************************************************
_ _ _
___ _ __ ___ _ _ __ __ _ __| |_ (_)_ _ __ _ __| |___
/ _ \ '_ \/ -_) ' \/ _/ _` / _| ' \| | ' \/ _` |_/ _` / -_)
\___/ .__/\___|_||_\__\__,_\__|_||_|_|_||_\__, (_)__,_\___|
|_| |___/
For license information see doc/license.txt --- Unicode Reminder メモ
****************************************************************************/
namespace OpencachingDE\Logging;
// Keep a loose Monolog compatibility to make it easier to replace it later
class Console implements LoggingInterface
{
public function __construct()
{
}
private function log($tag, $message)
{
echo '[' . $tag . '] ' . $message . PHP_EOL;
}
public function debug($message, array $context = array())
{
$this->log('DEBUG', $message);
}
public function info($message, array $context = array())
{
$this->log('INFO', $message);
}
public function notice($message, array $context = array())
{
$this->log('NOTICE', $message);
}
public function warning($message, array $context = array())
{
$this->log('WARNING', $message);
}
public function error($message, array $context = array())
{
$this->log('ERROR', $message);
}
public function critical($message, array $context = array())
{
$this->log('CRITICAL', $message);
}
public function emergency($message, array $context = array())
{
$this->log('EMERGENCY', $message);
}
}

View File

@ -0,0 +1,56 @@
<?php
/****************************************************************************
_ _ _
___ _ __ ___ _ _ __ __ _ __| |_ (_)_ _ __ _ __| |___
/ _ \ '_ \/ -_) ' \/ _/ _` / _| ' \| | ' \/ _` |_/ _` / -_)
\___/ .__/\___|_||_\__\__,_\__|_||_|_|_||_\__, (_)__,_\___|
|_| |___/
For license information see doc/license.txt --- Unicode Reminder メモ
****************************************************************************/
namespace OpencachingDE\Logging;
// Keep a loose Monolog compatibility to make it easier to replace it later
class File implements LoggingInterface
{
public function __construct()
{
}
public function debug($message, array $context = array())
{
}
public function info($message, array $context = array())
{
}
public function notice($message, array $context = array())
{
}
public function warning($message, array $context = array())
{
}
public function error($message, array $context = array())
{
}
public function critical($message, array $context = array())
{
}
public function emergency($message, array $context = array())
{
}
}

View File

@ -0,0 +1,33 @@
<?php
/****************************************************************************
_ _ _
___ _ __ ___ _ _ __ __ _ __| |_ (_)_ _ __ _ __| |___
/ _ \ '_ \/ -_) ' \/ _/ _` / _| ' \| | ' \/ _` |_/ _` / -_)
\___/ .__/\___|_||_\__\__,_\__|_||_|_|_||_\__, (_)__,_\___|
|_| |___/
For license information see doc/license.txt --- Unicode Reminder メモ
****************************************************************************/
namespace OpencachingDE\Logging;
// Keep a loose Monolog compatibility to make it easier to replace it later
interface LoggingInterface
{
public function debug($message, array $context = array());
public function info($message, array $context = array());
public function notice($message, array $context = array());
public function warning($message, array $context = array());
public function error($message, array $context = array());
public function critical($message, array $context = array());
public function emergency($message, array $context = array());
}

View File

@ -0,0 +1,51 @@
<?php
/****************************************************************************
_ _ _
___ _ __ ___ _ _ __ __ _ __| |_ (_)_ _ __ _ __| |___
/ _ \ '_ \/ -_) ' \/ _/ _` / _| ' \| | ' \/ _` |_/ _` / -_)
\___/ .__/\___|_||_\__\__,_\__|_||_|_|_||_\__, (_)__,_\___|
|_| |___/
For license information see doc/license.txt --- Unicode Reminder メモ
****************************************************************************/
namespace OpencachingDE\Logging;
// Keep a loose Monolog compatibility to make it easier to replace it later
class Null implements LoggingInterface
{
public function __construct()
{
}
public function debug($message, array $context = array())
{
}
public function info($message, array $context = array())
{
}
public function notice($message, array $context = array())
{
}
public function warning($message, array $context = array())
{
}
public function error($message, array $context = array())
{
}
public function critical($message, array $context = array())
{
}
public function emergency($message, array $context = array())
{
}
}

View File

@ -0,0 +1,27 @@
<?php
/****************************************************************************
_ _ _
___ _ __ ___ _ _ __ __ _ __| |_ (_)_ _ __ _ __| |___
/ _ \ '_ \/ -_) ' \/ _/ _` / _| ' \| | ' \/ _` |_/ _` / -_)
\___/ .__/\___|_||_\__\__,_\__|_||_|_|_||_\__, (_)__,_\___|
|_| |___/
For license information see doc/license.txt --- Unicode Reminder メモ
****************************************************************************/
namespace OpencachingDE\Parser;
interface ParserInterface
{
/**
* Downloads and parses the item from $url for $items sub-items.
* @param int $items number of feeditems to parse from feed
* @param string $url url of the feed to parse
* @param bool $includetext Include description
* @return array feeditems
*/
public static function parse($items, $url, $includetext);
}

View File

@ -0,0 +1,93 @@
<?php
/****************************************************************************
_ _ _
___ _ __ ___ _ _ __ __ _ __| |_ (_)_ _ __ _ __| |___
/ _ \ '_ \/ -_) ' \/ _/ _` / _| ' \| | ' \/ _` |_/ _` / -_)
\___/ .__/\___|_||_\__\__,_\__|_||_|_|_||_\__, (_)__,_\___|
|_| |___/
For license information see doc/license.txt --- Unicode Reminder メモ
****************************************************************************/
namespace OpencachingDE\Parser;
class Rss implements ParserInterface
{
/**
* Downloads RSS feed from $url and parses it for $items items.
* @param int $items number of feeditems to parse from feed
* @param string $url url of the feed to parse
* @param bool $includetext Include description
* @return array feeditems
*/
public static function parse($items, $url, $includetext)
{
global $tpl;
if ($items <= 0) {
return '';
}
// check $url
if (!preg_match('!^(http|https|ftp)\://([a-zA-Z0-9\.\-]+(\:[a-zA-Z0-9\.&amp;%\$\-]+)*@)*((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])|localhost|([a-zA-Z0-9\-]+\.)*[a-zA-Z0-9\-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(\:[0-9]+)*(/($|[a-zA-Z0-9\.\:\,\?\'\\\+&amp;%\$#\=~_\-]+))*$!', $url)) {
return array();
}
$rss = array();
$tpl->assign('includetext', $includetext);
// get xml-data
$data = @file_get_contents($url);
// check data
if ($data !== false && strpos($data, 'rss version=') !== false) {
// parse XML
try {
// get SimpleXML-object
$xml = new \SimpleXMLElement($data);
$i = 0;
$headlines = array();
// walk through items
foreach ($xml->channel->item as $item) {
// check length
if ($items != 0 && $i >= $items) {
break;
}
// add html
if ($includetext) {
// fill array
$rss[] = array(
'pubDate' => strftime('%e. %B %Y', strtotime($item->pubDate)),
'title' => $item->title,
'link' => $item->link,
'description' => $item->description
);
} elseif (!in_array(htmlspecialchars_decode($item->title), $headlines) &&
strpos($item->title, 'VERSCHOBEN') === false) { // hack to exclude forum thread-move messages
// htmlspecialchars_decode() works around inconsistent HTML encoding
// e.g. in SMF Forum Threads
// fill array
$rss[] = array(
'pubDate' => strftime('%e. %B %Y', strtotime($item->pubDate)),
'title' => $item->title,
'link' => $item->link
);
$headlines[] = "" . htmlspecialchars_decode($item->title);
}
// increment counter
$i++;
}
} catch (Exception $e) {
$logger = $GLOBALS['container']->get('logger');
$logger->warning('Exception during Rss parsing: ' . $e->getMessage());
}
}
return $rss;
}
}

View File

@ -0,0 +1,219 @@
<?php
/****************************************************************************
_ _ _
___ _ __ ___ _ _ __ __ _ __| |_ (_)_ _ __ _ __| |___
/ _ \ '_ \/ -_) ' \/ _/ _` / _| ' \| | ' \/ _` |_/ _` / -_)
\___/ .__/\___|_||_\__\__,_\__|_||_|_|_||_\__, (_)__,_\___|
|_| |___/
For license information see doc/license.txt --- Unicode Reminder メモ
****************************************************************************/
namespace OpencachingDE\Util;
use OpencachingDE\Logging\LoggingInterface;
class Cookie
{
private $logger;
private $changed = false;
private $values = array();
private $session_initalized = false;
public function __construct(LoggingInterface $logger)
{
$this->logger = $logger;
global $opt;
if ($opt['session']['mode'] == SAVE_SESSION) {
if (isset($_REQUEST['SESSION']) && $_REQUEST['SESSION'] != '') {
$this->initSession();
}
} else {
if (isset($_COOKIE[$opt['session']['cookiename'] . 'data'])) {
//get the cookievars-array
$decoded = base64_decode($_COOKIE[$opt['session']['cookiename'] . 'data']);
if ($decoded !== false) {
$this->values = @unserialize($decoded);
if (!is_array($this->values)) {
$this->values = array();
}
} else {
$this->values = array();
}
}
}
}
private function initSession()
{
if ($this->session_initalized == true) {
return;
}
global $opt;
session_name('SESSION');
session_set_cookie_params($opt['session']['expire']['cookie'], $opt['session']['path'], $opt['session']['domain']);
session_start();
if ($opt['session']['check_referer']
&& isset($_SERVER['REFERER'])
&& strtolower(substr($_SERVER['REFERER'], 0, strlen($opt['page']['absolute_url']))) != strtolower($opt['page']['absolute_url'])
) {
$this->createNewSession();
}
if (isset($_REQUEST['SESSION']) && count($_SESSION) > 0) {
// comapre and set timestamp
if (isset($_SESSION['lastcall']) && (abs(time() - $_SESSION['lastcall']) > $opt['session']['expire']['url'])) {
$this->createNewSession();
}
$_SESSION['lastcall'] = time();
}
$this->session_initalized = true;
}
private function createNewSession()
{
session_regenerate_id();
$locale = isset($_SESSION['locale']) ? $_SESSION['locale'] : '';
foreach ($_SESSION AS $k => $v) {
unset($_SESSION[$k]);
}
if ($locale != '') {
$_SESSION['locale'] = $locale;
}
}
private function setSession($name, $value, $default = null)
{
if (!isset($_SESSION[$name]) || $_SESSION[$name] != $value) {
if ($value == $default) {
if (isset($_SESSION[$name])) {
unset($_SESSION[$name]);
$this->changed = true;
}
} else {
$this->initSession();
$_SESSION[$name] = $value;
$this->changed = true;
}
}
}
private function setCookie($name, $value, $default = null)
{
// Store cookie value in internal array. OcSmarty will call this->header()
// to actually set the cookie.
if (!isset($this->values[$name]) || $this->values[$name] != $value) {
if ($value == $default) {
if (isset($this->values[$name])) {
unset($this->values[$name]);
$this->changed = true;
}
} else {
$this->values[$name] = $value;
$this->changed = true;
}
}
}
public function set($name, $value, $default = null)
{
global $opt;
if ($opt['session']['mode'] == SAVE_SESSION) {
$this->setSession($name, $value, $default);
} else {
$this->setCookie($name, $value, $default);
}
}
public function get($name, $default = '')
{
global $opt;
if ($opt['session']['mode'] == SAVE_SESSION) {
return isset($_SESSION[$name]) ? $_SESSION[$name] : $default;
} else {
return isset($this->values[$name]) ? $this->values[$name] : $default;
}
}
function is_set($name)
{
global $opt;
if ($opt['session']['mode'] == SAVE_SESSION) {
return isset($_SESSION[$name]);
} else {
return isset($this->values[$name]);
}
}
public function un_set($name)
{
global $opt;
if ($opt['session']['mode'] == SAVE_SESSION) {
if (isset($_SESSION[$name])) {
unset($_SESSION[$name]);
$this->changed = true;
}
} else {
if (isset($this->values[$name])) {
unset($this->values[$name]);
$this->changed = true;
}
}
}
public function header()
{
global $opt;
if ($opt['session']['mode'] == SAVE_SESSION) {
// is autmatically sent
} else {
if ($this->changed == true) {
if (count($this->values) == 0) {
$this->logger->notice('Cookie data empty.');
setcookie($opt['session']['cookiename'] . 'data', false, time() + 31536000, $opt['session']['path'], $opt['session']['domain'], 0);
} else {
setcookie($opt['session']['cookiename'] . 'data', base64_encode(serialize($this->values)), time() + 31536000, $opt['session']['path'], $opt['session']['domain'], 0);
}
}
}
}
function debug()
{
global $opt;
if ($opt['session']['mode'] == SAVE_SESSION) {
print_r($_SESSION);
} else {
print_r($this->values);
}
exit;
}
public function close()
{
global $opt;
if ($opt['session']['mode'] == SAVE_SESSION) {
if ($this->session_initalized == true) {
if (count($_SESSION) == 0) {
@session_destroy();
} else {
session_write_close();
}
}
}
}
}

View File

@ -1,50 +0,0 @@
<?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;
$usr['admin'] = $login->admin;
}
else
$usr = false;
return;
}
?>

View File

@ -1,47 +0,0 @@
<?php
/****************************************************************************
For license information see doc/license.txt
Unicode Reminder メモ
****************************************************************************/
//
// bench.inc.php
//
class Cbench
{
var $start;
var $stop;
function CBench()
{
$this->start = 0;
$this->stop = 0;
}
function getmicrotime()
{
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
}
function start()
{
$this->start = $this->getmicrotime();
}
function stop()
{
$this->stop = $this->getmicrotime();
}
function diff()
{
$result = $this->stop - $this->start;
return $result;
}
function runTime()
{
$result = $this->getmicrotime() - $this->start;
return $result;
}
}
?>

View File

@ -1,189 +0,0 @@
<?php
/****************************************************************************
./lib/calculation.inc.php
--------------------
begin : Wed October 11 2006
For license information see doc/license.txt
****************************************************************************/
/****************************************************************************
Unicode Reminder メモ
all coordinate calculation related functions
Dont include this file by hand - it will be included from clicompatbase.inc.php
****************************************************************************/
function calcBearing($lat1, $lon1, $lat2, $lon2)
{
// Input sind Breite/Laenge in Altgrad
// Der Fall lat/lon1 == lat/lon2 sollte vorher abgefangen werden,
// zB. ueber die Abfrage der Distanz, dass Bearing nur bei Distanz > 5m
// geholt wird, sonst = " - " gesetzt wird...
if ($lat1 == $lat2 && $lon1 == $lon2)
{
return '-';
}
else
{
$pi = 3.141592653589793238462643383279502884197;
if ($lat1 == $lat2) $lat1 += 0.0000166;
if ($lon1 == $lon2) $lon1 += 0.0000166;
$rad_lat1 = $lat1 / 180.0 * $pi;
$rad_lon1 = $lon1 / 180.0 * $pi;
$rad_lat2 = $lat2 / 180.0 * $pi;
$rad_lon2 = $lon2 / 180.0 * $pi;
$delta_lon = $rad_lon2 - $rad_lon1;
$bearing = atan2 ( sin ( $delta_lon ) * cos ( $rad_lat2 ),
cos ( $rad_lat1 ) * sin ( $rad_lat2 ) - sin ( $rad_lat1 ) * cos ( $rad_lat2 ) * cos ( $delta_lon ) );
$bearing = 180.0 * $bearing / $pi;
// Output Richtung von lat/lon1 nach lat/lon2 in Altgrad von -180 bis +180
// wenn man Output von 0 bis 360 haben moechte, kann man dies machen:
if ( $bearing < 0.0 ) $bearing = $bearing + 360.0;
return $bearing;
}
}
function Bearing2Text($parBearing, $parShortText = 0)
{
if ($parShortText == 0)
{
if ($parBearing == '-')
{
return 'N/A';
}
elseif (($parBearing < 11.25) || ($parBearing > 348.75))
return 'Nord';
elseif ($parBearing < 33.75)
return 'Nord/Nordost';
elseif ($parBearing < 56.25)
return 'Nordost';
elseif ($parBearing < 78.75)
return 'Ost/Nordost';
elseif ($parBearing < 101.25)
return 'Ost';
elseif ($parBearing < 123.75)
return 'Ost/Südost';
elseif ($parBearing < 146.25)
return 'Südost';
elseif ($parBearing < 168.75)
return 'Süd/Südost';
elseif ($parBearing < 191.25)
return 'Süd';
elseif ($parBearing < 213.75)
return 'Süd/Südwest';
elseif ($parBearing < 236.25)
return 'Südwest';
elseif ($parBearing < 258.75)
return 'West/Südwest';
elseif ($parBearing < 281.25)
return 'West';
elseif ($parBearing < 303.75)
return 'West/Nordwest';
elseif ($parBearing < 326.25)
return 'Nordwest';
elseif ($parBearing <= 348.75)
return 'Nord/Nordwest';
else return 'N/A';
}
else
{
if ($parBearing == '-')
{
return 'N/A';
}
elseif (($parBearing < 11.25) || ($parBearing > 348.75))
return 'N';
elseif ($parBearing < 33.75)
return 'NNO';
elseif ($parBearing < 56.25)
return 'NO';
elseif ($parBearing < 78.75)
return 'ONO';
elseif ($parBearing < 101.25)
return 'O';
elseif ($parBearing < 123.75)
return 'OSO';
elseif ($parBearing < 146.25)
return 'SO';
elseif ($parBearing < 168.75)
return 'SSO';
elseif ($parBearing < 191.25)
return 'S';
elseif ($parBearing < 213.75)
return 'SSW';
elseif ($parBearing < 236.25)
return 'SW';
elseif ($parBearing < 258.75)
return 'WSW';
elseif ($parBearing < 281.25)
return 'W';
elseif ($parBearing < 303.75)
return 'WNW';
elseif ($parBearing < 326.25)
return 'NW';
elseif ($parBearing <= 348.75)
return 'NNW';
else return 'N/A';
}
}
function calcDistance($latFrom, $lonFrom, $latTo, $lonTo, $distanceMultiplier=1)
{
return acos(cos((90-$latFrom) * 3.14159 / 180) * cos((90-$latTo) * 3.14159 / 180) + sin((90-$latFrom) * 3.14159 / 180) * sin((90-$latTo) * 3.14159 / 180) * cos(($lonFrom-$lonTo) * 3.14159 / 180)) * 6370 * $distanceMultiplier;
}
function getSqlDistanceFormula($lonFrom, $latFrom, $maxDistance, $distanceMultiplier=1, $lonField='longitude', $latField='latitude', $tableName = 'caches')
{
$lonFrom = $lonFrom + 0;
$latFrom = $latFrom + 0;
$maxDistance = $maxDistance + 0;
$distanceMultiplier = $distanceMultiplier + 0;
if (!mb_ereg_match('^[a-zA-Z][a-zA-Z0-9_]{0,59}$', $lonField))
die('Fatal Error: invalid lonField');
if (!mb_ereg_match('^[a-zA-Z][a-zA-Z0-9_]{0,59}$', $latField))
die('Fatal Error: invalid latField');
if (!mb_ereg_match('^[a-zA-Z][a-zA-Z0-9_]{0,59}$', $tableName))
die('Fatal Error: invalid tableName');
$b1_rad = sprintf('%01.5f', (90 - $latFrom) * 3.14159 / 180);
$l1_deg = sprintf('%01.5f', $lonFrom);
$lonField = '`' . $tableName . '`.`' . $lonField . '`';
$latField = '`' . $tableName . '`.`' . $latField . '`';
$r = 6370 * $distanceMultiplier;
$retval = 'acos(cos(' . $b1_rad . ') * cos((90-' . $latField . ') * 3.14159 / 180) + sin(' . $b1_rad . ') * sin((90-' . $latField . ') * 3.14159 / 180) * cos((' . $l1_deg . '-' . $lonField . ') * 3.14159 / 180)) * ' . $r;
return $retval;
}
function getMaxLat($lon, $lat, $distance, $distanceMultiplier=1)
{
return $lat + $distance / (111.12 * $distanceMultiplier);
}
function getMinLat($lon, $lat, $distance, $distanceMultiplier=1)
{
return $lat - $distance / (111.12 * $distanceMultiplier);
}
function getMaxLon($lon, $lat, $distance, $distanceMultiplier=1)
{
return $lon + $distance * 180 / (abs(sin((90 - $lat) * 3.14159 / 180 )) * 6378 * $distanceMultiplier * 3.14159);
}
function getMinLon($lon, $lat, $distance, $distanceMultiplier=1)
{
return $lon - $distance * 180 / (abs(sin((90 - $lat) * 3.14159 / 180 )) * 6378 * $distanceMultiplier * 3.14159);
}
?>

View File

@ -24,16 +24,6 @@
global $interface_output, $dblink_slave;
if (!isset($interface_output)) $interface_output = 'plain';
if (isset($opt['rootpath']))
$rootpath = $opt['rootpath'];
else if (isset($rootpath))
$opt['rootpath'] = $rootpath;
else
{
$rootpath = './';
$opt['rootpath'] = $rootpath;
}
// yepp, we will use UTF-8
mb_internal_encoding('UTF-8');
mb_regex_encoding('UTF-8');
@ -47,10 +37,9 @@
define('regex_statpic_text', '^[a-zA-Z0-9\.\-_ @äüöÄÜÖß=)(\/\\\&*\$+~#!§%;,-?:\[\]{}¹²³\'\"`\|µ°]{0,29}$');
//load default webserver-settings and common includes
require_once($opt['rootpath'] . 'lib/settings.inc.php');
require_once($opt['rootpath'] . 'lib/calculation.inc.php');
require_once($opt['rootpath'] . 'lib/consts.inc.php');
require_once($opt['rootpath'] . 'lib2/errorhandler.inc.php');
require_once($GLOBALS['container']->get('ocde.config')->getBaseDir() . '/lib/settings.inc.php');
require_once($GLOBALS['container']->get('ocde.config')->getBaseDir() . '/lib/consts.inc.php');
require_once($GLOBALS['container']->get('ocde.config')->getBaseDir() . '/lib2/errorhandler.inc.php');
// check for banned UAs
$useragent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : "";
@ -396,14 +385,14 @@
if (isset($sql_debug) && ($sql_debug == true))
{
require_once($opt['rootpath'] . 'lib/sqldebugger.inc.php');
require_once($GLOBALS['container']->get('ocde.config')->getBaseDir() . '/lib/sqldebugger.inc.php');
$result = sqldbg_execute($filtered_sql, $bSlave);
if ($result === false) sql_error();
}
else
{
// Zeitmessung für die Ausführung
require_once($opt['rootpath'] . 'lib/bench.inc.php');
require_once($GLOBALS['container']->get('ocde.config')->getBaseDir() . '/lib/bench.inc.php');
$cSqlExecution = new Cbench;
$cSqlExecution->start();

File diff suppressed because it is too large Load Diff

View File

@ -1,84 +0,0 @@
<?php
/***************************************************************************
* For license information see doc/license.txt
*
* Unicode Reminder メモ
*
* Cookie handling
***************************************************************************/
$cookie = new cookie();
class cookie
{
var $changed = false;
var $values = array();
function cookie()
{
global $opt;
if (isset($_COOKIE[$opt['cookie']['name'] . 'data']))
{
//get the cookievars-array
$decoded = base64_decode($_COOKIE[$opt['cookie']['name'] . 'data']);
if ($decoded !== false)
{
$this->values = @unserialize($decoded);
if (!is_array($this->values))
$this->values = array();
}
else
$this->values = array();
}
}
function set($name, $value)
{
if (!isset($this->values[$name]) || $this->values[$name] != $value)
{
$this->values[$name] = $value;
$this->changed = true;
}
}
function get($name)
{
return isset($this->values[$name]) ? $this->values[$name] : '';
}
function is_set($name)
{
return isset($this->values[$name]);
}
function un_set($name)
{
if (isset($this->values[$name]))
{
unset($this->values[$name]);
$this->changed = true;
}
}
function header()
{
global $opt;
if ($this->changed == true)
{
if (count($this->values) == 0)
setcookie($opt['cookie']['name'] . 'data', false, time() + 31536000, $opt['cookie']['path'], $opt['cookie']['domain'], 0);
else
setcookie($opt['cookie']['name'] . 'data', base64_encode(serialize($this->values)), time() + 31536000, $opt['cookie']['path'], $opt['cookie']['domain'], 0);
}
}
function debug()
{
print_r($this->values);
exit;
}
}
?>

30
htdocs/lib/core.php Normal file
View File

@ -0,0 +1,30 @@
<?php
/****************************************************************************
_ _ _
___ _ __ ___ _ _ __ __ _ __| |_ (_)_ _ __ _ __| |___
/ _ \ '_ \/ -_) ' \/ _/ _` / _| ' \| | ' \/ _` |_/ _` / -_)
\___/ .__/\___|_||_\__\__,_\__|_||_|_|_||_\__, (_)__,_\___|
|_| |___/
For license information see doc/license.txt --- Unicode Reminder メモ
****************************************************************************/
require_once __DIR__ . '/../vendor/autoload.php';
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
$container = new ContainerBuilder();
$loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../config/'));
if (php_sapi_name() == 'cli') {
$loader->load('services_cli.yml');
} else {
$loader->load('services_web.yml');
}
// $loader->load('anotherfile.yml');
// Example: $config = $container->get('ocde.config');

View File

@ -1,63 +0,0 @@
<?php
/****************************************************************************
./lib/eventhandler.inc.php
-------------------
begin : Mon June 28 2004
For license information see doc/license.txt
****************************************************************************/
/****************************************************************************
Unicode Reminder メモ
handler for events like a new cache post or a new log post
add in the function all neccessary actions to refresh static files
****************************************************************************/
function delete_statpic($userid)
{
$userid = $userid + 0;
// data changed - delete statpic of user, if exists - will be recreated on next request
if (file_exists('./images/statpics/statpic'.$userid.'.jpg'))
{
unlink('./images/statpics/statpic'.$userid.'.jpg');
}
}
function event_new_cache($userid)
{
delete_statpic($userid);
}
function event_new_log($cacheid, $userid)
{
delete_statpic($userid);
}
function event_change_log_type($cacheid, $userid)
{
delete_statpic($userid);
}
function event_remove_log($cacheid, $userid)
{
delete_statpic($userid);
}
function event_edit_cache($cacheid, $userid)
{
delete_statpic($userid);
}
function event_change_statpic($userid)
{
delete_statpic($userid);
}
function event_notify_new_cache($cache_id)
{
}
?>

View File

@ -1,175 +0,0 @@
<?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 ''
*
* !! See also lib2/login.class.php. !!
*
***************************************************************************/
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 $permanent = false;
var $lastlogin = 0;
var $sessionid = '';
var $admin = 0;
var $verified = 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'); nonsense
$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 = 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); nonsense
}
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'];
$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;
}
public function listingAdmin()
{
global $opt;
return $this->hasAdminPriv(ADMIN_LISTING) && $opt['logic']['admin']['enable_listing_admins'];
}
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

@ -17,7 +17,7 @@
function search_output()
{
global $absolute_server_URI, $locale, $usr, $login;
global $absolute_server_URI, $locale, $usr;
global $cache_note_text;
$gpxHead =
@ -283,7 +283,7 @@ function search_output()
$thislog = mb_ereg_replace('{id}', 0, $thislog);
$thislog = mb_ereg_replace('{date}', date($gpxTimeFormat), $thislog);
$thislog = mb_ereg_replace('{userid}', $user_id, $thislog);
$thislog = mb_ereg_replace('{username}', xmlentities($login->username), $thislog);
$thislog = mb_ereg_replace('{username}', xmlentities($GLOBALS['container']->get('ocde.login')->getUsername()), $thislog);
$thislog = mb_ereg_replace('{type}', $gpxLogType[3], $thislog);
$thislog = mb_ereg_replace('{text}', xmlentities($cacheNote['note']), $thislog);

View File

@ -117,7 +117,7 @@ function search_output()
// und jetzt noch die Richtung ...
if ($caches_record['distance'] > 0)
{
$tmpline = mb_ereg_replace('{direction}', Bearing2Text(calcBearing($lat_rad / 3.14159 * 180, $lon_rad / 3.14159 * 180, $caches_record['latitude'], $caches_record['longitude']), 1), $tmpline);
$tmpline = mb_ereg_replace('{direction}', geomath::Bearing2Text(geomath::calcBearing($lat_rad / 3.14159 * 180, $lon_rad / 3.14159 * 180, $caches_record['latitude'], $caches_record['longitude']), 1), $tmpline);
}
else
$tmpline = mb_ereg_replace('{direction}', '', $tmpline);

View File

@ -1,4 +1,7 @@
<?php
use \OpencachingDE\Conversions\Coordinates;
/***************************************************************************
For license information see doc/license.txt
@ -100,10 +103,10 @@ Logeinträge:
$thisline = $txtLine;
$lat = sprintf('%01.5f', $r['latitude']);
$thisline = mb_ereg_replace('{lat}', help_latToDegreeStr($lat), $thisline);
$thisline = mb_ereg_replace('{lat}', Coordinates::latToDegreeStr($lat), $thisline);
$lon = sprintf('%01.5f', $r['longitude']);
$thisline = mb_ereg_replace('{lon}', help_lonToDegreeStr($lon), $thisline);
$thisline = mb_ereg_replace('{lon}', Coordinates::lonToDegreeStr($lon), $thisline);
$time = date('d.m.Y', strtotime($r['date_hidden']));
$thisline = mb_ereg_replace('{time}', $time, $thisline);
@ -207,4 +210,4 @@ Logeinträge:
return mb_ereg_replace("\r\r\n" ,"\r\n" , mb_ereg_replace("\n" ,"\r\n" , $str));
}
?>
?>

View File

@ -1,5 +1,7 @@
<?php
use \OpencachingDE\Conversions\Coordinates;
/***************************************************************************
For license information see doc/license.txt
@ -101,11 +103,11 @@ function search_output()
$thisline = $xmlLine;
$lat = sprintf('%01.5f', $r['latitude']);
$thisline = str_replace('{lat}', help_latToDegreeStr($lat), $thisline);
$thisline = str_replace('{lat}', Coordinates::latToDegreeStr($lat), $thisline);
$thisline = str_replace('{latvalue}', $lat, $thisline);
$lon = sprintf('%01.5f', $r['longitude']);
$thisline = str_replace('{lon}', help_lonToDegreeStr($lon), $thisline);
$thisline = str_replace('{lon}', Coordinates::lonToDegreeStr($lon), $thisline);
$thisline = str_replace('{lonvalue}', $lon, $thisline);
$time = date('d.m.Y', strtotime($r['date_hidden']));
@ -194,4 +196,4 @@ function search_output()
return $str;
}
?>
?>

View File

@ -1,9 +0,0 @@
CREDITS
Almost everything written by Edward Z. Yang (Ambush Commander). Lots of thanks
to the DevNetwork Community for their help (see docs/ref-devnetwork.html for
more details), Feyd especially (namely IPv6 and optimization). Thanks to RSnake
for letting me package his fantastic XSS cheatsheet for a smoketest.
vim: et sw=4 sts=4

View File

@ -1,374 +0,0 @@
Install
How to install HTML Purifier
HTML Purifier is designed to run out of the box, so actually using the
library is extremely easy. (Although... if you were looking for a
step-by-step installation GUI, you've downloaded the wrong software!)
While the impatient can get going immediately with some of the sample
code at the bottom of this library, it's well worth reading this entire
document--most of the other documentation assumes that you are familiar
with these contents.
---------------------------------------------------------------------------
1. Compatibility
HTML Purifier is PHP 5 only, and is actively tested from PHP 5.0.5 and
up. It has no core dependencies with other libraries. PHP
4 support was deprecated on December 31, 2007 with HTML Purifier 3.0.0.
HTML Purifier is not compatible with zend.ze1_compatibility_mode.
These optional extensions can enhance the capabilities of HTML Purifier:
* iconv : Converts text to and from non-UTF-8 encodings
* bcmath : Used for unit conversion and imagecrash protection
* tidy : Used for pretty-printing HTML
These optional libraries can enhance the capabilities of HTML Purifier:
* CSSTidy : Clean CSS stylesheets using %Core.ExtractStyleBlocks
* Net_IDNA2 (PEAR) : IRI support using %Core.EnableIDNA
---------------------------------------------------------------------------
2. Reconnaissance
A big plus of HTML Purifier is its inerrant support of standards, so
your web-pages should be standards-compliant. (They should also use
semantic markup, but that's another issue altogether, one HTML Purifier
cannot fix without reading your mind.)
HTML Purifier can process these doctypes:
* XHTML 1.0 Transitional (default)
* XHTML 1.0 Strict
* HTML 4.01 Transitional
* HTML 4.01 Strict
* XHTML 1.1
...and these character encodings:
* UTF-8 (default)
* Any encoding iconv supports (with crippled internationalization support)
These defaults reflect what my choices would be if I were authoring an
HTML document, however, what you choose depends on the nature of your
codebase. If you don't know what doctype you are using, you can determine
the doctype from this identifier at the top of your source code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
...and the character encoding from this code:
<meta http-equiv="Content-type" content="text/html;charset=ENCODING">
If the character encoding declaration is missing, STOP NOW, and
read 'docs/enduser-utf8.html' (web accessible at
http://htmlpurifier.org/docs/enduser-utf8.html). In fact, even if it is
present, read this document anyway, as many websites specify their
document's character encoding incorrectly.
---------------------------------------------------------------------------
3. Including the library
The procedure is quite simple:
require_once '/path/to/library/HTMLPurifier.auto.php';
This will setup an autoloader, so the library's files are only included
when you use them.
Only the contents in the library/ folder are necessary, so you can remove
everything else when using HTML Purifier in a production environment.
If you installed HTML Purifier via PEAR, all you need to do is:
require_once 'HTMLPurifier.auto.php';
Please note that the usual PEAR practice of including just the classes you
want will not work with HTML Purifier's autoloading scheme.
Advanced users, read on; other users can skip to section 4.
Autoload compatibility
----------------------
HTML Purifier attempts to be as smart as possible when registering an
autoloader, but there are some cases where you will need to change
your own code to accomodate HTML Purifier. These are those cases:
PHP VERSION IS LESS THAN 5.1.2, AND YOU'VE DEFINED __autoload
Because spl_autoload_register() doesn't exist in early versions
of PHP 5, HTML Purifier has no way of adding itself to the autoload
stack. Modify your __autoload function to test
HTMLPurifier_Bootstrap::autoload($class)
For example, suppose your autoload function looks like this:
function __autoload($class) {
require str_replace('_', '/', $class) . '.php';
return true;
}
A modified version with HTML Purifier would look like this:
function __autoload($class) {
if (HTMLPurifier_Bootstrap::autoload($class)) return true;
require str_replace('_', '/', $class) . '.php';
return true;
}
Note that there *is* some custom behavior in our autoloader; the
original autoloader in our example would work for 99% of the time,
but would fail when including language files.
AN __autoload FUNCTION IS DECLARED AFTER OUR AUTOLOADER IS REGISTERED
spl_autoload_register() has the curious behavior of disabling
the existing __autoload() handler. Users need to explicitly
spl_autoload_register('__autoload'). Because we use SPL when it
is available, __autoload() will ALWAYS be disabled. If __autoload()
is declared before HTML Purifier is loaded, this is not a problem:
HTML Purifier will register the function for you. But if it is
declared afterwards, it will mysteriously not work. This
snippet of code (after your autoloader is defined) will fix it:
spl_autoload_register('__autoload')
Users should also be on guard if they use a version of PHP previous
to 5.1.2 without an autoloader--HTML Purifier will define __autoload()
for you, which can collide with an autoloader that was added by *you*
later.
For better performance
----------------------
Opcode caches, which greatly speed up PHP initialization for scripts
with large amounts of code (HTML Purifier included), don't like
autoloaders. We offer an include file that includes all of HTML Purifier's
files in one go in an opcode cache friendly manner:
// If /path/to/library isn't already in your include path, uncomment
// the below line:
// require '/path/to/library/HTMLPurifier.path.php';
require 'HTMLPurifier.includes.php';
Optional components still need to be included--you'll know if you try to
use a feature and you get a class doesn't exists error! The autoloader
can be used in conjunction with this approach to catch classes that are
missing. Simply add this afterwards:
require 'HTMLPurifier.autoload.php';
Standalone version
------------------
HTML Purifier has a standalone distribution; you can also generate
a standalone file from the full version by running the script
maintenance/generate-standalone.php . The standalone version has the
benefit of having most of its code in one file, so parsing is much
faster and the library is easier to manage.
If HTMLPurifier.standalone.php exists in the library directory, you
can use it like this:
require '/path/to/HTMLPurifier.standalone.php';
This is equivalent to including HTMLPurifier.includes.php, except that
the contents of standalone/ will be added to your path. To override this
behavior, specify a new HTMLPURIFIER_PREFIX where standalone files can
be found (usually, this will be one directory up, the "true" library
directory in full distributions). Don't forget to set your path too!
The autoloader can be added to the end to ensure the classes are
loaded when necessary; otherwise you can manually include them.
To use the autoloader, use this:
require 'HTMLPurifier.autoload.php';
For advanced users
------------------
HTMLPurifier.auto.php performs a number of operations that can be done
individually. These are:
HTMLPurifier.path.php
Puts /path/to/library in the include path. For high performance,
this should be done in php.ini.
HTMLPurifier.autoload.php
Registers our autoload handler HTMLPurifier_Bootstrap::autoload($class).
You can do these operations by yourself--in fact, you must modify your own
autoload handler if you are using a version of PHP earlier than PHP 5.1.2
(See "Autoload compatibility" above).
---------------------------------------------------------------------------
4. Configuration
HTML Purifier is designed to run out-of-the-box, but occasionally HTML
Purifier needs to be told what to do. If you answer no to any of these
questions, read on; otherwise, you can skip to the next section (or, if you're
into configuring things just for the heck of it, skip to 4.3).
* Am I using UTF-8?
* Am I using XHTML 1.0 Transitional?
If you answered no to any of these questions, instantiate a configuration
object and read on:
$config = HTMLPurifier_Config::createDefault();
4.1. Setting a different character encoding
You really shouldn't use any other encoding except UTF-8, especially if you
plan to support multilingual websites (read section three for more details).
However, switching to UTF-8 is not always immediately feasible, so we can
adapt.
HTML Purifier uses iconv to support other character encodings, as such,
any encoding that iconv supports <http://www.gnu.org/software/libiconv/>
HTML Purifier supports with this code:
$config->set('Core.Encoding', /* put your encoding here */);
An example usage for Latin-1 websites (the most common encoding for English
websites):
$config->set('Core.Encoding', 'ISO-8859-1');
Note that HTML Purifier's support for non-Unicode encodings is crippled by the
fact that any character not supported by that encoding will be silently
dropped, EVEN if it is ampersand escaped. If you want to work around
this, you are welcome to read docs/enduser-utf8.html for a fix,
but please be cognizant of the issues the "solution" creates (for this
reason, I do not include the solution in this document).
4.2. Setting a different doctype
For those of you using HTML 4.01 Transitional, you can disable
XHTML output like this:
$config->set('HTML.Doctype', 'HTML 4.01 Transitional');
Other supported doctypes include:
* HTML 4.01 Strict
* HTML 4.01 Transitional
* XHTML 1.0 Strict
* XHTML 1.0 Transitional
* XHTML 1.1
4.3. Other settings
There are more configuration directives which can be read about
here: <http://htmlpurifier.org/live/configdoc/plain.html> They're a bit boring,
but they can help out for those of you who like to exert maximum control over
your code. Some of the more interesting ones are configurable at the
demo <http://htmlpurifier.org/demo.php> and are well worth looking into
for your own system.
For example, you can fine tune allowed elements and attributes, convert
relative URLs to absolute ones, and even autoparagraph input text! These
are, respectively, %HTML.Allowed, %URI.MakeAbsolute and %URI.Base, and
%AutoFormat.AutoParagraph. The %Namespace.Directive naming convention
translates to:
$config->set('Namespace.Directive', $value);
E.g.
$config->set('HTML.Allowed', 'p,b,a[href],i');
$config->set('URI.Base', 'http://www.example.com');
$config->set('URI.MakeAbsolute', true);
$config->set('AutoFormat.AutoParagraph', true);
---------------------------------------------------------------------------
5. Caching
HTML Purifier generates some cache files (generally one or two) to speed up
its execution. For maximum performance, make sure that
library/HTMLPurifier/DefinitionCache/Serializer is writeable by the webserver.
If you are in the library/ folder of HTML Purifier, you can set the
appropriate permissions using:
chmod -R 0755 HTMLPurifier/DefinitionCache/Serializer
If the above command doesn't work, you may need to assign write permissions
to all. This may be necessary if your webserver runs as nobody, but is
not recommended since it means any other user can write files in the
directory. Use:
chmod -R 0777 HTMLPurifier/DefinitionCache/Serializer
You can also chmod files via your FTP client; this option
is usually accessible by right clicking the corresponding directory and
then selecting "chmod" or "file permissions".
Starting with 2.0.1, HTML Purifier will generate friendly error messages
that will tell you exactly what you have to chmod the directory to, if in doubt,
follow its advice.
If you are unable or unwilling to give write permissions to the cache
directory, you can either disable the cache (and suffer a performance
hit):
$config->set('Core.DefinitionCache', null);
Or move the cache directory somewhere else (no trailing slash):
$config->set('Cache.SerializerPath', '/home/user/absolute/path');
---------------------------------------------------------------------------
6. Using the code
The interface is mind-numbingly simple:
$purifier = new HTMLPurifier($config);
$clean_html = $purifier->purify( $dirty_html );
That's it! For more examples, check out docs/examples/ (they aren't very
different though). Also, docs/enduser-slow.html gives advice on what to
do if HTML Purifier is slowing down your application.
---------------------------------------------------------------------------
7. Quick install
First, make sure library/HTMLPurifier/DefinitionCache/Serializer is
writable by the webserver (see Section 5: Caching above for details).
If your website is in UTF-8 and XHTML Transitional, use this code:
<?php
require_once '/path/to/htmlpurifier/library/HTMLPurifier.auto.php';
$config = HTMLPurifier_Config::createDefault();
$purifier = new HTMLPurifier($config);
$clean_html = $purifier->purify($dirty_html);
?>
If your website is in a different encoding or doctype, use this code:
<?php
require_once '/path/to/htmlpurifier/library/HTMLPurifier.auto.php';
$config = HTMLPurifier_Config::createDefault();
$config->set('Core.Encoding', 'ISO-8859-1'); // replace with your encoding
$config->set('HTML.Doctype', 'HTML 4.01 Transitional'); // replace with your doctype
$purifier = new HTMLPurifier($config);
$clean_html = $purifier->purify($dirty_html);
?>
vim: et sw=4 sts=4

View File

@ -1,504 +0,0 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!
vim: et sw=4 sts=4

File diff suppressed because it is too large Load Diff

View File

@ -1,11 +0,0 @@
<?php
/**
* This is a stub include that automatically configures the include path.
*/
set_include_path(dirname(__FILE__) . PATH_SEPARATOR . get_include_path() );
require_once 'HTMLPurifier/Bootstrap.php';
require_once 'HTMLPurifier.autoload.php';
// vim: et sw=4 sts=4

View File

@ -1,26 +0,0 @@
<?php
/**
* @file
* Convenience file that registers autoload handler for HTML Purifier.
* It also does some sanity checks.
*/
if (function_exists('spl_autoload_register') && function_exists('spl_autoload_unregister')) {
// We need unregister for our pre-registering functionality
HTMLPurifier_Bootstrap::registerAutoload();
if (function_exists('__autoload')) {
// Be polite and ensure that userland autoload gets retained
spl_autoload_register('__autoload');
}
} elseif (!function_exists('__autoload')) {
function __autoload($class) {
return HTMLPurifier_Bootstrap::autoload($class);
}
}
if (ini_get('zend.ze1_compatibility_mode')) {
trigger_error("HTML Purifier is not compatible with zend.ze1_compatibility_mode; please turn it off", E_USER_ERROR);
}
// vim: et sw=4 sts=4

View File

@ -1,4 +0,0 @@
<?php
if (!defined('HTMLPURIFIER_PREFIX')) {
define('HTMLPURIFIER_PREFIX', __DIR__);
}

View File

@ -1,23 +0,0 @@
<?php
/**
* @file
* Defines a function wrapper for HTML Purifier for quick use.
* @note ''HTMLPurifier()'' is NOT the same as ''new HTMLPurifier()''
*/
/**
* Purify HTML.
* @param $html String HTML to purify
* @param $config Configuration to use, can be any value accepted by
* HTMLPurifier_Config::create()
*/
function HTMLPurifier($html, $config = null) {
static $purifier = false;
if (!$purifier) {
$purifier = new HTMLPurifier();
}
return $purifier->purify($html, $config);
}
// vim: et sw=4 sts=4

View File

@ -1,222 +0,0 @@
<?php
/**
* @file
* This file was auto-generated by generate-includes.php and includes all of
* the core files required by HTML Purifier. Use this if performance is a
* primary concern and you are using an opcode cache. PLEASE DO NOT EDIT THIS
* FILE, changes will be overwritten the next time the script is run.
*
* @version 4.5.0
*
* @warning
* You must *not* include any other HTML Purifier files before this file,
* because 'require' not 'require_once' is used.
*
* @warning
* This file requires that the include path contains the HTML Purifier
* library directory; this is not auto-set.
*/
require 'HTMLPurifier.php';
require 'HTMLPurifier/AttrCollections.php';
require 'HTMLPurifier/AttrDef.php';
require 'HTMLPurifier/AttrTransform.php';
require 'HTMLPurifier/AttrTypes.php';
require 'HTMLPurifier/AttrValidator.php';
require 'HTMLPurifier/Bootstrap.php';
require 'HTMLPurifier/Definition.php';
require 'HTMLPurifier/CSSDefinition.php';
require 'HTMLPurifier/ChildDef.php';
require 'HTMLPurifier/Config.php';
require 'HTMLPurifier/ConfigSchema.php';
require 'HTMLPurifier/ContentSets.php';
require 'HTMLPurifier/Context.php';
require 'HTMLPurifier/DefinitionCache.php';
require 'HTMLPurifier/DefinitionCacheFactory.php';
require 'HTMLPurifier/Doctype.php';
require 'HTMLPurifier/DoctypeRegistry.php';
require 'HTMLPurifier/ElementDef.php';
require 'HTMLPurifier/Encoder.php';
require 'HTMLPurifier/EntityLookup.php';
require 'HTMLPurifier/EntityParser.php';
require 'HTMLPurifier/ErrorCollector.php';
require 'HTMLPurifier/ErrorStruct.php';
require 'HTMLPurifier/Exception.php';
require 'HTMLPurifier/Filter.php';
require 'HTMLPurifier/Generator.php';
require 'HTMLPurifier/HTMLDefinition.php';
require 'HTMLPurifier/HTMLModule.php';
require 'HTMLPurifier/HTMLModuleManager.php';
require 'HTMLPurifier/IDAccumulator.php';
require 'HTMLPurifier/Injector.php';
require 'HTMLPurifier/Language.php';
require 'HTMLPurifier/LanguageFactory.php';
require 'HTMLPurifier/Length.php';
require 'HTMLPurifier/Lexer.php';
require 'HTMLPurifier/PercentEncoder.php';
require 'HTMLPurifier/PropertyList.php';
require 'HTMLPurifier/PropertyListIterator.php';
require 'HTMLPurifier/Strategy.php';
require 'HTMLPurifier/StringHash.php';
require 'HTMLPurifier/StringHashParser.php';
require 'HTMLPurifier/TagTransform.php';
require 'HTMLPurifier/Token.php';
require 'HTMLPurifier/TokenFactory.php';
require 'HTMLPurifier/URI.php';
require 'HTMLPurifier/URIDefinition.php';
require 'HTMLPurifier/URIFilter.php';
require 'HTMLPurifier/URIParser.php';
require 'HTMLPurifier/URIScheme.php';
require 'HTMLPurifier/URISchemeRegistry.php';
require 'HTMLPurifier/UnitConverter.php';
require 'HTMLPurifier/VarParser.php';
require 'HTMLPurifier/VarParserException.php';
require 'HTMLPurifier/AttrDef/CSS.php';
require 'HTMLPurifier/AttrDef/Clone.php';
require 'HTMLPurifier/AttrDef/Enum.php';
require 'HTMLPurifier/AttrDef/Integer.php';
require 'HTMLPurifier/AttrDef/Lang.php';
require 'HTMLPurifier/AttrDef/Switch.php';
require 'HTMLPurifier/AttrDef/Text.php';
require 'HTMLPurifier/AttrDef/URI.php';
require 'HTMLPurifier/AttrDef/CSS/Number.php';
require 'HTMLPurifier/AttrDef/CSS/AlphaValue.php';
require 'HTMLPurifier/AttrDef/CSS/Background.php';
require 'HTMLPurifier/AttrDef/CSS/BackgroundPosition.php';
require 'HTMLPurifier/AttrDef/CSS/Border.php';
require 'HTMLPurifier/AttrDef/CSS/Color.php';
require 'HTMLPurifier/AttrDef/CSS/Composite.php';
require 'HTMLPurifier/AttrDef/CSS/DenyElementDecorator.php';
require 'HTMLPurifier/AttrDef/CSS/Filter.php';
require 'HTMLPurifier/AttrDef/CSS/Font.php';
require 'HTMLPurifier/AttrDef/CSS/FontFamily.php';
require 'HTMLPurifier/AttrDef/CSS/Ident.php';
require 'HTMLPurifier/AttrDef/CSS/ImportantDecorator.php';
require 'HTMLPurifier/AttrDef/CSS/Length.php';
require 'HTMLPurifier/AttrDef/CSS/ListStyle.php';
require 'HTMLPurifier/AttrDef/CSS/Multiple.php';
require 'HTMLPurifier/AttrDef/CSS/Percentage.php';
require 'HTMLPurifier/AttrDef/CSS/TextDecoration.php';
require 'HTMLPurifier/AttrDef/CSS/URI.php';
require 'HTMLPurifier/AttrDef/HTML/Bool.php';
require 'HTMLPurifier/AttrDef/HTML/Nmtokens.php';
require 'HTMLPurifier/AttrDef/HTML/Class.php';
require 'HTMLPurifier/AttrDef/HTML/Color.php';
require 'HTMLPurifier/AttrDef/HTML/FrameTarget.php';
require 'HTMLPurifier/AttrDef/HTML/ID.php';
require 'HTMLPurifier/AttrDef/HTML/Pixels.php';
require 'HTMLPurifier/AttrDef/HTML/Length.php';
require 'HTMLPurifier/AttrDef/HTML/LinkTypes.php';
require 'HTMLPurifier/AttrDef/HTML/MultiLength.php';
require 'HTMLPurifier/AttrDef/URI/Email.php';
require 'HTMLPurifier/AttrDef/URI/Host.php';
require 'HTMLPurifier/AttrDef/URI/IPv4.php';
require 'HTMLPurifier/AttrDef/URI/IPv6.php';
require 'HTMLPurifier/AttrDef/URI/Email/SimpleCheck.php';
require 'HTMLPurifier/AttrTransform/Background.php';
require 'HTMLPurifier/AttrTransform/BdoDir.php';
require 'HTMLPurifier/AttrTransform/BgColor.php';
require 'HTMLPurifier/AttrTransform/BoolToCSS.php';
require 'HTMLPurifier/AttrTransform/Border.php';
require 'HTMLPurifier/AttrTransform/EnumToCSS.php';
require 'HTMLPurifier/AttrTransform/ImgRequired.php';
require 'HTMLPurifier/AttrTransform/ImgSpace.php';
require 'HTMLPurifier/AttrTransform/Input.php';
require 'HTMLPurifier/AttrTransform/Lang.php';
require 'HTMLPurifier/AttrTransform/Length.php';
require 'HTMLPurifier/AttrTransform/Name.php';
require 'HTMLPurifier/AttrTransform/NameSync.php';
require 'HTMLPurifier/AttrTransform/Nofollow.php';
require 'HTMLPurifier/AttrTransform/SafeEmbed.php';
require 'HTMLPurifier/AttrTransform/SafeObject.php';
require 'HTMLPurifier/AttrTransform/SafeParam.php';
require 'HTMLPurifier/AttrTransform/ScriptRequired.php';
require 'HTMLPurifier/AttrTransform/TargetBlank.php';
require 'HTMLPurifier/AttrTransform/Textarea.php';
require 'HTMLPurifier/ChildDef/Chameleon.php';
require 'HTMLPurifier/ChildDef/Custom.php';
require 'HTMLPurifier/ChildDef/Empty.php';
require 'HTMLPurifier/ChildDef/List.php';
require 'HTMLPurifier/ChildDef/Required.php';
require 'HTMLPurifier/ChildDef/Optional.php';
require 'HTMLPurifier/ChildDef/StrictBlockquote.php';
require 'HTMLPurifier/ChildDef/Table.php';
require 'HTMLPurifier/DefinitionCache/Decorator.php';
require 'HTMLPurifier/DefinitionCache/Null.php';
require 'HTMLPurifier/DefinitionCache/Serializer.php';
require 'HTMLPurifier/DefinitionCache/Decorator/Cleanup.php';
require 'HTMLPurifier/DefinitionCache/Decorator/Memory.php';
require 'HTMLPurifier/HTMLModule/Bdo.php';
require 'HTMLPurifier/HTMLModule/CommonAttributes.php';
require 'HTMLPurifier/HTMLModule/Edit.php';
require 'HTMLPurifier/HTMLModule/Forms.php';
require 'HTMLPurifier/HTMLModule/Hypertext.php';
require 'HTMLPurifier/HTMLModule/Iframe.php';
require 'HTMLPurifier/HTMLModule/Image.php';
require 'HTMLPurifier/HTMLModule/Legacy.php';
require 'HTMLPurifier/HTMLModule/List.php';
require 'HTMLPurifier/HTMLModule/Name.php';
require 'HTMLPurifier/HTMLModule/Nofollow.php';
require 'HTMLPurifier/HTMLModule/NonXMLCommonAttributes.php';
require 'HTMLPurifier/HTMLModule/Object.php';
require 'HTMLPurifier/HTMLModule/Presentation.php';
require 'HTMLPurifier/HTMLModule/Proprietary.php';
require 'HTMLPurifier/HTMLModule/Ruby.php';
require 'HTMLPurifier/HTMLModule/SafeEmbed.php';
require 'HTMLPurifier/HTMLModule/SafeObject.php';
require 'HTMLPurifier/HTMLModule/SafeScripting.php';
require 'HTMLPurifier/HTMLModule/Scripting.php';
require 'HTMLPurifier/HTMLModule/StyleAttribute.php';
require 'HTMLPurifier/HTMLModule/Tables.php';
require 'HTMLPurifier/HTMLModule/Target.php';
require 'HTMLPurifier/HTMLModule/TargetBlank.php';
require 'HTMLPurifier/HTMLModule/Text.php';
require 'HTMLPurifier/HTMLModule/Tidy.php';
require 'HTMLPurifier/HTMLModule/XMLCommonAttributes.php';
require 'HTMLPurifier/HTMLModule/Tidy/Name.php';
require 'HTMLPurifier/HTMLModule/Tidy/Proprietary.php';
require 'HTMLPurifier/HTMLModule/Tidy/XHTMLAndHTML4.php';
require 'HTMLPurifier/HTMLModule/Tidy/Strict.php';
require 'HTMLPurifier/HTMLModule/Tidy/Transitional.php';
require 'HTMLPurifier/HTMLModule/Tidy/XHTML.php';
require 'HTMLPurifier/Injector/AutoParagraph.php';
require 'HTMLPurifier/Injector/DisplayLinkURI.php';
require 'HTMLPurifier/Injector/Linkify.php';
require 'HTMLPurifier/Injector/PurifierLinkify.php';
require 'HTMLPurifier/Injector/RemoveEmpty.php';
require 'HTMLPurifier/Injector/RemoveSpansWithoutAttributes.php';
require 'HTMLPurifier/Injector/SafeObject.php';
require 'HTMLPurifier/Lexer/DOMLex.php';
require 'HTMLPurifier/Lexer/DirectLex.php';
require 'HTMLPurifier/Strategy/Composite.php';
require 'HTMLPurifier/Strategy/Core.php';
require 'HTMLPurifier/Strategy/FixNesting.php';
require 'HTMLPurifier/Strategy/MakeWellFormed.php';
require 'HTMLPurifier/Strategy/RemoveForeignElements.php';
require 'HTMLPurifier/Strategy/ValidateAttributes.php';
require 'HTMLPurifier/TagTransform/Font.php';
require 'HTMLPurifier/TagTransform/Simple.php';
require 'HTMLPurifier/Token/Comment.php';
require 'HTMLPurifier/Token/Tag.php';
require 'HTMLPurifier/Token/Empty.php';
require 'HTMLPurifier/Token/End.php';
require 'HTMLPurifier/Token/Start.php';
require 'HTMLPurifier/Token/Text.php';
require 'HTMLPurifier/URIFilter/DisableExternal.php';
require 'HTMLPurifier/URIFilter/DisableExternalResources.php';
require 'HTMLPurifier/URIFilter/DisableResources.php';
require 'HTMLPurifier/URIFilter/HostBlacklist.php';
require 'HTMLPurifier/URIFilter/MakeAbsolute.php';
require 'HTMLPurifier/URIFilter/Munge.php';
require 'HTMLPurifier/URIFilter/SafeIframe.php';
require 'HTMLPurifier/URIScheme/data.php';
require 'HTMLPurifier/URIScheme/file.php';
require 'HTMLPurifier/URIScheme/ftp.php';
require 'HTMLPurifier/URIScheme/http.php';
require 'HTMLPurifier/URIScheme/https.php';
require 'HTMLPurifier/URIScheme/mailto.php';
require 'HTMLPurifier/URIScheme/news.php';
require 'HTMLPurifier/URIScheme/nntp.php';
require 'HTMLPurifier/VarParser/Flexible.php';
require 'HTMLPurifier/VarParser/Native.php';

View File

@ -1,30 +0,0 @@
<?php
/**
* @file
* Emulation layer for code that used kses(), substituting in HTML Purifier.
*/
require_once dirname(__FILE__) . '/HTMLPurifier.auto.php';
function kses($string, $allowed_html, $allowed_protocols = null) {
$config = HTMLPurifier_Config::createDefault();
$allowed_elements = array();
$allowed_attributes = array();
foreach ($allowed_html as $element => $attributes) {
$allowed_elements[$element] = true;
foreach ($attributes as $attribute => $x) {
$allowed_attributes["$element.$attribute"] = true;
}
}
$config->set('HTML.AllowedElements', $allowed_elements);
$config->set('HTML.AllowedAttributes', $allowed_attributes);
$allowed_schemes = array();
if ($allowed_protocols !== null) {
$config->set('URI.AllowedSchemes', $allowed_protocols);
}
$purifier = new HTMLPurifier($config);
return $purifier->purify($string);
}
// vim: et sw=4 sts=4

View File

@ -1,11 +0,0 @@
<?php
/**
* @file
* Convenience stub file that adds HTML Purifier's library file to the path
* without any other side-effects.
*/
set_include_path(dirname(__FILE__) . PATH_SEPARATOR . get_include_path() );
// vim: et sw=4 sts=4

View File

@ -1,237 +0,0 @@
<?php
/*! @mainpage
*
* HTML Purifier is an HTML filter that will take an arbitrary snippet of
* HTML and rigorously test, validate and filter it into a version that
* is safe for output onto webpages. It achieves this by:
*
* -# Lexing (parsing into tokens) the document,
* -# Executing various strategies on the tokens:
* -# Removing all elements not in the whitelist,
* -# Making the tokens well-formed,
* -# Fixing the nesting of the nodes, and
* -# Validating attributes of the nodes; and
* -# Generating HTML from the purified tokens.
*
* However, most users will only need to interface with the HTMLPurifier
* and HTMLPurifier_Config.
*/
/*
HTML Purifier 4.5.0 - Standards Compliant HTML Filtering
Copyright (C) 2006-2008 Edward Z. Yang
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* Facade that coordinates HTML Purifier's subsystems in order to purify HTML.
*
* @note There are several points in which configuration can be specified
* for HTML Purifier. The precedence of these (from lowest to
* highest) is as follows:
* -# Instance: new HTMLPurifier($config)
* -# Invocation: purify($html, $config)
* These configurations are entirely independent of each other and
* are *not* merged (this behavior may change in the future).
*
* @todo We need an easier way to inject strategies using the configuration
* object.
*/
class HTMLPurifier
{
/** Version of HTML Purifier */
public $version = '4.5.0';
/** Constant with version of HTML Purifier */
const VERSION = '4.5.0';
/** Global configuration object */
public $config;
/** Array of extra HTMLPurifier_Filter objects to run on HTML, for backwards compatibility */
private $filters = array();
/** Single instance of HTML Purifier */
private static $instance;
protected $strategy, $generator;
/**
* Resultant HTMLPurifier_Context of last run purification. Is an array
* of contexts if the last called method was purifyArray().
*/
public $context;
/**
* Initializes the purifier.
* @param $config Optional HTMLPurifier_Config object for all instances of
* the purifier, if omitted, a default configuration is
* supplied (which can be overridden on a per-use basis).
* The parameter can also be any type that
* HTMLPurifier_Config::create() supports.
*/
public function __construct($config = null) {
$this->config = HTMLPurifier_Config::create($config);
$this->strategy = new HTMLPurifier_Strategy_Core();
}
/**
* Adds a filter to process the output. First come first serve
* @param $filter HTMLPurifier_Filter object
*/
public function addFilter($filter) {
trigger_error('HTMLPurifier->addFilter() is deprecated, use configuration directives in the Filter namespace or Filter.Custom', E_USER_WARNING);
$this->filters[] = $filter;
}
/**
* Filters an HTML snippet/document to be XSS-free and standards-compliant.
*
* @param $html String of HTML to purify
* @param $config HTMLPurifier_Config object for this operation, if omitted,
* defaults to the config object specified during this
* object's construction. The parameter can also be any type
* that HTMLPurifier_Config::create() supports.
* @return Purified HTML
*/
public function purify($html, $config = null) {
// :TODO: make the config merge in, instead of replace
$config = $config ? HTMLPurifier_Config::create($config) : $this->config;
// implementation is partially environment dependant, partially
// configuration dependant
$lexer = HTMLPurifier_Lexer::create($config);
$context = new HTMLPurifier_Context();
// setup HTML generator
$this->generator = new HTMLPurifier_Generator($config, $context);
$context->register('Generator', $this->generator);
// set up global context variables
if ($config->get('Core.CollectErrors')) {
// may get moved out if other facilities use it
$language_factory = HTMLPurifier_LanguageFactory::instance();
$language = $language_factory->create($config, $context);
$context->register('Locale', $language);
$error_collector = new HTMLPurifier_ErrorCollector($context);
$context->register('ErrorCollector', $error_collector);
}
// setup id_accumulator context, necessary due to the fact that
// AttrValidator can be called from many places
$id_accumulator = HTMLPurifier_IDAccumulator::build($config, $context);
$context->register('IDAccumulator', $id_accumulator);
$html = HTMLPurifier_Encoder::convertToUTF8($html, $config, $context);
// setup filters
$filter_flags = $config->getBatch('Filter');
$custom_filters = $filter_flags['Custom'];
unset($filter_flags['Custom']);
$filters = array();
foreach ($filter_flags as $filter => $flag) {
if (!$flag) continue;
if (strpos($filter, '.') !== false) continue;
$class = "HTMLPurifier_Filter_$filter";
$filters[] = new $class;
}
foreach ($custom_filters as $filter) {
// maybe "HTMLPurifier_Filter_$filter", but be consistent with AutoFormat
$filters[] = $filter;
}
$filters = array_merge($filters, $this->filters);
// maybe prepare(), but later
for ($i = 0, $filter_size = count($filters); $i < $filter_size; $i++) {
$html = $filters[$i]->preFilter($html, $config, $context);
}
// purified HTML
$html =
$this->generator->generateFromTokens(
// list of tokens
$this->strategy->execute(
// list of un-purified tokens
$lexer->tokenizeHTML(
// un-purified HTML
$html, $config, $context
),
$config, $context
)
);
for ($i = $filter_size - 1; $i >= 0; $i--) {
$html = $filters[$i]->postFilter($html, $config, $context);
}
$html = HTMLPurifier_Encoder::convertFromUTF8($html, $config, $context);
$this->context =& $context;
return $html;
}
/**
* Filters an array of HTML snippets
* @param $config Optional HTMLPurifier_Config object for this operation.
* See HTMLPurifier::purify() for more details.
* @return Array of purified HTML
*/
public function purifyArray($array_of_html, $config = null) {
$context_array = array();
foreach ($array_of_html as $key => $html) {
$array_of_html[$key] = $this->purify($html, $config);
$context_array[$key] = $this->context;
}
$this->context = $context_array;
return $array_of_html;
}
/**
* Singleton for enforcing just one HTML Purifier in your system
* @param $prototype Optional prototype HTMLPurifier instance to
* overload singleton with, or HTMLPurifier_Config
* instance to configure the generated version with.
*/
public static function instance($prototype = null) {
if (!self::$instance || $prototype) {
if ($prototype instanceof HTMLPurifier) {
self::$instance = $prototype;
} elseif ($prototype) {
self::$instance = new HTMLPurifier($prototype);
} else {
self::$instance = new HTMLPurifier();
}
}
return self::$instance;
}
/**
* @note Backwards compatibility, see instance()
*/
public static function getInstance($prototype = null) {
return HTMLPurifier::instance($prototype);
}
}
// vim: et sw=4 sts=4

Some files were not shown because too many files have changed in this diff Show More