Your IP : 216.73.216.40


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

<?php

function studentzone() {
	$links = array('Enrollment','Study Center','Programs');

	$str = "<a href='inner.php?conf=$rowid' title='Expiry $dateexpiry'>$hypertext</a><br>";
	

}


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 banner1($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,$query='') {
	$tbl = 'webpages';
	if (!$query) $str = "
        <marquee id='scroll' scrolldelay='15' scrollamount='1' width='100%' height='340' direction='up'
        onmouseover=\"this.setAttribute('scrollamount', 0, 0);\" 
	onmouseout=\"this.setAttribute('scrollamount', 1, 0);\">";

        if ($query == 'offline') 
		$rs = mysql_query("select * from $tbl where webid='$webid' and parentid=99999 and status='offline' order by datecreation desc");
        else 
		$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>";
	}
        if ($query == 'online' || $query == '') $str .= "<a href='#' onclick=\"showPage('announcements','offline','$webid')\">X-pired Announcements...</a>";
        else $str .= "<a href='#' onclick=\"showPage('announcements','online','$webid')\">Current Announcements...</a>";
        if (!$query) $str .= "</marquee>";

	return $str;
}

function advertisements($webid) {
        $tbl = 'webpages';
        $str = "<marquee id='scroll' scrolldelay='15' scrollamount='1' width='100%' height='20' 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>
		<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',99990=>'Orphan',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='index.php' 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='#'>Edit</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";
					$str .= "<li><a href='#'>Content</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>\n";
				} else
					$str .= "<li><a href='admin.php?conf=$q->rowid' title='ICDP $q->hypertext'>$q->hypertext</a></li>\n";
			}
			$str .= "</ul></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></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 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");
        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>";
        }
	$contentcategories = array(0=>'Homepage',99990=>'Orphan',99995=>'Format',99996=>'Tender',99997=>'Profile',99998=>'Advertisement',99999=>'Announcement');
	if ($parentid == 0) {
		$str .= "</dir>";
		$parents = array(99990=>'Orphan',99995=>'Format',99996=>'Tender',99997=>'Profile',99998=>'Advertisement',99999=>'Announcement');
		foreach ($parents as $key => $cc) {
			$str .= "$cc<dir>";
        		$rs = mysql_query("select * from $tbl where webid='$webid' and status='online' and parentid=$key order by hypertext");
        		while ($o = mysql_fetch_object($rs)) {
                		$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>";
        		}
			$str .= "</dir>";
		}
        }
	return $str;
}

function tenders($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('tenders','offline','$webid')\">Xpired...</a></div>";
        else 
		$str .= "<div class='datetime'><a href='#' onclick=\"showPage('tenders','online','$webid')\">Current...</a></div>";

        return $str;
}

function formats($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;
}

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 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 755 $file");
}
?>