PDA

View Full Version : My second php script (The Noob Points System)



LordGregGreg
08-01-2007, 05:39 AM
Hey there, just thought I would post the code to anyone so they can either learn or add sujestions, let me know what u think.

I editied out parts of it for security reasons.
The final product is here
http://noobpoints.tehintar.net/
and
http://noobpoints.tehintar.net/noobadmin.php


<html>
<head>

<link rel="stylesheet" type="text/css"
href="<?php if($_GET['style']=='pro'){echo 'pro';}else{echo 'greg';}?>style.css" />
<TITLE>Noob Admin Panel</TITLE>
</head>
<body>
<script language="javascript">
function styleme(i)
{
if(i==1)
{

window.open("noobadmin.php?style=greg","_top",null,null);
}else
{
window.open("noobadmin.php?style=pro","_top",null,null);
}
}
function toggle(evt, h) {
var nName = evt.srcElement == null ? evt.target.nodeName : evt.srcElement.nodeName;
if (h.className == "screenshot" || nName == "A")
return;
h = h.nextSibling;
while (h && h.nodeName != "DIV")
h = h.nextSibling;
if (h) h.className = h.className == "hidden" ? "showing" : "hidden";
}
function gogetit(s)
{
window.open(s,"_top",null,null);
}
</script>
<table cellpadding="0" cellspacing="0" border="1">
<tr>
<td>Style:</td>
<td><input type="button" value="Greg" onclick="styleme(1)" /></td>
<td><input type="button" value="Pro" onclick="styleme(2)" /></td>
</tr>
</table>
<p>


<center><?php

$total_npoints=0;

//$noob_date=$date = mktime(date("H"),date("i") ,date("s"), date("m"), date("d")+1, date("y"));
$noob_date=$date = mktime();
$noob_bb='NOOBNOOBNOOBNOOBNOOBNOOBNOOBNOOBNOOBNOOB NOOBNOOB

';
include ('gregFunctions.php');
include("formchecker.php");
gConnect();


debug ('Connected to database successfully');
//emergency DROP TABLE noobs;

$noob_admins=

//Generating and showing imput erros here
$query='SELECT * FROM noobs';
$result = mysql_query($query) or $flag=true;//die('wochf');
if(($flag))
{
debug('The table is not set<br>Creating noob table now');
$query='CREATE TABLE `noobs` ('.
'`id` INT( 6 ) UNSIGNED NOT NULL auto_increment,'.
'`noob_name` VARCHAR( 30 ) NOT NULL ,'.
'`noob_submitter` VARCHAR( 30 ) NOT NULL ,'.
'`noob_reason` VARCHAR( 30 ) ,'.
'`noob_date` INT ,'.
'PRIMARY KEY (id),'.
'UNIQUE id (id)'.
') ENGINE = innodb';
mysql_query($query) or die('<br>making table didnt work');

}
if(isset($_POST['noob_name']))
{

$mode='';
if(($_POST['noob_name']!='')&&
($_POST['noob_evidence']!='')&& ($_POST['noob_reason']!=''))
{


if(($_POST['noob_id']>0))
{
$mode='edit';
}else
{
$mode='new';
}

if($mode!=''){
$fChecker = new formChecker ('ENG');
debug("mode is $mode");

$noob_name= mysql_escape_string(mysql_real_escape_string(strip _tags(trim($_POST['noob_name']))));
$noob_evidence= mysql_escape_string(mysql_real_escape_string(strip _tags(trim($_POST['noob_evidence']))));
debug("submiter is $noob_submitter");
if(($noob_submitter=='')&&($mode=='new'))
{
$noob_submitter='Unofficial';
}
//noob date set above
$noob_reason= mysql_escape_string(mysql_real_escape_string(strip _tags(trim($_POST['noob_reason']))));
$noob_pass=mysql_escape_string(mysql_real_escape_s tring(strip_tags(trim($_POST['noob_pass']))));
$noob_id=mysql_escape_string(mysql_real_escape_str ing(strip_tags(trim($_POST['noob_id']))));

debug('No errors in basic form part.');

debug('Validating input');
debug($noob_pass);
if (
(false === $fChecker -> validate ($noob_name, 'noob_name', formChecker::VALIDATE_TEXT,
array ('forbidden' => 'alphabetsoup','forbidden' => 'noone','max_length'=>100)))
|| (false === $fChecker -> validate ($noob_submitter, 'noob_submitter', formChecker::VALIDATE_TEXT, array ('max_length'=>100)))
|| (false === $fChecker -> validate ($noob_evidence, 'noob_evidence', formChecker::VALIDATE_TEXT, array ('max_length'=>200)))
|| (false === $fChecker -> validate ($noob_date, 'noob_date', formChecker::VALIDATE_TEXT, array ('max_length'=>100)))
|| (false === $fChecker -> validate ($noob_submitter, 'noob_pass', formChecker::VALIDATE_TEXT, array ('allowed'=>$noob_admins),true))
)
{
error( 'INPUT NOT VALID!!!');
}else
{
debug('Valid input');

$noobQuery = "INSERT INTO noobs VALUES (".
"'','$noob_name' ,".
"'$noob_submitter' ,".
"'$noob_reason' ,".
"'$noob_evidence' ,".
"'$noob_date' ".
")";
if($mode=='edit')
{
$noobQuery = "UPDATE noobs SET ".
"noob_name = '$noob_name',".

"noob_submitter = '$noob_submitter' ,".
"noob_reason ='$noob_reason' ,".
"noob_evidence='$noob_evidence' ".
" WHERE id={$noob_id}";
}
debug("Adding to data base right now, watch out<br>QUERY:"."'','$noobQuery");
$result = mysql_query($noobQuery) or die(mysql_error());

}

}
else
{
error('ERROR YOU MUST FILL IN ALL DATA');
}
}else
{
error('ERROR YOU MUST FILL IN ALL DATA');
}
}
//inseting bb code section and specif section
$active_noob_name='';

