Jump to content

clueless...


redrocco

Recommended Posts

I know absolutely nothing about scripting :/ I'm hoping someone here has the time and inclination to help me out here. The script accesses a remote page and reformats the data and calculates averages. It used to work. Is there a simple work-around to deal with allow_url_fopen being disabled?

 

heres the code :

 

<html>

<head>
<meta http-equiv="Content-Language" content="es-mx">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Top 20 Guilds</title>
</head>

<body bgcolor="#000000" text="#FFFFFF" style="font-family: Verdana; font-size: 10pt; color:#FFFFFF">

<P><CENTER><FONT SIZE="+1">Brought to you by </FONT><FONT COLOR="#ff0000" SIZE="+1">RED</FONT><FONT
SIZE="+1">/</FONT><FONT COLOR="#008080" SIZE="+1">NSZ</FONT></CENTER>



<div align="center">
<table border="1" width="640" cellspacing="0" cellpadding="0" bordercolor="#666666">
	<tr>
		<td width="167" bgcolor="#800000" align="center"><b><font size="2">
		Guild Name</font></b></td>

		<td width="41"  bgcolor="#800000" align="center"><b><font size="2">
		Tag</font></b></td>

		<td width="77"  bgcolor="#800000" align="center">
		<a href="guilds.php?4"><span style="text-decoration: none"><b><font size="2" color="#FFFFFF">
		Total members</font></b></td>

		<td width="77"  bgcolor="#800000" align="center">
		<a href="guilds.php?2"><span style="text-decoration: none"><b><font size="2" color="#FFFFFF">
		Total levels</font></b></span></a></td>

		<td width="65"  bgcolor="#800000" align="center">
		<a href="guilds.php?3"><span style="text-decoration: none"><b><font size="2" color="#FFFFFF">
		Average Level</font></b></span></a></td>

		<td width="61"  bgcolor="#800000" align="center">
		<a href="guilds.php?2"><span style="text-decoration: none"><b><font size="2" color="#FFFFFF">
		Top 100 Pos</font></b></span></a></td>

		<td width="61"  bgcolor="#800000" align="center">
		<a href="guilds.php?3"><span style="text-decoration: none"><b><font size="2" color="#FFFFFF">
		Average Pos</font></b></span></a></td>

		<td width="77"  bgcolor="#800000" align="center">
		<a href="guilds.php?1"><span style="text-decoration: none"><b><font size="2" color="#FFFFFF">
		Quality Index*</font></b></span></a></td>
	</tr>
<?

$page = file("http://game.endless-online.com/guilds.html");


$bandera = 0;
$j=0;
$gnum = 0;
for($i=0;$i<count($page);$i++) {

	//FINDING EACH <TR> AFTER THE WORD EXPERIENCE (table start)
	if ( trim($page[$i]) == "Experience" ) { $bandera = 1; }
	if ( ( $bandera == 1 ) AND ( trim($page[$i]) == "<tr>" )){

	//READIN CODE TO MAKE IT VARIABLES
	$name = str_replace ("</font>", "", trim($page[$i+6]) );
	$tag = str_replace ("</font>", "", trim($page[$i+8]) );
	$members = str_replace ("</font>", "", trim($page[$i+10]) );
	$exp = str_replace ("</font>", "", trim($page[$i+14]) );
	$gnum = $gnum + 1;
	$i = $i + 12;

	if ( $gnum == 100 ) { $bandera = 0; } //ONLY 100 guilds listed so no more <TR>s

	//Magic formula of the experience average
	$expaverage = (round($exp/$members , 2)) ;

	//gettin all info into an array

	$array[$j][1]= $expaverage + 1000.001;
	$array[$j][2]= $name;
	$array[$j][3]= $tag;
	$array[$j][4]= $members + 10000;
	$array[$j][5]= $exp;
	$array[$j][6]= $expaverage;
	$array[$j][7]= $gnum + 1000;

	$j = $j+1;

	}//end of if tr

}//end of for $i





// all file read, now sort first time to find Average pos and store it

rsort($array);

for($i=0;$i<count($array);$i++) {
$array[$i][8]= $i+1001;
}

//Now I want to get que quality index and make it another field

for($i=0;$i<count($array);$i++) {
$array[$i][9]= $array[$i][7] + $array[$i][8];
}

//NOW SORT IT DEPENDIN ON WHAT USER LIKES..

$sorting = $QUERY_STRING;


if ( $sorting == "" ) { $sorting = 1; }

echo "Results sorted by ";

