示例#1
0
 *  
 * @author Arslan Hassan
 * @license AAL
 * @since 3.0 
 */
include '../includes/config.inc.php';
//Getting mode..
$mode = post('mode');
if (!$mode) {
    $mode = get('mode');
}
$mode = mysql_clean($mode);
switch ($mode) {
    case "subscribe":
        $to = post('to');
        $insert_id = subscribe_user($to);
        if (error()) {
            echo json_encode(array('error' => error()));
        }
        if (msg()) {
            $output = subscription_buttons($to);
            echo json_encode(array('success' => msg(), 'output' => $output));
        }
        break;
    case "unsubscribe":
        $to = post('to');
        unsubscribe_user($to);
        if (error()) {
            echo json_encode(array('error' => error()));
        }
        if (msg()) {
                 $javascript = '<script>$( document ).ready( function(){ cb_confirm( "' . $heading . '","' . $body . '",function(){ window.location="' . $url . '" }) } )</script>';
                 register_anchor($javascript, 'cb_head');
             }
         }
     }
 }
 if ($confirm == 2) {
     $subscribe = get('subscribe');
     $unsubscribe = get('unsubscribe');
     if ($subscribe || $unsubscribe) {
         $sub_id = get('owner');
         $sub = get_user_details($sub_id);
         if ($sub) {
             $is_subscribed = is_user_subscribed($sub['userid']);
             if ($subscribe and !$is_subscribed) {
                 subscribe_user($sub_id);
             } else {
                 if ($unsubscribe and $is_subscribed) {
                     unsubscribe_user($sub_id);
                 }
             }
             if (!error()) {
                 $success = true;
             }
             if ($success) {
                 redirect_to(BASEURL . '/manage_subscriptions.php');
             }
         }
     }
 }
 $order = return_object_order('manage_subscriptions');