if(isset($_GET['noob_name']))
{
$active_noob_name=ucwords(mysql_escape_string(mysq l_real_escape_string(strip_tags(trim(urldecode($_G ET['noob_name']))))));
$query='SELECT * FROM noobs WHERE noob_name = '."'$active_noob_name'";
$result = mysql_query($query);
echo "<h1>Noob \"$active_noob_name\"'s</h1><br>";
$noob_bb.='You, '.$active_noob_name.' (http://noobpoints.tehintar.net/noobadmin.php?noob_name='.urlencode($active_noob_n ame).'), have been reported for being a NOOB.
Your ';

}else
if(isset($_GET['noob_submitter']))
{
$active_noob_submitter=ucwords(mysql_escape_string (mysql_real_escape_string(strip_tags(trim(urldecod e($_GET['noob_submitter']))))));
$query='SELECT * FROM noobs WHERE noob_submitter = '."'$active_noob_submitter'";
$result = mysql_query($query);
echo "<h1>Submitter \"$active_noob_submitter\"'s</h1><br>";


}else
if(isset($_GET['noob_reason']))
{
$active_noob_reason=ucwords(mysql_escape_string(my sql_real_escape_string(strip_tags(trim(urldecode($ _GET['noob_reason']))))));
$query='SELECT * FROM noobs WHERE noob_reason = '."'$active_noob_reason'";
$result = mysql_query($query);
echo "<h1>Reason \"".getNoobReasoning($active_noob_reason)."\":</h1><br>";


}else if($mode=='new')
{
$active_noob_name=ucwords($noob_name);
$query='SELECT * FROM noobs WHERE noob_name = '."'$active_noob_name'";
$result = mysql_query($query);
echo "<h1>Noob \"$active_noob_name\"'s</h1><br>";
$noob_bb.='You, '.$active_noob_name.', have been reported for being a NOOB.
Your ';

}else
{

$query='SELECT * FROM noobs';
$result = mysql_query($query);
}
debug('It is time to read from the data base');

$noob_bb.='Current violations include';
echo '

<table width="90%" cellspacing="0">
<caption align="top">
<h2>Noob Table</h2>
</caption>
<tr>
<td class="topleft">&nbsp;</td>
<td class="topcenter">&nbsp;</td>
<td class="topright">&nbsp;</td>
</tr>
</table>


<table width="90%" cellpadding="9px" class="fishTable" summary="This is the data base rendering of my fish">

<tr>
<td class="header">ID</td>
<td class="header">Noob Name</td>
<td class="header">Submitter</td>
<td class="header">Reason</td>
<td class="header">Link</td>
<td class="header">Points</td>
<td class="header">Date</td>
<td class="header">Age</td>
<td class="header">Edit</td>
<td class="header">Delete</td>
</tr>';