if ( $sorting == 1 ){
echo "Quality Index";
for($i=0;$i<count($array);$i++) {
$array[$i][1]= $array[$i][9];
}
sort($array);
}

if ( $sorting == 2 ){
echo "Top 100 (Total levels)";
for($i=0;$i<count($array);$i++) {
$array[$i][1]= $array[$i][7];
}
sort($array);
}

if ( $sorting == 3 ){
echo "Average Position (Average Level)";
for($i=0;$i<count($array);$i++) {
$array[$i][1]= $array[$i][8];
}
sort($array);
}

if ( $sorting == 4 ){
echo "Number of Members";
for($i=0;$i<count($array);$i++) {
$array[$i][1]= $array[$i][4];
}
rsort($array);
}




//NOW THAT ARRAY IS SORTED AS USER WANTED, SHOW DATA


for($i=0;$i<count($array);$i++) {
?><tr><td width="167" align="center"><font  size="2"<?

$color = "#FFFFFF";
if (trim($array[$i][3]) == "RED") { $color = "#FF0000"; }
if (trim($array[$i][3]) == "NSZ") { $color = "#008080"; }


echo " color=$color>";
echo $array[$i][2] . "</font></td>\r\n<td align=center width=41><font size=2 color=$color>";
echo $array[$i][3] . "</font></td>\r\n<td align=center width=77><font size=2 color=$color>";
echo ($array[$i][4] - 10000) . "</font></td>\r\n<td width=77 align=center><font size=2 color=$color>";
echo $array[$i][5] . "</font></td>\r\n<td width=65 align=center><font size=2 color=$color>";
echo $array[$i][6] . "</font></td>\r\n<td width=61 align=center><font size=2 color=$color>";
echo ($array[$i][7] - 1000) . "</font></td>\r\n<td width=61 align=center><font size=2 color=$color>";
echo ($array[$i][8] - 1000) . "</font></td>\r\n<td width=77 align=center><font size=2 color=$color>";
echo ($array[$i][9] - 2000) . "</font></td></tr>";


}//END FOR

?>

</table>
<p><br>
*Quality position = Average position + Top 100 position</div>
<p align="center"><font  size="1" >Source data 
obtained automatically from www.endless-onlinnt></div></td></tr></table>

<div id="eXTReMe"><a href="http://extremetracking.com/open?login=rednsz">
<img src="http://t1.extreme-dm.com/i.gif" style="border: 0;"
height="38" width="41" id="EXim" alt="eXTReMe Tracker" /></a>
<script type="text/javascript"><!--
var EXlogin='rednsz' // Login
var EXvsrv='s10' // VServer
EXs=screen;EXw=EXs.width;navigator.appName!="Netscape"?
EXb=EXs.colorDepth:EXb=EXs.pixelDepth;
navigator.javaEnabled()==1?EXjv="y":EXjv="n";
EXd=document;EXw?"":EXw="na";EXb?"":EXb="na";
EXd.write("<img src=http://e1.extreme-dm.com",
"/"+EXvsrv+".g?login="+EXlogin+"&",
"jv="+EXjv+"&j=y&srw="+EXw+"&srb="+EXb+"&",
"l="+escape(EXd.referrer)+" height=1 width=1>");//-->
</script><noscript><div id="neXTReMe"><img height="1" width="1" alt=""
src="http://e1.extreme-dm.com/s10.g?login=rednsz&j=n&jv=n" />
</div></noscript></div>

</body>

</html>

Link to comment
Share on other sites

  • 4 weeks later...

Hello,

 

I think fsockopen() or CURL doesn't depend on this parameter.I had tested it.pls reproduce

 

1.switch of allow_url_fopen

2.run the below script with filename changes

 

<?php

if( ini_get( 'allow_url_fopen' )) {

echo 'url fopen is open';

} else {

echo "url fopen is off" ;

}

 

$fp = fsockopen("localhost", 80, $errno, $errstr, 30);

if (!$fp) {

    echo "$errstr ($errno)<br />\n";

} else {

    $out = "GET test.txt HTTP/1.1\r\n"; //change file name

    $out .= "Host: localhost \r\n";

    $out .= "Connection: Close\r\n\r\n";

echo $out;

    fwrite($fp, $out);

    while (!feof($fp)) {

        echo fgets($fp, 128);

    }

    fclose($fp);

}

 

?>

 

allow_url_fopen paramter affects functions like fopen(remote url),file(),file_get_content.

 

anywayz i would be googling more for this issue and as far as i know CURL is an external lib and never read that it depend on this parameter.

 

kindly let me know weather above script worked or not.

 

 

Regards

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.