| 1 |
<?php
|
| 2 |
if (!isset($_SERVER["argc"]))
|
| 3 |
{
|
| 4 |
echo ("Invalid usage");
|
| 5 |
exit();
|
| 6 |
}
|
| 7 |
|
| 8 |
chdir(dirname($_SERVER["argv"][0]));
|
| 9 |
|
| 10 |
require_once "../lib/db_open.inc.php";
|
| 11 |
require_once "../lib/common.inc.php";
|
| 12 |
|
| 13 |
$sql = "SELECT section_config.SID, section_config.title AS s_title FROM section_config
|
| 14 |
INNER JOIN section_class ON section_config.CID = section_class.CID
|
| 15 |
WHERE section_config.enable AND section_class.enable AND ex_update
|
| 16 |
ORDER BY section_class.sort_order, section_config.sort_order";
|
| 17 |
|
| 18 |
$rs = mysqli_query($db_conn, $sql);
|
| 19 |
if ($rs == false)
|
| 20 |
{
|
| 21 |
echo ("Query section error: " . mysqli_error($db_conn));
|
| 22 |
exit();
|
| 23 |
}
|
| 24 |
|
| 25 |
$new = false;
|
| 26 |
|
| 27 |
while ($row = mysqli_fetch_array($rs))
|
| 28 |
{
|
| 29 |
echo ("更新 [".$row["s_title"]."] 中...\n");
|
| 30 |
|
| 31 |
$buffer = shell_exec($PHP_bin . " ./gen_ex_section.php " . $row["SID"]);
|
| 32 |
echo ($buffer . "\n");
|
| 33 |
|
| 34 |
$new = true;
|
| 35 |
}
|
| 36 |
|
| 37 |
mysqli_free_result($rs);
|
| 38 |
mysqli_close($db_conn);
|
| 39 |
|
| 40 |
if ($new)
|
| 41 |
{
|
| 42 |
echo ("生成目录中...\n");
|
| 43 |
|
| 44 |
$buffer = shell_exec($PHP_bin . " gen_ex_index.php");
|
| 45 |
if (!$buffer || file_put_contents("../gen_ex/index.html", $buffer) == false)
|
| 46 |
{
|
| 47 |
echo ("Open output error!");
|
| 48 |
exit();
|
| 49 |
}
|
| 50 |
}
|
| 51 |
?>
|