A preserved archive of the Logical Gamers community forums, 2009-2025. The original threads and posts, served read-only. Registration, posting and private messages are gone for good.

[PHP] Signature Shoutbox

1.2k views · started by ThatGuyJohn ·
#1
[PHP] Signature Shoutbox
Config.php
<?php

define("TEXT_DATABASE_NAME","text.txt"); // .txt file which stores the signature text
define("TEXT_IP_DATABASE","text1.txt"); // .txt file which stores previous signature texts and their IP addresses
define("HTTP_REFERRERS","referrers.txt"); // .txt file which stores the HTTP_REFERRALS so you can see who came from where

define("YOUR_USERNAME","Byah!"); // Your username
define("YOUR_PASSCODE","abc"); // Your secret passcode ***NOTE: This is NOT your password - just used to sign into the admin.php page

define("CLICK_KEY","Want to change my signature? Click here."); // Change the "click here to change..." text
define("NO_TEXT_KEY","*nothing*"); // Change what is shown if there is no text entered

define("RAW_IMAGE_NAME","imgraw.png"); // Change the raw image that is shown behind the signature. **NOTE: Does not support the Alpha channel

?>



Admin.php
<?php
include("config.php");
?>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>sigChange - Admin</title>
<style>
body {

background-color:#333;

font-family:Arial, Helvetica, sans-serif;

margin:0;
padding:0;

width:100%;

}
</style>
</head>

<body>

<br /><br />

<table border="0" cellpadding="0" cellspacing="0" align="center">
<tr>
<td align="center">
<span style="font-size:32px; color:#FFF;">sigChange</span><br />
<span style="font-size:12px; color:#FFF;">Administration Page</span><br /><br /></td>
</tr>
<tr><td align="center">

<?php if ($_POST['password'] == YOUR_PASSCODE) { ?>

<span style="color:#FFF;">Current Text</span><br />
<textarea style="width:500px; height:300px;" readonly><?php echo file_get_contents(TEXT_DATABASE_NAME,"w"); ?></textarea><br /><br />

<span style="color:#FFF;">Text Changes</span><br />
<textarea style="width:500px; height:300px;" readonly><?php echo file_get_contents(TEXT_IP_DATABASE,"w"); ?></textarea><br /><br />

<span style="color:#FFF;">HTTP Referrers</span><br />
<textarea style="width:500px; height:300px;" readonly><?php echo file_get_contents(HTTP_REFERRERS,"w"); ?></textarea><br /><br />

<?php } else { ?>

<form method="post" action="<?php echo $PHP_SELF; ?>">
<span style="color:#FFF;">Passkey:</span> <input type="password" name="password" style="width:200px;" /> <input type="submit" value="Login" />
</form>

<?php } ?>

</td>
</tr>
<tr>
<td><br /><br />
<img src="image.php" /></td>
</tr>
</table>

</body>
</html>



Image.php
<?php

include("config.php");

$im = imagecreatefrompng(RAW_IMAGE_NAME);

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

// CHOOSE TEXT COLOR

$yellow = imagecolorallocate($im, 255, 255, 0);
$blue = imagecolorallocate($im, 65, 105, 255);
$red = imagecolorallocate($im, 255, 0, 0);
$orange = imagecolorallocate($im, 255, 165, 0);
$green = imagecolorallocate($im, 0, 128, 0);
$brown = imagecolorallocate($im, 139, 69, 19);
$pink = imagecolorallocate($im, 255, 105, 180);
$white = imagecolorallocate($im, 255, 255, 255);
$gray = imagecolorallocate($im, 200, 200, 200);
$black = imagecolorallocate($im, 0, 0, 0);

$width = imagesx($im);
$height = imagesy($im);

$font = 4;

$text = html_entity_decode(file_get_contents(TEXT_DATABASE_NAME));

if (strlen($text) == 0) $text = NO_TEXT_KEY;