for($i=0;$i<mysql_numrows($result);$i++)
{
$noob_name = mysql_result($result,$i,"noob_name");
$noob_submitter= mysql_result($result,$i,"noob_submitter");
$noob_evidence=mysql_result($result,$i,"noob_evidence");
$noob_id = mysql_result($result,$i,"id");
$noob_reason = mysql_result($result,$i,"noob_reason");
$noob_date = mysql_result($result,$i,"noob_date");
//how long ago
//how many noob pts
if($noob_submitter=='Unofficial')
{
$noob_points=0;
}else
{
$noob_points=getNoobPoints($noob_reason);
}
$total_npoints+=$noob_points;
$noob_reasoning=getNoobReasoning($noob_reason);
$noob_bb.=' '.$noob_reasoning.' for ';
for ($a=0;$a<$noob_points;$a++)
{
$noob_bb.='http://itsat.tehintar.net/share/noobpoints.png (http://www.villavu.com/forum/showthread.php?t=5265) ';
}
$noob_bb.="
";

echo" <tr >
<td id=\"fish\" onmouseover=".'"redit(this)"'." onmouseout=".'"unredit(this)"'.">$noob_id</td>";
if($_GET['id']==$noob_id)
{
echo '<form name="edit" enctype="multipart/form-data" method="post" action="noobadmin.php">'.
'<input type="hidden" name="noob_id" value="'.$noob_id.'" />'."
<td id=\"fish\">".'<input type="text" name="noob_name" value="'.$noob_name.'""/>'."</td>
<td id=\"fish\">".$noob_submitter."</td>
".'<td class="formfish"><select name="noob_reason">
<option value="1">Not Searching (3)</option>
<option value="2">Double Posting (2)</option>
<option value="3">Wrong Forum Post (2)</option>
<option value="4">Thread/ Off Topic Post (1)</option>
<option value="5">Useless Post (1)</option>
<option value="6">Immaturity (2)</option>
<option value="7">Leet Speak (2)</option>
<option value="8">Spelling and Grammar (1)</option>
<option value="9">Leeching (1)</option>
<option value="10">Complaining/Demanding (3)</option>
<option value="11">Bad Member App (4)</option>
<option value="12">Arogant New Member (3)</option>
<option value="13">Grave Digging (2)</option>
<option value="14">Breaking Forum Rules (5)</option>

</select></td>'."
<td id=\"fish\">".'<input type="text" name="noob_evidence" value="'.$noob_evidence.'""/>'."</td>
<td id=\"fish\">";
for ($a=0;$a<$noob_points;$a++)
{
echo"<a href='http://www.villavu.com/forum/showthread.php?t=5265'>
<img src='http://itsat.tehintar.net/share/noobpoints.png'></a> ";
}
echo"</td>
<td id=\"fish\">". date("m/d/y", $noob_date)." </td>
<td id=\"fish\">".datediff(d, $noob_date,$date).' Days (or'.date("G", $date-$noob_date)." hrs).</td>";


echo'<td id=\"fish\">Pass:<input name="noob_pass" type="password"><p><input type="submit" name="Submit" value="Edit Noob!" onclick="return confirm('.
"'Are you sure you want to edit this data?".
" \\nChanges to be made to\\n$noob_name\\n$noob_submitter.');".'"/>'."</td></form>";

}else
{



echo "<td id=\"fish\"><a href=noobadmin.php?noob_name=".urlencode($noob_name).">$noob_name</a></td>
<td id=\"fish\"><a href=noobadmin.php?noob_submitter=".urlencode($noob_submitter).">$noob_submitter</a></td>
<td id=\"fish\"><a href=noobadmin.php?noob_reason=".urlencode($noob_reason).">$noob_reasoning</a></td>
<td id=\"fish\"><a href=\"$noob_evidence\">Link</a></td>
<td id=\"fish\">";
for ($a=0;$a<$noob_points;$a++)
{
echo"<a href='http://www.villavu.com/forum/showthread.php?t=5265'>
<img src='http://itsat.tehintar.net/share/noobpoints.png'></a> ";
}
//date("H", $date-$noob_date)
echo"</td>
<td id=\"fish\">". date("m/d/y", $noob_date)." </td>
<td id=\"fish\">".datediff('d', $date,$noob_date).' Days (or '.datediff('h', $date,$noob_date)." hrs).</td>
<td id=\"fish\"><a href=noobadmin.php?id={$noob_id}&act=0&style={$_GET['style']}>Edit</a></td>";

}
echo "<td id=\"fish\">";
echo '<div class="deletebuton" onclick="toggle(event, this)">Delete</div><div class="hidden">
<form name="deleteform" method="post"'." action=\"modify.php?id={$noob_id}&act=1 \"".'>
<input name="noob_pass" type="password"><input type="submit" name="Submit" value="Delete!" onclick="return confirm('.
"'Are you sure you want to \\n DELETE!!!\\nthis data?".
" \\n\\nYou will not be able to get back\\n$noon_name\\n$noob_submitter.');".'"/>'."</form></tr>";

//echo $fish_namet=mysql_result($result,$i,"fish_name");
}
$noob_bb.='This brings you to a new total of ';
for ($a=0;$a<$total_npoints;$a++)
{
$noob_bb.='http://itsat.tehintar.net/share/noobpoints.png (http://www.villavu.com/forum/showthread.php?t=5265)';
}
$noob_bb.=" ($total_npoints) Noob Points!";
if($active_noob_name=='')
{
$noob_bb.='

For more information from '."This database".
' (http://noobpoints.tehintar.net/noobadmin.php) please go Here. (http://noobpoints.tehintar.net/noobadmin.php?)';
$noob_bb.='

For more information on '."The Noob Points System".
' (http://noobpoints.tehintar.net) please go Here. (http://noobpoints.tehintar.net/)
';

}else
{
$noob_bb.='

For more information on '.$active_noob_name.
' (http://noobpoints.tehintar.net/noobadmin.php?noob_name='.urlencode($active_noob_n ame).') please go Here. (http://noobpoints.tehintar.net/noobadmin.php?noob_name='.urlencode($active_noob_n ame).')';

$noob_bb.='

For more information from '."This database".
' (http://noobpoints.tehintar.net/noobadmin.php) please go Here. (http://noobpoints.tehintar.net/noobadmin.php?)';
$noob_bb.='

For more information on '."The Noob Points System".
' (http://noobpoints.tehintar.net/) please go Here. (http://noobpoints.tehintar.net/)
';


}
$noob_bb.='
For more information on Noobs (http://www.villavu.com/forum/showthread.php?t=5265) please go'.
' Here. (http://www.villavu.com/forum/showthread.php?t=5265)

NOOBNOOBNOOBNOOBNOOBNOOBNOOBNOOBNOOBNOOBNOOBNOOB';

echo '</table><table width="90%" cellpadding="9px" class="fishTable">

<tr width="90%">
<td id="fish"><b>Total Noob Points<b></td>
<td id="fish">';
for ($a=0;$a<$total_npoints;$a++)
{
echo"<a href='http://www.villavu.com/forum/showthread.php?t=5265'>
<img src='http://itsat.tehintar.net/share/noobpoints.png'></a> ";
}
echo'</td></tr>';

writeBorder(false);

echo '<div class="cliktoggle" onclick="toggle(event, this)">Toggle BB Code</div>';
if($noob_name==$active_noob_name)
{
echo '<div class="showing">';
}else
{
echo '<div class="hidden">';

}
echo '<br><p><textarea name="noob_bb" cols="100" rows="10" readonly="readonly" wrap="physical">'.$noob_bb.'</textarea></div>';


echo '<br><div class="cliktoggle" onclick="toggle(event, this)">Toggle New Noob Pane</div><div class="hidden">

<form name="form1" method="post" action="noobadmin.php?style='.$_GET['style'].'">
<table width="244">
<tr>
<td class="formfish" width="151">Name</td>
<td class="formfish" ><input name="noob_name" type="text" size="100%" value="The Noobs SRL Name (be exact)"></td>
</tr>'.
// <tr>
// <td class="formfish">Username</td>
// <td class="formfish"><input name="noob_submitter" type="text" size="100%" value="The Submitters User Name"></td>
// </tr>
'<tr>
<td class="formfish">Password</td>
<td class="formfish"><input name="noob_pass" size="100%" type="password"></td>
</tr>
<tr>
<td class="formfish">Reason</td>
<td class="formfish"><select name="noob_reason">
<option value="1">Not Searching (3)</option>
<option value="2">Double Posting (2)</option>
<option value="3">Wrong Forum Post (2)</option>
<option value="4">Thread/ Off Topic Post (1)</option>
<option value="5">Useless Post (1)</option>
<option value="6">Immaturity (2)</option>
<option value="7">Leet Speak (2)</option>
<option value="8">Spelling and Grammar (1)</option>
<option value="9">Leeching (1)</option>
<option value="10">Complaining/Demanding (3)</option>
<option value="11">Bad Member App (4)</option>
<option value="12">Arogant New Member (3)</option>
<option value="13">Grave Digging (2)</option>
<option value="14">Breaking Forum Rules (5)</option>
</select></td>
</tr>
<tr>
<td class="formfish" width="61">Link to Offence (Evidence)</td>
<td class="formfish" width="171"><input name="noob_evidence" type="text" size="100%" value="copy and paste the url of the thread"></td>
</tr>

<tr>
<td class="formfish">Date</td>
<td class="formfish">
<input name="noob_date" type="text" size="100%" disabled="true" value="'.date("m/d/y", $date) .'" readonly="true">
</td>
</tr>
<tr>
<td class="formfish">&nbsp;</td>
<td class="formfish" align="center"><input type="submit" name="Submit" value="Report Noob!" onclick="return confirm('.
"'Are you sure you want to send this data?".
" \\n\\nYou will not be able to undo this.');".'"/></td>
</tr>
</table>
</form></div>
<br>
<div class="cliktoggle" onclick="toggle(event, this)">Toggle Search Pane</div><div class="hidden">

<table width="244">
<tr>
<form action="" method="get" enctype="application/x-www-form-urlencoded" name="search">
<td class="formfish"><input width="100%" type="text" name="noob_name"></td>
<td class="formfish"><input width="100%" type="submit" name="Submit" value="Search by Username"></td>
</form>
</tr>
<tr>
<form action="" method="get" enctype="application/x-www-form-urlencoded" name="search">
<td class="formfish"><input width="100%" type="text" name="noob_submitter"></td>
<td class="formfish"><input type="submit" name="Submit" value="Search by Submitter"></td>
</form>
</tr>
<tr>
<form action="" method="get" enctype="application/x-www-form-urlencoded" name="search">
<td class="formfish"><select name="noob_reason">
<option value="1">Not Searching (3)</option>
<option value="2">Double Posting (2)</option>
<option value="3">Wrong Forum Post (2)</option>
<option value="4">Thread/ Off Topic Post (1)</option>
<option value="5">Useless Post (1)</option>
<option value="6">Immaturity (2)</option>
<option value="7">Leet Speak (2)</option>
<option value="8">Spelling and Grammar (1)</option>
<option value="9">Leeching (1)</option>
<option value="10">Complaining/Demanding (3)</option>
<option value="11">Bad Member App (4)</option>
<option value="12">Arogant New Member (3)</option>
<option value="13">Grave Digging (2)</option>
<option value="14">Breaking Forum Rules (5)</option>
</select>

</td>
<td class="formfish"><input type="submit" name="Submit" value="Search by Offense"></td>
</form>
</tr>
</table></div>

';


mysql_close();

?>
</p>
<br>
<br>
<br>
</center>
</body>
</html>




oh yeah, the helper functions are good too (like generative a signature)


<?php
function writeBorder($top)
{
if($top)
{
echo '</table>
<table width="90%" cellspacing="0">
<tr>
<td class="topleft">&nbsp;</td>
<td class="top">&nbsp;</td>
<td class="top">&nbsp;</td>
</tr>
</table>';
}else
{
echo '</table>
<table width="90%" cellspacing="0">
<tr>
<td class="bottomleft">&nbsp;</td>
<td class="bottomcenter">&nbsp;</td>
<td class="bottomright">&nbsp;</td>
</tr>
</table>';
}
}
function getNoobReasoning($noob_reason)
{
$noob_reasoning='error';
switch ($noob_reason) {
case 0:
$noob_reasoning='error';
break;
case 1:
$noob_reasoning='Not Searching';
break;
case 2:
$noob_reasoning='Double Posting';
break;
case 3:
$noob_reasoning='Wrong Forum Post';
break;
case 4:
$noob_reasoning='Thread/ Off Topic Post';
break;
case 5:
$noob_reasoning='Useless Post';
break;
case 6:
$noob_reasoning='Immaturity';
break;
case 7:
$noob_reasoning='Leet Speak';
break;
case 8:
$noob_reasoning='Spelling and Grammar';
break;
case 9:
$noob_reasoning='Leeching';
break;
case 10:
$noob_reasoning='Complaining/Demanding';
break;
case 11:
$noob_reasoning='Bad Member App';
break;
case 12:
$noob_reasoning='Arrogant New Member';
break;
case 13:
$noob_reasoning='Grave Digging';
break;
case 14:
$noob_reasoning='Breaking Forum Rules';
break;

}
return $noob_reasoning;


}
function getNoobPoints($noob_reason)
{
$noob_reasoning='error';
switch ($noob_reason) {
case 0:
$noob_reasoning=0;//'error';
break;
case 1:
$noob_reasoning=3;//'Not Searching';
break;
case 2:
$noob_reasoning=2;//'Double Posting';
break;
case 3:
$noob_reasoning=2;//Wrong Forum Post';
break;
case 4:
$noob_reasoning=1;//'Thread/ Off Topic Post';
break;
case 5:
$noob_reasoning=1;//'Useless Post';
break;
case 6:
$noob_reasoning=2;//'Immaturity';
break;
case 7:
$noob_reasoning=2;//'Leet Speak';
break;
case 8:
$noob_reasoning=1;//'Spelling and Grammar';
break;
case 9:
$noob_reasoning=1;//'Leeching';
break;
case 10:
$noob_reasoning=3;//'Complaining/Demanding';
break;
case 11:
$noob_reasoning=4;//'Bad Member App';
break;
case 12:
$noob_reasoning=3;//'Arrogant New Member';
break;
case 13:
$noob_reasoning=2;//'grave digging';
break;
case 14:
$noob_reasoning=5;//'breaking forum rules';
break;
}
return $noob_reasoning;


}
function picky($i)
{


for ($a=0;$a<$i;$a++)
{
echo"<a href='http://www.villavu.com/forum/showthread.php?t=5265'>
<img src='http://itsat.tehintar.net/share/noobpoints.png'>&nbsp</a>";
}
return '';
}
function DateDiff
($interval,$date1,$date2) {
// get the number of seconds between the two dates
$timedifference = $date2 - $date1;

switch ($interval) {
case 'w':
$retval = $timedifference/604800;
break;
case 'd':
$retval = $timedifference/86400;
break;
case 'h':
$retval =$timedifference/3600;
break;
case 'n':
$retval = $timedifference/60;
break;
case 's':
$retval = $timedifference;
break;

}
if($retval<0){$retval*=-1;}
return round($retval);

}
function debug($n)
{
if(false){
echo '<table ><tr><td class="debug">'.$n.'</td> </tr></table>';
//echo'<div class="debug">sample text</div>';
}
}
function error($n)
{
echo '<h3 class="error">'.$n.'</h3>';
}
function gConnect()
{
$link = mysql_connect('');
or die('Could not connect: ' . mysql_error());
//debug('Connected to mysql successfully');
mysql_select_db('') or die('Could not select database');
}
function writeHeader($im,$ff,$xx,$yy,$string,$l)
{
imagestring($im,($ff),($xx+1), ($yy+1), "$string", $l);
imagestring($im,$ff,$xx, $yy, "$string", $black);
}
function drawSig($sigBaseColor)
{
gConnect();
$date = mktime();
$query='SELECT * FROM noobs';
$result = mysql_query($query);
$im = imagecreatefrompng("rednoob.png");
$title = imagecreatefrompng("title.png");
$fontColor = imagecolorallocate($im, 50, 0,0);
$light = imagecolorallocate($im, 190, 0, 0);
$picture_color=strtoupper(mysql_escape_string(mysq l_real_escape_string(strip_tags(trim(urldecode($si gBaseColor))))));

$x_1=45;
$x_2=170;
$x_3=337;
$x_4=501;
$y_1=28;
$y_header=29;
$y_space=17;
$tiny=false;
$long=true;
$header1=true;
$header2=true;
$font = 3;
if(strpos(strrev($picture_color),'22')!=0)
{
$picture_color=ucfirst(strtolower(substr($picture_ color,2)));
$im = imagecreatefrompng("22/NoobsSignature$picture_color.png");

$fontColor = imagecolorallocate($im, 0, 0,0);
$light = imagecolorallocate($im, 190, 190, 190);

$x_1=14;
$x_2=138;
$x_3=297;
$x_4=436;
$y_1=37;
$y_header=38;
$y_space=15;
$tiny=false;
$long=false;
$header1=false;
$header2=true;
$font = 3;
}else
if(strpos(strrev($picture_color),'33')!=0)
{
$picture_color=ucfirst(strtolower(substr($picture_ color,2)));
$im = imagecreatefrompng("33/NoobsSignatureSmall$picture_color.png");


$fontColor = imagecolorallocate($im, 0, 0,0);
$light = imagecolorallocate($im, 222, 222, 222);

$x_1=94;
$x_2=198;
$x_3=297;
$x_4=436;
$y_1=3;
$y_header=38;
$y_space=0;
$tiny=true;
$long=false;
$header1=false;
$header2=false;
$font = 3;
}
else
{
switch ($picture_color) {
case 'RED':
$im = imagecreatefrompng("rednoob.png");
$fontColor = imagecolorallocate($im, 50, 0,0);
$light = imagecolorallocate($im, 190, 0, 0);
break;
case 'BLUE':
$im = imagecreatefrompng("bluenoob.png");
$fontColor = imagecolorallocate($im, 0, 0, 50);
$light = imagecolorallocate($im, 0, 0, 190);
break;
case 'GREEN':
$im = imagecreatefrompng("greennoob.png");
$fontColor = imagecolorallocate($im, 0, 50, 0);
$light = imagecolorallocate($im, 0, 190, 0);
break;
case 'PURPLE':
$im = imagecreatefrompng("purplenoob.png");
$fontColor = imagecolorallocate($im, 29, 0, 45);
$light = imagecolorallocate($im, 95, 0,145);
break;
}
}


$noobpts = imagecreatefrompng("noobpoints.png");
if(strpos($picture_color,'ummer')!=0)
{
$noobpts = imagecreatefrompng("22/SNoobPoint.png");
}

// if there's an error, stop processing the page:

if(!$im){die("");}

$black = imagecolorallocate($im, 0, 0, 0);
$white = imagecolorallocate($im, 255, 255, 255);
$width = imagesx($im);
$height = imagesy($im);

//$font = 3;//'AllCaps.ttf' ; // local ttfs were trouble, so use an X11 font

$y=$y_1;
$num=0;
$lastNoob='';
$a=(mysql_numrows($result)-1);

$rows=5+1;
if($tiny)
{
$rows=1+1;
}
for($i=(mysql_numrows($result)-1);$a>(mysql_numrows($result)-$rows);$i--)
{
$x=$x_1;
$a--;
$noob_name = $noob_dname=ucwords(mysql_result($result,$i,"noob_name"));
if(strlen($noob_dname)>14){$noob_dname=substr($noob_dname,0,14);}
$noob_submitter= mysql_result($result,$i,"noob_submitter");
if((strcasecmp($noob_name,$lastNoob)==0)||(strcase cmp($noob_submitter,'Unofficial')==0))
{
$a++;
}else{
$lastNoob=$noob_name;
$noob_submitter= mysql_result($result,$i,"noob_submitter");
$noob_id = mysql_result($result,$i,"id");
$noob_reason = mysql_result($result,$i,"noob_reason");
$noob_date = mysql_result($result,$i,"noob_date");
$noob_reasoning=getNoobReasoning($noob_reason);
$noob_age=datediff('d', $date,$noob_date);
$noob_points=0;

$active_noob_name=$noob_name;
$query='SELECT * FROM noobs WHERE noob_name = '."'$active_noob_name'";
$presult = mysql_query($query);

for($ii=0;$ii<mysql_numrows($presult);$ii++)
{

$noob_dsubmitter= mysql_result($presult,$ii,"noob_submitter");
if((strcasecmp($noob_dsubmitter,'Unofficial')!=0))
{
$noob_points+=getNoobPoints(mysql_result($presult, $ii,"noob_reason"));
}
}
$y+=$y_space;
$num++;
if($tiny)
{
$string = "$noob_dname";
//$tbb = imageFTText ($im, $font_sz, 0, ($x), ($y), $fontColor, $font, "$string", array());
imagestring($im,$font,($x-1), ($y-1), "$string", $light);
imagestring($im,$font,($x+1), ($y+1), "$string", $light);
imagestring($im,$font,($x), ($y), "$string", $fontColor);
$x=$x_2;
for($iiing=0;$iiing<$noob_points;$iiing++)
{
if($iiing>=10)
{

imagefilledrectangle($im, $x_2+14, ($y) , $x-15, ($y+13), $black);
$string = " ".$noob_points." Points!";
//$tbb = imageFTText ($im, $font_sz, 0, 380, ($y), $fontColor, $font, "$string", array());
imagestring($im,$font,($x_2+20), ($y), "$string", $light);
$iiing+=100;

}
else{
imageCopy($im,$noobpts, $x, ($y), 0, 0, 14, 14) ;
$x+=14;
if($long)
{
$x+=1;
}
}
}


}else
{
$string = "$num. $noob_dname";
//$tbb = imageFTText ($im, $font_sz, 0, ($x), ($y), $fontColor, $font, "$string", array());
imagestring($im,$font,($x), ($y), "$string", $fontColor);
$x=$x_2;
$string = "$noob_reasoning";
//$tbb = imageFTText ($im, $font_sz, 0, ($x), ($y), $fontColor, $font, "$string", array());
imagestring($im,$font,($x), ($y), "$string", $fontColor);

$x=$x_3;
//$noob_points=20;//take this out after testing
for($iiing=0;$iiing<$noob_points;$iiing++)
{
if($iiing>=10)
{

imagefilledrectangle($im, $x_3+14, ($y) , $x-15, ($y+13), $black);
$string = " ".$noob_points." Points!";
//$tbb = imageFTText ($im, $font_sz, 0, 380, ($y), $fontColor, $font, "$string", array());
imagestring($im,$font,($x_3+20), ($y), "$string", $light);
$iiing+=100;

}
else{
imageCopy($im,$noobpts, $x, ($y), 0, 0, 14, 14) ;
$x+=14;
if($long)
{
$x+=1;
}
}
}
$x=$x_4;
$string = " ".datediff('d', $date,$noob_date)." Days";
if($long)
{
$string = " ".datediff('d', $date,$noob_date)." Days Old.";
}

//$tbb = imageFTText ($im, $font_sz, 0, ($x), ($y), $fontColor, $font, "$string", array());
imagestring($im,$font,($x), ($y), "$string", $fontColor);
}
}
}
if($header1)
{
imageCopy($im,$title, 0, 0, 0, 0, $width, $height);
}
if($header2)
{
writeheader($im,5,$x_1+21, $y_header, "Username",$light);
writeheader($im,5,$x_2, $y_header, "Offence",$light);
writeheader($im,5,$x_4+7, $y_header, "Age",$light);
if($long)
{
writeheader($im,5,$x_3, $y_header, "Total Noob Points",$light);
}else
{
writeheader($im,5,$x_3, $y_header, "Total Points",$light);
}

}
Header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
imagedestroy($noobpts);
}
?>

TravisV10
08-06-2007, 08:45 PM
Nice. I was thinking of making something similar to this. I know php html mysql css and stuff like that really well. I have been web deving my whole life. Great job btw! :D

Question: How long did this take you?

Hugolord
08-06-2007, 08:49 PM
suggestion had more or less of in every section like the guy with most noobs points and and less etc like on Rs worlds

Spky
08-06-2007, 08:54 PM
Nice work.

LordGregGreg
08-06-2007, 08:56 PM
suggestion had more or less of in every section like the guy with most noobs points and and less etc like on Rs worlds
thanks spky and born2code

im still wokring on it (hewre just came out with the new signatures) so i dont really know how long it took me.

and hugo .. i will add that, it wont be hard at all. The thing is... the effect it would bring kinda goes against the philosophy of the nooob points system. As someone could stay a noob long after they wernt one.

TravisV10
08-06-2007, 09:12 PM
My suggestions would be a search function and a little touching up. I could help ya out with it. I know php and mysql very well.

LordGregGreg
08-06-2007, 09:19 PM
My suggestions would be a search function and a little touching up. I could help ya out with it. I know php and mysql very well.search function has been added.

touching up.. needs more detail.

TravisV10
08-06-2007, 09:20 PM
rofl... my bad! :D

cathering_
08-06-2007, 09:23 PM
Ajax form submission? and valid XHTML?

LordGregGreg
08-06-2007, 09:27 PM
Ajax form submission? and valid XHTML?ok, ya got me there. lol. Your welcome to clean it up, but if your serious about it, let me give you the newest version.

TravisV10
08-06-2007, 09:40 PM
Can i help out?

cathering_
08-06-2007, 10:11 PM
error free php code maybe ? :)

