function cleanup_text($str) { $str = strip_tags($str, "<li>"); $from[] = '<p> </p>'; $to[] = ''; $from[] = ' '; $to[] = ' '; $from[] = '<p>'; $to[] = ''; $from[] = '\\n'; $to[] = ''; $from[] = '\\r'; $to[] = ''; $from[] = '</p>'; $to[] = ""; $from[] = '<br>'; $to[] = ""; $from[] = '<br />'; $to[] = ""; $from[] = '<br/>'; $to[] = ""; $from[] = '<li>'; $to[] = " - "; $from[] = '</li>'; $to[] = ""; $from[] = 'ó'; $to[] = 'o'; $from[] = '"'; $to[] = '"'; $from[] = '&[^;]*;'; $to[] = ''; $from[] = '&'; $to[] = ''; $from[] = '\''; $to[] = ''; $from[] = '"'; $to[] = ''; $from[] = '<'; $to[] = ''; $from[] = '>'; $to[] = ''; $from[] = '('; $to[] = ' -'; $from[] = ')'; $to[] = '- '; $from[] = ']]>'; $to[] = ']] >'; $from[] = ''; $to[] = ''; for ($i = 0; $i < count($from); $i++) { $str = str_replace($from[$i], $to[$i], $str); } return filterevilchars($str); }
function search_output() { global $db, $opt; global $distance_unit, $startat, $count, $sql, $sqlLimit; $encoding = 'UTF-8'; $xmlLine = "\t<cache>\n\t\t<name><![CDATA[{cachename}]]></name>\n\t\t<owner id=\"{ownerid}\"><![CDATA[{owner}]]></owner>\n\t\t<id>{cacheid}</id>\n\t\t<waypoint>{waypoint}</waypoint>\n\t\t<hidden>{time}</hidden>\n\t\t<status id=\"{statusid}\">{status}</status>\n\t\t<lon value=\"{lonvalue}\">{lon}</lon>\n\t\t<lat value=\"{latvalue}\">{lat}</lat>\n\t\t<distance unit=\"" . $distance_unit . "\">{distance}</distance>\n\t\t<type id=\"{typeid}\">{type}</type>\n\t\t<difficulty>{difficulty}</difficulty>\n\t\t<terrain>{terrain}</terrain>\n\t\t<size id=\"{sizeid}\">{container}</size>\n\t\t<country id=\"{countryid}\">{country}</country>\n\t\t<link><![CDATA[" . $opt['page']['default_absolute_url'] . "viewcache.php?wp={waypoint}]]></link>\n\t\t<desc><![CDATA[{shortdesc}]]></desc>\n\t\t<hints><![CDATA[{hints}]]></hints>\n\t</cache>\n"; // create temporary table sql_temp_table_slave('searchtmp'); sql_slave('CREATE TEMPORARY TABLE &searchtmp SELECT SQL_BUFFER_RESULT SQL_CALC_FOUND_ROWS ' . $sql . $sqlLimit); $resultcount = sql_value_slave('SELECT FOUND_ROWS()', 0); $rsCount = sql_slave('SELECT COUNT(*) `count` FROM &searchtmp'); $rCount = sql_fetch_array($rsCount); mysql_free_result($rsCount); // start output if (!$db['debug']) { 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 "\t<docinfo>\n"; echo "\t\t<results>" . $rCount['count'] . "</results>\n"; echo "\t\t<startat>" . $startat . "</startat>\n"; echo "\t\t<perpage>" . $count . "</perpage>\n"; echo "\t\t<total>" . $resultcount . "</total>\n"; echo "\t</docinfo>\n"; } $rs = sql_slave("SELECT &searchtmp.`cache_id` `cacheid`,\n &searchtmp.`longitude` `longitude`,\n &searchtmp.`latitude` `latitude`,\n `caches`.`wp_oc` `waypoint`,\n `caches`.`date_hidden` `date_hidden`,\n `caches`.`name` `name`,\n `caches`.`country` `countrycode`,\n `caches`.`terrain` `terrain`,\n `caches`.`difficulty` `difficulty`,\n `caches`.`desc_languages` `desc_languages`,\n `cache_size`.`name` `size`,\n `cache_size`.`id` `size_id`,\n `cache_type`.`name` `type`,\n `cache_type`.`id` `type_id`,\n `cache_status`.`name` `status`,\n `cache_status`.`id` `status_id`,\n `user`.`username` `username`,\n `user`.`user_id` `user_id`,\n `cache_desc`.`desc` `desc`,\n `cache_desc`.`short_desc` `short_desc`,\n `cache_desc`.`hint` `hint`,\n `cache_desc`.`desc_html` `html`,\n &searchtmp.`distance` `distance`,\n `sys_trans_text`.`text` `country`\n FROM &searchtmp\n INNER JOIN `caches` ON &searchtmp.`cache_id`=`caches`.`cache_id`\n INNER JOIN `user` ON &searchtmp.`user_id`=`user`.`user_id`\n INNER JOIN `cache_desc`\n ON `caches`.`cache_id`=`cache_desc`.`cache_id` \n AND `caches`.`default_desclang`=`cache_desc`.`language`\n INNER JOIN `cache_type` ON `caches`.`type`=`cache_type`.`id`\n INNER JOIN `cache_status` ON `caches`.`status`=`cache_status`.`id`\n INNER JOIN `cache_size` ON `caches`.`size`=`cache_size`.`id`\n LEFT JOIN `countries` ON `countries`.`short`=`caches`.`country`\n LEFT JOIN `sys_trans_text` ON `sys_trans_text`.`trans_id`=`countries`.`trans_id`\n AND `sys_trans_text`.`lang`='&1'", $opt['template']['locale']); while ($r = sql_fetch_array($rs)) { if (strlen($r['desc_languages']) > 2) { $r = get_locale_desc($r); } $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}', text_xmlentities($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_gc(decodeEntities(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 converted from 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}', text_xmlentities(sprintf("%01.1f", $r['distance'])), $thisline); $thisline = lf2crlf($thisline); if (!$db['debug']) { echo $thisline; } } mysql_free_result($rs); sql_drop_temp_table_slave('searchtmp'); if (!$db['debug']) { echo "</result>\n"; } }
function xmlentities($str) { $from[0] = '&'; $to[0] = '&'; $from[1] = '<'; $to[1] = '<'; $from[2] = '>'; $to[2] = '>'; $from[3] = '"'; $to[3] = '"'; $from[4] = '\''; $to[4] = '''; for ($i = 0; $i <= 4; $i++) { $str = mb_ereg_replace($from[$i], $to[$i], $str); } $str = output_convert($str); return filterevilchars($str); }
$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('{container}', $r['size'], $thisline); $thisline = str_replace('{status}', $r['status'], $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('{distance}', htmlspecialchars(sprintf("%01.1f", $r['distance'])), $thisline); // logs ermitteln $logentries = ''; $thisline = lf2crlf($thisline); echo $thisline; } $dbcSearch->simpleQuery('DROP TABLE `xmlcontent` '); echo "</result>\n"; exit; function html2txt($html) { $str = preg_replace('/[[:cntrl:]]/', '', $html); $str = str_replace("\r\n", '', $str); $str = str_replace("\n", '', $str); $str = str_replace('<br />', "\n", $str);
$thisline = str_replace('{lonraw}', $r['longitude'], $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}', $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); } if ($r['html'] == 0) { $thisline = str_replace('{desc}', filterevilchars(strip_tags($r['desc'])), $thisline); } else { $thisline = str_replace('{desc}', html2txt(filterevilchars($r['desc'])), $thisline); } $thisline = str_replace('{type}', $r['type'], $thisline); $thisline = str_replace('{typeid}', $r['typeid'], $thisline); $thisline = str_replace('{container}', $r['size'], $thisline); $thisline = str_replace('{sizeid}', $r['sizeid'], $thisline); $thisline = str_replace('{status}', $r['status'], $thisline); $thisline = str_replace('{statusid}', $r['statusid'], $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('{ownerid}', $r['user_id'], $thisline); $thisline = str_replace('{owner}', $r['owner'], $thisline); echo $thisline; }
function restore_umlauts($str) { $from[0] = 'ä'; $to[0] = 'ä'; $from[1] = 'ä'; $to[1] = 'ä'; $from[2] = 'Ä'; $to[2] = 'Ä'; $from[3] = 'ö'; $to[3] = 'ö'; $from[4] = 'Ö'; $to[4] = 'Ö'; $from[5] = 'ü'; $to[5] = 'ü'; $from[6] = 'Ü'; $to[6] = 'Ü'; $from[7] = 'ß'; $to[7] = 'ß'; $from[8] = '€'; $to[8] = '€'; $from[9] = '®'; $to[9] = '®'; $from[10] = '™'; $to[10] = '™'; $from[11] = '&'; $to[11] = '&'; for ($i = 0; $i <= 11; $i++) { $str = mb_ereg_replace($from[$i], $to[$i], $str); } return filterevilchars($str); }
} // Pictures if (count($naPictures) > 0) { $sIds = ''; foreach ($naPictures as $id) { $sIds .= ', ' . $id; } $sIds = substr($sIds, 2); $rs = sql('SELECT `id`, `url`, `title`, `description`, `desc_html`, `object_id`, `object_type`, `date_created`, `uuid`, `last_modified` FROM `pictures` WHERE `id` IN (' . $sIds . ')'); for ($i = 0; $i < mysql_num_rows($rs); $i++) { $r = this_sql_fetch_array($rs); $sHTML = $r['desc_html'] == '1' ? '1' : '0'; echo $t1 . '<picture>' . "\n"; echo $t2 . '<id id="' . $r['id'] . '">' . $r['uuid'] . '</id>' . "\n"; echo $t2 . '<url>' . htmlentities(filterevilchars($r['url'])) . '</url>' . "\n"; echo $t2 . '<title>' . htmlentities_iso88592(filterevilchars($r['title'])) . '</title>' . "\n"; echo $t2 . '<object id="' . $r['object_id'] . '" type="' . $r['object_type'] . '" typename="' . $objecttypes[$r['object_type']] . '">' . object_id2uuid($r['object_id'], $r['object_type']) . '</object>' . "\n"; echo $t2 . '<datecreated>' . date($sDateformat, strtotime($r['date_created'])) . '</datecreated>' . "\n"; echo $t2 . '<lastmodified>' . date($sDateformat, strtotime($r['last_modified'])) . '</lastmodified>' . "\n"; echo $t1 . '</picture>' . "\n"; } mysql_free_result($rs); } // removed_objects if (count($naRemovedObjects) > 0) { $sIds = ''; foreach ($naRemovedObjects as $id) { $sIds .= ', ' . $id; } $sIds = substr($sIds, 2); $rs = sql('SELECT `id`, `localid`, `uuid`, `type`, `removed_date` FROM `removed_objects` WHERE `id` IN (' . $sIds . ')');