September 28, 2011
Cool signature script
This is a quick fun script for people wanting to have a cool signature of different forums. This script will let users add new messages and display them on your signature dynamically. Installation is very easy, just create a file with the following code and another file named 'data.txt' in the same folder. Don't forget to chmod data.txt to 0755.<?php
$sigs = array();
$file = 'data.txt';
$contents = file_get_contents($file);
if(!empty($contents))
$sigs = json_decode($contents);
if(isset($_GET['add'])){
if(isset($_GET['clr'])){
file_put_contents($file,'');
$sigs = array();
}
if(!empty($_POST['submit'])){
$nom = $_POST['nom'];
$msg = $_POST['msg'];
if(!empty($nom) && !empty($msg)){
$nom = preg_replace('@[^a-z0-9 ><_\-\?\.]@i','',$nom);
$msg = preg_replace('@[^a-z0-9 ><_\-\?\.]@i','',$msg);
if(!(strlen($nom)<=12 && strlen($msg)<=70)){
$nom = substr($nom,0,12);
$msg = substr($msg,0,12);
}
$sigs[] = array('time'=>$_SERVER['REQUEST_TIME'],'nom'=>$nom,'msg'=>$msg);
}
}
{
echo'
<img src="?img" alt="" border="0" />
<br />
<form method="POST">
<input type="hidden" value="" name="add" />
<input type="text" value="" name="nom" size="12" />
<input type="text" value="" name="msg" size="70" />
<input type="submit" name="submit" value="Add" />
</form>
';
echo"<a href='?img'>view sig</a> | <a href='?add'>add msg</a> | <a href='?add&clr'>clear all</a>";
}
$sigs = json_encode($sigs);
file_put_contents($file,$sigs);
}
elseif(isset($_GET['img'])){
if(!empty($sigs)){
$sigs = array_reverse($sigs);
$img = imagecreatetruecolor(800,120);
imagecolorallocate($img,0,0,0);
$color = imagecolorallocate($img,255,255,255);
$i = 0;
foreach($sigs as $sig){
if($i>=5)
break;
imagestring($img,15,4,10+($i*20),'| '.$sig->nom.' : '.$sig->msg,$color);
imagestring($img,15,720,10+($i*20),date('h:i:s',$sig->time),$color);
$i++;
}
header('Content-type: image/png');
imagepng($img);
imagedestroy($img);
}
}else{
echo"<a href='?img'>view sig</a> | <a href='?add'>add msg</a> | <a href='?add&clr'>clear all</a>";
}
?>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment