KillaCode

Moderators: Moderator, Global Moderator

Post Reply
Scott
Administrator
Administrator
Posts: 0
Joined: Sun Apr 25, 2004 1:08 pm

KillaCode

Post by Scott »

KillaCode.com is something I would like to get started asap. However, rather than Rob making a purdy layout and me doing some PHP, I think its time we swapped some roles around. As you can see, we\'re currently a little low on the layout side <_<

If anyone feels like helping out with the layout and/or the coding, let me know here or via pm. The bonus for this site is that time limit is not a major issue, but we would like the site active somepoint before the domain expires.
Tami
Administrator
Administrator
Posts: 0
Joined: Sun Apr 25, 2004 1:05 pm

KillaCode

Post by Tami »

Nice layout Scott...did you code that all in one day?

We do have a snippet library script that was coded by a group on sourceforge however it\'s still in beta; if anyone would like to have a look at it to see what\'s what, you\'re more than welcome to, just ask.

KillaCode will have snippets, downloads, tutorials, articles, other coding reference stuff...pretty well the contents of the Code Crypt section here on the KG forum will be moved to KillaCode.
Image

[color=\"#41211C\"]It takes years to build up trust and only seconds to destroy it

[/color]
radar
Newbie
Newbie
Posts: 0
Joined: Thu Jun 17, 2004 12:37 am

KillaCode

Post by radar »

Dear god&#33;

That layout OWNS.

I'll help out. Just tell me what to do.
Tami
Administrator
Administrator
Posts: 0
Joined: Sun Apr 25, 2004 1:05 pm

KillaCode

Post by Tami »

Something professional looking utilizing the KillaNet theme which can accomodate the sub-forum areas from the Code Crypt section on the forum:

Code Crypt Support,
Basic Web Design,
Cascading Style Sheets,
(X)HTML,
Hosting Help,
j&#097;v&#097;script,
MySQL,
PHP Scripting,
Perl,
Programming Challenges,
Python,
Web Builder News & Events,
Reference,
Web Building Software

These will need to be in an easily navigable format, tutorials need to be well indexed and easy to find, the snippets section needs to be similarly indexed.

Here is the snippets script I mentioned earlier:

[attachment=873]attachment[/attachment]

These are some notes that were given to me along with the script:
http://sourceforge.net/projects/php-csl/

it\'s just been rewritten to correct a bug where all "+" symbols were stripped from the output.
Nasty bug that was!
And reverse encryption code storage has been eliminated, probably due to that same bug.

You\'ll probably need to add a user account setup and submission aprovals cause I think only admins and superusers can add code right now.
Last edited by Tami on Thu May 05, 2005 12:52 am, edited 1 time in total.
Image

[color=\"#41211C\"]It takes years to build up trust and only seconds to destroy it

[/color]
Trinity
Newbie
Newbie
Posts: 0
Joined: Wed May 05, 2004 9:19 am

KillaCode

Post by Trinity »

This should save a lot of the coding, just the layout stuff needs to be changed over.

Fully commented database class, just needs the variables updated - totally OOP, easy to use.

Code: Select all

<?php 
	/* 
 &nbsp;CodeCrypt.org
 &nbsp;Name&#58; cDatabase.php 
 &nbsp;Path&#58; _lib/_classes/cDatabase.php
 &nbsp;Desc&#58; Database Connection Class
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Auth&#58; Trinity
	*/
	
	class cDataBase {
 &nbsp;// Database Variables
 &nbsp;// _dbVarName
 &nbsp;var &#036;_dbHost = 'localhost';
 &nbsp;var &#036;_dbUser = 'codec';
 &nbsp;var &#036;_dbPass = 'pr3dat0r';
 &nbsp;var &#036;_dbName = 'code';
 &nbsp;
 &nbsp;// Data Storing Variables
 &nbsp;// _dVarName
 &nbsp;var &#036;_dConnection;
 &nbsp;var &#036;_dResult;
 &nbsp;var &#036;_dItems = array&#40;&#41;;
	
 &nbsp;// Constructor Function &#40;init&#41;
 &nbsp;function cDataBase&#40;&#41; {
 	&nbsp;&#036;this-> _dConnection = &#036;this->dbConnect&#40;&#41;;
 &nbsp;}
 &nbsp;
 &nbsp;// Function to connect to the database
 &nbsp;function dbConnect&#40;&#41; {
 	&nbsp;if &#40;mysql_connect&#40;&#036;this-> _dbHost, &#036;this-> _dbUser, &#036;this-> _dbPass&#41;&#41; {
 &nbsp; &nbsp;&#036;this-> _dConnection = mysql_connect&#40;&#036;this-> _dbHost, &#036;this-> _dbUser, &#036;this-> _dbPass&#41;;
 &nbsp; &nbsp;mysql_select_db&#40;&#036;this-> _dbName, &#036;this-> _dConnection&#41;;
 &nbsp; &nbsp;return &#036;this-> _dConnection;
 	&nbsp;}
 	&nbsp;else {
 &nbsp; &nbsp;return mysql_error&#40;&#41;;
 	&nbsp;}
 &nbsp;}	
 &nbsp;
 &nbsp;// Function to Query database, but return no data
 &nbsp;// Will return either "True" or a mysql_error&#40;&#41;
 &nbsp;// Requires input of vaild query string
 &nbsp;function doQuery&#40;&#036;sql&#41; {
 	&nbsp;if &#40;&#33;mysql_query&#40;&#036;sql, &#036;this-> _dConnection&#41;&#41; {
 &nbsp; &nbsp;return mysql_error&#40;&#41;;
 	&nbsp;}
 	&nbsp;return true;
 &nbsp;}
 &nbsp;
 &nbsp;// Function to Query database, when accessing data
 &nbsp;// Returns a data array or mysql_error&#40;&#41;
 &nbsp;// Requires input of valid query string
 &nbsp;function doQueryResult&#40;&#036;sql&#41; {
 	&nbsp;&#036;this-> _dItems = "";
 	&nbsp;if &#40;&#036;sql &#33;= ""&#41; {
 &nbsp; &nbsp;&#036;this-> _dResult = mysql_query&#40;&#036;sql, &#036;this-> _dConnection&#41;;
 &nbsp; &nbsp;&#036;dItem = array&#40;&#41;;
 &nbsp; &nbsp;while &#40;&#036;dItem = mysql_fetch_array&#40;&#036;this-> _dResult&#41;&#41; {
 &nbsp; 	&nbsp;&#036;this-> _dItems&#91;&#93; = &#036;dItem;
 &nbsp; &nbsp;}
 &nbsp; &nbsp;return &#036;this-> _dItems;
 &nbsp; &nbsp;mysql_free_result&#40;&#036;this-> _dResult&#41;;
 	&nbsp;}
 	&nbsp;else {
 &nbsp; &nbsp;return mysql_error&#40;&#41;;
 	&nbsp;}
 &nbsp;}
 &nbsp;
 &nbsp;// Function to Query database, when accessing data
 &nbsp;// Returns a data array or mysql_error&#40;&#41;
 &nbsp;// Requires input of valid query string
 &nbsp;function doCountRow&#40;&#036;sql&#41; {
 	&nbsp;if &#40;&#036;sql &#33;= ""&#41; {
 &nbsp; &nbsp;&#036;this-> _dResult = mysql_query&#40;&#036;sql, &#036;this-> _dConnection&#41;;
 &nbsp; &nbsp;&#036;dItem = mysql_fetch_row&#40;&#036;this-> _dResult&#41;;
 &nbsp; &nbsp;&#036;this-> _dResult = &#036;dItem&#91;'0'&#93;;
 &nbsp; &nbsp;return &#036;this-> _dResult;
 	&nbsp;}
 	&nbsp;else {
 &nbsp; &nbsp;return mysql_error&#40;&#41;;
 	&nbsp;}
 &nbsp;}
 &nbsp;
 &nbsp;// Close connection to the databse
 &nbsp;function dbDisconnect&#40;&#41; {
 	&nbsp;mysql_close&#40;&#036;this-> _dConnection&#41;;
 	&nbsp;return true;
 &nbsp;}
	}
	
