1<?php
2
3define('FCK_ACTION_SUBDIR', realpath(dirname(__FILE__)) . '/');
4
5$entities = array();
6serialize_ents('ents.data');
7serialize_ents('fcked-ents.data');
8serialize_ents('ents.merge.data');
9$file = "";
10
11if(isset($argv[1])) {
12     $f = $argv[1];
13     if ($f && file_exists($f)) $file = $f;
14}
15elseif(file_exists('add.ent')) {
16  $file = 'add.ent';
17
18}
19
20
21if($file && file_exists($file)) {
22   echo "adding entities from $file\n";
23   serialize_ents($file);
24}
25
26$serialized = FCK_ACTION_SUBDIR . 'ent.ser';
27file_put_contents($serialized,serialize($entities));
28//$ents = unserialize(file_get_contents($serialized));
29//print_r($ents);
30exit;
31
32function serialize_ents($file) {
33global $entities;
34
35    $entities_file = FCK_ACTION_SUBDIR . $file;
36    if(!file_exists($entities_file)) return;
37    $lines = file_get_contents($entities_file);
38    $lines_array=preg_split('/^\n/ms',$lines);
39
40    foreach ($lines_array as $line) {
41        if(isset($line) && strlen($line)) {
42            list($icon, $numeric,$character) = @preg_split('/\s+/',$line);
43            if(!$icon || !$numeric || !$character) continue;
44            $numeric = trim($numeric,'&#;');
45            $character=trim($character,'&;');
46            $entities[$numeric] = $icon;
47            $entities[$character] = $icon;
48        }
49
50
51    }
52
53     $entities[32] = ' ';
54     $entities['nbsp'] = ' ';
55}
56
57
58
59
60
61?>
62