\n"; if( $fh = @sugar_fopen( $the_file, "w" ) ){ fputs( $fh, $the_string); fclose( $fh ); return( true ); } else{ return( false ); } } function var_export_helper($tempArray) { if(!is_array($tempArray)){ return var_export($tempArray, true); } $addNone = 0; foreach($tempArray as $key=>$val) { if($key == '' && $val == '') $addNone = 1; } $newArray = var_export($tempArray, true); if($addNone) { $newArray = str_replace("array (", "array ( '' => '',", $newArray); } return $newArray; } function grabFiles($url) { $dh = fsockopen($url, 80); while($fileName = readdir($dh)) { if(is_dir($url.$fileName)) { grabFiles($url.$fileName); } $fh = sugar_fopen($url.$fileName, "r"); $fileContent = fread($fh, filesize($url.$fileName)); $writeFile = "./{$fileName}"; $fhLocal = sugar_fopen($writeFile, "w"); fwrite($writeFile, $fileContent); } } /////////////////////////////////////////////////////////////////////////////// //// START CODE while($file = readdir($dhUnicode)) { if(is_dir($file)) { $dhUniDeep = opendir("http://www.unicode.org/Public/MAPPINGS/OBSOLETE/EASTASIA/{$file}"); } } $dh = opendir("./"); $search = array(" ", " ", " ", " "); $replace = array("\t","\t","\t","\t"); if(is_resource($dh)) { while($inputFile = readdir($dh)) { if(strpos($inputFile, "php")) { continue; } $inputFileVarSafe = str_replace("-","_",$inputFile); $outputFile = $inputFileVarSafe.".php"; $fh = sugar_fopen($inputFile, "r"); if(is_resource($fh)) { $charset = array(); while($line = fgets($fh)) { $commentPos = strpos($line, "#"); if($commentPos == 0) { continue; // skip comment strings } $exLine = str_replace($search, $replace, $line); $exLine = explode("\t", $line); $count = count($exLine); if($count < 2) { echo "count was {$count} :: file is {$inputFile} :: Error parsing line: {$line}\r"; continue; // unexpected explode } // we know 0 is charset encoding // we know 1 is unicode in hex $countExLine = count($exLine); for($i=1; $i<$countExLine; $i++) { $exLine[$i] = trim($exLine[$i]); if($exLine[$i] != "") { $unicode = $exLine[$i]; break 1; } } $charset[$exLine[0]] = $unicode; } if(count($charset) > 0) { write_array_to_file($inputFileVarSafe, $charset, $outputFile); } } else { echo "Error occured reading line from file!\r"; } } } else { die("no directory handle"); } echo "DONE\r"; ?>