?>
User class code, may be useful:

Code: Select all

<?php 
	/* 
 &nbsp;CodeCrypt.org
 &nbsp;Name&#58; cUsers.php 
 &nbsp;Path&#58; _lib/_classes/cUsers.php
 &nbsp;Desc&#58; CodeCrypt Users
	*/
	
	// Make sure we have access to the databse
	require_once&#40;'cDatabase.php'&#41;;

	class cUsers {
 &nbsp;
 &nbsp;// Constant Variabls
 &nbsp;var &#036;_table = "users";
 &nbsp;
 &nbsp;// Other Variables
 &nbsp;var &#036;_dbCon;
 &nbsp;
 &nbsp;// Constructor Function &#40;init&#41;
 &nbsp;function cUsers&#40;&#41; {
 	&nbsp;&#036;this->_dbCon = new cDataBase&#40;&#41;;
 &nbsp;}
 &nbsp;
 &nbsp;/* &nbsp;#######################################
 	&nbsp;Internal Functions
 &nbsp;*/ &nbsp;#######################################
 &nbsp;
 &nbsp;// Check to see if a name exists
 &nbsp;// Vaild &#036;name required
 &nbsp;function _checkName&#40;&#036;username&#41; {
 	&nbsp;&#036;sql = "SELECT * FROM &#036;this->_table WHERE &#96;username&#96;='".&#036;username."'";
 	&nbsp;if &#40;&#036;results = &#036;this->_dbCon->doQueryResult&#40;&#036;sql&#41;&#41; {
 &nbsp; &nbsp;foreach &#40;&#036;results as &#036;result&#41; {
 &nbsp; 	&nbsp;return true;
 &nbsp; &nbsp;}
 	&nbsp;}
 	&nbsp;else {
 &nbsp; &nbsp;return false;
 	&nbsp;}
 &nbsp; &nbsp;
 &nbsp;}	
 &nbsp;
 &nbsp;function _checkEmail&#40;&#036;email&#41; {
 	&nbsp;&#036;sql = "SELECT * FROM &#036;this->_table WHERE &#96;email&#96;='".&#036;email."'";
 	&nbsp;if &#40;&#036;results = &#036;this->_dbCon->doQueryResult&#40;&#036;sql&#41;&#41; {
 &nbsp; &nbsp;foreach &#40;&#036;results as &#036;result&#41; {
 &nbsp; 	&nbsp;return true;
 &nbsp; &nbsp;}
 	&nbsp;}
 	&nbsp;else {
 &nbsp; &nbsp;return false;
 	&nbsp;}
 &nbsp;}
 &nbsp;
 &nbsp;//Set the cookie variables for this session
 &nbsp;//&#036;aArgs is an array of user values
 &nbsp;function _setCookie&#40;&#036;aArgs&#41; {
 	&nbsp;&#036;uInfo = implode&#40;"|", &#036;aArgs&#41;;
 	&nbsp;setcookie&#40;"ccAccount", &#036;uInfo, time&#40;&#41;+31536000, "/", ".codecrypt.org", "0"&#41;;
 &nbsp;}
 	&nbsp;
 &nbsp;
 &nbsp;/* &nbsp;#######################################
 	&nbsp;Inserting new things into the database 
 &nbsp;*/ &nbsp;#######################################
 &nbsp;function addUser&#40;&#036;aArgs&#41; {
 	&nbsp;// First check to make sure these things are alright
 	&nbsp;if &#40;&#036;this->_checkName&#40;&#036;aArgs&#91;'user'&#93;&#41;&#41; {
 &nbsp; &nbsp;&#036;return = "Sorry, but that nickname is already in use<br />";
 &nbsp; &nbsp;&#036;return .= "Click <a href=&#092;"javascript&#58;history.back&#40;1&#41;&#092;">here</a> to go back and choose another name.";
 	&nbsp;}
 	&nbsp;elseif &#40;&#036;this->_checkEmail&#40;&#036;aArgs&#91;'email'&#93;&#41;&#41; {
 &nbsp; &nbsp;&#036;return = "Sorry, but that email is already in use<br />";
 &nbsp; &nbsp;&#036;return .= "Click <a href=&#092;"javascript&#58;history.back&#40;1&#41;&#092;">here</a> to go back and enter another email address.";
 	&nbsp;}
 	&nbsp;
 	&nbsp;else {
 &nbsp; &nbsp;&#036;uActivate = microtime&#40;&#41;*5451384;
 &nbsp; &nbsp;&#036;uActivate .= &#036;aArgs&#91;'user'&#93;;
 &nbsp; &nbsp;&#036;uActivate = md5&#40;&#036;uActivate&#41;;
 &nbsp; &nbsp;&#036;mailSender = "From&#58; ".ENTITY." <".MAIL_ADMIN.">";
 &nbsp; &nbsp;&#036;mailMessage = "Hello ". &#036;aArgs&#91;'user'&#93; .",&#092;r&#092;n";
 &nbsp; &nbsp;&#036;mailMessage .= "This is a message to confirm your registration with ".SITE_URL."&#092;r&#092;n";
 &nbsp; &nbsp;&#036;mailMessage .= "Your account has not been activated yet. To activate your account, click the link below. Some users may need to copy the link and paste it into their browser.&#092;r&#092;n";
 &nbsp; &nbsp;&#036;mailMessage .= SITE_URL."/members.php?action=activate&id=". &#036;uActivate ."&#092;r&#092;n";
 &nbsp; &nbsp;&#036;mailMessage .= "Username&#58; ". &#036;aArgs&#91;'user'&#93; ."&#092;r&#092;n";
 &nbsp; &nbsp;&#036;mailMessage .= "Password&#58; ". &#036;aArgs&#91;'pass'&#93; ."&#092;r&#092;n";
 &nbsp; &nbsp;&#036;mailMessage .= "Thankyou for registering with ". ENTITY .".&#092;r&#092;n";
 &nbsp; &nbsp;mail&#40;&#036;aArgs&#91;'email'&#93;, "CodeCrypt Account Activation", &#036;mailMessage, "&#036;mailSender&#092;r&#092;n"&#41;;
 &nbsp; &nbsp;&#036;aArgs&#91;'pass'&#93; = md5&#40;&#036;aArgs&#91;'pass'&#93;&#41;;
 &nbsp; &nbsp;&#036;return = "Registration succesfull. Please check your email.";
 &nbsp; &nbsp;&#036;sql = "INSERT INTO &#036;this->_table &#40;&#96;username&#96;,&#96;password&#96;,&#96;email&#96;, &#96;active&#96;, &#96;validate&#96;, &#96;regip&#96;&#41; "
 &nbsp; &nbsp;."VALUES &#40;'".&#036;aArgs&#91;'user'&#93;."', '".&#036;aArgs&#91;'pass'&#93;."','".&#036;aArgs&#91;'email'&#93;."',0,'".&#036;uActivate."', '".&#036;_SERVER&#91;'REMOTE_ADDR'&#93;."'&#41;";
 &nbsp; &nbsp;&#036;result = &#036;this->_dbCon->doQuery&#40;&#036;sql&#41;;
 &nbsp; &nbsp;if &#40;&#036;result &#33;= true&#41; {
 &nbsp; 	&nbsp;echo &#036;result;
 &nbsp; &nbsp;}
 &nbsp; 	&nbsp;
 	&nbsp;}
 	&nbsp;return &#036;return;
 &nbsp;}
 &nbsp;
 &nbsp;/* &nbsp;#######################################
 	&nbsp;Authenticate / Login
 &nbsp;*/ &nbsp;#######################################
 &nbsp;function logIn&#40;&#036;aArgs&#41; {
 	&nbsp;&#036;aArgs&#91;'pass'&#93; = md5&#40;&#036;aArgs&#91;'pass'&#93;&#41;;
 	&nbsp;&#036;sql = "SELECT * FROM &#036;this->_table WHERE &#96;username&#96;='".&#036;aArgs&#91;'user'&#93;."' LIMIT 1";
 	&nbsp;if &#40;&#036;results = &#036;this->_dbCon->doQueryResult&#40;&#036;sql&#41;&#41; {
 &nbsp; &nbsp;foreach &#40;&#036;results as &#036;result&#41; {
 &nbsp; 	&nbsp;if &#40;&#036;aArgs&#91;'pass'&#93; &#33;= &#036;result&#91;'password'&#93;&#41; {
 &nbsp; &nbsp; &nbsp;&#036;return = "That password does not match the one we have stored";
 &nbsp; 	&nbsp;}
 &nbsp; 	&nbsp;elseif &#40;&#036;result&#91;'active'&#93; == 0&#41; {
 &nbsp; &nbsp; &nbsp;&#036;return = "This account has not been activated.";
 &nbsp; 	&nbsp;}
 &nbsp; 	&nbsp;else {
 &nbsp; &nbsp; &nbsp;&#036;return = "Login successful, redirecting<br />";
 &nbsp; &nbsp; &nbsp;&#036;return .= "<a href=&#092;"login.php?id=". &#036;result&#91;'id'&#93; ."&user=". &#036;aArgs&#91;'user'&#93; ."&rank=". &#036;result&#91;'rank'&#93; ."&#092;">Click here if you're not redirected</a>";
 &nbsp; &nbsp; &nbsp;&#036;return .= "<meta http-equiv=&#092;"refresh&#092;" content=&#092;"3;URL='http&#58;//codecrypt.org/login.php?id=". &#036;result&#91;'id'&#93; ."&user=". &#036;aArgs&#91;'user'&#93; ."&rank=". &#036;result&#91;'rank'&#93; ."'&#092;">";
 &nbsp; 	&nbsp;}
 &nbsp; &nbsp;}
 	&nbsp;}
 	&nbsp;else {
 &nbsp; &nbsp;&#036;return = "Username does not exist";
 	&nbsp;}
 	&nbsp;return &#036;return;
 &nbsp;}
 &nbsp;
 &nbsp;function logOut&#40;&#41; {
 	&nbsp;if &#40;&#33;&#036;this->getSession&#40;&#41;&#41; {
 &nbsp; &nbsp;&#036;return = "You are not logged in&#33;";
 	&nbsp;}
 	&nbsp;else {
 &nbsp; &nbsp;&#036;return = "Logging out.<br />";
 &nbsp; &nbsp;&#036;return .= "<a href=&#092;"logout.php&#092;">Click here if you're not redirected</a>";
 &nbsp; &nbsp;&#036;return .= "<meta http-equiv=&#092;"refresh&#092;" content=&#092;"3;URL=logout.php&#092;">";
 	&nbsp;}
 	&nbsp;return &#036;return;
 &nbsp;}
 &nbsp;
 &nbsp;function getSession&#40;&#41; {
 	&nbsp;if &#40;isset&#40;&#036;_COOKIE&#91;'ccAccount'&#93;&#41;&#41; {
 &nbsp; &nbsp;&#036;uInfo = explode&#40;"|", &#036;_COOKIE&#91;'ccAccount'&#93;&#41;;
 &nbsp; &nbsp;&#036;return&#91;'uID'&#93; = &#036;uInfo&#91;'0'&#93;;
 &nbsp; &nbsp;&#036;return&#91;'Username'&#93; = &#036;uInfo&#91;'1'&#93;;
 &nbsp; &nbsp;&#036;return&#91;'rank'&#93; = &#036;uInfo&#91;'2'&#93;;
 &nbsp; &nbsp;return &#036;return;
 	&nbsp;}
 	&nbsp;else {
 &nbsp; &nbsp;return false;
 	&nbsp;}
 &nbsp;}
 &nbsp;
 &nbsp;function validateUser&#40;&#036;activate&#41; {
 	&nbsp;&#036;sql = "SELECT * FROM &#036;this->_table WHERE &#96;validate&#96;='".&#036;activate."' LIMIT 1";
 	&nbsp;if &#40;&#036;results = &#036;this->_dbCon->doQueryResult&#40;&#036;sql&#41;&#41; {
 &nbsp; &nbsp;foreach &#40;&#036;results as &#036;result&#41; {
 &nbsp; 	&nbsp;&#036;sql = "UPDATE &#036;this->_table SET &#96;active&#96; = 1, &#96;validate&#96;='' WHERE &#96;id&#96; = '". &#036;result&#91;'id'&#93; ."'";
 &nbsp; 	&nbsp;&#036;this->_dbCon->doQuery&#40;&#036;sql&#41;;
 &nbsp; 	&nbsp;&#036;return = "Success&#33; Your account has been activated, you may now access all your member features&#33;";
 &nbsp; 	&nbsp;&#036;return .= "<br />Click <a href=&#092;"members.php&#092;">here</a> to login.";
 &nbsp; &nbsp;}
 	&nbsp;}
 	&nbsp;else {
 &nbsp; &nbsp;&#036;return = "Validation failed.";
 &nbsp; &nbsp;&#036;return = "<br />Please check that the link is correct in your email.";
 &nbsp; &nbsp;&#036;return = "<br />If you have any further problems please contact an admin.";
 	&nbsp;}
 	&nbsp;return &#036;return;
 &nbsp;}
	}

