Your IP : 216.73.216.40


Current Path : /var/www/html/mmishra/mm/bmb/
Upload File :
Current File : /var/www/html/mmishra/mm/bmb/functions.inc.php

<?php

function metadata($keyname) {
	$tbl = 'metadata';
        $rs = mysql_query("select keyvalue from $tbl where webid='$webid' and keyname='$keyname'");
        if ($rs) {
                $o = mysql_fetch_object($rs);
                return $o->keyvalue;
        } else {
                return "Oops! value of metadata ($keyname) is missing.";
        }
}

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 = "<b>Announcements</b><br>
        <marquee id='scroll' scrolldelay='15' scrollamount='1' width='100%' height='400' direction='up'
        onmouseover=\"this.setAttribute('scrollamount', 0, 0);\" 
	onmouseout=\"this.setAttribute('scrollamount', 1, 0);\">";

        $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 .= "<a href='inner.php?conf=$o->rowid' title='Expiry $o->dateexpiry'>$o->hypertext</a><br>
                &nbsp;&nbsp;<img src='images/arrow.gif' /> $o->pagetitle
		<div class='datehit'>[ dated $o->datecreation, $o->hits hits ]</div><br>";
	}
        $str .= "</marquee>";

	return $str;
}

function advertisements($webid) {
        $tbl = 'webpages';
        $str = "<marquee id='scroll' scrolldelay='15' scrollamount='1' width='100%' height='30' direction='left'
        onmouseover=\"this.setAttribute('scrollamount', 0, 0);\"
        onmouseout=\"this.setAttribute('scrollamount', 1, 0);\">";

        $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 .= "<img src='images/arrow.gif' />
		<a href='inner.php?conf=$o->rowid' title='Dated $o->datecreation, Expiry $o->dateexpiry'>$o->hypertext</a>&nbsp;";
                if ($o->dateexpiry > date('Y-m-d')) mysql_query("update $tbl set status='offline' where rowid=$rowid");
        }
	$str .= "</marquee>";

        return $str;
}

function latestUpdations($webid) {
	$tbl = 'webpages';
	$str = "<b>Recent Updations</b>&nbsp;<br>";
        $rs = mysql_query("SELECT * FROM $tbl where webid='$webid' and status='online' order by dateupdation desc limit 1,5");
        while ($o = mysql_fetch_object($rs)) {
               	$str .= "
		<img src='images/arrow.gif' /> <a href='inner.php?conf=$o->rowid' title='Expiry $o->dateexpiry'>$o->hypertext</a>
		<!--<br>
		&nbsp;&nbsp;<img src='images/arrow.gif' /> $o->pagetitle
		-->
		<div class='datehit'>[ Dated $o->dateupdation, $o->hits hits ]</div>
               	";
		//<dir class='description'>". strip_tags(substr($o->pagecontent,0,100)). "...</dir>
        }
	return $str;
}

function leastVisited($webid) {
	$tbl = 'webpages';
	$str = "<b>Least Visited</b>&nbsp;<br>";
        $rs = mysql_query("select * from $tbl where webid='$webid' and status='online' and pageaccess='public' order by hits limit 1,5");
        while ($o = mysql_fetch_object($rs)) {
               	$str .= "
		<img src='images/arrow.gif' /> <a href='inner.php?conf=$o->rowid' title='Expiry $o->dateexpiry'>$o->hypertext</a>
		<!--<br>
		&nbsp;&nbsp;<img src='images/arrow.gif'> $o->pagetitle
		-->
		<div class='datehit'>[ Dated $o->dateupdation, $o->hits hits ]</div>
               	";
		//<dir class='description'>". strip_tags(substr($o->pagecontent,0,100)). "...</dir>
		//";
        }
	return $str;
}

