<?
/***********************************************************************/
/*                                                                     */
/*  This file is created by deZender                                   */
/*                                                                     */
/*  deZender (Decoder for Zend Encoder/SafeGuard):                     */
/*    Version:      0.9.3.0                                            */
/*    Author:       qinvent.com                                        */
/*    Release on:   2005.11.12                                         */
/*                                                                     */
/***********************************************************************/

  
if ($frm['action'] == 'checkpayment')
  {
	$lid = sprintf ('%d', $frm['lid']);
	$email = $frm['email'];
	$amount = $frm['PAYMENT_AMOUNT'];
    $batch = $frm['PAYMENT_BATCH_NUM'];
    $account = $frm['PAYER_ACCOUNT'];
	
	$q = 'update hl_listings set status = 1 where id = ' . $lid;
      if (!($sth = mysql_query ($q)))
      {
        exit (mysql_error ());        
      }
	
	
  $q = 'select * from hl_emails where id = \'listing_approve\'';
  $sth = mysql_query ($q);
  $msg = mysql_fetch_array ($sth);
  $text = $msg['text'];
  $subject = $msg['subject'];
  
  
  $q = 'select * from hl_listings where id = '.$lid;
  $sth = mysql_query ($q);
  $row = mysql_fetch_array ($sth);
  
  reset ($row);
  
  foreach ($row as $k => $v)
  {
    if (is_array ($v))
    {
      continue;
    }

    $v = strip_tags ($v);
    $v = preg_replace ('' . '/(\\$)/', '\\\\$', $v);
    $text = preg_replace ('' . '/#' . $k . '#/', '' . $v, $text);
    $subject = preg_replace ('' . '/#' . $k . '#/', '' . $v, $subject);
  }
  
  $text = preg_replace ('/#site_name#/', $settings['site_name'], $text);
  $subject = preg_replace ('/#site_name#/', $settings['site_name'], $subject);
  $text = preg_replace ('/#site_url#/', $settings['site_url'], $text);
  $subject = preg_replace ('/#site_url#/', $settings['site_url'], $subject);
  $text = preg_replace ('/#id#/',$lid,$text);
  
  $text = 'Congratulations! 
  You have successfully transfered $'.$amount.' from EG account #'.$account.' to our EG account which batch is #'.$batch.'!
  
  '.$text;  
  
  $text2 = 'Congratulations!
  New Listing '.$row['name'].' just paid $'.$amount.' from EG account #'.$account.' to our EG account which batch is #'.$batch.'!
  
  You can EDIT this site infomation at :
  
 '.$settings['site_url'].'/admin.php?a=edit_listing&lid='.$lid;
 
 
  
    mail ($settings['admin_email'], $settings['site_name'] . ' paid successful', $text2);
	mail ($email,$subject,$text);
	
    header ('Location: ?a=egold_processing&say=success&amount='.$amount.'&account='.$account.'&email='.$email.'&batch='.$batch.'&lid='.$lid);
	
    exit ();
  }

  $smarty->assign ('lid',$frm['lid']);
  $smarty->assign ('email',$frm['email']);
  $smarty->assign ('amount',$frm['amount']);
  $smarty->assign ('account',$frm['account']);
  $smarty->assign ('batch',$frm['batch']);
  $smarty->assign ('say', $frm['say']);
  $smarty->display ('egold_processing.tpl');
?>