?>
And for the tutorials, this might be useful:

Code: Select all

<?php 
	/* 
 &nbsp;CodeCrypt.org
 &nbsp;Name&#58; cTutorials.php 
 &nbsp;Path&#58; _lib/_classes/cTutorials.php
 &nbsp;Desc&#58; Tutorials Classes
	*/
	
	// Make sure we have access to the databse
	require_once&#40;'cDatabase.php'&#41;;

	class cTutorials {
 &nbsp;
 &nbsp;// Constant Variabls
 &nbsp;var &#036;_table = "tutorials";
 &nbsp;var &#036;_tableCat = "tutorial_cat";
 &nbsp;
 &nbsp;// Other Variables
 &nbsp;var &#036;_dbCon;
 &nbsp;
 &nbsp;// Constructor Function &#40;init&#41;
 &nbsp;function cTutorials&#40;&#41; {
 	&nbsp;&#036;this->_dbCon = new cDataBase&#40;&#41;;
 &nbsp;}
 &nbsp;
 &nbsp;/*
 &nbsp;########################################################################
 &nbsp;Internal Functions
 &nbsp;########################################################################
 &nbsp;*/
 &nbsp;
	
 &nbsp;/*
 &nbsp;########################################################################
 &nbsp;Showing Data
 &nbsp;########################################################################
 &nbsp;*/
 &nbsp;//Show the actual Tutorial
 &nbsp;function showTut&#40;&#036;id, &#036;cat&#41; {
 	&nbsp;&#036;sql = "SELECT * FROM &#96;tutorials&#96; WHERE &#96;id&#96; = '&#036;id' AND &#96;cat&#96; = '&#036;cat'";	
 	&nbsp;&#036;results = &#036;this->_dbCon->doQueryResult&#40;&#036;sql&#41;;
 	&nbsp;foreach &#40;&#036;results as &#036;result&#41; {
 &nbsp; &nbsp;print '
 &nbsp; &nbsp;<img src="images/hd_tutorial.gif" />
 &nbsp; &nbsp;<div id="news">
 &nbsp; &nbsp;';
 &nbsp; &nbsp;print '<h1>'.&#036;result&#91;'name'&#93;.'</h1>';
 &nbsp; &nbsp;print &#036;result&#91;'tutorial'&#93;;
 &nbsp; &nbsp;if &#40;&#036;result&#91;'active'&#93; == 0&#41; {
 &nbsp; 	&nbsp;print '
 &nbsp; &nbsp;<br /><br />
 &nbsp; &nbsp;<a href="?action=acceptTut">Accept Tutorial</a> 
 &nbsp; &nbsp;| <a href="?action=editTut">Edit Tutorial</a> 
 &nbsp; &nbsp;| <a href="?action=declineTut">Reject Tutorial</a> 
 &nbsp; 	&nbsp;';
 &nbsp; &nbsp;print '</div>';
 	&nbsp;}
 &nbsp;}
 &nbsp;
 &nbsp;function showCat&#40;&#036;cat&#41; {
 	&nbsp;//Print the start of the table
 	&nbsp;print'
 	&nbsp;<img src="images/hd_tutorials.gif" />
 	&nbsp;<table cellpadding="0" cellspacing="0" id="index" class="margin">
 &nbsp; &nbsp;<tr>
 &nbsp; &nbsp; <td class="header" colspan="3">PHP Tutorials</td>
 &nbsp; &nbsp;</tr>
 	&nbsp;';
 	&nbsp;&#036;sql = "SELECT *,DATE_FORMAT&#40;date, '%a %D %b'&#41; AS dated FROM &#96;tutorials&#96; WHERE &#96;cat&#96; = '&#036;cat' AND &#96;active&#96; = '1' ORDER BY date DESC";	
 	&nbsp;&#036;results = &#036;this->_dbCon->doQueryResult&#40;&#036;sql&#41;;
 	&nbsp;foreach &#40;&#036;results as &#036;result&#41; {
 &nbsp; &nbsp;print '
 &nbsp; &nbsp;<tr>	
 &nbsp; &nbsp; <td class="frm_link" width="60%"><a href="tutorials.php?action=showTut&cat='.&#036;cat.'&id='.&#036;result&#91;'id'&#93;.'" class="frm_link">'.&#036;result&#91;'name'&#93;.'</a>'.&#036;result&#91;'desc'&#93;.'</td>
 &nbsp; &nbsp; <td class="content" width="20%"><a href="#">'.&#036;result&#91;'author'&#93;.'</a></td>
 &nbsp; &nbsp; <td class="content" width="20%">'.&#036;result&#91;'dated'&#93;.'</td>
 &nbsp; &nbsp;</tr>
 &nbsp; &nbsp;';
 	&nbsp;}
 	&nbsp;//Close the tables
 	&nbsp;print '</table>';
 &nbsp;}
 &nbsp;
 &nbsp;function showQue&#40;&#41; {
 	&nbsp;print'
 	&nbsp;<img src="images/hd_tutorials.gif" />
 	&nbsp;<table cellpadding="0" cellspacing="0" id="index" class="margin">
 &nbsp; &nbsp;<tr>
 &nbsp; &nbsp; <td class="header" colspan="3">Tutorial Submission Que</td>
 &nbsp; &nbsp;</tr>
 	&nbsp;';
 	&nbsp;&#036;sql = "SELECT *,DATE_FORMAT&#40;date, '%a %D %b'&#41; AS dated FROM &#96;tutorials&#96; WHERE &#96;active&#96; = '0' ORDER BY date DESC";	
 	&nbsp;&#036;results = &#036;this->_dbCon->doQueryResult&#40;&#036;sql&#41;;
 	&nbsp;foreach &#40;&#036;results as &#036;result&#41; {
 &nbsp; &nbsp;print '
 &nbsp; &nbsp;<tr>	
 &nbsp; &nbsp; <td class="frm_link" width="60%"><a href="tutorials.php?action=showTut&cat='.&#036;result&#91;'cat'&#93;.'&id='.&#036;result&#91;'id'&#93;.'" class="frm_link">'.&#036;result&#91;'name'&#93;.'</a>'.&#036;result&#91;'desc'&#93;.'</td>
 &nbsp; &nbsp; <td class="content" width="20%"><a href="#">'.&#036;result&#91;'author'&#93;.'</a></td>
 &nbsp; &nbsp; <td class="content" width="20%">'.&#036;result&#91;'dated'&#93;.'</td>
 &nbsp; &nbsp;</tr>
 &nbsp; &nbsp;';
 	&nbsp;}
 	&nbsp;//Close the tables
 	&nbsp;print '</table>';
 &nbsp;}
 &nbsp;
 &nbsp;function showRoot&#40;&#41; {
 	&nbsp;print '
 	&nbsp;<img src="images/hd_tutorials.gif" /><br /><br />
 	&nbsp;<table cellpadding="0" cellspacing="0" id="index" class="margin">
 &nbsp; &nbsp;<tr>
 &nbsp; &nbsp; <td class="header" colspan="2">Tutorial Catagories</td>
 &nbsp; &nbsp;</tr>
 	&nbsp;';
 	&nbsp;&#036;sql = "SELECT * FROM tutorial_cat";
 	&nbsp;&#036;results = &#036;this->_dbCon->doQueryResult&#40;&#036;sql&#41;;
 	&nbsp;foreach &#40;&#036;results as &#036;result&#41; {
 &nbsp; &nbsp;print '
 &nbsp; &nbsp; <tr>	
 &nbsp; &nbsp; &nbsp;<td class="frm_link" width="72%"><a href="?action=showCat&cat='.&#036;result&#91;'id'&#93;.'" class="frm_link">'.&#036;result&#91;'name'&#93;.'</a>'.&#036;result&#91;'desc'&#93;.'</td>
 &nbsp; &nbsp; &nbsp;<td class="content" width="10%">'.&#036;result&#91;'number'&#93;.'</td>
 &nbsp; &nbsp; </tr>
 &nbsp; &nbsp;';
 	&nbsp;}
 	&nbsp;print ' 
 &nbsp; &nbsp;</tr>
 	&nbsp;</table>
 	&nbsp;';	
 &nbsp;}

 &nbsp;
 &nbsp;function showAdminRoot&#40;&#41; {
 	&nbsp;print '
 	&nbsp;<img src="images/hd_tutorials.gif" /><br /><br />
 	&nbsp;<table cellpadding="0" cellspacing="0" id="index" class="margin">
 &nbsp; &nbsp;<tr>
 &nbsp; &nbsp; <td class="header" colspan="3">Tutorial Catagories</td>
 &nbsp; &nbsp;</tr>
 	&nbsp;';
 	&nbsp;&#036;sql = "SELECT * FROM tutorial_cat";
 	&nbsp;&#036;results = &#036;this->_dbCon->doQueryResult&#40;&#036;sql&#41;;
 	&nbsp;foreach &#40;&#036;results as &#036;result&#41; {
 &nbsp; &nbsp;print '
 &nbsp; &nbsp; <tr>	
 &nbsp; &nbsp; &nbsp;<td class="frm_link" width="50%"><a href="#" class="frm_link">'.&#036;result&#91;'name'&#93;.'</a></td>
 &nbsp; &nbsp; &nbsp;<td class="content" width="25%"><a href="?action=editTutCat&id='.&#036;result&#91;'id'&#93;.'">Edit</a></td>
 &nbsp; &nbsp; &nbsp; <td class="content" width="25%"><a href="?action=deleteTutCat&id='.&#036;result&#91;'id'&#93;.'">Delete</a></td>
 &nbsp; &nbsp; </tr>
 &nbsp; &nbsp;';
 	&nbsp;}
 	&nbsp;print '
 	&nbsp;</table>
 	&nbsp;<br /><br />
 	&nbsp;<img src="images/hd_addcat.gif" />
 	&nbsp;<br />
 	&nbsp;<div id="commentReply">
 &nbsp; &nbsp;<p>Please keep the description short as we have limited room in the tables that display
 &nbsp; &nbsp;the catagories.</p>
 &nbsp; &nbsp;<form method="post" action="?action=showTutCat" id="addcat">
 &nbsp; 	&nbsp;<span><label for="title">Title&#58;</label><input name="title" id="title" /></span>
 &nbsp; 	&nbsp;<span><label for="text">Description&#58;</label><textarea id="text" name="text" rows="13" cols="55"></textarea></span>
 &nbsp; 	&nbsp;<span class="submit"><input type="submit" id="submit" name="submit" value="&nbsp;Add Catagory&nbsp;" /></span>
 &nbsp; &nbsp;</form>
 	&nbsp;</div>
 &nbsp;';
 &nbsp;}	
 &nbsp;function showEditTutCat&#40;&#036;id&#41; {
 	&nbsp;&#036;sql = "SELECT * FROM tutorial_cat WHERE id=&#036;id";
 	&nbsp;&#036;results = &#036;this->_dbCon->doQueryResult&#40;&#036;sql&#41;;
 	&nbsp;foreach &#40;&#036;results as &#036;result&#41; {
 &nbsp; &nbsp;print '
 	&nbsp;<img src="images/hd_editcat.gif" />
 	&nbsp;<br />
 	&nbsp;<div id="commentReply">
 &nbsp; &nbsp;<p>Please keep the description short as we have limited room in the tables that display
 &nbsp; &nbsp;the catagories.</p>
 &nbsp; &nbsp;<form method="post" action="?action=editTutCat&id='.&#036;id.'" id="editcat">
 &nbsp; 	&nbsp;<span><label for="title">Title&#58;</label><input name="title" id="title" value="'.&#036;result&#91;'name'&#93;.'"/></span>
 &nbsp; 	&nbsp;<span><label for="text">Description&#58;</label><textarea id="text" name="text" rows="13" cols="55">'.&#036;result&#91;'desc'&#93;.'</textarea></span>
 &nbsp; 	&nbsp;<span class="submit"><input type="submit" id="submit" name="submit" value="&nbsp;Update Catagory&nbsp;" /></span>
 &nbsp; &nbsp;</form>
 	&nbsp;</div>
 &nbsp; &nbsp;';
 	&nbsp;}
 &nbsp;}
 &nbsp;function showAddTut&#40;&#41; {
 	&nbsp;print '
 	&nbsp;<img src="images/hd_addtut.gif" />
 	&nbsp;<div id="commentReply">
 &nbsp; &nbsp;<p>Please make sure that you select the right category for your news. HTML will be stripped 
 &nbsp; &nbsp;and line breaks added. You can also use emoticons and BB Code.</p>
 &nbsp; &nbsp;<form method="post" action="?action=addTutorial" id="addtut">
 &nbsp; 	&nbsp;<span><label for="title">Title&#58;</label><input name="title" id="title" /></span>
 &nbsp; 	&nbsp;<span><label for="author">Author&#58;</label><input name="author" id="author" /></span>
 &nbsp; 	&nbsp;<span><label for="desc">Descriptione&#58;</label><input name="desc" id="desc" /></span>
 &nbsp; 	&nbsp;<span><label for="cat">Category&#58;</label>
 &nbsp; 	&nbsp;<select id="cat" name="cat" title="Category">
 	&nbsp;';
 	&nbsp;&#036;sql = "SELECT * FROM tutorial_cat";
 	&nbsp;&#036;results = &#036;this->_dbCon->doQueryResult&#40;&#036;sql&#41;;
 	&nbsp;foreach &#40;&#036;results as &#036;result&#41; {
 &nbsp; &nbsp;print '
 &nbsp; 	&nbsp;<option value="'.&#036;result&#91;'id'&#93;.'">'.&#036;result&#91;'name'&#93;.'</option>
 &nbsp; &nbsp;';
 	&nbsp;}
 	&nbsp;print '
 &nbsp; 	&nbsp;</select></span>
 &nbsp; 	&nbsp;<span><label for="text">Tutorial&#58;</label><textarea id="text" name="text" rows="13" cols="55"></textarea></span>
 &nbsp; 	&nbsp;<span class="submit"><input type="submit" id="submit" name="submit" value="&nbsp;Submit Tutorial&nbsp;" /></span>
 &nbsp; &nbsp;</form>
 	&nbsp;</div>
 &nbsp; &nbsp;';
 &nbsp;}
 &nbsp;/*
 &nbsp;########################################################################
 &nbsp;Adding Data
 &nbsp;########################################################################
 &nbsp;*/
 &nbsp;function addTut&#40;&#036;title, &#036;desc, &#036;cat, &#036;uID, &#036;author, &#036;tutorial&#41; {
 	&nbsp;&#036;sql = "INSERT INTO &#96;tutorials&#96; &#40;&#96;name, &#96;desc&#96;, &#96;cat&#96;, &#96;userid&#96;, &#96;author&#96;, &#96;tutorial, &#96;active&#96;&#41; VALUES &#40;'".&#036;title."', '".&#036;desc."', '".&#036;cat."', '".&#036;uID."', '".&#036;author."', '".&#036;tutorial."', &nbsp;'1'&#41;";
 	&nbsp;&#036;result = &#036;this->_dbCon->doQuery&#40;&#036;sql&#41;; 
 	&nbsp;if &#40;&#036;result &#33;= true&#41; {
 &nbsp; &nbsp;echo &#036;result;
 	&nbsp;}
 	&nbsp;&#036;this->showCat&#40;&#036;cat&#41;;
 &nbsp;}
 &nbsp;function submitTut&#40;&#036;title, &#036;desc, &#036;cat, &#036;uID, &#036;author, &#036;tutorial&#41; {
 	&nbsp;&#036;sql = "INSERT INTO tutorials &#40;&#96;name, &#96;desc&#96;, &#96;cat&#96;, &#96;userid&#96;, &#96;author&#96;, &#96;tutorial, &#96;active&#96;&#41; VALUES &#40;'".&#036;title."', '".&#036;desc."', '".&#036;cat."', '".&#036;uID."', '".&#036;author."', '".&#036;tutorial."', &nbsp;'0'&#41;";
 	&nbsp;&#036;result = &#036;this->_dbCon->doQuery&#40;&#036;sql&#41;; 
 	&nbsp;if &#40;&#036;result &#33;= true&#41; {
 &nbsp; &nbsp;echo &#036;result;
 	&nbsp;}
 	&nbsp;&#036;this->showCat&#40;&#036;cat&#41;;
 &nbsp;}
 &nbsp;function addTutCat&#40;&#036;title, &#036;desc&#41; {
 	&nbsp;&#036;sql = "INSERT INTO tutorial_cat &#40;&#96;name&#96;,&#96;desc&#96;&#41; VALUES &#40;'".&#036;title."','".&#036;desc."'&#41;";
 	&nbsp;&#036;result = &#036;this->_dbCon->doQuery&#40;&#036;sql&#41;;
 	&nbsp;if &#40;&#036;result &#33;= true&#41; {
 &nbsp; &nbsp;echo &#036;result;
 	&nbsp;}
 	&nbsp;&#036;this->showAdminRoot&#40;&#41;;
 &nbsp;}
 &nbsp;/*
 &nbsp;########################################################################
 &nbsp;Updating Data
 &nbsp;########################################################################
 &nbsp;*/
 &nbsp;function editTutCat&#40;&#036;id, &#036;title, &#036;desc&#41; {
 	&nbsp;&#036;sql = "UPDATE &#96;tutorial_cat&#96; SET &#96;name&#96; = '&#036;title',&#96;desc&#96; = '&#036;desc' WHERE &#96;id&#96; = '&#036;id' LIMIT 1";
 	&nbsp;&#036;result = &#036;this->_dbCon->doQuery&#40;&#036;sql&#41;;
 	&nbsp;if &#40;&#036;result &#33;= true&#41; {
 &nbsp; &nbsp;echo &#036;result;
 	&nbsp;}
 	&nbsp;&#036;this->showAdminRoot&#40;&#41;;
 &nbsp;}
 &nbsp;/*
 &nbsp;########################################################################
 &nbsp;Deleting Data
 &nbsp;########################################################################
 &nbsp;*/
 &nbsp;function deleteTutCat&#40;&#036;id&#41; {
 	&nbsp;&#036;sql = "DELETE FROM tutorial_cat WHERE id = &#036;id";
 	&nbsp;&#036;result = &#036;this->_dbCon->doQuery&#40;&#036;sql&#41;;
 	&nbsp;if &#40;&#036;result &#33;= true&#41; {
 &nbsp; &nbsp;echo &#036;result;
 	&nbsp;}
 	&nbsp;&#036;this->showAdminRoot&#40;&#41;;
 &nbsp;}
 &nbsp;
	}

