| Current Path : /var/www/html/mmishra/indem/icdp.bak/ |
| Current File : /var/www/html/mmishra/indem/icdp.bak/functions.inc |
<?php
function dbConnect() {
$link = mysql_connect("localhost", "root", "mysql");
mysql_select_db("icdp");
return $link;
}
function counter() {
$file = "counter.inc";
if (!file_exists($file)) {
touch ($file);
$count=0;
} else {
include "counter.inc";
$count++;
}
$str = '<? $count='.$count.'; ?>';
$handle = fopen ($file, 'r+');
fwrite ($handle, $str);
fclose($handle);
return $count;
}
function ajax() {
?>
<script language="javascript">
function GetXmlHttpObject() {
var xmlHttp=null;
try {
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
} catch (e) {
// Internet Explorer
try {
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
function showPage(q) {
if (q.length<3) {
document.getElementById("search_result").innerHTML="";
return;
}
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null) {
alert ("Your browser does not support AJAX!");
return;
}
var url="search.php?q="+q;
//alert(url);
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
function stateChanged() {
if (xmlHttp.readyState==4) {
document.getElementById("search_result").innerHTML=xmlHttp.responseText;
}
}
</script>
<?php
}
function flash() {
?>
<!-- START AD -->
<div class="WRBannerCenter" align="center">
<script language="JavaScript"><!--
function show(object) {
if (document.getElementById) {
document.getElementById(object).style.visibility = 'visible';
document.getElementById(object).style.top = document.getElementById('banner').style.top;
document.getElementById(object).style.left = document.getElementById('banner').style.left;
} else if (document.layers && document.layers[object]) {
document.layers[object].visibility = 'visible';
document.layers[object].top = document.getElementById('banner').style.top;
document.layers[object].left = document.getElementById('banner').style.left;
} else if (document.all) {
document.all[object].style.visibility = 'visible';
document.all[object].style.top = document.getElementById('banner').style.top;
document.all[object].style.left = document.getElementById('banner').style.left;
}
}
function hide(object) {
if (document.getElementById) {
document.getElementById(object).style.visibility = 'hidden';
} else if (document.layers && document.layers[object]) {
document.layers[object].visibility = 'hidden';
} else if (document.all) {
document.all[object].style.visibility = 'hidden';
}
}
//--></script>
<div class="flash" id="j_dj" onMouseOver="show('j_dj')" onMouseOut="hide('j_dj')">
<a href="http://www.iiita.ac.in"><img src="banners/cc1-lt-cc2.jpg" width="700" hspace="0" vspace="0" border="0"></a>
</div>
<!-- END AD -->
<?php
}
function setup($key) {
$tbl = 'setup';
$rs = mysql_query("select setup_value from $tbl where setup_key='$key'");
if ($rs) {
$o = mysql_fetch_object($rs);
return $o->setup_value . '<br>';
} else {
return "Ooops! content missing";
}
}
function sibling($parentid) {
$tbl = 'webpages';
$rs = mysql_query("select * from $tbl where parentid=$parentid");
if ($rs) {
$str = "<div align='right'>See also: ";
while ($o = mysql_fetch_object($rs)) {
$linktext = str_replace(" ", " ", $o->linktext);
$str .= "[ <a href='inner.php?conf=$o->pageid'>$linktext</a> ] ";
}
$str .= "</div>";
}
return $str;
}
function sendmail($email, $subject, $body) {
require("class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "mail.iiita.ac.in"; // SMTP server
$mail->FromName = "indem alld";
$mail->From = "indem@iiita.ac.in";
$mail->AddAddress($email,$email);
$mail->AddAddress("indem@iiita.ac.in","indem@iiita.ac.in");
$mail->Username = "indem";
$mail->Password = "#indemica";
$mail->Subject = $subject;
$mail->Body = $body;
$mail->WordWrap = 75;
if (!$mail->Send()) {
return $mail->ErrorInfo;
} else {
return TRUE;
}
}
function logs($user, $referer, $url) {
$tbl = 'logs';
if (!$user) $user = 'guest';
if (!$referer) $referer = 'direct';
if ($url == '/') $url = 'index.php';
$ip = $_SERVER["REMOTE_ADDR"];
mysql_query("insert into $tbl values(NULL, '$user', '$referer', '$url','$ip',now())");
}
function checkadmin($role) {
if ($role != "admin") {
echo "<div align=center>You must be a Site Administrator to access this page</div>";
exit;
}
}
function checklogin($user) {
if (!$user) {
echo "<div align=center>You must be logged in to access this page</div>";
exit;
}
}
function hitcounter() {
$file = "counter.inc";
if (!file_exists($file)) {
touch ($file);
$count=0;
} else {
include "counter.inc";
$count++;
}
echo $count;
$str = '<? $count='.$count.'; ?>';
$handle = fopen ($file, 'r+');
fwrite ($handle, $str);
fclose($handle);
}
function hitmeter($url = 'index') {
$tbl = 'hitmeter';
if (mysql_num_rows(mysql_query("select * from $tbl where url='$url'"))) {
mysql_query("update $tbl set counter=counter+1 where url='$url'");
} else {
mysql_query("insert into $tbl(url,counter,dated) values('$url',1,now())");
}
$tbl = 'webpages';
if (mysql_num_rows(mysql_query("select * from $tbl where pageid='$url'"))) {
mysql_query("update $tbl set counter=counter+1 where id='$url'");
}
$tbl = 'menus';
if (mysql_num_rows(mysql_query("select * from $tbl where href='$url'"))) {
mysql_query("update $tbl set counter=counter+1 where href='$url'");
}
}
function login(){
?>
<br>
<table width=100px class="login_box" border=0 cellpadding=0 cellspacing=2>
<tr><td></td><td height=20 align=right>
<input type="button" class="btn_close" value="X" onclick="hide_login();">
<input type=hidden name=login>
<!--helps inner.php know that we are trying to logon, so that it can create a session-->
<input type=hidden name=target value='<?=$target?>'>
</td></tr>
<tr><td><b>Username</b></td><td height=15>
<input class='text' type='text' name='txtID'>
</td></tr>
<tr><td height=15><b>Password</b></td><td>
<input class='text' type='password' name='txtPWD'>
</td></tr>
<tr><td height=30>
<input type='submit' value='Login'>
</td></tr>
</table>
<?
}
function fixed_links(){
$str = "<table border=0 cellspacing=2 cellpadding=0>
<tr><td height='15'><a href='inner.php?conf=tendercur'>Tenders</a></td></tr>
<tr><td height='15'><a href='inner.php?conf=rtiquery'>Query & RTI</a></td></tr>
<tr><td height='15'><a href='inner.php?conf=formformats'>Form Formats</a></td></tr>
<tr><td height='15'><a href='inner.php?conf=gallery'>Photo Gallery</a></td></tr>
<tr><td height='15'><a href='inner.php?conf=profiles'>Web Profiles</a></td></tr>
<tr><td height='15'><a href='inner.php?conf=telephone'>Telephones</a></td></tr>
<tr><td height='15'><a href='inner.php?conf=feedback'>Feedback</a></td></tr>
</table>";
generate_file("fixed_links.inc", $str);
}
function logView() {
mysql_query("insert into log values(NULL, '$user', '$referer', '$page_url','$ip',now())");
}
function uniq_sid($uid, $pwd) {
$epwd = base64_encode($pwd);
srand((double)microtime()*100000000);
//generate a unique sid
do {
$ch = "";
for($i=0; $i<20; $i++) {
$ch = $ch . chr(rand(65, 90));
}
// loop until a uniq string is generated
} while (!mysql_query("insert into auth values('$ch','$uid','$pwd','".$_SERVER["REMOTE_ADDR"]."',now())"));
return $ch;
}
function authenticate($uid, $pwd) {
$tbl = 'profiles';
$rs = mysql_query("select * from $tbl where login='$uid' and passwd=password('$pwd')");
if (mysql_num_rows($rs)) {
$o = mysql_fetch_object($rs);
if ($o->webmaster == 'Yes') return 'admin';
else return 'user';
} else {
return 'guest';
}
}
function hilite($body, $text) {
/*Internet stopped working.. So quit halfway */
/* Can we make it work also for & kind of stuffs.. */
/* The & etc is also taken care of now. */
$body = unhtmlentities($body);
$new_text = preg_replace("/\040/","+",$text);
$new_text = explode("+",$new_text);
foreach($new_text as $txt){
$txt = trim($txt);
if(empty($txt)) continue;
$alpha_text = preg_replace("/\W/","-",$text);
$strings = explode("-",$alpha_text);
foreach($strings as $str){
if(!empty($str))
$texts[] = $str;
}
}
//$patterns[$i] = '/'.preg_quote($text[$i], '/').'/i';
$orig_body = $body;
$new_body = "";
foreach($texts as $text){
$text = trim($text);
if(strlen($text)<=2) continue;
if($new_body!=""){
$body=unhtmlentities($new_body);
$new_body="";
}
while ($body!="") {
if (preg_match('{^([^<]*)?(</?[^>]+?>)?(.*)$}s',$body,$matches)) {
/* this while loop is to preserve case of every match. */
$new_str = $matches[1];
while($new_str!=""){
$match_pos = strpos(strtolower($new_str),strtolower($text));
if($match_pos===false){
$new_body.=htmlentities($new_str);
$new_str="";
} else {
if($match_pos!=0)
$new_body.=htmlentities(substr($new_str,0,$match_pos));
$match = substr($new_str,$match_pos,strlen($text));
$replacement = "<span style=\"background: black; color: white;\">$match</span>";
$new_body.= $replacement;
$new_str = substr($new_str,$match_pos+strlen($text));
}
}
$new_body.= $matches[2];
$body = $matches[3];
}
}
}
if($new_body=="") return $orig_body;
else return $orig_body;
}
function banner() {
$str = "<div align='right'>". date("h:i:s A, l, jS \of F Y") . "</div>";
$no = rand(1,17);
$str .= "<img id='banner' src='banners/banner{$no}.png' align='center' onMouseOver=\"show('j_dj')\" onMouseOut=\"hide('j_dj')\" />";
$str .= "<div align='right'>[" . counter() . " times ]</div>";
generate_file("banner.inc", $str);
return $str;
}
function menus($user, $role, $parentid = 0) {
$tbl = 'webpages';
$rs = mysql_query("select * from $tbl where parentid=$parentid order by counter desc, linktext");
if ($parentid && !mysql_num_rows($rs)) return '';
if ($parentid == 0) {
$str = "<ul id='nav' class='dropdown dropdown-horizontal'>
<li><a href='./'>Home</a></li>";
} else {
$str = '<ul>';
}
while ($o = mysql_fetch_object($rs)) {
$submenu = menus($user, $role, $o->rowid);
if ($submenu) $str .= "<li><span class='dir'>$o->pagetitle</span>$submenu</li>";
else if ($role == 'admin')
$str .= "<li><a href='inner.php?conf=webpages&pageid=$o->pageid'>$o->pagetitle ($o->counter)</a></li>";
else
$str .= "<li><a href='inner.php?conf=$o->pageid'>$o->pagetitle ($o->counter)</a></li>";
}
if ($parentid == 0) {
$str .= "<li><span class='dir'>Webmaster</span><ul>";
$str .= "<li><a href='./'>" . setup('webmaster') . "</a></li>";
$str .= webmaster($role);
$str .= "</ul></li>";
if ($role == 'admin') $str .= "<li><a href='inner.php?conf=webpages&parentid=0'>Add new...</a></li>";
} else {
if ($role == 'admin') {
$str .= "<li class='divider'><a href='inner.php?conf=webpages&parentid=$parentid'>Add new...</a></li>";
}
}
$str .= "</ul>";
return $str;
}
function menusx($user, $role, $referer = 0) {
$tbl = 'menus';
$rs = mysql_query("select * from $tbl where referer=$referer order by counter desc, title");
if (!mysql_num_rows($rs)) return '';
if ($referer == 0) {
$str = "<ul id='nav' class='dropdown dropdown-horizontal'>
<li><a href='./'>Home</a></li>";
} else {
$str = '<ul>';
}
while ($o = mysql_fetch_object($rs)) {
$submenu = menus($user, $role, $o->id);
if ($submenu) $str .= "<li><span class='dir'>$o->title</span>$submenu</li>";
else if ($role == 'admin') $str .= "<li><a href='inner.php?conf=webpages&pageid=$o->href'>$o->pagetitle ($o->counter)</a></li>";
else $str .= "<li><a href='inner.php?conf=$o->href'>$o->title ($o->counter)</a></li>";
}
if ($referer == 0) {
$str .= "<li><span class='dir'>Webmaster</span><ul>";
$str .= "<li><a href='./'>" . setup('webmaster') . "</a></li>";
$str .= webmaster($role);
$str .= "</ul></li>";
if ($role == 'admin') $str .= "<li><a href='inner.php?conf=menus&referer=0'>Add new...</a></li>";
$str .= "</ul>";
//generate_file("menus.inc", $str);
} else {
if ($role == 'admin') {
$str .= "<li class='divider'><a href='inner.php?conf=menus&referer=$referer'>Add new...</a></li>";
}
$str .= "</ul>";
}
return $str;
}
function webmaster($user, $role) {
if ($role == 'admin') {
$str = "<li><a href='inner.php?conf=welcome'>Welcome</a></li>
<li><a href='inner.php?conf=setup'>Setup Key</a></li>
<li><a href='?conf=banner'>Site Banner</a></li>
<li><a href='?conf=webpages&id=mm'>Webpage</a></li>
<li><a href='?conf=announcements&id=mm'>Announcement</a></li>
<li><a href='?conf=news&id=mm'>Advertisement</a></li>
";
} else if ($role == 'user') {
$str = "<li><a href='inner.php?conf=profiles&loginID=$user'>Profile</a></li>
<li><a href='inner.php?conf=uploads'>File Upload</a></li>
<li><a href='inner.php?conf=formats'>Form Formats</a></li>
<li><a href='inner.php?conf=gallery'>Photo Gallery</a></li>
<li><a href='inner.php?conf=logview'>Log View</a></li>
<li><a href='inner.php?conf=hitmeter'>Hit Meter</a></li>
";
}
$str .= "<li class='divider'>";
if ($user) {
$str .= "<a href='inner.php?logout=1'>Sign Out ($user as $role)</a>";
} else {
$str .= "<a href='inner.php?conf=login'>Sign In</a>";
}
$str .= "</li>";
return $str;
}
function announcements() {
$tbl = 'announcements';
$str = "<b>Announcements</b><br>
<marquee scrolldelay='15' scrollamount='1' width='100%' height='300' direction='up'
onmouseover=\"this.setAttribute('scrollamount', 0, 0);\"
onmouseout=\"this.setAttribute('scrollamount', 1, 0);\">";
$rs = mysql_query("SELECT * FROM $tbl where status='online' order by dated desc, id desc");
while ($o = mysql_fetch_object($rs)) {
$i++;
$str .= "<img src='images/arrow.gif'>$o->subject
<a href='downloads.php?filename=$o->filename&tbl=announcements'>$o->message</a><br>
<font size=-1px>$o->description</font>
<div align='right'><font size=-1px>[ dated $o->dated, $o->counter times ]</font></div>";
}
$str .= "<hr>[ <a href='http://www.adobe.com/products/acrobat/readstep2.html'>Download Acrobat</a> ]
[ <a href='?conf=xannouncements'>Xpired...</a> ]
</marquee>";
generate_file("announcements.inc", $str);
return $str;
}
function updations() {
$tbl = 'webpages';
$str = "<b>Recent Updations</b><br>";
$i = 0;
$rs = mysql_query("SELECT * FROM $tbl order by dateupdation desc limit 1,5");
while ($o = mysql_fetch_object($rs)) {
$i++;
$str .= "<img src='images/arrow.gif'><a href='inner.php?conf=$o->pageid'>$o->pagetitle</a>
<dir class='description'>" . strip_tags(substr($o->pagecontent,0,100)) . "...</dir>
<div class='datetime'>[ dated $o->dateupdation, $o->counter times ]</div>";
}
//generate_file("updations.inc", $str);
return $str;
}
function photo_gallery() {
$fp = fopen ("gallery.inc", "r");
if (!$fp) {
$images = array("logo.jpg");
} else {
$i = 0;
$images = array();
while (!feof ($fp)) {
$line = fgets ($fp, 1024);
//$images = explode(",", $line);
if ($line != "\n") $images[$i] = str_replace("\n", "", $line);
$i++;
}
}
fclose($fp);
$i--;
srand((double)microtime()*1000000);
$no = rand(0, $i);
$fname = $images[$no];
echo "<img src='images/$fname' width='420' height='240'></img>";
}
function welcome() {
$tbl = 'webpages';
$rs1 = mysql_query("select title,content from $tbl where id='site_intro'");
if ($rs1) {
$o = mysql_fetch_object($rs1);
$str = "<b>$o->title</b><br>$o->content<br>";
} else {
$str = "Welcome...<br><br>Nothing to show here.
Please visit control panel to create this section";
}
generate_file("welcome.inc", $str);
}
function upload_file() {
$maxsize =9998860800;
$uploadfile = strtolower(basename($_FILES['userfile']['name']));
$addto_gallery = $_POST['addto_gallery'];
$filesize = $_FILES["userfile"]["size"];
if ($uploadfile && $filesize < $maxsize) {
$filename = explode(".", strtolower($uploadfile));
$ext = $filename[count($filename)-1];
if ($ext == 'jpg' || $ext == 'gif' || $ext == 'tif' || $ext == 'png') {
$dir = 'images/';
if ($addto_gallery == 'yes') addto_gallery($uploadfile);
} else $dir = 'documents/';
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $dir.$uploadfile)) {
shell_exec("chmod 755 $dir.$uploadfile");
echo "$uploadfile was successfully uploaded.<br><br>";
} else {
echo "Sorry! there may be some error.<br><br>";
}
} else {
echo "Either file name is missing or file size exceeds the max. limit of 10 MB<br><br>";
}
}
function noticefeed() {
$rs = mysql_query("SELECT * FROM notices where status='online' order by dated desc, id desc");
while ($o = mysql_fetch_object($rs)) {
$i++;
$str .= "<table border='0' cellpadding='0' cellspacing='2'>
<tr valign='top'><td><img src='images/arrow.gif'></td>
<td onmouseover=\"show('announce$i')\" onmouseout=\"hide('announce$i')\">
<a href='downloads.php?filename=$o->filename&tbl=notices'>$o->subject</a><br/>
<table class='announce' id='announce$i' border='0' cellpadding='0' cellspacing='5'>
<tr valign='top'><td align='center' class='announce'>
<font size=1pts>$o->description<br>Dated: $o->dated<br>Hits so far: $o->counter</td>
</tr></table>
</td></tr></table>";
}
$str .= "<div align='right'>[ <a href='http://www.adobe.com/products/acrobat/readstep2.html'>
Download Acrobat</a> ][ <a href='inner.php?conf=noticemore'>More...</a> ]</div>";
generate_file("notices.inc", $str);
$i = 0;
$rs = mysql_query("SELECT * FROM notices where status='expired' order by dated desc");
$str = "Past notifications only.<ul>";
$rs = mysql_query("SELECT * FROM notices where status='expired' order by dated desc");
while ($o = mysql_fetch_object($rs)) {
$i++;
$str .= "<li><b>$i) $o->subject</b>
<dir>$o->description<br>";
if ($o->url) $str .= "More details: <a href='$o->filename'>$o->filename</a>";
$str .= "<div align='right'><i>Hits so far: $o->counter ($o->dated to $o->expiry)</i></div>
</dir></li>";
}
$str .= "</ul>";
generate_file("noticex.inc", $str);
}
function tenderfeed() {
$str = "Please adhere with the dates and go through the file where ever attached. Thanks.<ul>";
$rs = mysql_query("SELECT * FROM tenders where status='current' order by dated desc, id desc");
while ($o = mysql_fetch_object($rs)) {
$i++;
$str .= "<li><b>$o->subject</b><dir style='margin:0 0 0 0'>";
if ($description) {
echo $o->description."<br>";
}
if ($o->filename) $str .= "More details:
<a href='downloads.php?filename=$o->filename&tbl=tenders'>$o->filename</a>";
$str .= "<div align='right'><i>
Dated $o->dated Downloads $o->counter (Last-date $o->expiry)</i></div>
</dir></li>";
}
$str .= "</ul> <? tenderfeed(); ?>
<div align='right'>
<a href='http://www.adobe.com/products/acrobat/readstep2.html'>Download Acrobat</a>
| <a href='inner.php?conf=tendermore'>More...</a></div>";
generate_file("tenders.inc", $str);
$i = 0;
$str = "Past tenders only.<ul>";
$rs = mysql_query("SELECT * FROM tenders where status='expired' order by dated desc");
while ($o = mysql_fetch_object($rs)) {
$i++;
$str .= "<li><b>$o->subject</b><dir style='margin:0 0 0 0'>";
if ($description) {
echo $o->description."<br>";
}
if ($o->filename) $str .= "More details:
<a href='downloads.php?filename=$o->filename&tbl=tenders'>$o->filename</a>";
$str .= "<div align='right'><i>
During $o->dated - $o->expiry total downloads $o->counter</i></div>
</dir></li>";
}
$str .= "</ul> <? tenderfeed(); ?>
<div align='right'>
<a href='http://www.adobe.com/products/acrobat/readstep2.html'>Download Acrobat</a>
| <a href='inner.php?conf=tendercur'>More...</a></div>";
generate_file("tenderx.inc", $str);
}
function formatfeed() {
$rs = mysql_query("SELECT * FROM formats where status='current' order by dated desc");
$str = "Please click on the filename to download desired form format.<ul>";
while ($o = mysql_fetch_object($rs)) {
$i++;
$str .= "<li><b>$o->description</b>
<dir style='margin:0 0 0 0'>
<a href='downloads.php?filename=$o->filename&tbl=formats' target='new'>$o->filename</a><br>";
$str .= "<div align='right' style='margin:0 0 0 0'>
<i>Dated $o->dated Downloads $o->counter</i></div>
</dir></li>";
}
$str .= "</ul> <? formatfeed(); ?>
<div align='right'>
<a href='http://www.adobe.com/products/acrobat/readstep2.html'>Download Acrobat</a>
</div>";
generate_file("formats.inc", $str);
}
function newsfeed(){
$str = '<? xml version=\"1.0\" ?> <rss version=\"2.0\"><channel>';
$rs = mysql_query("SELECT * FROM news where status='current' order by dated desc, id desc");
while ($o = mysql_fetch_object($rs)) {
$str .= "<item>
<title>$o->subject</title>
<link>$o->url</link>
<description>$o->description</description>
<pubDate>$o->dated</pubDate>
<category>Achievement</category>
</item>";
}
$str .= "</channel></rss>";
generate_file("rss.xml", $str);
}
function generate_file($file, $str) {
if (!file_exists($file)) {
touch ($file);
}
if (!$handle = fopen ($file, 'w+')) {
echo "$file file permission error";
} else if (is_writable($file)) {
if (fwrite ($handle, $str) === FALSE) {
echo "Can't write to $file";
}
}
fclose($handle);
$out = shell_exec("chmod 757 $file");
}
function addto_gallery($fname){
$str = shell_exec("cat gallery.inc") . "\n";
//if not already in gallery
if (!strpos($str, $fname)) {
$str .= $fname;
generate_file("gallery.inc", $str);
}
}
function getFileExtension($str) {
$i = strrpos($str,".");
if (!$i) { return ""; }
$l = strlen($str) - $i;
$ext = substr($str,$i+1,$l);
return $ext;
}
function create_img($image_in,$image_out,$text,$color,$font,$font_size,$angle,$offset_x,$offset_y,$shadow_color) {
if (!$text) $text = 'mmishra@iiita.ac.in';
if (!$offset_x) $offset_x = 0; // Horizontal offset in pixels, from the right
if (!$offset_y) $offset_y = 0; // Vertical offset in pixels, from the bottom
if ($shadow_color) $drop_shadow = true;
else $shadow_color = '#909009';
#################################################################################
# END OF SETTINGS
#################################################################################
// Load functions for image watermarking
include("watermark_text.class.php");
// create class instance
$img = new Zubrag_watermark($image_in);
// shadow params
$img->setShadow($drop_shadow, $shadow_color);
// font params
$img->setFont($font, $font_size);
// Apply watermark
$img->ApplyWatermark($text, $color, $angle, $offset_x, $offset_y);
// Save on server
$img->SaveAsFile($image_out);
// release resources
$img->Free();
return;
}
function check_email($email) {
if (eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]", $email)) {
return FALSE;
}
list($Username, $Domain) = split("@",$email);
if (getmxrr($Domain, $MXHost)) {
return TRUE;
} else {
if (fsockopen($Domain, 25, $errno, $errstr, 30)) {
return TRUE;
} else {
return FALSE;
}
}
}
function check_abuser($post,$name,$email,$ip) {
if (mysql_num_rows(mysql_query("select * from abusers where ip='$ip' or email='$email' or name='$name'"))) {
return TRUE;
} else {
$abuses = array('nude','teen','www','url','sex','suck','fuck','xxx','pussy','penis','hotty','sexual','porn','movie');
foreach ($abuses as $abuse) {
if (stristr($post,$abuse)) {
mysql_query("insert into abusers(name,email,ip,dated) values('$name','$email','$ip',now())");
return TRUE;
}
}
return FALSE;
}
}
function ReplaceBadWords($str, $bad_words, $replace_str){
if (!is_array($bad_words)){
$bad_words = explode(',', $bad_words);
}
for ($x=0; $x < count($bad_words); $x++){
$fix = isset($bad_words[$x]) ? $bad_words[$x] : '';
$_replace_str = $replace_str;
if (strlen($replace_str)==1){
$_replace_str = str_pad($_replace_str, strlen($fix), $replace_str);
}
$str = preg_replace('/'.$fix.'/i', $_replace_str, $str);
}
return $str;
}
function htmlsafe($str) {
return trim(htmlspecialchars(stripslashes($str), ENT_QUOTES));
}
function unhtmlentities ($string){
$trans_tbl = get_html_translation_table (HTML_ENTITIES);
$trans_tbl = array_flip ($trans_tbl);
return strtr ($string, $trans_tbl);
}
?>