function makeOne($dic) { $block = ""; $fd = fopen($dic["fidx_path"], "rb"); $offset = 0; $rec = false; while (true) { # if not EOF read next block if (!feof($fd)) { $block .= fread($fd, self::$block_size); } else { break; } $block_size = strlen($block); $next_offset = $offset + $block_size; # Process block $position = 0; // Points to beginning of every word $last_zero = 0; while (true) { $next_zero = @strpos($block, "", $position); $next_position = $next_zero + 8 + 1; # End of block if ($next_zero === false || $next_position > $block_size) { # Cut remaining block and break $block = substr($block, $position, $block_size); break; } # Extract word and prefix $word = substr($block, $position, $next_zero - $position); $prefix = mb_convert_case(mb_substr($word, 0, Z::config("prefix_length")), MB_CASE_LOWER); # Init prefix on first iteration if (!$rec) { $rec = array("start" => 0, "end" => 0, "prefix" => $prefix); } # Update end of prefix block $rec["end"] = $offset + $next_zero + 8; # Save prefix block if ($rec["prefix"] != $prefix) { $this->savePrefix($dic["fid"], $rec); # Start new prefix record $rec["prefix"] = $prefix; $rec["start"] = $offset + $position; } $position = $next_position; } $offset = $next_offset; } fclose($fd); }
function configMerge($upd) { self::$config = array_merge(self::$config, $upd); }
$idx = $next_zero + 8 + 1; } } $layout = '<?=$content?>'; eval("?>" . getTemplate('show') . "<?"); break; case 'stat': $layout = '<?=$content?>'; $list = Z::c()->query("SELECT fid, fversion, fwordcount, fbookname, fdescription FROM t_dic WHERE fstate_id = ? ORDER BY fbookname", Dic::DIC_GOOD); foreach ($list as $k => $v) { $list[$k]["fdescription"] = nl2br($list[$k]["fdescription"]); } echo json_encode($list); break; case 'admin.login': if ($_POST["password"] == Z::config("admin_password")) { $_SESSION["is_admin"] = 1; echo json_encode(true); } else { echo json_encode(false); } break; case 'admin': if (!$_SESSION["is_admin"]) { redirect("?m=home"); } eval("?>" . getTemplate('admin') . "<?"); break; case 'admin.reindex': if (!$_SESSION["is_admin"]) { redirect("?m=home");
</div> <div id="dlgAdmin" title="Admin area login" style="display:none;"> <div> <form> <input type="password" name="password" value=""><br/><br/> <input type="submit" name="submit" value="Login"> </form> </div> </div> <div id="container"> <div id="header"><h1>phpMyDict - <?php echo Z::config("version"); ?> </h1></div> <div id="wrapper"> <div id="content" style="overflow: auto;height:420px"> <p id="dic_content" > </p> </div> </div> <div id="navigation"> <p> <!-- Lookup in