1
wizanda
HELP! Fixing code, How to turn register globals off?
  • 2005/8/12 7:02

  • wizanda

  • Home away from home

  • Posts: 1585

  • Since: 2004/3/21


Can someone who knows what they are doing, edited this code so register globals are off in the module? plz

function index() {
    global 
$xoopsConfig$xoopsDB$xoopsUser$xoopsTheme$xoopsLogger$xoopsModule$xoopsTpl$surano;
    include 
XOOPS_ROOT_PATH.'/header.php';
    
$myts =& MyTextSanitizer::getInstance();
    
searchform();
    echo 
"<br>";

     
$result mysql_query ("select sura, surano, ayatno, ayat from quran where ayatno=1 order by surano");
    echo 
"<tr bgcolor="#D2F3CF">";
     
echo "<td align="center" width="25">"._MD_NO."</td><td align="left" width="175">"._MD_CHAPTERNAME."</td><td align="center" width="100">"._MD_VERSES."</td><td align="center" width="175">"._MD_LISTENDOWNLOAD."</td></tr>";
     while (list (
$sura,$surano,$ayat,$ayatno) = mysql_fetch_row ($result)) {
   
     
$result2 mysql_query ("select count(ayatno) from quran where surano=$surano");
     list (
$ayatcount) = mysql_fetch_row ($result2);
     
mysql_free_result ($result2);
     echo 
"<tr bgcolor="#ffffff">";
     
echo "<td align="center" width="25">$surano.</td><td align="left" width="175"><a href="index.php?op=viewayat&amp;surano=$surano">$sura</a></td><td align="center" width="100">$ayatcount</td><td align="center" width="175"><a href="http://quran.al-islam.com/Recite/CRecite_g2.asp?s=$surano&f=$ayat&Reciter=1">$surano<a/></td>";
     
echo "</tr>";
 }
     echo 
"<tr valign="top"><td width="100%" colspan="4" align="center">";
    
    
developer(); 
 
    echo 
"</td></tr></table>";
    include 
'../../footer.php';
}

// Main Index Finished Here

// Search function


