2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 /*********************************************************************************
4 * SugarCRM is a customer relationship management program developed by
5 * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
7 * This program is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU Affero General Public License version 3 as published by the
9 * Free Software Foundation with the addition of the following permission added
10 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
11 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
12 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
19 * You should have received a copy of the GNU Affero General Public License along with
20 * this program; if not, see http://www.gnu.org/licenses or write to the Free
21 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
25 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
27 * The interactive user interfaces in modified source and object code versions
28 * of this program must display Appropriate Legal Notices, as required under
29 * Section 5 of the GNU Affero General Public License version 3.
31 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
32 * these Appropriate Legal Notices must retain the display of the "Powered by
33 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
34 * technical reasons, the Appropriate Legal Notices must display the words
35 * "Powered by SugarCRM".
36 ********************************************************************************/
38 /*********************************************************************************
40 * Description: TODO: To be written.
41 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
42 * All Rights Reserved.
43 * Contributor(s): ______________________________________..
44 ********************************************************************************/
45 // takes a file as an argument and parses the stuff as text;
47 function write_array_to_file( $the_name, $the_array, $the_file ) {
49 $the_string = "<?php\n" .
51 if(empty(\$GLOBALS["sugarEntry"])) die("Not A Valid Entry Point");
52 /*********************************************************************************
53 * SugarCRM is a customer relationship management program developed by
54 * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
56 * This program is free software; you can redistribute it and/or modify it under
57 * the terms of the GNU Affero General Public License version 3 as published by the
58 * Free Software Foundation with the addition of the following permission added
59 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
60 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
61 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
63 * This program is distributed in the hope that it will be useful, but WITHOUT
64 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
65 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
68 * You should have received a copy of the GNU Affero General Public License along with
69 * this program; if not, see http://www.gnu.org/licenses or write to the Free
70 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
73 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
74 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
76 * The interactive user interfaces in modified source and object code versions
77 * of this program must display Appropriate Legal Notices, as required under
78 * Section 5 of the GNU Affero General Public License version 3.
80 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
81 * these Appropriate Legal Notices must retain the display of the "Powered by
82 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
83 * technical reasons, the Appropriate Legal Notices must display the words
84 * "Powered by SugarCRM".
85 ********************************************************************************/
90 var_export_helper( $the_array ) .
93 if( $fh = @sugar_fopen( $the_file, "w" ) ){
94 fputs( $fh, $the_string);
103 function var_export_helper($tempArray) {
104 if(!is_array($tempArray)){
105 return var_export($tempArray, true);
109 foreach($tempArray as $key=>$val)
111 if($key == '' && $val == '')
115 $newArray = var_export($tempArray, true);
119 $newArray = str_replace("array (", "array ( '' => '',", $newArray);
125 function grabFiles($url) {
126 $dh = fsockopen($url, 80);
127 while($fileName = readdir($dh)) {
128 if(is_dir($url.$fileName)) {
129 grabFiles($url.$fileName);
132 $fh = sugar_fopen($url.$fileName, "r");
134 $fileContent = fread($fh, filesize($url.$fileName));
136 $writeFile = "./{$fileName}";
137 $fhLocal = sugar_fopen($writeFile, "w");
139 fwrite($writeFile, $fileContent);
143 ///////////////////////////////////////////////////////////////////////////////
146 while($file = readdir($dhUnicode)) {
148 $dhUniDeep = opendir("http://www.unicode.org/Public/MAPPINGS/OBSOLETE/EASTASIA/{$file}");
160 $search = array(" ", " ", " ", " ");
161 $replace = array("\t","\t","\t","\t");
164 if(is_resource($dh)) {
165 while($inputFile = readdir($dh)) {
166 if(strpos($inputFile, "php")) {
170 $inputFileVarSafe = str_replace("-","_",$inputFile);
171 $outputFile = $inputFileVarSafe.".php";
173 $fh = sugar_fopen($inputFile, "r");
174 if(is_resource($fh)) {
176 while($line = fgets($fh)) {
177 $commentPos = strpos($line, "#");
178 if($commentPos == 0) {
179 continue; // skip comment strings
183 $exLine = str_replace($search, $replace, $line);
184 $exLine = explode("\t", $line);
187 $count = count($exLine);
189 echo "count was {$count} :: file is {$inputFile} :: Error parsing line: {$line}\r";
190 continue; // unexpected explode
193 // we know 0 is charset encoding
194 // we know 1 is unicode in hex
195 $countExLine = count($exLine);
196 for($i=1; $i<$countExLine; $i++) {
197 $exLine[$i] = trim($exLine[$i]);
198 if($exLine[$i] != "") {
199 $unicode = $exLine[$i];
203 $charset[$exLine[0]] = $unicode;
207 if(count($charset) > 0) {
208 write_array_to_file($inputFileVarSafe, $charset, $outputFile);
212 echo "Error occured reading line from file!\r";
217 die("no directory handle");