Your IP : 216.73.216.40


Current Path : /var/www/html/mmishra/indem/sip/
Upload File :
Current File : /var/www/html/mmishra/indem/sip/functions.inc.php

<?php

function banner($webid) {
	$tbl = 'websites';
	$rs = mysql_query("select * from $tbl where webid='$webid' and status='online'");
	if (mysql_num_rows($rs)) {
        	$o = mysql_fetch_object($rs);
        	$title = $o->title;
        	$counter = $o->counter;
	
		$str = "<div class='datetime'>". date("h:i:s A, l, jS \of F Y") . "</div>
		<img class='banner' id='banner' src='text2image.php' onMouseOver=\"show('j_dj')\" onMouseOut=\"hide('j_dj')\" />
		<div class='datetime'>[ $counter times ]</div>";
	        mysql_query("update $tbl set counter = counter+1 where webid='$webid'");
	} else {
		$str = "The website you are looking for is offline.";
	}
	return $str;
}

function announcements($webid) {
	$tbl = 'webpages';
	$str = "<ul>";
        $rs = mysql_query("select * from $tbl where webid='$webid' and parentid=99999 and status='online' order by datecreation desc");
        while ($o = mysql_fetch_object($rs)) {
		$i++;
               	$str .= "<li><a href='inner.php?conf=$o->rowid' title='Expiry $o->dateexpiry'>$o->hypertext</a><br>
		<div class='btn_more'>Dated $o->datecreation, $o->hits hits</div></li>";
	}
        $str .= "</ul>";

	return $str;
}

function advertisements($webid) {
        $tbl = 'webpages';
        $str .= "<ul>";
        $rs = mysql_query("SELECT * FROM $tbl where webid='$webid' and parentid=99998 and status='online' order by datecreation desc");
        while ($o = mysql_fetch_object($rs)) {
                $str .= "<li><a href='inner.php?conf=$o->rowid' title='Dated $o->datecreation, Expiry $o->dateexpiry'>$o->hypertext</a></li>";
                if ($o->dateexpiry > date('Y-m-d')) mysql_query("update $tbl set status='offline' where rowid=$rowid");
        }
	$str .= "</ul>";

        return $str;
}

function latestUpdations($webid) {
	$tbl = 'webpages';
	$str = '<ul>';
        $rs = mysql_query("SELECT * FROM $tbl where webid='$webid' and status='online' and pageaccess='public' order by dateupdation desc limit 0,5");
        while ($o = mysql_fetch_object($rs)) {
               	$str .= "<li><a href='inner.php?conf=$o->rowid' title='Expiry $o->dateexpiry'>$o->hypertext</a>
		<div align='right'>Dated $o->dateupdation, Hits $o->hits</div></li>";
		//<dir class='description'>". strip_tags(substr($o->pagecontent,0,100)). "...</dir>
        }
	$str .= '</ul>';
	return $str;
}

function leastVisited($webid) {
	$tbl = 'webpages';
	/*$str = "<ul>";
        $rs = mysql_query("select * from $tbl where webid='$webid' and status='online' and pageaccess='public' order by hits limit 0,5");
        while ($o = mysql_fetch_object($rs)) {
               	$str .= "<li><a href='inner.php?conf=$o->rowid' title='Expiry $o->dateexpiry'>$o->hypertext</a></li>";
		//<div style='float: right; font-size: x-small'>[ Dated $o->dateupdation, $o->hits hits ]</div>
		//<dir class='description'>". strip_tags(substr($o->pagecontent,0,100)). "...</dir>
        }
	$str .= '</ul>';
	*/
	$str = "<ul>";
        $rs = mysql_query("select * from $tbl where webid='$webid' and status='online' and pageaccess='public' group by datecreation-curdate() order by hits limit 1,5");
        while ($o = mysql_fetch_object($rs)) {
		
               	$str .= "<li><a href='inner.php?conf=$o->rowid' title='Expiry $o->dateexpiry'>$o->hypertext</a></li>";
		//<div style='float: right; font-size: x-small'>[ Dated $o->dateupdation, $o->hits hits ]</div>
		//<dir class='description'>". strip_tags(substr($o->pagecontent,0,100)). "...</dir>
        }
	$str .= '</ul>';
	return $str;
}