$leftTextPos = ($width - imagefontwidth($font) * strlen($text))/2;
imagestring($im, 4, $leftTextPos + 1, $height - 110, $text, $black);
imagestring($im, 4, $leftTextPos, $height - 110, $text, $yellow);
imagestring($im, $font, (($width - imagefontwidth($font) * strlen(CLICK_KEY))/2) + 1, $height - 20, CLICK_KEY, $black);
imagestring($im, $font, ($width - imagefontwidth($font) * strlen(CLICK_KEY))/2, $height - 20, CLICK_KEY, $gray);

header('Content-type: image/png');

imagepng($im);

imagedestroy($im);

?>



Index.php
<?php

include("config.php");

function censor ($text) {

$text = str_ireplace("\\","",$text);
$text = str_ireplace("fuck","love",$text);
$text = str_ireplace("nigger","white man",$text);
$text = str_ireplace("cunt","lady parts",$text);
$text = str_ireplace("shit","poop",$text);
$text = str_ireplace("fag","homosexual",$text);
$text = str_ireplace("cock","Male Rooster",$text);
$text = str_ireplace("gay","freaking awesome",$text);

return $text;

}

if(!file_exists(TEXT_DATABASE_NAME)) fopen(TEXT_DATABASE_NAME,"w");
if(!file_exists(TEXT_IP_DATABASE)) fopen(TEXT_IP_DATABASE,"w");
if(!file_exists(HTTP_REFERRERS)) fopen(HTTP_REFERRERS,"w");

if (!isset($_POST['text'])) {

$contents = file_get_contents(HTTP_REFERRERS);
$f = fopen(HTTP_REFERRERS,"w");
fwrite($f, $contents . "\n" . $_SERVER['REMOTE_ADDR'] . ":" . $_SERVER['HTTP_REFERER']);
fclose($f);

}

?>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>sigChange - <?php echo YOUR_USERNAME; ?></title>
<style>
body {

background-color:#333;

font-family:Arial, Helvetica, sans-serif;

margin:0;
padding:0;

width:100%;

}
</style>
</head>

<body>
<br /><br />

<?php

if (isset($_POST['text'])) {

$f = fopen(TEXT_DATABASE_NAME,"w");

$text = censor(substr($_POST['text'],0,200));
$textBackup = substr($_POST['text'],0,200);

fwrite($f,htmlentities($text));
fclose($f);

$contents = file_get_contents(TEXT_IP_DATABASE);
$f = fopen(TEXT_IP_DATABASE,"w");
fwrite($f, $contents . "\n" . $_SERVER['REMOTE_ADDR'] . ":" . $textBackup . ":" . $text);
fclose($f);

echo "<div style='width:100%; height:18px; background-color:#00FF66; border-top:#006600 5px solid; border-bottom:#006600 5px solid; text-align:center;'>" . YOUR_USERNAME . "'s Signature Updated!</div><br /><br />";

}
?>

<table border="0" cellpadding="0" cellspacing="0" align="center">
<tr>
<td align="center">
<span style="font-size:32px; color:#FFF;">sigChange</span><br />
<span style="font-size:12px; color:#FFF;">Change <?php echo YOUR_USERNAME; ?>'s Signature!</span><br /><br /></td>
</tr>
<tr><td align="center"><form method="post" action="<?php echo $PHP_SELF; ?>">
<span style="color:#FFF;">Message: </span><input type="text" name="text" /><br />
<center><input type="submit" value="Submit" /></center>
</form></td>
</tr>
<tr>
<td><br /><br />
<img src="image.php" /></td>
</tr>
</table>

</body>
</html>




upload those and make sure u have a raw image for the background.

My Raw image:
http://mortal.elementfx.com/sigimg/imgraw.png


Example in my signature
#2
This isn't a tutorial, moved to source codes. Great either way. Good job!
#3
haha sorry about that i thought i click source codes :$