database_fetch_assoc($database->database_query("SELECT admin_email, admin_name FROM se_admins ORDER BY admin_id ASC LIMIT 1"));
//mail("bateworldhelp@gmail.com", "Check this user test", "User ID: ".$user_id."
//Subscription ID: ".$subscription_id);
/*$handle = fopen("../cc_log_segpay", "a+");
if(!$handle) :
//echo "Error opening file.\n";
mail("leprakhauns@gmail.com", "Error Segpay", "Error opening file.\n");
endif;
*/
if($_POST['approved']=="Yes"){
if($_POST["action"]=="Auth")
{
if($_POST["refundreasoncode"]==""){
if($_POST) :
/*if(! fwrite($handle,"APPROVED: \n". print_r($_POST, TRUE) . "\n\n\n")) :
//echo 'Error writing file.';
mail("leprakhauns@gmail.com", "Error Segpay", "Error writing file.\n");
endif;
*/
$x=explode(":", $_POST["eticketid"]);
$subscription_type = $x[1];
$user_id = $_POST['seuser'];
$subscription_id = $_POST['purchaseid'];
//echo "User: ".$user_id."
Subscription type: ". $subscription_type."
Subscription ID: ". $subscription_id ;
switch($subscription_type) :
case '20139' : # $15 -> 90-day recurring
$plan_id = '1';
$recurring = TRUE;
break;
case '27396' : # $15 -> 90-day recurring
$plan_id = '1';
$recurring = TRUE;
break;
case '0000005066' :
$plan_id = '1';
$recurring = TRUE;
break;
case '20141' : # $25 -> 180-day
$plan_id = '2';
$recurring = FALSE;
break;
case '20140' : # $45 -> 365-day
$plan_id = '3';
$recurring = FALSE;
break;
case '24603' : # $45 -> 365-day
$plan_id = '3';
$recurring = FALSE;
break;
case '28103' : # $45 -> 365-day
$plan_id = '3';
$recurring = FALSE;
break;
case '20142' : # $15 -> 90-day non-recurring
$plan_id = '6';
$recurring = FALSE;
break;
case '23501' : # $15 -> 90-day non-recurring
$plan_id = '9';
$recurring = TRUE;
break;
case '24623' : # $15 -> 90-day non-recurring
$plan_id = '9';
$recurring = TRUE;
break;
case '23791' : # $15 -> 30-day recurring
$plan_id = '10';
$recurring = TRUE;
break;
case '27395' : # $15 -> 30-day recurring
$plan_id = '10';
$recurring = TRUE;
break;
case '24602' : # $15 -> 30-day recurring
$plan_id = '10';
$recurring = TRUE;
break;
case '24601' : # $15 -> 30-day non-recurring
$plan_id = '11';
$recurring = FALSE;
break;
endswitch;
$plan = new semods_plan($plan_id, $user_id);
/* Query to see if plan exists for user */
$user_plan_rows = semods::db_query_assoc_all("SELECT *
FROM se_semods_userplans UP
LEFT JOIN se_semods_plans P
ON UP.userplan_plan_id = P.plan_id
WHERE userplan_user_id = $user_id order by userplan_id DESC LIMIT 1
");
if($user_plan_rows[0]['userplan_plan_id']==4&&$user_plan_rows[0]['userplan_state']!=2)
{
//mail("leprakhauns@gmail.com", "Trial User paid money", $user_plan_rows[0]['userplan_user_id']);
}
if(!$user_plan_rows) :
$plan->plan_exists = FALSE;
$userplan = $plan->plan_subscribe($user_id, 0, array('cc_id' => $subscription_id), $recurring, 'Segpay');
mail($recepient_info['admin_email'], "Check this user 1", "https://bateworld.com/bwadmin/admin_viewusers.php?id=".$user_id."
Subscription ID: ".$subscription_id);
elseif($user_plan_rows[0]['userplan_plan_id'] == $plan_id) :
if($user_plan_rows[0]['userplan_plan_id']==4&&$user_plan_rows[0]['userplan_state']!=2)
{
//mail("leprakhauns@gmail.com", "This doesn't make sense?", $user_plan_rows[0]['userplan_user_id']);
}
if($recurring==FALSE)
{
if($user_plan_rows[0]['userplan_expiredate']