first init

This commit is contained in:
Metrax
2012-05-09 20:05:43 +02:00
commit e05b7bb8f0
6205 changed files with 395435 additions and 0 deletions
+4
View File
@@ -0,0 +1,4 @@
<FilesMatch ".*">
Order deny,allow
Deny from all
</FilesMatch>
+127
View File
@@ -0,0 +1,127 @@
<?php
/***************************************************************************
./lib/auth.inc.php
--------------------
begin : Fri September 16 2005
copyright : (C) 2005 The OpenCaching Group
forum contact at : http://www.opencaching.com/phpBB2
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
/****************************************************************************
Unicode Reminder メモ
all login/logout related functions
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_UsernameFromID - get the username from the given id,
* otherwise false
*/
function auth_UsernameFromID($userid)
{
//select the right user
$rs = sql("SELECT `username` FROM `user` WHERE `user_id`='&1'", $userid);
if (mysql_num_rows($rs) > 0)
{
$record = sql_fetch_array($rs);
return $record['username'];
}
else
{
//user not exists
return false;
}
}
/* auth_user - fills usr[]
* no return value
*/
function auth_user()
{
global $usr, $login;
$login->verify();
if ($login->userid != 0)
{
//set up $usr array
$usr['userid'] = $login->userid;
$usr['email'] = sqlValue("SELECT `email` FROM `user` WHERE `user_id`='" . sql_escape($login->userid) . "'", '');
$usr['username'] = $login->username;
}
else
$usr = false;
return;
}
/* auth_login - try to log in a user
* returns the userid on success, otherwise false
*/
function auth_login($user, $password)
{
global $login, $autherr;
$retval = $login->try_login($user, $password, null);
switch ($retval)
{
case LOGIN_TOOMUCHLOGINS:
$autherr = AUTHERR_TOOMUCHLOGINS;
return false;
case LOGIN_USERNOTACTIVE:
$autherr = AUTHERR_USERNOTACTIVE;
return false;
case LOGIN_BADUSERPW:
$autherr = AUTHERR_WRONGAUTHINFO;
return false;
case LOGIN_OK:
$autherr = AUTHERR_NOERROR;
return $login->userid;
default:
$autherr = AUTHERR_WRONGAUTHINFO;
return false;
}
}
/* auth_logout - log out the user
* returns false if the user wasn't logged in, true if success
*/
function auth_logout()
{
global $login, $usr;
if ($login->userid != 0)
{
$login->logout();
return true;
}
else
{
$usr = false;
return false;
}
}
?>
@@ -0,0 +1,727 @@
<?php
/**
* PHP Class b2evo_captcha Version 1.3.1, released 27-Jan-2006
*
* a PHP Class for creating and testing captchas used in b2evolution
*
* Author : Ben Franske, ben@franske.com, http://ben.franske.com
*
* Based on hn_captcha Version 1.2 by Horst Nogajski, horst@nogajski.de
* - hn_captcha is a fork of ocr_captcha by Julien Pachet
*
* License: GNU GPL (http://www.opensource.org/licenses/gpl-license.html)
*
**/
/**
*
* changes in version 1.3.1:
* - removed unrequired double quotes
* - use function_exists() to check for some required functions
*
* changes in version 1.3:
* - modified for use in b2evolution and to make more of a standalone class:
* - stripped code so only image generation and testing remain
* - removed code for multiple attempts, one shot per image only (K.I.S.S.)
* - automatically select from multiple random fonts from the fonts folder
* - support for random captcha length
* - support for easily selecting valid characters and number of characters
* - added built-in garbage cleanup
* - support for case sensitive captchas
* - upgraded from rand() functions to mt_rand() functions
* - support for full md5 hashes instead of hash substrings
* - made it easier to drop in different image generation function
*
* changes in version 1.2:
* - added a new configuration-variable: secretposition
* - once more modified the function get_try(): generate a string of 32 chars length,
* where at secretposition is the number of current-try.
* Hopefully this is enough for hackprevention.
*
* changes in version 1.1:
* - added a new configuration-variable: maxrotation
* - added a new configuration-variable: secretstring
* - modified function get_try(): now ever returns a string of 16 chars
*
**/
/**
* License: GNU GPL (http://www.opensource.org/licenses/gpl-license.html)
*
* This program is free software;
*
* you can redistribute it and/or modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 of the License,
* or (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program;
* if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
**/
class b2evo_captcha
{
////////////////////////////////
//
// Default options, can be overridden from the calling code
//
/**
* Absolute path to a Tempfolder (with trailing slash!). This must be writeable for PHP and also accessible via HTTP, because the image will be stored there.
*
**/
var $tempfolder;
/**
* Absolute path to folder with TrueTypeFonts (with trailing slash!). This must be readable by PHP.
*
**/
var $TTF_folder;
/**
* The minimum number of characters to use for the captcha
* Set to the same as maxchars to use fixed length captchas
**/
var $minchars = 5;
/**
* The maximum number of characters to use for the captcha
* Set to the same as minchars to use fixed length captchas
**/
var $maxchars = 7;
/**
* The minimum font size to use
*
**/
var $minsize = 20;
/**
* The maximum font size to use
*
**/
var $maxsize = 30;
/**
* The maximum degrees a Char should be rotated. Set it to 30 means a random rotation between -30 and 30.
*
**/
var $maxrotation = 25;
/**
* Background noise On/Off (if is FALSE, a grid will be created)
*
**/
var $noise = TRUE;
/**
* This will only use the 216 websafe color pallette for the image.
*
**/
var $websafecolors = FALSE;
/**
* Outputs configuration values for testing
*
**/
var $debug = FALSE;
/**
* Filename of garbage collector counter which is stored in the tempfolder
*
**/
var $counter_filename = 'b2evo_captcha_counter.txt';
/**
* Prefix of captcha image filenames
*
**/
var $filename_prefix = 'b2evo_captcha_';
/**
* Number of captchas to generate before garbage collection is done
*
**/
var $collect_garbage_after = 100;
/**
* Maximum lifetime of a captcha (in seconds) before being deleted during garbage collection
*
**/
var $maxlifetime = 600;
/**
* Make all letters uppercase (does not preclude symbols)
*
**/
var $case_sensitive = TRUE;
////////////////////////////////
//
// Private options, these are fixed options
//
/**
* String of valid characters which may appear in the captcha
*
**/
var $validchars = 'abcdefghjkmnpqrstuvwxyz23456789?@#$%&*ABCDEFGHJKLMNPQRSTUVWXYZ23456789?@#$%&*';
/**
* Picture width
*
**/
var $lx;
/**
* Picture height
*
**/
var $ly;
/**
* JPEG Image quality
*
**/
var $jpegquality = 80;
/**
* Noise multiplier (number of characters gets multipled by this to define noise)
* Note: This doesn't quite make sense, do you really want less noise in a smaller captcha?
**/
var $noisefactor = 9;
/**
* Number of backgrond noise characters
*
**/
var $nb_noise;
/**
* Holds the list of possible fonts
*
**/
var $TTF_RANGE;
/**
* Holds the currently selected font filename
*
**/
var $TTF_file;
/**
* Holds the number of characters in the captcha
*
**/
var $chars;
var $public_K;
var $private_K;
/**
* Captcha filename
*
**/
var $filename;
/**
* Holds the version number of the GD-Library
*
**/
var $gd_version;
var $r;
var $g;
var $b;
////////////////////////////////
//
// CONSTRUCTOR
//
/**
* Extracts the config array and overrides default settings.
*
**/
function b2evo_captcha($config,$secure=TRUE)
{
// Test for GD-Library(-Version)
$this->gd_version = $this->get_gd_version();
if($this->gd_version == 0) die('There is no GD-Library-Support enabled. The b2evo captcha class cannot be used!');
if($this->debug) echo "\n<br>-b2evo-Captcha-Debug: The available GD-Library has major version ".$this->gd_version;
// extracts config array
if(is_array($config))
{
if($secure && (!function_exists('version_compare') || version_compare(phpversion(), '4.2.0', '< ')) && function_exists(array_key_exists))
{
if($this->debug) echo "\n<br>-b2evo-Captcha-Debug: Extracts Config-Array in secure-mode!";
$valid = get_class_vars(get_class($this));
foreach($config as $k=>$v)
{
if(array_key_exists($k,$valid)) $this->$k = $v;
}
}
else
{
if($this->debug) echo "\n<br>-b2evo-Captcha-Debug: Extracts Config-Array in unsecure-mode!";
foreach($config as $k=>$v) $this->$k = $v;
}
}
// check vars for min-max-chars and min-max-size
if($this->minchars > $this->maxchars)
{
$temp = $this->minchars;
$this->minchars = $this->maxchars;
$this->maxchars = $temp;
if($this->debug) echo "\n<br>-b2evo-Captcha-Debug: Arrghh! What do you think I mean with min and max? Switch minchars with maxchars.";
}
if($this->minsize > $this->maxsize)
{
$temp = $this->minsize;
$this->minsize = $this->maxsize;
$this->maxsize = $temp;
if($this->debug) echo "\n<br>-b2evo-Captcha-Debug: Arrghh! What do you think I mean with min and max? Switch minsize with maxsize.";
}
// check TrueTypeFonts
$this->TTF_RANGE = array('0');
if ($handle = opendir($this->TTF_folder)) {
$i=0;
while (false !== ($file = readdir($handle))) {
//You could add a regex to this if to make sure the files are all *.ttf
if ($file != '.' && $file != '..') {
if (is_file($this->TTF_folder . $file)) {
$this->TTF_RANGE[$i]=$file;
if($this->debug) echo "\n<br>-b2evo-Captcha-Debug: Found font file (".$file.')';
}
}
}
closedir($handle);
}
if(is_array($this->TTF_RANGE))
{
if($this->debug) echo "\n<br>-b2evo-Captcha-Debug: Checking given TrueType-Array! (".count($this->TTF_RANGE).')';
$temp = array();
foreach($this->TTF_RANGE as $k=>$v)
{
if(is_readable($this->TTF_folder.$v)) $temp[] = $v;
}
$this->TTF_RANGE = $temp;
if($this->debug) echo "\n<br>-b2evo-Captcha-Debug: Valid TrueType-files: (".count($this->TTF_RANGE).')';
if(count($this->TTF_RANGE) < 1) die('No Truetype fonts available for the CaptchaClass.');
}
else
{
if($this->debug) echo "\n<br>-b2evo-Captcha-Debug: Check given TrueType-File! (".$this->TTF_RANGE.')';
if(!is_readable($this->TTF_folder.$this->TTF_RANGE)) die('No Truetypefont available for the b2evo captcha class.');
}
// select first TrueTypeFont
$this->change_TTF();
if($this->debug) echo "\n<br>-b2evo-Captcha-Debug: Set current TrueType-File: (".$this->TTF_file.")";
// get number of noise-chars for background if is enabled
$this->nb_noise = $this->noise ? ($this->chars * $this->noisefactor) : 0;
if($this->debug) echo "\n<br>-b2evo-Captcha-Debug: Set number of noise characters to: (".$this->nb_noise.')';
// seed the random number generator if less than php 4.2.0
if( !function_exists('version_compare') || version_compare(phpversion(), '4.2.0', '< ') )
{
mt_srand((double)microtime()*1000000);
}
// specify counter-filename
if($this->debug) echo "\n<br>-Captcha-Debug: The counterfilename is (".$this->tempfolder.$this->counter_filename.')';
// retrieve last counter-value
$test = $this->txt_counter($this->tempfolder.$this->counter_filename);
// set and retrieve current counter-value
$counter = $this->txt_counter($this->tempfolder.$this->counter_filename,TRUE);
// check if counter works correct
if(($counter !== FALSE) && ($counter - $test == 1))
{
// Counter works perfect, =:)
if($this->debug) echo "\n<br>-Captcha-Debug: Current counter-value is ($counter). Garbage-collector should start at (".$this->collect_garbage_after.')';
// check if garbage-collector should run
if($counter >= $this->collect_garbage_after)
{
// Reset counter
if($this->debug) echo "\n<br>-Captcha-Debug: Reset the counter-value. (0)";
$this->txt_counter($this->tempfolder.$this->counter_filename,TRUE,0);
// start garbage-collector
$this->garbage_collector_error = $this->collect_garbage() ? FALSE : TRUE;
if($this->debug) echo "\n<br>-Captcha-Debug: ERROR! SOME TRASHFILES COULD NOT BE DELETED!";
}
}
else
{
// Counter-ERROR!
if($this->debug) echo "\n<br>-Captcha-Debug: ERROR! NO COUNTER-VALUE AVAILABLE!";
}
}
////////////////////////////////
//
// PUBLIC METHODS
//
/**
* Generates a captcha image and returns the complete path to the image
*
**/
function get_b2evo_captcha()
{
$this->make_captcha();
if($public=='') $public = $this->public_key;
return str_replace($_SERVER['DOCUMENT_ROOT'],'',$this->tempfolder).$this->filename_prefix.$public.'.jpg';
}
/**
*
* Validates submission and returns result
* Returns 0 = invalid sumbit | 1 = valid submit
*
**/
function validate_submit($image,$attempt)
{
$correct_hash = substr($image,-36,32);
if($this->case_sensitive==0) $attempt = strtoupper($attempt);
if($this->check_captcha($correct_hash,$attempt))
{
if($this->debug) echo "\n<br>-Captcha-Debug: Validating submitted form returns: (1)";
return 1;
}
else
{
if($this->debug) echo "\n<br>-Captcha-Debug: Validating submitted form returns: (0)";
return 0;
}
}
////////////////////////////////
//
// PRIVATE METHODS
//
/** @private **/
function make_captcha($private_key='')
{
if($private_key=='') $private_key = $this->generate_keypair();
// set dimension of image
$this->lx = (strlen($private_key) + 1) * (int)(($this->maxsize + $this->minsize) / 1.5);
$this->ly = (int)(2.4 * $this->maxsize);
if($this->debug) echo "\n<br>-b2evo-Captcha-Debug: Set image dimension to: (".$this->lx.' x '.$this->ly.')';
if($this->debug) echo "\n<br>-Captcha-Debug: Generate private key: ($private_key)";
// set number of noise-chars for background if is enabled
$this->nb_noise = $this->noise ? (strlen($private_key) * $this->noisefactor) : 0;
if($this->debug) echo "\n<br>-b2evo-Captcha-Debug: Set number of noise characters to: (".$this->nb_noise.')';
// create Image and set the apropriate function depending on GD-Version & websafecolor-value
if($this->gd_version >= 2 && !$this->websafecolors)
{
$func1 = 'imagecreatetruecolor';
$func2 = 'imagecolorallocate';
}
else
{
$func1 = 'imageCreate';
$func2 = 'imagecolorclosest';
}
$image = $func1($this->lx,$this->ly);
if($this->debug) echo "\n<br>-Captcha-Debug: Generate ImageStream with: ($func1())";
if($this->debug) echo "\n<br>-Captcha-Debug: For colordefinitions we use: ($func2())";
// Set Backgroundcolor
$this->random_color(224, 255);
$back = @imagecolorallocate($image, $this->r, $this->g, $this->b);
@ImageFilledRectangle($image,0,0,$this->lx,$this->ly,$back);
if($this->debug) echo "\n<br>-Captcha-Debug: We allocate one color for Background: (".$this->r.'-'.$this->g.'-'.$this->b.')';
// allocates the 216 websafe color palette to the image
if($this->gd_version < 2 || $this->websafecolors) $this->makeWebsafeColors($image);
// fill with noise or grid
if($this->nb_noise > 0)
{
// random characters in background with random position, angle, color
if($this->debug) echo "\n<br>-Captcha-Debug: Fill background with noise: (".$this->nb_noise.')';
for($i=0; $i < $this->nb_noise; $i++)
{
$size = intval(mt_rand((int)($this->minsize / 2.3), (int)($this->maxsize / 1.7)));
$angle = intval(mt_rand(0, 360));
$x = intval(mt_rand(0, $this->lx));
$y = intval(mt_rand(0, (int)($this->ly - ($size / 5))));
$this->random_color(160, 224);
$color = $func2($image, $this->r, $this->g, $this->b);
$text = chr(intval(mt_rand(45,250)));
@ImageTTFText($image, $size, $angle, $x, $y, $color, $this->change_TTF(), $text);
}
}
else
{
// generate grid
if($this->debug) echo "\n<br>-Captcha-Debug: Fill background with x-gridlines: (".(int)($this->lx / (int)($this->minsize / 1.5)).')';
for($i=0; $i < $this->lx; $i += (int)($this->minsize / 1.5))
{
$this->random_color(160, 224);
$color = $func2($image, $this->r, $this->g, $this->b);
@imageline($image, $i, 0, $i, $this->ly, $color);
}
if($this->debug) echo "\n<br>-Captcha-Debug: Fill background with y-gridlines: (".(int)($this->ly / (int)(($this->minsize / 1.8))).')';
for($i=0 ; $i < $this->ly; $i += (int)($this->minsize / 1.8))
{
$this->random_color(160, 224);
$color = $func2($image, $this->r, $this->g, $this->b);
@imageline($image, 0, $i, $this->lx, $i, $color);
}
}
// generate Text
if($this->debug) echo "\n<br>-Captcha-Debug: Fill forground with chars and shadows: (".$this->chars.')';
for($i=0, $x = intval(mt_rand($this->minsize,$this->maxsize)); $i < strlen($private_key); $i++)
{
$text = substr($private_key, $i, 1);
$angle = intval(mt_rand(($this->maxrotation * -1), $this->maxrotation));
$size = intval(mt_rand($this->minsize, $this->maxsize));
$y = intval(mt_rand((int)($size * 1.5), (int)($this->ly - ($size / 7))));
$this->random_color(0, 127);
$color = $func2($image, $this->r, $this->g, $this->b);
$this->random_color(0, 127);
$shadow = $func2($image, $this->r + 127, $this->g + 127, $this->b + 127);
@ImageTTFText($image, $size, $angle, $x + (int)($size / 15), $y, $shadow, $this->change_TTF(), $text);
@ImageTTFText($image, $size, $angle, $x, $y - (int)($size / 15), $color, $this->TTF_file, $text);
$x += (int)($size + ($this->minsize / 5));
}
@ImageJPEG($image, $this->get_filename(), $this->jpegquality);
$res = file_exists($this->get_filename());
if($this->debug) echo "\n<br>-Captcha-Debug: Save Image with quality [".$this->jpegquality.'] as ('.$this->get_filename().') returns: ('.($res ? 'TRUE' : 'FALSE').')';
@ImageDestroy($image);
if($this->debug) echo "\n<br>-Captcha-Debug: Destroy Imagestream.";
if(!$res) die('Unable to save captcha-image.');
}
/** @private **/
function makeWebsafeColors(&$image)
{
//$a = array();
for($r = 0; $r <= 255; $r += 51)
{
for($g = 0; $g <= 255; $g += 51)
{
for($b = 0; $b <= 255; $b += 51)
{
$color = imagecolorallocate($image, $r, $g, $b);
//$a[$color] = array('r'=>$r,'g'=>$g,'b'=>$b);
}
}
}
if($this->debug) echo "\n<br>-Captcha-Debug: Allocate 216 websafe colors to image: (".imagecolorstotal($image).')';
//return $a;
}
/** @private **/
function random_color($min,$max)
{
$this->r = intval(mt_rand($min,$max));
$this->g = intval(mt_rand($min,$max));
$this->b = intval(mt_rand($min,$max));
//echo ' ('.$this->r.'-'.$this->g.'-'.$this->b.') ';
}
/** @private **/
function change_TTF()
{
if(is_array($this->TTF_RANGE))
{
$key = array_rand($this->TTF_RANGE);
$this->TTF_file = $this->TTF_folder.$this->TTF_RANGE[$key];
}
else
{
$this->TTF_file = $this->TTF_folder.$this->TTF_RANGE;
}
return $this->TTF_file;
}
/** @private **/
function check_captcha($correct_hash,$attempt)
{
// when check, destroy picture on disk
if(file_exists($this->get_filename($correct_hash)))
{
$res = @unlink($this->get_filename($correct_hash)) ? 'TRUE' : 'FALSE';
if($this->debug) echo "\n<br>-Captcha-Debug: Delete image (".$this->get_filename($correct_hash).") returns: ($res)";
}
else
return FALSE;
$res = (md5($attempt)===$correct_hash) ? 'TRUE' : 'FALSE';
if($this->debug) echo "\n<br>-Captcha-Debug: Comparing public with private key returns: ($res)";
return $res == 'TRUE' ? TRUE : FALSE;
}
/** @private **/
function get_filename($public='')
{
if($public=='') $public=$this->public_key;
return $this->tempfolder.$this->filename_prefix.$public.'.jpg';
}
/** @private **/
function get_filename_url($public="")
{
if($public=='') $public = $this->public_key;
return str_replace($_SERVER['DOCUMENT_ROOT'],'',$this->tempfolder).$this->filename_prefix.$public.'.jpg';
}
/** @private **/
function get_gd_version()
{
if (!function_exists('imagejpeg')) {
$gd_version_number = 0;
} else {
static $gd_version_number = null;
if($gd_version_number === null)
{
ob_start();
phpinfo(8);
$module_info = ob_get_contents();
ob_end_clean();
if(preg_match("/\bgd\s+version\b[^\d\n\r]+?([\d\.]+)/i", $module_info, $matches))
{
$gd_version_number = $matches[1];
}
else
{
$gd_version_number = 0;
}
}
}
return $gd_version_number;
}
// this is where the actual text and public hash is generated and stored
function generate_keypair()
{
$key = '';
$this->chars = mt_rand($this->minchars,$this->maxchars);
for($i=0; $i < $this->chars; $i++) {
$key .= $this->validchars{mt_rand(0,strlen($this->validchars))};
}
if($this->case_sensitive==0) $key = strtoupper($key);
$this->public_key = md5($key);
if($this->debug) echo "\n<br>-Captcha-Debug: Generate Keys, private key is: (".$key.')';
if($this->debug) echo "\n<br>-Captcha-Debug: Generate Keys, public key is: (".$this->public_key.')';
return $key;
}
//Store/Retrieve a counter-value in/from a textfile. Optionally count it up or store a (as third param) specified value.
// Returns counter-value
function txt_counter($filename,$add=FALSE,$fixvalue=FALSE)
{
if(is_file($filename) ? TRUE : touch($filename))
{
if(is_readable($filename) && is_writable($filename))
{
$fp = @fopen($filename, 'r');
if($fp)
{
$counter = (int)trim(fgets($fp));
fclose($fp);
if($add)
{
if($fixvalue !== FALSE)
{
$counter = (int)$fixvalue;
}
else
{
$counter++;
}
$fp = @fopen($filename, 'w');
if($fp)
{
fputs($fp,$counter);
fclose($fp);
return $counter;
}
else return FALSE;
}
else
{
return $counter;
}
}
else return FALSE;
}
else return FALSE;
}
else return FALSE;
}
// Scanns the tempfolder for jpeg-files with nameprefix used by the class and trash them if they are older than maxlifetime.
function collect_garbage()
{
$OK = FALSE;
$captchas = 0;
$trashed = 0;
if($handle = @opendir($this->tempfolder))
{
$OK = TRUE;
while(false !== ($file = readdir($handle)))
{
if(!is_file($this->tempfolder.$file)) continue;
// check for name-prefix, extension and filetime
if(substr($file,0,strlen($this->prefix)) == $this->prefix)
{
if(strrchr($file, '.') == '.jpg')
{
$captchas++;
if((time() - filemtime($this->tempfolder.$file)) >= $this->maxlifetime)
{
$trashed++;
$res = @unlink($this->tempfolder.$file);
if(!$res) $OK = FALSE;
}
}
}
}
closedir($handle);
}
if($this->debug) echo "\n<br>-Captcha-Debug: There are ($captchas) captcha-images in tempfolder, where ($trashed) are seems to be lost.";
return $OK;
}
} // END CLASS b2evo_captcha
?>
View File
+1
View File
@@ -0,0 +1 @@
see http://sourceforge.net/projects/b2evo-captcha
+41
View File
@@ -0,0 +1,41 @@
<?php
//
// 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;
}
}
?>
+96
View File
@@ -0,0 +1,96 @@
<?php
/***************************************************************************
./lib/cache_icon.inc.php
--------------------
begin : Sun october 9 2005
copyright : (C) 2005 The OpenCaching Group
forum contact at : http://www.opencaching.com/phpBB2
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
/****************************************************************************
Unicode Reminder メモ
function to generate the name of the needed cache-icon
****************************************************************************/
function getCacheIcon($user_id, $cache_id, $cache_status, $cache_userid, $iconname)
{
global $dblink;
$cacheicon_searchable = false;
$cacheicon_type = "";
$inactive = false;
// mark if found
if(isset($user_id))
{
$found = 0;
$resp = sql("SELECT `type` FROM `cache_logs` WHERE `cache_id`='&1' AND `user_id`='&2' ORDER BY `type`", $cache_id, $user_id);
while($row = sql_fetch_assoc($resp))
{
if($found <= 0)
{
switch($row['type'])
{
case 1:
case 7: $found = $row['type']; $cacheicon_type = "-found"; $inactive = true; break;
case 2: $found = $row['type']; $cacheicon_type = "-dnf"; break;
}
}
}
}
if($cache_userid == $user_id)
{
$cacheicon_type = "-owner";
$inactive = true;
switch($cache_status)
{
case 1: $cacheicon_searchable = "-s"; break;
case 2: $cacheicon_searchable = "-n"; break;
case 3: $cacheicon_searchable = "-a"; break;
case 4: $cacheicon_searchable = "-a"; break;
case 6: $cacheicon_searchable = "-a"; break;
case 7: $cacheicon_searchable = "-a"; break;
}
}
else
{
switch($cache_status)
{
case 1: $cacheicon_searchable = "-s"; break;
case 2: $inactive = true; $cacheicon_searchable = "-n"; break;
case 3: $inactive = true; $cacheicon_searchable = "-a"; break;
case 4: $inactive = true; $cacheicon_searchable = "-a"; break;
case 6: $inactive = true; $cacheicon_searchable = "-a"; break;
case 7: $inactive = true; $cacheicon_searchable = "-a"; break;
}
}
// cacheicon
$iconext = "." . mb_eregi_replace("^.*\.", "", $iconname);
$iconname = mb_eregi_replace("\..*", "", $iconname);
$iconname .= $cacheicon_searchable . $cacheicon_type . $iconext;
return array($iconname, $inactive);
}
function getSmallCacheIcon($iconname)
{
$iconname = mb_eregi_replace('([^/]+)$', '16x16-\1', $iconname);
return $iconname;
}
?>
+147
View File
@@ -0,0 +1,147 @@
<?php
/***************************************************************************
./lib/caches.inc.php
--------------------
begin : June 24 2004
copyright : (C) 2004 The OpenCaching Group
forum contact at : http://www.opencaching.com/phpBB2
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
/****************************************************************************
Unicode Reminder メモ
functions and variables for cache-submission related things
****************************************************************************/
// Array with cachetypes, also stored in database - table cache_type
$cache_types[] = array('id' => '2', 'short' => 'Trad.', 'de' => 'normaler Cache', 'en' => 'Traditional Cache');
$cache_types[] = array('id' => '10', 'short' => 'Driv.', 'de' => 'Drive-In', 'en' => 'Drive-In');
$cache_types[] = array('id' => '3', 'short' => 'Multi', 'de' => 'Multicache', 'en' => 'Multicache');
$cache_types[] = array('id' => '7', 'short' => 'Quiz', 'de' => 'Rätselcache', 'en' => 'Quizcache');
$cache_types[] = array('id' => '8', 'short' => 'Math', 'de' => 'Mathe-/Physikcache', 'en' => 'Math/Physics-Cache');
$cache_types[] = array('id' => '9', 'short' => 'Moving', 'de' => 'Beweglicher Cache', 'en' => 'Moving Cache');
$cache_types[] = array('id' => '4', 'short' => 'Virt.', 'de' => 'virtueller Cache', 'en' => 'virtual Cache');
$cache_types[] = array('id' => '5', 'short' => 'ICam.', 'de' => 'Webcam Cache', 'en' => 'Webcam Cache');
$cache_types[] = array('id' => '6', 'short' => 'Event', 'de' => 'Event Cache', 'en' => 'Event Cache');
$cache_types[] = array('id' => '1', 'short' => 'Other', 'de' => 'unbekannter Cachetyp', 'en' => 'unknown cachetyp');
// Cachetype-ID selected by default
// $default_cachetype_id = -1;
// Array with cachestatus, also stored in database - table cache_status
$cache_status[] = array('id' => '1', 'de' => 'Kann gesucht werden', 'en' => 'Ready for search');
$cache_status[] = array('id' => '2', 'de' => 'Momentan nicht verfügbar', 'en' => 'Temporary not available');
$cache_status[] = array('id' => '3', 'de' => 'Archiviert', 'en' => 'Archived');
$cache_status[] = array('id' => '4', 'de' => 'Von den Approvern entfernt, um geprüft zu werden', 'en' => 'Hidden by approvers to check');
$cache_status[] = array('id' => '5', 'de' => 'Noch nicht veröffentlicht', 'en' => 'Not yet available');
$cache_status[] = array('id' => '6', 'de' => 'Gesperrt', 'en' => 'Locked, visible');
$cache_status[] = array('id' => '7', 'de' => 'Gesperrt, unsichtbar', 'en' => 'Locked, invisible');
// Sachestatus-ID selected by default
$default_cachestatus_id = 1;
// Array with cachesizes, also stored in database - table cache_size
$cache_size[] = array('id' => '2', 'de' => 'mikro', 'en' => 'micro');
$cache_size[] = array('id' => '3', 'de' => 'klein', 'en' => 'small');
$cache_size[] = array('id' => '4', 'de' => 'normal', 'en' => 'normal');
$cache_size[] = array('id' => '5', 'de' => 'groß', 'en' => 'large');
$cache_size[] = array('id' => '6', 'de' => 'extrem groß', 'en' => 'very large');
$cache_size[] = array('id' => '1', 'de' => 'andere Größe', 'en' => 'other size');
$cache_size[] = array('id' => '7', 'de' => 'kein Behälter', 'en' => 'no container');
// Sachesize-ID selected by default
// $default_cachesize_id = -1;
// Array with log_types
/*
$log_types[] = array('id' => '1', 'de' => 'Gefunden', 'en' => 'Found');
$log_types[] = array('id' => '2', 'de' => 'Nicht gefunden', 'en' => 'Not found');
$log_types[] = array('id' => '3', 'de' => 'Bemerkung', 'en' => 'Note');
$log_types[] = array('id' => '4', 'de' => 'Gesperrt', 'en' => 'Closed');
$log_types[] = array('id' => '5', 'de' => 'Freigegeben', 'en' => 'Opened');
$log_types[] = array('id' => '6', 'de' => 'Entfernt', 'en' => 'Removed');
*/
$log_types = array();
// Sachesize-ID selected by default
$default_logtype_id = 1;
// new: get log_types from database
get_log_types_from_database();
function get_log_types_from_database()
{
global $dblink;
global $log_types;
$resp = sql("SELECT * FROM log_types ORDER BY id");
while($row = sql_fetch_assoc($resp))
{
$log_types[] = $row;
}
}
function log_type_from_id($id, $lang)
{
global $log_types;
foreach ($log_types AS $type)
{
if ($type['id'] == $id)
{
return $type[$lang];
}
}
}
function cache_type_from_id($id, $lang)
{
global $cache_types;
foreach ($cache_types AS $cache_type)
{
if ($cache_type['id'] == $id)
{
return $cache_type[$lang];
}
}
}
function cache_size_from_id($id, $lang)
{
global $cache_size;
foreach ($cache_size AS $size)
{
if ($size['id'] == $id)
{
return $size[$lang];
}
}
}
function cache_status_from_id($id, $lang)
{
global $cache_status;
foreach ($cache_status AS $status)
{
if ($status['id'] == $id)
{
return $status[$lang];
}
}
}
?>
+199
View File
@@ -0,0 +1,199 @@
<?php
/***************************************************************************
./lib/calculation.inc.php
--------------------
begin : Wed October 11 2006
copyright : (C) 2006 The OpenCaching Group
forum contact at : http://develforum.opencaching.de
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
/****************************************************************************
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);
}
?>
+121
View File
@@ -0,0 +1,121 @@
<?php
/***************************************************************************
./lib/captcha.inc.php
--------------------
begin : April 30 2007
copyright : (C) 2007 The OpenCaching Group
forum contact at : http://develforum.opencaching.de
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
/****************************************************************************
Unicode Reminder メモ
captcha generator
****************************************************************************/
/* generate configuration
*/
//Change these settings to change the way the captcha generation works and match your server settings
//Folder Path where image files can be stored, must be readable and writable by the web server
//Don't forget the trailing slash
$tempfolder = 'cache/captcha/';
//Folder Path where your captcha font files are stored, must be readable by the web server
//Don't forget the trailing slash
$TTF_folder = 'lib/b2evo-captcha/b2evo_captcha_fonts/';
//The minimum number of characters to use for the captcha
//Set to the same as maxchars to use fixed length captchas
$minchars = 5;
//The maximum number of characters to use for the captcha
//Set to the same as minchars to use fixed length captchas
$maxchars = 7;
//The minimum character font size to use for the captcha
//Set to the same as maxsize to use fixed font size
$minsize = 20;
//The maximum character font size to use for the captcha
//Set to the same as minsize to use fixed font size
$maxsize = 30;
//The maximum rotation (in degrees) for each character
$maxrotation = 25;
//Use background noise instead of a grid
$noise = TRUE;
//Use web safe colors (only 216 colors)
$websafecolors = TRUE;
//Enable debug messages
$debug = FALSE;
//Filename of garbage collector counter which is stored in the tempfolder
$counter_filename = 'b2evo_captcha_counter.txt';
//Prefix of captcha image filenames
$filename_prefix = '';
//Number of captchas to generate before garbage collection is done
$collect_garbage_after = 50;
//Maximum lifetime of a captcha (in seconds) before being deleted during garbage collection
$maxlifetime = 1800;
//Make all letters uppercase (does not preclude symbols)
$case_sensitive = FALSE;
//////////////////////////////////////////
//DO NOT EDIT ANYTHING BELOW THIS LINE!
//
//
//$folder_root = substr(__FILE__,0,(strpos(__FILE__,'.php')));
$folder_root = $opt['rootpath'];
$CAPTCHA_CONFIG = array('tempfolder'=>$folder_root.$tempfolder,'TTF_folder'=>$folder_root.$TTF_folder,'minchars'=>$minchars,'maxchars'=>$maxchars,'minsize'=>$minsize,'maxsize'=>$maxsize,'maxrotation'=>$maxrotation,'noise'=>$noise,'websafecolors'=>$websafecolors,'debug'=>$debug,'counter_filename'=>$counter_filename,'filename_prefix'=>$filename_prefix,'collect_garbage_after'=>$collect_garbage_after,'maxlifetime'=>maxlifetime,'case_sensitive'=>$case_sensitive);
require_once($opt['rootpath'] . 'lib/b2evo-captcha/b2evo_captcha.class.php');
// return true/false
function checkCaptcha($id, $string)
{
global $CAPTCHA_CONFIG;
$captcha =& new b2evo_captcha($CAPTCHA_CONFIG);
// additional check ... id and string can only contain [a-f0-9]
if (mb_ereg_match('^[0-9a-f]{32}$', $id) == false)
return false;
if ($captcha->validate_submit($id, $string) == 1)
return true;
else
return false;
}
// return array(id, filename)
function createCaptcha()
{
global $CAPTCHA_CONFIG;
$captcha =& new b2evo_captcha($CAPTCHA_CONFIG);
$ret['filename'] = $captcha->get_b2evo_captcha();
$ret['id'] = substr($ret['filename'], -36, 32);
return $ret;
}
?>
+569
View File
@@ -0,0 +1,569 @@
<?php
// Unicode Reminder メモ
$allowedtags = mb_split(',', 'a,b,i,p,q,s,u,br,dd,dl,dt,em,h1,h2,h3,h4,h5,h6,hr,li,td,th,tr,tt,ol,ul,big,bdo,col,dfn,del,dir,div,ins,img,kbd,map,pre,sub,sup,var,abbr,area,cite,code,font,menu,samp,span,small,thead,tfoot,tbody,table,strong,center,strike,acronym,address,caption,isindex,colgroup,fieldset');
$allowedattr = mb_split(',', 'id,src,alt,dir,rel,rev,abbr,axis,char,cite,face,href,lang,name,size,span,type,align,class,clear,color,frame,ismap,rules,scope,shape,start,style,title,value,width,border,coords,height,hspace,nowrap,nohref,target,usemap,vspace,valign,bgcolor,charoff,charset,colspan,compact,headers,noshade,rowspan,summary,longdesc,hreflang,datetime,tabindex,accesskey,background,cellspacing,cellpadding');
/** @class: InputFilter (PHP4 & PHP5, with comments)
* @project: PHP Input Filter
* @date: 10-05-2005
* @version: 1.2.2_php4/php5
* @author: Daniel Morris
* @contributors: Gianpaolo Racca, Ghislain Picard, Marco Wandschneider, Chris Tobin and Andrew Eddie.
* @copyright: Daniel Morris
* @email: dan@rootcube.com
* @license: GNU General Public License (GPL)
*/
class InputFilter
{
var $tagsArray; // default = empty array
var $attrArray; // default = empty array
var $tagsMethod; // default = 0
var $attrMethod; // default = 0
var $xssAuto; // default = 1
var $tagBlacklist = array('applet', 'body', 'bgsound', 'base', 'basefont', 'embed', 'frame', 'frameset', 'head', 'html', 'id', 'iframe', 'ilayer', 'layer', 'link', 'meta', 'name', 'object', 'script', 'style', 'title', 'xml');
var $attrBlacklist = array('action', 'codebase', 'dynsrc', 'lowsrc'); // also will strip ALL event handlers
/**
* Constructor for inputFilter class. Only first parameter is required.
* @access constructor
* @param Array $tagsArray - list of user-defined tags
* @param Array $attrArray - list of user-defined attributes
* @param int $tagsMethod - 0= allow just user-defined, 1= allow all but user-defined
* @param int $attrMethod - 0= allow just user-defined, 1= allow all but user-defined
* @param int $xssAuto - 0= only auto clean essentials, 1= allow clean blacklisted tags/attr
*/
function inputFilter($tagsArray = array(), $attrArray = array(), $tagsMethod = 0, $attrMethod = 0, $xssAuto = 1) {
// make sure user defined arrays are in lowercase
for ($i = 0; $i < count($tagsArray); $i++)
$tagsArray[$i] = mb_strtolower($tagsArray[$i]);
for ($i = 0; $i < count($attrArray); $i++)
$attrArray[$i] = mb_strtolower($attrArray[$i]);
// assign to member vars
$this->tagsArray = (array)$tagsArray;
$this->attrArray = (array)$attrArray;
$this->tagsMethod = $tagsMethod;
$this->attrMethod = $attrMethod;
$this->xssAuto = $xssAuto;
}
/**
* Method to be called by another php script. Processes for XSS and specified bad code.
* @access public
* @param Mixed $source - input string/array-of-string to be 'cleaned'
* @return String $source - 'cleaned' version of input parameter
*/
function process($source)
{
// clean all elements in this array
if (is_array($source))
{
// filter element for XSS and other 'bad' code etc.
foreach($source as $key => $value)
if (is_string($value)) $source[$key] = $this->remove($this->decode($value));
return $source;
// clean this string
}
else if (is_string($source))
{
// filter source for XSS and other 'bad' code etc.
return $this->remove($this->decode($source));
// return parameter as given
}
else
return $source;
}
/**
* Internal method to iteratively remove all unwanted tags and attributes
* @access protected
* @param String $source - input string to be 'cleaned'
* @return String $source - 'cleaned' version of input parameter
*/
function remove($source)
{
$loopCounter=0;
// provides nested-tag protection
while($source != $this->filterTags($source))
{
$source = $this->filterTags($source);
$loopCounter++;
}
return $source;
}
/**
* Internal method to strip a string of certain tags
* @access protected
* @param String $source - input string to be 'cleaned'
* @return String $source - 'cleaned' version of input parameter
*/
function filterTags($source)
{
// filter pass setup
$preTag = NULL;
$postTag = $source;
// find initial tag's position
$tagOpen_start = mb_strpos($source, '<');
// interate through string until no tags left
while($tagOpen_start !== FALSE)
{
// process tag interatively
$preTag .= mb_substr($postTag, 0, $tagOpen_start);
$postTag = mb_substr($postTag, $tagOpen_start);
$fromTagOpen = mb_substr($postTag, 1);
// end of tag
$tagOpen_end = mb_strpos($fromTagOpen, '>');
if ($tagOpen_end === false) break;
// next start of tag (for nested tag assessment)
$tagOpen_nested = mb_strpos($fromTagOpen, '<');
if (($tagOpen_nested !== false) && ($tagOpen_nested < $tagOpen_end))
{
$preTag .= mb_substr($postTag, 0, ($tagOpen_nested+1));
$postTag = mb_substr($postTag, ($tagOpen_nested+1));
$tagOpen_start = mb_strpos($postTag+1, '<');
continue;
}
$tagOpen_nested = (mb_strpos($fromTagOpen, '<') + $tagOpen_start + 1);
$currentTag = mb_substr($fromTagOpen, 0, $tagOpen_end);
$tagLength = mb_strlen($currentTag);
if (!$tagOpen_end)
{
$preTag .= $postTag;
$tagOpen_start = mb_strpos($postTag, '<');
}
// this is needed when additional spaces between attrname and attrvalue or tagname and first attrname
$currentTag = $this->wellFormTagWithAttr($currentTag);
// iterate through tag finding attribute pairs - setup
$tagLeft = $currentTag;
$attrSet = array();
$currentSpace = mb_strpos($tagLeft, ' ');
// is end tag
if (mb_substr($currentTag, 0, 1) == "/")
{
$isCloseTag = TRUE;
list($tagName) = mb_split(' ', $currentTag);
$tagName = mb_substr($tagName, 1);
// is start tag
}
else
{
$isCloseTag = FALSE;
list($tagName) = mb_split(' ', $currentTag);
}
// excludes all "non-regular" tagnames OR no tagname OR remove if xssauto is on and tag is blacklisted
if ((!mb_eregi("^[a-z][a-z0-9]*$",$tagName)) || (!$tagName) || ((in_array(mb_strtolower($tagName), $this->tagBlacklist)) && ($this->xssAuto)))
{
$postTag = mb_substr($postTag, ($tagLength + 2));
$tagOpen_start = mb_strpos($postTag, '<');
// don't append this tag
continue;
}
// this while is needed to support attribute values with spaces in!
while ($currentSpace !== FALSE)
{
$fromSpace = mb_substr($tagLeft, ($currentSpace+1));
$nextSpace = mb_strpos($fromSpace, ' ');
$openQuotes = mb_strpos($fromSpace, '"');
$closeQuotes = mb_strpos(mb_substr($fromSpace, ($openQuotes+1)), '"') + $openQuotes + 1;
// another equals exists
if (mb_strpos($fromSpace, '=') !== FALSE)
{
if (($openQuotes !== FALSE) && (mb_strpos(mb_substr($fromSpace, ($openQuotes+1)), '"') !== FALSE) && ($openQuotes < $nextSpace))
{
// opening and closing quotes exists
$attr = mb_substr($fromSpace, 0, ($closeQuotes + 1));
}
else
{
// one or neither exist
$attr = mb_substr($fromSpace, 0, $nextSpace);
}
}
else
{
// no more equals exist
$attr = mb_substr($fromSpace, 0, $nextSpace);
}
// last attr pair
if (!$attr) $attr = $fromSpace;
// add to attribute pairs array
$attrSet[] = $attr;
// next inc
$tagLeft = mb_substr($fromSpace, mb_strlen($attr));
$currentSpace = mb_strpos($tagLeft, ' ');
}
// check the last element of attrSet ... maybe empty or attr="value"/
if (count($attrSet) > 0)
{
if ($attrSet[count($attrSet) - 1] == '')
unset($attrSet[count($attrSet) - 1]);
if (mb_substr($attrSet[count($attrSet) - 1], -1) == '/')
$attrSet[count($attrSet) - 1] = mb_substr($attrSet[count($attrSet) - 1], 0, mb_strlen($attrSet[count($attrSet) - 1]) - 1);
}
// appears in array specified by user
$tagFound = in_array(mb_strtolower($tagName), $this->tagsArray);
// remove this tag on condition
if ((!$tagFound && $this->tagsMethod) || ($tagFound && !$this->tagsMethod))
{
// reconstruct tag with allowed attributes
if (!$isCloseTag)
{
$attrSet = $this->filterAttr($attrSet);
$preTag .= '<' . $tagName;
for ($i = 0; $i < count($attrSet); $i++)
$preTag .= ' ' . $attrSet[$i];
// reformat single tags to XHTML
if (mb_strpos($fromTagOpen, "</" . $tagName))
$preTag .= '>';
else
$preTag .= ' />';
// just the tagname
}
else
$preTag .= '</' . $tagName . '>';
}
// find next tag's start
$postTag = mb_substr($postTag, ($tagLength + 2));
$tagOpen_start = mb_strpos($postTag, '<');
}
// append any code after end of tags
$preTag .= $postTag;
return $preTag;
}
/**
* Internal method to strip a tag of certain attributes
* @access protected
* @param Array $attrSet
* @return Array $newSet
*/
function filterAttr($attrSet)
{
$newSet = array();
// process attributes
for ($i = 0; $i <count($attrSet); $i++)
{
// skip blank spaces in tag
if (!$attrSet[$i]) continue;
// split into attr name and value
$attrSubSet = mb_split('=', trim($attrSet[$i]));
list($attrSubSet[0]) = mb_split(' ', $attrSubSet[0]);
// bugfix ... '=' inside attributes
$aCount = count($attrSubSet);
for ($aN = 2; $aN < $aCount; $aN++)
$attrSubSet[1] .= '=' . $attrSubSet[$aN];
while (count($attrSubSet) > 2)
unset($attrSubSet[count($attrSubSet) - 1]);
// removes all "non-regular" attr names AND also attr blacklisted
if ((!mb_eregi("^[a-z]*$",$attrSubSet[0])) || (($this->xssAuto) && ((in_array(mb_strtolower($attrSubSet[0]), $this->attrBlacklist)) || (mb_substr($attrSubSet[0], 0, 2) == 'on'))))
continue;
// xss attr value filtering
if ($attrSubSet[1])
{
// strips unicode, hex, etc
$attrSubSet[1] = mb_ereg_replace('&#', '', $attrSubSet[1]);
// strip normal newline within attr value
$attrSubSet[1] = mb_ereg_replace('[\t\n\r\f]+', '', $attrSubSet[1]);
// strip double quotes
$attrSubSet[1] = mb_ereg_replace('"', '', $attrSubSet[1]);
// [requested feature] convert single quotes from either side to doubles (Single quotes shouldn't be used to pad attr value)
if ((mb_substr($attrSubSet[1], 0, 1) == "'") && (mb_substr($attrSubSet[1], (mb_strlen($attrSubSet[1]) - 1), 1) == "'"))
$attrSubSet[1] = mb_substr($attrSubSet[1], 1, (mb_strlen($attrSubSet[1]) - 2));
// strip slashes
$attrSubSet[1] = stripslashes($attrSubSet[1]);
}
// auto strip attr's with "javascript:
if ( ((mb_strpos(mb_strtolower($attrSubSet[1]), 'expression') !== false) && (mb_strtolower($attrSubSet[0]) == 'style')) ||
(mb_strpos(mb_strtolower($attrSubSet[1]), 'javascript:') !== false) ||
(mb_strpos(mb_strtolower($attrSubSet[1]), 'behaviour:') !== false) ||
(mb_strpos(mb_strtolower($attrSubSet[1]), 'vbscript:') !== false) ||
(mb_strpos(mb_strtolower($attrSubSet[1]), 'mocha:') !== false) ||
(mb_strpos(mb_strtolower($attrSubSet[1]), 'livescript:') !== false)
) continue;
// if matches user defined array
$attrFound = in_array(mb_strtolower($attrSubSet[0]), $this->attrArray);
// keep this attr on condition
if ((!$attrFound && $this->attrMethod) || ($attrFound && !$this->attrMethod))
{
// attr has value
if (isset($attrSubSet[1]))
{
$newSet[] = $attrSubSet[0] . '="' . $attrSubSet[1] . '"';
}
else
{
// reformat single attributes to XHTML
$newSet[] = $attrSubSet[0] . '="' . $attrSubSet[0] . '"';
}
}
}
return $newSet;
}
/**
* Try to convert to plaintext
* @access protected
* @param String $source
* @return String $source
*/
function decode($source) {
// url decode
// $source = html_entity_decode($source, ENT_QUOTES, "UTF-8");
// convert decimal
// $source = mb_ereg_replace('&#(\d+);',"chr(\\1)", $source); // decimal notation
// convert hex
// $source = mb_eregi_replace('&#x([a-f0-9]+);',"chr(0x\\1)", $source); // hex notation
return $source;
}
/**
* Method to be called by another php script. Processes for SQL injection
* @access public
* @param Mixed $source - input string/array-of-string to be 'cleaned'
* @param Buffer $connection - An open MySQL connection
* @return String $source - 'cleaned' version of input parameter
*/
function safeSQL($source, &$connection)
{
// clean all elements in this array
if (is_array($source))
{
// filter element for SQL injection
foreach($source as $key => $value)
if (is_string($value))
$source[$key] = $this->quoteSmart($this->decode($value), $connection);
return $source;
// clean this string
}
else if (is_string($source))
{
// filter source for SQL injection
if (is_string($source)) return $this->quoteSmart($this->decode($source), $connection);
// return parameter as given
}
else
return $source;
}
/**
* @author Chris Tobin
* @author Daniel Morris
* @access protected
* @param String $source
* @param Resource $connection - An open MySQL connection
* @return String $source
*/
function quoteSmart($source, &$connection)
{
// strip slashes
if (get_magic_quotes_gpc()) $source = stripslashes($source);
// quote both numeric and text
$source = $this->escapeString($source, $connection);
return $source;
}
/**
* @author Chris Tobin
* @author Daniel Morris
* @access protected
* @param String $source
* @param Resource $connection - An open MySQL connection
* @return String $source
*/
function escapeString($string, &$connection)
{
// depreciated function
if (version_compare(phpversion(),"4.3.0", "<"))
{
mysql_escape_string($string);
// current function
}
else
mysql_real_escape_string($string);
return $string;
}
/**
* @author Oliver Dietz
* @access protected
* @param String $tag
* @return String $tag
*
* this function well forms the attrlist
*
* examples
* input ' a href = "abc" '
* output 'a href="abc"'
*
* input ' / a href = "abc" '
* output '/a'
*
* input ' a href = abc '
* output 'a href=abc'
*
*/
function wellFormTagWithAttr($tag)
{
/** replace ' ' by ' '
* remove ' ' left and right from '='
* remove ' ' from beginning and end
* add a single or double quote if last quote is not terminated
* remove all attrs from closing tags
* remove cr's, lf's tab's and such things
* and do all that things (expect the last) only outside (single or double) quotes
*/
$tag = mb_ereg_replace('[\t\n\r\f]+', ' ', $tag);
$pos = 0;
$retval = '';
$appendTermchar = false;
while ($pos < mb_strlen($tag))
{
$nextdPos = mb_strpos($tag, '"', $pos);
$nextsPos = mb_strpos($tag, '\'', $pos);
if (($nextdPos === false) && ($nextsPos === false))
{
// keine weiteren Tags ... bis zum ende filtern
$filter_len = mb_strlen($tag) - $pos;
$no_filter_len = 0;
}
else
{
if ($nextdPos === false) $nextdPos = mb_strlen($tag) + 1;
if ($nextsPos === false) $nextsPos = mb_strlen($tag) + 1;
if ($nextsPos < $nextdPos)
{
$nextPos = $nextsPos;
$termchar = '\'';
}
else
{
$nextPos = $nextdPos;
$termchar = '"';
}
$filter_len = $nextPos - $pos + 1;
// ok, wir haben einen Anfang ... nach dem Ende suchen
$endFilter = mb_strpos($tag, $termchar, $nextPos + 1);
if ($endFilter === false)
{
$appendTermchar = true;
$no_filter_len = mb_strlen($tag) - $nextPos - 1;
}
else
{
$no_filter_len = $endFilter - $nextPos + 1;
}
}
$retval .= $this->spaceReplace(mb_substr($tag, $pos, $filter_len));
$pos += $filter_len;
$retval .= mb_substr($tag, $pos, $no_filter_len);
$pos += $no_filter_len;
}
if ($appendTermchar == true)
$retval .= $termchar;
if (mb_substr($retval, 0, 1) == '/')
{
//alle Attribute entfernen
$spacePos = mb_strpos($retval, ' ');
if ($spacePos !== false)
$retval = mb_substr($retval, 0, $spacePos);
}
return $retval;
}
function spaceReplace($str)
{
while (mb_strpos($str, ' ') !== false)
$str = mb_ereg_replace(' ', ' ', $str);
if (mb_substr($str, 0, 1) == ' ')
$str = mb_substr($str, 1);
if (mb_substr($str, -1) == ' ')
$str = mb_substr($str, 0, mb_strlen($str) - 1);
$str = mb_ereg_replace(' =', '=', $str);
$str = mb_ereg_replace('= ', '=', $str);
$str = mb_ereg_replace('/ ', '/', $str);
if (mb_substr($str, -1) == '/')
if (mb_substr($str, -2) != ' /')
$str = mb_substr($str, 0, mb_strlen($str) - 1);
return $str;
}
}
?>
+723
View File
@@ -0,0 +1,723 @@
<?php
/***************************************************************************
./lib/clicompatbase.inc.php
--------------------
begin : Fri September 16 2005
copyright : (C) 2005 The OpenCaching Group
forum contact at : http://www.opencaching.com/phpBB2
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
/****************************************************************************
Unicode Reminder メモ
contains functions that are compatible with the php-CLI-scripts under util.
Can be included without including common.inc.php, but will be included from
common.inc.php.
Global variables that need to be set up when including without common.inc.php:
$dblink
****************************************************************************/
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');
mb_language('uni');
// language unspecific constants
define('regex_username', '^[a-zA-Z0-9][a-zA-Z0-9\.\-_ @äüöÄÜÖ=)(\/\\\&*+~#]{2,59}$');
define('regex_password', '^[a-zA-Z0-9\.\-_ @äüöÄÜÖ=)(\/\\\&*+~#]{3,60}$');
define('regex_last_name', '^[a-zA-Z][a-zA-Z0-9\.\- äüöÄÜÖ]{1,59}$');
define('regex_first_name', '^[a-zA-Z][a-zA-Z0-9\.\- äüöÄÜÖ]{1,59}$');
define('regex_statpic_text', '^[a-zA-Z0-9\.\-_ @äüöÄÜÖß=)(\/\\\&*\$+~#!§%;,-?:\[\]{}¹²³\'\"`\|µ°]{0,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');
$dblink_slave = false;
// sql debugger?
if (!isset($sql_allow_debug)) $sql_allow_debug = 0;
// prepare EMail-From
$emailheaders = 'From: "' . $emailaddr . '" <' . $emailaddr . '>';
function logentry($module, $eventid, $userid, $objectid1, $objectid2, $logtext, $details)
{
sql("INSERT INTO logentries (`module`, `eventid`, `userid`, `objectid1`, `objectid2`, `logtext`, `details`) VALUES (
'&1', '&2', '&3', '&4', '&5', '&6', '&7')",
$module, $eventid, $userid, $objectid1, $objectid2, $logtext, serialize($details));
}
//create a "universal unique" replication "identifier"
function create_uuid()
{
$uuid = mb_strtoupper(md5(uniqid(rand(), true)));
//split into XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX (type VARCHAR 36, case insensitiv)
$uuid = mb_substr($uuid, 0, 8) . '-' . mb_substr($uuid, -24);
$uuid = mb_substr($uuid, 0, 13) . '-' . mb_substr($uuid, -20);
$uuid = mb_substr($uuid, 0, 18) . '-' . mb_substr($uuid, -16);
$uuid = mb_substr($uuid, 0, 23) . '-' . mb_substr($uuid, -12);
return $uuid;
}
// set a unique waypoint to this cache
function setCacheWaypoint($cacheid)
{
global $oc_waypoint_prefix;
$bLoop = true;
// falls mal was nicht so funktioniert wie es soll ...
$nMaxLoop = 10;
$nLoop = 0;
while (($bLoop == true) && ($nLoop < $nMaxLoop))
{
$rs = sql("SELECT MAX(`wp_oc`) `maxwp` FROM `caches` WHERE wp_oc!='OCGC77'");
$r = sql_fetch_assoc($rs);
mysql_free_result($rs);
if ($r['maxwp'] == null)
$nNext = 1;
else
$nNext = hexdec(mb_substr($r['maxwp'], 2, 4)) + 1;
$nNext = dechex($nNext);
while (mb_strlen($nNext) < 4)
$nNext = '0' . $nNext;
$sWP = $oc_waypoint_prefix . mb_strtoupper($nNext);
$bLoop = false;
$nLoop++;
sql("UPDATE IGNORE `caches` SET `wp_oc`='&1' WHERE `cache_id`='&2' AND ISNULL(`wp_oc`)", $sWP, $cacheid) || $bLoop = true;
}
}
function setLastFound($cacheid)
{
$rs = sql("SELECT MAX(`date`) `date` FROM `cache_logs` WHERE `cache_id`=&1 AND `type`=1", $cacheid);
$r = sql_fetch_array($rs);
mysql_free_result($rs);
if ($r['date'] == null)
sql("UPDATE `caches` SET `last_found`=null WHERE `cache_id`=&1", $cacheid);
else
sql("UPDATE `caches` SET `last_found`='&1' WHERE `cache_id`=&2", $r['date'], $cacheid);
}
// update last_modified=NOW() for every object depending on that cacheid
function touchCache($cacheid)
{
sql("UPDATE `caches` SET `last_modified`=NOW() WHERE `cache_id`='&1'", $cacheid);
sql("UPDATE `caches`, `cache_logs` SET `cache_logs`.`last_modified`=NOW() WHERE `caches`.`cache_id`=`cache_logs`.`cache_id` AND `caches`.`cache_id`='&1'", $cacheid);
sql("UPDATE `caches`, `cache_desc` SET `cache_desc`.`last_modified`=NOW() WHERE `caches`.`cache_id`=`cache_desc`.`cache_id` AND `caches`.`cache_id`='&1'", $cacheid);
sql("UPDATE `caches`, `pictures` SET `pictures`.`last_modified`=NOW() WHERE `caches`.`cache_id`=`pictures`.`object_id` AND `pictures`.`object_type`=2 AND `caches`.`cache_id`='&1'", $cacheid);
sql("UPDATE `caches`, `cache_logs`, `pictures` SET `pictures`.`last_modified`=NOW() WHERE `caches`.`cache_id`=`cache_logs`.`cache_id` AND `cache_logs`.`id`=`pictures`.`object_id` AND `pictures`.`object_type`=1 AND `caches`.`cache_id`='&1'", $cacheid);
}
// read a file and return it as a string
// WARNING: no huge files!
function read_file($file='')
{
$fh = fopen($file, 'r');
if ($fh)
{
$content = fread($fh, filesize($file));
}
fclose($fh);
return $content;
}
// explode with more than one separator
function explode_multi($str, $sep)
{
$ret = array();
$nCurPos = 0;
while ($nCurPos < mb_strlen($str))
{
$nNextSep = mb_strlen($str);
for ($nSepPos = 0; $nSepPos < mb_strlen($sep); $nSepPos++)
{
$nThisPos = mb_strpos($str, mb_substr($sep, $nSepPos, 1), $nCurPos);
if ($nThisPos !== false)
if ($nNextSep > $nThisPos)
$nNextSep = $nThisPos;
}
$ret[] = mb_substr($str, $nCurPos, $nNextSep - $nCurPos);
$nCurPos = $nNextSep + 1;
}
return $ret;
}
function mb_strpos_multi($haystack, $needles)
{
$arg = func_get_args();
$start = false;
foreach ($needles AS $needle)
{
$thisstart = mb_strpos($haystack, $needle, $arg[2]);
if ($start == false)
$start = $thisstart;
else if ($thisstart == false)
{
}
else if ($start > $thisstart)
$start = $thisstart;
}
return $start;
}
function escape_javascript($text)
{
return str_replace('\'', '\\\'', str_replace('"', '&quot;', $text));
}
// called if mysql_query faild, sends email to sysadmin
function sql_failed($sql)
{
sql_error();
}
function sqlValue($sql, $default)
{
$rs = sql($sql);
if ($r = sql_fetch_row($rs))
{
if ($r[0] == null)
return $default;
else
return $r[0];
}
else
return $default;
}
function sql_value_slave($sql, $default)
{
$rs = sql_slave($sql);
if ($r = sql_fetch_row($rs))
{
if ($r[0] == null)
return $default;
else
return $r[0];
}
else
return $default;
}
function getSysConfig($name, $default)
{
return sqlValue('SELECT `value` FROM `sysconfig` WHERE `name`=\'' . sql_escape($name) . '\'', $default);
}
function setSysConfig($name, $value)
{
if (sqlValue('SELECT COUNT(*) FROM sysconfig WHERE name=\'' . sql_escape($name) . '\'', 0) == 1)
sql("UPDATE `sysconfig` SET `value`='&1' WHERE `name`='&2' LIMIT 1", $value, $name);
else
sql("INSERT INTO `sysconfig` (`name`, `value`) VALUES ('&1', '&2')", $name, $value);
}
/*
sql("SELECT id FROM &tmpdb.table WHERE a=&1 AND &tmpdb.b='&2'", 12345, 'abc');
returns: recordset or false
*/
function sql($sql)
{
global $dblink;
// prepare args
$args = func_get_args();
unset($args[0]);
if (isset($args[1]) && is_array($args[1]))
{
$tmp_args = $args[1];
unset($args);
// correct indizes
$args = array_merge(array(0), $tmp_args);
unset($tmp_args);
unset($args[0]);
}
return sql_internal($dblink, $sql, false, $args);
}
function sql_slave($sql)
{
global $dblink_slave;
// prepare args
$args = func_get_args();
unset($args[0]);
if (isset($args[1]) && is_array($args[1]))
{
$tmp_args = $args[1];
unset($args);
// correct indizes
$args = array_merge(array(0), $tmp_args);
unset($tmp_args);
unset($args[0]);
}
if ($dblink_slave === false)
db_connect_anyslave();
return sql_internal($dblink_slave, $sql, true, $args);
}
function sql_internal($_dblink, $sql, $bSlave)
{
global $opt;
global $sql_debug, $sql_warntime;
global $sql_replacements;
global $sqlcommands;
global $dblink_slave;
$args = func_get_args();
unset($args[0]);
unset($args[1]);
unset($args[2]);
/* as an option, you can give as second parameter an array
* with all values for the placeholder. The array has to be
* with numeric indizes.
*/
if (isset($args[3]) && is_array($args[3]))
{
$tmp_args = $args[3];
unset($args);
// correct indizes
$args = array_merge(array(0), $tmp_args);
unset($tmp_args);
unset($args[0]);
}
$sqlpos = 0;
$filtered_sql = '';
// $sql von vorne bis hinten durchlaufen und alle &x ersetzen
$nextarg = mb_strpos($sql, '&');
while ($nextarg !== false)
{
// muss dieses & ersetzt werden, oder ist es escaped?
$escapesCount = 0;
while ((($nextarg - $escapesCount - 1) > 0) && (mb_substr($sql, $nextarg - $escapesCount - 1, 1) == '\\')) $escapesCount++;
if (($escapesCount % 2) == 1)
$nextarg++;
else
{
$nextchar = mb_substr($sql, $nextarg + 1, 1);
if (is_numeric($nextchar))
{
$arglength = 0;
$arg = '';
// nächstes Zeichen das keine Zahl ist herausfinden
while (mb_ereg_match('^[0-9]{1}', $nextchar) == 1)
{
$arg .= $nextchar;
$arglength++;
$nextchar = mb_substr($sql, $nextarg + $arglength + 1, 1);
}
// ok ... ersetzen
$filtered_sql .= mb_substr($sql, $sqlpos, $nextarg - $sqlpos);
$sqlpos = $nextarg + $arglength;
if (isset($args[$arg]))
{
if (is_numeric($args[$arg]))
$filtered_sql .= $args[$arg];
else
{
if ((mb_substr($sql, $sqlpos - $arglength - 1, 1) == '\'') && (mb_substr($sql, $sqlpos + 1, 1) == '\''))
$filtered_sql .= sql_escape($args[$arg]);
else if ((mb_substr($sql, $sqlpos - $arglength - 1, 1) == '`') && (mb_substr($sql, $sqlpos + 1, 1) == '`'))
$filtered_sql .= sql_escape($args[$arg]);
else
sql_error();
}
}
else
{
// NULL
if ((mb_substr($sql, $sqlpos - $arglength - 1, 1) == '\'') && (mb_substr($sql, $sqlpos + 1, 1) == '\''))
{
// Anführungszeichen weg machen und NULL einsetzen
$filtered_sql = mb_substr($filtered_sql, 0, mb_strlen($filtered_sql) - 1);
$filtered_sql .= 'NULL';
$sqlpos++;
}
else
$filtered_sql .= 'NULL';
}
$sqlpos++;
}
else
{
$arglength = 0;
$arg = '';
// nächstes Zeichen das kein Buchstabe/Zahl ist herausfinden
while (mb_ereg_match('^[a-zA-Z0-9]{1}', $nextchar) == 1)
{
$arg .= $nextchar;
$arglength++;
$nextchar = mb_substr($sql, $nextarg + $arglength + 1, 1);
}
// ok ... ersetzen
$filtered_sql .= mb_substr($sql, $sqlpos, $nextarg - $sqlpos);
if (isset($sql_replacements[$arg]))
{
$filtered_sql .= $sql_replacements[$arg];
}
else
sql_error();
$sqlpos = $nextarg + $arglength + 1;
}
}
$nextarg = mb_strpos($sql, '&', $nextarg + 1);
}
// rest anhängen
$filtered_sql .= mb_substr($sql, $sqlpos);
// \& durch & ersetzen
$nextarg = mb_strpos($filtered_sql, '\&');
while ($nextarg !== false)
{
$escapesCount = 0;
while ((($nextarg - $escapesCount - 1) > 0) && (mb_substr($filtered_sql, $nextarg - $escapesCount - 1, 1) == '\\')) $escapesCount++;
if (($escapesCount % 2) == 0)
{
// \& ersetzen durch &
$filtered_sql = mb_substr($filtered_sql, 0, $nextarg) . '&' . mb_substr($filtered_sql, $nextarg + 2);
$nextarg--;
}
$nextarg = mb_strpos($filtered_sql, '\&', $nextarg + 2);
}
//
// ok ... hier ist filtered_sql fertig
//
/* todo:
- errorlogging
- LIMIT
- DROP/DELETE ggf. blocken
*/
if (isset($sql_debug) && ($sql_debug == true))
{
require_once($opt['rootpath'] . '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');
$cSqlExecution = new Cbench;
$cSqlExecution->start();
$result = mysql_query($filtered_sql, $_dblink);
if ($result === false) sql_error();
$cSqlExecution->stop();
if ($cSqlExecution->diff() > $sql_warntime)
sql_warn('execution took ' . $cSqlExecution->diff() . ' seconds');
}
return $result;
}
function sql_escape($value)
{
global $dblink;
$value = mysql_real_escape_string($value, $dblink);
$value = mb_ereg_replace('&', '\&', $value);
return $value;
}
function sql_error()
{
global $sql_errormail;
global $emailheaders;
global $absolute_server_URI;
global $interface_output;
global $dberrormsg;
if ($sql_errormail != '')
{
// sendout email
$email_content = mysql_errno() . ": " . mysql_error();
$email_content .= "\n--------------------\n";
$email_content .= print_r(debug_backtrace(), true);
mb_send_mail($sql_errormail, 'sql_error: ' . $absolute_server_URI, $email_content, $emailheaders);
}
if ($interface_output == 'html')
{
// display errorpage
tpl_errorMsg('sql_error', $dberrormsg);
exit;
}
else if ($interface_output == 'plain')
{
echo "\n";
echo 'sql_error' . "\n";
echo '---------' . "\n";
echo print_r(debug_backtrace(), true) . "\n";
exit;
}
die('sql_error');
}
function sql_warn($warnmessage)
{
global $sql_errormail;
global $emailheaders;
global $absolute_server_URI;
$email_content = $warnmessage;
$email_content .= "\n--------------------\n";
$email_content .= print_r(debug_backtrace(), true);
//mb_send_mail($sql_errormail, 'sql_warn: ' . $absolute_server_URI, $email_content, $emailheaders);
}
/*
Ersatz für die in Mysql eingebauten Funktionen
*/
function sql_fetch_array($rs)
{
return mysql_fetch_array($rs);
}
function sql_fetch_assoc($rs)
{
return mysql_fetch_assoc($rs);
}
function sql_fetch_row($rs)
{
return mysql_fetch_row($rs);
}
function sql_free_result($rs)
{
return mysql_free_result($rs);
}
function mb_trim($str)
{
$bLoop = true;
while ($bLoop == true)
{
$sPos = mb_substr($str, 0, 1);
if ($sPos == ' ' || $sPos == "\r" || $sPos == "\n" || $sPos == "\t" || $sPos == "\x0B" || $sPos == "\0")
$str = mb_substr($str, 1, mb_strlen($str) - 1);
else
$bLoop = false;
}
$bLoop = true;
while ($bLoop == true)
{
$sPos = mb_substr($str, -1, 1);
if ($sPos == ' ' || $sPos == "\r" || $sPos == "\n" || $sPos == "\t" || $sPos == "\x0B" || $sPos == "\0")
$str = mb_substr($str, 0, mb_strlen($str) - 1);
else
$bLoop = false;
}
return $str;
}
//disconnect the databse
function db_disconnect()
{
global $dbpconnect, $dblink, $dblink_slave, $dbslaveid;
//is connected and no persistent connect used?
if (($dbpconnect == false) && ($dblink !== false))
{
@mysql_close($dblink);
$dblink = false;
}
if (($dbpconnect == false) && ($dblink_slave !== false))
{
@mysql_close($dblink_slave);
$dblink_slave = false;
$dbslaveid = -1;
}
}
//database handling
function db_connect()
{
global $dblink, $dbpconnect, $dbusername, $dbname, $dbserver, $dbpasswd, $dbpconnect;
//connect to the database by the given method - no php error reporting!
if ($dbpconnect == true)
{
$dblink = @mysql_pconnect($dbserver, $dbusername, $dbpasswd);
}
else
{
$dblink = @mysql_connect($dbserver, $dbusername, $dbpasswd);
}
if ($dblink != false)
{
mysql_query("SET NAMES 'utf8'", $dblink);
//database connection established ... set the used database
if (@mysql_select_db($dbname, $dblink) == false)
{
//error while setting the database ... disconnect
db_disconnect();
$dblink = false;
}
}
}
function db_slave_exclude()
{
global $usr;
if ($usr === false)
return;
sql("INSERT INTO `sys_repl_exclude` (`user_id`, `datExclude`) VALUES ('&1', NOW())
ON DUPLICATE KEY UPDATE `datExclude`=NOW()", $usr['userid']);
}
function db_connect_anyslave()
{
global $dblink, $dblink_slave, $opt, $usr, $dbslaveid;
if ($dblink_slave !== false)
return;
$nMaxTimeDiff = $opt['db']['slave']['max_behind'];
if ($usr !== false)
{
$nMaxTimeDiff = sqlValue("SELECT TIMESTAMP(NOW())-TIMESTAMP(`datExclude`) FROM `sys_repl_exclude` WHERE `user_id`='" . ($usr['userid']+0) . "'", $opt['db']['slave']['max_behind']);
if ($nMaxTimeDiff > $opt['db']['slave']['max_behind'])
$nMaxTimeDiff = $opt['db']['slave']['max_behind'];
}
$id = sqlValue("SELECT `id`, `weight`*RAND() AS `w` FROM `sys_repl_slaves` WHERE `active`=1 AND `online`=1 AND (TIMESTAMP(NOW())-TIMESTAMP(`last_check`)+`time_diff`<'" . ($nMaxTimeDiff+0) . "') ORDER BY `w` DESC LIMIT 1", -1);
if ($id == -1)
{
$dblink_slave = $dblink;
$dbslaveid = -1;
}
else
{
db_connect_slave($id);
}
}
function db_connect_primary_slave()
{
global $opt, $dblink, $dblink_slave, $dbslaveid;
if ($opt['db']['slave']['primary'] == -1)
{
$dblink_slave = $dblink;
$dbslaveid = -1;
}
else
db_connect_slave($opt['db']['slave']['primary']);
}
function db_connect_slave($id)
{
global $opt, $dblink_slave, $dbpconnect, $dbname, $dbslaveid;
// the right slave is connected
if ($dblink_slave !== false)
{
// TODO: disconnect if other slave is connected
return;
}
$slave = $opt['db']['slaves'][$id];
if ($dbpconnect == true)
$dblink_slave = @mysql_pconnect($slave['server'], $slave['username'], $slave['password']);
else
$dblink_slave = @mysql_connect($slave['server'], $slave['username'], $slave['password']);
if ($dblink_slave !== false)
{
$dbslaveid = $id;
if (mysql_select_db($dbname, $dblink_slave) == false)
sql_error();
mysql_query("SET NAMES 'utf8'", $dblink_slave);
}
else
sql_error();
}
?>
File diff suppressed because it is too large Load Diff
+44
View File
@@ -0,0 +1,44 @@
<?php
/***************************************************************************
./lib/consts.inc.php
-------------------
begin : Thu December 29 2005
copyright : (C) 2005 The OpenCaching Group
forum contact at : http://www.opencaching.com/phpBB2
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
/****************************************************************************
Unicode Reminder メモ
named consts
****************************************************************************/
// for cachelists
define('cachelist_type_ignore', 1);
define('cachelist_type_watch', 2);
define('cachelist_type_series', 3);
define('cachelist_type_user', 4);
define('cachelist_type_other', 5);
define('cachelist_nopermission', 0);
define('cachelist_owner', 1);
define('cachelist_mod', 2);
// for notifications
define('notify_new_cache', 1);
// for ratings
define('rating_percentage', 10); // percentage of found caches to be rated
?>
+84
View File
@@ -0,0 +1,84 @@
<?php
/***************************************************************************
* You can find the license in the docs directory
*
* 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;
}
}
?>
+137
View File
@@ -0,0 +1,137 @@
<?php
// Unicode Reminder メモ
define("CS2CS", "cs2cs");
function cs2cs_core($lat, $lon, $to) {
$descriptorspec = array(
0 => array("pipe", "r"), // stdin is a pipe that the child will read from
1 => array("pipe", "w"), // stdout is a pipe that the child will write to
2 => array("pipe", "w") // stderr is a pipe that the child will write to
);
if (mb_eregi('^[a-z0-9_ ,\+\-=]*$', $to) == 0) {
die("invalid arguments in command: " . $to ."\n");
}
$command = CS2CS . " +proj=latlong +datum=WGS84 +to " . $to;
$process = proc_open($command, $descriptorspec, $pipes);
if (is_resource($process)) {
fwrite($pipes[0], $lon . " " . $lat);
fclose($pipes[0]);
$stdout = stream_get_contents($pipes[1]);
fclose($pipes[1]);
$stderr = stream_get_contents($pipes[2]);
fclose($pipes[2]);
//
// $procstat = proc_get_status($process);
//
// neither proc_close nor proc_get_status return reasonable results with PHP5 and linux 2.6.11,
// see http://bugs.php.net/bug.php?id=32533
//
// as temporary (?) workaround, check stderr output.
// (Vinnie, 2006-02-09)
if ($stderr) {
die("proc_open() failed:<br>command='$command'<br>stderr='" . $stderr . "'");
}
proc_close($process);
return explode_multi(mb_trim($stdout), "\t\n ");
} else {
die("proc_open() failed, command=$command\n");
}
}
function cs2cs_utm($lat, $lon) {
// get UTM letter
if ( $lat <= 84.0 && $lat >= 72.0 )
$utmLetter = 'X';
else if ( $lat < 72.0 && $lat >= 64.0 )
$utmLetter = 'W';
else if ( $lat < 64.0 && $lat >= 56.0 )
$utmLetter = 'V';
else if ( $lat < 56.0 && $lat >= 48.0 )
$utmLetter = 'U';
else if ( $lat < 48.0 && $lat >= 40.0 )
$utmLetter = 'T';
else if ( $lat < 40.0 && $lat >= 32.0 )
$utmLetter = 'S';
else if ( $lat < 32.0 && $lat >= 24.0 )
$utmLetter = 'R';
else if ( $lat < 24.0 && $lat >= 16.0 )
$utmLetter = 'Q';
else if ( $lat < 16.0 && $lat >= 8.0 )
$utmLetter = 'P';
else if ( $lat < 8.0 && $lat >= 0.0 )
$utmLetter = 'N';
else if ( $lat < 0.0 && $lat >= -8.0 )
$utmLetter = 'M';
else if ( $lat < -8.0 && $lat >= -16.0 )
$utmLetter = 'L';
else if ( $lat < -16.0 && $lat >= -24.0 )
$utmLetter = 'K';
else if ( $lat < -24.0 && $lat >= -32.0 )
$utmLetter = 'J';
else if ( $lat < -32.0 && $lat >= -40.0 )
$utmLetter = 'H';
else if ( $lat < -40.0 && $lat >= -48.0 )
$utmLetter = 'G';
else if ( $lat < -48.0 && $lat >= -56.0 )
$utmLetter = 'F';
else if ( $lat < -56.0 && $lat >= -64.0 )
$utmLetter = 'E';
else if ( $lat < -64.0 && $lat >= -72.0 )
$utmLetter = 'D';
else if ( $lat < -72.0 && $lat >= -80.0 )
$utmLetter = 'C';
else
$utmLetter = 'Z'; //returns 'Z' if the lat is outside the UTM limits of 84N to 80S
$zone = (int) ( ( $lon + 180 ) / 6 ) + 1;
if ( $lat >= 56.0 && $lat < 64.0 && $lon >= 3.0 && $lon < 12.0 ) { $zone = 32; }
// Special zones for Svalbard.
if ($lat >= 72.0 && $lat < 84.0 )
{
if ( $lon >= 0.0 && $lon < 9.0 )
$zone = 31;
else if ( $lon >= 9.0 && $lon < 21.0 )
$zone = 33;
else if ( $lon >= 21.0 && $lon < 33.0 )
$zone = 35;
else if ( $lon >= 33.0 && $lon < 42.0 )
$zone = 37;
}
$cs2csresult = cs2cs_core($lat, $lon, "+proj=utm +datum=WGS84 +zone=$zone");
return array_merge(Array($zone, $utmLetter), $cs2csresult);
}
function cs2cs_gk($lat, $lon) {
$zone = round($lon/3);
$falseeasting = $zone * 1000000 + 500000;
$cs2csresult = cs2cs_core($lat, $lon, "+proj=tmerc +ellps=bessel +lat_0=0 +lon_0=".($zone*3)." +x_0=".$falseeasting." +towgs84=606,23,413 ");
return $cs2csresult;
}
?>
+73
View File
@@ -0,0 +1,73 @@
<?php
/***************************************************************************
./lib/eventhandler.inc.php
-------------------
begin : Mon June 28 2004
copyright : (C) 2004 The OpenCaching Group
forum contact at : http://www.opencaching.com/phpBB2
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
/****************************************************************************
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)
{
}
?>
+339
View File
@@ -0,0 +1,339 @@
<?php
/***************************************************************************
./lib/ftsearch.inc.php
--------------------
begin : January 10 2007
copyright : (C) 2007 The OpenCaching Group
forum contact at : http://develforum.opencaching.de
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
/****************************************************************************
Unicode Reminder メモ
functions for the full text search-engine
****************************************************************************/
/* begin conversion rules */
$ftsearch_simplerules[] = array('qu', 'k');
$ftsearch_simplerules[] = array('ts', 'z');
$ftsearch_simplerules[] = array('tz', 'z');
$ftsearch_simplerules[] = array('alp', 'alb');
$ftsearch_simplerules[] = array('y', 'i');
$ftsearch_simplerules[] = array('ai', 'ei');
$ftsearch_simplerules[] = array('ou', 'u');
$ftsearch_simplerules[] = array('th', 't');
$ftsearch_simplerules[] = array('ph', 'f');
$ftsearch_simplerules[] = array('oh', 'o');
$ftsearch_simplerules[] = array('ah', 'a');
$ftsearch_simplerules[] = array('eh', 'e');
$ftsearch_simplerules[] = array('aux', 'o');
$ftsearch_simplerules[] = array('eau', 'o');
$ftsearch_simplerules[] = array('eux', 'oe');
$ftsearch_simplerules[] = array('^ch', 'sch');
$ftsearch_simplerules[] = array('ck', 'k');
$ftsearch_simplerules[] = array('ie', 'i');
$ftsearch_simplerules[] = array('ih', 'i');
$ftsearch_simplerules[] = array('ent', 'end');
$ftsearch_simplerules[] = array('uh', 'u');
$ftsearch_simplerules[] = array('sh', 'sch');
$ftsearch_simplerules[] = array('ver', 'wer');
$ftsearch_simplerules[] = array('dt', 't');
$ftsearch_simplerules[] = array('hard', 'hart');
$ftsearch_simplerules[] = array('egg', 'ek');
$ftsearch_simplerules[] = array('eg', 'ek');
$ftsearch_simplerules[] = array('cr', 'kr');
$ftsearch_simplerules[] = array('ca', 'ka');
$ftsearch_simplerules[] = array('ce', 'ze');
$ftsearch_simplerules[] = array('x', 'ks');
$ftsearch_simplerules[] = array('ve', 'we');
$ftsearch_simplerules[] = array('va', 'wa');
/* end conversion rules */
function ftsearch_hash(&$str)
{
$astr = ftsearch_split($str, true);
foreach ($astr AS $k => $s)
{
if (strlen($s) > 2)
$astr[$k] = sprintf("%u", crc32($s));
else
unset($astr[$k]);
}
return $astr;
}
// str = long text
function ftsearch_split(&$str, $simple)
{
global $ftsearch_ignores;
// interpunktion
$str = mb_ereg_replace('\\?', ' ', $str);
$str = mb_ereg_replace('\\)', ' ', $str);
$str = mb_ereg_replace('\\(', ' ', $str);
$str = mb_ereg_replace('\\.', ' ', $str);
$str = mb_ereg_replace('´', ' ', $str);
$str = mb_ereg_replace('`', ' ', $str);
$str = mb_ereg_replace('\'', ' ', $str);
$str = mb_ereg_replace('/', ' ', $str);
$str = mb_ereg_replace(':', ' ', $str);
$str = mb_ereg_replace(',', ' ', $str);
$str = mb_ereg_replace("\r\n", ' ', $str);
$str = mb_ereg_replace("\n", ' ', $str);
$str = mb_ereg_replace("\r", ' ', $str);
$ostr = '';
while ($ostr != $str)
{
$ostr = $str;
$str = mb_ereg_replace(' ', ' ', $str);
}
$astr = mb_split(' ', $str);
$str = '';
ftsearch_load_ignores();
for ($i = count($astr) - 1; $i >= 0; $i--)
{
// ignore?
if (array_search(mb_strtolower($astr[$i]), $ftsearch_ignores) !== false)
unset($astr[$i]);
else
{
if ($simple)
$astr[$i] = ftsearch_text2simple($astr[$i]);
if ($astr[$i] == '')
unset($astr[$i]);
}
}
return $astr;
}
function ftsearch_load_ignores()
{
global $ftsearch_ignores;
global $ftsearch_ignores_loaded;
if ($ftsearch_ignores_loaded != true)
{
$ftsearch_ignores = array();
$rs = sql('SELECT `word` FROM `search_ignore`');
while ($r = sql_fetch_assoc($rs))
$ftsearch_ignores[] = $r['word'];
sql_free_result($rs);
$ftsearch_ignores_loaded = true;
}
}
// str = single word
function ftsearch_text2simple($str)
{
global $ftsearch_simplerules;
$str = ftsearch_text2sort($str);
// regeln anwenden
foreach ($ftsearch_simplerules AS $rule)
{
$str = mb_ereg_replace($rule[0], $rule[1], $str);
}
// doppelte chars ersetzen
for ($c = ord('a'); $c <= ord('z'); $c++)
{
$old_str = '';
while ($old_str != $str)
{
$old_str = $str;
$str = mb_ereg_replace(chr($c) . chr($c), chr($c), $str);
}
$old_str = '';
}
return $str;
}
// str = single word
function ftsearch_text2sort($str)
{
$str = mb_strtolower($str);
// deutsches
$str = mb_ereg_replace('ä', 'ae', $str);
$str = mb_ereg_replace('ö', 'oe', $str);
$str = mb_ereg_replace('ü', 'ue', $str);
$str = mb_ereg_replace('Ä', 'ae', $str);
$str = mb_ereg_replace('Ö', 'oe', $str);
$str = mb_ereg_replace('Ü', 'ue', $str);
$str = mb_ereg_replace('ß', 'ss', $str);
// akzente usw.
$str = mb_ereg_replace('à', 'a', $str);
$str = mb_ereg_replace('á', 'a', $str);
$str = mb_ereg_replace('â', 'a', $str);
$str = mb_ereg_replace('è', 'e', $str);
$str = mb_ereg_replace('é', 'e', $str);
$str = mb_ereg_replace('ë', 'e', $str);
$str = mb_ereg_replace('É', 'e', $str);
$str = mb_ereg_replace('ô', 'o', $str);
$str = mb_ereg_replace('ó', 'o', $str);
$str = mb_ereg_replace('ò', 'o', $str);
$str = mb_ereg_replace('ê', 'e', $str);
$str = mb_ereg_replace('ě', 'e', $str);
$str = mb_ereg_replace('û', 'u', $str);
$str = mb_ereg_replace('ç', 'c', $str);
$str = mb_ereg_replace('c', 'c', $str);
$str = mb_ereg_replace('ć', 'c', $str);
$str = mb_ereg_replace('î', 'i', $str);
$str = mb_ereg_replace('ï', 'i', $str);
$str = mb_ereg_replace('ì', 'i', $str);
$str = mb_ereg_replace('í', 'i', $str);
$str = mb_ereg_replace('ł', 'l', $str);
$str = mb_ereg_replace('š', 's', $str);
$str = mb_ereg_replace('Š', 's', $str);
$str = mb_ereg_replace('u', 'u', $str);
$str = mb_ereg_replace('ý', 'y', $str);
$str = mb_ereg_replace('ž', 'z', $str);
$str = mb_ereg_replace('Ž', 'Z', $str);
$str = mb_ereg_replace('Æ', 'ae', $str);
$str = mb_ereg_replace('æ', 'ae', $str);
$str = mb_ereg_replace('œ', 'oe', $str);
// sonstiges
$str = mb_ereg_replace('[^A-Za-z ]', '', $str);
return $str;
}
function ftsearch_refresh()
{
ftsearch_refresh_all_caches();
ftsearch_refresh_all_cache_desc();
ftsearch_refresh_all_pictures();
ftsearch_refresh_all_cache_logs();
}
function ftsearch_refresh_all_caches()
{
$rs = sql('SELECT `caches`.`cache_id` FROM `caches` LEFT JOIN `search_index_times` ON `caches`.`cache_id`=`search_index_times`.`object_id` AND 2=`search_index_times`.`object_type` WHERE `caches`.`status`!=5 AND ISNULL(`search_index_times`.`object_id`) UNION DISTINCT SELECT `caches`.`cache_id` FROM `caches` INNER JOIN `search_index_times` ON `search_index_times`.`object_type`=2 AND `caches`.`cache_id`=`search_index_times`.`object_id` WHERE `caches`.`last_modified`>`search_index_times`.`last_refresh` AND `caches`.`status`!=5');
while ($r = sql_fetch_assoc($rs))
ftsearch_refresh_cache($r['cache_id']);
sql_free_result($rs);
}
function ftsearch_refresh_cache($cache_id)
{
$rs = sql("SELECT `name`, `last_modified` FROM `caches` WHERE `cache_id`='&1'", $cache_id);
if ($r = sql_fetch_assoc($rs))
{
ftsearch_set_entries(2, $cache_id, $cache_id, $r['name'], $r['last_modified']);
}
sql_free_result($rs);
}
function ftsearch_refresh_all_cache_desc()
{
$rs = sql('SELECT `cache_desc`.`id` FROM `cache_desc` INNER JOIN `caches` ON `caches`.`cache_id`=`cache_desc`.`cache_id` LEFT JOIN `search_index_times` ON `cache_desc`.`id`=`search_index_times`.`object_id` AND 3=`search_index_times`.`object_type` WHERE `caches`.`status`!=5 AND ISNULL(`search_index_times`.`object_id`) UNION DISTINCT SELECT `cache_desc`.`id` FROM `cache_desc` INNER JOIN `caches` ON `caches`.`cache_id`=`cache_desc`.`cache_id` INNER JOIN `search_index_times` ON `search_index_times`.`object_type`=3 AND `cache_desc`.`id`=`search_index_times`.`object_id` WHERE `cache_desc`.`last_modified`>`search_index_times`.`last_refresh` AND `caches`.`status`!=5');
while ($r = sql_fetch_assoc($rs))
ftsearch_refresh_cache_desc($r['id']);
sql_free_result($rs);
}
function ftsearch_refresh_cache_desc($id)
{
$rs = sql("SELECT `cache_id`, `desc`, `last_modified` FROM `cache_desc` WHERE `id`='&1'", $id);
if ($r = sql_fetch_assoc($rs))
{
$r['desc'] = ftsearch_strip_html($r['desc']);
ftsearch_set_entries(3, $id, $r['cache_id'], $r['desc'], $r['last_modified']);
}
sql_free_result($rs);
}
function ftsearch_refresh_all_pictures()
{
$rs = sql('SELECT `pictures`.`id` FROM `pictures` LEFT JOIN `search_index_times` ON `pictures`.`id`=`search_index_times`.`object_id` AND 6=`search_index_times`.`object_type` WHERE ISNULL(`search_index_times`.`object_id`) UNION DISTINCT SELECT `pictures`.`id` FROM `pictures` INNER JOIN `search_index_times` ON `search_index_times`.`object_type`=6 AND `pictures`.`id`=`search_index_times`.`object_id` WHERE `pictures`.`last_modified`>`search_index_times`.`last_refresh`');
while ($r = sql_fetch_assoc($rs))
ftsearch_refresh_picture($r['id']);
sql_free_result($rs);
}
function ftsearch_refresh_picture($id)
{
$rs = sql("SELECT `caches`.`cache_id`, `pictures`.`title`, `pictures`.`last_modified` FROM `pictures` INNER JOIN `caches` ON `pictures`.`object_type`=2 AND `caches`.`cache_id`=`pictures`.`object_id` WHERE `pictures`.`id`='&1' UNION DISTINCT SELECT `cache_logs`.`cache_id` , `pictures`.`title`, `pictures`.`last_modified` FROM `pictures` INNER JOIN `cache_logs` ON `pictures`.`object_type`=1 AND `cache_logs`.`id`=`pictures`.`object_id` WHERE `pictures`.`id`='&1' LIMIT 1", $id);
if ($r = sql_fetch_assoc($rs))
{
ftsearch_set_entries(6, $id, $r['cache_id'], $r['title'], $r['last_modified']);
}
sql_free_result($rs);
}
function ftsearch_refresh_all_cache_logs()
{
$rs = sql('SELECT `cache_logs`.`id` FROM `cache_logs` LEFT JOIN `search_index_times` ON `cache_logs`.`id`=`search_index_times`.`object_id` AND 1=`search_index_times`.`object_type` WHERE ISNULL(`search_index_times`.`object_id`) UNION DISTINCT SELECT `cache_logs`.`id` FROM `cache_logs` INNER JOIN `search_index_times` ON `search_index_times`.`object_type`=1 AND `cache_logs`.`id`=`search_index_times`.`object_id` WHERE `cache_logs`.`last_modified`>`search_index_times`.`last_refresh`');
while ($r = sql_fetch_assoc($rs))
ftsearch_refresh_cache_logs($r['id']);
sql_free_result($rs);
}
function ftsearch_refresh_cache_logs($id)
{
$rs = sql("SELECT `cache_id`, `text`, `last_modified` FROM `cache_logs` WHERE `id`='&1'", $id);
if ($r = sql_fetch_assoc($rs))
{
$r['text'] = ftsearch_strip_html($r['text']);
ftsearch_set_entries(1, $id, $r['cache_id'], $r['text'], $r['last_modified']);
}
sql_free_result($rs);
}
function ftsearch_delete_entries($object_type, $object_id, $cache_id)
{
sql("DELETE FROM `search_index` WHERE `object_type`='&1' AND `cache_id`='&2'", $object_type, $cache_id);
sql("DELETE FROM `search_index_times` WHERE `object_type`='&1' AND `object_id`='&2'", $object_type, $object_id);
}
function ftsearch_set_entries($object_type, $object_id, $cache_id, &$text, $last_modified)
{
ftsearch_delete_entries($object_type, $object_id, $cache_id);
$ahash = ftsearch_hash($text);
foreach ($ahash AS $k => $h)
{
sql("INSERT INTO `search_index` (`object_type`, `cache_id`, `hash`, `count`) VALUES ('&1', '&2', '&3', '&4') ON DUPLICATE KEY UPDATE `count`=`count`+1", $object_type, $cache_id, $h, 1);
}
sql("INSERT INTO `search_index_times` (`object_id`, `object_type`, `last_refresh`) VALUES ('&1', '&2', '&3') ON DUPLICATE KEY UPDATE `last_refresh`='&3'", $object_id, $object_type, $last_modified);
}
function ftsearch_strip_html($text)
{
$text = str_replace("\n", ' ', $text);
$text = str_replace("\r", ' ', $text);
$text = str_replace('<br />', ' ', $text);
$text = str_replace('<br/>', ' ', $text);
$text = str_replace('<br>', ' ', $text);
$text = strip_tags($text);
$text = html_entity_decode($text, ENT_COMPAT, 'UTF-8');
return $text;
}
?>
+529
View File
@@ -0,0 +1,529 @@
<?php
/*
*------------------------------------------------------------
* BMP Image functions
*------------------------------------------------------------
* By JPEXS
*/
/*
*------------------------------------------------------------
* ImageBMP
*------------------------------------------------------------
* - Creates new BMP file
*
* Parameters: $img - Target image
* $file - Target file to store
* - if not specified, bmp is returned
*
* Returns: if $file specified - true if OK
if $file not specified - image data
*/
function imagebmp($img,$file="",$RLE=0)
{
$ColorCount=imagecolorstotal($img);
$Transparent=imagecolortransparent($img);
$IsTransparent=$Transparent!=-1;
if($IsTransparent) $ColorCount--;
if($ColorCount==0) {$ColorCount=0; $BitCount=24;};
if(($ColorCount>0)and($ColorCount<=2)) {$ColorCount=2; $BitCount=1;};
if(($ColorCount>2)and($ColorCount<=16)) { $ColorCount=16; $BitCount=4;};
if(($ColorCount>16)and($ColorCount<=256)) { $ColorCount=0; $BitCount=8;};
$Width=imagesx($img);
$Height=imagesy($img);
$Zbytek=(4-($Width/(8/$BitCount))%4)%4;
if($BitCount<24) $palsize=pow(2,$BitCount)*4;
$size=(floor($Width/(8/$BitCount))+$Zbytek)*$Height+54;
$size+=$palsize;
$offset=54+$palsize;
// Bitmap File Header
$ret = 'BM'; // header (2b)
$ret .= int_to_dword($size); // size of file (4b)
$ret .= int_to_dword(0); // reserved (4b)
$ret .= int_to_dword($offset); // byte location in the file which is first byte of IMAGE (4b)
// Bitmap Info Header
$ret .= int_to_dword(40); // Size of BITMAPINFOHEADER (4b)
$ret .= int_to_dword($Width); // width of bitmap (4b)
$ret .= int_to_dword($Height); // height of bitmap (4b)
$ret .= int_to_word(1); // biPlanes = 1 (2b)
$ret .= int_to_word($BitCount); // biBitCount = {1 (mono) or 4 (16 clr ) or 8 (256 clr) or 24 (16 Mil)} (2b)
$ret .= int_to_dword($RLE); // RLE COMPRESSION (4b)
$ret .= int_to_dword(0); // width x height (4b)
$ret .= int_to_dword(0); // biXPelsPerMeter (4b)
$ret .= int_to_dword(0); // biYPelsPerMeter (4b)
$ret .= int_to_dword(0); // Number of palettes used (4b)
$ret .= int_to_dword(0); // Number of important colour (4b)
// image data
$CC=$ColorCount;
$sl1=strlen($ret);
if($CC==0) $CC=256;
if($BitCount<24)
{
$ColorTotal=imagecolorstotal($img);
if($IsTransparent) $ColorTotal--;
for($p=0;$p<$ColorTotal;$p++)
{
$color=imagecolorsforindex($img,$p);
$ret.=inttobyte($color["blue"]);
$ret.=inttobyte($color["green"]);
$ret.=inttobyte($color["red"]);
$ret.=inttobyte(0); //RESERVED
};
$CT=$ColorTotal;
for($p=$ColorTotal;$p<$CC;$p++)
{
$ret.=inttobyte(0);
$ret.=inttobyte(0);
$ret.=inttobyte(0);
$ret.=inttobyte(0); //RESERVED
};
};
if($BitCount<=8)
{
for($y=$Height-1;$y>=0;$y--)
{
$bWrite="";
for($x=0;$x<$Width;$x++)
{
$color=imagecolorat($img,$x,$y);
$bWrite.=decbinx($color,$BitCount);
if(strlen($bWrite)==8)
{
$retd.=inttobyte(bindec($bWrite));
$bWrite="";
};
};
if((strlen($bWrite)<8)and(strlen($bWrite)!=0))
{
$sl=strlen($bWrite);
for($t=0;$t<8-$sl;$t++)
$sl.="0";
$retd.=inttobyte(bindec($bWrite));
};
for($z=0;$z<$Zbytek;$z++)
$retd.=inttobyte(0);
};
};
if(($RLE==1)and($BitCount==8))
{
for($t=0;$t<strlen($retd);$t+=4)
{
if($t!=0)
if(($t)%$Width==0)
$ret.=chr(0).chr(0);
if(($t+5)%$Width==0)
{
$ret.=chr(0).chr(5).substr($retd,$t,5).chr(0);
$t+=1;
}
if(($t+6)%$Width==0)
{
$ret.=chr(0).chr(6).substr($retd,$t,6);
$t+=2;
}
else
{
$ret.=chr(0).chr(4).substr($retd,$t,4);
};
};
$ret.=chr(0).chr(1);
}
else
{
$ret.=$retd;
};
if($BitCount==24)
{
for($z=0;$z<$Zbytek;$z++)
$Dopl.=chr(0);
for($y=$Height-1;$y>=0;$y--)
{
for($x=0;$x<$Width;$x++)
{
$color=imagecolorsforindex($img,ImageColorAt($img,$x,$y));
$ret.=chr($color["blue"]).chr($color["green"]).chr($color["red"]);
}
$ret.=$Dopl;
};
};
if($file!="")
{
$r=($f=fopen($file,"w"));
$r=$r and fwrite($f,$ret);
$r=$r and fclose($f);
return $r;
}
else
{
echo $ret;
};
};
/*
*------------------------------------------------------------
* ImageCreateFromBmp
*------------------------------------------------------------
* - Reads image from a BMP file
*
* Parameters: $file - Target file to load
*
* Returns: Image ID
*/
function imagecreatefrombmp($file)
{
global $CurrentBit, $echoMode;
$f=fopen($file,"r");
$Header=fread($f,2);
if($Header=="BM")
{
$Size=freaddword($f);
$Reserved1=freadword($f);
$Reserved2=freadword($f);
$FirstByteOfImage=freaddword($f);
$SizeBITMAPINFOHEADER=freaddword($f);
$Width=freaddword($f);
$Height=freaddword($f);
$biPlanes=freadword($f);
$biBitCount=freadword($f);
$RLECompression=freaddword($f);
$WidthxHeight=freaddword($f);
$biXPelsPerMeter=freaddword($f);
$biYPelsPerMeter=freaddword($f);
$NumberOfPalettesUsed=freaddword($f);
$NumberOfImportantColors=freaddword($f);
if($biBitCount<24)
{
$img=imagecreate($Width,$Height);
$Colors=pow(2,$biBitCount);
for($p=0;$p<$Colors;$p++)
{
$B=freadbyte($f);
$G=freadbyte($f);
$R=freadbyte($f);
$Reserved=freadbyte($f);
$Palette[]=imagecolorallocate($img,$R,$G,$B);
};
if($RLECompression==0)
{
$Zbytek=(4-ceil(($Width/(8/$biBitCount)))%4)%4;
for($y=$Height-1;$y>=0;$y--)
{
$CurrentBit=0;
for($x=0;$x<$Width;$x++)
{
$C=freadbits($f,$biBitCount);
imagesetpixel($img,$x,$y,$Palette[$C]);
};
if($CurrentBit!=0) {freadbyte($f);};
for($g=0;$g<$Zbytek;$g++)
freadbyte($f);
};
};
};
if($RLECompression==1) //$BI_RLE8
{
$y=$Height;
$pocetb=0;
while(true)
{
$y--;
$prefix=freadbyte($f);
$suffix=freadbyte($f);
$pocetb+=2;
$echoit=false;
if($echoit)echo "Prefix: $prefix Suffix: $suffix<BR>";
if(($prefix==0)and($suffix==1)) break;
if(feof($f)) break;
while(!(($prefix==0)and($suffix==0)))
{
if($prefix==0)
{
$pocet=$suffix;
$Data.=fread($f,$pocet);
$pocetb+=$pocet;
if($pocetb%2==1) {freadbyte($f); $pocetb++;};
};
if($prefix>0)
{
$pocet=$prefix;
for($r=0;$r<$pocet;$r++)
$Data.=chr($suffix);
};
$prefix=freadbyte($f);
$suffix=freadbyte($f);
$pocetb+=2;
if($echoit) echo "Prefix: $prefix Suffix: $suffix<BR>";
};
for($x=0;$x<strlen($Data);$x++)
{
imagesetpixel($img,$x,$y,$Palette[ord($Data[$x])]);
};
$Data="";
};
};
if($RLECompression==2) //$BI_RLE4
{
$y=$Height;
$pocetb=0;
/*while(!feof($f))
echo freadbyte($f)."_".freadbyte($f)."<BR>";*/
while(true)
{
//break;
$y--;
$prefix=freadbyte($f);
$suffix=freadbyte($f);
$pocetb+=2;
$echoit=false;
if($echoit)echo "Prefix: $prefix Suffix: $suffix<BR>";
if(($prefix==0)and($suffix==1)) break;
if(feof($f)) break;
while(!(($prefix==0)and($suffix==0)))
{
if($prefix==0)
{
$pocet=$suffix;
$CurrentBit=0;
for($h=0;$h<$pocet;$h++)
$Data.=chr(freadbits($f,4));
if($CurrentBit!=0) freadbits($f,4);
$pocetb+=ceil(($pocet/2));
if($pocetb%2==1) {freadbyte($f); $pocetb++;};
};
if($prefix>0)
{
$pocet=$prefix;
$i=0;
for($r=0;$r<$pocet;$r++)
{
if($i%2==0)
{
$Data.=chr($suffix%16);
}
else
{
$Data.=chr(floor($suffix/16));
};
$i++;
};
};
$prefix=freadbyte($f);
$suffix=freadbyte($f);
$pocetb+=2;
if($echoit) echo "Prefix: $prefix Suffix: $suffix<BR>";
};
for($x=0;$x<strlen($Data);$x++)
{
imagesetpixel($img,$x,$y,$Palette[ord($Data[$x])]);
};
$Data="";
};
};
if($biBitCount==24)
{
$img=imagecreatetruecolor($Width,$Height);
$Zbytek=$Width%4;
for($y=$Height-1;$y>=0;$y--)
{
for($x=0;$x<$Width;$x++)
{
$B=freadbyte($f);
$G=freadbyte($f);
$R=freadbyte($f);
$color=imagecolorexact($img,$R,$G,$B);
if($color==-1) $color=imagecolorallocate($img,$R,$G,$B);
imagesetpixel($img,$x,$y,$color);
}
for($z=0;$z<$Zbytek;$z++)
freadbyte($f);
};
};
return $img;
};
fclose($f);
};
/*
* Helping functions:
*-------------------------
*
* freadbyte($file) - reads 1 byte from $file
* freadword($file) - reads 2 bytes (1 word) from $file
* freaddword($file) - reads 4 bytes (1 dword) from $file
* freadlngint($file) - same as freaddword($file)
* decbin8($d) - returns binary string of d zero filled to 8
* RetBits($byte,$start,$len) - returns bits $start->$start+$len from $byte
* freadbits($file,$count) - reads next $count bits from $file
* RGBToHex($R,$G,$B) - convert $R, $G, $B to hex
* int_to_dword($n) - returns 4 byte representation of $n
* int_to_word($n) - returns 2 byte representation of $n
*/
function freadbyte($f)
{
return ord(fread($f,1));
};
function freadword($f)
{
$b1=freadbyte($f);
$b2=freadbyte($f);
return $b2*256+$b1;
};
function freadlngint($f)
{
return freaddword($f);
};
function freaddword($f)
{
$b1=freadword($f);
$b2=freadword($f);
return $b2*65536+$b1;
};
function RetBits($byte,$start,$len)
{
$bin=decbin8($byte);
$r=bindec(substr($bin,$start,$len));
return $r;
};
$CurrentBit=0;
function freadbits($f,$count)
{
global $CurrentBit,$SMode;
$Byte=freadbyte($f);
$LastCBit=$CurrentBit;
$CurrentBit+=$count;
if($CurrentBit==8)
{
$CurrentBit=0;
}
else
{
fseek($f,ftell($f)-1);
};
return RetBits($Byte,$LastCBit,$count);
};
function RGBToHex($Red,$Green,$Blue)
{
$hRed=dechex($Red);if(strlen($hRed)==1) $hRed="0$hRed";
$hGreen=dechex($Green);if(strlen($hGreen)==1) $hGreen="0$hGreen";
$hBlue=dechex($Blue);if(strlen($hBlue)==1) $hBlue="0$hBlue";
return($hRed.$hGreen.$hBlue);
};
function int_to_dword($n)
{
return chr($n & 255).chr(($n >> 8) & 255).chr(($n >> 16) & 255).chr(($n >> 24) & 255);
}
function int_to_word($n)
{
return chr($n & 255).chr(($n >> 8) & 255);
}
function decbin8($d)
{
return decbinx($d,8);
};
function decbinx($d,$n)
{
$bin=decbin($d);
$sbin=strlen($bin);
for($j=0;$j<$n-$sbin;$j++)
$bin="0$bin";
return $bin;
};
function inttobyte($n)
{
return chr($n);
};
?>
View File
+232
View File
@@ -0,0 +1,232 @@
<?php
/***************************************************************************
* You can find the license in the docs directory
*
* Unicode Reminder メモ
*
* This class provides access to the login user data. Informations are
* stored in a cookie. Authentication has 2 levels unverified and verified.
*
* Unverified means: In the cookie is a userid and username provided, but
* the system didn't checked if that information is valid.
* This is good enough, if the login information is only
* used to display e.g. the loginbox. There is no
* security-hole if someone cheats the cookie.
*
* Verified means: In the cookie is a userid and username provided and
* the system checkd the information. A valid login-
* session exists. You have to verify the login-session
* when you read personal informations or write
* logentries, caches etc. to the database.
*
* Methods:
* verify() validate the login-session
* try_login() try to login with the given user/password
* logout() logout the user
*
* Properties:
* userid Integer 0 if no login, userid otherwise
* username String username or ''
*
***************************************************************************/
define('LOGIN_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
// login times in seconds
define('LOGIN_TIME', 60*60);
define('LOGIN_TIME_PERMANENT', 90*24*60*60);
$login = new login();
class login
{
var $userid = 0;
var $username = '';
var $lastlogin = 0;
var $permanent = false;
var $sessionid = '';
var $verified = false;
var $admin = false;
function login()
{
global $cookie;
if ($cookie->is_set('userid') && $cookie->is_set('username'))
{
$this->userid = $cookie->get('userid')+0;
$this->username = $cookie->get('username');
$this->permanent = (($cookie->get('permanent')+0) == 1);
$this->lastlogin = $cookie->get('lastlogin');
$this->sessionid = $cookie->get('sessionid');
$this->admin = (($cookie->get('admin')+0) == 1);
$this->verified = false;
// wenn lastlogin zu 50% abgelaufen, verify()
// permanent = 90 Tage, sonst 60 Minuten
if ((($this->permanent == true) && (strtotime($this->lastlogin) + LOGIN_TIME/2 < time())) ||
(($this->permanent == false) && (strtotime($this->lastlogin) + LOGIN_TIME_PERMANENT/2 < time())))
$this->verify();
if ($this->admin != false)
$this->verify();
}
else
$this->pClear();
}
function pClear()
{
// set to no valid login
$this->userid = 0;
$this->username = '';
$this->permanent = false;
$this->lastlogin = '';
$this->sessionid = '';
$this->admin = false;
$this->verified = true;
$this->pStoreCookie();
}
function pStoreCookie()
{
global $cookie;
$cookie->set('userid', $this->userid);
$cookie->set('username', $this->username);
$cookie->set('permanent', ($this->permanent==true ? 1 : 0));
$cookie->set('lastlogin', $this->lastlogin);
$cookie->set('sessionid', $this->sessionid);
$cookie->set('admin', ($this->admin==true ? 1 : 0));
}
function verify()
{
if ($this->verified == true)
return;
if ($this->userid == 0)
{
$this->pClear();
return;
}
$min_lastlogin = date('Y-m-d H:i:s', time() - LOGIN_TIME);
$min_lastlogin_permanent = date('Y-m-d H:i:s', time() - LOGIN_TIME_PERMANENT);
$rs = sql("SELECT `sys_sessions`.`last_login`, `user`.`admin` FROM &db.`sys_sessions`, &db.`user` WHERE `sys_sessions`.`user_id`=`user`.`user_id` AND `user`.`is_active_flag`=1 AND `sys_sessions`.`uuid`='&1' AND `sys_sessions`.`user_id`='&2' AND ((`sys_sessions`.`permanent`=1 AND `sys_sessions`.`last_login`>'&3') OR (`sys_sessions`.`permanent`=0 AND `sys_sessions`.`last_login`>'&4'))", $this->sessionid, $this->userid, $min_lastlogin_permanent, $min_lastlogin);
if ($rUser = sql_fetch_assoc($rs))
{
if ((($this->permanent == true) && (strtotime($rUser['last_login']) + LOGIN_TIME/2 < time())) ||
(($this->permanent == false) && (strtotime($rUser['last_login']) + LOGIN_TIME_PERMANENT/2 < time())))
{
sql("UPDATE `sys_sessions` SET `sys_sessions`.`last_login`=NOW() WHERE `sys_sessions`.`uuid`='&1' AND `sys_sessions`.`user_id`='&2'", $this->sessionid, $this->userid);
$rUser['last_login'] = date('Y-m-d H:i:s');
}
// user.last_login is used for statics, so we keep it up2date
sql("UPDATE `user` SET `user`.`last_login`=NOW() WHERE `user`.`user_id`='&1'", $this->userid);
$this->lastlogin = $rUser['last_login'];
$this->admin = ($rUser['admin'] == 1);
$this->verified = true;
}
else
{
// prevent bruteforce
sql("INSERT INTO `sys_logins` (`remote_addr`, `success`) VALUES ('&1', 0)", $_SERVER['REMOTE_ADDR']);
$this->pClear();
}
sql_free_result($rs);
$this->pStoreCookie();
return;
}
function try_login($user, $password, $permanent)
{
global $opt;
$this->pClear();
// check the number of logins in the last hour ...
sql("DELETE FROM `sys_logins` WHERE `timestamp`<'&1'", date('Y-m-d H:i:s', time() - 3600));
$logins_count = sqlValue("SELECT COUNT(*) `count` FROM `sys_logins` WHERE `remote_addr`='" . sql_escape($_SERVER['REMOTE_ADDR']) . "'", 0);
if ($logins_count > 24)
return LOGIN_TOOMUCHLOGINS;
// delete old sessions
$min_lastlogin_permanent = date('Y-m-d H:i:s', time() - LOGIN_TIME_PERMANENT);
sql("DELETE FROM `sys_sessions` WHERE `last_login`<'&1'", $min_lastlogin_permanent);
$pwmd5 = md5($password);
if ($opt['login']['hash'])
$pwmd5 = hash('sha512', $pwmd5);
// compare $user with email and username, if both matches use email
$rsUser = sql("SELECT `user_id`, `username`, 2 AS `prio`, `is_active_flag`, `permanent_login_flag`, `admin` FROM `user` WHERE `username`='&1' AND `password`='&2' UNION
SELECT `user_id`, `username`, 1 AS `prio`, `is_active_flag`, `permanent_login_flag`, `admin` FROM `user` WHERE `email`='&1' AND `password`='&2' ORDER BY `prio` ASC LIMIT 1", $user, $pwmd5);
$rUser = sql_fetch_assoc($rsUser);
sql_free_result($rsUser);
if ($permanent == null)
$permanent = ($rUser['permanent_login_flag'] == 1);
if ($rUser)
{
// ok, there is a valid login
if ($rUser['is_active_flag'] != 0)
{
// begin session
$uuid = sqlValue('SELECT UUID()', '');
sql("INSERT INTO `sys_sessions` (`uuid`, `user_id`, `permanent`, `last_login`) VALUES ('&1', '&2', '&3', NOW())", $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'] == 1);
$this->verified = true;
$retval = LOGIN_OK;
}
else
$retval = LOGIN_USERNOTACTIVE;
}
else
{
// sorry, bad login
$retval = LOGIN_BADUSERPW;
}
sql("INSERT INTO `sys_logins` (`remote_addr`, `success`, `timestamp`) VALUES ('&1', '&2', NOW())", $_SERVER['REMOTE_ADDR'], ($rUser===false ? 0 : 1));
// store to cookie
$this->pStoreCookie();
return $retval;
}
function logout()
{
sql("DELETE FROM `sys_sessions` WHERE `uuid`='&1' AND `user_id`='&2'", $this->sessionid, $this->userid);
$this->pClear();
}
public function hasAdminPriv($privilege = false)
{
global $cookie;
$this->verify();
if ($privilege === false)
return $this->admin != 0;
return ($this->admin & $privilege) == $privilege;
}
}
?>
View File
+271
View File
@@ -0,0 +1,271 @@
<?PHP
/** SS_ZIP class is designed to work with ZIP archives
@author Yuriy Horobey, smiledsoft.com
@email info@smiledsoft.com
*/
class ss_zip{
/** 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);
}
}
/** debug helper.
the only job for this function is take parameter $v and ouput it with print_r() preceding with < xmp > etc
The $l is a label like l=myvar
*/
function dbg($v,$l='var'){echo"<xmp>$l=";print_r($v);echo"</xmp>";}
?>
+338
View File
@@ -0,0 +1,338 @@
<?php
/***************************************************************************
./lib/search.gpx.inc.php
-------------------
begin : November 1 2005
copyright : (C) 2005 The OpenCaching Group
forum contact at : http://www.opencaching.com/phpBB2
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
/****************************************************************************
Unicode Reminder メモ
GPX search output
****************************************************************************/
global $content, $bUseZip, $sqldebug;
$gpxHead =
'<?xml version="1.0" encoding="utf-8"?>
<gpx xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd"
xmlns="http://www.topografix.com/GPX/1/0"
version="1.0"
creator="www.opencaching.de">
<desc>Geocache</desc>
<author>www.opencaching.de</author>
<url>http://www.opencaching.de</url>
<urlname>www.opencaching.de</urlname>
<time>{time}</time>
';
$gpxLine =
'
<wpt lat="{lat}" lon="{lon}">
<time>{time}</time>
<name>{waypoint}</name>
<desc>{cachename}</desc>
<src>www.opencaching.de</src>
<url>http://www.opencaching.de/viewcache.php?cacheid={cacheid}</url>
<urlname>{cachename}</urlname>
<sym>Geocache</sym>
<type>Geocache|{type}</type>
</wpt>
';
$gpxFoot = '</gpx>';
$gpxTimeFormat = 'Y-m-d\TH:i:s\Z';
$gpxStatus[0] = 'Unavailable'; // andere
$gpxStatus[1] = 'Available';
$gpxStatus[2] = 'Unavailable';
$gpxStatus[3] = 'Archived';
$gpxContainer[0] = 'Other';
$gpxContainer[2] = 'Micro';
$gpxContainer[3] = 'Small';
$gpxContainer[4] = 'Regular';
$gpxContainer[5] = 'Large';
$gpxContainer[6] = 'Large';
$gpxContainer[7] = 'Virtual';
// known by gpx
$gpxType[0] = 'Unknown Cache';
$gpxType[2] = 'Traditional Cache';
$gpxType[3] = 'Multi-cache';
$gpxType[4] = 'Virtual Cache';
$gpxType[5] = 'Webcam Cache';
$gpxType[6] = 'Event Cache';
// unknown ... converted
$gpxType[7] = 'Unknown Cache';
$gpxType[8] = 'Unknown Cache';
$gpxType[10] = 'Traditional Cache';
//prepare the output
$caches_per_page = 20;
$sql = 'SELECT ';
if (isset($lat_rad) && isset($lon_rad))
{
$sql .= getSqlDistanceFormula($lon_rad * 180 / 3.14159, $lat_rad * 180 / 3.14159, 0, $multiplier[$distance_unit]) . ' `distance`, ';
}
else
{
if ($usr === false)
{
$sql .= '0 distance, ';
}
else
{
//get the users home coords
$rs_coords = sql_slave("SELECT `latitude`, `longitude` FROM `user` WHERE `user_id`='&1'", $usr['userid']);
$record_coords = sql_fetch_array($rs_coords);
if ((($record_coords['latitude'] == NULL) || ($record_coords['longitude'] == NULL)) || (($record_coords['latitude'] == 0) || ($record_coords['longitude'] == 0)))
{
$sql .= '0 distance, ';
}
else
{
//TODO: load from the users-profile
$distance_unit = 'km';
$lon_rad = $record_coords['longitude'] * 3.14159 / 180;
$lat_rad = $record_coords['latitude'] * 3.14159 / 180;
$sql .= getSqlDistanceFormula($record_coords['longitude'], $record_coords['latitude'], 0, $multiplier[$distance_unit]) . ' `distance`, ';
}
mysql_free_result($rs_coords);
}
}
$sAddJoin = '';
$sAddGroupBy = '';
$sAddField = '';
$sGroupBy = '';
if ($options['sort'] == 'bylastlog')
{
$sAddField = ', MAX(`cache_logs`.`date`) AS `lastLog`';
$sAddJoin = ' LEFT JOIN `cache_logs` ON `caches`.`cache_id`=`cache_logs`.`cache_id`';
$sGroupBy = ' GROUP BY `cache_logs`.`cache_id`';
}
$sql .= '`caches`.`cache_id` `cache_id`, `caches`.`status` `status`, `caches`.`type` `type`, `caches`.`size` `size`, `caches`.`longitude` `longitude`, `caches`.`latitude` `latitude`, `caches`.`user_id` `user_id`,
IF(IFNULL(`stat_caches`.`toprating`,0)>3, 4, IFNULL(`stat_caches`.`toprating`, 0)) `ratingvalue`,
`cache_location`.`adm2` `state`' .
$sAddField
. ' FROM `caches`
LEFT JOIN `stat_caches` ON `caches`.`cache_id`=`stat_caches`.`cache_id`
LEFT JOIN `cache_location` ON `caches`.`cache_id`=`cache_location`.`cache_id`' .
$sAddJoin
. ' WHERE `caches`.`cache_id` IN (' . $sqlFilter . ')' .
$sGroupBy;
$sortby = $options['sort'];
$sql .= ' ORDER BY ';
if ($options['orderRatingFirst'])
$sql .= '`ratingvalue` DESC, ';
if ($sortby == 'bylastlog')
{
$sql .= '`lastLog` DESC, ';
$sortby = 'bydistance';
}
if (isset($lat_rad) && isset($lon_rad) && ($sortby == 'bydistance'))
{
$sql .= '`distance` ASC';
}
else if ($sortby == 'bycreated')
{
$sql .= '`caches`.`date_created` DESC';
}
else // by name
{
$sql .= '`caches`.`name` ASC';
}
//startat?
$startat = isset($_REQUEST['startat']) ? $_REQUEST['startat'] : 0;
if (!is_numeric($startat)) $startat = 0;
if (isset($_REQUEST['count']))
$count = $_REQUEST['count'];
else
$count = $caches_per_page;
if ($count == 'max') $count = 500;
if (!is_numeric($count)) $count = 0;
if ($count < 1) $count = 1;
if ($count > 500) $count = 500;
$sqlLimit = ' LIMIT ' . $startat . ', ' . $count;
// temporäre tabelle erstellen
sql_slave('CREATE TEMPORARY TABLE `gpxcontent` ' . $sql . $sqlLimit);
$rsCount = sql_slave('SELECT COUNT(*) `count` FROM `gpxcontent`');
$rCount = sql_fetch_array($rsCount);
mysql_free_result($rsCount);
if ($rCount['count'] == 1)
{
$rsName = sql_slave('SELECT `caches`.`wp_oc` `wp_oc` FROM `gpxcontent`, `caches` WHERE `gpxcontent`.`cache_id`=`caches`.`cache_id` LIMIT 1');
$rName = sql_fetch_array($rsName);
mysql_free_result($rsName);
$sFilebasename = $rName['wp_oc'];
}
else
$sFilebasename = 'ocde' . $options['queryid'];
$bUseZip = ($rCount['count'] > 20);
$bUseZip = $bUseZip || (isset($_REQUEST['zip']) && ($_REQUEST['zip'] == '1'));
if ($bUseZip == true)
{
$content = '';
require_once($rootpath . 'lib/phpzip/ss_zip.class.php');
$phpzip = new ss_zip('',6);
}
// ok, ausgabe starten
if ($sqldebug == false)
{
if ($bUseZip == true)
{
header("content-type: application/zip");
header('Content-Disposition: attachment; filename=' . $sFilebasename . '.zip');
}
else
{
header("Content-type: application/gpx");
header("Content-Disposition: attachment; filename=" . $sFilebasename . ".gpx");
}
}
$gpxHead = mb_ereg_replace('{time}', date($gpxTimeFormat, time()), $gpxHead);
append_output($gpxHead);
// ok, ausgabe ...
$rs = sql_slave('SELECT SQL_BUFFER_RESULT `gpxcontent`.`cache_id` `cacheid`, `gpxcontent`.`longitude` `longitude`, `gpxcontent`.`latitude` `latitude`, `gpxcontent`.`state` `state`, `caches`.`wp_oc` `waypoint`, `caches`.`date_hidden` `date_hidden`, `caches`.`name` `name`, `caches`.`country` `country`, `caches`.`terrain` `terrain`, `caches`.`difficulty` `difficulty`, `caches`.`desc_languages` `desc_languages`, `caches`.`size` `size`, `caches`.`type` `type`, `caches`.`status` `status`, `user`.`username` `username`, `caches`.`user_id` `userid`, `cache_desc`.`desc` `desc`, `cache_desc`.`short_desc` `short_desc`, `cache_desc`.`hint` `hint` FROM `gpxcontent`, `caches`, `user`, `cache_desc` WHERE `gpxcontent`.`cache_id`=`caches`.`cache_id` AND `caches`.`cache_id`=`cache_desc`.`cache_id` AND `caches`.`default_desclang`=`cache_desc`.`language` AND `gpxcontent`.`user_id`=`user`.`user_id`');
while($r = sql_fetch_array($rs))
{
$thisline = $gpxLine;
$lat = sprintf('%01.5f', $r['latitude']);
$thisline = mb_ereg_replace('{lat}', $lat, $thisline);
$lon = sprintf('%01.5f', $r['longitude']);
$thisline = mb_ereg_replace('{lon}', $lon, $thisline);
$time = date($gpxTimeFormat, strtotime($r['date_hidden']));
$thisline = mb_ereg_replace('{time}', $time, $thisline);
$thisline = mb_ereg_replace('{waypoint}', $r['waypoint'], $thisline);
$thisline = mb_ereg_replace('{cacheid}', $r['cacheid'], $thisline);
$thisline = mb_ereg_replace('{cachename}', xmlentities($r['name']), $thisline);
$thisline = mb_ereg_replace('{country}', $r['country'], $thisline);
$thisline = mb_ereg_replace('{state}', xmlentities($r['state']), $thisline);
if ($r['hint'] == '')
$thisline = mb_ereg_replace('{hints}', '', $thisline);
else
$thisline = mb_ereg_replace('{hints}', '<encoded_hints>' . xmlentities(strip_tags($r['hint'])) . '</encoded_hints>', $thisline);
$thisline = mb_ereg_replace('{shortdesc}', xmlentities($r['short_desc']), $thisline);
$thisline = mb_ereg_replace('{desc}', xmlentities($r['desc']), $thisline);
if (isset($gpxType[$r['type']]))
$thisline = mb_ereg_replace('{type}', $gpxType[$r['type']], $thisline);
else
$thisline = mb_ereg_replace('{type}', $gpxType[0], $thisline);
if (isset($gpxContainer[$r['size']]))
$thisline = mb_ereg_replace('{container}', $gpxContainer[$r['size']], $thisline);
else
$thisline = mb_ereg_replace('{container}', $gpxContainer[0], $thisline);
if (isset($gpxStatus[$r['status']]))
$thisline = mb_ereg_replace('{status}', $gpxStatus[$r['status']], $thisline);
else
$thisline = mb_ereg_replace('{status}', $gpxStatus[0], $thisline);
$sDiffDecimals = '';
if ($r['difficulty'] % 2) $sDiffDecimals = '.5';
$r['difficulty'] -= $r['difficulty'] % 2;
$thisline = mb_ereg_replace('{difficulty}', ($r['difficulty']/2) . $sDiffDecimals, $thisline);
$sTerrDecimals = '';
if ($r['terrain'] % 2) $sTerrDecimals = '.5';
$r['terrain'] -= $r['terrain'] % 2;
$thisline = mb_ereg_replace('{terrain}', ($r['terrain']/2) . $sTerrDecimals, $thisline);
$thisline = mb_ereg_replace('{owner}', xmlentities($r['username']), $thisline);
$thisline = mb_ereg_replace('{userid}', xmlentities($r['userid']), $thisline);
append_output($thisline);
}
mysql_free_result($rs);
append_output($gpxFoot);
if ($sqldebug == true) sqldbg_end();
// phpzip versenden
if ($bUseZip == true)
{
$phpzip->add_data($sFilebasename . '.gpx', $content);
echo $phpzip->save($sFilebasename . '.zip', 'b');
}
exit;
function xmlentities($str)
{
$from[0] = '&'; $to[0] = '&amp;';
$from[1] = '<'; $to[1] = '&lt;';
$from[2] = '>'; $to[2] = '&gt;';
$from[3] = '"'; $to[3] = '&quot;';
$from[4] = '\''; $to[4] = '&apos;';
$from[5] = ']]>'; $to[5] = ']] >';
for ($i = 0; $i <= 4; $i++)
$str = mb_ereg_replace($from[$i], $to[$i], $str);
return filterevilchars($str);
}
function filterevilchars($str)
{
return mb_ereg_replace('[\\x00-\\x09|\\x0B-\\x0C|\\x0E-\\x1F]', '', $str);
}
function append_output($str)
{
global $content, $bUseZip, $sqldebug;
if ($sqldebug == true) return;
if ($bUseZip == true)
$content .= $str;
else
echo $str;
}
?>
+589
View File
@@ -0,0 +1,589 @@
<?php
/****************************************************************************
Unicode Reminder メモ
GPX search output (GC compatible)
****************************************************************************/
global $content, $bUseZip, $sqldebug;
$gpxHead =
'<?xml version="1.0" encoding="utf-8"?>
<gpx xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="1.0" creator="Opencaching.de - http://www.opencaching.de" xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd http://www.groundspeak.com/cache/1/0/1 http://www.groundspeak.com/cache/1/0/1/cache.xsd" xmlns="http://www.topografix.com/GPX/1/0">
<name>Cache Listing Generated from Opencaching.de</name>
<desc>This is a waypoint file generated from Opencaching.de</desc>
<author>Opencaching.de</author>
<email>info@opencaching.de</email>
<url>http://www.opencaching.de</url>
<urlname>Geocaching in Deutschland, Oesterreich und der Schweiz</urlname>
<time>{time}</time>
<keywords>cache, geocache, opencaching, waypoint, opencachingnetwork</keywords>';
$gpxLine =
' <wpt lat="{lat}" lon="{lon}">
<time>{time}</time>
<name>{waypoint}</name>
<desc>{cachename}</desc>
<src>www.opencaching.de</src>
<url>http://www.opencaching.de/viewcache.php?cacheid={cacheid}</url>
<urlname>{cachename}</urlname>
<sym>{sym}</sym>
<type>Geocache|{type}</type>
<groundspeak:cache id="{cacheid}" {status} xmlns:groundspeak="http://www.groundspeak.com/cache/1/0">
<groundspeak:name>{cachename}</groundspeak:name>
<groundspeak:placed_by>{owner}</groundspeak:placed_by>
<groundspeak:owner id="{userid}">{owner}</groundspeak:owner>
<groundspeak:type>{type}</groundspeak:type>
<groundspeak:container>{container}</groundspeak:container>
<groundspeak:attributes>
{attributes} </groundspeak:attributes>
<groundspeak:difficulty>{difficulty}</groundspeak:difficulty>
<groundspeak:terrain>{terrain}</groundspeak:terrain>
<groundspeak:country>{country}</groundspeak:country>
<groundspeak:state>{state}</groundspeak:state>
<groundspeak:short_description html="True">{shortdesc}</groundspeak:short_description>
<groundspeak:long_description html="True">{desc}</groundspeak:long_description>
{hints}
<groundspeak:logs>
{logs} </groundspeak:logs>
<groundspeak:travelbugs>
{geokrety} </groundspeak:travelbugs>
</groundspeak:cache>
</wpt>
';
$gpxAttributes = ' <groundspeak:attribute id="{attrib_id}" inc="1">{attrib_name}</groundspeak:attribute>';
$gpxLog = ' <groundspeak:log id="{id}">
<groundspeak:date>{date}</groundspeak:date>
<groundspeak:type>{type}</groundspeak:type>
<groundspeak:finder id="{userid}">{username}</groundspeak:finder>
<groundspeak:text encoded="False">{text}</groundspeak:text>
</groundspeak:log>';
$gpxGeokrety = ' <groundspeak:travelbug id="{gkid}" ref="{gkref}">
<groundspeak:name>{gkname}</groundspeak:name>
</groundspeak:travelbug>';
$gpxFoot = '</gpx>';
$gpxTimeFormat = 'Y-m-d\TH:i:s\Z';
$gpxStatus[0] = 'available="False" archived="False"'; // other (unavailable, not archived)
$gpxStatus[1] = 'available="True" archived="False"'; //available, not archived
$gpxStatus[2] = 'available="False" archived="False"'; //unavailable, not archived
$gpxStatus[3] = 'available="False" archived="True"'; //unavailable, archived
$gpxStatus[6] = 'available="False" archived="True"'; //locked, visible
$gpxContainer[0] = 'Other';
$gpxContainer[2] = 'Micro';
$gpxContainer[3] = 'Small';
$gpxContainer[4] = 'Regular';
$gpxContainer[5] = 'Large';
$gpxContainer[6] = 'Large';
$gpxContainer[7] = 'Virtual';
// known by gpx
$gpxType[0] = 'Unknown Cache';
$gpxType[2] = 'Traditional Cache';
$gpxType[3] = 'Multi-cache';
$gpxType[4] = 'Virtual Cache';
$gpxType[5] = 'Webcam Cache';
$gpxType[6] = 'Event Cache';
// unknown ... converted
$gpxType[7] = 'Unknown Cache';
$gpxType[8] = 'Unknown Cache';
$gpxType[10] = 'Traditional Cache';
$gpxLogType[0] = 'Other';
$gpxLogType[1] = 'Found it';
$gpxLogType[2] = 'Didn\'t find it';
$gpxLogType[3] = 'Write note';
$gpxLogType[7] = 'Attended';
$gpxLogType[8] = 'Will attend';
$gpxSymNormal = 'Geocache';
$gpxSymFound = 'Geocache Found';
// 1st set of attributes - attributes that correlate to GC attributes
// conditions
$gpxAttribID[59] = '6';
$gpxAttribName[59] = 'Recommended for kids';
$gpxAttribID[28] = '10';
$gpxAttribName[28] = 'Difficult climbing';
$gpxAttribID[26] = '11';
$gpxAttribName[26] = 'May require wading';
$gpxAttribID[29] = '12';
$gpxAttribName[29] = 'May require swimming';
$gpxAttribID[38] = '13';
$gpxAttribName[38] = 'Available at all times';
$gpxAttribID[1] = '14';
$gpxAttribName[1] = 'Recommended at night';
$gpxAttribID[44] = '15';
$gpxAttribName[44] = 'Available during winter';
$gpxAttribID[55] = '47';
$gpxAttribName[55] = 'Field puzzle';
$gpxAttribID[24] = '53';
$gpxAttribName[24] = 'Park and grab';
// facilities
$gpxAttribID[18] = '25';
$gpxAttribName[18] = 'Parking available';
$gpxAttribID[19] = '26';
$gpxAttribName[19] = 'Public transportation';
$gpxAttribID[20] = '27';
$gpxAttribName[20] = 'Drinking water nearby';
$gpxAttribID[21] = '28';
$gpxAttribName[21] = 'Public restrooms nearby';
$gpxAttribID[22] = '29';
$gpxAttribName[22] = 'Telephone nearby';
// hazards
$gpxAttribID[11] = '21';
$gpxAttribName[11] = 'Cliff / falling rocks';
$gpxAttribID[12] = '12';
$gpxAttribName[12] = 'Hunting';
$gpxAttribID[9] = '23';
$gpxAttribName[9] = 'Dangerous area';
$gpxAttribID[16] = '17';
$gpxAttribName[16] = 'Poisonous plants';
$gpxAttribID[13] = '39';
$gpxAttribName[13] = 'Thorns';
$gpxAttribID[17] = '18';
$gpxAttribName[17] = 'Dangerous animals';
$gpxAttribID[14] = '19';
$gpxAttribName[14] = 'Ticks';
$gpxAttribID[15] = '20';
$gpxAttribName[15] = 'Abandoned mines';
// equipment
$gpxAttribID[36] = '2';
$gpxAttribName[36] = 'Access or parking fee';
$gpxAttribID[49] = '3';
$gpxAttribName[49] = 'Climbing gear';
$gpxAttribID[48] = '44';
$gpxAttribName[48] = 'Flashlight required';
$gpxAttribID[52] = '4';
$gpxAttribName[52] = 'Boat';
$gpxAttribID[51] = '5';
$gpxAttribName[51] = 'Scuba gear';
$gpxAttribID[46] = '51';
$gpxAttribName[46] = 'Special tool required';
// 2nd set of attributes - OC only attributes, changed ID (+100) to be save in oc-gc-mixed environments
$gpxAttribID[6] = '106';
$gpxAttribName[6] = 'Only loggable at Opencaching';
$gpxAttribID[7] = '107';
$gpxAttribName[7] = 'Hyperlink to another caching portal only';
$gpxAttribID[8] = '108';
$gpxAttribName[8] = 'Letterbox (needs stamp)';
$gpxAttribID[10] = '110';
$gpxAttribName[10] = 'Active railway nearby';
$gpxAttribID[23] = '123';
$gpxAttribName[23] = 'First aid available';
$gpxAttribID[25] = '125';
$gpxAttribName[25] = 'Long walk';
$gpxAttribID[27] = '127';
$gpxAttribName[27] = 'Hilly area';
$gpxAttribID[30] = '130';
$gpxAttribName[30] = 'Point of interest';
$gpxAttribID[31] = '131';
$gpxAttribName[31] = 'Moving target';
$gpxAttribID[32] = '132';
$gpxAttribName[32] = 'Webcam';
$gpxAttribID[33] = '133';
$gpxAttribName[33] = 'Within enclosed rooms (caves, buildings etc.)';
$gpxAttribID[34] = '134';
$gpxAttribName[34] = 'In the water';
$gpxAttribID[35] = '135';
$gpxAttribName[35] = 'Without GPS (letterboxes, cistes, compass juggling ...)';
$gpxAttribID[37] = '137';
$gpxAttribName[37] = 'Overnight stay necessary';
$gpxAttribID[39] = '139';
$gpxAttribName[39] = 'Only available at specified times';
$gpxAttribID[40] = '140';
$gpxAttribName[40] = 'by day only';
$gpxAttribID[41] = '141';
$gpxAttribName[41] = 'Tide';
$gpxAttribID[42] = '142';
$gpxAttribName[42] = 'All seasons';
$gpxAttribID[43] = '143';
$gpxAttribName[43] = 'Breeding season / protected nature';
$gpxAttribID[47] = '147';
$gpxAttribName[47] = 'Compass';
$gpxAttribID[50] = '150';
$gpxAttribName[50] = 'Cave equipment';
$gpxAttribID[53] = '153';
$gpxAttribName[53] = 'Aircraft';
$gpxAttribID[54] = '154';
$gpxAttribName[54] = 'Investigation';
$gpxAttribID[56] = '156';
$gpxAttribName[56] = 'Arithmetical problem';
$gpxAttribID[57] = '157';
$gpxAttribName[57] = 'Other cache type';
$gpxAttribID[58] = '158';
$gpxAttribName[58] = 'Ask owner for start conditions';
//prepare the output
$caches_per_page = 20;
$sql = 'SELECT ';
if (isset($lat_rad) && isset($lon_rad))
{
$sql .= getSqlDistanceFormula($lon_rad * 180 / 3.14159, $lat_rad * 180 / 3.14159, 0, $multiplier[$distance_unit]) . ' `distance`, ';
}
else
{
if ($usr === false)
{
$sql .= '0 distance, ';
}
else
{
//get the users home coords
$rs_coords = sql_slave("SELECT `latitude`, `longitude` FROM `user` WHERE `user_id`='&1'", $usr['userid']);
$record_coords = sql_fetch_array($rs_coords);
if ((($record_coords['latitude'] == NULL) || ($record_coords['longitude'] == NULL)) || (($record_coords['latitude'] == 0) || ($record_coords['longitude'] == 0)))
{
$sql .= '0 distance, ';
}
else
{
//TODO: load from the users-profile
$distance_unit = 'km';
$lon_rad = $record_coords['longitude'] * 3.14159 / 180;
$lat_rad = $record_coords['latitude'] * 3.14159 / 180;
$sql .= getSqlDistanceFormula($record_coords['longitude'], $record_coords['latitude'], 0, $multiplier[$distance_unit]) . ' `distance`, ';
}
mysql_free_result($rs_coords);
}
}
$sAddJoin = '';
$sAddGroupBy = '';
$sAddField = '';
$sGroupBy = '';
if ($options['sort'] == 'bylastlog')
{
$sAddField = ', MAX(`cache_logs`.`date`) AS `lastLog`';
$sAddJoin = ' LEFT JOIN `cache_logs` ON `caches`.`cache_id`=`cache_logs`.`cache_id`';
$sGroupBy = ' GROUP BY `cache_logs`.`cache_id`';
}
$sql .= '`caches`.`cache_id` `cache_id`, `caches`.`status` `status`, `caches`.`type` `type`, `caches`.`size` `size`, `caches`.`longitude` `longitude`, `caches`.`latitude` `latitude`, `caches`.`user_id` `user_id`,
IF(IFNULL(`stat_caches`.`toprating`,0)>3, 4, IFNULL(`stat_caches`.`toprating`, 0)) `ratingvalue`,
`cache_location`.`adm2` `state`' .
$sAddField
. ' FROM `caches`
LEFT JOIN `stat_caches` ON `caches`.`cache_id`=`stat_caches`.`cache_id`
LEFT JOIN `cache_location` ON `caches`.`cache_id`=`cache_location`.`cache_id`' .
$sAddJoin
. ' WHERE `caches`.`cache_id` IN (' . $sqlFilter . ')' .
$sGroupBy;
$sortby = $options['sort'];
$sql .= ' ORDER BY ';
if ($options['orderRatingFirst'])
$sql .= '`ratingvalue` DESC, ';
if ($sortby == 'bylastlog')
{
$sql .= '`lastLog` DESC, ';
$sortby = 'bydistance';
}
if (isset($lat_rad) && isset($lon_rad) && ($sortby == 'bydistance'))
{
$sql .= '`distance` ASC';
}
else if ($sortby == 'bycreated')
{
$sql .= '`caches`.`date_created` DESC';
}
else // by name
{
$sql .= '`caches`.`name` ASC';
}
//startat?
$startat = isset($_REQUEST['startat']) ? $_REQUEST['startat'] : 0;
if (!is_numeric($startat)) $startat = 0;
if (isset($_REQUEST['count']))
$count = $_REQUEST['count'];
else
$count = $caches_per_page;
if ($count == 'max') $count = 500;
if (!is_numeric($count)) $count = 0;
if ($count < 1) $count = 1;
if ($count > 500) $count = 500;
$sqlLimit = ' LIMIT ' . $startat . ', ' . $count;
// create temporary table
sql_slave('CREATE TEMPORARY TABLE `gpxcontent` ' . $sql . $sqlLimit);
$rsCount = sql_slave('SELECT COUNT(*) `count` FROM `gpxcontent`');
$rCount = sql_fetch_array($rsCount);
mysql_free_result($rsCount);
if ($rCount['count'] == 1)
{
$rsName = sql_slave('SELECT `caches`.`wp_oc` `wp_oc` FROM `gpxcontent`, `caches` WHERE `gpxcontent`.`cache_id`=`caches`.`cache_id` LIMIT 1');
$rName = sql_fetch_array($rsName);
mysql_free_result($rsName);
$sFilebasename = $rName['wp_oc'];
}
else
$sFilebasename = 'ocde' . $options['queryid'];
$bUseZip = ($rCount['count'] > 20);
$bUseZip = $bUseZip || (isset($_REQUEST['zip']) && ($_REQUEST['zip'] == '1'));
if ($bUseZip == true)
{
$content = '';
require_once($rootpath . 'lib/phpzip/ss_zip.class.php');
$phpzip = new ss_zip('',6);
}
// ok, let's start
if ($sqldebug == false)
{
if ($bUseZip == true)
{
header("content-type: application/zip");
header('Content-Disposition: attachment; filename=' . $sFilebasename . '.zip');
}
else
{
header("Content-type: application/gpx");
header("Content-Disposition: attachment; filename=" . $sFilebasename . ".gpx");
}
}
$gpxHead = mb_ereg_replace('{time}', date($gpxTimeFormat, time()), $gpxHead);
append_output($gpxHead);
// ok, output ...
if ($usr === false)
$user_id = 0;
else
$user_id = $usr['userid'];
$rs = sql_slave("SELECT SQL_BUFFER_RESULT `gpxcontent`.`cache_id` `cacheid`, `gpxcontent`.`longitude` `longitude`, `gpxcontent`.`latitude` `latitude`,
`gpxcontent`.`state` `state`, `caches`.`wp_oc` `waypoint`, `caches`.`date_hidden` `date_hidden`, `caches`.`name` `name`,
`caches`.`country` `country`, `countries`.`name` AS `country_name`, `caches`.`terrain` `terrain`, `caches`.`difficulty` `difficulty`, `caches`.`desc_languages` `desc_languages`,
`caches`.`size` `size`, `caches`.`type` `type`, `caches`.`status` `status`, `user`.`username` `username`, `caches`.`user_id` `userid`,
`cache_desc`.`desc` `desc`, `cache_desc`.`short_desc` `short_desc`, `cache_desc`.`hint` `hint`,
IFNULL(`stat_cache_logs`.`found`, 0) AS `found`
FROM `gpxcontent`
INNER JOIN `caches` ON `gpxcontent`.`cache_id`=`caches`.`cache_id`
INNER JOIN `countries` ON `caches`.`country`=`countries`.`short`
INNER JOIN `user` ON `gpxcontent`.`user_id`=`user`.`user_id`
INNER JOIN `cache_desc` ON `caches`.`cache_id`=`cache_desc`.`cache_id`
AND `caches`.`default_desclang`=`cache_desc`.`language`
LEFT JOIN `stat_cache_logs` ON `gpxcontent`.`cache_id`=`stat_cache_logs`.`cache_id` AND `stat_cache_logs`.`user_id`='&1'", $user_id);
while($r = sql_fetch_array($rs))
{
$thisline = $gpxLine;
$lat = sprintf('%01.5f', $r['latitude']);
$thisline = mb_ereg_replace('{lat}', $lat, $thisline);
$lon = sprintf('%01.5f', $r['longitude']);
$thisline = mb_ereg_replace('{lon}', $lon, $thisline);
$time = date($gpxTimeFormat, strtotime($r['date_hidden']));
$thisline = mb_ereg_replace('{time}', $time, $thisline);
$thisline = mb_ereg_replace('{waypoint}', $r['waypoint'], $thisline);
$thisline = mb_ereg_replace('{cacheid}', $r['cacheid'], $thisline);
$thisline = mb_ereg_replace('{cachename}', xmlentities($r['name']), $thisline);
$thisline = mb_ereg_replace('{country}', $r['country_name'], $thisline);
$thisline = mb_ereg_replace('{state}', xmlentities($r['state']), $thisline);
if ($r['hint'] == '')
$thisline = mb_ereg_replace('{hints}', '', $thisline);
else
$thisline = mb_ereg_replace('{hints}', '<groundspeak:encoded_hints>' . xmlentities(strip_tags($r['hint'])) . '</groundspeak:encoded_hints>', $thisline);
$thisline = mb_ereg_replace('{shortdesc}', xmlentities($r['short_desc']), $thisline);
$thisline = mb_ereg_replace('{desc}', xmlentities($r['desc']), $thisline);
if (isset($gpxType[$r['type']]))
$thisline = mb_ereg_replace('{type}', $gpxType[$r['type']], $thisline);
else
$thisline = mb_ereg_replace('{type}', $gpxType[0], $thisline);
if (isset($gpxContainer[$r['size']]))
$thisline = mb_ereg_replace('{container}', $gpxContainer[$r['size']], $thisline);
else
$thisline = mb_ereg_replace('{container}', $gpxContainer[0], $thisline);
if (isset($gpxStatus[$r['status']]))
$thisline = mb_ereg_replace('{status}', $gpxStatus[$r['status']], $thisline);
else
$thisline = mb_ereg_replace('{status}', $gpxStatus[0], $thisline);
$sDiffDecimals = '';
if ($r['difficulty'] % 2) $sDiffDecimals = '.5';
$r['difficulty'] -= $r['difficulty'] % 2;
$thisline = mb_ereg_replace('{difficulty}', ($r['difficulty']/2) . $sDiffDecimals, $thisline);
$sTerrDecimals = '';
if ($r['terrain'] % 2) $sTerrDecimals = '.5';
$r['terrain'] -= $r['terrain'] % 2;
$thisline = mb_ereg_replace('{terrain}', ($r['terrain']/2) . $sTerrDecimals, $thisline);
$thisline = mb_ereg_replace('{owner}', xmlentities($r['username']), $thisline);
$thisline = mb_ereg_replace('{userid}', xmlentities($r['userid']), $thisline);
if ($r['found'] > 0)
$thisline = mb_ereg_replace('{sym}', xmlentities($gpxSymFound), $thisline);
else
$thisline = mb_ereg_replace('{sym}', xmlentities($gpxSymNormal), $thisline);
// clear logs, attributes and geokrety
$logentries = '';
$attribentries = '';
$gkentries = '';
// fetch logs
if ($user_id != 0)
{
// current users logs
$rsLogs = sql_slave("SELECT `cache_logs`.`id`, `cache_logs`.`type`, `cache_logs`.`date`, `cache_logs`.`text`, `user`.`username`, `user`.`user_id` FROM `cache_logs`, `user` WHERE `cache_logs`.`user_id`=`user`.`user_id` AND `cache_logs`.`cache_id`=&1 AND `user`.`user_id`=&2 ORDER BY `cache_logs`.`date` DESC", $r['cacheid'], $user_id);
while ($rLog = sql_fetch_array($rsLogs))
{
$thislog = $gpxLog;
$thislog = mb_ereg_replace('{id}', $rLog['id'], $thislog);
$thislog = mb_ereg_replace('{date}', date($gpxTimeFormat, strtotime($rLog['date'])), $thislog);
$thislog = mb_ereg_replace('{userid}', xmlentities($rLog['user_id']), $thislog);
$thislog = mb_ereg_replace('{username}', xmlentities($rLog['username']), $thislog);
if (isset($gpxLogType[$rLog['type']]))
$logtype = $gpxLogType[$rLog['type']];
else
$logtype = $gpxLogType[0];
$thislog = mb_ereg_replace('{type}', $logtype, $thislog);
$thislog = mb_ereg_replace('{text}', xmlentities($rLog['text']), $thislog);
$logentries .= $thislog . "\n";
}
mysql_free_result($rsLogs);
}
// first 20 logs (except current users)
$rsLogs = sql_slave("SELECT `cache_logs`.`id`, `cache_logs`.`type`, `cache_logs`.`date`, `cache_logs`.`text`, `user`.`username`, `user`.`user_id` FROM `cache_logs`, `user` WHERE `cache_logs`.`user_id`=`user`.`user_id` AND `cache_logs`.`cache_id`=&1 AND `user`.`user_id`!=&2 ORDER BY `cache_logs`.`date` DESC LIMIT 20", $r['cacheid'], $user_id);
while ($rLog = sql_fetch_array($rsLogs))
{
$thislog = $gpxLog;
$thislog = mb_ereg_replace('{id}', $rLog['id'], $thislog);
$thislog = mb_ereg_replace('{date}', date($gpxTimeFormat, strtotime($rLog['date'])), $thislog);
$thislog = mb_ereg_replace('{userid}', xmlentities($rLog['user_id']), $thislog);
$thislog = mb_ereg_replace('{username}', xmlentities($rLog['username']), $thislog);
if (isset($gpxLogType[$rLog['type']]))
$logtype = $gpxLogType[$rLog['type']];
else
$logtype = $gpxLogType[0];
$thislog = mb_ereg_replace('{type}', $logtype, $thislog);
$thislog = mb_ereg_replace('{text}', xmlentities($rLog['text']), $thislog);
$logentries .= $thislog . "\n";
}
mysql_free_result($rsLogs);
$thisline = mb_ereg_replace('{logs}', $logentries, $thisline);
// attributes
$rsAttributes = sql_slave("SELECT `caches_attributes`.`attrib_id` FROM `caches_attributes` WHERE `caches_attributes`.`cache_id`=&1", $r['cacheid']);
while ($rAttrib = sql_fetch_array($rsAttributes))
{
$thisattribute = $gpxAttributes;
$thisattribute_id = $gpxAttribID[$rAttrib['attrib_id']];
$thisattribute_name = $gpxAttribName[$rAttrib['attrib_id']];
$thisattribute = mb_ereg_replace('{attrib_id}', $thisattribute_id, $thisattribute);
$thisattribute = mb_ereg_replace('{attrib_name}', $thisattribute_name, $thisattribute);
$attribentries .= $thisattribute . "\n";
}
mysql_free_result($rsAttributes);
$thisline = mb_ereg_replace('{attributes}', $attribentries, $thisline);
// geokrety
$rsGeokrety = sql_slave("SELECT `gk_item`.`id`, `gk_item`.`name`, `caches`.`wp_oc` FROM `gk_item` INNER JOIN `gk_item_waypoint` ON `gk_item`.`id`=`gk_item_waypoint`.`id` INNER JOIN `caches` ON `gk_item_waypoint`.`wp`=`caches`.`wp_oc` WHERE `caches`.`cache_id`=&1", $r['cacheid']);
while ($rGK = sql_fetch_array($rsGeokrety))
{
$thiskrety = $gpxGeokrety;
$thiskrety = mb_ereg_replace('{gkid}', $rGK['id'], $thiskrety);
$thiskrety = mb_ereg_replace('{gkref}', sprintf("GK%04X",$rGK['id']), $thiskrety);
$thiskrety = mb_ereg_replace('{gkname}', $rGK['name'], $thiskrety);
$gkentries .= $thiskrety . "\n";
}
mysql_free_result($rsGeokrety);
$thisline = mb_ereg_replace('{geokrety}', $gkentries, $thisline);
append_output($thisline);
}
mysql_free_result($rs);
append_output($gpxFoot);
if ($sqldebug == true) sqldbg_end();
// send using phpzip
if ($bUseZip == true)
{
$phpzip->add_data($sFilebasename . '.gpx', $content);
echo $phpzip->save($sFilebasename . '.zip', 'b');
}
exit;
function xmlentities($str)
{
$from[0] = '&'; $to[0] = '&amp;';
$from[1] = '<'; $to[1] = '&lt;';
$from[2] = '>'; $to[2] = '&gt;';
$from[3] = '"'; $to[3] = '&quot;';
$from[4] = '\''; $to[4] = '&apos;';
$from[5] = ']]>'; $to[5] = ']] >';
for ($i = 0; $i <= 4; $i++)
$str = mb_ereg_replace($from[$i], $to[$i], $str);
return filterevilchars($str);
}
function filterevilchars($str)
{
return mb_ereg_replace('[\\x00-\\x09|\\x0B-\\x0C|\\x0E-\\x1F]', '', $str);
}
function append_output($str)
{
global $content, $bUseZip, $sqldebug;
if ($sqldebug == true) return;
if ($bUseZip == true)
$content .= $str;
else
echo $str;
}
?>
+423
View File
@@ -0,0 +1,423 @@
<?php
/***************************************************************************
./lib/search.gpx.inc.php
-------------------
begin : November 1 2005
copyright : (C) 2005 The OpenCaching Group
forum contact at : http://www.opencaching.com/phpBB2
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
/****************************************************************************
Unicode Reminder メモ
GPX search output
****************************************************************************/
global $content, $bUseZip, $sqldebug;
$gpxHead =
'<?xml version="1.0" encoding="utf-8"?>
<gpx xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd http://geocaching.com.au/geocache/1 http://geocaching.com.au/geocache/1/geocache.xsd"
xmlns="http://www.topografix.com/GPX/1/0"
version="1.0"
creator="www.opencaching.de">
<desc>Geocache</desc>
<author>Geocaching Australia</author>
<url>http://www.opencaching.de</url>
<urlname>www.opencaching.de</urlname>
<time>{time}</time>
';
$gpxLine =
'
<wpt lat="{lat}" lon="{lon}">
<time>{time}</time>
<name>{waypoint}</name>
<desc>{cachename}</desc>
<src>www.opencaching.de</src>
<url>http://www.opencaching.de/viewcache.php?cacheid={cacheid}</url>
<urlname>{cachename}</urlname>
<sym>Geocache</sym>
<type>Geocache</type>
<geocache status="{status}" xmlns="http://geocaching.com.au/geocache/1">
<name>{cachename}</name>
<owner>{owner}</owner>
<locale></locale>
<state>{state}</state>
<country>{country}</country>
<type>{type}</type>
<container>{container}</container>
<difficulty>{difficulty}</difficulty>
<terrain>{terrain}</terrain>
<summary html="false">{shortdesc}</summary>
<description html="true">{desc}</description>
{hints}
<licence></licence>
<logs>
{logs}
</logs>
</geocache>
</wpt>
';
$gpxLog = '
<log id="{id}">
<time>{date}</time>
<geocacher>{username}</geocacher>
<type>{type}</type>
<text>{text}</text>
</log>
';
$gpxFoot = '</gpx>';
$gpxTimeFormat = 'Y-m-d\TH:i:s\Z';
$gpxStatus[0] = 'Unavailable'; // andere
$gpxStatus[1] = 'Available';
$gpxStatus[2] = 'Unavailable';
$gpxStatus[3] = 'Archived';
$gpxContainer[0] = 'Other';
$gpxContainer[2] = 'Micro';
$gpxContainer[3] = 'Small';
$gpxContainer[4] = 'Regular';
$gpxContainer[5] = 'Large';
$gpxContainer[6] = 'Large';
$gpxContainer[7] = 'Virtual';
// known by gpx
$gpxType[0] = 'Other';
$gpxType[2] = 'Traditional';
$gpxType[3] = 'Multi';
$gpxType[4] = 'Virtual';
$gpxType[5] = 'Webcam';
$gpxType[6] = 'Event';
// unknown ... converted
$gpxType[7] = 'Multi';
$gpxType[8] = 'Multi';
$gpxType[10] = 'Traditional';
$gpxLogType[0] = 'Other';
$gpxLogType[1] = 'Found';
$gpxLogType[2] = 'Not Found';
$gpxLogType[3] = 'Note';
//prepare the output
$caches_per_page = 20;
$sql = 'SELECT ';
if (isset($lat_rad) && isset($lon_rad))
{
$sql .= getSqlDistanceFormula($lon_rad * 180 / 3.14159, $lat_rad * 180 / 3.14159, 0, $multiplier[$distance_unit]) . ' `distance`, ';
}
else
{
if ($usr === false)
{
$sql .= '0 distance, ';
}
else
{
//get the users home coords
$rs_coords = sql_slave("SELECT `latitude`, `longitude` FROM `user` WHERE `user_id`='&1'", $usr['userid']);
$record_coords = sql_fetch_array($rs_coords);
if ((($record_coords['latitude'] == NULL) || ($record_coords['longitude'] == NULL)) || (($record_coords['latitude'] == 0) || ($record_coords['longitude'] == 0)))
{
$sql .= '0 distance, ';
}
else
{
//TODO: load from the users-profile
$distance_unit = 'km';
$lon_rad = $record_coords['longitude'] * 3.14159 / 180;
$lat_rad = $record_coords['latitude'] * 3.14159 / 180;
$sql .= getSqlDistanceFormula($record_coords['longitude'], $record_coords['latitude'], 0, $multiplier[$distance_unit]) . ' `distance`, ';
}
mysql_free_result($rs_coords);
}
}
$sAddJoin = '';
$sAddGroupBy = '';
$sAddField = '';
$sGroupBy = '';
if ($options['sort'] == 'bylastlog')
{
$sAddField = ', MAX(`cache_logs`.`date`) AS `lastLog`';
$sAddJoin = ' LEFT JOIN `cache_logs` ON `caches`.`cache_id`=`cache_logs`.`cache_id`';
$sGroupBy = ' GROUP BY `cache_logs`.`cache_id`';
}
$sql .= '`caches`.`cache_id` `cache_id`, `caches`.`status` `status`, `caches`.`type` `type`, `caches`.`size` `size`, `caches`.`longitude` `longitude`, `caches`.`latitude` `latitude`, `caches`.`user_id` `user_id`,
IF(IFNULL(`stat_caches`.`toprating`,0)>3, 4, IFNULL(`stat_caches`.`toprating`, 0)) `ratingvalue`,
`cache_location`.`adm2` `state`' .
$sAddField
. ' FROM `caches`
LEFT JOIN `stat_caches` ON `caches`.`cache_id`=`stat_caches`.`cache_id`
LEFT JOIN `cache_location` ON `caches`.`cache_id`=`cache_location`.`cache_id`' .
$sAddJoin
. ' WHERE `caches`.`cache_id` IN (' . $sqlFilter . ')' .
$sGroupBy;
$sortby = $options['sort'];
$sql .= ' ORDER BY ';
if ($options['orderRatingFirst'])
$sql .= '`ratingvalue` DESC, ';
if ($sortby == 'bylastlog')
{
$sql .= '`lastLog` DESC, ';
$sortby = 'bydistance';
}
if (isset($lat_rad) && isset($lon_rad) && ($sortby == 'bydistance'))
{
$sql .= '`distance` ASC';
}
else if ($sortby == 'bycreated')
{
$sql .= '`caches`.`date_created` DESC';
}
else // by name
{
$sql .= '`caches`.`name` ASC';
}
//startat?
$startat = isset($_REQUEST['startat']) ? $_REQUEST['startat'] : 0;
if (!is_numeric($startat)) $startat = 0;
if (isset($_REQUEST['count']))
$count = $_REQUEST['count'];
else
$count = $caches_per_page;
if ($count == 'max') $count = 500;
if (!is_numeric($count)) $count = 0;
if ($count < 1) $count = 1;
if ($count > 500) $count = 500;
$sqlLimit = ' LIMIT ' . $startat . ', ' . $count;
// temporäre tabelle erstellen
sql_slave('CREATE TEMPORARY TABLE `gpxcontent` ' . $sql . $sqlLimit);
$rsCount = sql_slave('SELECT COUNT(*) `count` FROM `gpxcontent`');
$rCount = sql_fetch_array($rsCount);
mysql_free_result($rsCount);
if ($rCount['count'] == 1)
{
$rsName = sql_slave('SELECT `caches`.`wp_oc` `wp_oc` FROM `gpxcontent`, `caches` WHERE `gpxcontent`.`cache_id`=`caches`.`cache_id` LIMIT 1');
$rName = sql_fetch_array($rsName);
mysql_free_result($rsName);
$sFilebasename = $rName['wp_oc'];
}
else
$sFilebasename = 'ocde' . $options['queryid'];
$bUseZip = ($rCount['count'] > 20);
$bUseZip = $bUseZip || (isset($_REQUEST['zip']) && ($_REQUEST['zip'] == '1'));
if ($bUseZip == true)
{
$content = '';
require_once($rootpath . 'lib/phpzip/ss_zip.class.php');
$phpzip = new ss_zip('',6);
}
// ok, ausgabe starten
if ($sqldebug == false)
{
if ($bUseZip == true)
{
header("content-type: application/zip");
header('Content-Disposition: attachment; filename=' . $sFilebasename . '.zip');
}
else
{
header("Content-type: application/gpx");
header("Content-Disposition: attachment; filename=" . $sFilebasename . ".gpx");
}
}
$gpxHead = mb_ereg_replace('{time}', date($gpxTimeFormat, time()), $gpxHead);
append_output($gpxHead);
// ok, ausgabe ...
$rs = sql_slave('SELECT SQL_BUFFER_RESULT `gpxcontent`.`cache_id` `cacheid`, `gpxcontent`.`longitude` `longitude`, `gpxcontent`.`latitude` `latitude`, `gpxcontent`.`state` `state`, `caches`.`wp_oc` `waypoint`, `caches`.`date_hidden` `date_hidden`, `caches`.`name` `name`, `caches`.`country` `country`, `caches`.`terrain` `terrain`, `caches`.`difficulty` `difficulty`, `caches`.`desc_languages` `desc_languages`, `caches`.`size` `size`, `caches`.`type` `type`, `caches`.`status` `status`, `user`.`username` `username`, `cache_desc`.`desc` `desc`, `cache_desc`.`short_desc` `short_desc`, `cache_desc`.`hint` `hint` FROM `gpxcontent`, `caches`, `user`, `cache_desc` WHERE `gpxcontent`.`cache_id`=`caches`.`cache_id` AND `caches`.`cache_id`=`cache_desc`.`cache_id` AND `caches`.`default_desclang`=`cache_desc`.`language` AND `gpxcontent`.`user_id`=`user`.`user_id`');
while($r = sql_fetch_array($rs))
{
$thisline = $gpxLine;
$lat = sprintf('%01.5f', $r['latitude']);
$thisline = mb_ereg_replace('{lat}', $lat, $thisline);
$lon = sprintf('%01.5f', $r['longitude']);
$thisline = mb_ereg_replace('{lon}', $lon, $thisline);
$time = date($gpxTimeFormat, strtotime($r['date_hidden']));
$thisline = mb_ereg_replace('{time}', $time, $thisline);
$thisline = mb_ereg_replace('{waypoint}', $r['waypoint'], $thisline);
$thisline = mb_ereg_replace('{cacheid}', $r['cacheid'], $thisline);
$thisline = mb_ereg_replace('{cachename}', xmlentities($r['name']), $thisline);
$thisline = mb_ereg_replace('{country}', $r['country'], $thisline);
$thisline = mb_ereg_replace('{state}', xmlentities($r['state']), $thisline);
if ($r['hint'] == '')
$thisline = mb_ereg_replace('{hints}', '', $thisline);
else
$thisline = mb_ereg_replace('{hints}', '<hints>' . xmlentities(strip_tags($r['hint'])) . '</hints>', $thisline);
$thisline = mb_ereg_replace('{shortdesc}', xmlentities($r['short_desc']), $thisline);
$thisline = mb_ereg_replace('{desc}', xmlentities($r['desc']), $thisline);
if (isset($gpxType[$r['type']]))
$thisline = mb_ereg_replace('{type}', $gpxType[$r['type']], $thisline);
else
$thisline = mb_ereg_replace('{type}', $gpxType[0], $thisline);
if (isset($gpxContainer[$r['size']]))
$thisline = mb_ereg_replace('{container}', $gpxContainer[$r['size']], $thisline);
else
$thisline = mb_ereg_replace('{container}', $gpxContainer[0], $thisline);
if (isset($gpxStatus[$r['status']]))
$thisline = mb_ereg_replace('{status}', $gpxStatus[$r['status']], $thisline);
else
$thisline = mb_ereg_replace('{status}', $gpxStatus[0], $thisline);
$difficulty = sprintf('%01.1f', $r['difficulty'] / 2);
$thisline = mb_ereg_replace('{difficulty}', $difficulty, $thisline);
$terrain = sprintf('%01.1f', $r['terrain'] / 2);
$thisline = mb_ereg_replace('{terrain}', $terrain, $thisline);
$thisline = mb_ereg_replace('{owner}', xmlentities($r['username']), $thisline);
// logs ermitteln
if ($usr === false)
{
$user_id = 0;
}
else
{
$user_id = $usr['userid'];
}
$logentries = '';
if ($user_id != 0)
{
// my logs
$rsLogs = sql_slave("SELECT `cache_logs`.`id`, `cache_logs`.`type`, `cache_logs`.`date`, `cache_logs`.`text`, `user`.`username` FROM `cache_logs`, `user` WHERE `cache_logs`.`user_id`=`user`.`user_id` AND `cache_logs`.`cache_id`=&1 AND `user`.`user_id`=&2 ORDER BY `cache_logs`.`date` DESC", $r['cacheid'], $user_id);
while ($rLog = sql_fetch_array($rsLogs))
{
$thislog = $gpxLog;
$thislog = mb_ereg_replace('{id}', $rLog['id'], $thislog);
$thislog = mb_ereg_replace('{date}', date($gpxTimeFormat, strtotime($rLog['date'])), $thislog);
$thislog = mb_ereg_replace('{username}', xmlentities($rLog['username']), $thislog);
if (isset($gpxLogType[$rLog['type']]))
$logtype = $gpxLogType[$rLog['type']];
else
$logtype = $gpxLogType[0];
$thislog = mb_ereg_replace('{type}', $logtype, $thislog);
$thislog = mb_ereg_replace('{text}', xmlentities($rLog['text']), $thislog);
$logentries .= $thislog . "\n";
}
}
// first 20 logs (except mine)
$rsLogs = sql_slave("SELECT `cache_logs`.`id`, `cache_logs`.`type`, `cache_logs`.`date`, `cache_logs`.`text`, `user`.`username` FROM `cache_logs`, `user` WHERE `cache_logs`.`user_id`=`user`.`user_id` AND `cache_logs`.`cache_id`=&1 AND `user`.`user_id`!=&2 ORDER BY `cache_logs`.`date` DESC LIMIT 20", $r['cacheid'], $user_id);
while ($rLog = sql_fetch_array($rsLogs))
{
$thislog = $gpxLog;
$thislog = mb_ereg_replace('{id}', $rLog['id'], $thislog);
$thislog = mb_ereg_replace('{date}', date($gpxTimeFormat, strtotime($rLog['date'])), $thislog);
$thislog = mb_ereg_replace('{username}', xmlentities($rLog['username']), $thislog);
if (isset($gpxLogType[$rLog['type']]))
$logtype = $gpxLogType[$rLog['type']];
else
$logtype = $gpxLogType[0];
$thislog = mb_ereg_replace('{type}', $logtype, $thislog);
$thislog = mb_ereg_replace('{text}', xmlentities($rLog['text']), $thislog);
$logentries .= $thislog . "\n";
}
$thisline = mb_ereg_replace('{logs}', $logentries, $thisline);
append_output($thisline);
}
mysql_free_result($rs);
append_output($gpxFoot);
if ($sqldebug == true) sqldbg_end();
// phpzip versenden
if ($bUseZip == true)
{
$phpzip->add_data($sFilebasename . '.gpx', $content);
echo $phpzip->save($sFilebasename . '.zip', 'b');
}
exit;
function xmlentities($str)
{
$from[0] = '&'; $to[0] = '&amp;';
$from[1] = '<'; $to[1] = '&lt;';
$from[2] = '>'; $to[2] = '&gt;';
$from[3] = '"'; $to[3] = '&quot;';
$from[4] = '\''; $to[4] = '&apos;';
$from[5] = ']]>'; $to[5] = ']] >';
for ($i = 0; $i <= 4; $i++)
$str = mb_ereg_replace($from[$i], $to[$i], $str);
return filterevilchars($str);
}
function filterevilchars($str)
{
return mb_ereg_replace('[\\x00-\\x09|\\x0B-\\x0C|\\x0E-\\x1F]', '', $str);
}
function append_output($str)
{
global $content, $bUseZip, $sqldebug;
if ($sqldebug == true) return;
if ($bUseZip == true)
$content .= $str;
else
echo $str;
}
?>
+451
View File
@@ -0,0 +1,451 @@
<?php
/***************************************************************************
./lib/search.gpx.inc.php
-------------------
begin : November 1 2005
copyright : (C) 2005 The OpenCaching Group
forum contact at : http://www.opencaching.com/phpBB2
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
/****************************************************************************
Unicode Reminder メモ
GPX search output
****************************************************************************/
global $content, $bUseZip, $sqldebug;
$gpxHead =
'<?xml version="1.0" encoding="utf-8"?>
<gpx xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd"
xmlns="http://www.topografix.com/GPX/1/0"
version="1.0"
creator="www.opencaching.de">
<desc>Geocache</desc>
<author>www.opencaching.de</author>
<url>http://www.opencaching.de</url>
<urlname>www.opencaching.de</urlname>
<time>{time}</time>
';
$gpxLine =
'
<wpt lat="{lat}" lon="{lon}">
<time>{time}</time>
<name>{waypoint}</name>
<desc>{cachename}</desc>
<src>www.opencaching.de</src>
<url>http://www.opencaching.de/viewcache.php?cacheid={cacheid}</url>
<urlname>{cachename}</urlname>
<sym>{sym}</sym>
<type>Geocache|{type}</type>
<extensions>
<cache id="{cacheid}" status="{status}">
<name>{cachename}</name>
<owner userid="{userid}">{owner}</owner>
<locale></locale>
<state>{state}</state>
<country>{country}</country>
<type>{type}</type>
<container>{container}</container>
<difficulty>{difficulty}</difficulty>
<terrain>{terrain}</terrain>
<short_description html="true">{shortdesc}</short_description>
<long_description html="true">{desc}</long_description>
{hints}
<licence></licence>
<logs>
{logs}
</logs>
</cache>
</extensions>
</wpt>
';
$gpxLog = '
<log id="{id}">
<date>{date}</date>
<finder id="{userid}">{username}</finder>
<type>{type}</type>
<text>{text}</text>
</log>
';
$gpxFoot = '</gpx>';
$gpxTimeFormat = 'Y-m-d\TH:i:s\Z';
$gpxStatus[0] = 'Unavailable'; // andere
$gpxStatus[1] = 'Available';
$gpxStatus[2] = 'Unavailable';
$gpxStatus[3] = 'Archived';
$gpxContainer[0] = 'Other';
$gpxContainer[2] = 'Micro';
$gpxContainer[3] = 'Small';
$gpxContainer[4] = 'Regular';
$gpxContainer[5] = 'Large';
$gpxContainer[6] = 'Large';
$gpxContainer[7] = 'Virtual';
// known by gpx
$gpxType[0] = 'Unknown Cache';
$gpxType[2] = 'Traditional Cache';
$gpxType[3] = 'Multi-cache';
$gpxType[4] = 'Virtual Cache';
$gpxType[5] = 'Webcam Cache';
$gpxType[6] = 'Event Cache';
// unknown ... converted
$gpxType[7] = 'Unknown Cache';
$gpxType[8] = 'Unknown Cache';
$gpxType[10] = 'Traditional Cache';
$gpxLogType[0] = 'Other';
$gpxLogType[1] = 'Found it';
$gpxLogType[2] = 'Didn\'t find it';
$gpxLogType[3] = 'Write note';
$gpxLogType[7] = 'Attended';
$gpxLogType[8] = 'Will attend';
$gpxSymNormal = 'Geocache';
$gpxSymFound = 'Geocache Found';
//prepare the output
$caches_per_page = 20;
$sql = 'SELECT ';
if (isset($lat_rad) && isset($lon_rad))
{
$sql .= getSqlDistanceFormula($lon_rad * 180 / 3.14159, $lat_rad * 180 / 3.14159, 0, $multiplier[$distance_unit]) . ' `distance`, ';
}
else
{
if ($usr === false)
{
$sql .= '0 distance, ';
}
else
{
//get the users home coords
$rs_coords = sql_slave("SELECT `latitude`, `longitude` FROM `user` WHERE `user_id`='&1'", $usr['userid']);
$record_coords = sql_fetch_array($rs_coords);
if ((($record_coords['latitude'] == NULL) || ($record_coords['longitude'] == NULL)) || (($record_coords['latitude'] == 0) || ($record_coords['longitude'] == 0)))
{
$sql .= '0 distance, ';
}
else
{
//TODO: load from the users-profile
$distance_unit = 'km';
$lon_rad = $record_coords['longitude'] * 3.14159 / 180;
$lat_rad = $record_coords['latitude'] * 3.14159 / 180;
$sql .= getSqlDistanceFormula($record_coords['longitude'], $record_coords['latitude'], 0, $multiplier[$distance_unit]) . ' `distance`, ';
}
mysql_free_result($rs_coords);
}
}
$sAddJoin = '';
$sAddGroupBy = '';
$sAddField = '';
$sGroupBy = '';
if ($options['sort'] == 'bylastlog')
{
$sAddField = ', MAX(`cache_logs`.`date`) AS `lastLog`';
$sAddJoin = ' LEFT JOIN `cache_logs` ON `caches`.`cache_id`=`cache_logs`.`cache_id`';
$sGroupBy = ' GROUP BY `cache_logs`.`cache_id`';
}
$sql .= '`caches`.`cache_id` `cache_id`, `caches`.`status` `status`, `caches`.`type` `type`, `caches`.`size` `size`, `caches`.`longitude` `longitude`, `caches`.`latitude` `latitude`, `caches`.`user_id` `user_id`,
IF(IFNULL(`stat_caches`.`toprating`,0)>3, 4, IFNULL(`stat_caches`.`toprating`, 0)) `ratingvalue`,
`cache_location`.`adm2` `state`' .
$sAddField
. ' FROM `caches`
LEFT JOIN `stat_caches` ON `caches`.`cache_id`=`stat_caches`.`cache_id`
LEFT JOIN `cache_location` ON `caches`.`cache_id`=`cache_location`.`cache_id`' .
$sAddJoin
. ' WHERE `caches`.`cache_id` IN (' . $sqlFilter . ')' .
$sGroupBy;
$sortby = $options['sort'];
$sql .= ' ORDER BY ';
if ($options['orderRatingFirst'])
$sql .= '`ratingvalue` DESC, ';
if ($sortby == 'bylastlog')
{
$sql .= '`lastLog` DESC, ';
$sortby = 'bydistance';
}
if (isset($lat_rad) && isset($lon_rad) && ($sortby == 'bydistance'))
{
$sql .= '`distance` ASC';
}
else if ($sortby == 'bycreated')
{
$sql .= '`caches`.`date_created` DESC';
}
else // by name
{
$sql .= '`caches`.`name` ASC';
}
//startat?
$startat = isset($_REQUEST['startat']) ? $_REQUEST['startat'] : 0;
if (!is_numeric($startat)) $startat = 0;
if (isset($_REQUEST['count']))
$count = $_REQUEST['count'];
else
$count = $caches_per_page;
if ($count == 'max') $count = 500;
if (!is_numeric($count)) $count = 0;
if ($count < 1) $count = 1;
if ($count > 500) $count = 500;
$sqlLimit = ' LIMIT ' . $startat . ', ' . $count;
// temporäre tabelle erstellen
sql_slave('CREATE TEMPORARY TABLE `gpxcontent` ' . $sql . $sqlLimit);
$rsCount = sql_slave('SELECT COUNT(*) `count` FROM `gpxcontent`');
$rCount = sql_fetch_array($rsCount);
mysql_free_result($rsCount);
if ($rCount['count'] == 1)
{
$rsName = sql_slave('SELECT `caches`.`wp_oc` `wp_oc` FROM `gpxcontent`, `caches` WHERE `gpxcontent`.`cache_id`=`caches`.`cache_id` LIMIT 1');
$rName = sql_fetch_array($rsName);
mysql_free_result($rsName);
$sFilebasename = $rName['wp_oc'];
}
else
$sFilebasename = 'ocde' . $options['queryid'];
$bUseZip = ($rCount['count'] > 20);
$bUseZip = $bUseZip || (isset($_REQUEST['zip']) && ($_REQUEST['zip'] == '1'));
if ($bUseZip == true)
{
$content = '';
require_once($rootpath . 'lib/phpzip/ss_zip.class.php');
$phpzip = new ss_zip('',6);
}
// ok, ausgabe starten
if ($sqldebug == false)
{
if ($bUseZip == true)
{
header("content-type: application/zip");
header('Content-Disposition: attachment; filename=' . $sFilebasename . '.zip');
}
else
{
header("Content-type: application/gpx");
header("Content-Disposition: attachment; filename=" . $sFilebasename . ".gpx");
}
}
$gpxHead = mb_ereg_replace('{time}', date($gpxTimeFormat, time()), $gpxHead);
append_output($gpxHead);
// ok, ausgabe ...
if ($usr === false)
$user_id = 0;
else
$user_id = $usr['userid'];
$rs = sql_slave("SELECT SQL_BUFFER_RESULT `gpxcontent`.`cache_id` `cacheid`, `gpxcontent`.`longitude` `longitude`, `gpxcontent`.`latitude` `latitude`,
`gpxcontent`.`state` `state`, `caches`.`wp_oc` `waypoint`, `caches`.`date_hidden` `date_hidden`, `caches`.`name` `name`,
`caches`.`country` `country`, `caches`.`terrain` `terrain`, `caches`.`difficulty` `difficulty`, `caches`.`desc_languages` `desc_languages`,
`caches`.`size` `size`, `caches`.`type` `type`, `caches`.`status` `status`, `user`.`username` `username`, `caches`.`user_id` `userid`,
`cache_desc`.`desc` `desc`, `cache_desc`.`short_desc` `short_desc`, `cache_desc`.`hint` `hint`,
IFNULL(`stat_cache_logs`.`found`, 0) AS `found`
FROM `gpxcontent`
INNER JOIN `caches` ON `gpxcontent`.`cache_id`=`caches`.`cache_id`
INNER JOIN `user` ON `gpxcontent`.`user_id`=`user`.`user_id`
INNER JOIN `cache_desc` ON `caches`.`cache_id`=`cache_desc`.`cache_id`
AND `caches`.`default_desclang`=`cache_desc`.`language`
LEFT JOIN `stat_cache_logs` ON `gpxcontent`.`cache_id`=`stat_cache_logs`.`cache_id` AND `stat_cache_logs`.`user_id`='&1'",
$user_id);
while($r = sql_fetch_array($rs))
{
$thisline = $gpxLine;
$lat = sprintf('%01.5f', $r['latitude']);
$thisline = mb_ereg_replace('{lat}', $lat, $thisline);
$lon = sprintf('%01.5f', $r['longitude']);
$thisline = mb_ereg_replace('{lon}', $lon, $thisline);
$time = date($gpxTimeFormat, strtotime($r['date_hidden']));
$thisline = mb_ereg_replace('{time}', $time, $thisline);
$thisline = mb_ereg_replace('{waypoint}', $r['waypoint'], $thisline);
$thisline = mb_ereg_replace('{cacheid}', $r['cacheid'], $thisline);
$thisline = mb_ereg_replace('{cachename}', xmlentities($r['name']), $thisline);
$thisline = mb_ereg_replace('{country}', $r['country'], $thisline);
$thisline = mb_ereg_replace('{state}', xmlentities($r['state']), $thisline);
if ($r['hint'] == '')
$thisline = mb_ereg_replace('{hints}', '', $thisline);
else
$thisline = mb_ereg_replace('{hints}', '<encoded_hints>' . xmlentities(strip_tags($r['hint'])) . '</encoded_hints>', $thisline);
$thisline = mb_ereg_replace('{shortdesc}', xmlentities($r['short_desc']), $thisline);
$thisline = mb_ereg_replace('{desc}', xmlentities($r['desc']), $thisline);
if (isset($gpxType[$r['type']]))
$thisline = mb_ereg_replace('{type}', $gpxType[$r['type']], $thisline);
else
$thisline = mb_ereg_replace('{type}', $gpxType[0], $thisline);
if (isset($gpxContainer[$r['size']]))
$thisline = mb_ereg_replace('{container}', $gpxContainer[$r['size']], $thisline);
else
$thisline = mb_ereg_replace('{container}', $gpxContainer[0], $thisline);
if (isset($gpxStatus[$r['status']]))
$thisline = mb_ereg_replace('{status}', $gpxStatus[$r['status']], $thisline);
else
$thisline = mb_ereg_replace('{status}', $gpxStatus[0], $thisline);
$sDiffDecimals = '';
if ($r['difficulty'] % 2) $sDiffDecimals = '.5';
$r['difficulty'] -= $r['difficulty'] % 2;
$thisline = mb_ereg_replace('{difficulty}', ($r['difficulty']/2) . $sDiffDecimals, $thisline);
$sTerrDecimals = '';
if ($r['terrain'] % 2) $sTerrDecimals = '.5';
$r['terrain'] -= $r['terrain'] % 2;
$thisline = mb_ereg_replace('{terrain}', ($r['terrain']/2) . $sTerrDecimals, $thisline);
$thisline = mb_ereg_replace('{owner}', xmlentities($r['username']), $thisline);
$thisline = mb_ereg_replace('{userid}', xmlentities($r['userid']), $thisline);
if ($r['found'] > 0)
$thisline = mb_ereg_replace('{sym}', xmlentities($gpxSymFound), $thisline);
else
$thisline = mb_ereg_replace('{sym}', xmlentities($gpxSymNormal), $thisline);
$logentries = '';
// logs ermitteln
if ($user_id != 0)
{
// my logs
$rsLogs = sql_slave("SELECT `cache_logs`.`id`, `cache_logs`.`type`, `cache_logs`.`date`, `cache_logs`.`text`, `user`.`username`, `user`.`user_id` FROM `cache_logs`, `user` WHERE `cache_logs`.`user_id`=`user`.`user_id` AND `cache_logs`.`cache_id`=&1 AND `user`.`user_id`=&2 ORDER BY `cache_logs`.`date` DESC", $r['cacheid'], $user_id);
while ($rLog = sql_fetch_array($rsLogs))
{
$thislog = $gpxLog;
$thislog = mb_ereg_replace('{id}', $rLog['id'], $thislog);
$thislog = mb_ereg_replace('{date}', date($gpxTimeFormat, strtotime($rLog['date'])), $thislog);
$thislog = mb_ereg_replace('{userid}', xmlentities($rLog['user_id']), $thislog);
$thislog = mb_ereg_replace('{username}', xmlentities($rLog['username']), $thislog);
if (isset($gpxLogType[$rLog['type']]))
$logtype = $gpxLogType[$rLog['type']];
else
$logtype = $gpxLogType[0];
$thislog = mb_ereg_replace('{type}', $logtype, $thislog);
$thislog = mb_ereg_replace('{text}', xmlentities($rLog['text']), $thislog);
$logentries .= $thislog . "\n";
}
}
// first 20 logs (except mine)
$rsLogs = sql_slave("SELECT `cache_logs`.`id`, `cache_logs`.`type`, `cache_logs`.`date`, `cache_logs`.`text`, `user`.`username`, `user`.`user_id` FROM `cache_logs`, `user` WHERE `cache_logs`.`user_id`=`user`.`user_id` AND `cache_logs`.`cache_id`=&1 AND `user`.`user_id`!=&2 ORDER BY `cache_logs`.`date` DESC LIMIT 20", $r['cacheid'], $user_id);
while ($rLog = sql_fetch_array($rsLogs))
{
$thislog = $gpxLog;
$thislog = mb_ereg_replace('{id}', $rLog['id'], $thislog);
$thislog = mb_ereg_replace('{date}', date($gpxTimeFormat, strtotime($rLog['date'])), $thislog);
$thislog = mb_ereg_replace('{userid}', xmlentities($rLog['user_id']), $thislog);
$thislog = mb_ereg_replace('{username}', xmlentities($rLog['username']), $thislog);
if (isset($gpxLogType[$rLog['type']]))
$logtype = $gpxLogType[$rLog['type']];
else
$logtype = $gpxLogType[0];
$thislog = mb_ereg_replace('{type}', $logtype, $thislog);
$thislog = mb_ereg_replace('{text}', xmlentities($rLog['text']), $thislog);
$logentries .= $thislog . "\n";
}
$thisline = mb_ereg_replace('{logs}', $logentries, $thisline);
append_output($thisline);
}
mysql_free_result($rs);
append_output($gpxFoot);
if ($sqldebug == true) sqldbg_end();
// phpzip versenden
if ($bUseZip == true)
{
$phpzip->add_data($sFilebasename . '.gpx', $content);
echo $phpzip->save($sFilebasename . '.zip', 'b');
}
exit;
function xmlentities($str)
{
$from[0] = '&'; $to[0] = '&amp;';
$from[1] = '<'; $to[1] = '&lt;';
$from[2] = '>'; $to[2] = '&gt;';
$from[3] = '"'; $to[3] = '&quot;';
$from[4] = '\''; $to[4] = '&apos;';
$from[5] = ']]>'; $to[5] = ']] >';
for ($i = 0; $i <= 4; $i++)
$str = mb_ereg_replace($from[$i], $to[$i], $str);
return filterevilchars($str);
}
function filterevilchars($str)
{
return mb_ereg_replace('[\\x00-\\x09|\\x0B-\\x0C|\\x0E-\\x1F]', '', $str);
}
function append_output($str)
{
global $content, $bUseZip, $sqldebug;
if ($sqldebug == true) return;
if ($bUseZip == true)
$content .= $str;
else
echo $str;
}
?>
+336
View File
@@ -0,0 +1,336 @@
<?php
/***************************************************************************
./lib/search.html.inc.php
-------------------
begin : July 25 2004
copyright : (C) 2004 The OpenCaching Group
forum contact at : http://www.opencaching.com/phpBB2
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
/****************************************************************************
Unicode Reminder メモ
(X)HTML search output
TODO: (1) save the options in the database
(2) sort the results and the make the final query
****************************************************************************/
global $sqldebug;
require_once($stylepath . '/lib/icons.inc.php');
require_once('lib/cache_icon.inc.php');
//prepare the output
$tplname = 'search.result.caches';
$caches_per_page = 20;
//build lines
$cache_line = read_file($stylepath . '/search.result.caches.row.tpl.php');
$cache_line = mb_ereg_replace('{string_by}', $string_by, $cache_line);
$caches_output = '';
/*
$lat_rad
$lon_rad
$distance_unit
*/
$distance_unit = 'km';
$sql = 'SELECT SQL_BUFFER_RESULT SQL_CALC_FOUND_ROWS ';
if (isset($lat_rad) && isset($lon_rad))
{
$sql .= getSqlDistanceFormula($lon_rad * 180 / 3.14159, $lat_rad * 180 / 3.14159, 0, $multiplier[$distance_unit]) . ' `distance`, ';
}
else
{
if ($usr === false)
{
$sql .= '0 distance, ';
}
else
{
//get the users home coords
$rs_coords = sql_slave("SELECT `latitude`, `longitude` FROM `user` WHERE `user_id`='&1'", $usr['userid']);
$record_coords = sql_fetch_array($rs_coords);
if ((($record_coords['latitude'] == NULL) || ($record_coords['longitude'] == NULL)) || (($record_coords['latitude'] == 0) || ($record_coords['longitude'] == 0)))
{
$sql .= '0 distance, ';
}
else
{
//TODO: load from the users-profile
$distance_unit = 'km';
$lon_rad = $record_coords['longitude'] * 3.14159 / 180;
$lat_rad = $record_coords['latitude'] * 3.14159 / 180;
$sql .= getSqlDistanceFormula($record_coords['longitude'], $record_coords['latitude'], 0, $multiplier[$distance_unit]) . ' `distance`, ';
}
mysql_free_result($rs_coords);
}
}
$sAddJoin = '';
$sAddGroupBy = '';
$sAddField = '';
$sGroupBy = '';
if ($options['sort'] == 'bylastlog')
{
$sAddField = ', MAX(`cache_logs`.`date`) AS `lastLog`';
$sAddJoin = ' LEFT JOIN `cache_logs` ON `caches`.`cache_id`=`cache_logs`.`cache_id`';
$sGroupBy = ' GROUP BY `cache_logs`.`cache_id`';
}
$sql .= ' `caches`.`name` `name`, `caches`.`status` `status`, `caches`.`longitude` `longitude`, `caches`.`latitude` `latitude`,
`caches`.`difficulty` `difficulty`, `caches`.`terrain` `terrain`, `caches`.`desc_languages` `desc_languages`,
`caches`.`date_created` `date_created`, `caches`.`type` `type`, `caches`.`cache_id` `cache_id`,
`user`.`username` `username`, `user`.`user_id` `user_id`,
`cache_type`.`icon_large` `icon_large`,
`cache_type`.`name` `cacheTypeName`,
IFNULL(`stat_caches`.`found`, 0) `founds`,
IFNULL(`stat_caches`.`toprating`, 0) `topratings`,
IF(IFNULL(`stat_caches`.`toprating`,0)>3, 4, IFNULL(`stat_caches`.`toprating`, 0)) `ratingvalue`,
IF(ISNULL(`tbloconly`.`cache_id`), 0, 1) AS `oconly`' .
$sAddField
. ' FROM `caches`
INNER JOIN `user` ON `caches`.`user_id`=`user`.`user_id`
INNER JOIN `cache_type` ON `cache_type`.`id`=`caches`.`type`
LEFT JOIN `stat_caches` ON `caches`.`cache_id`=`stat_caches`.`cache_id`
LEFT JOIN `caches_attributes` AS `tbloconly` ON `caches`.`cache_id`=`tbloconly`.`cache_id` AND
`tbloconly`.`attrib_id`=6' .
$sAddJoin
. ' WHERE `caches`.`cache_id` IN (' . $sqlFilter . ')' .
$sGroupBy;
$sortby = $options['sort'];
$sql .= ' ORDER BY ';
if ($options['orderRatingFirst'])
$sql .= '`ratingvalue` DESC, ';
if ($sortby == 'bylastlog')
{
$sql .= '`lastLog` DESC, ';
$sortby = 'bydistance';
}
if (isset($lat_rad) && isset($lon_rad) && ($sortby == 'bydistance'))
{
$sql .= '`distance` ASC';
}
else if ($sortby == 'bycreated')
{
$sql .= '`caches`.`date_created` DESC';
}
else // by name
{
$sql .= '`caches`.`name` ASC';
}
//startat?
$startat = isset($_REQUEST['startat']) ? $_REQUEST['startat'] : 0;
if (!is_numeric($startat)) $startat = 0;
if (!is_numeric($caches_per_page)) $caches_per_page = 20;
$startat = floor($startat / $caches_per_page) * $caches_per_page;
$sql .= ' LIMIT ' . $startat . ', ' . $caches_per_page;
$nRowIndex = 0;
$rs_caches = sql_slave($sql, $sqldebug);
$resultcount = sql_value_slave('SELECT FOUND_ROWS()', 0);
tpl_set_var('results_count', $resultcount);
while ($caches_record = sql_fetch_array($rs_caches))
{
$tmpline = $cache_line;
list($iconname, $inactive) = getCacheIcon($usr['userid'], $caches_record['cache_id'], $caches_record['status'],
$caches_record['user_id'], $caches_record['icon_large']);
$tmpline = mb_ereg_replace('{icon_large}', $iconname, $tmpline);
$tmpline = mb_ereg_replace('{cachetype}', htmlspecialchars(t($caches_record['cacheTypeName']), ENT_COMPAT, 'UTF-8'), $tmpline);
// short_desc ermitteln TODO: nicht die erste sondern die richtige wählen
$rsdesc = sql_slave("SELECT `short_desc` FROM `cache_desc` WHERE `cache_id`='&1' LIMIT 1", $caches_record['cache_id']);
$desc_record = sql_fetch_array($rsdesc);
mysql_free_result($rsdesc);
$tmpline = mb_ereg_replace('{short_desc}', htmlspecialchars($desc_record['short_desc'], ENT_COMPAT, 'UTF-8'), $tmpline);
$dDiff = abs(dateDiff('d', $caches_record['date_created'], date('Y-m-d')));
if ($dDiff < $caches_olddays)
$tmpline = mb_ereg_replace('{new}', $caches_newstring, $tmpline);
else
$tmpline = mb_ereg_replace('{new}', '', $tmpline);
$tmpline = mb_ereg_replace('{diffpic}', icon_difficulty("diff", $caches_record['difficulty']), $tmpline);
$tmpline = mb_ereg_replace('{terrpic}', icon_difficulty("terr", $caches_record['terrain']), $tmpline);
$tmpline = mb_ereg_replace('{ratpic}', icon_rating($caches_record['founds'], $caches_record['topratings']), $tmpline);
if ($caches_record['oconly'] == 1)
$tmpline = mb_ereg_replace('{oconly}', $caches_oconlystring, $tmpline);
else
$tmpline = mb_ereg_replace('{oconly}', '', $tmpline);
// das letzte found suchen
$sql = 'SELECT `cache_logs`.`id` `id`, `cache_logs`.`type` `type`, `cache_logs`.`date` `date`, `log_types`.`icon_small` `icon_small`
FROM `cache_logs`, `log_types`
WHERE `cache_logs`.`cache_id`=\'' . sql_escape($caches_record['cache_id']) . '\'
AND `log_types`.`id`=`cache_logs`.`type`
ORDER BY `cache_logs`.`date` DESC LIMIT 6';
$result = sql_slave($sql);
if ($row = sql_fetch_array($result))
{
$tmpline = mb_ereg_replace('{logimage1}',
icon_log_type($row['icon_small'], ""). '<a href=\'viewlogs.php?cacheid='.htmlspecialchars($caches_record['cache_id'], ENT_COMPAT, 'UTF-8').'#'.htmlspecialchars($row['id'], ENT_COMPAT, 'UTF-8').'\'>{gray_s}' .date($logdateformat, strtotime($row['date'])) . '{gray_e}</a>', $tmpline);
$tmpline = mb_ereg_replace('{logdate1}', "", $tmpline);
}
else
{
$tmpline = mb_ereg_replace('{logimage1}', "<img src='images/trans.gif' border='0' width='16' height='16' />", $tmpline);
$tmpline = mb_ereg_replace('{logdate1}', "--.--.----", $tmpline);
}
$lastlogs = "";
while ($row = sql_fetch_array($result))
{
$lastlogs .= '<a href=\'viewlogs.php?cacheid=' . urlencode($caches_record['cache_id']) . '#' . htmlspecialchars($row['id'], ENT_COMPAT, 'UTF-8') . '\'>' . icon_log_type($row['icon_small'], '') . '</a>&nbsp;';
}
$tmpline = mb_ereg_replace('{lastlogs}', $lastlogs, $tmpline);
// 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);
}
else
$tmpline = mb_ereg_replace('{direction}', '', $tmpline);
$desclangs = '';
$aLangs = mb_split(',', $caches_record['desc_languages']);
foreach ($aLangs AS $thislang)
{
$desclangs .= '<a href="viewcache.php?cacheid=' . urlencode($caches_record['cache_id']) . '&desclang=' . urlencode($thislang) . '" style="text-decoration:none;"><b><font color="blue">' . htmlspecialchars($thislang, ENT_COMPAT, 'UTF-8') . '</font></b></a> ';
}
$tmpline = mb_ereg_replace('{desclangs}', $desclangs, $tmpline);
$tmpline = mb_ereg_replace('{cachename}', htmlspecialchars($caches_record['name'], ENT_COMPAT, 'UTF-8'), $tmpline);
$tmpline = mb_ereg_replace('{urlencode_cacheid}', htmlspecialchars(urlencode($caches_record['cache_id']), ENT_COMPAT, 'UTF-8'), $tmpline);
$tmpline = mb_ereg_replace('{urlencode_userid}', htmlspecialchars(urlencode($caches_record['user_id']), ENT_COMPAT, 'UTF-8'), $tmpline);
$tmpline = mb_ereg_replace('{username}', htmlspecialchars($caches_record['username'], ENT_COMPAT, 'UTF-8'), $tmpline);
$tmpline = mb_ereg_replace('{distance}', htmlspecialchars(sprintf("%01.1f", $caches_record['distance']), ENT_COMPAT, 'UTF-8'), $tmpline);
$tmpline = mb_ereg_replace('{position}', $nRowIndex + $startat + 1, $tmpline);
// backgroundcolor of line
if (($nRowIndex % 2) == 1) $bgcolor = $bgcolor2;
else $bgcolor = $bgcolor1;
if($inactive)
{
//$bgcolor = $bgcolor_inactive;
$tmpline = mb_ereg_replace('{gray_s}', "<span class='text_gray'>", $tmpline);
$tmpline = mb_ereg_replace('{gray_e}', "</span>", $tmpline);
}
else
{
$tmpline = mb_ereg_replace('{gray_s}', "", $tmpline);
$tmpline = mb_ereg_replace('{gray_e}', "", $tmpline);
}
$tmpline = mb_ereg_replace('{bgcolor}', $bgcolor, $tmpline);
$nRowIndex++;
$caches_output .= $tmpline;
}
mysql_free_result($rs_caches);
tpl_set_var('results', $caches_output);
//more than one page?
if ($startat > 0)
{
$pages = t('Seite:') . ' <a href="search.php?queryid=' . $options['queryid'] . '&startat=0">&lt;&lt;</a> <a href="search.php?queryid=' . $options['queryid'] . '&startat=' . ($startat - $caches_per_page) . '">&lt;</a> ';
}
else
{
$pages = t('Seite:') . ' &lt;&lt; &lt; ';
}
$frompage = ($startat / $caches_per_page) - 3;
if ($frompage < 1) $frompage = 1;
$maxpage = ceil($resultcount / $caches_per_page);
$topage = $frompage + 8;
if ($topage > $maxpage) $topage = $maxpage;
for ($i = $frompage; $i <= $topage; $i++)
{
if (($startat / $caches_per_page + 1) == $i)
{
$pages .= ' <b>' . $i . '</b>';
}
else
{
$pages .= ' <a href="search.php?queryid=' . $options['queryid'] . '&startat=' . (($i - 1) * $caches_per_page) . '">' . $i . '</a>';
}
}
if ($startat / $caches_per_page < ($maxpage - 1))
{
$pages .= ' <a href="search.php?queryid=' . $options['queryid'] . '&startat=' . ($startat + $caches_per_page) . '">&gt;</a> <a href="search.php?queryid=' . $options['queryid'] . '&startat=' . (($maxpage - 1) * $caches_per_page) . '">&gt;&gt;</a> ';
}
else
{
$pages .= ' &gt; &gt;&gt;';
}
//'<a href="search.php?queryid=' . $options['queryid'] . '&startat=20">20</a> 40 60 80 100';
//$caches_per_page
//count($caches) - 1
tpl_set_var('pages', $pages);
// speichern-link
if ($usr === false)
tpl_set_var('safelink', '');
else
tpl_set_var('safelink', mb_ereg_replace('{queryid}', $options['queryid'], $safelink));
// downloads
tpl_set_var('queryid', $options['queryid']);
tpl_set_var('startat', $startat);
tpl_set_var('startatp1', $startat + 1);
if (($resultcount - $startat) < 500)
tpl_set_var('endat', $startat + $resultcount - $startat);
else
tpl_set_var('endat', $startat + 500);
// kompatibilität!
if ($distance_unit == 'sm')
tpl_set_var('distanceunit', 'mi');
else if ($distance_unit == 'nm')
tpl_set_var('distanceunit', 'sm');
else
tpl_set_var('distanceunit', $distance_unit);
if ($sqldebug == true)
sqldbg_end();
else
tpl_BuildTemplate();
?>
+161
View File
@@ -0,0 +1,161 @@
<?php
/***************************************************************************
./lib/search.inc.php
--------------------
begin : Sun September 25 2005
copyright : (C) 2005 The OpenCaching Group
forum contact at : http://www.opencaching.com/phpBB2
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
/****************************************************************************
Unicode Reminder メモ
functions for the search-engine
****************************************************************************/
/* begin conversion rules */
$search_simplerules[] = array('qu', 'k');
$search_simplerules[] = array('ts', 'z');
$search_simplerules[] = array('tz', 'z');
$search_simplerules[] = array('alp', 'alb');
$search_simplerules[] = array('y', 'i');
$search_simplerules[] = array('ai', 'ei');
$search_simplerules[] = array('ou', 'u');
$search_simplerules[] = array('th', 't');
$search_simplerules[] = array('ph', 'f');
$search_simplerules[] = array('oh', 'o');
$search_simplerules[] = array('ah', 'a');
$search_simplerules[] = array('eh', 'e');
$search_simplerules[] = array('aux', 'o');
$search_simplerules[] = array('eau', 'o');
$search_simplerules[] = array('eux', 'oe');
$search_simplerules[] = array('^ch', 'sch');
$search_simplerules[] = array('ck', 'k');
$search_simplerules[] = array('ie', 'i');
$search_simplerules[] = array('ih', 'i');
$search_simplerules[] = array('ent', 'end');
$search_simplerules[] = array('uh', 'u');
$search_simplerules[] = array('sh', 'sch');
$search_simplerules[] = array('ver', 'wer');
$search_simplerules[] = array('dt', 't');
$search_simplerules[] = array('hard', 'hart');
$search_simplerules[] = array('egg', 'ek');
$search_simplerules[] = array('eg', 'ek');
$search_simplerules[] = array('cr', 'kr');
$search_simplerules[] = array('ca', 'ka');
$search_simplerules[] = array('ce', 'ze');
$search_simplerules[] = array('x', 'ks');
$search_simplerules[] = array('ve', 'we');
$search_simplerules[] = array('va', 'wa');
/* end conversion rules */
function search_text2simple($str)
{
global $search_simplerules;
$str = search_text2sort($str);
// regeln anwenden
foreach ($search_simplerules AS $rule)
{
$str = mb_ereg_replace($rule[0], $rule[1], $str);
}
// doppelte chars ersetzen
for ($c = ord('a'); $c <= ord('z'); $c++)
$str = mb_ereg_replace(chr($c) . chr($c), chr($c), $str);
return $str;
}
function search_text2sort($str)
{
$str = mb_strtolower($str);
// alles was nicht a-z ist ersetzen
$str = mb_ereg_replace('0', '', $str);
$str = mb_ereg_replace('1', '', $str);
$str = mb_ereg_replace('2', '', $str);
$str = mb_ereg_replace('3', '', $str);
$str = mb_ereg_replace('4', '', $str);
$str = mb_ereg_replace('5', '', $str);
$str = mb_ereg_replace('6', '', $str);
$str = mb_ereg_replace('7', '', $str);
$str = mb_ereg_replace('8', '', $str);
$str = mb_ereg_replace('9', '', $str);
// deutsches
$str = mb_ereg_replace('ä', 'ae', $str);
$str = mb_ereg_replace('ö', 'oe', $str);
$str = mb_ereg_replace('ü', 'ue', $str);
$str = mb_ereg_replace('Ä', 'ae', $str);
$str = mb_ereg_replace('Ö', 'oe', $str);
$str = mb_ereg_replace('Ü', 'ue', $str);
$str = mb_ereg_replace('ß', 'ss', $str);
// akzente usw.
$str = mb_ereg_replace('à', 'a', $str);
$str = mb_ereg_replace('á', 'a', $str);
$str = mb_ereg_replace('â', 'a', $str);
$str = mb_ereg_replace('è', 'e', $str);
$str = mb_ereg_replace('é', 'e', $str);
$str = mb_ereg_replace('ë', 'e', $str);
$str = mb_ereg_replace('É', 'e', $str);
$str = mb_ereg_replace('ô', 'o', $str);
$str = mb_ereg_replace('ó', 'o', $str);
$str = mb_ereg_replace('ò', 'o', $str);
$str = mb_ereg_replace('ê', 'e', $str);
$str = mb_ereg_replace('ě', 'e', $str);
$str = mb_ereg_replace('û', 'u', $str);
$str = mb_ereg_replace('ç', 'c', $str);
$str = mb_ereg_replace('c', 'c', $str);
$str = mb_ereg_replace('ć', 'c', $str);
$str = mb_ereg_replace('î', 'i', $str);
$str = mb_ereg_replace('ï', 'i', $str);
$str = mb_ereg_replace('ì', 'i', $str);
$str = mb_ereg_replace('í', 'i', $str);
$str = mb_ereg_replace('ł', 'l', $str);
$str = mb_ereg_replace('š', 's', $str);
$str = mb_ereg_replace('Š', 's', $str);
$str = mb_ereg_replace('u', 'u', $str);
$str = mb_ereg_replace('ý', 'y', $str);
$str = mb_ereg_replace('ž', 'z', $str);
$str = mb_ereg_replace('Ž', 'Z', $str);
$str = mb_ereg_replace('Æ', 'ae', $str);
$str = mb_ereg_replace('æ', 'ae', $str);
$str = mb_ereg_replace('œ', 'oe', $str);
// interpunktion
$str = mb_ereg_replace('\\?', '', $str);
$str = mb_ereg_replace('\\)', '', $str);
$str = mb_ereg_replace('\\(', '', $str);
$str = mb_ereg_replace('\\.', ' ', $str);
$str = mb_ereg_replace('´', ' ', $str);
$str = mb_ereg_replace('`', ' ', $str);
$str = mb_ereg_replace('\'', ' ', $str);
// sonstiges
$str = str_replace('', '', $str);
// der rest
$str = mb_ereg_replace('[^a-z]', '', $str);
return $str;
}
?>
+352
View File
@@ -0,0 +1,352 @@
<?php
/***************************************************************************
./lib/search.kml.inc.php
-------------------
begin : November 1 2005
copyright : (C) 2005 The OpenCaching Group
forum contact at : http://www.opencaching.com/phpBB2
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
/****************************************************************************
Unicode Reminder メモ
kml search output
****************************************************************************/
global $content, $bUseZip, $sqldebug;
$kmlLine =
'
<Placemark>
<description><![CDATA[<a href="http://www.opencaching.de/viewcache.php?cacheid={cacheid}">Beschreibung ansehen</a><br>Von {username}<br>&nbsp;<br><table cellspacing="0" cellpadding="0" border="0"><tr><td>{typeimgurl} </td><td>Art: {type}<br>Größe: {size}</td></tr><tr><td colspan="2">Schwierigkeit: {difficulty} von 5.0<br>Gelände: {terrain} von 5.0</td></tr></table>]]></description>
<name>{name}</name>
<LookAt>
<longitude>{lon}</longitude>
<latitude>{lat}</latitude>
<range>5000</range>
<tilt>0</tilt>
<heading>3</heading>
</LookAt>
<styleUrl>#{icon}</styleUrl>
<Point>
<coordinates>{lon},{lat},0</coordinates>
</Point>
<Snippet>D: {difficulty}/T: {terrain} {size} von {username}</Snippet>
</Placemark>
';
$kmlFoot = '</Folder></Document></kml>';
$kmlTimeFormat = 'Y-m-d\TH:i:s\Z';
//prepare the output
$caches_per_page = 20;
$sql = 'SELECT ';
if (isset($lat_rad) && isset($lon_rad))
{
$sql .= getSqlDistanceFormula($lon_rad * 180 / 3.14159, $lat_rad * 180 / 3.14159, 0, $multiplier[$distance_unit]) . ' `distance`, ';
}
else
{
if ($usr === false)
{
$sql .= '0 distance, ';
}
else
{
//get the users home coords
$rs_coords = sql_slave("SELECT `latitude`, `longitude` FROM `user` WHERE `user_id`='&1'", $usr['userid']);
$record_coords = sql_fetch_array($rs_coords);
if ((($record_coords['latitude'] == NULL) || ($record_coords['longitude'] == NULL)) || (($record_coords['latitude'] == 0) || ($record_coords['longitude'] == 0)))
{
$sql .= '0 distance, ';
}
else
{
//TODO: load from the users-profile
$distance_unit = 'km';
$lon_rad = $record_coords['longitude'] * 3.14159 / 180;
$lat_rad = $record_coords['latitude'] * 3.14159 / 180;
$sql .= getSqlDistanceFormula($record_coords['longitude'], $record_coords['latitude'], 0, $multiplier[$distance_unit]) . ' `distance`, ';
}
mysql_free_result($rs_coords);
}
}
$sAddJoin = '';
$sAddGroupBy = '';
$sAddField = '';
$sGroupBy = '';
if ($options['sort'] == 'bylastlog')
{
$sAddField = ', MAX(`cache_logs`.`date`) AS `lastLog`';
$sAddJoin = ' LEFT JOIN `cache_logs` ON `caches`.`cache_id`=`cache_logs`.`cache_id`';
$sGroupBy = ' GROUP BY `cache_logs`.`cache_id`';
}
$sql .= '`caches`.`cache_id` `cache_id`, `caches`.`status` `status`, `caches`.`type` `type`, `caches`.`size` `size`, `caches`.`longitude` `longitude`, `caches`.`latitude` `latitude`, `caches`.`user_id` `user_id`,
IF(IFNULL(`stat_caches`.`toprating`,0)>3, 4, IFNULL(`stat_caches`.`toprating`, 0)) `ratingvalue`' .
$sAddField
. ' FROM `caches`
LEFT JOIN `stat_caches` ON `caches`.`cache_id`=`stat_caches`.`cache_id`' .
$sAddJoin
. ' WHERE `caches`.`cache_id` IN (' . $sqlFilter . ')' .
$sGroupBy;
$sortby = $options['sort'];
$sql .= ' ORDER BY ';
if ($options['orderRatingFirst'])
$sql .= '`ratingvalue` DESC, ';
if ($sortby == 'bylastlog')
{
$sql .= '`lastLog` DESC, ';
$sortby = 'bydistance';
}
if (isset($lat_rad) && isset($lon_rad) && ($sortby == 'bydistance'))
{
$sql .= '`distance` ASC';
}
else if ($sortby == 'bycreated')
{
$sql .= '`caches`.`date_created` DESC';
}
else // by name
{
$sql .= '`caches`.`name` ASC';
}
//startat?
$startat = isset($_REQUEST['startat']) ? $_REQUEST['startat'] : 0;
if (!is_numeric($startat)) $startat = 0;
if (isset($_REQUEST['count']))
$count = $_REQUEST['count'];
else
$count = $caches_per_page;
if ($count == 'max') $count = 500;
if (!is_numeric($count)) $count = 0;
if ($count < 1) $count = 1;
if ($count > 500) $count = 500;
$sqlLimit = ' LIMIT ' . $startat . ', ' . $count;
// temporäre tabelle erstellen
sql_slave('CREATE TEMPORARY TABLE `kmlcontent` ' . $sql . $sqlLimit);
$rsCount = sql_slave('SELECT COUNT(*) `count` FROM `kmlcontent`');
$rCount = sql_fetch_array($rsCount);
mysql_free_result($rsCount);
if ($rCount['count'] == 1)
{
$rsName = sql_slave('SELECT `caches`.`wp_oc` `wp_oc` FROM `kmlcontent`, `caches` WHERE `kmlcontent`.`cache_id`=`caches`.`cache_id` LIMIT 1');
$rName = sql_fetch_array($rsName);
mysql_free_result($rsName);
$sFilebasename = $rName['wp_oc'];
}
else
$sFilebasename = 'ocde' . $options['queryid'];
$bUseZip = ($rCount['count'] > 20);
$bUseZip = $bUseZip || (isset($_REQUEST['zip']) && ($_REQUEST['zip'] == '1'));
if ($bUseZip == true)
{
$content = '';
require_once($rootpath . 'lib/phpzip/ss_zip.class.php');
$phpzip = new ss_zip('',6);
}
// ok, ausgabe starten
if ($sqldebug == false)
{
if ($bUseZip == true)
{
header("Content-Type: application/vnd.google-earth.kmz");
header('Content-Disposition: attachment; filename=' . $sFilebasename . '.kmz');
}
else
{
header("Content-Type: application/vnd.google-earth.kml");
header("Content-Disposition: attachment; filename=" . $sFilebasename . ".kml");
}
}
$kmlDetailHead = read_file($stylepath . '/search.result.caches.kml.head.tpl.php');
$rsMinMax = sql_slave('SELECT MIN(`longitude`) `minlon`, MAX(`longitude`) `maxlon`, MIN(`latitude`) `minlat`, MAX(`latitude`) `maxlat` FROM `kmlcontent`', $sqldebug);
$rMinMax = sql_fetch_array($rsMinMax);
mysql_free_result($rsMinMax);
$kmlDetailHead = mb_ereg_replace('{minlat}', $rMinMax['minlat'], $kmlDetailHead);
$kmlDetailHead = mb_ereg_replace('{minlon}', $rMinMax['minlon'], $kmlDetailHead);
$kmlDetailHead = mb_ereg_replace('{maxlat}', $rMinMax['maxlat'], $kmlDetailHead);
$kmlDetailHead = mb_ereg_replace('{maxlon}', $rMinMax['maxlon'], $kmlDetailHead);
$kmlDetailHead = mb_ereg_replace('{time}', date($kmlTimeFormat), $kmlDetailHead);
append_output($kmlDetailHead);
// ok, ausgabe ...
/*
wp
name
username
type
size
lon
lat
icon
*/
$rs = sql_slave('SELECT SQL_BUFFER_RESULT `kmlcontent`.`cache_id` `cacheid`, `kmlcontent`.`longitude` `longitude`, `kmlcontent`.`latitude` `latitude`, `kmlcontent`.`type` `type`, `caches`.`date_hidden` `date_hidden`, `caches`.`name` `name`, `caches`.`status` `status`, `cache_type`.`de` `typedesc`, `cache_size`.`de` `sizedesc`, `caches`.`terrain` `terrain`, `caches`.`difficulty` `difficulty`, `user`.`username` `username` FROM `kmlcontent`, `caches`, `cache_type`, `cache_size`, `user` WHERE `kmlcontent`.`cache_id`=`caches`.`cache_id` AND `kmlcontent`.`type`=`cache_type`.`id` AND `kmlcontent`.`size`=`cache_size`.`id` AND `kmlcontent`.`user_id`=`user`.`user_id`', $sqldebug);
while($r = sql_fetch_array($rs))
{
$thisline = $kmlLine;
// icon suchen
switch ($r['type'])
{
case 2:
$icon = 'tradi';
$typeimgurl = '<img src="http://www.opencaching.de/resource2/ocstyle/images/cacheicon/traditional.gif" alt="Normaler Cache" title="Normaler Cache" />';
break;
case 3:
$icon = 'multi';
$typeimgurl = '<img src="http://www.opencaching.de/resource2/ocstyle/images/cacheicon/multi.gif" alt="Multicache" title="Multicache" />';
break;
case 4:
$icon = 'virtual';
$typeimgurl = '<img src="http://www.opencaching.de/resource2/ocstyle/images/cacheicon/virtual.gif" alt="virtueller Cache" title="virtueller Cache" />';
break;
case 5:
$icon = 'webcam';
$typeimgurl = '<img src="http://www.opencaching.de/resource2/ocstyle/images/cacheicon/webcam.gif" alt="Webcam Cache" title="Webcam Cache" />';
break;
case 6:
$icon = 'event';
$typeimgurl = '<img src="http://www.opencaching.de/resource2/ocstyle/images/cacheicon/event.gif" alt="Event Cache" title="Event Cache" />';
break;
case 7:
$icon = 'mystery';
$typeimgurl = '<img src="http://www.opencaching.de/resource2/ocstyle/images/cacheicon/mystery.gif" alt="Rätselcache" title="Event Cache" />';
break;
case 8:
$icon = 'mathe';
$typeimgurl = '<img src="http://www.opencaching.de/resource2/ocstyle/images/cacheicon/mathe.gif" alt="Mathe-/Physik-Cache" title="Event Cache" />';
break;
case 9:
$icon = 'moving';
$typeimgurl = '<img src="http://www.opencaching.de/resource2/ocstyle/images/cacheicon/moving.gif" alt="Moving Cache" title="Event Cache" />';
break;
case 10:
$icon = 'drivein';
$typeimgurl = '<img src="http://www.opencaching.de/resource2/ocstyle/images/cacheicon/drivein.gif" alt="Drive-In Cache" title="Event Cache" />';
break;
default:
$icon = 'other';
$typeimgurl = '<img src="http://www.opencaching.de/resource2/ocstyle/images/cacheicon/unknown.gif" alt="unbekannter Cachetyp" title="unbekannter Cachetyp" />';
break;
}
$thisline = mb_ereg_replace('{icon}', $icon, $thisline);
$thisline = mb_ereg_replace('{typeimgurl}', $typeimgurl, $thisline);
$lat = sprintf('%01.5f', $r['latitude']);
$thisline = mb_ereg_replace('{lat}', $lat, $thisline);
$lon = sprintf('%01.5f', $r['longitude']);
$thisline = mb_ereg_replace('{lon}', $lon, $thisline);
$time = date($kmlTimeFormat, strtotime($r['date_hidden']));
$thisline = mb_ereg_replace('{time}', $time, $thisline);
$thisline = mb_ereg_replace('{name}', xmlentities($r['name']), $thisline);
if (($r['status'] == 2) || ($r['status'] == 3))
{
if ($r['status'] == 2)
$thisline = mb_ereg_replace('{archivedflag}', 'Momentan nicht verfügbar!, ', $thisline);
else
$thisline = mb_ereg_replace('{archivedflag}', 'Archiviert!, ', $thisline);
}
else
$thisline = mb_ereg_replace('{archivedflag}', '', $thisline);
$thisline = mb_ereg_replace('{type}', xmlentities($r['typedesc']), $thisline);
$thisline = mb_ereg_replace('{size}', xmlentities($r['sizedesc']), $thisline);
$difficulty = sprintf('%01.1f', $r['difficulty'] / 2);
$thisline = mb_ereg_replace('{difficulty}', $difficulty, $thisline);
$terrain = sprintf('%01.1f', $r['terrain'] / 2);
$thisline = mb_ereg_replace('{terrain}', $terrain, $thisline);
$time = date($kmlTimeFormat, strtotime($r['date_hidden']));
$thisline = mb_ereg_replace('{time}', $time, $thisline);
$thisline = mb_ereg_replace('{username}', xmlentities($r['username']), $thisline);
$thisline = mb_ereg_replace('{cacheid}', xmlentities($r['cacheid']), $thisline);
append_output($thisline);
}
mysql_free_result($rs);
append_output($kmlFoot);
if ($sqldebug == true) sqldbg_end();
// phpzip versenden
if ($bUseZip == true)
{
$phpzip->add_data($sFilebasename . '.kml', $content);
// use 'r'=raw instead of 'b'=browser: don't generate new header information!
echo $phpzip->save($sFilebasename . '.kmz', 'r');
}
exit;
function xmlentities($str)
{
$from[0] = '&'; $to[0] = '&amp;';
$from[1] = '<'; $to[1] = '&lt;';
$from[2] = '>'; $to[2] = '&gt;';
$from[3] = '"'; $to[3] = '&quot;';
$from[4] = '\''; $to[4] = '&apos;';
for ($i = 0; $i <= 4; $i++)
$str = mb_ereg_replace($from[$i], $to[$i], $str);
return $str;
}
function append_output($str)
{
global $content, $bUseZip, $sqldebug;
if ($sqldebug == true) return;
if ($bUseZip == true)
$content .= $str;
else
echo $str;
}
?>
+280
View File
@@ -0,0 +1,280 @@
<?php
/***************************************************************************
./lib/search.loc.inc.php
-------------------
begin : November 1 2005
copyright : (C) 2005 The OpenCaching Group
forum contact at : http://www.opencaching.com/phpBB2
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
/****************************************************************************
Unicode Reminder メモ
loc search output
****************************************************************************/
global $content, $bUseZip, $sqldebug;
$locHead = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><loc version="1.0" src="opencaching.de">' . "\n";
$locLine =
'
<waypoint>
<name id="{waypoint}"><![CDATA[{archivedflag}{name} by {username}]]></name>
<coord lat="{lat}" lon="{lon}"/>
<type>Geocache</type>
<link text="Beschreibung">http://www.opencaching.de/viewcache.php?cacheid={cacheid}</link>
</waypoint>
';
$locFoot = '</loc>';
//prepare the output
$caches_per_page = 20;
$sql = 'SELECT ';
if (isset($lat_rad) && isset($lon_rad))
{
$sql .= getSqlDistanceFormula($lon_rad * 180 / 3.14159, $lat_rad * 180 / 3.14159, 0, $multiplier[$distance_unit]) . ' `distance`, ';
}
else
{
if ($usr === false)
{
$sql .= '0 distance, ';
}
else
{
//get the users home coords
$rs_coords = sql_slave("SELECT `latitude`, `longitude` FROM `user` WHERE `user_id`='&1'", $usr['userid']);
$record_coords = sql_fetch_array($rs_coords);
if ((($record_coords['latitude'] == NULL) || ($record_coords['longitude'] == NULL)) || (($record_coords['latitude'] == 0) || ($record_coords['longitude'] == 0)))
{
$sql .= '0 distance, ';
}
else
{
//TODO: load from the users-profile
$distance_unit = 'km';
$lon_rad = $record_coords['longitude'] * 3.14159 / 180;
$lat_rad = $record_coords['latitude'] * 3.14159 / 180;
$sql .= getSqlDistanceFormula($record_coords['longitude'], $record_coords['latitude'], 0, $multiplier[$distance_unit]) . ' `distance`, ';
}
mysql_free_result($rs_coords);
}
}
$sAddJoin = '';
$sAddGroupBy = '';
$sAddField = '';
$sGroupBy = '';
if ($options['sort'] == 'bylastlog')
{
$sAddField = ', MAX(`cache_logs`.`date`) AS `lastLog`';
$sAddJoin = ' LEFT JOIN `cache_logs` ON `caches`.`cache_id`=`cache_logs`.`cache_id`';
$sGroupBy = ' GROUP BY `cache_logs`.`cache_id`';
}
$sql .= '`caches`.`cache_id` `cache_id`, `caches`.`status` `status`, `caches`.`type` `type`, `caches`.`size` `size`, `caches`.`longitude` `longitude`, `caches`.`latitude` `latitude`, `caches`.`user_id` `user_id`,
IF(IFNULL(`stat_caches`.`toprating`,0)>3, 4, IFNULL(`stat_caches`.`toprating`, 0)) `ratingvalue`' .
$sAddField
. ' FROM `caches`
LEFT JOIN `stat_caches` ON `caches`.`cache_id`=`stat_caches`.`cache_id`' .
$sAddJoin
. ' WHERE `caches`.`cache_id` IN (' . $sqlFilter . ')' .
$sGroupBy;
$sortby = $options['sort'];
$sql .= ' ORDER BY ';
if ($options['orderRatingFirst'])
$sql .= '`ratingvalue` DESC, ';
if ($sortby == 'bylastlog')
{
$sql .= '`lastLog` DESC, ';
$sortby = 'bydistance';
}
if (isset($lat_rad) && isset($lon_rad) && ($sortby == 'bydistance'))
{
$sql .= '`distance` ASC';
}
else if ($sortby == 'bycreated')
{
$sql .= '`caches`.`date_created` DESC';
}
else // by name
{
$sql .= '`caches`.`name` ASC';
}
//startat?
$startat = isset($_REQUEST['startat']) ? $_REQUEST['startat'] : 0;
if (!is_numeric($startat)) $startat = 0;
if (isset($_REQUEST['count']))
$count = $_REQUEST['count'];
else
$count = $caches_per_page;
if ($count == 'max') $count = 500;
if (!is_numeric($count)) $count = 0;
if ($count < 1) $count = 1;
if ($count > 500) $count = 500;
$sqlLimit = ' LIMIT ' . $startat . ', ' . $count;
// temporäre tabelle erstellen
sql_slave('CREATE TEMPORARY TABLE `loccontent` ' . $sql . $sqlLimit, $sqldebug);
$rsCount = sql_slave('SELECT COUNT(*) `count` FROM `loccontent`');
$rCount = sql_fetch_array($rsCount);
mysql_free_result($rsCount);
if ($rCount['count'] == 1)
{
$rsName = sql_slave('SELECT `caches`.`wp_oc` `wp_oc` FROM `loccontent`, `caches` WHERE `loccontent`.`cache_id`=`caches`.`cache_id` LIMIT 1');
$rName = sql_fetch_array($rsName);
mysql_free_result($rsName);
$sFilebasename = $rName['wp_oc'];
}
else
$sFilebasename = 'ocde' . $options['queryid'];
$bUseZip = ($rCount['count'] > 20);
$bUseZip = $bUseZip || (isset($_REQUEST['zip']) ? $_REQUEST['zip'] == '1' : false);
if ($bUseZip == true)
{
$content = '';
require_once($rootpath . 'lib/phpzip/ss_zip.class.php');
$phpzip = new ss_zip('',6);
}
// ok, ausgabe starten
if ($sqldebug == false)
{
if ($bUseZip == true)
{
header("content-type: application/zip");
header('Content-Disposition: attachment; filename='. $sFilebasename . '.zip');
}
else
{
header("Content-type: application/loc");
header("Content-Disposition: attachment; filename=" . $sFilebasename . ".loc");
}
}
append_output($locHead);
// ok, ausgabe ...
/*
cacheid
name
lon
lat
archivedflag
type
size
difficulty
terrain
username
*/
$rs = sql_slave('SELECT SQL_BUFFER_RESULT `loccontent`.`cache_id` `cacheid`, `loccontent`.`longitude` `longitude`, `loccontent`.`latitude` `latitude`, `caches`.`date_hidden` `date_hidden`, `caches`.`name` `name`, `caches`.`status` `status`, `caches`.`wp_oc` `waypoint`, `cache_type`.`short` `typedesc`, `cache_size`.`de` `sizedesc`, `caches`.`terrain` `terrain`, `caches`.`difficulty` `difficulty`, `user`.`username` `username` FROM `loccontent`, `caches`, `cache_type`, `cache_size`, `user` WHERE `loccontent`.`cache_id`=`caches`.`cache_id` AND `loccontent`.`type`=`cache_type`.`id` AND `loccontent`.`size`=`cache_size`.`id` AND `loccontent`.`user_id`=`user`.`user_id`');
while($r = sql_fetch_array($rs))
{
$thisline = $locLine;
$lat = sprintf('%01.5f', $r['latitude']);
$thisline = mb_ereg_replace('{lat}', $lat, $thisline);
$lon = sprintf('%01.5f', $r['longitude']);
$thisline = mb_ereg_replace('{lon}', $lon, $thisline);
$thisline = mb_ereg_replace('{waypoint}', $r['waypoint'], $thisline);
$thisline = mb_ereg_replace('{name}', xmlentities($r['name']), $thisline);
if (($r['status'] == 2) || ($r['status'] == 3))
{
if ($r['status'] == 2)
$thisline = mb_ereg_replace('{archivedflag}', 'Momentan nicht verfügbar!, ', $thisline);
else
$thisline = mb_ereg_replace('{archivedflag}', 'Archiviert!, ', $thisline);
}
else
$thisline = mb_ereg_replace('{archivedflag}', '', $thisline);
$thisline = mb_ereg_replace('{type}', xmlentities($r['typedesc']), $thisline);
$thisline = mb_ereg_replace('{size}', xmlentities($r['sizedesc']), $thisline);
$difficulty = sprintf('%01.1f', $r['difficulty'] / 2);
$thisline = mb_ereg_replace('{difficulty}', $difficulty, $thisline);
$terrain = sprintf('%01.1f', $r['terrain'] / 2);
$thisline = mb_ereg_replace('{terrain}', $terrain, $thisline);
$thisline = mb_ereg_replace('{username}', xmlentities($r['username']), $thisline);
$thisline = mb_ereg_replace('{cacheid}', $r['cacheid'], $thisline);
append_output($thisline);
}
mysql_free_result($rs);
append_output($locFoot);
if ($sqldebug == true) sqldbg_end();
// phpzip versenden
if ($bUseZip == true)
{
$phpzip->add_data($sFilebasename . '.loc', $content);
echo $phpzip->save($sFilebasename . '.zip', 'b');
}
exit;
function xmlentities($str)
{
$from[0] = '&'; $to[0] = '&amp;';
$from[1] = '<'; $to[1] = '&lt;';
$from[2] = '>'; $to[2] = '&gt;';
$from[3] = '"'; $to[3] = '&quot;';
$from[4] = '\''; $to[4] = '&apos;';
for ($i = 0; $i <= 4; $i++)
$str = mb_ereg_replace($from[$i], $to[$i], $str);
return $str;
}
function append_output($str)
{
global $content, $bUseZip, $sqldebug;
if ($sqldebug == true) return;
if ($bUseZip == true)
$content .= $str;
else
echo $str;
}
?>
+40
View File
@@ -0,0 +1,40 @@
<?php
/***************************************************************************
./lib/search.ovl.inc.php
-------------------
begin : November 5 2005
copyright : (C) 2005 The OpenCaching Group
forum contact at : http://www.opencaching.com/phpBB2
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
/****************************************************************************
Unicode Reminder メモ
****************************************************************************/
// result already cached
if (sql_value_slave("SELECT COUNT(*) FROM `mapresult` WHERE `query_id`=" . ($options['queryid']+0), 0) > 0)
{
echo "READY";
exit;
}
sql_slave("CREATE TEMPORARY TABLE `tmpmapresult` (`query_id` INT UNSIGNED NOT NULL DEFAULT " . ($options['queryid']+0) . ", `cache_id` INT UNSIGNED NOT NULL, PRIMARY KEY (`query_id`, `cache_id`)) ENGINE=MEMORY");
sql_slave("INSERT INTO `tmpmapresult` (`cache_id`) " . $sqlFilter);
sql_slave("INSERT INTO `mapresult_data` (`query_id`, `cache_id`) SELECT `query_id`, `cache_id` FROM `tmpmapresult`");
sql_slave("INSERT INTO `mapresult` (`query_id`, `date_created`) VALUES ('&1', NOW())", $options['queryid']);
echo "READY";
exit;
?>
+42
View File
@@ -0,0 +1,42 @@
<?php
/***************************************************************************
* You can find the license in the docs directory
*
* Unicode Reminder メモ
*
* Execute search request for map.php
* (use caching of the same quries)
* TODO:cleanup
***************************************************************************/
global $dblink, $dbslaveid;
$sqlchecksum = sprintf('%u', crc32($sqlFilter));
/* config */
$opt['map']['maxcacheage'] = 3600;
// check if query was already executed within the cache period
$rsMapCache = sql("SELECT `result_id` FROM `map2_result` WHERE `sqlchecksum`='&1' AND DATE_ADD(`date_created`, INTERVAL '&2' SECOND)>NOW() AND `sqlquery`='&3'", $sqlchecksum, $opt['map']['maxcacheage'], $sqlFilter);
if ($rMapCache = sql_fetch_assoc($rsMapCache))
{
$resultId = $rMapCache['result_id'];
sql("UPDATE `map2_result` SET `shared_counter`=`shared_counter`+1 WHERE `result_id`='" . ($resultId+0) . "'");
}
else
{
db_connect_anyslave();
// ensure that query is performed without errors before reserving the result_id
sql_slave("CREATE TEMPORARY TABLE `tmpmapresult` (`cache_id` INT UNSIGNED NOT NULL, PRIMARY KEY (`cache_id`)) ENGINE=MEMORY");
sql_slave("INSERT INTO `tmpmapresult` (`cache_id`) " . $sqlFilter);
sql("INSERT INTO `map2_result` (`slave_id`, `sqlchecksum`, `sqlquery`, `date_created`, `date_lastqueried`) VALUES ('&1', '&2', '&3', NOW(), NOW())", $dbslaveid, $sqlchecksum, $sqlFilter);
$resultId = mysql_insert_id($dblink);
sql_slave("INSERT IGNORE INTO `map2_data` (`result_id`, `cache_id`) SELECT '&1', `cache_id` FROM `tmpmapresult`", $resultId);
sql_slave("DROP TEMPORARY TABLE `tmpmapresult`");
}
echo $resultId;
exit;
?>
+238
View File
@@ -0,0 +1,238 @@
<?php
/***************************************************************************
./lib/search.ov2.inc.php
-------------------
begin : November 2 2005
copyright : (C) 2005 The OpenCaching Group
forum contact at : http://www.opencaching.com/phpBB2
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
/****************************************************************************
Unicode Reminder メモ
ov2 search output
****************************************************************************/
global $content, $bUseZip, $sqldebug;
//prepare the output
$caches_per_page = 20;
$sql = 'SELECT ';
if (isset($lat_rad) && isset($lon_rad))
{
$sql .= getSqlDistanceFormula($lon_rad * 180 / 3.14159, $lat_rad * 180 / 3.14159, 0, $multiplier[$distance_unit]) . ' `distance`, ';
}
else
{
if ($usr === false)
{
$sql .= '0 distance, ';
}
else
{
//get the users home coords
$rs_coords = sql_slave("SELECT `latitude`, `longitude` FROM `user` WHERE `user_id`='&1'", $usr['userid']);
$record_coords = sql_fetch_array($rs_coords);
if ((($record_coords['latitude'] == NULL) || ($record_coords['longitude'] == NULL)) || (($record_coords['latitude'] == 0) || ($record_coords['longitude'] == 0)))
{
$sql .= '0 distance, ';
}
else
{
//TODO: load from the users-profile
$distance_unit = 'km';
$lon_rad = $record_coords['longitude'] * 3.14159 / 180;
$lat_rad = $record_coords['latitude'] * 3.14159 / 180;
$sql .= getSqlDistanceFormula($record_coords['longitude'], $record_coords['latitude'], 0, $multiplier[$distance_unit]) . ' `distance`, ';
}
mysql_free_result($rs_coords);
}
}
$sAddJoin = '';
$sAddGroupBy = '';
$sAddField = '';
if ($options['sort'] == 'bylastlog')
{
$sAddField = ', MAX(`cache_logs`.`date`) AS `lastLog`';
$sAddJoin = ' LEFT JOIN `cache_logs` ON `caches`.`cache_id`=`cache_logs`.`cache_id`';
$sGroupBy = ' GROUP BY `cache_logs`.`cache_id`';
}
$sql .= '`caches`.`cache_id` `cache_id`, `caches`.`status` `status`, `caches`.`type` `type`, `caches`.`size` `size`, `caches`.`longitude` `longitude`, `caches`.`latitude` `latitude`, `caches`.`user_id` `user_id`,
IF(IFNULL(`stat_caches`.`toprating`,0)>3, 4, IFNULL(`stat_caches`.`toprating`, 0)) `ratingvalue`' .
$sAddField
. ' FROM `caches`
LEFT JOIN `stat_caches` ON `caches`.`cache_id`=`stat_caches`.`cache_id`' .
$sAddJoin
. ' WHERE `caches`.`cache_id` IN (' . $sqlFilter . ')' .
$sGroupBy;
$sortby = $options['sort'];
$sql .= ' ORDER BY ';
if ($options['orderRatingFirst'])
$sql .= '`ratingvalue` DESC, ';
if ($sortby == 'bylastlog')
{
$sql .= '`lastLog` DESC, ';
$sortby = 'bydistance';
}
if (isset($lat_rad) && isset($lon_rad) && ($sortby == 'bydistance'))
{
$sql .= '`distance` ASC';
}
else if ($sortby == 'bycreated')
{
$sql .= '`caches`.`date_created` DESC';
}
else // by name
{
$sql .= '`caches`.`name` ASC';
}
//startat?
$startat = isset($_REQUEST['startat']) ? $_REQUEST['startat'] : 0;
if (!is_numeric($startat)) $startat = 0;
if (isset($_REQUEST['count']))
$count = $_REQUEST['count'];
else
$count = $caches_per_page;
if ($count == 'max') $count = 500;
if (!is_numeric($count)) $count = 0;
if ($count < 1) $count = 1;
if ($count > 500) $count = 500;
$sqlLimit = ' LIMIT ' . $startat . ', ' . $count;
// temporäre tabelle erstellen
sql_slave('CREATE TEMPORARY TABLE `ov2content` ' . $sql . $sqlLimit);
$rsCount = sql_slave('SELECT COUNT(*) `count` FROM `ov2content`');
$rCount = sql_fetch_array($rsCount);
mysql_free_result($rsCount);
if ($rCount['count'] == 1)
{
$rsName = sql_slave('SELECT `caches`.`wp_oc` `wp_oc` FROM `ov2content`, `caches` WHERE `ov2content`.`cache_id`=`caches`.`cache_id` LIMIT 1');
$rName = sql_fetch_array($rsName);
mysql_free_result($rsName);
$sFilebasename = $rName['wp_oc'];
}
else
$sFilebasename = 'ocde' . $options['queryid'];
$bUseZip = ($rCount['count'] > 20);
$bUseZip = $bUseZip || (isset($_REQUEST['zip']) ? $_REQUEST['zip'] == '1' : false);
if ($bUseZip == true)
{
$content = '';
require_once($opt['rootpath'] . 'lib/phpzip/ss_zip.class.php');
$phpzip = new ss_zip('',6);
}
// ok, ausgabe starten
if ($sqldebug == false)
{
if ($bUseZip == true)
{
header("content-type: application/zip");
header('Content-Disposition: attachment; filename=' . $sFilebasename . '.zip');
}
else
{
header("Content-type: application/ov2");
header("Content-Disposition: attachment; filename=" . $sFilebasename . ".ov2");
}
}
// ok, ausgabe ...
/*
cacheid
name
lon
lat
archivedflag
type
size
difficulty
terrain
username
*/
$sql = 'SELECT `ov2content`.`cache_id` `cacheid`, `ov2content`.`longitude` `longitude`, `ov2content`.`latitude` `latitude`, `caches`.`date_hidden` `date_hidden`, `caches`.`name` `name`, `caches`.`wp_oc` `wp_oc`, `cache_type`.`short` `typedesc`, `cache_size`.`de` `sizedesc`, `caches`.`terrain` `terrain`, `caches`.`difficulty` `difficulty`, `user`.`username` `username` FROM `ov2content`, `caches`, `cache_type`, `cache_size`, `user` WHERE `ov2content`.`cache_id`=`caches`.`cache_id` AND `ov2content`.`type`=`cache_type`.`id` AND `ov2content`.`size`=`cache_size`.`id` AND `ov2content`.`user_id`=`user`.`user_id`';
$rs = sql_slave($sql, $sqldebug);
while($r = sql_fetch_array($rs))
{
$lat = sprintf('%07d', $r['latitude'] * 100000);
$lon = sprintf('%07d', $r['longitude'] * 100000);
$name = convert_string($r['name']);
$username = convert_string($r['username']);
$type = convert_string($r['typedesc']);
$size = convert_string($r['sizedesc']);
$difficulty = sprintf('%01.1f', $r['difficulty'] / 2);
$terrain = sprintf('%01.1f', $r['terrain'] / 2);
$cacheid = convert_string($r['wp_oc']);
$line = "$name by $username, $type, $size, $cacheid";
$record = pack("CLllA*x", 2, 1 + 4 + 4 + 4 + strlen($line) + 1, (int)$lon, (int)$lat, $line);
append_output($record);
}
mysql_free_result($rs);
if ($sqldebug == true) sqldbg_end();
// phpzip versenden
if ($bUseZip == true)
{
$phpzip->add_data($sFilebasename . '.ov2', $content);
echo $phpzip->save($sFilebasename . '.zip', 'b');
}
exit;
function convert_string($str)
{
$newstr = iconv("UTF-8", "ISO-8859-1", $str);
if ($newstr == false)
return "--- charset error ---";
else
return $newstr;
}
function append_output($str)
{
global $content, $bUseZip, $sqldebug;
if ($sqldebug == true) return;
if ($bUseZip == true)
$content .= $str;
else
echo $str;
}
?>
+256
View File
@@ -0,0 +1,256 @@
<?php
/***************************************************************************
./lib/search.ovl.inc.php
-------------------
begin : November 5 2005
copyright : (C) 2005 The OpenCaching Group
forum contact at : http://www.opencaching.com/phpBB2
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
/****************************************************************************
Unicode Reminder メモ
ovl search output for TOP25, TOP50 etc.
****************************************************************************/
global $content, $bUseZip, $sqldebug;
$ovlLine = "[Symbol {symbolnr1}]\r\nTyp=6\r\nGroup=1\r\nWidth=20\r\nHeight=20\r\nDir=100\r\nArt=1\r\nCol=3\r\nZoom=1\r\nSize=103\r\nArea=2\r\nXKoord={lon}\r\nYKoord={lat}\r\n[Symbol {symbolnr2}]\r\nTyp=2\r\nGroup=1\r\nCol=3\r\nArea=1\r\nZoom=1\r\nSize=130\r\nFont=1\r\nDir=100\r\nXKoord={lonname}\r\nYKoord={latname}\r\nText={cachename}\r\n";
$ovlFoot = "[Overlay]\r\nSymbols={symbolscount}\r\n";
//prepare the output
$caches_per_page = 20;
$sql = 'SELECT ';
if (isset($lat_rad) && isset($lon_rad))
{
$sql .= getSqlDistanceFormula($lon_rad * 180 / 3.14159, $lat_rad * 180 / 3.14159, 0, $multiplier[$distance_unit]) . ' `distance`, ';
}
else
{
if ($usr === false)
{
$sql .= '0 distance, ';
}
else
{
//get the users home coords
$rs_coords = sql_slave("SELECT `latitude`, `longitude` FROM `user` WHERE `user_id`='&1'", $usr['userid']);
$record_coords = sql_fetch_array($rs_coords);
if ((($record_coords['latitude'] == NULL) || ($record_coords['longitude'] == NULL)) || (($record_coords['latitude'] == 0) || ($record_coords['longitude'] == 0)))
{
$sql .= '0 distance, ';
}
else
{
//TODO: load from the users-profile
$distance_unit = 'km';
$lon_rad = $record_coords['longitude'] * 3.14159 / 180;
$lat_rad = $record_coords['latitude'] * 3.14159 / 180;
$sql .= getSqlDistanceFormula($record_coords['longitude'], $record_coords['latitude'], 0, $multiplier[$distance_unit]) . ' `distance`, ';
}
mysql_free_result($rs_coords);
}
}
$sAddJoin = '';
$sAddGroupBy = '';
$sAddField = '';
$sGroupBy = '';
if ($options['sort'] == 'bylastlog')
{
$sAddField = ', MAX(`cache_logs`.`date`) AS `lastLog`';
$sAddJoin = ' LEFT JOIN `cache_logs` ON `caches`.`cache_id`=`cache_logs`.`cache_id`';
$sGroupBy = ' GROUP BY `cache_logs`.`cache_id`';
}
$sql .= '`caches`.`cache_id` `cache_id`, `caches`.`longitude` `longitude`, `caches`.`latitude` `latitude`,
IF(IFNULL(`stat_caches`.`toprating`,0)>3, 4, IFNULL(`stat_caches`.`toprating`, 0)) `ratingvalue`' .
$sAddField
. ' FROM `caches`
LEFT JOIN `stat_caches` ON `caches`.`cache_id`=`stat_caches`.`cache_id`' .
$sAddJoin
. ' WHERE `caches`.`cache_id` IN (' . $sqlFilter . ')' .
$sGroupBy;
$sortby = $options['sort'];
$sql .= ' ORDER BY ';
if ($options['orderRatingFirst'])
$sql .= '`ratingvalue` DESC, ';
if ($sortby == 'bylastlog')
{
$sql .= '`lastLog` DESC, ';
$sortby = 'bydistance';
}
if (isset($lat_rad) && isset($lon_rad) && ($sortby == 'bydistance'))
{
$sql .= '`distance` ASC';
}
else if ($sortby == 'bycreated')
{
$sql .= '`caches`.`date_created` DESC';
}
else // by name
{
$sql .= '`caches`.`name` ASC';
}
//startat?
$startat = isset($_REQUEST['startat']) ? $_REQUEST['startat'] : 0;
if (!is_numeric($startat)) $startat = 0;
if (isset($_REQUEST['count']))
$count = $_REQUEST['count'];
else
$count = $caches_per_page;
if ($count == 'max') $count = 500;
if (!is_numeric($count)) $count = 0;
if ($count < 1) $count = 1;
if ($count > 500) $count = 500;
$sqlLimit = ' LIMIT ' . $startat . ', ' . $count;
// temporäre tabelle erstellen
sql_slave('CREATE TEMPORARY TABLE `ovlcontent` ' . $sql . $sqlLimit, $sqldebug);
$rsCount = sql_slave('SELECT COUNT(*) `count` FROM `ovlcontent`');
$rCount = sql_fetch_array($rsCount);
mysql_free_result($rsCount);
if ($rCount['count'] == 1)
{
$rsName = sql_slave('SELECT `caches`.`wp_oc` `wp_oc` FROM `ovlcontent`, `caches` WHERE `ovlcontent`.`cache_id`=`caches`.`cache_id` LIMIT 1');
$rName = sql_fetch_array($rsName);
mysql_free_result($rsName);
$sFilebasename = $rName['wp_oc'];
}
else
$sFilebasename = 'ocde' . $options['queryid'];
$bUseZip = ($rCount['count'] > 20);
$bUseZip = $bUseZip || (isset($_REQUEST['zip']) && ($_REQUEST['zip'] == '1'));
if ($bUseZip == true)
{
$content = '';
require_once($opt['rootpath'] . 'lib/phpzip/ss_zip.class.php');
$phpzip = new ss_zip('',6);
}
// ok, ausgabe starten
if ($sqldebug == false)
{
if ($bUseZip == true)
{
header("content-type: application/zip");
header('Content-Disposition: attachment; filename=' . $sFilebasename . '.zip');
}
else
{
header("Content-type: application/ovl");
header("Content-Disposition: attachment; filename=" . $sFilebasename . ".ovl");
}
}
// ok, ausgabe ...
/*
{symbolnr1}
{lon}
{lat}
{symbolnr2}
{lonname}
{latname}
{cachename}
*/
$nr = 1;
$rs = sql_slave('SELECT SQL_BUFFER_RESULT `ovlcontent`.`cache_id` `cacheid`, `ovlcontent`.`longitude` `longitude`, `ovlcontent`.`latitude` `latitude`, `caches`.`name` `name` FROM `ovlcontent`, `caches` WHERE `ovlcontent`.`cache_id`=`caches`.`cache_id`');
while($r = sql_fetch_array($rs))
{
$thisline = $ovlLine;
$lat = sprintf('%01.5f', $r['latitude']);
$thisline = mb_ereg_replace('{lat}', $lat, $thisline);
$thisline = mb_ereg_replace('{latname}', $lat, $thisline);
$lon = sprintf('%01.5f', $r['longitude']);
$thisline = mb_ereg_replace('{lon}', $lon, $thisline);
$thisline = mb_ereg_replace('{lonname}', $lon, $thisline);
$thisline = mb_ereg_replace('{cachename}', convert_string($r['name']), $thisline);
$thisline = mb_ereg_replace('{symbolnr1}', $nr, $thisline);
$thisline = mb_ereg_replace('{symbolnr2}', $nr + 1, $thisline);
append_output($thisline);
$nr += 2;
}
mysql_free_result($rs);
$ovlFoot = mb_ereg_replace('{symbolscount}', $nr - 1, $ovlFoot);
append_output($ovlFoot);
if ($sqldebug == true) sqldbg_end();
// phpzip versenden
if ($bUseZip == true)
{
$phpzip->add_data($sFilebasename . '.ovl', $content);
echo $phpzip->save($sFilebasename . '.zip', 'b');
}
exit;
function convert_string($str)
{
$newstr = iconv("UTF-8", "ISO-8859-1", $str);
if ($newstr == false)
return $str;
else
return $newstr;
}
function xmlentities($str)
{
$from[0] = '&'; $to[0] = '&amp;';
$from[1] = '<'; $to[1] = '&lt;';
$from[2] = '>'; $to[2] = '&gt;';
$from[3] = '"'; $to[3] = '&quot;';
$from[4] = '\''; $to[4] = '&apos;';
for ($i = 0; $i <= 4; $i++)
$str = mb_ereg_replace($from[$i], $to[$i], $str);
return $str;
}
function append_output($str)
{
global $content, $bUseZip, $sqldebug;
if ($sqldebug == true) return;
if ($bUseZip == true)
$content .= $str;
else
echo $str;
}
?>
+316
View File
@@ -0,0 +1,316 @@
<?php
/***************************************************************************
./lib/search.gpx.inc.php
-------------------
begin : November 1 2005
copyright : (C) 2005 The OpenCaching Group
forum contact at : http://www.opencaching.com/phpBB2
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
/****************************************************************************
Unicode Reminder メモ
GPX search output
****************************************************************************/
global $content, $bUseZip, $sqldebug;
$txtLine = "Name: {cachename} von {owner}
Koordinaten: {lon} {lat}
Status: {status}
Versteckt am: {time}
Wegpunkt: {waypoint}
Land: {country}
Cacheart: {type}
Behälter: {container}
D/T: {difficulty}/{terrain}
Online: " . $absolute_server_URI . "viewcache.php?wp={waypoint}
Kurzbeschreibung: {shortdesc}
Beschreibung{htmlwarn}:
<===================>
{desc}
<===================>
Zusätzliche Hinweise:
<===================>
{hints}
<===================>
A|B|C|D|E|F|G|H|I|J|K|L|M
N|O|P|Q|R|S|T|U|V|W|X|Y|Z
Logeinträge:
{logs}
";
$txtLogs = "<===================>
{username} / {date} / {type}
{text}
";
//prepare the output
$caches_per_page = 20;
$sql = 'SELECT ';
if (isset($lat_rad) && isset($lon_rad))
{
$sql .= getSqlDistanceFormula($lon_rad * 180 / 3.14159, $lat_rad * 180 / 3.14159, 0, $multiplier[$distance_unit]) . ' `distance`, ';
}
else
{
if ($usr === false)
{
$sql .= '0 distance, ';
}
else
{
//get the users home coords
$rs_coords = sql_slave("SELECT `latitude`, `longitude` FROM `user` WHERE `user_id`='&1'", $usr['userid']);
$record_coords = sql_fetch_array($rs_coords);
if ((($record_coords['latitude'] == NULL) || ($record_coords['longitude'] == NULL)) || (($record_coords['latitude'] == 0) || ($record_coords['longitude'] == 0)))
{
$sql .= '0 distance, ';
}
else
{
//TODO: load from the users-profile
$distance_unit = 'km';
$lon_rad = $record_coords['longitude'] * 3.14159 / 180;
$lat_rad = $record_coords['latitude'] * 3.14159 / 180;
$sql .= getSqlDistanceFormula($record_coords['longitude'], $record_coords['latitude'], 0, $multiplier[$distance_unit]) . ' `distance`, ';
}
mysql_free_result($rs_coords);
}
}
$sAddJoin = '';
$sAddGroupBy = '';
$sAddField = '';
$sGroupBy = '';
if ($options['sort'] == 'bylastlog')
{
$sAddField = ', MAX(`cache_logs`.`date`) AS `lastLog`';
$sAddJoin = ' LEFT JOIN `cache_logs` ON `caches`.`cache_id`=`cache_logs`.`cache_id`';
$sGroupBy = ' GROUP BY `cache_logs`.`cache_id`';
}
$sql .= '`caches`.`cache_id` `cache_id`, `caches`.`status` `status`, `caches`.`type` `type`,
`caches`.`size` `size`, `caches`.`longitude` `longitude`, `caches`.`latitude` `latitude`,
`caches`.`user_id` `user_id`,
IF(IFNULL(`stat_caches`.`toprating`,0)>3, 4, IFNULL(`stat_caches`.`toprating`, 0)) `ratingvalue`' .
$sAddField
. ' FROM `caches`
LEFT JOIN `stat_caches` ON `caches`.`cache_id`=`stat_caches`.`cache_id`' .
$sAddJoin
. ' WHERE `caches`.`cache_id` IN (' . $sqlFilter . ')' .
$sGroupBy;
$sortby = $options['sort'];
$sql .= ' ORDER BY ';
if ($options['orderRatingFirst'])
$sql .= '`ratingvalue` DESC, ';
if ($sortby == 'bylastlog')
{
$sql .= '`lastLog` DESC, ';
$sortby = 'bydistance';
}
if (isset($lat_rad) && isset($lon_rad) && ($sortby == 'bydistance'))
{
$sql .= '`distance` ASC';
}
else if ($sortby == 'bycreated')
{
$sql .= '`caches`.`date_created` DESC';
}
else // by name
{
$sql .= '`caches`.`name` ASC';
}
//startat?
$startat = isset($_REQUEST['startat']) ? $_REQUEST['startat'] : 0;
if (!is_numeric($startat)) $startat = 0;
if (isset($_REQUEST['count']))
$count = $_REQUEST['count'];
else
$count = $caches_per_page;
if ($count == 'max') $count = 500;
if (!is_numeric($count)) $count = 0;
if ($count < 1) $count = 1;
if ($count > 500) $count = 500;
$sqlLimit = ' LIMIT ' . $startat . ', ' . $count;
// temporäre tabelle erstellen
sql_slave('CREATE TEMPORARY TABLE `txtcontent` ' . $sql . $sqlLimit, $sqldebug);
$rsCount = sql_slave('SELECT COUNT(*) `count` FROM `txtcontent`');
$rCount = sql_fetch_array($rsCount);
mysql_free_result($rsCount);
if ($rCount['count'] == 1)
{
$rsName = sql_slave('SELECT `caches`.`wp_oc` `wp_oc` FROM `txtcontent`, `caches` WHERE `txtcontent`.`cache_id`=`caches`.`cache_id` LIMIT 1');
$rName = sql_fetch_array($rsName);
mysql_free_result($rsName);
$sFilebasename = $rName['wp_oc'];
}
else
$sFilebasename = 'ocde' . $options['queryid'];
$bUseZip = ($rCount['count'] > 1);
$bUseZip = $bUseZip || (isset($_REQUEST['zip']) && ($_REQUEST['zip'] == '1'));
if ($bUseZip == true)
{
$content = '';
require_once($opt['rootpath'] . 'lib/phpzip/ss_zip.class.php');
$phpzip = new ss_zip('',6);
}
// ok, ausgabe starten
if ($sqldebug == false)
{
if ($bUseZip == true)
{
header("content-type: application/zip");
header('Content-Disposition: attachment; filename=' . $sFilebasename . '.zip');
}
else
{
header("Content-type: text/plain");
header("Content-Disposition: attachment; filename=" . $sFilebasename . ".txt");
}
}
// ok, ausgabe ...
$rs = sql_slave('SELECT SQL_BUFFER_RESULT `txtcontent`.`cache_id` `cacheid`, `txtcontent`.`longitude` `longitude`, `txtcontent`.`latitude` `latitude`, `caches`.`wp_oc` `waypoint`, `caches`.`date_hidden` `date_hidden`, `caches`.`name` `name`, `caches`.`country` `country`, `caches`.`terrain` `terrain`, `caches`.`difficulty` `difficulty`, `caches`.`desc_languages` `desc_languages`, `cache_size`.`de` `size`, `cache_type`.`de` `type`, `cache_status`.`de` `status`, `user`.`username` `username`, `cache_desc`.`desc` `desc`, `cache_desc`.`short_desc` `short_desc`, `cache_desc`.`hint` `hint`, `cache_desc`.`desc_html` `html` FROM `txtcontent`, `caches`, `user`, `cache_desc`, `cache_type`, `cache_status`, `cache_size` WHERE `txtcontent`.`cache_id`=`caches`.`cache_id` AND `caches`.`cache_id`=`cache_desc`.`cache_id` AND `caches`.`default_desclang`=`cache_desc`.`language` AND `txtcontent`.`user_id`=`user`.`user_id` AND `caches`.`type`=`cache_type`.`id` AND `caches`.`status`=`cache_status`.`id` AND `caches`.`size`=`cache_size`.`id`');
while($r = sql_fetch_array($rs))
{
$thisline = $txtLine;
$lat = sprintf('%01.5f', $r['latitude']);
$thisline = mb_ereg_replace('{lat}', help_latToDegreeStr($lat), $thisline);
$lon = sprintf('%01.5f', $r['longitude']);
$thisline = mb_ereg_replace('{lon}', help_lonToDegreeStr($lon), $thisline);
$time = date('d.m.Y', strtotime($r['date_hidden']));
$thisline = mb_ereg_replace('{time}', $time, $thisline);
$thisline = mb_ereg_replace('{waypoint}', $r['waypoint'], $thisline);
$thisline = mb_ereg_replace('{cacheid}', $r['cacheid'], $thisline);
$thisline = mb_ereg_replace('{cachename}', $r['name'], $thisline);
$thisline = mb_ereg_replace('{country}', db_CountryFromShort($r['country']), $thisline);
if ($r['hint'] == '')
$thisline = mb_ereg_replace('{hints}', '', $thisline);
else
$thisline = mb_ereg_replace('{hints}', str_rot13_html(strip_tags($r['hint'])), $thisline);
$thisline = mb_ereg_replace('{shortdesc}', $r['short_desc'], $thisline);
if ($r['html'] == 0)
{
$thisline = mb_ereg_replace('{htmlwarn}', '', $thisline);
$thisline = mb_ereg_replace('{desc}', strip_tags($r['desc']), $thisline);
}
else
{
$thisline = mb_ereg_replace('{htmlwarn}', ' (Vorsicht, aus HTML konvertiert)', $thisline);
$thisline = mb_ereg_replace('{desc}', html2txt($r['desc']), $thisline);
}
$thisline = mb_ereg_replace('{type}', $r['type'], $thisline);
$thisline = mb_ereg_replace('{container}', $r['size'], $thisline);
$thisline = mb_ereg_replace('{status}', $r['status'], $thisline);
$difficulty = sprintf('%01.1f', $r['difficulty'] / 2);
$thisline = mb_ereg_replace('{difficulty}', $difficulty, $thisline);
$terrain = sprintf('%01.1f', $r['terrain'] / 2);
$thisline = mb_ereg_replace('{terrain}', $terrain, $thisline);
$thisline = mb_ereg_replace('{owner}', $r['username'], $thisline);
// logs ermitteln
$logentries = '';
$rsLogs = sql_slave("SELECT `cache_logs`.`id`, `cache_logs`.`text_html`, `log_types`.`de` `type`, `cache_logs`.`date`, `cache_logs`.`text`, `user`.`username` FROM `cache_logs`, `user`, `log_types` WHERE `cache_logs`.`user_id`=`user`.`user_id` AND `cache_logs`.`type`=`log_types`.`id` AND `cache_logs`.`cache_id`=&1 ORDER BY `cache_logs`.`date` DESC LIMIT 20", $r['cacheid']);
while ($rLog = sql_fetch_array($rsLogs))
{
$thislog = $txtLogs;
$thislog = mb_ereg_replace('{id}', $rLog['id'], $thislog);
$thislog = mb_ereg_replace('{date}', date('d.m.Y', strtotime($rLog['date'])), $thislog);
$thislog = mb_ereg_replace('{username}', $rLog['username'], $thislog);
$logtype = $rLog['type'];
$thislog = mb_ereg_replace('{type}', $logtype, $thislog);
if ($rLog['text_html'] == 0)
$thislog = mb_ereg_replace('{text}', $rLog['text'], $thislog);
else
$thislog = mb_ereg_replace('{text}', html2txt($rLog['text']), $thislog);
$logentries .= $thislog . "\n";
}
$thisline = mb_ereg_replace('{logs}', $logentries, $thisline);
$thisline = lf2crlf($thisline);
if (($rCount['count'] == 1) && ($bUseZip == false))
echo $thisline;
else
{
$phpzip->add_data($r['waypoint'] . '.txt', $thisline);
}
}
mysql_free_result($rs);
if ($sqldebug == true) sqldbg_end();
// phpzip versenden
if ($bUseZip == true)
{
echo $phpzip->save($sFilebasename . '.zip', 'b');
}
exit;
function html2txt($html)
{
$str = mb_ereg_replace("\r\n", '', $html);
$str = mb_ereg_replace("\n", '', $str);
$str = mb_ereg_replace('<br />', "\n", $str);
$str = strip_tags($str);
return $str;
}
function lf2crlf($str)
{
return mb_ereg_replace("\r\r\n" ,"\r\n" , mb_ereg_replace("\n" ,"\r\n" , $str));
}
?>
+285
View File
@@ -0,0 +1,285 @@
<?php
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
/****************************************************************************
XML search output
****************************************************************************/
global $content, $bUseZip, $sqldebug;
$lang = 'DE';
$encoding = 'UTF-8';
$xmlLine = " <cache>
<name><![CDATA[{cachename}]]></name>
<owner id=\"{ownerid}\"><![CDATA[{owner}]]></owner>
<id>{cacheid}</id>
<waypoint>{waypoint}</waypoint>
<hidden>{time}</hidden>
<status id=\"{statusid}\">{status}</status>
<lon value=\"{lonvalue}\">{lon}</lon>
<lat value=\"{latvalue}\">{lat}</lat>
<distance unit=\"".$distance_unit."\">{distance}</distance>
<type id=\"{typeid}\">{type}</type>
<difficulty>{difficulty}</difficulty>
<terrain>{terrain}</terrain>
<size id=\"{sizeid}\">{container}</size>
<country id=\"{countryid}\">{country}</country>
<link><![CDATA[http://www.opencaching.de/viewcache.php?wp={waypoint}]]></link>
<desc><![CDATA[{shortdesc}]]></desc>
<hints><![CDATA[{hints}]]></hints>
</cache>
";
$txtLogs = "";
//prepare the output
$caches_per_page = 20;
$sql = 'SELECT SQL_BUFFER_RESULT SQL_CALC_FOUND_ROWS ';
if (isset($lat_rad) && isset($lon_rad))
{
$sql .= getSqlDistanceFormula($lon_rad * 180 / 3.14159, $lat_rad * 180 / 3.14159, 0, $multiplier[$distance_unit]) . ' `distance`, ';
}
else
{
if ($usr === false)
{
$sql .= '0 distance, ';
}
else
{
//get the users home coords
$rs_coords = sql_slave("SELECT `latitude`, `longitude` FROM `user` WHERE `user_id`='&1'", $usr['userid']);
$record_coords = sql_fetch_array($rs_coords);
if ((($record_coords['latitude'] == NULL) || ($record_coords['longitude'] == NULL)) || (($record_coords['latitude'] == 0) || ($record_coords['longitude'] == 0)))
{
$sql .= '0 distance, ';
}
else
{
//TODO: load from the users-profile
$distance_unit = 'km';
$lon_rad = $record_coords['longitude'] * 3.14159 / 180;
$lat_rad = $record_coords['latitude'] * 3.14159 / 180;
$sql .= getSqlDistanceFormula($record_coords['longitude'], $record_coords['latitude'], 0, $multiplier[$distance_unit]) . ' `distance`, ';
}
mysql_free_result($rs_coords);
}
}
$sql .= '`caches`.`cache_id` `cache_id`, `caches`.`status` `status`, `caches`.`type` `type`, `caches`.`size` `size`, `caches`.`longitude` `longitude`, `caches`.`latitude` `latitude`, `caches`.`user_id` `user_id`
FROM `caches`
WHERE `caches`.`cache_id` IN (' . $sqlFilter . ')';
$sortby = $options['sort'];
$sql .= ' ORDER BY ';
if ($options['orderRatingFirst'])
$sql .= '`ratingvalue` DESC, ';
if ($sortby == 'bylastlog')
{
$sql .= '`lastLog` DESC, ';
$sortby = 'bydistance';
}
if (isset($lat_rad) && isset($lon_rad) && ($sortby == 'bydistance'))
{
$sql .= '`distance` ASC';
}
else if ($sortby == 'bycreated')
{
$sql .= '`caches`.`date_created` DESC';
}
else // by name
{
$sql .= '`caches`.`name` ASC';
}
//startat?
$startat = isset($_REQUEST['startat']) ? $_REQUEST['startat'] : 0;
if (!is_numeric($startat)) $startat = 0;
if (isset($_REQUEST['count']))
$count = $_REQUEST['count'];
else
$count = $caches_per_page;
if ($count == 'max') $count = 500;
if (!is_numeric($count)) $count = 0;
if ($count < 1) $count = 1;
if ($count > 500) $count = 500;
$sqlLimit = ' LIMIT ' . $startat . ', ' . $count;
// create temporary table
sql_slave('CREATE TEMPORARY TABLE `xmlcontent` ' . $sql . $sqlLimit);
$resultcount = sql_value_slave('SELECT FOUND_ROWS()', 0);
$rsCount = sql_slave('SELECT COUNT(*) `count` FROM `xmlcontent`');
$rCount = sql_fetch_array($rsCount);
mysql_free_result($rsCount);
// ok, ausgabe starten
if ($sqldebug == false)
{
header("Content-type: application/xml; charset=".$encoding);
//header("Content-Disposition: attachment; filename=" . $sFilebasename . ".txt");
}
echo "<?xml version=\"1.0\" encoding=\"".$encoding."\"?>\n";
echo "<result>\n";
echo " <docinfo>\n";
echo " <results>" . $rCount['count'] . "</results>\n";
echo " <startat>" . $startat . "</startat>\n";
echo " <perpage>" . $count . "</perpage>\n";
echo " <total>" . $resultcount . "</total>\n";
echo " </docinfo>\n";
// ok, ausgabe ...
$rs = sql_slave('SELECT `xmlcontent`.`cache_id` `cacheid`,
`xmlcontent`.`longitude` `longitude`,
`xmlcontent`.`latitude` `latitude`,
`caches`.`wp_oc` `waypoint`,
`caches`.`date_hidden` `date_hidden`,
`caches`.`name` `name`,
`caches`.`country` `country`,
`caches`.`terrain` `terrain`,
`caches`.`difficulty` `difficulty`,
`caches`.`desc_languages` `desc_languages`,
`cache_size`.`name` `size`,
`cache_size`.`id` `size_id`,
`cache_type`.`name` `type`,
`cache_type`.`id` `type_id`,
`cache_status`.`name` `status`,
`cache_status`.`id` `status_id`,
`user`.`username` `username`,
`user`.`user_id` `user_id`,
`cache_desc`.`desc` `desc`,
`cache_desc`.`short_desc` `short_desc`,
`cache_desc`.`hint` `hint`,
`cache_desc`.`desc_html` `html`,
`xmlcontent`.`distance` `distance`
FROM `xmlcontent`
INNER JOIN `caches` ON `xmlcontent`.`cache_id`=`caches`.`cache_id`
INNER JOIN `user` ON `xmlcontent`.`user_id`=`user`.`user_id`
INNER JOIN `cache_desc` ON `caches`.`cache_id`=`cache_desc`.`cache_id` AND `caches`.`default_desclang`=`cache_desc`.`language`
INNER JOIN `cache_type` ON `caches`.`type`=`cache_type`.`id`
INNER JOIN `cache_status` ON `caches`.`status`=`cache_status`.`id`
INNER JOIN `cache_size` ON `caches`.`size`=`cache_size`.`id`');
while ($r = sql_fetch_array($rs))
{
$thisline = $xmlLine;
$lat = sprintf('%01.5f', $r['latitude']);
$thisline = str_replace('{lat}', help_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('{lonvalue}', $lon, $thisline);
$time = date('d.m.Y', strtotime($r['date_hidden']));
$thisline = str_replace('{time}', $time, $thisline);
$thisline = str_replace('{waypoint}', $r['waypoint'], $thisline);
$thisline = str_replace('{cacheid}', $r['cacheid'], $thisline);
$thisline = str_replace('{cachename}', filterevilchars($r['name']), $thisline);
$thisline = str_replace('{country}', db_CountryFromShort($r['country']), $thisline);
$thisline = str_replace('{countryid}', $r['country'], $thisline);
if ($r['hint'] == '')
$thisline = str_replace('{hints}', '', $thisline);
else
$thisline = str_replace('{hints}', str_rot13_html(filterevilchars(strip_tags($r['hint']))), $thisline);
$thisline = str_replace('{shortdesc}', filterevilchars($r['short_desc']), $thisline);
if ($r['html'] == 0)
{
$thisline = str_replace('{htmlwarn}', '', $thisline);
$thisline = str_replace('{desc}', filterevilchars(strip_tags($r['desc'])), $thisline);
}
else
{
$thisline = str_replace('{htmlwarn}', ' (Text pøeveden z HTML)', $thisline);
$thisline = str_replace('{desc}', html2txt(filterevilchars($r['desc'])), $thisline);
}
$thisline = str_replace('{type}', $r['type'], $thisline);
$thisline = str_replace('{typeid}', $r['type_id'], $thisline);
$thisline = str_replace('{container}', $r['size'], $thisline);
$thisline = str_replace('{sizeid}', $r['size_id'], $thisline);
$thisline = str_replace('{status}', $r['status'], $thisline);
$thisline = str_replace('{statusid}', $r['status_id'], $thisline);
$difficulty = sprintf('%01.1f', $r['difficulty'] / 2);
$thisline = str_replace('{difficulty}', $difficulty, $thisline);
$terrain = sprintf('%01.1f', $r['terrain'] / 2);
$thisline = str_replace('{terrain}', $terrain, $thisline);
$thisline = str_replace('{owner}', filterevilchars($r['username']), $thisline);
$thisline = str_replace('{ownerid}', filterevilchars($r['user_id']), $thisline);
$thisline = str_replace('{distance}', htmlspecialchars(sprintf("%01.1f", $r['distance'])), $thisline);
$thisline = lf2crlf($thisline);
echo $thisline;
}
mysql_free_result($rs);
sql_slave('DROP TABLE `xmlcontent` ');
if ($sqldebug == true) sqldbg_end();
echo "</result>\n";
exit;
function html2txt($html)
{
$str = str_replace("\r\n", '', $html);
$str = str_replace("\n", '', $str);
$str = str_replace('<br />', "\n", $str);
$str = strip_tags($str);
return $str;
}
function lf2crlf($str)
{
return str_replace("\r\r\n" ,"\r\n" , str_replace("\n" ,"\r\n" , $str));
}
function filterevilchars($str)
{
$evilchars = array(31 => 31, 30 => 30,
29 => 29, 28 => 28, 27 => 27, 26 => 26, 25 => 25, 24 => 24,
23 => 23, 22 => 22, 21 => 21, 20 => 20, 19 => 19, 18 => 18,
17 => 17, 16 => 16, 15 => 15, 14 => 14, 12 => 12, 11 => 11,
9 => 9, 8 => 8, 7 => 7, 6 => 6, 5 => 5, 4 => 4, 3 => 3,
2 => 2, 1 => 1, 0 => 0);
foreach ($evilchars AS $ascii)
$str = str_replace(chr($ascii), '', $str);
$str = preg_replace('/&([a-zA-Z]{1})caron;/', '\\1', $str);
$str = preg_replace('/&([a-zA-Z]{1})acute;/', '\\1', $str);
return $str;
}
?>
+307
View File
@@ -0,0 +1,307 @@
<?php
/***************************************************************************
./lib/settings.inc.php
-------------------
begin : Mon June 14 2004
copyright : (C) 2004 The OpenCaching Group
forum contact at : http://www.opencaching.com/phpBB2
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
/****************************************************************************
Unicode Reminder メモ
server specific settings
****************************************************************************/
//relative path to the root directory
if (!isset($rootpath)) $rootpath = './';
//default used language
if (!isset($lang)) $lang = 'de';
//default used style
if (!isset($style)) $style = 'ocstyle';
//pagetitle
if (!isset($pagetitle)) $pagetitle = 'www.opencaching.de';
//id of the node
$oc_nodeid = 4;
// waypoint prefix of the node
// OC = oc.de, OP = oc.pl, ... AA = local development
$oc_waypoint_prefix = 'AA';
//name of the cookie
$opt['cookie']['name'] = 'oc_devel';
$opt['cookie']['path'] = '/';
$opt['cookie']['domain'] = '';
//Debug?
if (!isset($debug_page)) $debug_page = true;
$develwarning = '<div id="debugoc"><font size="6" face="arial" color="red"><center>Entwicklersystem - nur Testdaten!</center></font></div>';
//site in service? Set to false when doing bigger work on the database to prevent error's
if (!isset($site_in_service)) $site_in_service = true;
//if you are running this site on a other domain than staging.opencaching.de, you can set
//this in private_db.inc.php, but don't forget the ending /
$absolute_server_URI = 'http://www.opencaching.de/';
// EMail address of the sender
if (!isset($emailaddr)) $emailaddr = 'contact@mail.opencaching.de';
// location of cache images
if (!isset($picdir)) $picdir = $rootpath . 'images/uploads';
if (!isset($picurl)) $picurl = 'http://www.opencaching.de/images/uploads';
// Thumbsize
$thumb_max_width = 175;
$thumb_max_height = 175;
// maximal size of images
if (!isset($maxpicsize)) $maxpicsize = 153600;
// allowed extensions of images
if (!isset($picextensions)) $picextensions = ';jpg;jpeg;gif;png;bmp;';
// news settings
$use_news_approving = true;
$news_approver_email = 'news-approver@devel.opencaching.de';
$opt['page']['showdonations'] = false;
//local database settings
$dbusername = 'username';
$dbname = 'database';
$dbserver = 'server';
$dbpasswd = 'password';
$dbpconnect = false;
$tmpdbname = 'test'; // empty db with CREATE and DROP priviledges
// date format
$opt['db']['dateformat'] = 'Y-m-d H:i:s';
// warnlevel for sql-execution
$sql_errormail = 'sqlerror@somewhere.net';
$dberrormail = $sql_errormail;
$sql_warntime = 0.1;
$sql_allow_debug = 0;
// minimum of 24 chars
$sql_debug_cryptkey = 'this is my very, very secret \'secret key\'';
// replacements for sql()
$sql_replacements['db'] = $dbname;
$sql_replacements['tmpdb'] = $tmpdbname;
// safemode_zip-binary
$safemode_zip = '/path/to/phpzip.php';
$zip_basedir = '/path/to/html/download/zip/';
$zip_wwwdir = 'download/zip/';
$googlemap_key = "<key>";
$googlemap_type = "G_MAP_TYPE"; // alternativ: _HYBRID_TYPE
// cache_maps-settings
//$cachemap_wms_url = 'http://www.top-sectret.oc/{min_lat},{min_lon},{max_lat},{max_lon}';
$cachemap_wms_url = 'http://www.opencaching.de/cachemaps.php?wp={wp_oc}';
$cachemap_size_lat = 0.2;
$cachemap_size_lon = 0.2;
$cachemap_pixel_x = 200;
$cachemap_pixel_y = 200;
$cachemap_url = 'images/cachemaps/';
$cachemap_dir = $rootpath . $cachemap_url;
$opt['translate']['debug'] = false;
// see config2/settings-dist.inc.php
$opt['template']['default']['locale'] = 'DE'; // may be overwritten by $opt['domain'][...]['locale']
$opt['template']['default']['country'] = 'DE'; // may be overwritten by $opt['domain'][...]['country']
$opt['template']['locales']['DE']['show'] = true;
$opt['template']['locales']['DE']['flag'] = 'images/flag/DE.gif';
$opt['template']['locales']['DE']['name'] = 'Deutsch';
$opt['template']['locales']['FR']['show'] = true;
$opt['template']['locales']['FR']['flag'] = 'images/flag/FR.gif';
$opt['template']['locales']['FR']['name'] = 'Français';
$opt['template']['locales']['NL']['show'] = true;
$opt['template']['locales']['NL']['flag'] = 'images/flag/NL.gif';
$opt['template']['locales']['NL']['name'] = 'Nederlands';
$opt['template']['locales']['EN']['show'] = true;
$opt['template']['locales']['EN']['flag'] = 'images/flag/EN.gif';
$opt['template']['locales']['EN']['name'] = 'English';
$opt['template']['locales']['PL']['show'] = true;
$opt['template']['locales']['PL']['flag'] = 'images/flag/PL.gif';
$opt['template']['locales']['PL']['name'] = 'Polski';
$opt['template']['locales']['IT']['show'] = true;
$opt['template']['locales']['IT']['flag'] = 'images/flag/IT.gif';
$opt['template']['locales']['IT']['name'] = 'Italiano';
$opt['template']['locales']['RU']['show'] = true;
$opt['template']['locales']['RU']['flag'] = 'images/flag/RU.gif';
$opt['template']['locales']['RU']['name'] = 'Russian';
$opt['locale']['EN']['locales'] = array('en_US.utf8', 'en_US', 'en');
$opt['locale']['EN']['format']['date'] = '%x';
$opt['locale']['EN']['format']['datelong'] = '%d. %B %Y';
$opt['locale']['EN']['format']['datetime'] = '%x %I:%M %p';
$opt['locale']['EN']['format']['datetimesec'] = '%x %X';
$opt['locale']['EN']['format']['time'] = '%I:%M %p';
$opt['locale']['EN']['format']['timesec'] = '%X';
$opt['locale']['DE']['locales'] = array('de_DE.utf8', 'de_DE@euro', 'de_DE', 'de', 'ge');
$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']['page']['subtitle1'] = 'Geocaching mit Opencaching';
$opt['locale']['DE']['page']['subtitle2'] = '';
$opt['locale']['PL']['locales'] = array('pl_PL.utf8', 'pl_PL', 'pl');
$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']['NL']['locales'] = array('nl_NL.utf8', 'nl_NL', 'nl');
$opt['locale']['NL']['format']['date'] = '%x';
$opt['locale']['NL']['format']['datelong'] = '%d. %B %Y';
$opt['locale']['NL']['format']['datetime'] = '%x %H:%M';
$opt['locale']['NL']['format']['datetimesec'] = '%x %X';
$opt['locale']['NL']['format']['time'] = '%H:%M';
$opt['locale']['NL']['format']['timesec'] = '%X';
$opt['locale']['NL']['page']['subtitle1'] = 'Geocaching met Opencaching';
$opt['locale']['NL']['page']['subtitle2'] = '';
$opt['locale']['IT']['locales'] = array('it_IT.utf8', 'it_IT', 'it');
$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']['page']['subtitle1'] = 'Geocaching con Opencaching';
$opt['locale']['IT']['page']['subtitle2'] = '';
$opt['locale']['FR']['locales'] = array('fr_FR.utf8', 'fr_FR@euro', 'fr_FR', 'french', 'fr');
$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']['RU']['locales'] = array('ru_RU.utf8', 'ru_RU', 'ru');
$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']['ES']['locales'] = array('es_ES.utf8', 'es_ES', 'es');
$opt['locale']['ES']['format']['date'] = '%x';
$opt['locale']['ES']['format']['datelong'] = '%d. %B %Y';
$opt['locale']['ES']['format']['datetime'] = '%x %H:%M';
$opt['locale']['ES']['format']['datetimesec'] = '%x %X';
$opt['locale']['ES']['format']['time'] = '%H:%M';
$opt['locale']['ES']['format']['timesec'] = '%X';
$opt['locale']['ES']['country'] = 'ES';
$opt['locale']['ES']['page']['subtitle1'] = 'Geocaching con Opencaching';
$opt['locale']['ES']['page']['subtitle2'] = '';
$opt['page']['title'] = 'OPENCACHING';
$opt['page']['subtitle1'] = 'Geocaching with Opencaching';
$opt['page']['subtitle2'] = '';
/* Sponsoring advertisements
* (plain HTML)
*/
// example: $opt['page']['sponsor']['topright'] = '<div class="site-slogan" style="background-image: url(resource2/ocstyle/images/darkbluetransparent.png);"><div style="width: 100%; text-align: left;"><p class="search"><a href="http://www.wanderjugend.de" target="_blank"><img border="0" align="right" style="margin-left: 10px;" src="resource2/ocstyle/images/dwj.gif" width="40px" height="20px" alt="... die outdoororientierte Jugendorganisation des Deutschen Wanderverbandes" /></a> Unterst&uuml;tzt und gef&ouml;rdert durch<br />die Deutsche Wanderjugend</p> </div></div>';
$opt['page']['sponsor']['topright'] = '<div class="site-slogan" style="border-width:0px;"><div style="width: 100%; text-align: left;"><p class="search">&nbsp;<br />&nbsp;</p></div></div>';
$opt['page']['sponsor']['bottom'] = 'Driven by the Opencaching Community';
/* multi-domain settings
*
* if one of the domains matches $_SERVER['SERVER_NAME'], the default values will be overwritten
* can be used to host more than one locale on one server with multiple default-locales
*/
//$opt['domain']['www.opencaching.de']['url'] = 'http://www.opencaching.de/';
//$opt['domain']['www.opencaching.de']['locale'] = 'DE';
//$opt['domain']['www.opencaching.de']['style'] = 'ocstyle';
//$opt['domain']['www.opencaching.de']['cookiedomain'] = '.opencaching.de';
//$opt['domain']['www.opencaching.de']['country'] = 'DE';
//$opt['domain']['www.opencaching.pl']['url'] = 'http://www.opencaching.pl/';
//$opt['domain']['www.opencaching.pl']['locale'] = 'PL';
//$opt['domain']['www.opencaching.pl']['style'] = 'ocstyle';
//$opt['domain']['www.opencaching.pl']['cookiedomain'] = '.opencaching.pl';
//$opt['domain']['www.opencaching.pl']['country'] = 'PL';
/* replicated slave databases
* use same config as in config2/settings.inc.php (!)
*/
$opt['db']['slaves'] = array();
/*
$opt['db']['slaves'][0]['server'] = 'slave-ip-or-socket';
// if a slave is no active, the slave will not be tracked
// by online-check or purge of master logs!
// Therefore you might have to initialize the replication again,
// after activating a slave.
$opt['db']['slaves'][0]['active'] = true;
// relative weight compared to other slaves
// see doc2/replicaiton.txt (!)
$opt['db']['slaves'][0]['weight'] = 100;
$opt['db']['slaves'][0]['username'] = '';
$opt['db']['slaves'][0]['password'] = '';
$opt['db']['slaves'][1]...
*/
// maximum time (sec) a slave is allowed to be behind
// the state of the master database before no connection
// is redirected to this slave
$opt['db']['slave']['max_behind'] = 180;
// use this slave when a specific slave must be connected
// (e.g. xml-interface and mapserver-results)
// you can use -1 to use the master (not recommended, because replicated to slaves)
$opt['db']['slave']['primary'] = -1;
/* post_config() is invoked directly before the first HTML line of the main.tpl.php is sent to the client.
*/
function post_config()
{
global $menu;
$menu[] = array(
'title' => t('Geokrety'),
'menustring' => t('Geokrety'),
'siteid' => 'geokrety',
'visible' => true,
'filename' => 'http://geokrety.org/index.php?lang=de_DE.UTF-8'
);
}
?>
+365
View File
@@ -0,0 +1,365 @@
<?php
/***************************************************************************
./lib/sqldebugger.inc.php
--------------------
begin : Mon June 27 2006
copyright : (C) 2006 The OpenCaching Group
forum contact at : http://www.opencaching.com/phpBB2
Unicode Reminder メモ
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
require_once($opt['rootpath'] . 'lib/bench.inc.php');
$sqldbg_cmdNo = 0;
$sqldbg_sumTimes = 0;
function sqldbg_begin()
{
header('Content-type: text/html; charset=utf-8');
?>
<html>
<head>
<title></title>
<style type="text/css">
<!--
.sqlno
{
font-size:medium;
}
.sqlcommand
{
}
.selrows
{
margin-bottom:15px;
}
.firstresultrow
{
}
.result
{
display:none;
}
.explain
{
}
.runtime
{
}
.affectedrows
{
}
.allruntime
{
font-size:medium;
}
.comments
{
color:gray;
}
.white
{
color:white;
}
.error
{
color:red;
font-size:medium;
}
.errormsg
{
}
table
{
margin-bottom:15px;
}
td
{
color:gray;
font-size:x-small;
white-space:nowrap;
padding:1px 5px 1px 5px;
}
th
{
color:gray;
}
.slave_title
{
font-style:italic;
color:blue;
}
.slave_sql
{
color:blue;
}
-->
</style>
<script type="text/javascript">
<!--
function switchOpt(id)
{
var cssRules = "";
if (document.all)
cssRules = "rules";
else
cssRules = "cssRules";
var value = document.getElementById(id).checked ? "block" : "none";
for (var i = 0; i < document.styleSheets.length; i++)
for (var j = 0; j < document.styleSheets[i][cssRules].length; j++)
if (document.styleSheets[i][cssRules][j].selectorText == "." + id)
document.styleSheets[i][cssRules][j].style["display"] = value;
}
//-->
</script>
</head>
<body>
<div class="white">/*</div>
<table>
<tr>
<td><input checked="checked" onclick="switchOpt('sqlno')" id="sqlno" type="checkbox" /><label for="sqlno">Command number</label></td>
<td><input checked="checked" onclick="switchOpt('sqlcommand')" id="sqlcommand" type="checkbox" /><label for="sqlcommand">Sql command</label></td>
<td><input checked="checked" onclick="switchOpt('selrows')" id="selrows" type="checkbox" /><label for="selrows">Selected rows</label></td>
<td><input checked="checked" onclick="switchOpt('firstresultrow')" id="firstresultrow" type="checkbox" /><label for="firstresultrow">First result row</label></td>
</tr>
<tr>
<td><input onclick="switchOpt('result')" id="result" type="checkbox" /><label for="result">Result rows</label></td>
<td><input checked="checked" onclick="switchOpt('explain')" id="explain" type="checkbox" /><label for="explain">Explain query</label></td>
<td><input checked="checked" onclick="switchOpt('runtime')" id="runtime" type="checkbox" /><label for="runtime">Runtime</label></td>
<td><input checked="checked" onclick="switchOpt('affectedrows')" id="affectedrows" type="checkbox" /><label for="affectedrows">Affected rows</label></td>
</tr>
<tr>
<td><input checked="checked" onclick="switchOpt('allruntime')" id="allruntime" type="checkbox" /><label for="allruntime">Runtime sum</label></td>
<td><input checked="checked" onclick="switchOpt('comments')" id="comments" type="checkbox" /><label for="comments">Comments</label></td>
</tr>
</table>
<div class="white">*/</div>
<?php
}
function sqldbg_execute($sql, $bSlave)
{
global $dblink;
global $sqldbg_cmdNo;
global $sqldbg_sumTimes;
$sqldbg_cmdNo++;
echo '<p class="sqlno"><span class="white">/*</span> SQL command ' . $sqldbg_cmdNo . ' ';
if ($bSlave)
echo '<span class="slave_title">(slave)</span>';
echo '<span class="white">*/</span>';
echo '</p>';
echo '<p class="sqlcommand">';
if ($bSlave)
echo '<span class="slave_sql">';
echo htmlspecialchars($sql, ENT_COMPAT, 'UTF-8');
if ($bSlave)
echo '</span>';
echo ' ;</p>';
echo '<div class="comments"><div class="white">/*</div><br>';
// Explains
$bUseExplain = true;
$sqlexplain = $sql;
$usebr = false;
if (mb_strtoupper(mb_substr($sqlexplain, 0, 6)) == 'ALTER ')
$bUseExplain = false;
else if (mb_strtoupper(mb_substr($sqlexplain, 0, 7)) == 'DELETE ')
{
$sqlexplain = sqldbg_strip_from($sqlexplain);
}
else if ((mb_strtoupper(mb_substr($sqlexplain, 0, 12)) == 'INSERT INTO ') ||
(mb_strtoupper(mb_substr($sqlexplain, 0, 19)) == 'INSERT IGNORE INTO '))
{
$sqlexplain = sqldbg_strip_temptable($sqlexplain);
if ($sqlexplain == '')
$bUseExplain = false;
}
else if (mb_strtoupper(mb_substr($sqlexplain, 0, 7)) == 'INSERT ')
$bUseExplain = false;
else if (mb_strtoupper(mb_substr($sqlexplain, 0, 7)) == 'UPDATE ')
$bUseExplain = false;
else if (mb_strtoupper(mb_substr($sqlexplain, 0, 11)) == 'DROP TABLE ')
$bUseExplain = false;
else if (mb_strtoupper(mb_substr($sqlexplain, 0, 23)) == 'CREATE TEMPORARY TABLE ')
{
$sqlexplain = sqldbg_strip_temptable($sqlexplain);
if ($sqlexplain == '')
$bUseExplain = false;
}
if ($bUseExplain == true)
{
$bFirstLine = true;
$nLine = 0;
$rs = mysql_query($sqlexplain, $dblink);
echo '<div class="selrows">Number of selected rows: ' . mysql_num_rows($rs) . '</div>';
echo '<table class="firstresultrow" border="1">';
while ($r = sql_fetch_assoc($rs))
{
$usebr = true;
$nLine++;
if ($bFirstLine == true)
{
echo '<tr>' . "\n";
foreach ($r AS $field => $value)
{
echo '<th>' . htmlspecialchars($field, ENT_COMPAT, 'UTF-8') . '</th>' . "\n";
}
echo '</tr>' . "\n";
}
if ($bFirstLine)
echo '<tr>';
else
echo '<tr class="result">';
foreach ($r AS $value)
{
echo '<td>' . htmlspecialchars(($value != null) ? $value : 'NULL', ENT_COMPAT, 'UTF-8') . '</td>';
}
echo '</tr>' . "\n";
if ($nLine == 25) break;
$bFirstLine = false;
}
echo '</table>';
mysql_free_result($rs);
echo '<table class="explain" border="1">';
$bFirstLine = true;
$rs = mysql_query('EXPLAIN EXTENDED ' . $sqlexplain);
while ($r = sql_fetch_assoc($rs))
{
if ($bFirstLine == true)
{
echo '<tr>';
foreach ($r AS $field => $value)
{
echo '<th>' . htmlspecialchars($field, ENT_COMPAT, 'UTF-8') . '</th>';
}
echo '</tr>' . "\n";
$bFirstLine = false;
}
echo '<tr>';
foreach ($r AS $value)
{
echo '<td>' . htmlspecialchars(($value != null) ? mb_ereg_replace('\*/', '* /', $value) : 'NULL', ENT_COMPAT, 'UTF-8') . '</td>';
}
echo '</tr>' . "\n";
}
echo '</table>';
$usebr = true;
}
// dont use query cache!
$sql = sqldbg_insert_nocache($sql);
$bSqlExecution = new Cbench;
$bSqlExecution->start();
$rsResult = mysql_query($sql, $dblink);
$bError = ($rsResult == false);
$bSqlExecution->stop();
$sqldbg_sumTimes += $bSqlExecution->Diff();
if ($bError == true)
{
echo '<div class="error">Error while executing SQL command!</div>';
echo '<div class="errormsg">';
echo '<table>';
$rs = mysql_query('SHOW WARNINGS', $dblink);
while ($r = sql_fetch_assoc($rs))
echo '<tr><td>' . htmlspecialchars($r['Message'], ENT_COMPAT, 'UTF-8') . '</td></tr>';
echo '</table>';
echo '</div>';
}
echo '<div class="runtime">Runtime: ' . sprintf('%01.5f', $bSqlExecution->Diff()) . ' sek.</div>';
echo '<div class="affectedrows">Number of affected rows: ' . mysql_affected_rows($dblink) . '</div>';
echo '<div class="white">*/</div></div>';
return $rsResult;
}
function sqldbg_end()
{
global $sqldbg_sumTimes;
echo '<span class="white">/*</span><div class="allruntime"><hr>';
echo 'Runtime sum: ' . sprintf('%01.5f', $sqldbg_sumTimes) . ' sek.<span class="white">*/</span></div>';
echo '</body></html>';
exit;
}
function sqldbg_strip_temptable($sql)
{
$start = mb_strpos(mb_strtoupper($sql), 'SELECT ');
if ($start === false)
return '';
return mb_substr($sql, $start);
}
function sqldbg_strip_from($sql)
{
$start = mb_strpos(mb_strtoupper($sql), 'FROM ');
if ($start === false)
return '';
return 'SELECT * ' . mb_substr($sql, $start);
}
function sqldbg_insert_nocache($sql)
{
if (mb_strtoupper(mb_substr($sql, 0, 7)) == 'SELECT ')
$sql = 'SELECT SQL_NO_CACHE ' . mb_substr($sql, 7);
return $sql;
}
?>
+9
View File
@@ -0,0 +1,9 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>blank_page</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body class="mceContentBody">
</body>
</html>
File diff suppressed because it is too large Load Diff
+43
View File
@@ -0,0 +1,43 @@
body {
background-color: #FFFFFF;
font-family:verdana,arial,helvetica,helv,sans-serif;
font-size:x-small;
letter-spacing:0px;
/*line-height:3ex;*/
vertical-align:top;
scrollbar-3dlight-color: #F0F0EE;
scrollbar-arrow-color: #676662;
scrollbar-base-color: #F0F0EE;
scrollbar-darkshadow-color: #DDDDDD;
scrollbar-face-color: #E0E0DD;
scrollbar-highlight-color: #F0F0EE;
scrollbar-shadow-color: #F0F0EE;
scrollbar-track-color: #F5F5F5;
}
h1
{
font-family:sans-serif;
font-size:x-small;
text-align:justify;
}
h2
{
font-family:sans-serif;
font-size:x-small;
text-align:justify;
}
a
{
color:black;
text-decoration:underline;
}
a:hover
{
color:blue;
}
+43
View File
@@ -0,0 +1,43 @@
tinyMCE.init({
mode : "textareas",
theme : "advanced",
plugins : "advhr,contextmenu,emotions,insertdatetime,paste,table",
theme_advanced_buttons1 : "cut,copy,paste,pasteword,pastetext,removeformat,separator,undo,redo,separator,link,unlink,image,separator,fontselect,fontsizeselect",
theme_advanced_buttons2 : "bold,italic,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,bullist,numlist,separator,insertdate,inserttime,separator,forecolor,backcolor,charmap,emotions",
theme_advanced_buttons3 : "visualaid,tablecontrols,separator,advhr",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_path_location : "bottom",
plugin_insertdate_dateFormat : "%d.%m.%Y",
plugin_insertdate_timeFormat : "%H:%M:%S",
file_browser_callback : "imageBrowser",
theme_advanced_resize_horizontal : false,
theme_advanced_resizing : true,
editor_deselector : "mceNoEditor",
language : "de",
preformatted : true,
remove_linebreaks : false,
oninit : "postInit",
content_css : "lib/tinymce/config/content.css"
});
var fileBrowserReturnURL = "";
var fileBrowserWin;
var fileBrowserFieldName;
function imageBrowser(field_name, url, type, win)
{
window.open('../../../../imagebrowser.php?cacheid=<?php echo isset($_REQUEST['cacheid']) ? ($_REQUEST['cacheid']+0) : 0; ?>', '', 'width=450,height=550,menubar=no,scrollbars=yes,status=no,location=no,resizable=yes,status=no,dependent');
fileBrowserWin = win;
fileBrowserFieldName = field_name;
}
function fileBrowserReturn(url)
{
fileBrowserWin.document.forms[0].elements[fileBrowserFieldName].value = url;
}
+43
View File
@@ -0,0 +1,43 @@
tinyMCE.init({
mode : "textareas",
theme : "advanced",
plugins : "advhr,contextmenu,emotions,insertdatetime,paste,table",
theme_advanced_buttons1 : "cut,copy,paste,pasteword,pastetext,removeformat,separator,undo,redo,separator,link,unlink,separator,fontselect,fontsizeselect",
theme_advanced_buttons2 : "bold,italic,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,bullist,numlist,separator,insertdate,inserttime,separator,forecolor,backcolor,charmap,emotions",
theme_advanced_buttons3 : "",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_path_location : "bottom",
plugin_insertdate_dateFormat : "%d.%m.%Y",
plugin_insertdate_timeFormat : "%H:%M:%S",
file_browser_callback : "imageBrowser",
theme_advanced_resize_horizontal : false,
theme_advanced_resizing : true,
editor_deselector : "mceNoEditor",
language : "de",
preformatted : true,
remove_linebreaks : false,
oninit : "postInit",
content_css : "lib/tinymce/config/content.css"
});
var fileBrowserReturnURL = "";
var fileBrowserWin;
var fileBrowserFieldName;
function imageBrowser(field_name, url, type, win)
{
window.open('../../../../imagebrowser.php?logid=<?php echo isset($_REQUEST['logid']) ? ($_REQUEST['logid']+0) : 0; ?>', '', 'width=450,height=550,menubar=no,scrollbars=yes,status=no,location=no,resizable=yes,status=no,dependent');
fileBrowserWin = win;
fileBrowserFieldName = field_name;
}
function fileBrowserReturn(url)
{
fileBrowserWin.document.forms[0].elements[fileBrowserFieldName].value = url;
}
+41
View File
@@ -0,0 +1,41 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>About</title>
<link href="css/screen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="header">
<h1>About</h1>
</div>
<div class="content">
<h2>General information</h2>
<div class="section">
<p>TinyMCE is a powerful WYSIWYG editor control for web browsers such as MSIE or Mozilla that enables the user to edit HTML contents in a more user friendly way. The editor control is very flexible and it's built for integration purposes for example usage within systems like Intranets, CMS, LMS and so forth.</p>
<p>
TinyMCE is developed by <a href="http://www.moxiecode.com">Moxiecode Systems AB</a> and is currently released under the &quot;LGPL&quot; license, read the license agreement for details.
</p>
<h2>Features</h2>
<p>
<ul>
<li>Easy to integrate, takes only a couple lines of code.</li>
<li>Theme and template support.</li>
<li>Easy to extend with custom code. (Plugins and callbacks)</li>
<li>Customizable HTML output. Block elements and force attributes.</li>
<li>International language support (Language packs).</li>
<li>Multiple browser support, currently Mozilla (PC, Mac and Linux), MSIE (PC) and FireFox (PC, Mac and Linux) and some limited Safari support.</li>
</ul>
</p>
</div>
</div>
<div class="footer">
<div class="helpindexlink"><a href="index.html">Index</a></div>
<div class="copyright">Copyright &copy; 2003-2006 <a href="http://www.moxiecode.com">Moxiecode Systems AB</a></div>
<br style="clear: both" />
</div>
</body>
</html>
@@ -0,0 +1,84 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Compatiblity Chart</title>
<link href="css/screen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="header">
<h1>Compatiblity Chart</h1>
</div>
<div class="content">
<h2>Browser support</h2>
<div class="section">
<p>TinyMCE uses advanced JavaScript and tries to be as smart as possible when it comes to different browsers, the main focus is on Microsoft Internet Explorer and Mozilla/Firefox. The table was reset to only show the browsers we ourselves can test on. It works with many older versions of Mozilla and Firefox. <strong>Just cause a browser is not listed on this page doesn't mean it does not work, try out the examples on our website.</strong></p>
<p>Since MacOS X 10.4 is more or less Linux we are not testing much on Linux any more, use the Sourceforge bug report system to submit bugs on the very latest browsers only.</p>
<p>
<table border="1" cellspacing="0" cellpadding="4">
<tr>
<td>&nbsp;</td>
<td>Windows XP</td>
<td>MacOS X 10.4</td>
</tr>
<tr>
<td>MSIE 6</td>
<td>OK</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>MSIE 5.5 SP2</td>
<td>OK</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>MSIE 5.0</td>
<td>OK</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>Mozilla 1.7.x</td>
<td>OK</td>
<td>OK</td>
</tr>
<tr>
<td>Firefox 1.0.x</td>
<td>OK</td>
<td>OK</td>
</tr>
<tr>
<td>Firefox 1.5b2</td>
<td>OK</td>
<td>OK</td>
</tr>
<tr>
<td>Safari 2.0 (412)</td>
<td>&nbsp;</td>
<td>OK(1)</td>
</tr>
<tr>
<td>Opera 9 Preview 1</td>
<td>OK(1)</td>
<td>OK(1)</td>
</tr>
</table>
</p>
<p>
<ul>
<li>(1) - Partialy working</li>
<li>(2) - Buggy browser version</li>
</ul>
</p>
</div>
</div>
<div class="footer">
<div class="helpindexlink"><a href="index.html">Index</a></div>
<div class="copyright">Copyright &copy; 2003-2006 <a href="http://www.moxiecode.com">Moxiecode Systems AB</a></div>
<br style="clear: both" />
</div>
</body>
</html>
+83
View File
@@ -0,0 +1,83 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Credits</title>
<link href="css/screen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="header">
<h1>Credits</h1>
</div>
<div class="content">
<h2>Contributors</h2>
<div class="section">
<p>These are the people, companies or organizations that have contributed in some way to the TinyMCE project. If you feel we are missing someone please inform us right away and we will correct this in future versions of TinyMCE.</p>
<p>
Please note that some of these have contributed with complete language packs and some have updated parts of language packs or similar.
</p>
</div>
<div class="separator"></div>
<div class="section">
<p>
<ul>
<li class="list_subtitle">Code / Solutions / Features</li>
<ul>
<li>Digital Ventures</li>
<li>donadoni</li>
<li>Michael Keck</li>
<li>Victor Nilsson</li>
<li>Jürgen Baute</li>
<li>"Neirda"</li>
<li>"speednet"</li>
<li>Virtuelcom</li>
<li>"SlyD"</li>
<li>Ernst de Moor</li>
<li>"jamesw"</li>
<li>Vincent FIACK</li>
<li>Aptest</li>
</ul>
<li class="list_subtitle">Language packs</li>
<ul>
<li>Marcin Szymon Sznyra</li>
<li>"revyag"</li>
<li>Jim Kou</li>
<li>"Krokogras"</li>
<li>Hani Suleiman</li>
<li>Jan Moelgaard</li>
<li>Christopher Müller</li>
<li>Virtuelcom</li>
<li>Pavel Novák</li>
<li>Simon Rupf</li>
<li>"Fabrix Xm"</li>
<li>Mats Löfström, York Consulting AB</li>
<li>Morteza Zafari</li>
<li>Laurent Dran</li>
<li>Tobias Heer</li>
<li>"Innozent"</li>
<li>"cube316"</li>
<li>José Pedro Pereira</li>
<li>"Martin"</li>
<li>Sten Aksel Heien</li>
<li>Setzer Gabbiani</li>
<li>Jacaranda Bill</li>
<li>Pat Boens</li>
<li>Roman Filippov</li>
<li>Arnoud van Delden</li>
</ul>
</ul>
</p>
<p>There are also a few corporations that have contributed in various ways to have features developed by payed support.
</p>
</div>
</div>
<div class="footer">
<div class="helpindexlink"><a href="index.html">Index</a></div>
<div class="copyright">Copyright &copy; 2003-2006 <a href="http://www.moxiecode.com">Moxiecode Systems AB</a></div>
<br style="clear: both" />
</div>
</body>
</html>
+168
View File
@@ -0,0 +1,168 @@
body {
background-color: #FFFFFF;
font-family: Verdana, Arial, helvetica, sans-serif;
font-size: 12px;
}
.header {
border: #E0E0E0 solid 1px;
}
.footer {
border: #E0E0E0 solid 1px;
height: 20px;
}
h1 {
font-size: 18px;
font-weight: bold;
padding: 0;
margin: 4px;
}
h2 {
font-size: 14px;
font-weight: bold;
padding: 0;
margin: 0;
margin-top: 4px;
margin-bottom: 4px;
}
h3 {
font-size: 11px;
font-weight: bold;
padding: 0;
margin: 0;
margin-bottom: 3px;
}
.section {
margin-left: 15px;
}
.column {
margin-right: 20px;
float: left
}
.separator {
border-bottom: 1px solid #E6EBF1;
margin-top: 10px;
margin-bottom: 10px;
}
p {
}
.helpindex {
margin-left: 20px;
padding-left: 0;
}
.optionlist {
margin: 0;
padding: 0;
margin-bottom: 10px;
}
.optionlist li {
padding: 0;
margin: 0;
margin-top: 3px;
margin-bottom: 3px;
margin-left: 10px;
list-style-type: none;
}
.helpindex li {
margin-top: 3px;
}
.content {
margin: 10px;
}
.example {
background-color: #E6EBF1;
margin-left: 10px;
}
code, pre {
margin: 0;
padding: 0;
background-color: #E6EBF1;
}
.copyright {
margin: 3px;
float: left;
}
.helpindexlink {
margin: 3px;
float: right;
}
a:visited {
color: #666666;
text-decoration: underline;
}
a:active {
color: #666666;
text-decoration: underline;
}
a:hover {
color: #666666;
text-decoration: underline;
}
a {
color: #666666;
text-decoration: underline;
}
.list_subtitle {
padding-top: 5px;
}
.note {
margin-top: 5px;
margin-left: 10px;
font-size: 10px;
}
.marked {
color: red;
font-weight: bold;
}
thead {
background-color: #E6EBF1;
}
.btable {
}
.btable th {
border: 1px solid gray;
vertical-align: top;
}
.btable td {
border: 1px solid gray;
vertical-align: top;
}
.plist {
list-style-type: none;
margin: 0;
padding: 0;
}
.plist li {
padding-bottom: 3px;
}
@@ -0,0 +1,57 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Customization - Creating a language pack</title>
<link href="css/screen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="header">
<h1>Customization - Creating a language pack</h1>
</div>
<div class="content">
<h2>Making language packs</h2>
<p>Language packs are simply JavaScript name/value arrays placed in the &quot;<ISO-639-1 code>.js&quot; files in the &quot;lang&quot; directory. Remember to allways use the &quot;lang_&quot; prefix for these value names so that they don't override other variables in the templates. The example below shows how the cut, copy and paste texts are lang packed. Notice there are three kinds of language packs the first one is the general one shared by all themes these are located in the &quot;jscripts/tiny_mce/langs&quot; directory the secound ones are theme specific language packs these are contained in &quot;jscripts/tiny_mce/themes/&lt;some theme&gt;/langs&quot; and the last one is plugin specific language packs located in each plugin.
</p>
<p>
<div class="example">
<pre>
tinyMCE.addToLang('',{
cut_desc : 'Cut (Ctrl+X)',
copy_desc : 'Copy (Ctrl+C)',
paste_desc : 'Paste (Ctrl+P)'
);
</pre>
</div>
</p>
<p>
Remember the last translation line should not have a , character at the end. The first parameter to the addToLang is the prefix to add before each variable, this was added to reduce the overall size of the language packs to reduce the overall download time.
</p>
<h3>Files to edit</h3>
<p>
When translating TinyMCE, these are the files that currently needs to be translated:
</p>
<p>
/tinymce/jscripts/tiny_mce/langs/en.js<br />
/tinymce/jscripts/tiny_mce/plugins/&lt;plugin&gt;/langs/en.js<br />
/tinymce/jscripts/tiny_mce/themes/advanced/langs/en.js<br />
</p>
<p>
Notice some language variables may include a name/url of a gif image or simmilar, for example the button for bold has a "F" character in the Swedish language pack. There are also relative window sizes located in the language packs, for example is the link dialog needs to be bigger inorder to fit a specific translation you can alter the width of the window by modifying these variables.
</p>
<h3>Contributing your language pack</h3>
<p>
Go to the <a href="http://sourceforge.net/tracker/?atid=635684&group_id=103281&func=browse">sourceforge patch page</a> and upload a zip containing all the language files in the correct directory structure.<br /><br />
Please translate all the plugins, even if you aren't using them.<br />
</p>
</div>
<div class="footer">
<div class="helpindexlink"><a href="index.html">Index</a></div>
<div class="copyright">Copyright &copy; 2003-2006 <a href="http://www.moxiecode.com">Moxiecode Systems AB</a></div>
<br style="clear: both" />
</div>
</body>
</html>
@@ -0,0 +1,227 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Customization - Creating a plugin</title>
<link href="css/screen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="header">
<h1>Customization - Creating a plugin</h1>
</div>
<div class="content">
<h2>Creating your own plugins</h2>
<p>
Creating you own plugins for the TinyMCE application is fairly easy if you know the basics of HTML, CSS and Javascript. The most easy way is to copy the &quot;_template&quot; directory or one of the other core plugins and work from there. The &quot;_template&quot; directory is a tutorial plugin that shows how to create a plugin. After you copy the template you need to change the red sections marked below to the name of your plugin this is needed so that plugins don't overlap in other words it gives the plugin a unique name.
</p>
<p>If you want you may add plugin specific options/settings but remember to namespace them in the following format &quot;&lt;your plugin&gt;_&lt;option&gt;&quot; for example &quot;yourplugin_someoption&quot;.</p>
<p>Specific callback functions that you don't need or doesn't do anything can be removed.</p>
<div class="separator"></div>
<h3>Plugin directory structure</h3>
<p>
<table class="btable">
<thead>
<th>File/Directory</td>
<th>Description</td>
</thead>
<tbody>
<tr><td>css</td><td>Plugin specific CSS files</td></tr>
<tr><td>docs</td><td>Plugin specific documentation</td></tr>
<tr><td>images</td><td>Plugin specific images</td></tr>
<tr><td>jscripts</td><td>Plugin specific jscripts for HTML dialogs</td></tr>
<tr><td>langs</td><td>Plugin specific language files</td></tr>
<tr><td>editor_plugin.js</td><td>Editor plugin file (compressed).</td></tr>
<tr><td>editor_plugin_src.js</td><td>Editor plugin file (source).</td></tr>
<tr><td>somedialog.htm</td><td>Plugin specific dialog HTML file.</td></tr>
</table>
</p>
<div class="separator"></div>
<h3>Plugin example source</h3>
<p>
The example below shows a simple empty plugin and all possible callbacks.
</p>
<p>
<div class="example">
<pre>
var TinyMCE_<span class="marked">SomeName</span>Plugin = {
/**
* Returns information about the plugin as a name/value array.
* The current keys are longname, author, authorurl, infourl and version.
*
* @returns Name/value array containing information about the plugin.
* @type Array
*/
getInfo : function() {
return {
longname : 'Your plugin',
author : 'Your name',
authorurl : 'http://www.yoursite.com',
infourl : 'http://www.yoursite.com/docs/template.html',
version : "1.0"
};
},
/**
* Gets executed when a TinyMCE editor instance is initialized.
*
* @param {TinyMCE_Control} Initialized TinyMCE editor control instance.
*/
initInstance : function(inst) {
// You can take out plugin specific parameters
alert("Initialization parameter:" + tinyMCE.getParam("<span class="marked">somename</span>_someparam", false));
// Register custom keyboard shortcut
inst.addShortcut('ctrl', 't', 'lang_<span class="marked">somename</span>_desc', 'mceSomeCommand');
},
/**
* Returns the HTML code for a specific control or empty string if this plugin doesn't have that control.
* A control can be a button, select list or any other HTML item to present in the TinyMCE user interface.
* The variable {$editor_id} will be replaced with the current editor instance id and {$pluginurl} will be replaced
* with the URL of the plugin. Language variables such as {$lang_somekey} will also be replaced with contents from
* the language packs.
*
* @param {string} cn Editor control/button name to get HTML for.
* @return HTML code for a specific control or empty string.
* @type string
*/
getControlHTML : function(cn) {
switch (cn) {
case "<span class="marked">SomeControl</span>":
return tinyMCE.getButtonHTML(cn, 'lang_<span class="marked">someplugin</span>_<span class="marked">button</span>_desc', '{$pluginurl}/images/<span class="marked">someimage</span>.gif', '<span class="marked">mceSomeCommand</span>');
}
return "";
},
getControlHTML : function(cn) {
switch (cn) {
case "advhr":
return tinyMCE.getButtonHTML(cn, 'lang_insert_advhr_desc', '{$pluginurl}/images/advhr.gif', 'mceAdvancedHr');
}
return "";
},
/**
* Executes a specific command, this function handles plugin commands.
*
* @param {string} editor_id TinyMCE editor instance id that issued the command.
* @param {HTMLElement} element Body or root element for the editor instance.
* @param {string} command Command name to be executed.
* @param {string} user_interface True/false if a user interface should be presented.
* @param {mixed} value Custom value argument, can be anything.
* @return true/false if the command was executed by this plugin or not.
* @type
*/
execCommand : function(editor_id, element, command, user_interface, value) {
// Handle commands
switch (command) {
// Remember to have the "mce" prefix for commands so they don't intersect with built in ones in the browser.
case "mce<span class="marked">SomeCommand</span>":
// Do your custom command logic here.
return true;
}
// Pass to next handler in chain
return false;
},
/**
* Gets called ones the cursor/selection in a TinyMCE instance changes. This is useful to enable/disable
* button controls depending on where the user are and what they have selected. This method gets executed
* alot and should be as performance tuned as possible.
*
* @param {string} editor_id TinyMCE editor instance id that was changed.
* @param {HTMLNode} node Current node location, where the cursor is in the DOM tree.
* @param {int} undo_index The current undo index, if this is -1 custom undo/redo is disabled.
* @param {int} undo_levels The current undo levels, if this is -1 custom undo/redo is disabled.
* @param {boolean} visual_aid Is visual aids enabled/disabled ex: dotted lines on tables.
* @param {boolean} any_selection Is there any selection at all or is there only a cursor.
*/
handleNodeChange : function(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) {
},
/**
* Gets called when a TinyMCE editor instance gets filled with content on startup.
*
* @param {string} editor_id TinyMCE editor instance id that was filled with content.
* @param {HTMLElement} body HTML body element of editor instance.
* @param {HTMLDocument} doc HTML document instance.
*/
setupContent : function(editor_id, body, doc) {
},
/**
* Gets called when the contents of a TinyMCE area is modified, in other words when a undo level is
* added.
*
* @param {TinyMCE_Control} inst TinyMCE editor area control instance that got modified.
*/
onChange : function(inst) {
},
/**
* Gets called when TinyMCE handles events such as keydown, mousedown etc. TinyMCE
* doesn't listen on all types of events so custom event handling may be required for
* some purposes.
*
* @param {Event} e HTML editor event reference.
* @return true - pass to next handler in chain, false - stop chain execution
* @type boolean
*/
handleEvent : function(e) {
return true;
},
/**
* Gets called when HTML contents is inserted or retrived from a TinyMCE editor instance.
* The type parameter contains what type of event that was performed and what format the content is in.
* Possible valuses for type is get_from_editor, insert_to_editor, get_from_editor_dom, insert_to_editor_dom.
*
* @param {string} type Cleanup event type.
* @param {mixed} content Editor contents that gets inserted/extracted can be a string or DOM element.
* @param {TinyMCE_Control} inst TinyMCE editor instance control that performes the cleanup.
* @return New content or the input content depending on action.
* @type string
*/
cleanup : function(type, content, inst) {
return content;
},
// Private plugin internal methods
/**
* This is just a internal plugin method, prefix all internal methods with a _ character.
* The prefix is needed so they doesn't collide with future TinyMCE callback functions.
*
* @param {string} a Some arg1.
* @param {string} b Some arg2.
* @return Some return.
* @type string
*/
_someInternalFunction : function(a, b) {
return 1;
}
};
// Adds the plugin class to the list of available TinyMCE plugins
tinyMCE.addPlugin("<span class="marked">someplugin</span>", TinyMCE_<span class="marked">SomePlugin</span>Plugin);
</pre>
</div>
</p>
</div>
<div class="footer">
<div class="helpindexlink"><a href="index.html">Index</a></div>
<div class="copyright">Copyright &copy; 2003-2006 <a href="http://www.moxiecode.com">Moxiecode Systems AB</a></div>
<br style="clear: both" />
</div>
</body>
</html>
@@ -0,0 +1,262 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Customization - Creating a theme</title>
<link href="css/screen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="header">
<h1>Customization - Creating a theme</h1>
</div>
<div class="content">
<h2>Creating your own Themes</h2>
<p>
Creating you own themes for the TinyMCE application is fairly easy if you know the basics of HTML, CSS and Javascript. The most easy way is to copy the &quot;simple&quot; or the &quot;advanced&quot; template and rename it as your own name to for example &quot;mytheme&quot;. After you copy the template you need to change the red sections marked below to &quot;mytheme&quot; this is needed so that themes don't overlap in other words it gives the theme a unique name. Then just alter the HTML code as you see fit but notice some elements needs to be there so check the docs below on each function also remember that your custom themes needs to be located in tiny_mce's &quot;themes&quot; directory. If you want you may add theme specific options/settings but remember to namespace them in the following format &quot;theme_&lt;your theme&gt;_&lt;option&gt;&quot;.
</p>
<div class="separator"></div>
<h3>Theme directory structure</h3>
<p>
<table class="btable">
<thead>
<th>File/Directory</td>
<th>Description</td>
</thead>
<tbody>
<tr><td>css</td><td>Theme specific CSS files</td></tr>
<tr><td>docs</td><td>Theme specific documentation</td></tr>
<tr><td>images</td><td>Theme specific images</td></tr>
<tr><td>jscripts</td><td>Theme specific jscripts for HTML dialogs</td></tr>
<tr><td>langs</td><td>Theme specific language files</td></tr>
<tr><td>editor_template.js</td><td>Editor theme template file (compressed).</td></tr>
<tr><td>editor_template_src.js</td><td>Editor theme template file (source).</td></tr>
<tr><td>somedialog.htm</td><td>Theme specific dialog HTML file.</td></tr>
</table>
</p>
<div class="separator"></div>
<h3>Theme example source</h3>
<p>
The example below shows a simple empty theme and all possible callbacks.
</p>
<p>
<div class="example">
<pre>
var TinyMCE_<span class="marked">SomeName</span>Theme = {
/**
* Returns information about the theme as a name/value array.
* The current keys are longname, author, authorurl, infourl and version.
*
* @returns Name/value array containing information about the theme.
* @type Array
*/
getInfo : function() {
return {
longname : 'Your Theme',
author : 'Your name',
authorurl : 'http://www.yoursite.com',
infourl : 'http://www.yoursite.com/docs/template.html',
version : "1.0"
};
},
/**
* Gets executed when a TinyMCE editor instance is initialized.
*
* @param {TinyMCE_Control} Initialized TinyMCE editor control instance.
*/
initInstance : function(inst) {
// You can take out theme specific parameters
alert("Initialization parameter:" + tinyMCE.getParam("<span class="marked">somename</span>_someparam", false));
// Register custom keyboard shortcut
inst.addShortcut('ctrl', 't', 'lang_<span class="marked">somename</span>_desc', 'mceSomeCommand');
},
/**
* Returns the HTML code for a specific control or empty string if this theme doesn't have that control.
* A control can be a button, select list or any other HTML item to present in the TinyMCE user interface.
* The variable {$editor_id} will be replaced with the current editor instance id and {$themeurl} will be replaced
* with the URL of the theme. Language variables such as {$lang_somekey} will also be replaced with contents from
* the language packs.
*
* @param {string} cn Editor control/button name to get HTML for.
* @return HTML code for a specific control or empty string.
* @type string
*/
getControlHTML : function(cn) {
switch (cn) {
case "<span class="marked">SomeControl</span>":
return tinyMCE.getButtonHTML(cn, 'lang_<span class="marked">sometheme</span>_<span class="marked">button</span>_desc', '{$themeurl}/images/<span class="marked">someimage</span>.gif', '<span class="marked">mceSomeCommand</span>');
}
return "";
},
/**
* Returns the HTML code that should be inserted for a specific editor instance.
* This function should return a name/value array with three items html, delta_width, delta_height.
* The html item should contain the HTML code to insert as a editor instance.
* The variable {$editor_id} will be replaced with the current editor instance id and {$themeurl} will be replaced
* with the URL of the theme. Language variables such as {$lang_somekey} will also be replaced with contents from
* the language packs. Any element with the id {$editor_id} will be replaced with the editor iframe element.
* The {$width} and {$height} variables will be replaced with the editors outside dimension values.
* The delta_width/height is the relative width/height in pixels to add or remove from the iframe dimensions.
*
* @param {Array} settings Name/Value array instance settings.
* @param {string} editor_id TinMYCE editor control instance id.
* @return Name/Value array of editor template data.
* @type Array
*/
getEditorTemplate : function(settings, editor_id) {
var html = "";
// Build toolbar and editor instance
html += "..";
return {
html : html,
delta_width : 0,
delta_height : 0
};
},
/**
* Executes a specific command, this function handles theme commands.
*
* @param {string} editor_id TinyMCE editor instance id that issued the command.
* @param {HTMLElement} element Body or root element for the editor instance.
* @param {string} command Command name to be executed.
* @param {string} user_interface True/false if a user interface should be presented.
* @param {mixed} value Custom value argument, can be anything.
* @return true/false if the command was executed by this theme or not.
* @type
*/
execCommand : function(editor_id, element, command, user_interface, value) {
// Handle commands
switch (command) {
// Remember to have the "mce" prefix for commands so they don't intersect with built in ones in the browser.
case "mce<span class="marked">SomeCommand</span>":
// Do your custom command logic here.
return true;
}
// Pass to next handler in chain
return false;
},
/**
* Gets called ones the cursor/selection in a TinyMCE instance changes. This is useful to enable/disable
* button controls depending on where the user are and what they have selected. This method gets executed
* alot and should be as performance tuned as possible.
*
* @param {string} editor_id TinyMCE editor instance id that was changed.
* @param {HTMLNode} node Current node location, where the cursor is in the DOM tree.
* @param {int} undo_index The current undo index, if this is -1 custom undo/redo is disabled.
* @param {int} undo_levels The current undo levels, if this is -1 custom undo/redo is disabled.
* @param {boolean} visual_aid Is visual aids enabled/disabled ex: dotted lines on tables.
* @param {boolean} any_selection Is there any selection at all or is there only a cursor.
*/
handleNodeChange : function(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) {
},
/**
* Gets called when a TinyMCE editor instance gets filled with content on startup.
*
* @param {string} editor_id TinyMCE editor instance id that was filled with content.
* @param {HTMLElement} body HTML body element of editor instance.
* @param {HTMLDocument} doc HTML document instance.
*/
setupContent : function(editor_id, body, doc) {
},
/**
* Gets called when the contents of a TinyMCE area is modified, in other words when a undo level is
* added.
*
* @param {TinyMCE_Control} inst TinyMCE editor area control instance that got modified.
*/
onChange : function(inst) {
},
/**
* Gets called when TinyMCE handles events such as keydown, mousedown etc. TinyMCE
* doesn't listen on all types of events so custom event handling may be required for
* some purposes.
*
* @param {Event} e HTML editor event reference.
* @return true - pass to next handler in chain, false - stop chain execution
* @type boolean
*/
handleEvent : function(e) {
return true;
},
/**
* Gets called when HTML contents is inserted or retrived from a TinyMCE editor instance.
* The type parameter contains what type of event that was performed and what format the content is in.
* Possible valuses for type is get_from_editor, insert_to_editor, get_from_editor_dom, insert_to_editor_dom.
*
* @param {string} type Cleanup event type.
* @param {mixed} content Editor contents that gets inserted/extracted can be a string or DOM element.
* @param {TinyMCE_Control} inst TinyMCE editor instance control that performes the cleanup.
* @return New content or the input content depending on action.
* @type string
*/
cleanup : function(type, content, inst) {
return content;
},
// Private theme internal methods
/**
* This is just a internal theme method, prefix all internal methods with a _ character.
* The prefix is needed so they doesn't collide with future TinyMCE callback functions.
*
* @param {string} a Some arg1.
* @param {string} b Some arg2.
* @return Some return.
* @type string
*/
_someInternalFunction : function(a, b) {
return 1;
}
};
// Adds the theme class to the list of available TinyMCE themes
tinyMCE.addTheme("<span class="marked">sometheme</span>", TinyMCE_<span class="marked">SomeTheme</span>Theme);
</pre>
</div>
</p>
<div class="separator"></div>
<h3>Creating popup HTML files</h3>
<p>
When creating a popup you need to include the &quot;tiny_mce_popup.js&quot; this enables you to retrive the tinyMCE global instance in all popup windows. All variables and language definitions gets replaced in the page when it loads. So language variables such as {$lang_something} can be places in the HTML code, if you need to get a language string in JavaScript simply use the tinyMCE.getLang function.
</p>
<h3>Example of simple popup file:</h3>
<div class="example">
<pre>
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;{$lang_theme_sample_title}&lt;/title&gt;
&lt;script language=&quot;javascript&quot; src=&quot;../../tiny_mce_popup.js&quot;&gt;&lt;/script&gt;
&lt;script language=&quot;javascript&quot;&gt;
// getWindowArg returns any arguments passed to the window
alert(tinyMCE.getWindowArg('some_arg'));
&lt;/script&gt;
&lt;body&gt;
&lt;strong&gt;{$lang_theme_sample_desc}&lt;/strong&gt;
&lt;/body&gt;
</pre>
</div>
<div class="footer">
<div class="helpindexlink"><a href="index.html">Index</a></div>
<div class="copyright">Copyright &copy; 2003-2006 <a href="http://www.moxiecode.com">Moxiecode Systems AB</a></div>
<br style="clear: both" />
</div>
</body>
</html>
+220
View File
@@ -0,0 +1,220 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Frequently Asked Questions</title>
<link href="css/screen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="header">
<h1>Frequently Asked Questions</h1>
</div>
<div class="content">
<p>Here are some common answers to common questions. If you need more help you can always visit the <a href="http://tinymce.moxiecode.com/">TinyMCE Forum</a> on the TinyMCE web site.</p>
<p>
<ul class="plist">
<li><a href="#broken">TinyMCE is broken, what should I do?</a></li>
<li><a href="#paths">Why is my paths incorrect, I want absolute/relative URLs?</a></li>
<li><a href="#strip">Why does TinyMCE strip aways attributes or tags from my source?</a></li>
<li><a href="#font">How do I change the default font size/face color of the editor?</a></li>
<li><a href="#remove">How do I remove/add buttons/controls to TinyMCE?</a></li>
<li><a href="#quotes">Why does my HTML output include lots of \&quot; like &lt;a href=\&quot;mylink.htm\&quot;&gt;link&lt;/a&gt;?</a></li>
<li><a href="#load">TinyMCE takes ages to load, is there a way to make it load quicker?</a></li>
<li><a href="#hidden">TinyMCE stops working when placed in tabs or hidden divs?</a></li>
<li><a href="#commercial">Can I use TinyMCE in my commercial application?</a></li>
<li><a href="#commercial2">Are there any restrictions to using TinyMCE in my commercial application?</a></li>
<li><a href="#lgpl">I don't like LGPL, is there a commercial license available for me?</a></li>
<li><a href="#support">Do you provide support?</a></li>
<li><a href="#who">Who made this software?</a></li>
</ul>
</p>
<div class="separator"></div>
<a name="broken"></a>
<h2>TinyMCE is broken, what should I do?</h2>
<div class="section">
<p>There are a few things you should check before posting questions about your problem at the forum or sourceforge.</p>
<p>
<ul>
<li>Does TinyMCE work on the <a href="http://tinymce.moxiecode.com/example_full.php?example=true">TinyMCE website</a>. Then you know that TinyMCE works with your browser.</li>
<li>Try to disable any other JavaScripts on the page, some scripts interfere with internal functions that TinyMCE uses. Those scripts are probably poorly written.</li>
<li>Check that you havn't missed removing the last , character in your initialization code and that all the other rows have a trailing , character.</li>
<li>Verify that the path/URL to TinyMCE is correct, you can use the excellent tool <a href="http://www.fiddlertool.com/fiddler/">Fiddler</a> for this and other HTTP debugging.</li>
<li>Do not cross domain load TinyMCE or any other script unless you really really must, since this will invoke various browser security features. In other words, try placing everything on the same server.</li>
<li>Don't place textareas within paragraph elements since this is not valid HTML and it will break MSIE and TinyMCE.</li>
</ul>
</p>
</div>
<div class="separator"></div>
<a name="paths"></a>
<h2>Why is my paths incorrect, I want absolute/relative URLs?</h2>
<div class="section">
<p>
These are the diffrent configuration scenarios for URLs within TinyMCE:
<table class="btable">
<thead>
<th>Output</th>
<th>Config</th>
<th>Description</th>
</thead>
<tbody>
<tr>
<td><strong>http://www.site.com/path1/path2/file.htm</strong> will be converted to <strong>path2/file.htm</strong></td>
<td nowrap="nowrap">
<a href="option_relative_urls.html">relative_urls</a> : true,<br />
<a href="option_document_base_url.html">document_base_url</a> : &quot;http://www.site.com/path1/&quot;<br />
</td>
<td>This will convert all URLs within the same domain to relative URLs.<br /> <strong>The URLs will be relative from the <a href="option_document_base_url.html">document_base_url</a></strong>.</td>
</tr>
<tr>
<td><strong>path2/file.htm</strong> will be converted to <strong>/path1/path2/file.htm</strong></td>
<td nowrap="nowrap">
<a href="option_relative_urls.html">relative_urls</a> : false,<br />
<a href="option_remove_script_host.html">remove_script_host</a> : true,<br />
<a href="option_document_base_url.html">document_base_url</a> : &quot;http://www.site.com/path1/&quot;<br />
</td>
<td>This will convert all relative URLs to absolute URLs.<br /> <strong>The URLs will be absolute based on the <a href="option_document_base_url.html">document_base_url</a></strong>.</td>
</tr>
<tr>
<td><strong>path2/file.htm</strong> will be converted to <strong>http://www.site.com/path1/path2/file.htm</strong></td>
<td nowrap="nowrap">
<a href="option_relative_urls.html">relative_urls</a> : false,<br />
<a href="option_remove_script_host.html">remove_script_host</a> : false,<br />
<a href="option_document_base_url.html">document_base_url</a> : &quot;http://www.site.com/path1/&quot;<br />
</td>
<td>This will convert all relative URLs to absolute URLs.<br /> <strong>The URLs will be absolute based on the <a href="option_document_base_url.html">document_base_url</a></strong>.</td>
</tr>
<tr>
<td><strong>path2/file.htm</strong> or <strong>http://www.site.com/path1/path2/file.htm</strong> will not be converted at all.</td>
<td nowrap="nowrap">
<a href="option_convert_urls.html">convert_urls</a> : false<br />
</td>
<td>This option will preserve the URLs as they are in a separate attribute while editing, <strong>since browsers tend to auto convert URLs</strong>.</td>
</tr>
</tbody>
</table>
</p>
</div>
<div class="separator"></div>
<a name="strip"></a>
<h2>Why does TinyMCE strip aways attributes or tags from my source?</h2>
<div class="section">
<p>You need to check out the &quot;<a href="option_valid_elements.html">valid_elements</a>&quot; and &quot;<a href="option_extended_valid_elements.html">extended_valid_elements</a>&quot; option in the configuration. By default, TinyMCE only allows certain tags and attributes. TinyMCE also tries to follow the XHTML specification as much as possible (and so should you), this can cause some unexpected source changes, there are however configuration options to battle this issue, study the configuration options in details.</p>
</div>
<div class="separator"></div>
<a name="font"></a>
<h2>How do I change the default font size/face color of the editor?</h2>
<div class="section">
<p>
We recommend that you have a look at the <a href="option_content_css.html">content_css</a> option, this enables you to switch the CSS file TinyMCE uses for it's editing area with a file with your CSS rules for font size and so forth.
</p>
</div>
<div class="separator"></div>
<a name="remove"></a>
<h2>How do I remove/add buttons/controls to TinyMCE?</h2>
<div class="section">
<p>
There are quite a few options for this but a reference of all available buttons/control names can be found in the <a href="reference_buttons.html">button/control reference</a>.
</p>
</div>
<div class="separator"></div>
<a name="quotes"></a>
<h2>Why does my HTML output include lots of \&quot; like &lt;a href=\&quot;mylink.htm\&quot;&gt;link&lt;/a&gt;?</h2>
<div class="section">
<p>This is probably because you are using PHP and it has a feature that's called magic quotes that is enabled by default. You can read more about this at the <a href="http://se2.php.net/magic_quotes/">PHP website</a> or use the <a href="http://www.php.net/manual/en/function.stripslashes.php">stripslashes</a> function.</p>
</div>
<div class="separator"></div>
<a name="load"></a>
<h2>TinyMCE takes ages to load, is there a way to make it load quicker?</h2>
<div class="section">
<p>
If you use PHP on your server you can use tiny_mce_gzip.php instead of tiny_mce.js in page script call. This PHP file bundles all .js files together into two HTTP requests instead of one for each plugin, language file and theme and it also GZip compresses these files.
</p>
</div>
<div class="separator"></div>
<a name="hidden"></a>
<h2>TinyMCE stops working when placed in tabs or hidden divs?</h2>
<div class="section">
<p>Since Gecko based browsers Mozilla/Firefox has a bug where it looses designMode on iframes that are hidden a special option is needed that re-enables the design mode when reappearing after being hidden. Enable this option to resolve the issue: &quot;<a href="option_auto_reset_designmode.html">auto_reset_designmode</a>&quot;.</p>
</div>
<div class="separator"></div>
<a name="commercial"></a>
<h2>Can I use TinyMCE in my commercial application?</h2>
<div class="section">
<p>Yes you can, the LGPL license is a Free Software License. You can read the whole license <a href="license.html">here</a> or visit Free Software Foundation web site <a href="http://www.fsf.org/" target="_blank">here</a></p>
</div>
<div class="separator"></div>
<a name="commercial2"></a>
<h2>Are there any restrictions to using TinyMCE in my commercial application?</h2>
<div class="section">
<p>
Yes, all copyright notices must be intact. Moxiecode Systems are still the copyright holders of the source code, so you can not use the code for other applications. Any modifications or add-ons you make to the source has to be contributes back to the TinyMCE community.
</p>
<p>
If you start to make a lot of revenue from using TinyMCE, please remember the time and dedication that has been put into this by other developers, respect this and give credit to those who deserve it.
</p>
</div>
<div class="separator"></div>
<a name="lgpl"></a>
<h2>I don't like LGPL, is there a commercial license available for me?</h2>
<div class="section">
<p>
Yes, we can draw up a license for you that enables you to remove copyright restrictions or anything else you would like to have in this license agreement. Contact us through email, sales (at) moxiecode (dot) com.
</p>
</div>
<div class="separator"></div>
<a name="support"></a>
<h2>Do you provide support?</h2>
<div class="section">
<p>
We do not provide any non-commercial support outside the forum on the <a href="http://tinymce.moxiecode.com/">TinyMCE</a> web site. If you require commercial support, contact us by email, sales (at) moxiecode (dot) com.
</p>
</div>
<div class="separator"></div>
<a name="who"></a>
<h2>Who made this software?</h2>
<div class="section">
<p>
The author of TinyMCE is <a href="http://www.moxiecode.com/" target="_blank">Moxiecode Systems</a>, parts of code has also been contributed by others, <a href="credits.html">here</a> are the credits list.
</p>
</div>
</div>
<div class="footer">
<div class="helpindexlink"><a href="index.html">Index</a></div>
<div class="copyright">Copyright &copy; 2003-2006 <a href="http://www.moxiecode.com">Moxiecode Systems AB</a></div>
<br style="clear: both" />
</div>
</body>
</html>
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

+44
View File
@@ -0,0 +1,44 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>TinyMCE Documentation - Index</title>
<link href="css/screen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="header">
<h1>TinyMCE Documentation</h1>
</div>
<div class="content">
<ul class="helpindex">
<li><a href="about.html">About TinyMCE</a></li>
<li><a href="installing.html">Installation instructions</a></li>
<li class="list_subtitle"><strong>Reference</strong></li>
<ul>
<li><a href="reference_configuration.html">Configuration</a></li>
<li><a href="reference_buttons.html">Button/control reference</a></li>
<li><a href="reference_javascript_functions.html">JavaScript functions</a></li>
<li><a href="reference_plugins.html">Plugins</a></li>
</ul>
<li class="list_subtitle"><strong>Customization</strong></li>
<ul style="padding-bottom: 5px;">
<li><a href="customization_plugins.html">Creating a plugin</a></li>
<li><a href="customization_language_packs.html">Creating a language pack</a></li>
<li><a href="customization_themes.html">Creating a theme</a></li>
</ul>
<li><a href="compatiblity_chart.html">Compatiblity chart</a></li>
<li><a href="faq.html">Frequently asked questions</a></li>
<li><a href="credits.html">Credits</a></li>
<li><a href="license.html">License (LGPL)</a></li>
</ul>
</div>
<div class="footer">
<div class="helpindexlink"><a href="index.html">Index</a></div>
<div class="copyright">Copyright &copy; 2003-2006 <a href="http://www.moxiecode.com">Moxiecode Systems AB</a></div>
<br style="clear: both" />
</div>
</body>
</html>
@@ -0,0 +1,35 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Installation Example 00</title>
<link href="css/screen.css" rel="stylesheet" type="text/css" />
<script language="javascript" type="text/javascript" src="../jscripts/tiny_mce/tiny_mce.js"></script>
<script language="javascript" type="text/javascript">
tinyMCE.init({
mode : "textareas",
theme : "simple"
});
</script>
</head>
<body>
<div class="header">
<h1>Installation example 00</h1>
</div>
<div class="content">
<h3>Example</h3>
<form method="post">
<textarea name="content" cols="50" rows="15">This is some content that will be editable with TinyMCE.</textarea>
</form>
</div>
</div>
<div class="footer">
<div class="helpindexlink"><a href="index.html">Index</a></div>
<div class="copyright">Copyright &copy; 2003-2006 <a href="http://www.moxiecode.com">Moxiecode Systems AB</a></div>
<br style="clear: both" />
</div>
</body>
</html>
@@ -0,0 +1,36 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Installation Example 01</title>
<link href="css/screen.css" rel="stylesheet" type="text/css" />
<script language="javascript" type="text/javascript" src="../jscripts/tiny_mce/tiny_mce_src.js"></script>
<script language="javascript" type="text/javascript">
tinyMCE.init({
mode : "textareas",
theme : "advanced"
});
</script>
</head>
<body>
<div class="header">
<h1>Installation example 01</h1>
</div>
<div class="content">
<h3>Example</h3>
<p>Open this page with "View source" or similar to see how the configuration is made.</p>
<form method="post">
<textarea name="content" cols="50" rows="15">This is some content that will be editable with TinyMCE.</textarea>
</form>
</div>
</div>
<div class="footer">
<div class="helpindexlink"><a href="index.html">Index</a></div>
<div class="copyright">Copyright &copy; 2003-2006 <a href="http://www.moxiecode.com">Moxiecode Systems AB</a></div>
<br style="clear: both" />
</div>
</body>
</html>
@@ -0,0 +1,52 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Installation Example 02</title>
<link href="css/screen.css" rel="stylesheet" type="text/css" />
<script language="javascript" type="text/javascript" src="../jscripts/tiny_mce/tiny_mce.js"></script>
<script language="javascript" type="text/javascript">
tinyMCE.init({
mode : "textareas",
theme : "advanced",
plugins : "table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,zoom,flash,searchreplace,print,contextmenu",
theme_advanced_buttons1_add_before : "save,separator",
theme_advanced_buttons1_add : "fontselect,fontsizeselect",
theme_advanced_buttons2_add : "separator,insertdate,inserttime,preview,zoom,separator,forecolor,backcolor",
theme_advanced_buttons2_add_before: "cut,copy,paste,separator,search,replace,separator",
theme_advanced_buttons3_add_before : "tablecontrols,separator",
theme_advanced_buttons3_add : "emotions,iespell,flash,advhr,separator,print",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_path_location : "bottom",
plugin_insertdate_dateFormat : "%Y-%m-%d",
plugin_insertdate_timeFormat : "%H:%M:%S",
extended_valid_elements : "a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]",
external_link_list_url : "example_data/example_link_list.js",
external_image_list_url : "example_data/example_image_list.js",
flash_external_list_url : "example_data/example_flash_list.js"
});
</script>
</head>
<body>
<div class="header">
<h1>Installation example 02</h1>
</div>
<div class="content">
<h3>Example</h3>
<p>Open this page with "View source" or similar to see how the configuration is made.</p>
<form method="post">
<textarea name="content" cols="85" rows="15">This is some content that will be editable with TinyMCE.</textarea>
</form>
</div>
</div>
<div class="footer">
<div class="helpindexlink"><a href="index.html">Index</a></div>
<div class="copyright">Copyright &copy; 2003-2006 <a href="http://www.moxiecode.com">Moxiecode Systems AB</a></div>
<br style="clear: both" />
</div>
</body>
</html>
@@ -0,0 +1,43 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Installation Example 02</title>
<link href="css/screen.css" rel="stylesheet" type="text/css" />
<script language="javascript" type="text/javascript" src="../jscripts/tiny_mce/tiny_mce.js"></script>
<script language="javascript" type="text/javascript">
tinyMCE.init({
mode : "textareas",
theme : "advanced",
theme_advanced_buttons1 : "bold,italic,underline,separator,strikethrough,justifyleft,justifycenter,justifyright, justifyfull,bullist,numlist,undo,redo,link,unlink",
theme_advanced_buttons2 : "",
theme_advanced_buttons3 : "",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_path_location : "bottom",
extended_valid_elements : "a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]"
});
</script>
</head>
<body>
<div class="header">
<h1>Installation example 02</h1>
</div>
<div class="content">
<h3>Example</h3>
<p>Open this page with "View source" or similar to see how the configuration is made.</p>
<form method="post">
<textarea name="content" cols="85" rows="15">This is some content that will be editable with TinyMCE.</textarea>
</form>
</div>
</div>
<div class="footer">
<div class="helpindexlink"><a href="index.html">Index</a></div>
<div class="copyright">Copyright &copy; 2003-2006 <a href="http://www.moxiecode.com">Moxiecode Systems AB</a></div>
<br style="clear: both" />
</div>
</body>
</html>
+121
View File
@@ -0,0 +1,121 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Installation instructions</title>
<link href="css/screen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="header">
<h1>Installation instructions</h1>
</div>
<div class="content">
<p>Installing TinyMCE is very simple, follow the instructions here. We give a few examples of to integrate TinyMCE, also look at the extensive <a href="reference_configuration.html">options</a> for configuration.</p>
<div class="separator"></div>
<h2>Requirements</h2>
<div class="section">
<p>TinyMCE has no direct requirements except for <a href="compatiblity_chart.html">browser compatibility</a> and of course JavaScript needs to be turned on. There is NO backend code distributed with TinyMCE.
</p>
</div>
<div class="separator"></div>
<h2>Downloading</h2>
<div class="section">
<p>For download instructions check our <a href="http://tinymce.moxiecode.com">web site.</a></p>
</div>
<div class="separator"></div>
<h2>Extracting the archives</h2>
<div class="section">
<p>On windows you could use <a href="http://www.winzip.com">WinZip</a> or something similar. And on other operating systems such as Linux you simply extract the archive with the tar command. You can find a example on how to extract the archived file on Linux below.</p>
<p>
You should extract TinyMCE in your wwwroot or site domain root folder
</p>
<h3>Extract example using a shell:</h3>
<div class="example">
<pre>
$ cd wwwroot
$ gzip -d tinymce_1_44.tar.gz
$ tar xvf tinymce_1_44.tar
</pre>
</div>
<p>
<h3>A folder structure looking like this is created:</h3>
<div class="example">
<pre>
/tinymce/
/tinymce/docs/
/tinymce/docs/zh_cn/
/tinymce/examples/
/tinymce/examples/zh_cn/
/tinymce/jscripts/
/tinymce/jscripts/tiny_mce/
/tinymce/jscripts/tiny_mce/langs/
/tinymce/jscripts/tiny_mce/plugins/
/tinymce/jscripts/tiny_mce/plugins/&lt;plugin folders&gt;
/tinymce/jscripts/tiny_mce/themes/
/tinymce/jscripts/tiny_mce/themes/advanced/
/tinymce/jscripts/tiny_mce/themes/default/
/tinymce/jscripts/tiny_mce/themes/simple/
</pre>
</div>
</p>
</div>
<div class="separator"></div>
<h2>Making changes on your web site</h2>
<div class="section">
<p>Once you have extracted the archive you will need to edit the pages to include the configuration and javascript for TinyMCE. Please note that you should probably only include the TinyMCE javascript on the pages that need it, not all the pages of the web site. Remember to change the URL to the .js below to match your installation path.</p>
<p>
<h3>The most basic page integration (converts all textarea elements into editors):</h3>
<div class="example">
<pre>
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;TinyMCE Test&lt;/title&gt;
<strong>&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot; src=&quot;../jscripts/tiny_mce/tiny_mce.js&quot;&gt;&lt;/script&gt;
&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;
tinyMCE.init({
mode : &quot;textareas&quot;
});
&lt;/script&gt;</strong>
&lt;/head&gt;
&lt;body&gt;
&lt;form method=&quot;post&quot;&gt;
&lt;textarea name=&quot;content&quot; cols=&quot;50&quot; rows=&quot;15&quot;&gt;This is some content that will be editable with TinyMCE.&lt;/textarea&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
</div>
</p>
<p>
Here are a few different example of how you could integrate TinyMCE.
</p>
<p>
<ul>
<li><a href="installation_example_00.html">Example 00</a> - Simple Theme</li>
<li><a href="installation_example_01.html">Example 01</a> - Advanced Theme</li>
<li><a href="installation_example_02.html">Example 02</a> - Advanced Theme Full</li>
<li><a href="installation_example_03.html">Example 03</a> - Advanced Theme Simplified</li>
</ul>
</p>
<p>
If you have any problems, you should check the forum on the <a href="http://tinymce.moxiecode.com/" target="_blank">TinyMCE web site.</a></p>
</div>
</div>
<div class="footer">
<div class="helpindexlink"><a href="index.html">Index</a></div>
<div class="copyright">Copyright &copy; 2003-2006 <a href="http://www.moxiecode.com">Moxiecode Systems AB</a></div>
<br style="clear: both" />
</div>
</body>
</html>
+465
View File
@@ -0,0 +1,465 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>TinyMCE License (LGPL)</title>
<link href="css/screen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="header">
<h1>TinyMCE License (LGPL)</h1>
</div>
<div class="content">
<p>
Visit the <a href="faq.html">FAQ</a> for general answers surrounding TinyMCE. Or visit <a href="http://www.fsf.org" target="_blank">http://www.fsf.org</a> for more information about Open-Source licenses.
</p>
<pre>
GNU LIBRARY GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 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 library GPL. It is
numbered 2 because it goes with version 2 of the ordinary GPL.]
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 Library General Public License, applies to some
specially designated Free Software Foundation software, and to any
other libraries whose authors decide to use it. You can use it for
your libraries, too.
When we speak of free software, we are referring to freedom, 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 or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the 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 a program 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.
Our method of protecting your rights has two steps: (1) copyright
the library, and (2) offer you this license which gives you legal
permission to copy, distribute and/or modify the library.
Also, for each distributor's protection, we want to make certain
that everyone understands that there is no warranty for this free
library. If the library is modified by someone else and passed on, we
want its recipients to know that what they have is not the original
version, so that any problems introduced by others will not reflect on
the original authors' reputations.
.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that companies distributing free
software will individually obtain patent licenses, thus in effect
transforming the program into proprietary software. To prevent this,
we have made it clear that any patent must be licensed for everyone's
free use or not licensed at all.
Most GNU software, including some libraries, is covered by the ordinary
GNU General Public License, which was designed for utility programs. This
license, the GNU Library General Public License, applies to certain
designated libraries. This license is quite different from the ordinary
one; be sure to read it in full, and don't assume that anything in it is
the same as in the ordinary license.
The reason we have a separate public license for some libraries is that
they blur the distinction we usually make between modifying or adding to a
program and simply using it. Linking a program with a library, without
changing the library, is in some sense simply using the library, and is
analogous to running a utility program or application program. However, in
a textual and legal sense, the linked executable is a combined work, a
derivative of the original library, and the ordinary General Public License
treats it as such.
Because of this blurred distinction, using the ordinary General
Public License for libraries did not effectively promote software
sharing, because most developers did not use the libraries. We
concluded that weaker conditions might promote sharing better.
However, unrestricted linking of non-free programs would deprive the
users of those programs of all benefit from the free status of the
libraries themselves. This Library General Public License is intended to
permit developers of non-free programs to use free libraries, while
preserving your freedom as a user of such programs to change the free
libraries that are incorporated in them. (We have not seen how to achieve
this as regards changes in header files, but we have achieved it as regards
changes in the actual functions of the Library.) The hope is that this
will lead to faster development of free libraries.
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, while the latter only
works together with the library.
Note that it is possible for a library to be covered by the ordinary
General Public License rather than by this special one.
.
GNU LIBRARY GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library which
contains a notice placed by the copyright holder or other authorized
party saying it may be distributed under the terms of this Library
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 compile 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) 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.
c) 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.
d) 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 source code 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 to
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 Library 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
</pre>
</div>
<div class="footer">
<div class="helpindexlink"><a href="index.html">Index</a></div>
<div class="copyright">Copyright &copy; 2003-2006 <a href="http://www.moxiecode.com">Moxiecode Systems AB</a></div>
<br style="clear: both" />
</div>
</body>
</html>
@@ -0,0 +1,38 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Option: accessibility_focus</title>
<link href="css/screen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="header">
<h1>Option: accessibility_focus</h1>
</div>
<div class="content">
<p>
If this option is set to true some accessibility focus will available to all buttons, you will be able to tab through them all. If you set this option to false, focus will be placed inside the text area when you tab through the interface.
</p>
<div class="separator"></div>
<h3>Example of usage of the accessibility_focus option:</h3>
<div class="example">
<pre>
tinyMCE.init({
...
<strong>accessibility_focus : false</strong>
});
</pre>
</div>
</div>
<div class="footer">
<div class="helpindexlink"><a href="index.html">Index</a></div>
<div class="copyright">Copyright &copy; 2003-2006 <a href="http://www.moxiecode.com">Moxiecode Systems AB</a></div>
<br style="clear: both" />
</div>
</body>
</html>
@@ -0,0 +1,38 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Option: accessibility_warnings</title>
<link href="css/screen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="header">
<h1>Option: accessibility_warnings</h1>
</div>
<div class="content">
<p>
If this option is set to true some accessibility warnings will be presented to the user if they miss specifying that information. This option is set to true default, since we should all try to make this world a better place for disabled people. But if you are annoyed with the warnings, set this option to false.
</p>
<div class="separator"></div>
<h3>Example of usage of the accessibility_warnings option:</h3>
<div class="example">
<pre>
tinyMCE.init({
...
<strong>accessibility_warnings : false</strong>
});
</pre>
</div>
</div>
<div class="footer">
<div class="helpindexlink"><a href="index.html">Index</a></div>
<div class="copyright">Copyright &copy; 2003-2006 <a href="http://www.moxiecode.com">Moxiecode Systems AB</a></div>
<br style="clear: both" />
</div>
</body>
</html>
@@ -0,0 +1,38 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Option: add_form_submit_trigger</title>
<link href="css/screen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="header">
<h1>Option: add_form_submit_trigger</h1>
</div>
<div class="content">
<p>
This option enables you to turn on/off the onsubmit event listener. This feature adds a onsubmit event listener on all forms on the page, if a form is submitted a tinyMCE.triggerSave() JavaScript calls gets executed, this function moves HTML content from the editor iframe and to the hidden form element. This option is set to true by default.
</p>
<div class="separator"></div>
<h3>Example of usage of the add_form_submit_trigger option:</h3>
<div class="example">
<pre>
tinyMCE.init({
...
<strong>add_form_submit_trigger : false</strong>
});
</pre>
</div>
</div>
<div class="footer">
<div class="helpindexlink"><a href="index.html">Index</a></div>
<div class="copyright">Copyright &copy; 2003-2006 <a href="http://www.moxiecode.com">Moxiecode Systems AB</a></div>
<br style="clear: both" />
</div>
</body>
</html>
@@ -0,0 +1,38 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Option: add_unload_trigger</title>
<link href="css/screen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="header">
<h1>Option: add_unload_trigger</h1>
</div>
<div class="content">
<p>
If you set this option to true, page contents will be stored away is the page is unloaded for example is the user navigates away from the page and then navigated back to it by pressing the back button. This option is set to true by default.
</p>
<div class="separator"></div>
<h3>Example of usage of the add_unload_trigger option:</h3>
<div class="example">
<pre>
tinyMCE.init({
...
<strong>add_unload_trigger : false</strong>
});
</pre>
</div>
</div>
<div class="footer">
<div class="helpindexlink"><a href="index.html">Index</a></div>
<div class="copyright">Copyright &copy; 2003-2006 <a href="http://www.moxiecode.com">Moxiecode Systems AB</a></div>
<br style="clear: both" />
</div>
</body>
</html>
@@ -0,0 +1,38 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Option: apply_source_formatting</title>
<link href="css/screen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="header">
<h1>Option: apply_source_formatting</h1>
</div>
<div class="content">
<p>
This option enables you to tell TinyMCE to apply some source formatting to the output HTML code. This function is disabled by default.
</p>
<div class="separator"></div>
<h3>Example of usage of the apply_source_formatting option:</h3>
<div class="example">
<pre>
tinyMCE.init({
...
<strong>apply_source_formatting : true</strong>
});
</pre>
</div>
</div>
<div class="footer">
<div class="helpindexlink"><a href="index.html">Index</a></div>
<div class="copyright">Copyright &copy; 2003-2006 <a href="http://www.moxiecode.com">Moxiecode Systems AB</a></div>
<br style="clear: both" />
</div>
</body>
</html>
+38
View File
@@ -0,0 +1,38 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Option: ask</title>
<link href="css/screen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="header">
<h1>Option: ask</h1>
</div>
<div class="content">
<p>
This option enables you to add a confirmation dialog when focusing textareas. This dialog asks if the focused textarea should be converted into a editor instance or not. It will only ask once since it would get annoying otherwice. The default value of this option is &quot;false&quot;.
</p>
<div class="separator"></div>
<h3>Example of usage of the ask option:</h3>
<div class="example">
<pre>
tinyMCE.init({
...
<strong>ask : true</strong>
});
</pre>
</div>
</div>
<div class="footer">
<div class="helpindexlink"><a href="index.html">Index</a></div>
<div class="copyright">Copyright &copy; 2003-2006 <a href="http://www.moxiecode.com">Moxiecode Systems AB</a></div>
<br style="clear: both" />
</div>
</body>
</html>
@@ -0,0 +1,38 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Option: auto_focus</title>
<link href="css/screen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="header">
<h1>Option: auto_focus</h1>
</div>
<div class="content">
<p>
This option enables you to auto focus a editor instance. The value of this option should be a editor instance id. Editor instance ids are specified as &quot;mce_editor_&lt;index&gt;&quot; where index is a value starting from 0. So if there are 3 editor instances on a page these would have the following ids mce_editor_0, mce_editor_1 and mce_editor_2.
</p>
<div class="separator"></div>
<h3>Example of usage of the auto_focus option:</h3>
<div class="example">
<pre>
tinyMCE.init({
...
<strong>auto_focus : "mce_editor_2"</strong>
});
</pre>
</div>
</div>
<div class="footer">
<div class="helpindexlink"><a href="index.html">Index</a></div>
<div class="copyright">Copyright &copy; 2003-2006 <a href="http://www.moxiecode.com">Moxiecode Systems AB</a></div>
<br style="clear: both" />
</div>
</body>
</html>
@@ -0,0 +1,38 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Option: auto_reset_designmode</title>
<link href="css/screen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="header">
<h1>Option: auto_reset_designmode</h1>
</div>
<div class="content">
<p>
This option is very useful if TinyMCE is used in a DHTML tab system or other divs that are hidden and displayed by some JavaScript. Since Mozilla has a bug when using display:none, the designMode state gets lost. To prevent this from happening you should enable this option. The default value of this option is &quot;true&quot;.
</p>
<div class="separator"></div>
<h3>Example of usage of the auto_reset_designmode option:</h3>
<div class="example">
<pre>
tinyMCE.init({
...
<strong>auto_reset_designmode : true</strong>
});
</pre>
</div>
</div>
<div class="footer">
<div class="helpindexlink"><a href="index.html">Index</a></div>
<div class="copyright">Copyright &copy; 2003-2006 <a href="http://www.moxiecode.com">Moxiecode Systems AB</a></div>
<br style="clear: both" />
</div>
</body>
</html>
@@ -0,0 +1,38 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Option: auto_resize</title>
<link href="css/screen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="header">
<h1>Option: auto_resize</h1>
</div>
<div class="content">
<p>
This option enables you to get the TinyMCE editor area to resize to the bounderies of the contents. This option is very experimental and is set to false by default.
</p>
<div class="separator"></div>
<h3>Example of usage of the auto_resize option:</h3>
<div class="example">
<pre>
tinyMCE.init({
...
<strong>auto_resize : true</strong>
});
</pre>
</div>
</div>
<div class="footer">
<div class="helpindexlink"><a href="index.html">Index</a></div>
<div class="copyright">Copyright &copy; 2003-2006 <a href="http://www.moxiecode.com">Moxiecode Systems AB</a></div>
<br style="clear: both" />
</div>
</body>
</html>
@@ -0,0 +1,38 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Option: browsers</title>
<link href="css/screen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="header">
<h1>Option: browsers</h1>
</div>
<div class="content">
<p>
This option should contain a comma separated list of supported browsers. This enables you to for example disable the editor while running on Safari. The default value of this option is: msie,gecko,safari,opera and since the support for Safari is very limited a warning message will appear until a better version is released. The possible values of this option is msie, gecko and safari.
</p>
<div class="separator"></div>
<h3>Example of usage of the browsers option:</h3>
<div class="example">
<pre>
tinyMCE.init({
...
<strong>browsers : "msie,gecko,opera"</strong>
});
</pre>
</div>
</div>
<div class="footer">
<div class="helpindexlink"><a href="index.html">Index</a></div>
<div class="copyright">Copyright &copy; 2003-2006 <a href="http://www.moxiecode.com">Moxiecode Systems AB</a></div>
<br style="clear: both" />
</div>
</body>
</html>
@@ -0,0 +1,38 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Option: button_tile_map</title>
<link href="css/screen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="header">
<h1>Option: button_tile_map</h1>
</div>
<div class="content">
<p>
If this option is set to true TinyMCE will use tiled images instead of individual images for most of the editor controls. This produces faster loading time since only one GIF image needs to be loaded instead of a GIF for each individual button. This option is set to false by default since it doesn't work with some DOCTYPE declarations.
</p>
<div class="separator"></div>
<h3>Example of usage of the button_tile_map option:</h3>
<div class="example">
<pre>
tinyMCE.init({
...
<strong>button_tile_map : true</strong>
});
</pre>
</div>
</div>
<div class="footer">
<div class="helpindexlink"><a href="index.html">Index</a></div>
<div class="copyright">Copyright &copy; 2003-2006 <a href="http://www.moxiecode.com">Moxiecode Systems AB</a></div>
<br style="clear: both" />
</div>
</body>
</html>
@@ -0,0 +1,38 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Option: cleanup</title>
<link href="css/screen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="header">
<h1>Option: cleanup</h1>
</div>
<div class="content">
<p>
This option enables you to turn on/off the built in cleanup functionality. TinyMCE is equipped with powerful cleanup functionality that enables you to specify what elements and attributes are allowed and how HTML contents should be generated. This option is set to true by default, but if you want to disable it you may set it to false. <strong>Notice: It's not recommended to disable this feature.</strong>
</p>
<div class="separator"></div>
<h3>Example of usage of the cleanup option:</h3>
<div class="example">
<pre>
tinyMCE.init({
...
<strong>cleanup : true</strong>
});
</pre>
</div>
</div>
<div class="footer">
<div class="helpindexlink"><a href="index.html">Index</a></div>
<div class="copyright">Copyright &copy; 2003-2006 <a href="http://www.moxiecode.com">Moxiecode Systems AB</a></div>
<br style="clear: both" />
</div>
</body>
</html>
@@ -0,0 +1,72 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Option: cleanup_callback</title>
<link href="css/screen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="header">
<h1>Option: cleanup_callback</h1>
</div>
<div class="content">
<p>
This option enables you to add custom cleanup logic to TinyMCE. This function is called when the cleanup process is executed this process occures when the editor saves/submits content, user hits the cleanup button and when the HTML editor dialog is presented. The format of this function is: customCleanup(type, value). Where type can be &quot;get_from_editor&quot; when the contents is extracted from TinyMCE for example when the user submits the form. The &quot;insert_to_editor&quot; type value gets passed when new contents is inserted into the editor on initialization or when the HTML editor dialog commits new content. The &quot;get_from_editor_dom&quot; value is executed when cleanup process has a valid DOM tree and is extracted from the editor. The &quot;insert_to_editor_dom&quot; gets passed when the editor has a valid DOM tree and contents has been inserted into the editor. The example below illustrated all these types.
</p>
<div class="separator"></div>
<h3>Example of usage of the cleanup_callback option:</h3>
<div class="example">
<pre>
function <strong>myCustomCleanup</strong>(type, value) {
switch (type) {
case "get_from_editor":
alert("Value HTML string: " + value);
// Do custom cleanup code here
break;
case "insert_to_editor":
alert("Value HTML string: " + value);
// Do custom cleanup code here
break;
case "get_from_editor_dom":
alert("Value DOM Element " + value);
// Do custom cleanup code here
break;
case "insert_to_editor_dom":
alert("Value DOM Element: " + value);
// Do custom cleanup code here
break;
}
return value;
}
tinyMCE.init({
...
<strong>cleanup_callback : "myCustomCleanup"</strong>
});
</pre>
</div>
</div>
<div class="footer">
<div class="helpindexlink"><a href="index.html">Index</a></div>
<div class="copyright">Copyright &copy; 2003-2006 <a href="http://www.moxiecode.com">Moxiecode Systems AB</a></div>
<br style="clear: both" />
</div>
</body>
</html>
@@ -0,0 +1,38 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Option: cleanup_on_startup</title>
<link href="css/screen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="header">
<h1>Option: cleanup_on_startup</h1>
</div>
<div class="content">
<p>
If you set this option to true, TinyMCE will perform a HTML cleanup call when the editor loads. This option is set to false by default.
</p>
<div class="separator"></div>
<h3>Example of usage of the cleanup_on_startup option:</h3>
<div class="example">
<pre>
tinyMCE.init({
...
<strong>cleanup_on_startup : true</strong>
});
</pre>
</div>
</div>
<div class="footer">
<div class="helpindexlink"><a href="index.html">Index</a></div>
<div class="copyright">Copyright &copy; 2003-2006 <a href="http://www.moxiecode.com">Moxiecode Systems AB</a></div>
<br style="clear: both" />
</div>
</body>
</html>
@@ -0,0 +1,38 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Option: content_css</title>
<link href="css/screen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="header">
<h1>Option: content_css</h1>
</div>
<div class="content">
<p>
This option enables you to specify a custom CSS file that extends the theme content CSS. This CSS file is the one used within the editor (the editable area). The default location of this CSS file is within the current theme. This option can also be a comma separated list of URLs.
</p>
<div class="separator"></div>
<h3>Example of usage of the content_css option:</h3>
<div class="example">
<pre>
tinyMCE.init({
...
<strong>content_css : "/mycontent.css"</strong>
});
</pre>
</div>
</div>
<div class="footer">
<div class="helpindexlink"><a href="index.html">Index</a></div>
<div class="copyright">Copyright &copy; 2003-2006 <a href="http://www.moxiecode.com">Moxiecode Systems AB</a></div>
<br style="clear: both" />
</div>
</body>
</html>
@@ -0,0 +1,38 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Option: convert_fonts_to_spans</title>
<link href="css/screen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="header">
<h1>Option: convert_fonts_to_spans</h1>
</div>
<div class="content">
<p>If you set this option to true, all TinyMCE will convert all font elements to span elements and generate span elements instead of font elements. This option should be used inorder to get more W3C compatible code, since font elements are deprecated. How sizes gets converted can be controlled by the <a href="option_font_size_classes.html">font_size_classes</a> and <a href="option_font_size_style_values.html">font_size_style_values</a> options.</p>
<p>
More information about this subject can be found in this article: <a href="http://www.microsoft.com/typography/web/designer/face7.htm">What's wrong with FONT FACE</a>
</p>
<div class="separator"></div>
<h3>Example of usage of the convert_fonts_to_spans option:</h3>
<div class="example">
<pre>
tinyMCE.init({
...
<strong>convert_fonts_to_spans : false</strong>
});
</pre>
</div>
</div>
<div class="footer">
<div class="helpindexlink"><a href="index.html">Index</a></div>
<div class="copyright">Copyright &copy; 2003-2006 <a href="http://www.moxiecode.com">Moxiecode Systems AB</a></div>
<br style="clear: both" />
</div>
</body>
</html>
@@ -0,0 +1,38 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Option: convert_newlines_to_brs</title>
<link href="css/screen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="header">
<h1>Option: convert_newlines_to_brs</h1>
</div>
<div class="content">
<p>
If you set this option to true newline characters codes gets converted in to br elements. This option is set to false by default.
</p>
<div class="separator"></div>
<h3>Example of usage of the convert_newlines_to_brs option:</h3>
<div class="example">
<pre>
tinyMCE.init({
...
<strong>convert_newlines_to_brs : true</strong>
});
</pre>
</div>
</div>
<div class="footer">
<div class="helpindexlink"><a href="index.html">Index</a></div>
<div class="copyright">Copyright &copy; 2003-2006 <a href="http://www.moxiecode.com">Moxiecode Systems AB</a></div>
<br style="clear: both" />
</div>
</body>
</html>
@@ -0,0 +1,36 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Option: convert_urls</title>
<link href="css/screen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="header">
<h1>Option: convert_urls</h1>
</div>
<div class="content">
<p>This option enables you to control if TinyMCE is to be clever and restore urls to their original values. URLs are auto converted/messed up by default since the built in browser logic works this way, there is no way to get the real URL unless you store it away. If you set this option to false it will try to keep these URLs intact. This option is set to true by default that means URLs will be forced absolute or relative depending on the state of <a href="option_relative_urls.html">relative_urls</a>.</p>
<div class="separator"></div>
<h3>Example of usage of the convert_urls option:</h3>
<div class="example">
<pre>
tinyMCE.init({
...
<strong>convert_urls : false</strong>
});
</pre>
</div>
</div>
<div class="footer">
<div class="helpindexlink"><a href="index.html">Index</a></div>
<div class="copyright">Copyright &copy; 2003-2006 <a href="http://www.moxiecode.com">Moxiecode Systems AB</a></div>
<br style="clear: both" />
</div>
</body>
</html>
@@ -0,0 +1,39 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Option: custom_shortcuts</title>
<link href="css/screen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="header">
<h1>Option: custom_shortcuts</h1>
</div>
<div class="content">
<p>
This option enables you to disable/enable the custom keyboard shortcuts plugins and themes may register. The value of this
option is set to true by default.
</p>
<div class="separator"></div>
<h3>Example of usage of the custom_shortcuts option:</h3>
<div class="example">
<pre>
tinyMCE.init({
...
<strong>custom_shortcuts : false</strong>
});
</pre>
</div>
</div>
<div class="footer">
<div class="helpindexlink"><a href="index.html">Index</a></div>
<div class="copyright">Copyright &copy; 2003-2006 <a href="http://www.moxiecode.com">Moxiecode Systems AB</a></div>
<br style="clear: both" />
</div>
</body>
</html>
@@ -0,0 +1,38 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Option: custom_undo_redo</title>
<link href="css/screen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="header">
<h1>Option: custom_undo_redo</h1>
</div>
<div class="content">
<p>
This option is a true/false option that enables you to disable/enable the custom undo/redo logic within TinyMCE. This option is enabled by default, if you disable it some operations may not be undoable.
</p>
<div class="separator"></div>
<h3>Example of usage of the custom_undo_redo option:</h3>
<div class="example">
<pre>
tinyMCE.init({
...
<strong>custom_undo_redo : false</strong>
});
</pre>
</div>
</div>
<div class="footer">
<div class="helpindexlink"><a href="index.html">Index</a></div>
<div class="copyright">Copyright &copy; 2003-2006 <a href="http://www.moxiecode.com">Moxiecode Systems AB</a></div>
<br style="clear: both" />
</div>
</body>
</html>
@@ -0,0 +1,38 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Option: custom_undo_redo_keyboard_shortcuts</title>
<link href="css/screen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="header">
<h1>Option: custom_undo_redo_keyboard_shortcuts</h1>
</div>
<div class="content">
<p>
This option enables you to disable/enable the usage of keyboard shortcuts for undo/redo. This feature is enabled by default. Keyboard shortcurs are Ctrl+Z for undo, Ctrl+Y for redo.
</p>
<div class="separator"></div>
<h3>Example of usage of the custom_undo_redo_keyboard_shortcuts option:</h3>
<div class="example">
<pre>
tinyMCE.init({
...
<strong>custom_undo_redo_keyboard_shortcuts : "false"</strong>
});
</pre>
</div>
</div>
<div class="footer">
<div class="helpindexlink"><a href="index.html">Index</a></div>
<div class="copyright">Copyright &copy; 2003-2006 <a href="http://www.moxiecode.com">Moxiecode Systems AB</a></div>
<br style="clear: both" />
</div>
</body>
</html>
@@ -0,0 +1,38 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Option: custom_undo_redo_levels</title>
<link href="css/screen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="header">
<h1>Option: custom_undo_redo_levels</h1>
</div>
<div class="content">
<p>
This option should contain the number of undo levels to keep in memory. This is set to -1 by default and such a value tells TinyMCE to use a unlimited number of undo levels. But this steals lots of memory so for low end systems a value of 10 may be better.
</p>
<div class="separator"></div>
<h3>Example of usage of the custom_undo_redo_levels option:</h3>
<div class="example">
<pre>
tinyMCE.init({
...
<strong>custom_undo_redo_levels : 10</strong>
});
</pre>
</div>
</div>
<div class="footer">
<div class="helpindexlink"><a href="index.html">Index</a></div>
<div class="copyright">Copyright &copy; 2003-2006 <a href="http://www.moxiecode.com">Moxiecode Systems AB</a></div>
<br style="clear: both" />
</div>
</body>
</html>
@@ -0,0 +1,38 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Option: custom_undo_redo_restore_selection</title>
<link href="css/screen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="header">
<h1>Option: custom_undo_redo_restore_selection</h1>
</div>
<div class="content">
<p>
This option gives you the possibility to turn on/off the restoration of the cursor/selection when a undo/redo event occurs. This option is enabled by default.
</p>
<div class="separator"></div>
<h3>Example of usage of the custom_undo_redo_restore_selection option:</h3>
<div class="example">
<pre>
tinyMCE.init({
...
<strong>custom_undo_redo_restore_selection : false</strong>
});
</pre>
</div>
</div>
<div class="footer">
<div class="helpindexlink"><a href="index.html">Index</a></div>
<div class="copyright">Copyright &copy; 2003-2006 <a href="http://www.moxiecode.com">Moxiecode Systems AB</a></div>
<br style="clear: both" />
</div>
</body>
</html>
+38
View File
@@ -0,0 +1,38 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Option: debug</title>
<link href="css/screen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="header">
<h1>Option: debug</h1>
</div>
<div class="content">
<p>
If the value of this option is set to &quot;true&quot; some debugging information will appear such as a list of what CSS files are used. The default value of this option is false.
</p>
<div class="separator"></div>
<h3>Example of usage of the debug option:</h3>
<div class="example">
<pre>
tinyMCE.init({
...
<strong>debug : true</strong>
});
</pre>
</div>
</div>
<div class="footer">
<div class="helpindexlink"><a href="index.html">Index</a></div>
<div class="copyright">Copyright &copy; 2003-2006 <a href="http://www.moxiecode.com">Moxiecode Systems AB</a></div>
<br style="clear: both" />
</div>
</body>
</html>
@@ -0,0 +1,38 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Option: dialog_type</title>
<link href="css/screen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="header">
<h1>Option: dialog_type</h1>
</div>
<div class="content">
<p>
This option enables you to specify how dialogs/popups should be opened, possible values are &quot;window&quot; and &quot;modal&quot;, where the window option opens a normal window and the dialog option opens a modal dialog. This option is set to &quot;window&quot; by default.
</p>
<div class="separator"></div>
<h3>Example of usage of the dialog_type option:</h3>
<div class="example">
<pre>
tinyMCE.init({
...
<strong>dialog_type : "modal"</strong>
});
</pre>
</div>
</div>
<div class="footer">
<div class="helpindexlink"><a href="index.html">Index</a></div>
<div class="copyright">Copyright &copy; 2003-2006 <a href="http://www.moxiecode.com">Moxiecode Systems AB</a></div>
<br style="clear: both" />
</div>
</body>
</html>
@@ -0,0 +1,38 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Option: directionality</title>
<link href="css/screen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="header">
<h1>Option: directionality</h1>
</div>
<div class="content">
<p>
This option specifies the default writing direction, some languages writes from right to left instead of left to right. The default value of this option is &quot:ltr&quot; but if you want to use from right to left mode specify &quot;rtl&quot; instead.
</p>
<div class="separator"></div>
<h3>Example of usage of the directionality option:</h3>
<div class="example">
<pre>
tinyMCE.init({
...
<strong>directionality : "rtl"</strong>
});
</pre>
</div>
</div>
<div class="footer">
<div class="helpindexlink"><a href="index.html">Index</a></div>
<div class="copyright">Copyright &copy; 2003-2006 <a href="http://www.moxiecode.com">Moxiecode Systems AB</a></div>
<br style="clear: both" />
</div>
</body>
</html>
@@ -0,0 +1,38 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Option: display_tab_class</title>
<link href="css/screen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="header">
<h1>Option: display_tab_class</h1>
</div>
<div class="content">
<p>
This option is useful when TinyMCE is used within tabs in MSIE. This property is needed since MSIE has a bug where it's impossible to retrive the width/height on elements like images while it's hidden using display:none. So use this property to define the class name that is used to hide a specific tab, this will help TinyMCE to display the tab while getting the image data.
</p>
<div class="separator"></div>
<h3>Example of usage of the display_tab_class option:</h3>
<div class="example">
<pre>
tinyMCE.init({
...
<strong>display_tab_class : "showTab"</strong>
});
</pre>
</div>
</div>
<div class="footer">
<div class="helpindexlink"><a href="index.html">Index</a></div>
<div class="copyright">Copyright &copy; 2003-2006 <a href="http://www.moxiecode.com">Moxiecode Systems AB</a></div>
<br style="clear: both" />
</div>
</body>
</html>
@@ -0,0 +1,38 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Option: docs_language</title>
<link href="css/screen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="header">
<h1>Option: docs_language</h1>
</div>
<div class="content">
<p>
This option should contain a language code of the editor documentation to use with TinyMCE. These codes are in <a href="http://www.loc.gov/standards/iso639-2/englangn.html">ISO-639-1</a> format to see if your language is available check the contents of &quot;tinymce/jscripts/tiny_mce/theme/&lt;theme used&gt;/docs&quot;. The default value of this option is the value specified in the &quot;language&quot; option or &quot;en&quot; for English.
</p>
<div class="separator"></div>
<h3>Example of usage of the docs_language option:</h3>
<div class="example">
<pre>
tinyMCE.init({
...
<strong>docs_language : "sv"</strong>
});
</pre>
</div>
</div>
<div class="footer">
<div class="helpindexlink"><a href="index.html">Index</a></div>
<div class="copyright">Copyright &copy; 2003-2006 <a href="http://www.moxiecode.com">Moxiecode Systems AB</a></div>
<br style="clear: both" />
</div>
</body>
</html>
@@ -0,0 +1,35 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Option: doctype</title>
<link href="css/screen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="header">
<h1>Option: doctype</h1>
</div>
<div class="content">
<p>This option enables you to specify the doctype that is used while editing content within TinyMCE, this defaults to <!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;>.</p>
<div class="separator"></div>
<h3>Example of usage of the doctype option:</h3>
<div class="example">
<pre>
tinyMCE.init({
...
<strong>doctype : &quot;&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;&quot;</strong>
});
</pre>
</div>
</div>
<div class="footer">
<div class="helpindexlink"><a href="index.html">Index</a></div>
<div class="copyright">Copyright &copy; 2003-2006 <a href="http://www.moxiecode.com">Moxiecode Systems AB</a></div>
<br style="clear: both" />
</div>
</body>
</html>
@@ -0,0 +1,36 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Option: document_base_url</title>
<link href="css/screen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="header">
<h1>Option: document_base_url</h1>
</div>
<div class="content">
<p>This option enables you to specify the URL from where all URLs will be relative to this option is only used when the <a href="option_relative_urls.html">relative_urls</a> option is set to true. The value of this option is set to the current document by default.</p>
<div class="separator"></div>
<h3>Example of usage of the document_base_url option:</h3>
<div class="example">
<pre>
tinyMCE.init({
...
<strong>document_base_url : "/somedir/somfile.html"</strong>
});
</pre>
</div>
</div>
<div class="footer">
<div class="helpindexlink"><a href="index.html">Index</a></div>
<div class="copyright">Copyright &copy; 2003-2006 <a href="http://www.moxiecode.com">Moxiecode Systems AB</a></div>
<br style="clear: both" />
</div>
</body>
</html>
@@ -0,0 +1,38 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Option: editor_css</title>
<link href="css/screen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="header">
<h1>Option: editor_css</h1>
</div>
<div class="content">
<p>
This option enables you to specify the CSS to be used for the editor toolbars/user interface of TinyMCE this option is set to a CSS file found in the currently used theme by default. This CSS contains layout information about panels and buttons used by TinyMCE.
</p>
<div class="separator"></div>
<h3>Example of usage of the editor_css option:</h3>
<div class="example">
<pre>
tinyMCE.init({
...
<strong>editor_css : "/myeditor.css"</strong>
});
</pre>
</div>
</div>
<div class="footer">
<div class="helpindexlink"><a href="index.html">Index</a></div>
<div class="copyright">Copyright &copy; 2003-2006 <a href="http://www.moxiecode.com">Moxiecode Systems AB</a></div>
<br style="clear: both" />
</div>
</body>
</html>
@@ -0,0 +1,49 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Option: editor_deselector</title>
<link href="css/screen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="header">
<h1>Option: editor_deselector</h1>
</div>
<div class="content">
<p>
This option enables you to specify a CSS class name that will be deselect textareas from being converted into editor instances. If this option isn't set to a value this option will not have any effect and the <a href="option_mode.html">mode</a> option will choose textareas instead. The default value of this option is &quot;mceNoEditor&quot; so if mceNoEditor is added to the class attribute of a textarea it will be excluded for convertion.
</p>
<div class="separator"></div>
<h3>Example of usage of the editor_deselector option:</h3>
<div class="example">
<pre>
tinyMCE.init({
...
<strong>editor_deselector : "mceNoEditor"</strong>
});
</pre>
</div>
<div class="separator"></div>
<h3>Example of usage in the HTML:</h3>
<div class="example">
<pre>
&lt;textarea id=&quot;myarea1&quot; class=&quot;<strong>mceNoEditor</strong>&quot;&gt;This will be a NOT be a editor.&lt;/textarea&gt;
&lt;textarea id=&quot;myarea2&quot;&gt;This will be a editor.&lt;/textarea&gt;
</pre>
</div>
</div>
<div class="footer">
<div class="helpindexlink"><a href="index.html">Index</a></div>
<div class="copyright">Copyright &copy; 2003-2006 <a href="http://www.moxiecode.com">Moxiecode Systems AB</a></div>
<br style="clear: both" />
</div>
</body>
</html>

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