| Current Path : /var/www/html/mmishra/mm/air/ |
| Current File : /var/www/html/mmishra/mm/air/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 = "<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' order by dateupdation desc 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 align='right'>Dated $o->dateupdation, Hits $o->hits</div>
//<dir class='description'>". strip_tags(substr($o->pagecontent,0,100)). "...</dir>
}
$str .= '</ul>';
return $str;
}
function leastVisited($webid) {
$tbl = 'webpages';
$str = "<b>Least Visited</b> <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>
<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 hmenusxx($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 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 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>
<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 = "<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>
<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));
}
?>