Verzeichnisstruktur phpBB-3.0.0
- Veröffentlicht
- 12.12.2007
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
generate_utf_casefold.php
001 <?php
002 /**
003 *
004 * @package phpBB3
005 * @version $Id$
006 * @copyright (c) 2005 phpBB Group
007 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
008 *
009 */
010
011 if (php_sapi_name() != 'cli')
012 {
013 die("This program must be run from the command line.\n");
014 }
015
016 //
017 // Security message:
018 //
019 // This script is potentially dangerous.
020 // Remove or comment the next line (die(".... ) to enable this script.
021 // Do NOT FORGET to either remove this script or disable it after you have used it.
022 //
023 die("Please read the first lines of this script for instructions on how to enable it");
024
025 set_time_limit(0);
026
027 define('IN_PHPBB', true);
028 $phpbb_root_path = '../';
029 $phpEx = substr(strrchr(__FILE__, '.'), 1);
030
031 echo "Checking for required files\n";
032 download('http://unicode.org/Public/UNIDATA/CaseFolding.txt');
033 echo "\n";
034
035
036 /**
037 * Load the CaseFolding table
038 */
039 echo "Loading CaseFolding\n";
040 $unidata = file_get_contents('CaseFolding.txt');
041
042
043 function utf8_chr($cp)
044 {
045 if ($cp > 0xFFFF)
046 {
047 return chr(0xF0 | ($cp >> 18)) . chr(0x80 | (($cp >> 12) & 0x3F)) . chr(0x80 | (($cp >> 6) & 0x3F)) . chr(0x80 | ($cp & 0x3F));
048 }
049 else if ($cp > 0x7FF)
050 {
051 return chr(0xE0 | ($cp >> 12)) . chr(0x80 | (($cp >> 6) & 0x3F)) . chr(0x80 | ($cp & 0x3F));
052 }
053 else if ($cp > 0x7F)
054 {
055 return chr(0xC0 | ($cp >> 6)) . chr(0x80 | ($cp & 0x3F));
056 }
057 else
058 {
059 return chr($cp);
060 }
061 }
062
063 preg_match_all('/^([0-9A-F]+); ([CFS]); ([0-9A-F]+(?: [0-9A-F]+)*);/im', $unidata, $array, PREG_SET_ORDER);
064
065 $uniarray = array();
066
067 foreach ($array as $value)
068 {
069 $uniarray[$value[2]][utf8_chr(hexdec((string)$value[1]))] = implode(array_map('utf8_chr', array_map('hexdec', explode(' ', $value[3]))));
070 }
071
072 foreach ($uniarray as $idx => $contents)
073 {
074 echo "Writing to case_fold_$idx.$phpEx\n";
075 $fp = fopen($phpbb_root_path . 'includes/utf/data/case_fold_' . strtolower($idx) . '.' . $phpEx, 'wb');
076 fwrite($fp, '<?php return ' . my_var_export($contents) . ';');
077 fclose($fp);
078 }
079
080 /**
081 * Return a parsable string representation of a variable
082 *
083 * This is function is limited to array/strings/integers
084 *
085 * @param mixed $var Variable
086 * @return string PHP code representing the variable
087 */
088 function my_var_export($var)
089 {
090 if (is_array($var))
091 {
092 $lines = array();
093
094 foreach ($var as $k => $v)
095 {
096 $lines[] = my_var_export($k) . '=>' . my_var_export($v);
097 }
098
099 return 'array(' . implode(',', $lines) . ')';
100 }
101 else if (is_string($var))
102 {
103 return "'" . str_replace(array('\\', "'"), array('\\\\', "\\'"), $var) . "'";
104 }
105 else
106 {
107 return $var;
108 }
109 }
110
111 /**
112 * Download a file to the develop/ dir
113 *
114 * @param string $url URL of the file to download
115 * @return void
116 */
117 function download($url)
118 {
119 global $phpbb_root_path;
120
121 if (file_exists($phpbb_root_path . 'develop/' . basename($url)))
122 {
123 return;
124 }
125
126 echo 'Downloading from ', $url, ' ';
127
128 if (!$fpr = fopen($url, 'rb'))
129 {
130 die("Can't download from $url\nPlease download it yourself and put it in the develop/ dir, kthxbai");
131 }
132
133 if (!$fpw = fopen($phpbb_root_path . 'develop/' . basename($url), 'wb'))
134 {
135 die("Can't open develop/" . basename($url) . " for output... please check your permissions or something");
136 }
137
138 $i = 0;
139 $chunk = 32768;
140 $done = '';
141
142 while (!feof($fpr))
143 {
144 $i += fwrite($fpw, fread($fpr, $chunk));
145 echo str_repeat("\x08", strlen($done));
146
147 $done = ($i >> 10) . ' KiB';
148 echo $done;
149 }
150 fclose($fpr);
151 fclose($fpw);
152
153 echo "\n";
154 }
155
156 ?>