Toggle main menu visibility
新聞
下載
教材
影音
討論
其他選單
好站連結
行事曆
電子相簿
常見問題
萬用表單
即時留言簿
友站消息
社大學員
:::
登入
登入
帳號
密碼
登入
重整畫面
:::
所有書籍
「[1062] PHP7入門」目錄
MarkDown
4-13 templtes/signup.tpl
1. 建構開發環境與系統規劃
1-1 Visual Studio Code編輯器完整設定
1-2 各種訊息整理
1-3 test.php
1-4 index.php
1-5 templates/index.tpl
2. 寫入資料到資料庫
2-1 templates/index.tpl
2-2 templates/admin.tpl
2-3 css/my.css
2-4 admin.php
3. 資料庫讀取與程式的整併
3-1 admin.php
3-2 index.php
3-3 function.php
3-4 templtes/index.tpl
4. 加入登入及管理功能
4-1 header.php
4-2 footer.php
4-3 index.php
4-4 admin.php
4-5 templtes/header.tpl
4-6 templtes/footer.tpl
4-7 templtes/index.tpl
4-8 templtes/admin.tpl
4-9 templates/op_show_article.tpl
4-10 templates/op_list_article.tpl
4-11 css/my.css
4-12 signup.php
4-13 templtes/signup.tpl
5. 編輯器及上傳縮圖
5-1 includes/mailsender.php
5-2 config.php
5-3 verifyuser.php
5-4 signup.php
5-5 header.php
5-6 admin.php
5-7 main_login.php
5-8 loginheader.php
5-9 index.php
5-10 css/my.css
5-11 templates/nav.tpl
5-12 templates/admin.tpl
5-13 templates/index.tpl
5-14 templates/signup.tpl
5-15 templates/verifyuser.tpl
5-16 templates/main_login.tpl
5-17 templates/op_article_form.tpl
5-18 ckeditor/config.js
5-19 elFinder/elfinder_cke.php
6. 使用上傳物件及管理功能
6-1 admin.php
6-2 index.php
6-3 templates/nav.tpl
6-4 templates/index.tpl
6-5 templates/admin.tpl
6-6 templates/footer.tpl
6-7 templates/op_article_form.tpl
6-8 templates/op_list_article.tpl
6-9 templates/op_show_article.tpl
6-10 css/my.css
6-11 reporter.sql
7. 多人合作開發
7-1 admin.php
7-2 index.php
7-3 function.php
7-4 templates/op_modify_article.tpl
7-5 templates/op_article_form.tpl
7-6 templates/op_modify_article.tpl
7-7 .gitignore
8. 文章分頁及搜尋
8-1 index.php
8-2 function.php
8-3 PageBar.php
8-4 search.php
8-5 css/my.css
8-6 templates/op_show_article.tpl
8-7 templates/op_list_article.tpl
8-8 templates/nav.tpl
8-9 templates/search.tpl
8-10 templates/op_search_article.tpl
8-11 templates/op_search_form.tpl
9. JOIN資料表及寄信功能
9-1 search.php
9-2 function.php
9-3 admin.php
9-4 templates/op_search_article.tpl
9-5 templates/op_show_article.tpl
5-1 includes/mailsender.php
\[1062\] PHP7入門 =============== ### 一、 完成登入機制 1. 先檢查UniForm Server是否有啟用php\_openssl.dll(PHP→Edit Basic and Modules→PHP Modules Enable/Disable) 2. 先處理寄信問題,修改config.php: ``` $mailServerType = 'smtp'; //IF $mailServerType = 'smtp' $smtp_server = 'smtp.gmail.com'; $smtp_user = '帳號@gmail.com'; $smtp_pw = '密碼'; $smtp_port = 587; //465 for ssl, 587 for tls, 25 for other $smtp_security = 'tls'; //ssl, tls or '' ``` 3. 修改includes/mailsender.php的20行為: ``` $mail->CharSet = "UTF-8"; ``` 4. 修改globalcon.php把其中第4行中的 6 + 刪除,最後會像這樣: ``` $signin_url = substr($base_url . $_SERVER['PHP_SELF'], 0, -(strlen(basename($_SERVER['PHP_SELF'])))); ``` 5. 分別修改 signup.php、verifyuser.php、main\_login.php將之套用樣板檔,若裡頭有任何地方有login/路徑的,請刪除之。 6. 記得修改選單nav.tpl,並修改資料庫架構,以便紀錄發文者。 7. [完整範例](https://www.tad0616.net/uploads/tad_book3/file/43/reporter.zip) ### 二、 修改管理頁面樣板 1. 放在footer.tpl的jquery.js可移至header.tpl,以應付越來越多的套件需求。 2. 可把隨機底圖部份的語法獨立出來,方便不同頁面套用,畢竟不是每個頁面都要大底圖。 ### 三、 安裝Ckeditor所見即所得編輯器 1. 下載
完整版Full Package 2. 編輯表單樣板檔並貼入以下語法: ```
``` 3. 使用內建的設定工具列:[localhost/reporter/ckeditor/samples/toolbarconfigurator/](localhost/reporter/ckeditor/samples/toolbarconfigurator/) ,將結果複製到 config.js 即可。 ### 四、 安裝elfinder檔案管理 1. 下載
,下載解壓並改名為elFinder 2. 將 elFinder/elfinder.html 改名為 elFinder/elfinder\_cke.html,以避免日後更新時,設定被覆蓋。 3. 修改 ckeditor/config.js ,在最後加入以下語法,以呼叫檔案管理工具: ``` config.filebrowserBrowseUrl = 'elFinder/elfinder_cke.html'; ``` 4. 下載
5. 修改 elFinder/elfinder\_cke.html 第10行為` main.cke.js` ``` ``` 6. 建立 files目錄(在linux下需設為777),將 elFinder/php/connector.minimal.php-dist 另存為 elFinder/php/connector.minimal.php 即可 ### 五、 上傳圖片 1. 若表單中有file元件,其表單編碼一定要加上: ``` enctype="multipart/form-data" ``` 2. 記得建立一個資料夾,例如:uploads(linux下權限記得設定為777) 3. 每上傳一個附檔(假設file欄位名稱為file),都會產生一組 $\_FILES 超級全域變數: - (1) $\_FILES\['file'\]\['name'\]:上傳檔案原始名稱。 - (2) $\_FILES\['file'\]\['type'\]:檔案的 MIME 類型,例如“image/gif”。 - (3) $\_FILES\['file'\]\['size'\]:已上傳檔案的大小,單位為bytes。 - (4) $\_FILES\['file'\]\['tmp\_name'\]:檔案被上傳後的臨時檔案名。 - (5) $\_FILES\['file'\]\['error'\]:和該檔案上傳相關的錯誤代碼。 4. 上傳的步驟:送出上傳→檔案會暫時放到tmp中→程式要搬移該檔到指定的位置。 5. 搬移上傳檔方法: ``` move_uploaded_file(暫存檔 , 新路徑檔名) ``` 6. 取得附檔名的方法: ``` $ext = pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION); ``` ### 六、 隨機假圖
1. 用法: ```
``` ### 七、 上傳工具 1. [https://www.verot.net/php\_class\_upload.htm](https://www.verot.net/php_class_upload.htm)下載解壓,把class.upload.php及lang目錄放到reporter目錄中。 2. 建立uploads資料夾,並產生縮圖並轉檔: ``` require_once 'class.upload.php'; $foo = new Upload($_FILES['cover']); if ($foo->uploaded) { // save uploaded image with a new name $foo->file_new_name_body = 'cover_' . $sn; $foo->image_resize = true; $foo->image_convert = png; $foo->image_x = 1200; $foo->image_ratio_y = true; $foo->Process('uploads/'); if ($foo->processed) { $foo->file_new_name_body = 'thumb_' . $sn; $foo->image_resize = true; $foo->image_convert = png; $foo->image_x = 400; $foo->image_ratio_y = true; $foo->Process('uploads/'); } } ``` ### 八、 用HTML Purifier阻擋 XSS 攻擊 1. 官網:http://htmlpurifier.org, 2. 下載解壓縮並把library複製到reporter下,建議改名為HTMLPurifier,接著在讀取單一篇文章的函數中加入: ``` require_once 'HTMLPurifier/HTMLPurifier.auto.php'; $config = HTMLPurifier_Config::createDefault(); $purifier = new HTMLPurifier($config); $data['content'] = $purifier->purify($data['content']); ``` ### 九、 加入Markdown編輯器 1. 官網:
,手冊:
2. 下載解壓並改名為editor,接著編輯表單樣板檔並貼入以下語法: ```
``` 3. 原先輸入框部份改為 ```
``` 4. 在editor下建立uploads資料夾,並將editor/examples下的php複製到editor下 5. 修改editor/php/upload.php,將 new EditorMdUploader();最後一個參數從false改為1,以便讓程式自動產生隨機檔名。 ### 十、 將Markdown轉為HTML 1. 在顯示單一文章的樣板檔前加入: ```
``` 2. 原本的內容區改為: ```
{$article.content}
```
:::
搜尋
search
進階搜尋
QR Code 區塊
快速登入
所有討論區
「PHP全端開發」線上課程討論區
XOOPS使用討論區
一般研習學員
社大學員專用
路過哈啦區
XOOPS佈景設計
XOOPS模組開發
Tad書籍區
即時留言簿
書籍目錄
展開
|
闔起
線上使用者
74
人線上 (
21
人在瀏覽
線上書籍
)
會員: 0
訪客: 74
更多…