?>
News and comments, using the db class:

Code: Select all

<?php 
	/* 
 &nbsp;CodeCrypt.org
 &nbsp;Name&#58; cNews.php 
 &nbsp;Path&#58; _lib/_classes/cNews.php
 &nbsp;Desc&#58; News System Class
	*/
	require_once&#40;'cDatabase.php'&#41;;
	
	class cNews {
 &nbsp;// Database Variables
 &nbsp;// _nVarName
 &nbsp;var &#036;_nLimit = '10';
 &nbsp;
 &nbsp;// Data Storing Variables
 &nbsp;// _dVarName
 &nbsp;var &#036;_dCon;

 &nbsp;
 &nbsp;// Constructor Function &#40;init&#41;
 &nbsp;function cNews&#40;&#41; {
 	&nbsp;&#036;this-> _dCon = new cDataBase&#40;&#41;;
 &nbsp;}
 &nbsp;
 &nbsp;/*
 &nbsp;########################################################################
 &nbsp;Displaying Data
 &nbsp;########################################################################
 &nbsp;*/
 &nbsp;
 &nbsp;//Displays the news to the index page
 &nbsp;//&#036;showAll is a boolean variable, either limit or no limit - 0/1
 &nbsp;function displayNews&#40;&#036;showAll, &#036;rank&#41; {
 	&nbsp;echo '<img src="images/hd_news.gif" />';
 	&nbsp;if &#40;&#036;showAll = "0"&#41; {
 &nbsp; &nbsp;&#036;sql = 
 &nbsp; &nbsp;"SELECT id,name,message,userid,title,DATE_FORMAT&#40;postdate, '%a %D %b @ %H&#58;%i'&#41; AS dated " .
 &nbsp; &nbsp;"FROM news ORDER BY postdate DESC LIMIT &#036;this->_nLimit";
 	&nbsp;}
 	&nbsp;else {
 &nbsp; &nbsp;&#036;sql = 
 &nbsp; &nbsp;"SELECT id,name,message,userid,title,DATE_FORMAT&#40;postdate, '%a %D %b @ %H&#58;%i'&#41; AS dated " .
 &nbsp; &nbsp;"FROM news ORDER BY postdate DESC";
 	&nbsp;}
 	&nbsp;&#036;results = &#036;this->_dCon->doQueryResult&#40;&#036;sql&#41;;
 	&nbsp;if &#40;&#036;rank == 3&#41; {
 &nbsp; &nbsp;foreach &#40;&#036;results as &#036;result&#41; {
 &nbsp; 	&nbsp;// Count the number of comments for this news item
 &nbsp; 	&nbsp;&#036;sql = 'SELECT count&#40;*&#41; FROM news_comments WHERE news_id='. &#036;result&#91;'id'&#93;;
 &nbsp; 	&nbsp;&#036;comment_count = &#036;this->_dCon->doCountRow&#40;&#036;sql&#41;;
 &nbsp; 	&nbsp;// Echo the information
 &nbsp; 	&nbsp;echo '<div id="news">';
 &nbsp; 	&nbsp;echo '<p class="header">'. &#036;result&#91;'title'&#93; .' - by <a href="members.php?acion=showProfile&id='.&#036;result&#91;'userid'&#93;.'">'. &#036;result&#91;'name'&#93; .'</a></p>';
 &nbsp; 	&nbsp;echo &#036;result&#91;'message'&#93;;
 &nbsp; 	&nbsp;echo '<p class="footer"><span class="right"><a href="?action=editNews&id='.&#036;result&#91;'id'&#93;.'">Edit</a>'
 &nbsp; &nbsp; &nbsp; .' | <a href="?action=deleteNews&id='.&#036;result&#91;'id'&#93;.'">Delete</a></span>'. &#036;result&#91;'dated'&#93; .' - <a href="?action=show&id='. &#036;result&#91;'id'&#93; .'"> Comments &#40;'. &#036;comment_count .'&#41;</a></p>'; 	&nbsp;
 &nbsp; 	&nbsp;echo '</div>';
 &nbsp; &nbsp;}
 	&nbsp;}
 	&nbsp;else {
 &nbsp; &nbsp;foreach &#40;&#036;results as &#036;result&#41; {
 &nbsp; 	&nbsp;// Count the number of comments for this news item
 &nbsp; 	&nbsp;&#036;sql = 'SELECT count&#40;*&#41; FROM news_comments WHERE news_id='. &#036;result&#91;'id'&#93;;
 &nbsp; 	&nbsp;&#036;comment_count = &#036;this->_dCon->doCountRow&#40;&#036;sql&#41;;
 &nbsp; 	&nbsp;// Echo the information
 &nbsp; 	&nbsp;echo '<div id="news">';
 &nbsp; 	&nbsp;echo '<p class="header">'. &#036;result&#91;'title'&#93; .' - by <a href="members.php?acion=showProfile&id='.&#036;result&#91;'userid'&#93;.'">'. &#036;result&#91;'name'&#93; .'</a></p>';
 &nbsp; 	&nbsp;echo &#036;result&#91;'message'&#93;;
 &nbsp; 	&nbsp;echo '<p class="footer">'. &#036;result&#91;'dated'&#93; .' - <a href="?action=show&id='. &#036;result&#91;'id'&#93; .'"> Comments &#40;'. &#036;comment_count .'&#41;</a></p>'; 	&nbsp;
 &nbsp; 	&nbsp;echo '</div>';
 &nbsp; &nbsp;}
 	&nbsp;}
 	&nbsp;if &#40;&#036;showAll = "0"&#41; {
 &nbsp; &nbsp;echo '<a href=?action=showAll>View all news</a>';
 	&nbsp;} &nbsp; 	&nbsp;
 &nbsp;}
 &nbsp;
 &nbsp;//Display just one news item &#40;for comments&#41;
 &nbsp;//&#036;id = the news id
 &nbsp;function displayOneItem&#40;&#036;id, &#036;rank&#41; {
 	&nbsp;echo '<img src="images/hd_article.gif" />';
 	&nbsp;&#036;sql = 
 &nbsp; &nbsp;"SELECT id,name,message,userid,title,DATE_FORMAT&#40;postdate, '%a %D %b @ %H&#58;%i'&#41; AS dated " .
 &nbsp; &nbsp;"FROM news WHERE id=". &#036;id;
 	&nbsp;&#036;results = &#036;this->_dCon->doQueryResult&#40;&#036;sql&#41;;
 	&nbsp;foreach &#40;&#036;results as &#036;result&#41; {
 &nbsp; &nbsp;echo '<div id="news">';
 &nbsp; &nbsp;echo '<p class="header">'. &#036;result&#91;'title'&#93; .' - by <a href="members.php?acion=showProfile&id='.&#036;result&#91;'userid'&#93;.'">'. &#036;result&#91;'name'&#93; .'</a></p>';
 &nbsp; &nbsp;echo &#036;result&#91;'message'&#93;;
 &nbsp; &nbsp;echo '<p class="footer">'. &#036;result&#91;'dated'&#93; .'</p>'; 	&nbsp;
 &nbsp; &nbsp;echo '</div>';
 	&nbsp;}
 	&nbsp;echo '<img src="images/hd_comments.gif" />';
 	&nbsp;&#036;this->displayComments&#40;&#036;id, &#036;rank&#41;;
 &nbsp;}
 &nbsp;
 &nbsp;//Display the comments
 &nbsp;//&#036;id = the news id
 &nbsp;function displayComments&#40;&#036;id, &#036;rank&#41; {
 	&nbsp;&#036;sql = "SELECT id,name,news_id,message,userid,DATE_FORMAT&#40;postdate, '%a %D %b @ %H&#58;%i'&#41; AS dated FROM news_comments WHERE news_id=&#036;id ORDER BY postdate ASC";
 	&nbsp;&#036;results = &#036;this->_dCon->doQueryResult&#40;&#036;sql&#41;;
 	&nbsp;if &#40;&#33;&#036;results&#41; {
 &nbsp; &nbsp;echo '<div id="comments"><p>No one has commented on this article.</&#91;></div>';
 	&nbsp;}
 	&nbsp;else {
 &nbsp; &nbsp;if &#40;&#036;rank <= 1&#41; {
 &nbsp; 	&nbsp;foreach &#40;&#036;results as &#036;result&#41; {
 &nbsp; &nbsp; &nbsp;echo '<div id="comments">';
 &nbsp; &nbsp; &nbsp;echo '<p><a href="members.php?acion=showProfile&id='.&#036;result&#91;'userid'&#93;.'">'. &#036;result&#91;'name'&#93; .'</a> says&#58;</p>';
 &nbsp; &nbsp; &nbsp;echo &#036;result&#91;'message'&#93;;
 &nbsp; &nbsp; &nbsp;echo '<p class="commentftr">'. &#036;result&#91;'dated'&#93; .'</p>';
 &nbsp; &nbsp; &nbsp;echo '</div>';
 &nbsp; 	&nbsp;}
 &nbsp; &nbsp;}
 &nbsp; &nbsp;elseif &#40;&#036;rank >= 2&#41; {
 &nbsp; 	&nbsp;foreach &#40;&#036;results as &#036;result&#41; {
 &nbsp; &nbsp; &nbsp;echo '<div id="comments">';
 &nbsp; &nbsp; &nbsp;echo '<p><a href="members.php?acion=showProfile&id='.&#036;result&#91;'userid'&#93;.'">'. &#036;result&#91;'name'&#93; .'</a> says&#58;</p>';
 &nbsp; &nbsp; &nbsp;echo &#036;result&#91;'message'&#93;;
 &nbsp; &nbsp; &nbsp;echo '<p class="commentftr"><span class="right"><a href="?action=deleteComment&id='.&#036;result&#91;'id'&#93;.'&nID='.&#036;id.'">Delete</a></span>'. &#036;result&#91;'dated'&#93; .'</p>';
 &nbsp; &nbsp; &nbsp;echo '</div>';
 &nbsp; 	&nbsp;}
 &nbsp; &nbsp;}
 	&nbsp;}
 	&nbsp;&#036;this->displayReply&#40;&#036;rank, &#036;id&#41;;
 &nbsp;}
 &nbsp;function displayReply&#40;&#036;rank, &#036;id&#41; {
 	&nbsp;if &#40;&#036;rank >= 1&#41; {
 &nbsp; &nbsp;echo '<img src="images/hd_addcom.gif" />';
 &nbsp; &nbsp;echo '
 &nbsp; 	&nbsp;<div id="commentReply">
 &nbsp; 	&nbsp;<p>Comments will be stripped of HTML and line breaks will be converted. Your IP will be logged
 &nbsp; 	&nbsp;to prevent abuse.</p>
 &nbsp; 	&nbsp;<form method="post" action="?action=addComment&id='.&#036;id.'" id="comments">
 &nbsp; &nbsp; &nbsp;<span><label for="text">Comments&#58;</label><textarea id="text" name="text" rows="13" cols="55"></textarea></span>
 &nbsp; &nbsp; &nbsp;<span class="submit"><input type="submit" id="submit" name="submit" value="&nbsp;Submit Comment&nbsp;" /></span>
 &nbsp; 	&nbsp;</form>
 &nbsp; 	&nbsp;</div>
 &nbsp; &nbsp;';
 	&nbsp;}
 	&nbsp;else {
 &nbsp; &nbsp;echo '
 	&nbsp;<img src="images/hd_addcom.gif" />
 	&nbsp;<div id="commentReply">
 &nbsp; &nbsp;<p class="centerText">You need to be <a href="members.php">logged in</a> to add comments.</p>
 	&nbsp;</div>
 &nbsp; &nbsp;';
 	&nbsp;}
 &nbsp;}
 &nbsp;function showNewsForm&#40;&#41; {
 	&nbsp;print '
 	&nbsp;<img src="images/hd_addnews.gif" />
 	&nbsp;<div id="commentReply">
 &nbsp; &nbsp;<p>Please make sure that you select the right category for your news. HTML will be stripped 
 &nbsp; &nbsp;and line breaks added. You can also use emoticons and BB Code.</p>
 &nbsp; &nbsp;<form method="post" action="index.php?action=addNews" id="comments">
 &nbsp; 	&nbsp;<span><label for="title">Title&#58;</label><input name="title" id="title" /></span>
 &nbsp; 	&nbsp;<span><label for="text">News&#58;</label><textarea id="text" name="text" rows="13" cols="55"></textarea></span>
 &nbsp; 	&nbsp;<span class="submit"><input type="submit" id="submit" name="submit" value="&nbsp;Submit News&nbsp;" /></span>
 &nbsp; &nbsp;</form>
 	&nbsp;</div>
 	&nbsp;';
 &nbsp;}
 &nbsp;
 &nbsp;function showEditForm&#40;&#036;id&#41; {
 	&nbsp;&#036;sql = "SELECT * FROM news WHERE id=&#036;id";
 	&nbsp;&#036;results = &#036;this->_dCon->doQueryResult&#40;&#036;sql&#41;;
 	&nbsp;foreach&#40;&#036;results as &#036;result&#41; {
 &nbsp; &nbsp;print '
 &nbsp; &nbsp;<img src="images/hd_addnews.gif" />
 &nbsp; &nbsp;<div id="commentReply">
 &nbsp; 	&nbsp;<p>Please make sure that you select the right category for your news. HTML will be stripped 
 &nbsp; 	&nbsp;and line breaks added. You can also use emoticons and BB Code.</p>
 &nbsp; 	&nbsp;<form method="post" action="index.php?action=editNews&id='.&#036;id.'" id="comments">
 &nbsp; &nbsp; &nbsp;<input type="hidden" name="date" value="'.&#036;result&#91;'postdate'&#93;.'">
 &nbsp; &nbsp; &nbsp;<span><label for="title">Title&#58;</label><input name="title" id="title" value="'.&#036;result&#91;'title'&#93;.'"/></span>
 &nbsp; &nbsp; &nbsp;<span><label for="text">News&#58;</label><textarea id="text" name="text" rows="13" cols="55">'.&#036;result&#91;'message'&#93;.'</textarea></span>
 &nbsp; &nbsp; &nbsp;<span class="submit"><input type="submit" id="submit" name="submit" value="&nbsp;Submit News&nbsp;" /></span>
 &nbsp; 	&nbsp;</form>
 &nbsp; &nbsp;</div>
 &nbsp; &nbsp;';
 	&nbsp;}
 &nbsp;}
 &nbsp;
 &nbsp;/*
 &nbsp;########################################################################
 &nbsp;Adding Data
 &nbsp;########################################################################
 &nbsp;*/
 &nbsp;
 &nbsp;//Add news to the database
 &nbsp;function addComment&#40;&#036;id, &#036;userName, &#036;uID, &#036;comment, &#036;rank&#41; {
 	&nbsp;&#036;sql = "INSERT INTO news_comments &#40;&#96;news_id&#96;,&#96;name&#96;,&#96;message&#96;,&#96;userid&#96;,&#96;postdate&#96;&#41; "
 	&nbsp;."VALUES &#40;'".&#036;id."','".&#036;userName."','".&#036;comment."','".&#036;uID."',now&#40;&#41;&#41;";	
 	&nbsp;&#036;result = &#036;this->_dCon->doQuery&#40;&#036;sql&#41;;
 	&nbsp;if &#40;&#036;result &#33;= true&#41; {
 &nbsp; &nbsp;echo &#036;result;
 	&nbsp;}
 	&nbsp;&#036;this->displayOneItem&#40;&#036;id, &#036;rank&#41;;
 &nbsp;}
 &nbsp;
 &nbsp;function addNews&#40;&#036;userName, &#036;uID, &#036;title, &#036;message, &#036;rank&#41; {
 	&nbsp;&#036;sql =	"INSERT INTO news &#40;&#96;name&#96;,&#96;userid&#96;,&#96;title&#96;,&#96;message&#96;,&#96;postdate&#96;&#41; VALUES &#40;'".&#036;userName."','".&#036;uID."','".&#036;title."', '".&#036;message."', now&#40;&#41;&#41;";
 	&nbsp;&#036;result = &#036;this->_dCon->doQuery&#40;&#036;sql&#41;;
 	&nbsp;if &#40;&#036;result &#33;= true&#41; {
 &nbsp; &nbsp;echo &#036;result;
 	&nbsp;}
 	&nbsp;&#036;this->displayNews&#40;0, &#036;rank&#41;;
 &nbsp;}
 &nbsp;
 &nbsp;/*
 &nbsp;########################################################################
 &nbsp;Update Data
 &nbsp;########################################################################
 &nbsp;*/
 &nbsp;
 &nbsp;function updateNews&#40;&#036;userName, &#036;uID, &#036;title, &#036;message, &#036;id, &#036;date&#41; {
 	&nbsp;&#036;sql = "UPDATE news SET name = '".&#036;userName."', userid = '".&#036;uID."', title = '".&#036;title."', message = '".&#036;message."', postdate = '".&#036;date."' WHERE id=&#036;id";
 	&nbsp;&#036;result = &#036;this->_dCon->doQuery&#40;&#036;sql&#41;;
 	&nbsp;if &#40;&#036;result &#33;= true&#41; {
 &nbsp; &nbsp;echo &#036;result;
 	&nbsp;}
 	&nbsp;&#036;this->displayNews&#40;0, 3&#41;;
 &nbsp;}
 &nbsp;
 &nbsp;/*
 &nbsp;########################################################################
 &nbsp;Delete Data
 &nbsp;########################################################################
 &nbsp;*/
 &nbsp;function deleteComment&#40;&#036;id, &#036;news_id, &#036;rank&#41; {
 	&nbsp;&#036;sql = "DELETE FROM news_comments WHERE id = &#036;id";
 	&nbsp;&#036;result = &#036;this->_dCon->doQuery&#40;&#036;sql&#41;;
 	&nbsp;if &#40;&#036;result &#33;= true&#41; {
 &nbsp; &nbsp;echo &#036;result;
 	&nbsp;}
 	&nbsp;&#036;this->displayOneItem&#40;&#036;news_id, &#036;rank&#41;;
 &nbsp;}
 &nbsp;
 &nbsp;function deleteNews&#40;&#036;id&#41; {
 	&nbsp;&#036;sql = "DELETE FROM news WHERE id = &#036;id";
 	&nbsp;&#036;result = &#036;this->_dCon->doQuery&#40;&#036;sql&#41;;
 	&nbsp;if &#40;&#036;result &#33;= true&#41; {
 &nbsp; &nbsp;echo &#036;result;
 	&nbsp;}
 	&nbsp;&#036;this->displayNews&#40;0, 3&#41;;
 &nbsp;}
	}