My lord LOL i just validate it without editing

Failed validation, 7457 Errors

LordGregGreg
08-07-2007, 02:36 AM
error free php code maybe ? :)

My lord LOL i just validate it without editing

Failed validation, 7457 Errorslol, yep, impresive huh? however it still all works and looks just fine in ff, ie, and netscape, so im happy enough.

how cna u validate without editing?

and what do you mean by error free php code?

andhows..thanks for all the help.

im hesistant about puttiing up the newest version just because it takes a while to edit out the autherntication points.

Esteban
08-07-2007, 03:41 AM
Look at all teh n00b points :o!

Nice work man, looks like some sweet code to me.

Drunkenoldma
08-07-2007, 08:49 AM
Why don't you make it so you can order the list by clicking on the title (where to order by)?

Hugolord
08-07-2007, 09:18 AM
that was my suggestion...

cathering_
08-07-2007, 11:05 AM
Oh i think i found a display error if you look at the top border table is complete but if u look at the bottom border its not complete? thats in IE 7

-----
edit:
Heres a template for noob table thing you can use it as template but its not completely valid I just took out wut i could without messing with the apprance I also made it no javascript compatiable also faster template switching with javascript

NOTE: make sure you change the #fish id to a .fish in both style files



<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link id="stylesheet1" rel="stylesheet" type="text/css" href="http://noobpoints.tehintar.net/gregstyle.css" />
<title>Noob Admin Panel</title>
<style id="stylesheet2" type="text/css">
.fish
{
/*background:#FF3300;
border-right:thin dotted rgb(250,250,0);
border-bottom:thin dotted rgb(250,150,0);*/
text-transform:capitalize;
display:inline-table;
padding: 4px;
border: thin solid rgb(255,0,0);

background-image:url('http://noobpoints.tehintar.net/images/fade_bac.png');
background-attachment: fixed;
}
.fish:hover
{
color:#000000;
background-image: url("http://noobpoints.tehintar.net/images/fade_ba1.png");
}
</style>
<style type="text/css">
<!--
img {border: 1px solid blue;}
-->
</style>
</head>
<body>
<script type="text/javascript">
<!--
function toggle(evt, h) {
var nName = evt.srcElement == null ? evt.target.nodeName : evt.srcElement.nodeName;
if (h.className == "screenshot" || nName == "A")
return;
h = h.nextSibling;
while (h && h.nodeName != "DIV")
h = h.nextSibling;
if (h) h.className = h.className == "hidden" ? "showing" : "hidden";
}
function gogetit(s)
{
window.open(s,"_top",null,null);
}
-->
</script>
<table cellpadding="0" cellspacing="0" border="1">
<tr>
<td><span style="color:#fff;">Style:</span></td>
<td><form method="get" id="SwapForm" onsubmit="document.getElementById('stylesheet1').href='http://noobpoints.tehintar.net/gregstyle.css';return false;" action="http://noobpoints.tehintar.net/noobadmin.php"><input type="hidden" name="style" value="greg" /><input type="submit" id="GregStyleBut" value="Greg" /></form></td>
<td><form method="get" id="SwapForm1" onsubmit="document.getElementById('stylesheet1').href='http://noobpoints.tehintar.net/prostyle.css';return false;" action="http://noobpoints.tehintar.net/noobadmin.php"><input type="hidden" name="style" value="pro" /><input type="submit" id="ProStyleBut" value="Pro" /></form></td>
</tr>
</table>
<div align="center">

