DevioLab CRYPTO TRADING AUTOMATION
LIVE
AUTOMATED CRYPTO TRADING • BINANCE
Автоматизуйте свій криптопортфель
Торгові боти DevioLab аналізують крипторинок, автоматично відкривають і закривають позиції та керують вашим портфелем на Binance 24/7.
CRYPTO 80 Bots
BINANCE Spot Trading
TRADING 24 / 7
Спробувати DevioLab
deviolab.com

Динамічний форум

Інформація про навчальний заклад

ВУЗ:
Національний університет Львівська політехніка
Інститут:
Не вказано
Факультет:
КН
Кафедра:
Не вказано

Інформація про роботу

Рік:
2013
Тип роботи:
Інші
Предмет:
Об’єктно-орієнтоване програмування

Частина тексту файла (без зображень, графіків і формул):

Міністерство освіти і науки України Національний університет “Львівська політехніка” Кафедра ПЗ Пояснювальна записка до курсової роботи з дисципліни “Об’єктно-орієнтоване програмування” на тему: “Динамічний форум”. Львів 2006 Довідникова програмна інтернет система ─ Форум. Завдання. Курсова робота повинна включати в себе можливість додавання записів, повинна бути передбачена можливість видалення записів; елементи ООП (об’єктно-орієнтованого програмування), які забезпечуються за допомогою мови PHP; зовнішній вигляд інтернет-сторінки, що забезпечується мовою HTML чи JAVA-скриптами. Виконання поставленого завдання. Вступ. Форум має лінійну тсруктуру. При перегляді теми можна прочитати всі повідомлення підряд зверху вниз і між повідомленнями немає ніякої службової інформації, лише ледь помітні горизонтальні лінії. При створенні нової теми чи додаванні повідомлення в тему вона “випливає” на перше місце в списку тем. Створений також режим адміністрування, у якому можна налаштувати зовнішній вигляд та внутрішні функції форуму. Текст програми. Дана курсова робота розроблялася в основному засобами мови програмування PHP і її текст складається з багатьох файлів. Текст кожного з них подано нижче. Файл .htaccess. Файл connect.inc повинен бути захищений засобами Apache за допомогою .htaccess, директива Files. <Files connect.inc> order allow,deny deny from all </Files> <Files .htaccess> order allow,deny deny from all </Files> Файл index.php. Цей файл використовується під’єднання основного скрипту, шо розмішений у файлі forum.php і для виведення привітання „Welcome to our forum”. <html> <head> <title> Forum </title> </head> <body> <font style="background: #479E47; color: white; margin: 0px 0 4px 0; font: normal 18px sans-serif; padding: 4px 2px 4px 4px; width: 100%">Welcome to our forum</font><br> <center> <? $f_incl_script="forum.php"; include($f_incl_script); ?> </center> </body> </html> Файл forum.php. Цей файл – це php-скрипт, який є основним файлом що відображає форум і підключає додаткові файли потрібні для роботи і адміністрування форуму. Ці файли розташовані в папці incl. <? if (empty($f_incl_script)) { $f_for_relative=""; } else { $f_for_relative=dirname($f_incl_script)."/"; } $forchangelines="one"; $showemails=trim(file_get_contents($f_for_relative."conf/showemails.txt")); include($f_for_relative."incl/scandir.php"); include($f_for_relative."incl/smilies.php"); if (empty($_GET['pagenum'])) { $_GET['pagenum']=0; } echo "\n \n \n <!-- Free forum provided by: ".file_get_contents($f_for_relative.'admin/conf/supporturl.txt')." -->\n \n \n"; echo "<link href=\"".$f_for_relative."templ/styles/".file_get_contents($f_for_relative."conf/css.txt").".css\" type=text/css rel=stylesheet>"; $layarr=file($f_for_relative."templ/layouts/".file_get_contents($f_for_relative."conf/layout.txt").".txt"); $f_top=$layarr[1]; $f_pre=$layarr[3]; $f_pre_two=$layarr[5]; $f_after=$layarr[7]; $f_bottom=$layarr[9]; $f_separ=$layarr[11]; $f_postinfoend=$layarr[13]; $f_posts_pre=$layarr[15]; $f_posts_after=$layarr[17]; $f_postr_pre=$layarr[19]; $f_postr_after=$layarr[21]; $f_beforeposttable=$layarr[23]; $f_afterposttable=$layarr[25]; $f_numofthispage=$layarr[27]; $f_numofthispage_end=$layarr[29]; $f_postnewsubj=$layarr[31]; $f_postnewreply=$layarr[33]; $f_smilies=$layarr[35]; if (empty($_GET['act'])) { $_GET['act']="subj"; } $f_messonpage=file_get_contents($f_for_relative."conf/messonpage.txt"); if ($_GET['act']=="subj") { // SHOW TOPICS START echo $f_top; $scandir=$f_for_relative."mess"; get_dir_files(); $filesoutput=$filearray; @sort($filesoutput); $filesoutput=@array_reverse($filesoutput); $f_i=$_GET['pagenum']*$f_messonpage; if (count($filesoutput)-$f_i>$f_messonpage) { $f_till=$f_i+$f_messonpage; } else { $f_till=count($filesoutput); $f_i=$_GET['pagenum']*$f_messonpage; } while ($f_i<$f_till) { if (is_dir($f_for_relative."mess/".$filesoutput[$f_i])) { if ($forchangelines=="one") { echo $f_pre; $forchangelines="two"; } else { echo $f_pre_two; $forchangelines="one"; } echo "<a href=?act=choosesubj&&id=".$filesoutput[$f_i]." class=f_link>"; $f_subj=stripslashes(file_get_contents($f_for_relative."mess/".$filesoutput[$f_i]."/topic.txt")); echo smilies($f_subj); echo "</a>"; echo $f_separ; echo substr($filesoutput[$f_i], 4, 2)."/".substr($filesoutput[$f_i], 6, 2)."/".substr($filesoutput[$f_i], 2, 2)." ".substr($filesoutput[$f_i], 8, 2).":".substr($filesoutput[$f_i], 10, 2).":".substr($filesoutput[$f_i], 12, 2); echo " by: "; echo stripslashes(file_get_contents($f_for_relative."mess/".$filesoutput[$f_i]."/addedby.txt")); if ($showemails=="yes") { echo " ("; echo stripslashes(file_get_contents($f_for_relative."mess/".$filesoutput[$f_i]."/email.txt")); echo ")"; } echo ","; echo " views: ".stripslashes(file_get_contents($f_for_relative."mess/".$filesoutput[$f_i]."/views.txt")); echo ","; unset($numofposts); unset($filearray); $scandir=$f_for_relative."mess/".$filesoutput[$f_i]."/mess"; get_dir_files(); $numofposts=count($filearray); echo " posts: "; echo $numofposts; echo $f_postinfoend; echo $f_after; } $f_i++; } echo $f_bottom; // start the pagenumbers links if (count($filesoutput)>$f_messonpage) { if ($_GET['pagenum']!=0) { $f_i_bef=0; while($f_i_bef<$_GET['pagenum']) { $f_i_toshow=$f_i_bef+1; echo "<a href=\"?act=subj&&pagenum=".$f_i_bef."\" class=f_pagenums>".$f_i_toshow."</a>"; $f_i_bef++; } } } echo $f_numofthispage; echo $_GET['pagenum']+1; echo $f_numofthispage_end; $f_pagenumnext=$_GET['pagenum']+1; if (count($filesoutput)>$f_messonpage*$f_pagenumnext) { $f_i_aft=$f_pagenumnext; while($f_i_aft*$f_messonpage<count($filesoutput)) { $f_i_toshow=$f_i_aft+1; echo "<a href=\"?act=subj&&pagenum=".$f_i_aft."\" class=f_pagenums>".$f_i_toshow."</a>"; $f_i_aft++; } } // end of the pagenumbers links // start new subject ?> <SCRIPT language=javascript> function validate() { if (add_subj.name.value == "") { alert("Your name, please!"); return false; } if (add_subj.email.value == "") { alert("Your email, please!"); return false; } if (add_subj.mess.value == "") { alert("And where is the subject?"); return false; } return true; } function smilies() { window.open("<? echo $f_for_relative;?>incl/opensmilies.php", "smilies", "toolbar=no, menubar=no, location=no, status=no, scrollbars=yes, width=20, height=500, left=100, top=200"); } </script> <? echo $f_postnewsubj; echo "<form action=\"".$f_for_relative."incl/addsubject.php\" method=post name=add_subj onsubmit=\"return validate();\" class=form_class>"; echo "<table><tr><td><font class=f_wordb4form>Name: </font></td><td><input type=text name=\"name\" class=f_text_form maxlength=22></td></tr>"; echo "<tr><td><font class=f_wordb4form>Email: </font></td><td><input type=text name=\"email\" class=f_text_form maxlength=50></td></tr>"; echo "<tr><td><font class=f_wordb4form>Message:</font></td><td><textarea class=addsubj name=mess>Your subject goes here</textarea><a href=\"javascript: smilies();\" class=smilies_link>".$f_smilies."</a></td></tr>"; echo "<tr><td>&nbsp;</td><td><input type=submit value=\"Add Subject\" class=f_submit_button></td></tr></table>"; echo "</font>"; // \"#\" onClick= // end of new subject // END OF SHOW TOPICS } if ($_GET['act']=="choosesubj") { // START OF SHOW POSTINGS echo str_replace("<!-- don't change this comment -->", "http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'], $f_beforeposttable); $postviews=file_get_contents($f_for_relative."mess/".$_GET['id']."/views.txt"); $postviews++; $inputfp=fopen($f_for_relative."mess/".$_GET['id']."/views.txt", "w"); $inputnew=fputs($inputfp, $postviews); fclose($inputfp); echo $f_top; echo $f_pre; echo $f_posts_pre; $f_subj=stripslashes(file_get_contents($f_for_relative."mess/".$_GET['id']."/topic.txt")); echo smilies($f_subj); echo $f_posts_after; echo $f_separ; echo substr($_GET['id'], 4, 2)."/".substr($_GET['id'], 6, 2)."/".substr($_GET['id'], 2, 2)." ".substr($_GET['id'], 8, 2).":".substr($_GET['id'], 10, 2).":".substr($_GET['id'], 12, 2); echo " by: "; echo stripslashes(file_get_contents($f_for_relative."mess/".$_GET['id']."/addedby.txt")); if ($showemails=="yes") { echo " ("; echo stripslashes(file_get_contents($f_for_relative."mess/".$_GET['id']."/email.txt")); echo ")"; } echo ","; echo " views: ".stripslashes(file_get_contents($f_for_relative."mess/".$_GET['id']."/views.txt")); echo ","; unset($numofposts); unset($filearray); unset($numofposts); $scandir=$f_for_relative."mess/".$_GET['id']."/mess/"; get_dir_files(); $numofposts=count($filearray); echo " posts: "; echo $numofposts; echo $f_postinfoend; echo $f_after; unset($filearray); unset($filesoutput); unset($numofposts); $scandir=$f_for_relative."mess/".$_GET['id']."/mess"; get_dir_files(); $filesoutput=$filearray; @sort($filesoutput); $filesoutput=@array_reverse($filesoutput); $f_i=$_GET['pagenum']*$f_messonpage; if (count($filesoutput)-$f_i>$f_messonpage) { $f_till=$f_i+$f_messonpage; } else { $f_till=count($filesoutput); $f_i=$_GET['pagenum']*$f_messonpage; } while ($f_i<$f_till) { echo $f_pre_two; echo $f_postr_pre; $f_subj=stripslashes(file_get_contents($f_for_relative."mess/".$_GET['id']."/mess/".$filesoutput[$f_i]."/mess.txt")); echo smilies($f_subj); echo $f_postr_after; echo $f_separ; echo substr($filesoutput[$f_i], 4, 2)."/".substr($filesoutput[$f_i], 6, 2)."/".substr($filesoutput[$f_i], 2, 2)." ".substr($filesoutput[$f_i], 8, 2).":".substr($filesoutput[$f_i], 10, 2).":".substr($filesoutput[$f_i], 12, 2); echo " by: "; echo stripslashes(file_get_contents($f_for_relative."mess/".$_GET['id']."/mess/".$filesoutput[$f_i]."/addedby.txt")); if ($showemails=="yes") { echo " ("; echo stripslashes(file_get_contents($f_for_relative."mess/".$_GET['id']."/mess/".$filesoutput[$f_i]."/email.txt")); echo ")"; } echo $f_postinfoend; echo $f_after; $f_i++; } echo $f_bottom; // start the pagenumbers links if (count($filesoutput)>$f_messonpage) { if ($_GET['pagenum']!=0) { $f_i_bef=0; while($f_i_bef<$_GET['pagenum']) { $f_i_toshow=$f_i_bef+1; echo "<a href=\"?act=choosesubj&&id=".$_GET['id']."&&pagenum=".$f_i_bef."\" class=f_pagenums>".$f_i_toshow."</a>"; $f_i_bef++; } } } echo $f_numofthispage; echo $_GET['pagenum']+1; echo $f_numofthispage_end; $f_pagenumnext=$_GET['pagenum']+1; if (count($filesoutput)>$f_messonpage*$f_pagenumnext) { $f_i_aft=$f_pagenumnext; while($f_i_aft*$f_messonpage<count($filesoutput)) { $f_i_toshow=$f_i_aft+1; echo "<a href=\"?act=choosesubj&&id=".$_GET['id']."&&pagenum=".$f_i_aft."\" class=f_pagenums>".$f_i_toshow."</a>"; $f_i_aft++; } } // end of the pagenumbers links echo str_replace("<!-- don't change this comment -->", "http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'], $f_afterposttable); // start new post ?> <SCRIPT language=javascript> function validate() { if (add_subj.name.value == "") { alert("Your name, please!"); return false; } if (add_subj.email.value == "") { alert("Your email, please!"); return false; } if (add_subj.mess.value == "") { alert("And where is the subject?"); return false; } return true; } function smilies() { window.open("<? echo $f_for_relative;?>incl/opensmilies.php", "smilies", "toolbar=no, menubar=no, location=no, status=no, scrollbars=yes, width=20, height=500, left=100, top=200"); } </script> <? echo $f_postnewreply; echo "<form action=\"".$f_for_relative."incl/addpost.php\" method=post name=add_subj onsubmit=\"return validate();\" class=form_class>"; echo "<table><tr><td><font class=f_wordb4form>Name: </font></td><td><input type=text name=\"name\" class=f_text_form maxlength=22></td></tr>"; echo "<tr><td><font class=f_wordb4form>Email: </font></td><td><input type=text name=\"email\" class=f_text_form maxlength=50></td></tr>"; echo "<tr><td><font class=f_wordb4form>Message: </font></td><td><textarea class=addsubj name=mess>Your reply goes here</textarea><a href=\"javascript: smilies();\" class=smilies_link>Smilies</a></td></tr>"; echo "<input type=hidden name=id value=".$_GET['id'].">"; echo "<tr><td>&nbsp;</td><td><input type=submit value=\"Post a Reply\" class=f_submit_button></td></tr></table>"; echo "</form>"; // end of new post //END OF SHOW POSTINGS } ?> Файл connect.inc. Цей файл ─ це PHP-скрипт який додає відповідь на вибрану тему. <? $MessLength=trim(file_get_contents("../conf/replylength.txt")); $err[1] = "Invalid e-mail"; $err[2] = "The subject cannot be longer than ".$MessLength." characters!"; function output_err($num) { global $err; ?> <center><h1>Error!</h1></center> <p><?=$err[$num];?> <? exit(); } if (!preg_match("/[0-9a-z_]+@[0-9a-z_^\.]+\.[a-z]{2,3}/i", $_POST['email'])) { output_err(1); } $_POST['email']=substr($_POST['email'], 0, 50); if (trim(file_get_contents("../conf/safeemails.txt"))=="yes") { $_POST['email']=str_replace("@"," at ",$_POST['email']); $_POST['email']=str_replace("."," dot ",$_POST['email']); } $_POST['name']=strip_tags($_POST['name']); $tagsallowedarr=file("../conf/tagsallowed.txt"); $tagsallowedstr=implode(", ", $tagsallowedarr); $_POST['mess']=strip_tags($_POST['mess'], $tagsallowedstr); $_POST['mess']=str_replace("\n","<br>",$_POST['mess']); if (strlen($_POST['mess'])>$MessLength) output_err(2); $_POST['name']=substr($_POST['name'], 0, 22); $mess_time="20".date('y').date('m').date('d').date('H').date('i').date('s'); mkdir("../mess/".$_POST['id']."/mess/".$mess_time); include("badwords.php"); $_POST['mess']=badwords($_POST['mess']); // For size of mess dir; $sizeformessdir=0; $sizeformessdir=strlen($_POST['name'])+strlen($_POST['email'])+strlen($_POST['mess']); if (!file_exists("../conf/sizeofmessdir.txt")) { $fp = fopen("../conf/sizeofmessdir.txt", "w"); $buffer = fputs($fp, "0"); fclose($fp); } $sizeformessdir=$sizeformessdir+file_get_contents("../conf/sizeofmessdir.txt"); $fp = fopen("../conf/sizeofmessdir.txt", "w"); $buffer = fputs($fp, $sizeformessdir); fclose($fp); // For size of mess dir END; $fp = fopen("../mess/".$_POST['id']."/mess/".$mess_time."/addedby.txt", "w"); $buffer = fputs($fp, $_POST['name']); fclose($fp); $fp = fopen("../mess/".$_POST['id']."/mess/".$mess_time."/email.txt", "w"); $buffer = fputs($fp, $_POST['email']); fclose($fp); $fp = fopen("../mess/".$_POST['id']."/mess/".$mess_time."/mess.txt", "w"); $buffer = fputs($fp, $_POST['mess']); fclose($fp); $if_notifyarr=file("../conf/notifynewreply.txt"); if (trim($if_notifyarr[0])=="yes") { $messtomail=substr($mess_time, 4, 2)."/".substr($mess_time, 6, 2)."/".substr($mess_time, 2, 2)." ".substr($mess_time, 8, 2).":".substr($mess_time, 10, 2).":".substr($mess_time, 12, 2)." ".$_POST['name']."(".$_POST['email']."): ".$_POST['mess']; if (trim($if_notifyarr[2])-17<strlen($messtomail)) { $messtomail=substr($messtomail, 0, $if_notifyarr[2]-20).".."; } $messtomail=stripslashes($messtomail); mail($if_notifyarr[1], "New forum reply added", $messtomail); } $backlocation= $_SERVER['HTTP_REFERER']; if (headers_sent()) { echo "The reply has been saved<br><form action=".$backlocation." method=get><input type=submit value=\"Go to forum\"</form>"; } else { header("Location: ".$backlocation); } ?> Файл addsubject.php. Цей файл ─ це PHP-скрипт який додає нову тему. <? $MessLength=trim(file_get_contents("../conf/messlength.txt")); $err[1] = "Invalid e-mail"; $err[2] = "The subject cannot be longer than ".$MessLength." characters!"; function output_err($num) { global $err; ?> <center><h1>Error!</h1></center> <p><?=$err[$num];?> <? exit(); } if (!preg_match("/[0-9a-z_]+@[0-9a-z_^\.]+\.[a-z]{2,3}/i", $_POST['email'])) { output_err(1); } $_POST['email']=substr($_POST['email'], 0, 50); if (trim(file_get_contents("../conf/safeemails.txt"))=="yes") { $_POST['email']=str_replace("@"," at ",$_POST['email']); $_POST['email']=str_replace("."," dot ",$_POST['email']); } $_POST['name']=strip_tags($_POST['name']); $tagsallowedarr=file("../conf/tagsallowed.txt"); $tagsallowedstr=implode(", ", $tagsallowedarr); $_POST['mess']=strip_tags($_POST['mess'], $tagsallowedstr); $_POST['mess']=str_replace("\n","<br>",$_POST['mess']); if (strlen($_POST['mess'])>$MessLength) output_err(2); $_POST['name']=substr($_POST['name'], 0, 22); include("badwords.php"); $_POST['mess']=badwords($_POST['mess']); // For size of mess dir; $sizeformessdir=0; $sizeformessdir=strlen($_POST['name'])+strlen($_POST['email'])+strlen($_POST['mess'])+6; if (!file_exists("../conf/sizeofmessdir.txt")) { $fp = fopen("../conf/sizeofmessdir.txt", "w"); $buffer = fputs($fp, "0"); fclose($fp); } $sizeformessdir=$sizeformessdir+file_get_contents("../conf/sizeofmessdir.txt"); $fp = fopen("../conf/sizeofmessdir.txt", "w"); $buffer = fputs($fp, $sizeformessdir); fclose($fp); // For size of mess dir END; if (file_get_contents("../conf/sizeofmessdir.txt")>file_get_contents("../conf/maxsizeofmessdir.txt")) { include("messdircleanup.php"); } $mess_time="20".date('y').date('m').date('d').date('H').date('i').date('s'); mkdir("../mess/".$mess_time); mkdir("../mess/".$mess_time."/mess"); $fp = fopen("../mess/".$mess_time."/addedby.txt", "w"); $buffer = fputs($fp, $_POST['name']); fclose($fp); $fp = fopen("../mess/".$mess_time."/email.txt", "w"); $buffer = fputs($fp, $_POST['email']); fclose($fp); $fp = fopen("../mess/".$mess_time."/topic.txt", "w"); $buffer = fputs($fp, $_POST['mess']); fclose($fp); $fp = fopen("../mess/".$mess_time."/views.txt", "w"); $buffer = fputs($fp, "0"); fclose($fp); $if_notifyarr=file("../conf/notifynewsubj.txt"); if (trim($if_notifyarr[0])=="yes") { $messtomail=substr($mess_time, 4, 2)."/".substr($mess_time, 6, 2)."/".substr($mess_time, 2, 2)." ".substr($mess_time, 8, 2).":".substr($mess_time, 10, 2).":".substr($mess_time, 12, 2)." ".$_POST['name']."(".$_POST['email']."): ".$_POST['mess']; if (trim($if_notifyarr[2])-17<strlen($messtomail)) { $messtomail=substr($messtomail, 0, $if_notifyarr[2]-20).".."; } $messtomail=stripslashes($messtomail); mail($if_notifyarr[1], "New forum subject", $messtomail); } $nogets=explode("?", $_SERVER['HTTP_REFERER']); $backlocation=$nogets[0]; if (headers_sent()) { echo "The new subject has been saved<br><form action=".$backlocation." method=get><input type=submit value=\"Go to forum\"</form>"; } else { header("Location: ".$backlocation); } ?> Файл badwords.php. Цей файл ─ це PHP-скрипт, який виконує перевірку на погані слова і заміняє їх заданими альтернативами. <? function badwords($checkthis) { $badwords_arr=file("../conf/badwords.txt"); $i_badw=0; while ($i_badw<count($badwords_arr)) { $badwords_arr[$i_badw]=trim($badwords_arr[$i_badw]); $i_badw++; } $replwith=trim(file_get_contents("../conf/badwordsrepl.txt")); $checked=str_replace($badwords_arr, $replwith, $checkthis); return $checked; } ?> Файл index.php. Цей файл забезпечує перегляд списку тем і показує список 20 тем по сторінках. Читає дані з таблиці topics. В кінці сторінки є форма для вводу нової теми, яка викликає скрипт newtopic.php
Антиботан аватар за замовчуванням

31.03.2013 21:41

Коментарі

Ви не можете залишити коментар. Для цього, будь ласка, увійдіть або зареєструйтесь.

Ділись своїми роботами та отримуй миттєві бонуси!

Нічого не вибрано
0%

Оголошення від адміністратора

Антиботан аватар за замовчуванням

Подякувати Студентському архіву довільною сумою

Admin

26.02.2023 12:38

Дякуємо, що користуєтесь нашим архівом!