42 lines
1.2 KiB
PHP
42 lines
1.2 KiB
PHP
<?php
|
|
/**
|
|
* 🍳 菜谱API管理页面
|
|
*
|
|
* 访问地址: /api/
|
|
*/
|
|
|
|
require '../zb_system/function/c_system_base.php';
|
|
$zbp->Load();
|
|
|
|
$tablePost = $zbp->db->dbpre . 'post';
|
|
$tableRecipeIngredient = $zbp->db->dbpre . 'recipe_ingredient';
|
|
|
|
$sqlRecipe = "SELECT COUNT(*) as total FROM $tablePost WHERE log_Type = 0 AND log_Status = 0";
|
|
$recipeResult = $zbp->db->Query($sqlRecipe);
|
|
$recipeCount = (int) ($recipeResult[0]['total'] ?? 0);
|
|
|
|
$sqlIngredient = "SELECT COUNT(DISTINCT name) as total FROM $tableRecipeIngredient";
|
|
$ingredientResult = $zbp->db->Query($sqlIngredient);
|
|
$ingredientCount = (int) ($ingredientResult[0]['total'] ?? 0);
|
|
|
|
$apiUrl = $zbp->host . 'api/api.php';
|
|
$apiActionUrl = $zbp->host . 'api/api_action.php';
|
|
|
|
$categories = array();
|
|
foreach ($zbp->categories as $cate) {
|
|
$categories[] = array('id' => $cate->ID, 'name' => $cate->Name);
|
|
}
|
|
|
|
$tags = array();
|
|
$tagList = $zbp->GetTagList('*', array(array('>', 'tag_Count', 0)), array('tag_Count' => 'DESC'), 50);
|
|
foreach ($tagList as $tag) {
|
|
$tags[] = array('id' => $tag->ID, 'name' => $tag->Name);
|
|
}
|
|
?>
|
|
<script>
|
|
window.API_URL = '<?php echo $apiUrl; ?>';
|
|
window.API_ACTION_URL = '<?php echo $apiActionUrl; ?>';
|
|
</script>
|
|
<?php
|
|
require 'templates/main.php';
|