<table width="90%" cellspacing="0">
<caption align="top">
<map id="null"><h2>Noob Table</h2></map>
</caption>
<tr>
<td class="topleft">&nbsp;</td>
<td class="topcenter">&nbsp;</td>
<td class="topright">&nbsp;</td>
</tr>
</table>


<table width="90%" cellpadding="9px" class="fishTable" summary="This is the data base rendering of my fish">

<tr>
<td class="header">ID</td>
<td class="header">Noob Name</td>
<td class="header">Submitter</td>
<td class="header">Reason</td>
<td class="header">Link</td>
<td class="header">Points</td>
<td class="header">Date</td>
<td class="header">Age</td>
<td class="header">Edit</td>
<td class="header">Delete</td>
</tr> <tr >
<td class="fish" onmouseover="redit(this)" onmouseout="unredit(this)">9</td><td class="fish"><a href="noobadmin.php?noob_name=Chimichanga">Chimichanga</a></td>
<td class="fish"><a href="noobadmin.php?noob_submitter=Lordgreggreg">Lordgreggreg</a></td>
<td class="fish"><a href="noobadmin.php?noob_reason=5">Useless Post</a></td>
<td class="fish"><a href="http://srl-forums.com">Link</a></td>
<td class="fish"><a href="http://www.villavu.com/forum/showthread.php?t=5265">
<img alt="NP" src="http://itsat.tehintar.net/share/noobpoints.png" /></a> </td>
<td class="fish">07/21/07 </td>
<td class="fish">17 Days (or 413 hrs).</td>
<td class="fish"><a href="noobadmin.php?id=9&amp;act=0&amp;style=">Edit</a></td><td class="fish">


