一、function.php
##################################################################################### # 建立目錄 ##################################################################################### if (!function_exists("mk_dir")) { function mk_dir($dir = "") { #若無目錄名稱秀出警告訊息 if (empty($dir)) { return; } #若目錄不存在的話建立目錄 if (!is_dir($dir)) { umask(000); //若建立失敗秀出警告訊息 mkdir($dir, 0777); } } }
二、SEO必要事項
<html lang="zh" prefix="og: http://ogp.me/ns#">
<meta name="keywords" content="關鍵字"> <meta name="description" content="網頁描述" /> <meta name="author" content="作者名稱"> <meta name="copyright" content="版權所有人名稱"> <meta property="og:title" content="網站名稱或標題" /> <meta property="og:type" content="website" /> <meta property="og:url" content="網址" /> <meta property="og:image" content="要顯示的縮圖" /> <meta property="og:description" content="網頁描述" >
<title>商品 類別 網站標題</title>
二、update.php
三、系統變數
//-------- 系統變數 ----- go_update(); //-------- 系統變數 end--
######################################## # 將預設系統項目寫入資料庫. # formtype # textbox => 單行 # textarea => 多行 # file => 檔案 => valuetype # single_img =>單圖 # multiple_img => 多圖 ######################################## function go_update() { global $mysqli; $i = 0; #---- meta ---- #關鍵字 $configs['meta'][$i]['name'] = 'system_meta_keywords'; $configs['meta'][$i]['title'] = '關鍵字'; $configs['meta'][$i]['description'] = '請用半型逗點隔開'; $configs['meta'][$i]['formtype'] = 'textbox'; $configs['meta'][$i]['valuetype'] = 'text'; $configs['meta'][$i]['default'] = "關鍵字,關鍵字"; // #關鍵字 $i++; $configs['meta'][$i]['name'] = 'system_meta_description'; $configs['meta'][$i]['title'] = '網頁描述'; $configs['meta'][$i]['description'] = '網頁描述'; $configs['meta'][$i]['formtype'] = 'textarea'; $configs['meta'][$i]['valuetype'] = 'text'; $configs['meta'][$i]['default'] = ""; // #作者名稱 $i++; $configs['meta'][$i]['name'] = 'system_meta_author'; $configs['meta'][$i]['title'] = '作者名稱'; $configs['meta'][$i]['description'] = '作者名稱'; $configs['meta'][$i]['formtype'] = 'textbox'; $configs['meta'][$i]['valuetype'] = 'text'; $configs['meta'][$i]['default'] = "郭俊良"; // #作者名稱 $i++; $configs['meta'][$i]['name'] = 'system_meta_copyright'; $configs['meta'][$i]['title'] = '版權所有人名稱'; $configs['meta'][$i]['description'] = '版權所有人名稱'; $configs['meta'][$i]['formtype'] = 'textbox'; $configs['meta'][$i]['valuetype'] = 'text'; $configs['meta'][$i]['default'] = "育將電腦工作室"; // #FB要顯示的縮圖 $i++; $configs['meta'][$i]['name'] = 'system_meta_og_image'; $configs['meta'][$i]['title'] = 'FB要顯示的縮圖'; $configs['meta'][$i]['description'] = 'FB要顯示的縮圖'; $configs['meta'][$i]['formtype'] = 'file'; $configs['meta'][$i]['valuetype'] = 'single_img'; $configs['meta'][$i]['default'] = ""; // #輪播圖 $i++; $configs['slider'][$i]['name'] = 'system_slider_image'; $configs['slider'][$i]['title'] = '輪播圖'; $configs['slider'][$i]['description'] = '輪播圖'; $configs['slider'][$i]['formtype'] = 'file'; $configs['slider'][$i]['valuetype'] = 'multiple_img'; $configs['slider'][$i]['default'] = "1920"; // #寫入 //sn ofsn title sort enable kind url target foreach ($configs as $kind => $config_one) { foreach ($config_one as $sort => $config) { if (!check_system_nameKind($config['name'], $kind)) { $config['default'] = $mysqli->real_escape_string($config['default']); $sql = "insert into `creative_system` (`name`,`title`,`value`,`description`,`formtype`,`valuetype`,`sort`,`enable`,`kind`) values ('{$config['name']}','{$config['title']}','{$config['default']}','{$config['description']}','{$config['formtype']}','{$config['valuetype']}','{$sort}','1','{$kind}')"; //die($sql); $mysqli->query($sql) or redirect_header("index.php", 3000, "更新系統失敗!!"); } } } #------------------------------ return true; }
<{if $WEB.file_name =="index.php"}> <{include file="tpl/admin_index.html"}> <{elseif $WEB.file_name =="icon.php"}> <{include file="tpl/admin_icon.html"}> <{elseif $WEB.file_name =="system.php"}> <{include file="tpl/admin_system.html"}> <{/if}>
<{if $op == "op_list"}> <div class="panel panel-default"> <div class="panel-heading">系統變數管理列表</div> <!-- /.panel-heading --> <div class="panel-body"> <div class="row" style="margin-bottom: 10px;"> <div class="col-md-3"> <{$kind_form}> </div> </div> <div class="table-responsive"> <table class="table table-striped table-bordered table-hover"> <thead> <tr class="active"> <th class="col-md-1 text-center">序</th> <th class="col-md-3 text-center">變數名稱</th> <th class="col-md-7 text-center">變數值</th> <th class="col-md-1 text-center">功能</th> </tr> </thead> <tbody> <{foreach from=$rows item=row key=i}> <tr> <td class="text-center"><{<{$row.sort}>}></td> <td><{$row.title}></td> <td><{$row.value}></td> <td class="text-center"> <a href="?op=op_form&sn=<{$row.sn}>" class="btn btn-xs btn-success"> 編輯 </a> </td> </tr> <{/foreach}> </tbody> </table> </div> <!-- /.table-responsive --> </div> <!-- /.panel-body --> </div> <{/if}> <{if $op == "op_form"}> <div class="panel panel-primary"> <div class="panel-heading"><h3 class="panel-title">系統變數管理 - <{$row.form_title}></h3></div> <div class="panel-body"> <form role="form" action="<{$WEB.file_name}>" method="post" id="myForm" enctype="multipart/form-data"> <div class="row"> <div class="col-md-8"> <div class="form-group"> <label for="title"><{$row.title}></label> <{$row.form}> </div> </div> <div class="col-md-4"> <br /> <{$row.description}> </div> </div> <div class="form-group"> <button type="submit" class="btn btn-primary">送出</button> <button type="button" class="btn btn-warning" onclick="location.href=''">返回</button> <input type='hidden' name='kind' value='<{$row.kind}>'> <input type='hidden' name='name' value='<{$row.name}>'> <input type='hidden' name='op' value='<{$row.op}>'> <input type='hidden' name='sn' value='<{$row.sn}>'> <input type='hidden' name='return' value=''> </div> </form> </div> </div> <{/if}>
##################################################################################### # 取得系統變數值 # get_system_var($kind,$name,$key); # (資料表,類別,欄名,資料庫欄名)# # 給前台使用,只撈 enable=1 ##################################################################################### function get_system_var($kind = "", $name = "", $key = "value") { global $mysqli; if (empty($kind) or empty($name)) { return; } $sql = "select `{$key}` from `creative_system` where `kind`='{$kind}' and `name`='{$name}' and enable='1'"; //die($sql); $result = $mysqli->query($sql) or redirect_header("index.php", 3, "取得系統變數發生錯誤!!"); list($value) = $result->fetch_row(); return $value; }
#---- 取得關鍵字 $kind = "meta"; $name = "system_meta_keywords"; $meta['keywords'] = get_system_var($kind, $name); #---- 取得網頁描述 $kind = "meta"; $name = "system_meta_description"; $meta['description'] = get_system_var($kind, $name); #---- 取得作者名稱 $kind = "meta"; $name = "system_meta_author"; $meta['author'] = get_system_var($kind, $name); #---- 版權所有人名稱 $kind = "meta"; $name = "system_meta_copyright"; $meta['copyright'] = get_system_var($kind, $name); $smarty->assign("meta", $meta);