?>
us3rX
Newbie
Newbie
Posts: 0
Joined: Thu May 06, 2004 6:11 am

KillaCode

Post by us3rX »

*wacks trin for not just attaching the files, also has nfi what that all does*

us3rX <img src=\'http://www.killanet.net/forum3/public/s ... /ph34r.gif\' class=\'bbc_emoticon\' alt=\':ph34r:\' />
[align=center]

Image

"Time is never wasted, when your wasted all the time" ~ Radio Dj/Unknown Source

"Death is the inevitable end to the suffering of the living." ~Unknown

"You were born an original. Don't die a copy" ~Murdoc Niccals

[/align]
Sp3culuM
Newbie
Newbie
Posts: 0
Joined: Mon May 17, 2004 2:36 pm

KillaCode

Post by Sp3culuM »

* Uses that to help with learning OOP *

Thanks Tron <img src=\'http://www.killanet.net/forum3/public/s ... igwink.gif\' class=\'bbc_emoticon\' alt=\';)\' />
Image
ner0
Newbie
Newbie
Posts: 0
Joined: Sat May 22, 2004 4:45 pm

KillaCode

Post by ner0 »

wow, I\'ll never complain about one-word/short posts again Trin <img src=\'http://www.killanet.net/forum3/public/s ... >/blum.gif\' class=\'bbc_emoticon\' alt=\':P\' />

