| Current Path : /var/www/html/mmishra/mm/ada/icdp/ |
| Current File : /var/www/html/mmishra/mm/ada/icdp/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 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>";
} else {
$str = "The website you are looking for is offline.";
}
return $str;
}
function announcements($webid) {
$tbl = 'webpages';
$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);\">";
$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>
<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='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> ";
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> <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> <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', $parentid=0) {
$tbl = 'webusers';
$rs1 = mysql_query("select * from $tbl where userid='$user'");
if (mysql_num_rows($rs1)) {
$q = mysql_fetch_object($rs1);
$role = $q->role;
} else
$role = 'public';
$contentcategories = array(0=>'Webpage',99990=>'Orphan',99995=>'Format',99996=>'Tender',99997=>'Profile',99998=>'Advertisement',99999=>'Announcement');
$tbl = 'webpages';
$rs = mysql_query("select * from $tbl where webid='$webid' and status='online' and parentid=$parentid and pageaccess='public' order by hits desc, rowid");
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, $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 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>
<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>
<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>
<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 get_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 get_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));
}
?>