<script type="text/javascript">
<!--
document.write('<div class="deletebuton" onclick="toggle(event, this)">Delete</div><div class="hidden">');
-->
</script>
<form name="deleteform" method="post" action="modify.php?id=9&amp;act=1" >
<input name="noob_pass" type="password" /><input type="submit" name="Submit" value="Delete!" onclick="return confirm('Are you sure you want to delete this data? \n\nYou will not be able to get back Lordgreggreg.');" /></form>
<script type="text/javascript">
<!--
document.write('</div>');
-->
</script>

</td></tr> <tr >
<td class="fish" onmouseover="redit(this)" onmouseout="unredit(this)">149</td><td class="fish"><a href="noobadmin.php?noob_name=papa+smurf">papa smurf</a></td>
<td class="fish"><a href="noobadmin.php?noob_submitter=Unofficial">Unofficial</a></td>
<td class="fish"><a href="noobadmin.php?noob_reason=6">Immaturity</a></td>
<td class="fish"><a href="http://www.villavu.com/forum/showthread.php?t=5580?p=177447#post177447">Link</a></td>
<td class="fish"><a href="http://www.villavu.com/forum/showthread.php?t=5265"><img alt="NP" src="http://itsat.tehintar.net/share/noobpoints.png" /></a></td>
<td class="fish">08/06/07 </td>
<td class="fish">1 Days (or 16 hrs).</td>
<td class="fish"><a href="noobadmin.php?id=149&amp;act=0&amp;style=">Edit</a></td><td class="fish">