function sitemap($webid, $parentid) {
	if ($parentid == 0) $str = "<h3>Sitemap</h3><a href='index.php'>Home</a><dir>";

        $tbl = 'webpages';
        $rs = mysql_query("select * from $tbl where webid='$webid' and status='online' and parentid=$parentid order by rowid");
        //if (mysql_num_rows($rs)) {
                while ($o = mysql_fetch_object($rs)) {
                        $pg = sitemap($webid, $o->rowid);
                        //$ptitle .= strtoupper($o->hypertext);
                        $ptitle .= $o->hypertext;
                        if ($pg) $str .= "$ptitle<dir>$pg</dir>";
                        else $str .= "<a href='inner.php?conf=$o->rowid'>$ptitle</a>
                        <div style='float: right; font-size: x-small'>[ dated $o->datecreation, $o->hits hits ]</div>
                        <dir style='font-size: x-small'>".strip_tags(substr(htmlunsafe($o->pagecontent),0,100))."...</dir>";
                }
        //} else 
		//$str .= '<dir>None</dir>';
	if ($parentid == 0) $str .= "</dir>";
        
	return $str;
}

function tenders($webid, $status='online') {
	$str = "<h3>Tenders</h3>";
        if ($status == 'online') $str .= "Please adhere with the dates and go through the file where ever attached. Thanks.";
        else $str .= "Past tenders only";

        $tbl = 'webpages';
        $rs = mysql_query("SELECT * FROM $tbl where webid='$webid' and parentid=99996 and status='$status' order by datecreation desc, rowid desc");
        if (mysql_num_rows($rs)) {
		while ($o = mysql_fetch_object($rs)) {
                	$str .= "<dir><a href='inner.php?conf=$o->rowid'>$o->hypertext</a>
                	<div align='right' style='font-size:x-small'>[ dated $o->datecreation, $o->hits hits ]</div>
                        ".substr(htmlunsafe(strip_tags($o->pagecontent)),0,200)."...</dir>";
                }
        } else 
		$str .= '<dir>None</dir>';

        if ($status == 'online') 
		$str .= "<div align='right' style='font-size:x-small'><a href='#' onclick=\"showPage('tenders','offline','$webid')\">Xpired...</a></div>";
        else 
		$str .= "<div align='right' style='font-size:x-small'><a href='#' onclick=\"showPage('tenders','online','$webid')\">Current...</a></div>";

        return $str;
}

function formats($webid) {
        $str = "<h3>Formats</h3>";
        
	$tbl = 'webpages';
        $rs = mysql_query("SELECT * FROM $tbl where webid='$webid' and parentid=99995 and status='online' order by datecreation desc, rowid desc");
        if (mysql_num_rows($rs)) {
		while ($o = mysql_fetch_object($rs)) {
                	$str .= "<dir><a href='inner.php?conf=$o->rowid'>$o->hypertext</a><br>
                	<div align='right' style='font-size:x-small'>[ dated $o->datecreation, $o->hits hits ]</div>
                        ".substr(htmlunsafe(strip_tags($o->pagecontent)),0,200)."...</dir>";
                }
        } else 
		$str .= '<dir>None</dir>';

        return $str;
}

function previous_month() {
        $pmonth = (int)(date("n"));
        if ($pmonth == 0) {
                $pmonth = 12;
                $pyear = date("Y") - 1;
        } else
                $pyear = date("Y");
        return date("M-Y",mktime(0,0,0,$pmonth,0,$pyear));
}

function next_month() {
        $nmonth = (int)(date("n"));
        if ($nmonth == 12) {
                $nmonth = 0;
                $nyear = date("Y") + 1;
        } else
                $nyear = date("Y");

        $nmonth = $nmonth + 1;
        return date("Y-m-d",mktime(0,0,0,$nmonth,25,$nyear));
}

function DateAdd($interval) {
        $curdate = getdate();
        $cday = $curdate['mday']+$interval;
        $cmonth = $curdate['mon'];
        $cyear = $curdate['year'];
        if ($cday > 30) {
                $cmonth = $cmonth + 1;
                $cday = $cday - 30;
                if ($cmonth == 13) {
                        $cyear = $cyear + 1;
                        $cmonth = 1;
                }
        }

        if ($cday < 10) $cday .= "0";
        if ($cmonth < 10) $cmonth .= "0";
        //$ourDate = array($cyear,$cmonth,$cday);
        $ourDate = "$cyear-$cmonth-$cday";

        return $ourDate;
}

function htmlsafe($str) {
	return trim(htmlspecialchars(stripslashes($str), ENT_QUOTES));
}

function htmlunsafe($str) {
	return trim(htmlspecialchars_decode($str, ENT_COMPAT));
}

?>