Code:
<?php
/************************************************************************/
/* */
/* Quran Module By Syed Mohammad Rasel */
/* =============================== */
/* version 1.0 30 August, 2002 */
/* http://www.nzmuslim.net syed@nzmuslim.net or syedrasel@hotmail.com */
/* Please do not sale it. KEEP IT FREE. DO NOT REMOVE MY INFORMATION. */
/************************************************************************/
/* Ported to phpnuke 6.x by Tayeb tayeb.habib@myiwc.com 13 August, 2003*/
/* Br Syed's version 1.0 plus worked only for phpnuke 5.x */
/* Search code for keywords completely rewritten */
/************************************************************************/
if (!eregi("modules.php", $PHP_SELF)) {
die ("You can't access this file directly...");
}
$index = 1;
global $user, $cookie, $prefix, $dbi, $user_prefix;
$module_name = basename(dirname(__FILE__));
cookiedecode($user);
$ip = getenv("REMOTE_ADDR");
$username = $cookie[1];
if (!isset($username)) {
$username = "$ip";
$guest = 1;
}
echo "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=windows-1256\">";
// This is not the right place to put...but anway.. it's working.. if u know where how to do encoding pls suggest me
/********** devloper information*************/
function developer() {
OPenTable();
echo "<p align=\"center\">
Quran Module version 1,2002<br>
Developed by <a href=\"syedrasel@hotmail.com\">Syed Mohammad Rasel</a><br>
Website: <a href=\"http://www.nzmuslim.net\">http://www.nzmuslim.net</a><br>
Audio from <a href=\"http://www.islamway.com\">www.islamway.com</a><br><br>
Ported to phpnuke 6.x by <a href=\"tayeb.habib@myiwc.com\">Tayeb Habib</a>";
CloseTable();
}
/************If you are a true muslim,please do not remove this copyright information.*****************/
/************************************************************************/
function index() {
global $prefix, $dbi, $username,$surano;
include("header.php");
searchform();
echo "<br>";
$result = mysql_query ("select sura,surano,ayatno,ayat from quran where ayatno=1 order by surano ");
OpenTable();
echo "<tr bgcolor=\"#D2F3CF\">";
echo "<td>No.</td><td>Name</td><td>Ayaats</td><td>listen(Real Audio)</td><td>Download(Mp3)</td></tr>";
while (list ($sura,$surano,$ayat,$ayatno) = mysql_fetch_row ($result)) {
$listen="0$surano.ram";
$download="0$surano.mp3";
if ($surano>99) {
$listen="$surano.ram";
$download="$surano.mp3";
}
if ($surano<10) {
$listen="00$surano.ram";
$download="00$surano.mp3";
}
$result2 = mysql_query ("select count(ayatno) from quran where surano=$surano");
list ($ayatcount) = mysql_fetch_row ($result2);
mysql_free_result ($result2);
echo "<tr bgcolor=\"white\">";
echo "<td>$surano.</td><td><a href=\"modules.php?name=Quran&action=viewayat&surano=$surano\">$sura</a></td><td>$ayatcount</td><td><center><a href=\"http://quran.islamway.com/agmy/$listen\">$surano<a/></center></td><td><center><a href=\"http://quran.islamway.com/agmy/$download\">$surano<a/></center></td>";
echo "</tr>";
}
echo "</tr>";
CloseTable();
include("footer.php");
}
/********** new search *************/
function search($query) {
global $prefix, $s, $dbi, $admin, $bgcolor2;
//OpenTable();
include("header.php");
$var = addslashes($query);
OpenTable();
// Get the search variable from URL
// $trimmed = trim($var); //trim whitespace from the stored variable
// rows to return
$limit=10;
// check for an empty string and display a message.
if ($var == "")
{
echo "<b><a href=modules.php?name=Quran>Home</a>::</b><center><font class=\"option\">Please enter a search...</p>";
exit;
}
// check for a search parameter
if (!isset($var))
{
echo "<b><a href=modules.php?name=Quran>Home</a>::</b><center><font class=\"option\">We dont seem to have a search parameter!</p>";
exit;
}
// Build SQL Query
$query = "select ayat, ayatno, sura, surano from quran where ayat like \"%$var%\" OR sura like \"%$var%\""; // EDIT HERE and specify your table and field names for the SQL query
$numresults=mysql_query($query);
$numrows=mysql_num_rows($numresults);
// If we have no results, offer a google search as an alternative
if ($numrows == 0)
{
echo "<h4>Results</h4>";
echo "<p>Sorry, your search: "" . $var . "" returned zero results</p>";
// google
}
// next determine if s has been passed to script, if not use 0
if (empty($s)) {
$s=0;
}
// get results
$query .= " limit $s,$limit";
$result = mysql_query($query) or die("Couldn't execute query");
// display what the person searched for
echo "<p><b><a href=modules.php?name=Quran>Home</a>::</b><center><font class=\"content\">Search Results for : <b><i>$var</i></b></center></p>";
// echo "<p>You searched for: "" . $var . ""</p>";
// $the_query = stripslashes($query);
// $the_query = str_replace("\'", "'", $the_query);
// begin to show results set
CloseTable();
echo "<br>";
$count = 1 + $s ;
// now you can display the results returned
while ($row= mysql_fetch_array($result)) {
$surano = $row["surano"];
$ayat = $row["ayat"];
$ayat = eregi_replace($var, "<span style=\"background-color: #FFFF00\"><b>$var</b></span>", $ayat);
$sura = $row["sura"];
echo "$surano.$ayat<br><br>" ;
$sura = ereg_replace($var, "<span style=\"background-color: #FFFF00\"><b>$var</b></span>", $sura);
$count++ ;
}
$currPage = (($s/$limit) + 1);
//break before paging
echo "<br />";
OpenTable();
// next we need to do the links to other results
if ($s>=1) { // bypass PREV link if s is 0
$prevs=($s-$limit);
print "<center><a href=\"$PHP_SELF?name=Quran&file=index&action=search&s=$prevs&query=$var\"><<
Prev 10</a>  ";
}
// calculate number of pages needing links
$pages=intval($numrows/$limit);
// $pages now contains int of pages needed unless there is a remainder from division
if ($numrows%$limit) {
// has remainder so add one page
$pages++;
}
// check to see if last page
if (!((($s+$limit)/$limit)==$pages) && $pages!=1) {
// not last page so give NEXT link
$news=$s+$limit;
echo " <a href=\"$PHP_SELF?name=Quran&file=index&action=search&s=$news&query=$var\">Next 10 >></a></center>";
}
$a = $s + ($limit) ;
if ($a > $numrows) { $a = $numrows ; }
$b = $s + 1 ;
echo "<p>Showing results $b to $a of $numrows</p>";
// echo "</td></tr></table>";
CloseTable();
developer();
include("footer.php");
}
/******************************/
function choose() {
echo"<b>Browse Sura </b> <select name=\"surano\" onChange=\"top.location.href=this.options[this.selectedIndex].value\"> ";
echo "<option value=>Select Sura</option>";
$dropdown=mysql_query("select sura, surano from quran where ayatno=1 ORDER BY surano ASC");
while (list($sura, $surano) = mysql_fetch_row($dropdown))
{
echo "<option value=modules.php?name=Quran&action=viewayat&surano=$surano>$surano.$sura</option>";
}
echo "</select></p>";
}
/**************** search form finished*****************/
function searchform() {
#global $query,$surano,$ayatno;
Opentable();
echo "<center><form action=\"modules.php?name=Quran&file=index&action=search\" method=\"post\">\n"
."Search in the Quran <input name=\"query\" type=text>\n"
."<input type=submit value=\"Search\">\n"
."<input type=hidden value=search name=search></form></center>";
echo"<center>";
echo"<hr>";
echo "<center><form action=\"modules.php?mop=modload&name=Quran&file=index&action=display\" method=\"post\">\n"
."Sura number <input name=\"surano\" type=\"text\" maxLength=\"3\" size=\"3\">\n"
."Ayat number <input name=\"ayatno\" type=\"text\" maxLength=\"4\" size=\"3\">\n"
."<input type=submit value=\"Display\">\n"
."<input type=hidden value=display name=action></form></center>";
echo"<center>";
choose();
CloseTable();
echo"<br>";
}
/**************** search form finished*****************/
/************ displaying ayat and sura******************/
function display($surano,$ayatno) {
include("header.php");
global $prefix, $dbi,$surano,$ayatno;
OpenTable();
$result=sql_query("select sura,surano, ayat from quran where surano=$surano AND ayatno= $ayatno",$dbi);
$resultar = sql_query("select ayat_ar from quran_ar Where surano_ar=$surano AND ayatno_ar= $ayatno ", $dbi);
if($result!="") {
while(list($sura,$surano,$ayat)=mysql_fetch_row($result)) {
list($ayat_ar,$ayatno_ar,$id) = sql_fetch_row($resultar, $dbi) ;
searchform();
echo" <strong>Displaying:</strong> $sura($surano) Ayat No: <b>$ayatno</b><br><br>";
echo"<font style=\"font-family:Simplified Arabic;font-size:18px\" color=black>$ayat_ar</font><br> $surano.$ayat";
}
}
else {
echo "<center><font class=\"option\"><b>You didn't mention Sura or Ayat Number to Find </b></font><br><br>";
echo "<A HREF=\"javascript:history.go(-1)\">Go Back and type keywords to search</A></center>";
}
CloseTable();
developer();
include("footer.php");
}
function makepagelink($link, $page, $pages) {
$page_link = "<b>[";
if($page!=1) $page_link .= " <a href=\"$link&page=1\">«</a> <a href=\"$link&page=".($page-1)."\">First</a>";
if($page>=6) $page_link .= " <a href=\"$link&page=".($page-5)."\">...</a>";
if($page+4>=$pages) $pagex=$pages;
else $pagex=$page+4;
for($i=$page-4 ; $i<=$pagex ; $i++) {
if($i<=0) $i=1;
if($i==$page) $page_link .= " $i";
else $page_link .= " <a href=\"$link&page=$i\">$i</a>";
}
if(($pages-$page)>=5) $page_link .= " <a href=\"$link&page=".($page+5)."\">...</a>";
if($page!=$pages) $page_link .= " <a href=\"$link&page=".($page+1)."\">›</a> <a href=\"$link&page=".$pages."\">Last</a>";
$page_link .= " ]</b>";
return $page_link;
}
/************ displaying ayat and sura finished******************/
function viewayat($surano) {
global $dbi,$module_name;
include("header.php");
$result2 = mysql_query ("select id from quran where surano=$surano ",$dbi);
$num_record=mysql_num_rows($result2);
if(isset($_GET['page']))
$page=intval($_GET['page']);
else $page=1;
$currentpage=$page;
$perpage =10;
$start=($page-1) * $perpage;
$pages=ceil($num_record/$perpage);
$starting_no = $start + 1;
if ($num_record - $start<$perpage) {
$end_count = $num_record;
} elseif ($num_record - $start >= $perpage) {
$end_count = $start + $perpage;
}
if($pages>1)
$page_link = makepagelink("modules.php?name=Quran&action=viewayat&surano=$surano", $page, $pages);
else
$page_link = "";
echo "<center><form action=\"modules.php?name=Quran&file=index&action=search\" method=\"post\">\n"
."Search in the Quran <input name=\"query\" type=text>\n"
."<input type=submit value=\"Search\">\n"
."<input type=hidden value=search name=search></form></center>";
echo"<center>";
//searchform();
$resultx=mysql_query("select id,sura,surano,ayatno,ayat from quran where surano=$surano limit $start,$perpage ", $dbi);
#$fullcountresult=sql_query("select surano from quran where surano=$surano ORDER BY `surano` ASC", $dbi);
#$totalayat = sql_num_rows($fullcountresult, $dbi);
//opentable();
list($id,$sura,$surano, $ayatno, $ayat)=sql_fetch_row($resultx, $dbi);
echo"<table cellSpacing=0 cellPadding=0 width=100% border=0>
<tr>
<td colSpan=3><hr color=#ff9933 noShade SIZE=1></td>
</tr>
<tr>
<td vAlign=top align=left>
<p align=left><a href=\"modules.php?name=$module_name\">Index</a> |$sura |$starting_no-$end_count of $num_record ayats » Page $currentpage/$pages</td>
<td width=20> </td>
<td vAlign=top align=right>
<p align=right>";
echo"$page_link";
echo"</td>
</tr>
<tr>
<td colSpan=3><hr color=#ff9933 noShade SIZE=1></td>
</tr>
</table>";
openTable();
echo "<center><form action=\"modules.php?mop=modload&name=Quran&file=index&action=display\" method=\"post\">\n"
."Sura number <input name=\"surano\" type=\"text\" maxLength=\"3\" size=\"3\">\n"
."Ayat number <input name=\"ayatno\" type=\"text\" maxLength=\"4\" size=\"3\">\n"
."<input type=submit value=\"Display\">\n"
."<input type=hidden value=display name=action></form></center>";
echo"<center>";
choose();
closeTable();
if ($ayatno<2) {
echo"<h5><center><u>In the name of Allah ,Most Gracious, Most Merciful</u></center></h5>";
}
echo "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"10\" border=\"0\"><tr><td><font class=\"content\">";
$result=mysql_query("select id,sura,surano,ayatno,ayat from quran where surano=$surano ORDER BY ayatno ASC limit $start,$perpage ", $dbi);
$resultar = sql_query("select ayat_ar,surano_ar,ayatno_ar from quran_ar Where surano_ar=$surano ORDER BY ayatno_ar ASC limit $start,$perpage ", $dbi);
while(list($id,$sura,$surano, $ayatno, $ayat)=sql_fetch_row($result, $dbi)) {
list($ayat_ar,$ayatno_ar,$id) = sql_fetch_row($resultar, $dbi) ;
$sura= stripslashes($sura);
$ayat = stripslashes($ayat);
$ayat_ar=stripslashes($ayat_ar);
# $ayatno_ar=$ayatno;
#echo"sura: $sura Ayats: $ayatno<br>";
echo "<font style=\"font-family:Simplified Arabic;font-size:18px\" color=black>$ayat_ar<a/></font><br>$surano.$ayat<br><hr class=\"line\" width=\"98%\" noShade SIZE=\"1\"><br>";
}
echo "</td></tr></table>";
//closetable();
developer();
include("footer.php");
}
/************************************************************************/
switch($action) {
case "viewayat":
viewayat($surano);
break;
case "search";
search($query);
break;
case "display";
display($surano,$ayatno);
break;
case "choose":
choose();
break;
default:
index();
break;
}
?>
|