<script type="text/javascript">
<!--
document.write('<div class="deletebuton" onclick="toggle(event, this)">Delete</div><div class="hidden">');
-->
</script>
<form name="deleteform" method="post" action="modify.php?id=149&amp;act=1">
<input name="noob_pass" type="password" /><input type="submit" name="Submit" value="Delete!" onclick="return confirm('Are you sure you want to delete this data?\n\nYou will not be able to get back Unofficial.');" /></form>

<script type="text/javascript">
<!--
document.write('</div>');
-->
</script>

</td></tr></table><table width="90%" cellpadding="9px" class="fishTable">

<tr style="width:90%;">
<td class="fish"><b>Total Noob Points</b></td>
<td class="fish">
<a href="http://www.villavu.com/forum/showthread.php?t=5265"> <img alt="NP" src="http://itsat.tehintar.net/share/noobpoints.png" /></a>
<a href="http://www.villavu.com/forum/showthread.php?t=5265"> <img alt="NP" src="http://itsat.tehintar.net/share/noobpoints.png" /></a>
</td>
</tr>
</table>
<table width="90%" cellspacing="0">
<tr>
<td class="bottomleft">&nbsp;</td>
<td class="bottomcenter">&nbsp;</td>
<td class="bottomright">&nbsp;</td>
</tr>
</table>