function hmenus($webid, $user='guest', $role='public', $parentid=0) {
	$contentcategories = array(0 => 'Webpage',99995=>'Format',99996=>'Tender',99997 =>'Profile',99998=>'Advertisement',99999=>'Announcement');
        $tbl = 'webpages';
	//$sql = "select * from $tbl where webid='$webid' and status='online' and parentid=$parentid and pageaccess='public' order by hits desc, hypertext";
	$sql = "select * from $tbl where webid='$webid' and status='online' and parentid=$parentid and pageaccess='public' order by rowid";
	$rs = mysql_query($sql);
        
	if (!$parentid) $str .= "<ul>\n<li><a href='./' title='Back to Homepage'>Home</a></li>\n";
	else if (!mysql_num_rows($rs)) return '';
	else $str = "<ul>\n";

        while ($o = mysql_fetch_object($rs)) {
                $dropdownmenu = hmenus($webid, $user, $role, $o->rowid);
                if ($dropdownmenu) 
			$str .= "<li><a href='#'>$o->hypertext</a>$dropdownmenu</li>\n";
                else {
			$str .= "<li><a href='inner.php?conf=$o->rowid' title='Dated $o->datecreation, Expiry $o->dateexpiry'>$o->hypertext</a>\n";
			if ($role == 'admin' && !$o->pagecontent) {
                		$id = innerconf('webpage');
                		if ($id) $str .= "<ul><li><a href='admin.php?conf=$id&parentid=$o->rowid' title='New page'>Add New...</a></li></ul>\n";
			}
			$str .= "</li>\n";
		}
	}
        
	if (!$parentid) {
		if ($role == 'admin') {
                	$id = innerconf('webpage');
                	if ($id) $str .= "<li><a href='admin.php?conf=$id&parentid=$parentid' title='New page'>Add New...</a></li>\n";
		}
                $str .= "<li><a href='#'>Extra</a><ul>\n";
		if ($user) {
			$str .= "<li><a href='inner.php?logout=1' title='Session: $user as $role'>Sign Out [$user]</a></li>\n";
			if ($role == 'admin') {
				$str .= "<li><a href='#'>Configuration</a><ul>\n";
				$rs1 = mysql_query("select * from $tbl where pageaccess='admin' order by hits desc, hypertext");
        			while ($q = mysql_fetch_object($rs1)) {
					if ($id == $q->rowid) {
						$str .= "<li><a href='#'>$q->hypertext ($q->hits)</a><ul>\n";
						foreach ($contentcategories as $key => $cc) {
							$str .= "<li><a href='admin.php?conf=$q->rowid&parentid=$key' title='Create page'>$cc</a></li>\n";
						}
						$str .= "</ul></li>";
					} else
						$str .= "<li><a href='admin.php?conf=$q->rowid' title='ICDP $q->hypertext'>$q->hypertext</a></li>\n";
				
				}
				$str .= "</ul></li>";
			}
		} else {
			$id = innerconf('login');
			$str .= "<li><a href='admin.php?conf=$id' title='For content management'>Sign In</a></li>\n";
		}
		$str .= "<li><a href='#'>Web Profiles</a><ul>\n";
                $rs1 = mysql_query("select * from $tbl where webid='$webid' and parentid='99997' and status='online' order by dateupdation");
                if (mysql_num_rows($rs1)) {
                        while ($o = mysql_fetch_object($rs1)) {
                                $str .= "<li><a href='inner.php?conf=$o->rowid'>$o->hypertext</a></li>\n";
                        }
                } else $str .= "<li><a href='#'>None</a></li>\n";
		$str .= "</ul></li>";

		$tbl = 'webusers';
		$str .= "<li><a href='#'>Online Users</a><ul>\n";
		$rs1 = mysql_query("select * from $tbl where webid='$webid' and sessionid>'' order by datesession");
		if (mysql_num_rows($rs1)) {
			while ($o = mysql_fetch_object($rs1)) {
				$str .= "<li><a href='inner.php?conf=webusers&uid=$o->userid'>$o->userid from $o->sessionip</a></li>\n";
			}
		} else $str .= "<li><a href='#'>None</a></li>\n";
			
                $str .= "</ul></li></ul></li>\n";
       		
        } else if ($role == 'admin') {
		$id = innerconf('webpage');
                $str .= "<li><a href='admin.php?conf=$id&parentid=$parentid' title='New page'>Add New...</a></li>\n";
	}
	$str .= "</ul>\n";
	return $str;
}

function search($webid, $query) {
	$str = "<b>Search [$query]</b>";

        $tbl = 'webpages';
        $rs = mysql_query("select * from $tbl where webid='$webid' and status='online' and CONCAT(pagecontent, keywords) like '%$query%'");
        if (mysql_num_rows($rs)) {
                while ($o = mysql_fetch_object($rs)) {
                        $str .= "<dir><a href='inner.php?conf=$o->rowid'>$o->hypertext</a><br>
                        &nbsp;&nbsp;<img src='images/arrow.gif' /> $o->pagetitle
                        <i class='datetime'>[ dated $o->datecreation, $o->hits hits ]</i>
                        <div class='description'>".strip_tags(substr(htmlunsafe($o->pagecontent),0,200)) . "...</div></dir>";
                }
        } else 
		$str .= '<dir>>None</dir>';
        
	return $str;
}

function sitemap($webid, $parentid) {
	if ($parentid == 0) $str = "<b>Sitemap</b><br><br><img src='images/arrow.gif'><a href='./'>Home</a><dir>";

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

function tender($webid, $status='online') {
	$str = "<b>Tenders</b><br>";
        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><br>
                	&nbsp;&nbsp;<img src='images/arrow.gif' /> $o->pagetitle
                	<i class='datetime'>[ dated $o->datecreation, $o->hits hits ]</i></dir>";
                        //<div class='description'>".strip_tags(substr(htmlunsafe($o->pagecontent),0,200)) . "...</div></dir>";
                }
        } else 
		$str .= '<dir>None</dir>';

        if ($status == 'online') 
		$str .= "<div class='datetime'><a href='#' onclick=\"showPage('tender','offline','$webid')\">Xpired...</a></div>";
        else 
		$str .= "<div class='datetime'><a href='#' onclick=\"showPage('tender','online','$webid')\">Current...</a></div>";

        return $str;
}

function format($webid) {
        $str = "<b>Formats</b><br>";
        
	$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>
                	&nbsp;&nbsp;<img src='images/arrow.gif' /> $o->pagetitle
                	<i class='datetime'>[ dated $o->datecreation, $o->hits hits ]</i>
                        <div class='description'>".strip_tags(substr(htmlunsafe($o->pagecontent),0,200)) . "...</div></dir>";
                }
        } else 
		$str .= '<dir>None</dir>';

        return $str;
}

?>