function search($query$min$show) {
    global 
$xoopsConfig$xoopsDB$xoopsUser$xoopsTheme$xoopsLogger$xoopsModule$xoopsTpl;

    if (!isset(
$min)) $min=0;
    if (!isset(
$max)) $max=$min+$perpage;

    
$perpage=10;

    
$searchresults=10;

    if (
$show!="") {
    
$searchresults=$show;
    } else {
    
$show=$searchresults;
    }
    
$query addslashes($query);
    
$result mysql_query("select ayat, sura, surano from quran where ayat LIKE '%$query%' OR sura LIKE '%$query%' limit  $min,$perpage");
    
$fullcountresult mysql_query("select id, sura, surano from quran where ayat LIKE '%$query%' ");

    
$totalselecteddownloads mysql_num_rows($fullcountresult);
    
$nrows  mysql_num_rows($fullcountresult);
    
$x=0;
    
$the_query stripslashes($query);
    
$the_query str_replace("'""'"$the_query);
    include 
XOOPS_ROOT_PATH.'/header.php';
    
$myts =& MyTextSanitizer::getInstance();
    echo 
"<br>";

    if (
$query != "") {

        if (
$nrows>0) {
    
    
searchform();
    echo 
"<tr valign="top"><td width="100%" colspan="4" align="center"><font class="option">"._MD_SEARCHRESULTS." :&nbsp;<b><i>$the_query</i></b>&nbsp; "._MD_FOUND." :&nbsp;$nrows&nbsp;"._MD_VERSES."&nbsp;</font><br><br>";
    
    while(list(
$ayat,$ayatno,$sura,$surano) = mysql_fetch_row($result))
                  {
    
$ayat stripslashes($ayat);
    
$sura stripslashes($sura);
        
$ayat eregi_replace($query"<span style="background-color#FFFF00"><b>$query</b></span>", $ayat);

        
echo "<p align="left">$sura.$ayat";

        echo 
"<br>";
        
$sura ereg_replace($query"<span style="background-color#FFFF00"><b>$query</b></span>", $sura);
        
echo "<br>";
         
$x++;
                }
       echo 
"</font>";

        }

       else {
        
searchform();
        echo 
"<tr><td width="100%" colspan="4" align="center"><br><br><font class="option"><b>"._MD_NOMATCHESFOUND."</b></font><br><br>"._MD_SEARCHAGAIN."<br></td></tr>";
              
        }

      
/* Calculates how many pages exist.  Which page one should be on, etc... */
        
$quranpagesint = ($totalselecteddownloads $searchresults);
        
$downloadpageremainder = ($totalselecteddownloads $searchresults);
        if (
$downloadpageremainder != 0) {
            
$downloadpages ceil($quranpagesint);
            if (
$totalselecteddownloads $searchresults) {
                
$downloadpageremainder 0;
        }
        } else {
            
$downloadpages $quranpagesint;
        }
        
/* Page Numbering */
        
if ($downloadpages!=&& $downloadpages!=0) {
        echo 
"<br><br>"
            
.""._MD_SELECTPAGES.": ";
        
$prev=$min-$searchresults;
        if (
$prev>=0) {
                echo 
"&nbsp;&nbsp;<b>[ <a href="index.php?op=search&amp;query=$the_query&amp;min=$prev&amp;show=$show">"
                
." << "._MD_PREVIOUS."</a> ]</b> ";
              }
        
$counter 1;
            
$currentpage = ($max $searchresults);
            while (
$counter<=$downloadpages ) {
                
$cpage $counter;
                
$mintemp = ($perpage $counter) - $searchresults;
                if (
$counter == $currentpage) {
            echo 
"<b>$counter</b> ";
            } else {
            echo 
"<a href="index.php?op=search&amp;query=$the_query&amp;min=$mintemp&amp;show=$show">$counter</a> ";
            }
                
$counter++;
            }
            
$next=$min+$searchresults;
            if (
$x>=$perpage) {
                echo 
"&nbsp;&nbsp;<b>[ <a href="index.php?op=search&amp;query=$the_query&amp;min=$next&amp;show=$show">"
                
." "._MD_NEXT." >></a> ]</b></td></tr>";
            }
    }
  }

else {
    
searchform();
    echo 
"<tr><td colspan="4" width="100%" align="center"><font class="option"><b>"._MD_FORGOTKEYWORDS."</b></font><br><br></td></tr>";
       
        }
    echo 
"<tr valign="top"><td width="100%" colspan="4" align="center">";
    
developer();
    echo 
"</td></tr></table>";
    include 
'../../footer.php';
    
}

/********/

function choose() {

echo 
"<tr valign="top"><td width="100%" colspan="4" align="center"><b>"._MD_BROWSECHAPTER." </b>&nbsp;&nbsp;<select name="surano" onChange="top.location.href=this.options[this.selectedIndex].value"> ";

echo 
"<option value=>"._MD_SELECTCHAPTER."</option>";

    
$dropdown mysql_query("select sura, surano from quran where ayatno=1 ORDER BY surano");
    while (list(
$sura,$surano) = mysql_fetch_row($dropdown))
        {
        echo 
"<option value=index.php?op=viewayat&amp;surano=$surano>$surano.$sura</option>";
        }

echo 
"</select></td></tr>";

}

/********/

function searchform() {

echo 
"<table width="100%" cellspacing="0" cellpadding="10" border="0">";
echo 
"<tr valign="top"><td width="100%" colspan="4" align="center">n"
    
."<p><img src="images/quran.gif" border="0" alt=""._MD_NOBLEQURAN.""><br><h2><font face="palatinogeorgiaverdanaarial">"._MD_NOBLEQURAN."</font></h2></p></td></tr>";


echo 
"<tr valign="top"><td width="100%" colspan="4" align="center">n"
    
."<p><form action="index.php?op=search" method="post">n"
    
.""._MD_SEARCHQURAN." <input name="query" type=text>n"
    
."<input type=submit value=""._MD_SEARCH."">n"
    
."<input type=hidden value=search name=search></form></p></td></tr>";

echo 
"<tr valign="top"><td width="100%" colspan="4" align="center">n"
    
."<p><form action="index.php?op=display" method="post">n"
    
.""._MD_CHAPTERNO."&nbsp;<input name="surano" type="text" maxLength="3" size="3">n"
    
."&nbsp;"._MD_VERSENO."&nbsp;<input name="ayatno" type="text" maxLength="4" size="3">n"
    
."<input type=submit value=""._MD_DISPLAY."">n"
    
."<input type=hidden value=display name=action></form></p></td></tr>";

echo 
"<tr valign="top"><td width="100%" colspan="4" align="center"><a href="".XOOPS_URL."/">"._MD_HOME."</a>&nbsp;|&nbsp;<a href="index.php">"._MD_QURANINDEX."</a><br></td></tr>";

choose();

echo
"<br>";
}

// Search function finished

// Displaying ayat and surah

function display($surano,$ayatno) {

global 
$xoopsConfig$xoopsDB$xoopsUser$xoopsTheme$xoopsLogger$xoopsModule$xoopsTpl$surano$ayatno;
include 
XOOPS_ROOT_PATH.'/header.php';
$myts =& MyTextSanitizer::getInstance();
$result mysql_query("select sura, surano, ayat from quran where surano=$surano AND ayatno=$ayatno");
$resultar mysql_query("select ayat_ar from quran_ar where surano_ar=$surano AND ayatno_ar=$ayatno");

if(
$result!="") {

while(list(
$sura,$surano,$ayat) = mysql_fetch_row($result)) {

list(
$ayat_ar,$ayatno_ar,$id) = mysql_fetch_row($resultar) ;

searchform();

echo 
"<tr valign="top"><td width="100%" align="center"><strong>"._MD_DISPLAYING.":</strong> $sura ($surano) &nbsp;"._MD_VERSENO.":&nbsp;<b>$ayatno</b><br><br>";

echo 
"<p align="right"><font style="font-family:Simplified Arabic;font-size:20px" color=black>$ayat_ar</font>&nbsp;&nbsp;<a href="http://quran.al-islam.com/Recite/CRecite_g2.asp?s=$surano&f=$ayatno&Reciter=1"><img src="images/audio.gif" border="0" alt=""._MD_LISTENTOVERSE.""></a></p><p> $surano.$ayat</p></td></tr>";
     
}

}

else {
    echo 
"<tr valign="top"><td width="100%" align="center"><font class="option"><b>"._MD_MENTIONNOCHAPTERORVERSE." </b></font><br><br>";

        echo 
"<A HREF="javascript:history.go(-1)">"._MD_TRYAGAIN."</A></td></tr>";

        }
    echo 
"<tr valign="top"><td width="100%" align="center">";
    
developer();
    echo 
"</td></tr></table>";
    include 
'../../footer.php';
 }

/********/

function viewayat($surano,$min,$show) {

   
$perpage=10;

    global 
$xoopsConfig$xoopsDB$xoopsUser$xoopsTheme$xoopsLogger$xoopsModule$xoopsTpl;
    include 
XOOPS_ROOT_PATH.'/header.php';
    
$myts =& MyTextSanitizer::getInstance();
    if (!isset(
$min)) $min=0;
    if (!isset(
$max)) $max=$min+$perpage;

    if (
$show!="") {
    
$perpage $show;
    } else {
    
$show=$perpage;
    }

    
searchform();

    
$resultx mysql_query("select id, sura, surano, ayatno, ayat from quran where surano=$surano limit $min,$perpage");
    
$fullcountresult mysql_query("select surano from quran where surano=$surano ORDER BY surano");
    
$totalayat mysql_num_rows($fullcountresult);
    echo 
"<table width="100%" cellspacing="0" cellpadding="10" border="0"><tr><td><font class="content">";
    
$x=0;

    list(
$id,$sura,$surano,$ayatno,$ayat) = mysql_fetch_row($resultx);

    
$result2 mysql_query ("select count(ayatno) from quran where surano=$surano ");
    list (
$ayatcount) = mysql_fetch_row ($result2);
    if (
$ayatcount<10) {

    
$showstart=1;

    
$showend=$ayatcount;

    }
    else {

    
$showstart=$min+1;
    
$showend=$show+$min;

    }
  
$x++;

echo 
"<center><p><b>"._MD_CHAPTERNAME.":</b>&nbsp;$sura&nbsp;<b>"._MD_TOTALVERSES."</b>:&nbsp;$totalayat&nbsp;<b>n"
    
.""._MD_DISPLAYING.":</b>&nbsp;$showstart-$showend&nbsp;<br>";

   if (
$ayatno<2) {

   echo
"<br><b>"._MD_BISMILLAH."</b></center>";

   }

// Displaying Navbar at the top start

/* Calculates how many pages exist. Which page one should be on, etc... */
    
$audiopagesint = ($totalayat $perpage);
    
#global $surano; // I dont know why it does not work without this.

    
$audiopageremainder = ($totalayat $perpage);
    if (
$audiopageremainder != 0) {
        
$audiopages ceil($audiopagesint);
        if (
$totalayat $perpage) {
            
$audiopageremainder 0;
        }
    } else {
        
$audiopages $audiopagesint;
    }
    
/* Page Numbering */
    
if ($audiopages!=&& $audiopages!=0) {
        echo 
"<br><center>";
          echo 
"Select pages: ";
         
$prev=$min-$perpage;
         if (
$prev>=0) {
           
#echo "&nbsp;&nbsp;<b>[ <a href="index.php?op=viewayat&amp;surano=$surano&amp;min=$prev&amp;show=$show">";
           #echo " <<Previous</a> ]</b> ";
      
}
        
$counter 1;
     
$currentpage = ($max $perpage);
           while (
$counter<=$audiopages ) {
              
$cpage $counter;
              
$mintemp = ($perpage $counter) - $perpage;
              if (
$counter == $currentpage) {

        echo 
"<b>$counter</b>&nbsp";

        } else {

        echo 
"<a href="index.php?op=viewayat&amp;surano=$surano&amp;min=$mintemp&amp;show=$show">$counter</a> ";

        }
               
$counter++;

           }
         
$next=$min+$perpage;

         if (
$x>=$perpage) {
            echo 
"&nbsp;&nbsp;<b>[ <a href="index.php?op=viewayat&amp;surano=$surano&amp;min=$next&amp;show=$show">";
            
#echo ""._MD_Next." >></a> ]</b></center> ";
         
}
    }
    echo 
"</td></tr></table>";


// Displaying Navbar at the top finished

   
$result mysql_query("select id, sura, surano, ayatno, ayat from quran where surano=$surano ORDER BY ayatno ASC limit  $min,$perpage");

   
$resultar mysql_query("select ayat_ar, surano_ar, ayatno_ar from quran_ar Where surano_ar=$surano ORDER BY ayatno_ar ASC limit $min,$perpage");

   while(list(
$id,$sura,$surano,$ayatno,$ayat)= mysql_fetch_row($result)) {

   list(
$ayat_ar,$ayatno_ar,$id) = mysql_fetch_row($resultar) ;

    
$sura=stripslashes($sura);
    
$ayat=stripslashes($ayat);
    
$ayat_ar=stripslashes($ayat_ar);
    
//  $ayatno_ar=$ayatno;
    //  echo"sura:&nbsp;$sura &nbsp;Ayats:&nbsp;$ayatno<br>";
    
echo "<p align="right"><font style="font-family:Simplified Arabic;font-size:20px" color=black>$ayat_ar<a/></font>&nbsp;&nbsp;<a href="http://quran.al-islam.com/Recite/CRecite_g2.asp?s=$surano&f=$id&Reciter=1"><img src="images/audio.gif" border="0" alt=""._MD_LISTENTOVERSE.""></a></p><p align="left">$surano.$ayat<br><hr width="98%" noShade SIZE="1"></p>";

    
}

// added
   
    
developer();
    include 
'../../footer.php';
    
}

$op = isset($HTTP_GET_VARS['op']) ? trim($HTTP_GET_VARS['op']) : '';

// Displaying ayat and surah finished here

switch($op) {

    case 
"viewayat":
    
viewayat($surano,$min,$show);
    break;

    case 
"search";
    
search($query,$min,$show);
    break;

    case 
"display";
    
display($surano,$ayatno);
    break;

    case 
"choose":
    
choose();
    break;

    default:
    
index();
    break;

}

I need this for my website, yet since moving the new server has register globals off.

I have written to the original author twice, yet no reply.

So can someone on here, please edit this for me!!

Please!!

Login

Donat-O-Meter

Stats
Goal: $15.00
Due Date: Sep 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $15.00
Make donations with PayPal!