if anything needs doing my door/box-flaps are always open.. but yeah the download sys, *goes off to stab it*
[color=\"green\"]'class KPIM::ProcessManager' only defines private constructors and has no friends[/color] <- :( poor class



[18:09:00] * ~Moppy stews ner0 erotically 1 times.
Scott
Administrator
Administrator
Posts: 0
Joined: Sun Apr 25, 2004 1:08 pm

KillaCode

Post by Scott »

Would anyone be interested in doing a layout for this?
Trinity
Newbie
Newbie
Posts: 0
Joined: Wed May 05, 2004 9:19 am

KillaCode

Post by Trinity »

Perhaps this would be an oppurtunity for a few people to submit mock-up designs and then one is chosen?

Then, the other designs can still be added to the KillaDesign portfolio as they are still possible layouts.
Scott
Administrator
Administrator
Posts: 0
Joined: Sun Apr 25, 2004 1:08 pm

KillaCode

Post by Scott »

Good idea. I know templates have been discussed as going on freeware, so thats also an option.
Trinity
Newbie
Newbie
Posts: 0
Joined: Wed May 05, 2004 9:19 am

KillaCode

Post by Trinity »

Okay, well I'll have a shot at it, perhaps radar, josh and a couple of others can as well.
Josh
Newbie
Newbie
Posts: 0
Joined: Fri Jun 04, 2004 2:54 pm

KillaCode

Post by Josh »

Yes I\'d like to have a go but at the moment I\'m working on another layout for tami for another website.... That will have to come first and then I\'ll work on something for killacode <img src=\'http://www.killanet.net/forum3/public/s ... /smile.gif\' class=\'bbc_emoticon\' alt=\':)\' />
[align=center]

Image

“If you stop learning, you stop living.” ~Tami Quiring

“It's the rare man who understands the value of a single perfect rose.”

[/align]
Kobra
Newbie
Newbie
Posts: 0
Joined: Mon May 31, 2004 4:46 pm

KillaCode

Post by Kobra »

I would love to help out with this project (although I'm still working on my overdue KillaWriters project <img src=\'http://www.killanet.net/forum3/public/s ... >/blum.gif\' class=\'bbc_emoticon\' alt=\':P\' />) but I can't make a template.. I suck at templates <img src=\'http://www.killanet.net/forum3/public/s ... #>/cry.gif\' class=\'bbc_emoticon\' alt=\':(\' />
Image
radar
Newbie
Newbie
Posts: 0
Joined: Thu Jun 17, 2004 12:37 am

KillaCode

Post by radar »

Is that a splotch of pink I see on there? (A)

Dim the diagonal lines and red is cool.
Last edited by radar on Thu Jul 07, 2005 5:52 am, edited 1 time in total.
Post Reply

Return to “Coffee Room”