<br />
<script type="text/javascript">
<!--
document.write('<div class="cliktoggle" onclick="toggle(event, this)">Toggle BB Code</div><div class="hidden">');
-->
</script>

<br />
<form method="post" action="http://noobpoints.tehintar.net/noobadmin.php">
<textarea name="noob_bb" cols="100" rows="10" readonly="readonly">Blah Blah Blah</textarea>
</form>
<script type="text/javascript">
<!--
document.write('</div>');
-->
</script>
<br />
<script type="text/javascript">
<!--
document.write('<div class="cliktoggle" onclick="toggle(event, this)">Toggle New Noob Pane</div><div class="hidden">');
-->
</script>

<form name="form1" method="post" action="noobadmin.php?style=">
<table width="244">
<tr>
<td class="formfish" width="151">Name</td>
<td class="formfish" ><input name="noob_name" type="text" size="100%" onfocus="if(this.value == 'The Noobs SRL Name (be exact)'){this.value='';}" onblur="if(this.value == ''){this.value='The Noobs SRL Name (be exact)';}" value="The Noobs SRL Name (be exact)" /></td>
</tr><tr>
<td class="formfish">Password</td>
<td class="formfish"><input name="noob_pass" size="100%" type="password" /></td>
</tr>
<tr>
<td class="formfish">Reason</td>
<td class="formfish"><select name="noob_reason">
<option value="1">Not Searching (3)</option>
<option value="2">Double Posting (2)</option>
<option value="3">Wrong Forum Post (2)</option>
<option value="4">Thread/ Off Topic Post (1)</option>
<option value="5">Useless Post (1)</option>
<option value="6">Immaturity (2)</option>
<option value="7">Leet Speak (2)</option>
<option value="8">Spelling and Grammar (1)</option>
<option value="9">Leeching (1)</option>
<option value="10">Complaining/Demanding (3)</option>
<option value="11">Bad Member App (4)</option>
<option value="12">Arogant New Member (3)</option>
<option value="13">Grave Digging (2)</option>
<option value="14">Breaking Forum Rules (5)</option>
</select></td>
</tr>
<tr>
<td class="formfish" width="61">Link to Offence (Evidence)</td>
<td class="formfish" width="171"><input name="noob_evidence" onfocus="if(this.value == 'Copy And Paste The URL Of The Thread.'){this.value='';}" onblur="if(this.value == ''){this.value='Copy And Paste The URL Of The Thread.';}" type="text" size="100%" value="Copy And Paste The URL Of The Thread." /></td>
</tr>

<tr>
<td class="formfish">Date</td>
<td class="formfish">
<input name="noob_date" type="text" size="100%" disabled="disabled" value="08/07/07" readonly="readonly" />
</td>
</tr>
<tr>
<td class="formfish">&nbsp;</td>
<td class="formfish" align="center"><input type="submit" name="Submit" value="Report Noob!" onclick="return confirm('Are you sure you want to send this data? \n\nYou will not be able to undo this.');" /></td>
</tr>
</table>
</form>

<script type="text/javascript">
<!--
document.write('</div>');
-->
</script>


<br />
<script type="text/javascript">
<!--
document.write('<div class="cliktoggle" onclick="toggle(event, this)">Toggle Search Pane</div><div class="hidden">');
-->
</script>

<table width="30%">
<tr><th>
<form action="" method="get" enctype="application/x-www-form-urlencoded" name="search1">
<td class="formfish"><input style="width:100%;" type="text" name="noob_name" /></tr>
<td class="formfish"><input style="width:100%;" type="submit" name="Submit" value="Search by Username" /></tr>
</form>
</th>
</tr>
<tr><th>
<form action="" method="get" enctype="application/x-www-form-urlencoded" name="search2">
<td class="formfish"><input style="width:100%;" type="text" name="noob_submitter" /></td>
<td class="formfish"><input type="submit" name="Submit" value="Search by Submitter" /></td>
</form></th>
</tr>
<tr><th>
<form action="" method="get" enctype="application/x-www-form-urlencoded" name="search3">
<td class="formfish"><select name="noob_reason">
<option value="1">Not Searching (3)</option>
<option value="2">Double Posting (2)</option>
<option value="3">Wrong Forum Post (2)</option>
<option value="4">Thread/ Off Topic Post (1)</option>
<option value="5">Useless Post (1)</option>
<option value="6">Immaturity (2)</option>
<option value="7">Leet Speak (2)</option>
<option value="8">Spelling and Grammar (1)</option>
<option value="9">Leeching (1)</option>
<option value="10">Complaining/Demanding (3)</option>
<option value="11">Bad Member App (4)</option>
<option value="12">Arogant New Member (3)</option>
<option value="13">Grave Digging (2)</option>
<option value="14">Breaking Forum Rules (5)</option>
</select>

</td>
<td class="formfish"><input type="submit" name="Submit" value="Search by Offense" /></td>
</form>
</th>
</tr>
</table>

<script type="text/javascript">
<!--
document.write('</div>');
-->
</script>

<br />
<br />
<br />
</div>
</body>
</html>

Drunkenoldma
08-08-2007, 08:11 PM
that was my suggestion...
oops sorry hugo

LordGregGreg
08-08-2007, 10:47 PM
Why don't you make it so you can order the list by clicking on the title (where to order by)?oh , like default , no index, file style. sure :)