Jump to content

Rosst

Members
  • Posts

    29
  • Joined

  • Last visited

    Never

Everything posted by Rosst

  1. I made a bbcode function for my news system, I wanted to add a php tag and so I tried but it didn't work, here is my code: [code]<? function bbcode($content){ $content = nl2br(htmlspecialchars($content));     $bbcode = array(        "'\[b\](.*?)\[/b\]'",        "'\[i\](.*?)\[/i\]'",        "'\[u\](.*?)\[/u\]'",        "'\[code\](.+?)\[/code\]'",        "'\[url=(.*?)\](.*?)\[/url\]'",        "'\[url\](.*?)\[/url\]'",        "'\[img\](.*?)\[/img\]'",          "'\[php\](.*?)\[/php\]'"         );                $html = array(         "<b>\\1</b>",         "<i>\\1</i>",         "<u>\\1</u>",         "<strong>Code:</strong><div style=\"margin:0px 10px;padding:5px;border:1px dotted #FFFFFF;width:80%;\"></em>\\1</em></div>",         "<a href=\"\\1\" target=\"_BLANK\">\\2</a>",         "<a href=\"\\1\" target=\"_BLANK\">\\1</a>",         "<img border=\"0\" src=\"\\1\">",         "<strong>PHP:</strong><div style=\"margin:0px 10px;padding:5px;border:1px dotted #FFFFFF;width:80%;\"></em><?php highlight_sting(\"\\1\"); ?></em></div>         );            $content = preg_replace($bbcode, $html, $content);     return nl2br($content); } ?>[/code] Oh also my news comments aren't showing up (I get the header and menu but no content) here is my code: [code]<?php ob_start(); // allows us to use cookies include("config.php"); // includes the config file if ($logged['username']){ // if the user is logged in they can view this switch($_GET['view']){ // news_comments.php?view= case 'news': // news_comments.php?view=news&id=$id $id = $_GET['acl']; // grabs the requested id $select = "select * from news where id=$id"; // selects the requested id from the database $select2 = "select * from news_comments where nid=$id ORDER BY id DESC"; // grabs comments for the news article $getnews = mysql_query($select) // querys the news db or die(mysql_error()); // die error! $getcomments = mysql_query($select2); // querys the comments db if (mysql_num_rows($getnews) == "0") { // if we are returned a nulled result echo 'Unable to find the article in our database'; // nothing found error! exit(); // exit } $row = mysql_fetch_array($getnews) // array or die(mysql_error()); // error! $nid = $row['id']; // news id $ntitle = $row['title']; // news title $ncontent = bbcode($row['content']); // news content with bbcode wrapped around it $nauthor = $row['author']; // news author $postdate = $row['postdate']; // news date     echo ("<tr>                 <td>$ntitle Posted by <a href=\"index.php?id=memb&user=$nauthor\">$nauthor</a> At $postdate<br></td>             </tr>                <tr>                 <td>$ncontent<br><br>Comments:<br></td>             </tr>");              if (mysql_num_rows($getcomments) == "0") { // if we are returned a nulled result for the comments echo a link to add em echo("There are no comments!<br>[<a href=\"index.php?id=newscom&view=addcomment&acl=$id\">Add a comment</a>]"); // add a link! } if($logged[username] && $logged[level] ==5) // if the user is a admin while($rowc= mysql_fetch_array($getcomments)){ // fetches an array $cauthor = $rowc['author']; // comment author $ccomment = bbcode($rowc['content']); // comment content $cdate = $rowc['postdate']; // comment date     echo ("<tr>                 <td>Comment Posted by <a href=\"index.php?id=memb&user=$nauthor\">$cauthor</a> At $cdate [<a href=\"index.php?id=newad&view=editcomment&acl=$id\">Edit</a>] [<a href=\"index.php?id=newad&view=deletecomment&acl=$id\">Delete</a>]<br></td>             </tr>                <tr>                 <td>$ccomment<br><br></td>             </tr>");     } while($rowc= mysql_fetch_array($getcomments)){ // if the user is a normal user echo this $cauthor = $rowc['author']; // comment author $ccomment = bbcode($rowc['content']); // comment content $cdate = $rowc['postdate']; // comment date     echo ("<tr>                 <td>Comment Posted by <a href=\"index.php?id=memb&user=$nauthor\">$cauthor</a> At $cdate<br></td>             </tr>                <tr>                 <td>$ccomment<br><br></td>             </tr>"); } echo("[<a href=\"index.php?id=newscom&view=addcomment&acl=$id\">Add a comment</a>]"); // add a comment break; case 'addcomment': // page for adding comments news_comments.php?view=addcomment&id=&id ob_start(); // cookies include("config.php"); // includes the config file $id = $_GET['acl']; // grabs the news id if(isset($_POST['add_comment'])) { // if the form has been submitted we query the db $author = $logged['username']; // comments author $postdate = date("g:i A, l F j"); // comments date $content = $_POST[content]; // comment $nid = $_GET['acl']; // news id $sql = "INSERT INTO news_comments ( `author` , `postdate`, `content`, `nid`) VALUES ('$author', '$postdate', '$comment', '$nid')"; // query for adding the comment $addblog = mysql_query($sql) // query?s the db or die(mysql_error()); // error! header("Location: index.php"); // redirects the user } else // the form has not been submitted so we display it { echo ("<form method=\"post\" name=\"addcomment\"> <tr>     <td height=\"20\">Comment:</td> </tr> <tr>     <td><br><textarea rows=\"5\" cols=\"35\" name=\"content\">Type your comment here!</textarea><br> <input type=\"submit\" name=\"add_comment\" value=\"Submit\"></td> </tr> </form>"); } } if (!isset($_GET['id'])) // if there is not requested id we redirect the user header("Location:index.php?id=news"); // goto news.php }else{ echo('Hey! you need to [<a href=http://vexxon.net/login.php>login</a>] first!'); // user is not logged in so they are asked to.'); } ?>[/code] And my link system is not working either, here is the code for it: [code] <?php ob_start(); // allows us to use cookies include("config.php"); // includes the config file if(!$logged[username]) { header("Location:http://vexxon.net"); // if they arent logged in or dont have admin powers they are redirected } function cleanlink($url) { $filter = array( "http://" => "", "www." => "", ); foreach ($filter as $remove => $stay) { $url = str_replace($remove, $stay, $url); } $filterurl = explode("/", $url); $bombedurl = $filterurl[0]; $url = "http://"; $url .= "$bombedurl"; $url .= "/"; return $url; } if(isset($_POST['submit'])) { $title=$_POST['title']; $url= cleanlink($_POST['url']); $description=$_POST['description']; $sql = mysql_query("INSERT INTO `links` ( `title` , `url` , `description` ) VALUES ('$title', '$url', '$description');"); // adds the link to the db header("Location:http://www.vexxon.net/index.php?id=links"); } else { ?> <form method="post" name="links"> <table width="52%" height="459" border="0"> <tr> <td valign="top">Links Title: </td> <td valign="top"><input name="title" type="text"></td> </tr> <tr> <td valign="top">Links URL: </td> <td valign="top"><input name="url" type="text" value="http://"></td> </tr> <tr> <td height="85" valign="top">Description: <br> </td> <td valign="top"><textarea cols="50" rows="20" name="description"></textarea> </td> </tr> <tr> <td height="25" valign="top"> </td> <td valign="top"><input type="submit" name="submit" value="Submit Link"></td> </tr> </table> </form> <? } ?>[/code]
  2. Rosst

    Need help

    Hey everyone, I changed some stuff and now my outputing works, I mean I see the content, but it seems the cookies aren't being set, here is my new code: [code]<?php ob_start(); include("config.php"); switch ($_GET['id']) { default: echo "Welcome to Vexxon.net, <a href='index.php?id=reg'>register now</a> to get access to the members area!!"; break; case 'reg': require("includes/register.php"); break; case 'log': if (!$logged[username]) { if (!$_POST[login]) { echo(" <center><form method=\"POST\" name=\"login\"> <table> <tr> <td align=\"center\"> Username: <input type=\"text\" size=\"15\" maxlength=\"25\" name=\"username\"> </td> </tr> <tr> <td align=\"center\"> Password: <input type=\"password\" size=\"15\" maxlength=\"25\" name=\"password\"> </td></tr><tr> <td align=\"center\"> <input type=\"submit\" name=\"login\" value=\"Login\"> </td></tr><tr> <td align=\"center\"> <a href=\"index.php?id=reg\">Register Here</a> </td></tr></table></form></center>"); } elseif ($_POST[login]) { // the form has been submitted. We continue... $username=$_POST['username']; $password = md5($_POST[password]); // the above lines set variables with the submitted information. $info = mysql_query("SELECT * FROM users WHERE username = '$username' AND password = '$password'") or die(mysql_error()); $data = mysql_fetch_array($info); if ($data[password] != $password || $data[username] != $username) { echo "Your password/username is wrong"; echo '</div> </div> <div class="footer"> <div align="center">©2005, vexxon productions</div> </div> </body> </html>'; exit(); } else { setcookie("id", $data[id], time()+(60*60*24*5), "/", ""); setcookie("pword", $data[password], time()+(60*60*24*5), "/", "");   Echo "You are logged in!"; header("Location: index.php?id=log"); } } } else { // we now display the user controls. $new = mysql_query("select * from pmessages where unread = 'unread' and touser = '$logged[username]'"); $new = mysql_num_rows($new); echo ("<center>Welcome <b>$logged[username]</b><br /></center> - <a href=\"index.php?id=editpro\">Edit Profile</a><br /> - <a href=\"index.php?id=memb\">Member List</a><br /> - <a href=\"index.php?id=pms\">Private Message Center ($new new)</a><br /> - <a href=\"index.php?id=logo\">Logout</a>"); } break; case 'memb': require("includes/members.php"); break; case 'on': require("includes/online.php"); break; case 'pms': require("includes/messages.php"); break; case 'logo': require("includes/logout.php"); break; case 'newad': require("includes/news_admin.php"); break; case 'editpro': require("includes/editprofile.php"); break; case 'news': require("includes/news.php"); break; case 'adm': require("includes/admin.php"); break; case 'newscom': require("includes/news_comments.php"); break; } ?>[/code]
  3. Rosst

    Need help

    [!--quoteo(post=380885:date=Jun 7 2006, 02:44 AM:name=Crayon Violent)--][div class=\'quotetop\']QUOTE(Crayon Violent @ Jun 7 2006, 02:44 AM) [snapback]380885[/snapback][/div][div class=\'quotemain\'][!--quotec--] first and foremost, I have to strongly scold you for your lack of indenting. debugging is a hell of a lot easier if you properly indent your code! that aside... 2nd, what do you mean by "nothing" is showing? do you get a blank page? certain variable(s) not showing? [/quote] Yes I get a blank page, I don't see why though.
  4. I was working on my site and I made a mistake in the log in section, the only section in my index.php other than the query stings, and now nothing is showing, I don't know why, please help me, this is my code: [code]<?php switch ($_GET['id']) { default: echo "Welcome to Vexxon.net, <a href='index.php?id=reg'>register now</a> to get access to the members area!!"; break; case 'reg': require("includes/register.php"); break; case 'log': include("config.php"); if (!$logged[username]) { if (!$_POST[login]) { echo(" <center><form method=\"POST\"> <table> <tr> <td align=\"center\"> Username: <input type=\"text\" size=\"15\" maxlength=\"25\" name=\"username\"> </td> </tr> <tr> <td align=\"center\"> Password: <input type=\"password\" size=\"15\" maxlength=\"25\" name=\"password\"> </td></tr><tr> <td align=\"center\"> <input type=\"submit\" name=\"login\" value=\"Login\"> </td></tr><tr> <td align=\"center\"> <a href=\"index.php?id=reg\">Register Here</a> </td></tr></table></form></center>"); } elseif ($_POST[login]) { // the form has been submitted. We continue... $username=$_POST['username']; $password = md5($_POST[password]); // the above lines set variables with the submitted information. $info = mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error()); $data = mysql_fetch_array($info); if ($data[password] != $password || $data[username] != $username) { echo "Your password/username is wrong"; exit(); } setcookie("id", $data[id], time()+(60*60*24*5), "/", ""); setcookie("pword", $data[pass], time()+(60*60*24*5), "/", "");   header("Location: login.php"); else { Echo "You are logged in!"; setcookie("uname", $data[id], time()+(60*60*24*5), "/", ""); setcookie("pword", $data[pass], time()+(60*60*24*5), "/", "");   header("Location: index.php?id=log"); } } } else { // we now display the user controls. $new = mysql_query("select * from pmessages where unread = 'unread' and touser = '$logged[username]'"); $new = mysql_num_rows($new); echo ("<center>Welcome <b>$logged[username]</b><br /></center> - <a href=\"index.php?id=editpro\">Edit Profile</a><br /> - <a href=\"index.php?id=memb\">Member List</a><br /> - <a href=\"index.php?id=pms\">Private Message Center ($new new)</a><br /> - <a href=\"index.php?id=logo\">Logout</a>"); } break; case 'memb': require("includes/members.php"); break; case 'on': require("includes/online.php"); break; case 'pms': require("includes/messages.php"); break; case 'logo': require("includes/logout.php"); break; case 'newad': require("includes/news_admin.php"); break; case 'editpro': require("includes/editprofile.php"); break; case 'news': require("includes/news.php"); break; case 'adm': require("includes/admin.php"); break; case 'newscom': require("includes/news_comments.php"); break; } ?>[/code]
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.