Your IP : 216.73.216.40


Current Path : /var/www/html/mmishra/indem/old/indem/wisdom/
Upload File :
Current File : /var/www/html/mmishra/indem/old/indem/wisdom/webmaster.php

<?php
/*
function dbConnect() {
        $link = mysql_connect("localhost", "root", "mysql");
        mysql_select_db("icdp");
        return $link;
}

function setup($key) {
	$tbl = 'setup';
        $rs1 = mysql_query("select setup_value from $tbl where setup_key='$key'");
        if ($rs1) {
                $o = mysql_fetch_object($rs1);
                return $o->setup_value;
        } else {
                return "Ooops! content missing";
        }
}

*/
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() . "&nbsp;times ]</div>";
	generate_file("banner.inc", $str);

	return $str;
}

function menus($referer = 0) {
	$tbl = 'menus';
	$rs = mysql_query("select * from $tbl where referer=$referer order by zindex");
	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($o->id);
		if ($submenu) $str .= "<li><span class='dir'>$o->title</span>$submenu</li>";
		else $str .= "<li><a href='inner.php?conf=$o->href'>$o->title</a></li>";
	}
	if ($referer == 0) {
		$str .= '</ul>';
		generate_file("menus.inc", $str);
		//fixed_links();
	} else {
		$str .= "<li class='divider'><a href='./'>More...</a></li></ul>";
	}
	return $str;
}

function announcements() {
	$tbl = 'announcements';
	$str = "<b>Recent Announcements</b><br>
        <marquee scrolldelay='15' scrollamount='1' width='100%' height='450' 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 updates() {

        include "updates.inc";
}

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 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 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>
        &nbsp;|&nbsp;<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>
        &nbsp;|&nbsp;<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);
}

?>