PHP + DBFILE Development Small Message This

xiaoxiao2021-03-06  41

Author: piscdong Time: 2004-4-8 Document Type: Original from: Blue ideal view statistics total: 4273 | year: 89 | Quarter: 89 | Month: 89 | Week: 7 | today: 3

I have been developing Blog in PHP DBFILE, I have learned a lot during the development process, so I try to write a small message. This message uses PHP DBFILE, does not need to use the database, can be used in Blog, such as http://www.customyze.com, the Tag Board in this blog is this message. The entire message requires four files, namely: Board.php, index.php, config.php, admin.php. Board.php is used to store data and you can add a message record in it. Code copy box

$ Board = array (

Array (1081410332, 'test', 'test message ",' http://www.piscdong.com ')

);

?> [Ctrl A All options and copy] Index.php is a message display and submission page. Code copy box

Require_once ('Board.php');

Function HTMLENCODE ($ Content) {

$ Content = HTMLSpecialchars ($ Content);

$ Content = preg_replace ("// r / i", "
", $ content);

RETURN $ Content;

}

IF ($ http_server_vars ['Request_Method'] == 'POST') {

$ configPath_Parts1 = PathInfo ($ Script_FileName);

$ TIME = Time ();

$ Name = $ http_post_vars ['name'];

$ URL = (PREG_MATCH ("/ ^ [// w -] * @ [// w -] (//. [// w -] ) $ / i ", $ http_post_vars ['url']) || $ http_post_vars ['URL'] == ')? $ http_post_vars [' URL ']:' http: //'.htmlspecialchars (preg_replace (" / https ? /: / i ", '', $ http_post_vars ['URL']), ENT_QUOTES;

$ INFO = HTMLENCode ($ http_post_vars ['info']);

IF ($ Name! = '' && $ INFO! = '') {

$ Board [] = Array ($ TIME, $ NAME, $ INFO, $ URL);

}

For ($ I = 0; $ I

$ bd = current ($ board);

$ S [] = "/ tarray (" $ bd [0]. ", '" $ bd [1]. "', '". $ bd [2]. ""', '". $ bd [3 ]. "")

NEXT ($ board);

$ Content = "";

$ filename = $ configPath_parts1 ['DIRNAME']. '/'. 'Board.php';

IF (IS_WRILENAME) ||! file_exists ($ filename)) {

IF (! $ handle = fopen ($ filename, 'w')) {

Return False;

}

IF (! fwrite ($ handle, $ content) {

Return False;

}

Fclose ($ handle);

} else {

Return False;

}

HEADER ('location :.');

} else {

?>

Message Ben </ Title></p> <p><meta http-equiv = "content-type" content = "text / html; charSet = GB2312" /></p> <p></ hEAD></p> <p><body></p> <p><form method = "post" name = "Form1" Action = ">></p> <p><table border = "0" cellspacing = "5" cellpadding = "0" align = "center"></p> <p><tr></p> <p><TD></p> <p><div style = "overflow: auto; height: 250px; border: 1px dotted # 999999; padding: 5px; Word-Wrap: Break-Word; Width: 400px;">></p> <p><? PHP</p> <p>End ($ board);</p> <p>For ($ I = 0; $ I <count ($ board); $ i ) {</p> <p>$ bd = current ($ board);</p> <p>$ S [] = '<strong>'. ($ BD [3]! = ''? '<a href = "': '). (preg_match (" / ^ [// w -] (///// [// w -] ) * @ [// w -] ) $ / i ", $ bd [3])? 'Mailto:': '' ). $ BD [3] (($ BD [3]! = '' &&! preg_match ("/ ^ [// w -] (//. [// w -] ) * @ [// W -] (//. [// w -] ) $ / i ", $ bd [3]))? '" target = "_ blank': '). ($ BD [3]! = ''? '">': '). $ BD [1]. ($ BD [3]! =' '?' </a> ':' ').': </ strong> '. $ bd [2]. '<Em> -'. Date ("g: i, m j, y", $ bd [0]). '</ Em>'; prev ($ board);</p> <p>}</p> <p>Echo Join ($ S, ');</p> <p>?></p> <p></ div></p> <p></ td></p> <p></ TR></p> <p><tr></p> <p><TD align = "center"></p> <p>Name: <input type = "text" name = "name" /> URL / email: <input type = "text" name = "url" /></p> <p><textarea name = "info" cols = "40" rows = "8"> </ textarea></p> <p><Input Type = "Submit" value = "release" /></p> <p></ td></p> <p></ TR></p> <p></ TABLE></p> <p></ form></p> <p></ body></p> <p></ html></p> <p><? php}?> [Ctrl a All Select All Selects and Copy] Config.php is stored in the password to manage the message, put the password in a single file. Convenient to modify. Code copy box <? Php $ password = '123456';?> [Ctrl a All Choose and copy] admin.php is a management page, which is simple, and can only delete a message. You need to enter the management password when deleting, and the management password is stored in Config.php. Code copy box <? PHP</p> <p>Require_once ('Board.php');</p> <p>Require_once ('config.php');</p> <p>IF (Isset ($ http_post_vars ['id') && $ http_post_vars ['id']! = '' && addslashes ($ http_post_vars ['password']) == $ password) {if (count ($ board)> 1 ) {</p> <p>UNSET ($ Board [INTVAL ($ http_post_vars ['id')]);</p> <p>For ($ I = 0; $ I <count ($ board); $ i ) {</p> <p>$ bd = current ($ board);</p> <p>$ S [] = "/ tarray (" $ bd [0]. ", '" $ bd [1]. "', '". $ bd [2]. ""', '". $ bd [3 ]. "")</p> <p>NEXT ($ Board);</p> <p>}</p> <p>$ Content = "<? PHP / N / $ BOARD = Array (/ N" .join ($ S, ", / N"). "/ n); / n?>";</p> <p>$ configPath_Parts1 = PathInfo ($ Script_FileName);</p> <p>$ filename = $ configPath_parts1 ['DIRNAME']. '/'. 'Board.php';</p> <p>IF (IS_WRILENAME) ||! file_exists ($ filename)) {</p> <p>IF (! $ handle = fopen ($ filename, 'w')) {</p> <p>Return False;</p> <p>}</p> <p>IF (! fwrite ($ handle, $ content) {</p> <p>Return False;</p> <p>}</p> <p>Fclose ($ handle);</p> <p>} else {</p> <p>Return False;</p> <p>}</p> <p>}</p> <p>HEADER ('loc.php');</p> <p>} else {</p> <p>?></p> <p><! Doctype html public "- // w3c // DTD XHTML 1.1 Transitional // En" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"></p> <p><html xmlns = "http://www.w3.org/1999/xhtml"></p> <p><HEAD></p> <p><title> Manage Message This </ Title></p> <p><meta http-equiv = "content-type" content = "text / html; charSet = GB2312" /></p> <p></ hEAD></p> <p><body></p> <p><table width = "500" border = "0" cellspacing = "1" cellpadding = "5" align = "center" bgcolor = "# 999999"></p> <p><? PHP</p> <p>For ($ I = 0; $ I <count ($ board); $ i ) {</p> <p>$ bd = current ($ board);</p> <p>$ S [] = '<tr> <td bgcolor = "#'. ($ I% 2! = 0? 'Ececec': 'fffff'). '"> <strong>'. ($ BD [3]! = ''? '<a href = "': '). (PREG_MATCH (" / ^ [// w -] (/// w -] ) * @ [// w -] (//.[//w-] ) $/i",$bd[3])?'mailto:':'').$bd[3].(($bd[3]!= ' '&&! preg_match ("/ ^ [// w -] * @ [// w -] (//. [// w -] ) $ / i ", $ bd [3])))? '" target = "_ blank': '). ($ BD [3]! =' ''"> ':'). $ BD [1]. ($ BD [3]! = ''? '</a>': ''). ': </ strong>'. $ BD [2]. '<em> -'. Date (" G: I, M J, Y ", $ BD [0]). '</ Em> </ td>'. (Count ($ board> 1? '<Td bgcolor =" #'. ($ I) 2! = 0? 'Ececec': 'ffffff'). '"Align =" center "> <form method =" post "action ="> <input type = "submit" value = "delete" /> <input TYPE = "name =" ID "value =" '. $ I.' "/> <input type =" password "name =" password "/> </ form> </ td> ':' '). '</ tr>'; Next ($ Board);</p> <p>}</p> <p>Echo Join ($ s, '');</p> <p>?></p> <p></ TABLE></p> <p></ body></p> <p></ html></p> <p><? php}?> [Ctrl A All Choose and then copy] This message is still very simple, the function is not perfect, such as no paging, etc., can continue to be improved. :-)</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-64725.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="64725" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.049</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'HNf692ws9D18auwltYpzXrtWNhA8Bp_2B02_2BIZ7TlJWLiEndqiXgQ7U4m_2FqVJMGT4NtNfKZIOHbAfl0B5_2B06w1xA_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>