Need help to convert script to php5

liunx

Guest
I have a few plugins to a forum mod that was working well when i was php4 but my server as been converted to php5

Can someone please help, this is one i need help with
When i know how to convert this i should be able to do the other



<?

#########################################
function feature_buy($this,$info2){
#########################################
global $ps;


$question[0]="Enter new title";
$answer[0]="<input type='text' name='new_title'><input type='submit' name='submit' value='Request Change'><input type='hidden' name='feature_action' value='request_change'><input type='hidden' name='item_id' value='{$info2['id']}'><input type='hidden' name='feature_id' value='{$info2['feature']}'>";

$count=0;
$output='';

foreach($question as $ask){

$a=$answer[$count];
$q=$ask;
$output .= $this->ipsclass->compiled_templates['skin_perfect_store']->skin_feature_form_line($q,$a);

}


$ps['html']['main_out'] = $this->ipsclass->compiled_templates['skin_perfect_store']->skin_feature_form_header('Enter new title request');
$ps['html']['main_out'] .= $output;
$ps['html']['main_out'] .= $this->ipsclass->compiled_templates['skin_perfect_store']->skin_feature_form_footer();



}
#########################################
function feature_accept($this,$info2){
#########################################
global $ps;

$trans['feature_info']=explode('[%]',$info2['feature_info']);
$trans['feature_info'][2]=addslashes($trans['feature_info'][2]);
$this->ipsclass->DB->query( "
UPDATE {$ps['db_pre']}members set
`title`='{$trans['feature_info'][2]}'
WHERE id='{$info2['buyer']}'

" ) or print mysql_error();


$st='|Payment released|3|';
$log_line = "\n".time().$st.$info2['buyer'];


//give points to member
if($info2['auc_on']=='checked'){$com=$ps['com_auc'];}else{$com=$ps['com_reg'];}
$this->give_points($info2['seller'],$info2['cost'],'take_from_bank',$com);

//Update bought count
$this->ipsclass->DB->query( "
UPDATE {$ps['db_pre']}perfect_store_items set
`buy_count`=`buy_count` + 1
WHERE id='{$info2['item_id']}'

" ) or print mysql_error();

return $log_line;


}
#########################################
function feature_actions($this,$action){
#########################################
global $ps;


if($action=='request_change'){

if(isset($_GET['item_id'])){ $id=$_GET['item_id']; }elseif(isset($_POST['item_id'])){ $id=$_POST['item_id']; }else{$this->error_out('No item ID given','back');return;}
$id=floor($id);
$WHERE="WHERE i.id='$id' AND i.validated='checked'";



//get item info
$query="SELECT
i.*,
m.name as member_name,
m2.pm_seller
FROM {$ps['db_pre']}perfect_store_items i
LEFT JOIN {$ps['db_pre']}members m on(m.id=i.seller)
LEFT JOIN {$ps['db_pre']}perfect_store_members m2 on(i.seller=m2.member_id)
$WHERE";


$this->ipsclass->DB->query( $query ) or print mysql_error();
$rs =$this->ipsclass->DB->fetch_row();


$rs['pm_seller']=explode(',',$rs['pm_seller']);
//are we allowed to buy from this cat?



if( (!in_array($this->ipsclass->member['g_id'],$ps['cats'][$rs['cat']]['allowed_buy_groups']))&&(!$ps['admin']) ){
$this->error_out('You are not allowed to buy this item','back');return;
}


if($rs['remaining']=='0'){
$this->error_out('This item is sold out','back');return;
}
//do we have enough points
//get points
$query="SELECT {$ps['points_field']} as points FROM {$ps['points_table']} WHERE {$ps['points_id_field']}='{$this->ipsclass->member['id']}'";
$this->ipsclass->DB->query( $query ) or print mysql_error();
$res =$this->ipsclass->DB->fetch_row();


if($rs['cost'] > $res['points']){

$this->error_out('You dont have enough points','back');return;

}

//take points from member
$this->take_points($this->ipsclass->member['id'],$rs['cost'],'add_to_bank');

$log_line=addslashes(time().'|Requested item '.$rs['name'].'|1|'.$this->ipsclass->member['id']);
$new_title=$_POST['new_title'];
$feature_id=$_POST['feature_id'];

$feature_info=$feature_id.'[%]Request to change your title to: '.$new_title.'[%]'.$new_title;

if($ps['features_list'][$feature_id]['auto_accept']){

$info2['seller']=$rs['seller'];
$info2['item_id']=$id;
$info2['cost']=$rs['cost'];
$info2['auc_on']=$rs['auc_on'];
$info2['buyer']=$this->ipsclass->member['id'];

$info2['feature_info']=$feature_info;

$log_line=feature_accept($this,$info2);

}
$feature_info=addslashes($feature_info);


$this->ipsclass->DB->query( "
INSERT INTO {$ps['db_pre']}perfect_store_transactions set
`item_id`='$id',
`buyer`='{$this->ipsclass->member['id']}',
`seller`='{$rs['seller']}',
`log`='{$log_line}',
`feature_info`='{$feature_info}'
" ) or print mysql_error();

$this->update_transaction_counts();

//do we pm seller of this action?
if( (in_array('1',$rs['pm_seller']))&&(!$ps['features_list'][$feature_id]['bypass_pm']) ){

$info2['buyer_name']=$this->ipsclass->member['name'];
$info2['item_name']=$rs['name'];
$info2['item_id']=$rs['$id'];


$msg=$this->ipsclass->compiled_templates['skin_perfect_store_pms']->skin_pm_purchase($info2);

$this->send_pm($rs['seller'],$ps['store_name'].': Item purchased',$msg);


}



header("location:{$this->base_url}&action=your_purchases");
exit;


}



}



?>Are you getting any specific errors when you run it? (If so, please copy-and-paste them here to help us debug.)

Normally PHP4 scripts should be forward-compatible with PHP5, except for a very few exceptions. More often in these situations I find it's not the change to PHP5 causing the problem, but a change in the PHP configuration (turning register_globals off when it was on before, for example).This is the error i get when it is run

Fatal error: Using $this when not in object context in line19The use of the "$this->" construct would indicate that these functions are intended to be class methods, but here they are not contained within a class definition. It would therefore appear that something is missing from the code (and I'm 99.9% certain you'd get the same sort of error in PHP4).This is a item change your title that works within a store made for ipb boards

This was working on php4 a few weeks ago, i only got the error when my host changed to php 5
 
Back
Top