用法 {$_SERVER['argv'][0]} [options] [-p|--project] <project> [[-o|--output] <dir>] \t 选项说明 --project=<name|ini> -p <project> 用于指定要搜索的项目名称或项目配置文件的路径, 如果指定的是名称,则使用 ../app/<name>.ini 作为配置文件 --output=<dir>\t -o <dir> 指定生成的骨架代码存储位置,默认为当前目录 -h|--help 显示帮助信息 EOF; exit(0); } // output dir $output = XSUtil::getOpt('o', 'output', true); if ($output === null) { $output = '.'; } if (!is_dir($output)) { echo "错误:输出目录 ({$output}) 不是一个有效的目录。\n"; exit(-1); } if (!is_writable($output)) { echo "错误:输出目录 ({$output}) 不可写入,请注意检查权限。\n"; exit(-1); } // execute the search try { // create xs object echo "初始化项目对象 ...\n";
// long options $params = array('source', 'file', 'sql', 'rebuild', 'clean', 'flush', 'flush-log', 'info', 'csv-delimiter', 'filter'); $params[] = 'add-synonym'; $params[] = 'del-synonym'; $params[] = 'stop-rebuild'; $params[] = 'custom-dict'; foreach ($params as $_) { $k = strtr($_, '-', '_'); ${$k} = XSUtil::getOpt(null, $_); } // file & database $file = XSUtil::getOpt(null, 'file', true); $db = XSUtil::getOpt('d', 'db'); $scws_multi = XSUtil::getOpt(null, 'scws-multi'); // help message if (XSUtil::getOpt('h', 'help') !== null || !is_string($project) || !$custom_dict && !$stop_rebuild && !$flush && !$flush_log && !$info && !$clean && !$source && !$add_synonym && !$del_synonym && !$scws_multi) { $version = XS_PACKAGE_NAME . '/' . XS_PACKAGE_VERSION; echo <<<EOF Indexer - 索引批量管理、导入工具 ({$version}) 用法 {$_SERVER['argv'][0]} [options] [-p|--project] <project> [--file] <file> \t 选项说明 --project=<name|ini> -p <project> 用于指定要搜索的项目名称或项目配置文件的路径, 如果指定的是名称,则使用 ../app/<name>.ini 作为配置文件 --charset=<gbk|utf-8> -c <charset> 指定您当前在用以及数据源的字符集,以便系统进行智能转换(默认:UTF-8) --db=<name> -d <db> 指定项目中的数据库名称,默认是名为 db 的库
#!/usr/bin/env php <?php /** * Xunsearch PHP-SDK 运行条件检测 * * @author hightman * @link http://www.xunsearch.com/ * @copyright Copyright © 2011 HangZhou YunSheng Network Technology Co., Ltd. * @license http://www.xunsearch.com/license/ * @version $Id$ */ require_once dirname(__FILE__) . '/../lib/XS.php'; require dirname(__FILE__) . '/XSUtil.class.php'; // magick output charset XSUtil::parseOpt(array('c', 'charset')); $charset = XSUtil::getOpt('c', 'charset'); XSUtil::setCharset($charset); // result number record $result = array('PHP 版本' => array('type' => (version_compare(PHP_VERSION, '5.2.0', '>=') ? '' : 'ERROR:') . PHP_VERSION, 'used' => 'XS(core)', 'note' => 'PHP 5.2.0 或更高版本是必须的。'), 'SPL 扩展' => array('type' => extension_loaded('spl') ? 'OK' : 'ERROR', 'used' => 'XS(core)', 'note' => 'SPL 扩展用于自动加载和对象戏法'), 'PCRE 扩展' => array('type' => extension_loaded('pcre') ? 'OK' : 'ERROR', 'used' => 'XSDocument, XSSearch', 'note' => '用于字符串切割、判断'), '编码转换' => array('type' => check_conv(), 'used' => 'XSDocument, XSSearch', 'note' => '用于支持非 UTF-8 字符集'), '缓存模块' => array('type' => check_cache(), 'used' => 'XS', 'note' => '用于缓存项目配置文件的解析结果'), 'JSON 扩展' => array('type' => extension_loaded('json') ? 'OK' : 'WARNING', 'used' => 'util.Quest, util.Indexer', 'note' => '用于读取或输出 JSON 格式的数据'), 'XML 扩展' => array('type' => extension_loaded('xml') ? 'OK' : 'WARNING', 'used' => 'util.Indexer', 'note' => '用于读取导入 XML 格式的数据'), 'MySQL 扩展' => array('type' => check_mysql(), 'used' => 'util.Indexer', 'note' => '用于读取导入 MySQL 的数据库'), 'SQLite 扩展' => array('type' => check_sqlite(), 'used' => 'util.Indexer', 'note' => '用于读取导入 SQLite 的数据库')); // output ?> Xunsearch PHP-SDK 运行需求检查 ============================== 检查内容 -------- 本程序用于确认您的服务器配置是否能满足运行 Xunsearch PHP-SDK 的要求。 它将检查服务器所运行的 PHP 版本,查看是否安装了合适的PHP扩展模块,以及 确认 php.ini 文件是否正确设置。
$project = XSUtil::getOpt('p', 'project', true); $query = XSUtil::getOpt(null, 'query', true); // magick output charset $charset = XSUtil::getOpt('c', 'charset'); XSUtil::setCharset($charset); // long options $params = array('import', 'del', 'put', 'flush', 'hot', 'clean', 'limit'); foreach ($params as $_) { $k = strtr($_, '-', '_'); ${$k} = XSUtil::getOpt(null, $_); } if ($query === null && $put === null && $del === null && $flush === null && $import === null && $hot === null && $clean === null) { $hot = 'total'; } // help message if (XSUtil::getOpt('h', 'help') !== null || !is_string($project) || $import !== null && !is_string($import) || $query !== null && !is_string($query) || $put !== null && !is_string($put) || $del !== null && !is_string($del)) { $version = XS_PACKAGE_NAME . '/' . XS_PACKAGE_VERSION; echo <<<EOF Logger - 搜索日志管理工具 ({$version}) 用法 {$_SERVER['argv'][0]} [options] [-p|--project] [project] [[--query] <word>] 选项说明 --project=<name|ini> -p <project> 用于指定要搜索的项目名称或项目配置文件的路径, 如果指定的是名称,则使用 ../app/<name>.ini 作为配置文件 --charset=<gbk|utf-8> -c <charset> 指定您当前在用以及导入数据源的字符集,以便系统进行 智能转换(默认:UTF-8)
if ($pos = strpos($cut_off, ',')) { $search->setCutOff(substr($cut_off, 0, $pos), substr($cut_off, $pos + 1)); } elseif (strpos($cut_off, '.') !== false) { $search->setCutOff(0, $cut_off); } else { $search->setCutOff($cut_off); } } // preform search $begin = microtime(true); $result = $search->setLimit($limit1, $offset)->search(); $cost = microtime(true) - $begin; $matched = $search->getLastCount(); $total = $search->getDbTotal(); // show query? if (XSUtil::getOpt(null, 'show-query') !== null) { echo str_repeat("-", 20) . "\n"; echo "解析后的 QUERY 语句:" . $search->getQuery() . "\n"; echo str_repeat("-", 20) . "\n"; } // related & corrected $correct = $search->getCorrectedQuery(); $related = $search->getRelatedQuery(); // info printf("在 %s 条数据中,大约有 %d 条包含 [7m%s[m ,第 %d-%d 条,用时:%.4f 秒。\n", number_format($total), $matched, $query, min($matched, $offset + 1), min($matched, $limit1 + $offset), $cost); // correct if (count($correct) > 0) { echo "您是不是想找:[4m" . implode("[m [4m", $correct) . "[m\n"; } // show result foreach ($result as $doc) {
// magick output charset $charset = XSUtil::getOpt('c', 'charset'); XSUtil::setCharset($charset); // long options $params = array('source', 'file', 'sql', 'rebuild', 'clean', 'flush', 'flush-log', 'info', 'csv-delimiter', 'filter'); $params[] = 'add-synonym'; $params[] = 'del-synonym'; foreach ($params as $_) { $k = strtr($_, '-', '_'); ${$k} = XSUtil::getOpt(null, $_); } // file & database $file = XSUtil::getOpt(null, 'file', true); $db = XSUtil::getOpt('d', 'db'); // help message if (XSUtil::getOpt('h', 'help') !== null || !is_string($project) || !$flush && !$flush_log && !$info && !$clean && !$source && !$add_synonym && !$del_synonym) { $version = PACKAGE_NAME . '/' . PACKAGE_VERSION; echo <<<EOF Indexer - 索引批量管理、导入工具 ({$version}) 用法 {$_SERVER['argv'][0]} [options] [-p|--project] <project> [--file] <file> \t 选项说明 --project=<name|ini> -p <project> 用于指定要搜索的项目名称或项目配置文件的路径, 如果指定的是名称,则使用 ../app/<name>.ini 作为配置文件 --charset=<gbk|utf-8> -c <charset> 指定您当前在用以及数据源的字符集,以便系统进行智能转换(默认:UTF-8) --db=<name> -d <db> 指定项目中的数据库名称,默认是名为 db 的库
// Usage: burst.php // $Id$ require_once dirname(__FILE__) . '/../util/XSUtil.class.php'; // check arguments XSUtil::parseOpt(array('i', 'c', 't')); $test_con = XSUtil::getOpt('c', null, true); $test_type = XSUtil::getOpt('t'); $test_index = XSUtil::getOpt('i'); if ($test_type !== 'search') { $test_type = 'index'; } if ($test_index === null && $test_con === null) { $test_con = 100; } // show help if (XSUtil::getOpt('h', 'help') !== null || $test_con == null && $test_index == null) { echo <<<EOF Burst - XS 服务端并发测试工具 用法 {$_SERVER['argv'][0]} [options] [-c|-i] <num> \t 选项说明 -c <num> 设置测试的并发总量,用于启动进程,默认 100 -i <num> 设置测试的序列,用于实际运行进程 -t <type> 设置测试的类型,其值为 index 或 search,默认为 index -h|--help 显示帮助说明 EOF; exit(0); }