Dynadot Aftermarket: discover domain gems worth investing in. Visit our aftermarket.

HELP - Fopen VS curl

SpaceshipSpaceship
Namecheap AuctionsNamecheap Auctions
Namecheap AuctionsNamecheap Auctions
Watch

ucheafrica

New Member
Impact
0
Please I need help to rewrite my code to use curl instead.My host disbled URL file access in the server cofiguration.
Reason:disabled fopen because of hackers.

Here is the code:

PHP:
<?

include ("output_fns.php");

function db_connect()
{
   mysql_pconnect("localhost","databasename","password");
   mysql_select_db("database");
}

function db_result_to_array($query)
{
   $result=mysql_query($query);
   $res_array = array();
   for ($count=0; $row = @mysql_fetch_array($result); $count++)
     $res_array[$count] = $row;
   return $res_array;
}

function parse_template($template)
{
global $menutype;
if ($menutype=="account")
 $menu="<p><font color=\"#FF0000\"><b>Account Management</b></font></p>
<a href=index.php >Summary</a><br>
<a href=editinfo.php >Edit info</a><br>
<a href=subscriptionlist.php> Your Subscriptions</a><br>
<a href=deposit.php >Deposit money</a><br>
<a href=transfer.php >Transfer money</a><br>
<a href=withdraw.php >Withdraw money</a><br>
<a href=request.php >Request money</a><br>
<a href=sell_manual.php >Sell Goods</a><br>
<a href=referrals.php>Referral Status</a><br>
<a href=logout.php >Logout</a><br>";
else if ($menutype=="sell")
 $menu="<p><font size=\"2\" color=\"#FF0000\"><b>Sell your goods and services</b></font></p>
<a href=sell.php?sub=donate >Donations</a><br>
<a href=sell.php?sub=single>Single items</a><br>
<a href=sell.php?sub=subscr >Subscriptions</a><br>";
for ($i=0; $i<count($template); $i++) 
 {
  $template[$i]=str_replace("<#menu#>", "$menu", $template[$i]);
 }
return $template;
}

function usheader()
{
$header=db_result_to_array("select usheader from admin");
if (@$header[0][0]) 
 {
  $header=file($header[0][0]);
  $header=parse_template($header);
  for ($i=0; $i<count($header); $i++) 
   echo $header[$i];
 }
 //echo "<pre>";
 //print_r ( $_SESSION );
 //echo "</pre>";
}

function usfooter()
{
$footer=db_result_to_array("select usfooter from admin");
if (@$footer[0][0]) 
 {
  $footer=readfile($footer[0][0]);
  for ($i=0; $i<count($footer); $i++) 
   echo $footer[$i];
 }
}

function mainheader()
{
$header=db_result_to_array("select mainheader from admin");
if (@$header[0][0]) 
 {
  $header=file($header[0][0]);
  for ($i=0; $i<count($header); $i++) 
   echo $header[$i];
 }
 //echo "<pre>";
 //print_r ( $_SESSION );
 //echo "</pre>";
}

function mainfooter()
{
//checking if login via username or e-mail
$usrnamelogin=db_result_to_array("select usrnamelogin from admin");
$usrnamelogin=$usrnamelogin[0][0];
if ($usrnamelogin==1)
 $usernametext="User name";
else
 $usernametext="E-mail";
$footer=db_result_to_array("select mainfooter from admin");
if (@$footer[0][0]) 
 {
  $footer=file($footer[0][0]);
  for ($i=0; $i<count($footer); $i++) 
  {
   $footer[$i]=str_replace("<#usernametext#>", $usernametext, $footer[$i]);
   echo $footer[$i];
  }
 }
}

function withdraw_calc()
{
global $table;
$total=0;
$user=db_result_to_array("select login from $table where user_id='".$_SESSION['usid']."'");
$withdraws=db_result_to_array("select amt from transactions where fromwho='".$user[0][0]."' and fromwhotype='".$_SESSION['type']."' and descr = 'Withdraw - pending'");
for ($i=0; $i<count($withdraws); $i++)
 $total+=$withdraws[$i][0];
return $total;
}

?>
 
Last edited by a moderator:
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Oh gosh!

Please use [php ][/ php] tags and remove excess line breaks! I'm not going to even look at code unless its a tiny bit neater!

:tu:

Dan

p.s. I could find no fopen in there anyway using Ctrl + F.
 
Last edited:
0
Close
Moved to Programming

You'll get the help you need here, Goodluck :tu:
 
0
Close
Edited original post to correct formatting ;) As far as fopen - I, like Daniel, can not see where it's being used?
 
0
Close
CatchedCatched

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Search: choose where to search from the All tab
Open the search at the top of any page. On the All tab, the list next to the search box lets you choose where to search: everything, all...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back