示例#1
0
function startApplication($user_id, $club_id)
{
    $user_id = escape($user_id);
    $club_id = escape($club_id);
    if (isApplicationStarted($user_id, $club_id)) {
        //already present
        return -1;
    }
    //if it's a club, verify existence
    if ($club_id != 0 && !clubExists($club_id)) {
        return -2;
    }
    //make sure it is available at this time
    if (!isAvailableWindow($club_id)) {
        return -3;
    }
    //subscribe to the club, since we're applying to it anyway
    if ($club_id != 0) {
        addSubscription($user_id, $club_id);
    }
    //add to applications table first
    mysql_query("INSERT INTO applications (user_id, club_id, submitted) VALUES ('{$user_id}', '{$club_id}', '')");
    $application_id = mysql_insert_id();
    //now insert blank answers to answers table
    if ($club_id == 0) {
        $result = mysql_query("SELECT id FROM baseapp WHERE category != '0' AND category != '-1'");
    } else {
        $result = mysql_query("SELECT id FROM supplements WHERE club_id='{$club_id}'");
    }
    while ($row = mysql_fetch_array($result)) {
        $question_id = escape($row['id']);
        mysql_query("INSERT INTO answers (application_id, var_id, val) VALUES ('{$application_id}', '{$question_id}', '')");
    }
    return 0;
}
示例#2
0
            } elseif ((double) $value == (double) $total_cost) {
                $found_duration = strtoupper(substr($duration, 0, 1));
            }
        }
        // If we have the duration then we're done.
        if ($found_duration !== 0) {
            $notify = true;
            addSubscription($subscription_id, $member_id, $found_duration);
        }
    } else {
        $actual_cost = $cost['fixed'];
        // It must be at least the right amount.
        if ($total_cost != 0 && $total_cost >= $actual_cost) {
            // Add the subscription.
            $notify = true;
            addSubscription($subscription_id, $member_id);
        }
    }
    // Send a receipt?
    if (!empty($modSettings['paid_email']) && $modSettings['paid_email'] == 2 && $notify) {
        $replacements = array('NAME' => $subscription_info['name'], 'SUBNAME' => $member_info['member_name'], 'SUBUSER' => $member_info['real_name'], 'SUBEMAIL' => $member_info['email_address'], 'PRICE' => sprintf($modSettings['paid_currency_symbol'], $total_cost), 'PROFILELINK' => $scripturl . '?action=profile;u=' . $member_id, 'DATE' => timeformat(time(), false));
        emailAdmins('paid_subscription_new', $replacements, $notify_users);
    }
}
// In case we have anything specific to do.
$gatewayClass->close();
// Log an error then die.
function generateSubscriptionError($text)
{
    global $modSettings, $notify_users, $smcFunc;
    // Send an email?
function ModifyUserSubscription()
{
    global $context, $txt, $modSettings, $smcFunc;
    loadSubscriptions();
    $context['log_id'] = isset($_REQUEST['lid']) ? (int) $_REQUEST['lid'] : 0;
    $context['sub_id'] = isset($_REQUEST['sid']) ? (int) $_REQUEST['sid'] : 0;
    $context['action_type'] = $context['log_id'] ? 'edit' : 'add';
    // Setup the template.
    $context['sub_template'] = 'modify_user_subscription';
    $context['page_title'] = $txt[$context['action_type'] . '_subscriber'];
    // If we haven't been passed the subscription ID get it.
    if ($context['log_id'] && !$context['sub_id']) {
        $request = $smcFunc['db_query']('', '
			SELECT id_subscribe
			FROM {db_prefix}log_subscribed
			WHERE id_sublog = {int:current_log_item}', array('current_log_item' => $context['log_id']));
        if ($smcFunc['db_num_rows']($request) == 0) {
            fatal_lang_error('no_access', false);
        }
        list($context['sub_id']) = $smcFunc['db_fetch_row']($request);
        $smcFunc['db_free_result']($request);
    }
    if (!isset($context['subscriptions'][$context['sub_id']])) {
        fatal_lang_error('no_access', false);
    }
    $context['current_subscription'] = $context['subscriptions'][$context['sub_id']];
    // Searching?
    if (isset($_POST['ssearch'])) {
        return ViewSubscribedUsers();
    } elseif (isset($_REQUEST['save_sub'])) {
        checkSession();
        // Work out the dates...
        $starttime = mktime($_POST['hour'], $_POST['minute'], 0, $_POST['month'], $_POST['day'], $_POST['year']);
        $endtime = mktime($_POST['hourend'], $_POST['minuteend'], 0, $_POST['monthend'], $_POST['dayend'], $_POST['yearend']);
        // Status.
        $status = $_POST['status'];
        // New one?
        if (empty($context['log_id'])) {
            // Find the user...
            $request = $smcFunc['db_query']('', '
				SELECT id_member, id_group
				FROM {db_prefix}members
				WHERE real_name = {string:name}
				LIMIT 1', array('name' => $_POST['name']));
            if ($smcFunc['db_num_rows']($request) == 0) {
                fatal_lang_error('error_member_not_found');
            }
            list($id_member, $id_group) = $smcFunc['db_fetch_row']($request);
            $smcFunc['db_free_result']($request);
            // Ensure the member doesn't already have a subscription!
            $request = $smcFunc['db_query']('', '
				SELECT id_subscribe
				FROM {db_prefix}log_subscribed
				WHERE id_subscribe = {int:current_subscription}
					AND id_member = {int:current_member}', array('current_subscription' => $context['sub_id'], 'current_member' => $id_member));
            if ($smcFunc['db_num_rows']($request) != 0) {
                fatal_lang_error('member_already_subscribed');
            }
            $smcFunc['db_free_result']($request);
            // Actually put the subscription in place.
            if ($status == 1) {
                addSubscription($context['sub_id'], $id_member, 0, $starttime, $endtime);
            } else {
                $smcFunc['db_insert']('', '{db_prefix}log_subscribed', array('id_subscribe' => 'int', 'id_member' => 'int', 'old_id_group' => 'int', 'start_time' => 'int', 'end_time' => 'int', 'status' => 'int'), array($context['sub_id'], $id_member, $id_group, $starttime, $endtime, $status), array('id_sublog'));
            }
        } else {
            $request = $smcFunc['db_query']('', '
				SELECT id_member, status
				FROM {db_prefix}log_subscribed
				WHERE id_sublog = {int:current_log_item}', array('current_log_item' => $context['log_id']));
            if ($smcFunc['db_num_rows']($request) == 0) {
                fatal_lang_error('no_access', false);
            }
            list($id_member, $old_status) = $smcFunc['db_fetch_row']($request);
            $smcFunc['db_free_result']($request);
            // Pick the right permission stuff depending on what the status is changing from/to.
            if ($old_status == 1 && $status != 1) {
                removeSubscription($context['sub_id'], $id_member);
            } elseif ($status == 1 && $old_status != 1) {
                addSubscription($context['sub_id'], $id_member, 0, $starttime, $endtime);
            } else {
                $smcFunc['db_query']('', '
					UPDATE {db_prefix}log_subscribed
					SET start_time = {int:start_time}, end_time = {int:end_time}, status = {int:status}
					WHERE id_sublog = {int:current_log_item}', array('start_time' => $starttime, 'end_time' => $endtime, 'status' => $status, 'current_log_item' => $context['log_id']));
            }
        }
        // Done - redirect...
        redirectexit('action=admin;area=paidsubscribe;sa=viewsub;sid=' . $context['sub_id']);
    } elseif (isset($_REQUEST['delete']) || isset($_REQUEST['finished'])) {
        checkSession();
        // Do the actual deletes!
        if (!empty($_REQUEST['delsub'])) {
            $toDelete = array();
            foreach ($_REQUEST['delsub'] as $id => $dummy) {
                $toDelete[] = (int) $id;
            }
            $request = $smcFunc['db_query']('', '
				SELECT id_subscribe, id_member
				FROM {db_prefix}log_subscribed
				WHERE id_sublog IN ({array_int:subscription_list})', array('subscription_list' => $toDelete));
            while ($row = $smcFunc['db_fetch_assoc']($request)) {
                removeSubscription($row['id_subscribe'], $row['id_member'], isset($_REQUEST['delete']));
            }
            $smcFunc['db_free_result']($request);
        }
        redirectexit('action=admin;area=paidsubscribe;sa=viewsub;sid=' . $context['sub_id']);
    }
    // Default attributes.
    if ($context['action_type'] == 'add') {
        $context['sub'] = array('id' => 0, 'start' => array('year' => (int) strftime('%Y', time()), 'month' => (int) strftime('%m', time()), 'day' => (int) strftime('%d', time()), 'hour' => (int) strftime('%H', time()), 'min' => (int) strftime('%M', time()) < 10 ? '0' . (int) strftime('%M', time()) : (int) strftime('%M', time()), 'last_day' => 0), 'end' => array('year' => (int) strftime('%Y', time()), 'month' => (int) strftime('%m', time()), 'day' => (int) strftime('%d', time()), 'hour' => (int) strftime('%H', time()), 'min' => (int) strftime('%M', time()) < 10 ? '0' . (int) strftime('%M', time()) : (int) strftime('%M', time()), 'last_day' => 0), 'status' => 1);
        $context['sub']['start']['last_day'] = (int) strftime('%d', mktime(0, 0, 0, $context['sub']['start']['month'] == 12 ? 1 : $context['sub']['start']['month'] + 1, 0, $context['sub']['start']['month'] == 12 ? $context['sub']['start']['year'] + 1 : $context['sub']['start']['year']));
        $context['sub']['end']['last_day'] = (int) strftime('%d', mktime(0, 0, 0, $context['sub']['end']['month'] == 12 ? 1 : $context['sub']['end']['month'] + 1, 0, $context['sub']['end']['month'] == 12 ? $context['sub']['end']['year'] + 1 : $context['sub']['end']['year']));
        if (isset($_GET['uid'])) {
            $request = $smcFunc['db_query']('', '
				SELECT real_name
				FROM {db_prefix}members
				WHERE id_member = {int:current_member}', array('current_member' => (int) $_GET['uid']));
            list($context['sub']['username']) = $smcFunc['db_fetch_row']($request);
            $smcFunc['db_free_result']($request);
        } else {
            $context['sub']['username'] = '';
        }
    } else {
        $request = $smcFunc['db_query']('', '
			SELECT ls.id_sublog, ls.id_subscribe, ls.id_member, start_time, end_time, status, payments_pending, pending_details,
				IFNULL(mem.real_name, {string:blank_string}) AS username
			FROM {db_prefix}log_subscribed AS ls
				LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = ls.id_member)
			WHERE ls.id_sublog = {int:current_subscription_item}
			LIMIT 1', array('current_subscription_item' => $context['log_id'], 'blank_string' => ''));
        if ($smcFunc['db_num_rows']($request) == 0) {
            fatal_lang_error('no_access', false);
        }
        $row = $smcFunc['db_fetch_assoc']($request);
        $smcFunc['db_free_result']($request);
        // Any pending payments?
        $context['pending_payments'] = array();
        if (!empty($row['pending_details'])) {
            $pending_details = @unserialize($row['pending_details']);
            foreach ($pending_details as $id => $pending) {
                // Only this type need be displayed.
                if ($pending[3] == 'payback') {
                    // Work out what the options were.
                    $costs = @unserialize($context['current_subscription']['real_cost']);
                    if ($context['current_subscription']['real_length'] == 'F') {
                        foreach ($costs as $duration => $cost) {
                            if ($cost != 0 && $cost == $pending[1] && $duration == $pending[2]) {
                                $context['pending_payments'][$id] = array('desc' => sprintf($modSettings['paid_currency_symbol'], $cost . '/' . $txt[$duration]));
                            }
                        }
                    } elseif ($costs['fixed'] == $pending[1]) {
                        $context['pending_payments'][$id] = array('desc' => sprintf($modSettings['paid_currency_symbol'], $costs['fixed']));
                    }
                }
            }
            // Check if we are adding/removing any.
            if (isset($_GET['pending'])) {
                foreach ($pending_details as $id => $pending) {
                    // Found the one to action?
                    if ($_GET['pending'] == $id && $pending[3] == 'payback' && isset($context['pending_payments'][$id])) {
                        // Flexible?
                        if (isset($_GET['accept'])) {
                            addSubscription($context['current_subscription']['id'], $row['id_member'], $context['current_subscription']['real_length'] == 'F' ? strtoupper(substr($pending[2], 0, 1)) : 0);
                        }
                        unset($pending_details[$id]);
                        $new_details = serialize($pending_details);
                        // Update the entry.
                        $smcFunc['db_query']('', '
							UPDATE {db_prefix}log_subscribed
							SET payments_pending = payments_pending - 1, pending_details = {string:pending_details}
							WHERE id_sublog = {int:current_subscription_item}', array('current_subscription_item' => $context['log_id'], 'pending_details' => $new_details));
                        // Reload
                        redirectexit('action=admin;area=paidsubscribe;sa=modifyuser;lid=' . $context['log_id']);
                    }
                }
            }
        }
        $context['sub_id'] = $row['id_subscribe'];
        $context['sub'] = array('id' => 0, 'start' => array('year' => (int) strftime('%Y', $row['start_time']), 'month' => (int) strftime('%m', $row['start_time']), 'day' => (int) strftime('%d', $row['start_time']), 'hour' => (int) strftime('%H', $row['start_time']), 'min' => (int) strftime('%M', $row['start_time']) < 10 ? '0' . (int) strftime('%M', $row['start_time']) : (int) strftime('%M', $row['start_time']), 'last_day' => 0), 'end' => array('year' => (int) strftime('%Y', $row['end_time']), 'month' => (int) strftime('%m', $row['end_time']), 'day' => (int) strftime('%d', $row['end_time']), 'hour' => (int) strftime('%H', $row['end_time']), 'min' => (int) strftime('%M', $row['end_time']) < 10 ? '0' . (int) strftime('%M', $row['end_time']) : (int) strftime('%M', $row['end_time']), 'last_day' => 0), 'status' => $row['status'], 'username' => $row['username']);
        $context['sub']['start']['last_day'] = (int) strftime('%d', mktime(0, 0, 0, $context['sub']['start']['month'] == 12 ? 1 : $context['sub']['start']['month'] + 1, 0, $context['sub']['start']['month'] == 12 ? $context['sub']['start']['year'] + 1 : $context['sub']['start']['year']));
        $context['sub']['end']['last_day'] = (int) strftime('%d', mktime(0, 0, 0, $context['sub']['end']['month'] == 12 ? 1 : $context['sub']['end']['month'] + 1, 0, $context['sub']['end']['month'] == 12 ? $context['sub']['end']['year'] + 1 : $context['sub']['end']['year']));
    }
}
示例#4
0
function reservationDispatch($op)
{
    if (isset($_POST['add_event'])) {
        Util::jump_to('index.php?modname=reservation&amp;op=add_event');
    }
    if (isset($_POST['category_gestion'])) {
        Util::jump_to('index.php?modname=reservation&amp;op=view_category&amp;id_course=' . $_SESSION['idCourse']);
    }
    if (isset($_POST['location_gestion'])) {
        Util::jump_to('index.php?modname=reservation&amp;op=classroom&amp;id_course=' . $_SESSION['idCourse']);
    }
    if (isset($_POST['undo'])) {
        Util::jump_to('index.php?modname=reservation&op=reservation&active_tab=subscribed_user');
    }
    if (isset($_POST['undo_switch'])) {
        Util::jump_to('index.php?modname=reservation&op=reservation&active_tab=events');
    }
    if (isset($_POST['undo_profile'])) {
        Util::jump_to('index.php?modname=reservation&op=reservation&active_tab=events');
    }
    if (isset($_POST['undo_mail'])) {
        Util::jump_to('index.php?modname=reservation&op=reservation&active_tab=events');
    }
    if (isset($_POST['okselector'])) {
        if (isset($_GET['id_course'])) {
            $op = 'send_registration';
        }
    }
    if (isset($_POST['cancelselector'])) {
        Util::jump_to('index.php?modname=reservation&op=reservation&active_tab=subscribed_user');
    }
    if (isset($_POST['undo_cat'])) {
        $op = 'view_category';
    }
    if (isset($_POST['undo_lab'])) {
        $op = 'view_laboratories';
    }
    switch ($op) {
        case 'del_subscription':
            delSubscription();
            break;
        case 'add_subscription':
            addSubscription();
            break;
        case 'add_registration':
            addRegistration();
            break;
        case 'send_registration':
            sendRegistration();
            break;
        case 'del_event':
            delEvent();
            break;
        case 'mod_event':
            modEvent();
            break;
        case 'add_event':
            addEvent();
            break;
        case 'view_user_event':
            viewUserEvent();
            break;
        case 'send_user_event':
            sendUserEvent();
            break;
        case 'excel':
            getExcelFile();
            break;
        case 'reservation':
        default:
            reservation();
            break;
        case 'view_category':
            viewCategoy();
            break;
        case 'add_category':
            addCategoy();
            break;
        case 'mod_category':
            modCategoy();
            break;
        case 'del_category':
            delCategoy();
            break;
            /*case 'view_laboratories':
            			viewLaboratories();
            		break;
            		
            		case 'add_laboratory':
            			addLaboratory();
            		break;
            		
            		case 'mod_laboratory':
            			modLaboratory();
            		break;
            		
            		case 'del_laboratory':
            			delLaboratory();
            		break;*/
            //TODO:
        /*case 'view_laboratories':
        			viewLaboratories();
        		break;
        		
        		case 'add_laboratory':
        			addLaboratory();
        		break;
        		
        		case 'mod_laboratory':
        			modLaboratory();
        		break;
        		
        		case 'del_laboratory':
        			delLaboratory();
        		break;*/
        //TODO:
        case "classroom":
            classroom();
            break;
        case "addclassroom":
            editclassroom();
            break;
        case "modclassroom":
            editclassroom(true);
            break;
        case "saveclassroom":
            saveclassroom();
            break;
        case "delclassroom":
            delclassroom();
            break;
            //TODO:
        //TODO:
        case 'switch_subscription':
            switchSubscription();
            break;
        case 'set_room_view_perm':
            setRoomViewPerm();
            break;
        case 'send_mail':
            reservationSendMail();
            break;
        case 'info_location':
            infoLocation();
            break;
    }
}
示例#5
0
 /**
  * Edit or add a user subscription.
  *
  * - Accessed from ?action=admin;area=paidsubscribe;sa=modifyuser
  */
 public function action_modifyuser()
 {
     global $context, $txt, $modSettings;
     require_once SUBSDIR . '/PaidSubscriptions.subs.php';
     loadSubscriptions();
     $context['log_id'] = isset($_REQUEST['lid']) ? (int) $_REQUEST['lid'] : 0;
     $context['sub_id'] = isset($_REQUEST['sid']) ? (int) $_REQUEST['sid'] : 0;
     $context['action_type'] = $context['log_id'] ? 'edit' : 'add';
     // Setup the template.
     $context['sub_template'] = 'modify_user_subscription';
     $context['page_title'] = $txt[$context['action_type'] . '_subscriber'];
     loadJavascriptFile('suggest.js', array('defer' => true));
     // If we haven't been passed the subscription ID get it.
     if ($context['log_id'] && !$context['sub_id']) {
         $context['sub_id'] = validateSubscriptionID($context['log_id']);
     }
     if (!isset($context['subscriptions'][$context['sub_id']])) {
         fatal_lang_error('no_access', false);
     }
     $context['current_subscription'] = $context['subscriptions'][$context['sub_id']];
     // Searching?
     if (isset($_POST['ssearch'])) {
         return $this->action_viewsub();
     } elseif (isset($_REQUEST['save_sub'])) {
         checkSession();
         // Work out the dates...
         $starttime = mktime($_POST['hour'], $_POST['minute'], 0, $_POST['month'], $_POST['day'], $_POST['year']);
         $endtime = mktime($_POST['hourend'], $_POST['minuteend'], 0, $_POST['monthend'], $_POST['dayend'], $_POST['yearend']);
         // Status.
         $status = $_POST['status'];
         // New one?
         if (empty($context['log_id'])) {
             // Find the user...
             require_once SUBSDIR . '/Members.subs.php';
             $member = getMemberByName($_POST['name']);
             if (empty($member)) {
                 fatal_lang_error('error_member_not_found');
             }
             if (alreadySubscribed($context['sub_id'], $member['id_member'])) {
                 fatal_lang_error('member_already_subscribed');
             }
             // Actually put the subscription in place.
             if ($status == 1) {
                 addSubscription($context['sub_id'], $member['id_member'], 0, $starttime, $endtime);
             } else {
                 $details = array('id_subscribe' => $context['sub_id'], 'id_member' => $member['id_member'], 'id_group' => $member['id_group'], 'start_time' => $starttime, 'end_time' => $endtime, 'status' => $status);
                 logSubscription($details);
             }
         } else {
             $subscription_status = getSubscriptionStatus($context['log_id']);
             // Pick the right permission stuff depending on what the status is changing from/to.
             if ($subscription_status['old_status'] == 1 && $status != 1) {
                 removeSubscription($context['sub_id'], $subscription_status['id_member']);
             } elseif ($status == 1 && $subscription_status['old_status'] != 1) {
                 addSubscription($context['sub_id'], $subscription_status['id_member'], 0, $starttime, $endtime);
             } else {
                 $item = array('start_time' => $starttime, 'end_time' => $endtime, 'status' => $status, 'current_log_item' => $context['log_id']);
                 updateSubscriptionItem($item);
             }
         }
         // Done - redirect...
         redirectexit('action=admin;area=paidsubscribe;sa=viewsub;sid=' . $context['sub_id']);
     } elseif (isset($_REQUEST['delete']) || isset($_REQUEST['finished'])) {
         checkSession();
         // Do the actual deletes!
         if (!empty($_REQUEST['delsub'])) {
             $toDelete = array();
             foreach ($_REQUEST['delsub'] as $id => $dummy) {
                 $toDelete[] = (int) $id;
             }
             $deletes = prepareDeleteSubscriptions($toDelete);
             foreach ($deletes as $id_subscribe => $id_member) {
                 removeSubscription($id_subscribe, $id_member, isset($_REQUEST['delete']));
             }
         }
         redirectexit('action=admin;area=paidsubscribe;sa=viewsub;sid=' . $context['sub_id']);
     }
     // Default attributes.
     if ($context['action_type'] == 'add') {
         $context['sub'] = array('id' => 0, 'start' => array('year' => (int) strftime('%Y', time()), 'month' => (int) strftime('%m', time()), 'day' => (int) strftime('%d', time()), 'hour' => (int) strftime('%H', time()), 'min' => (int) strftime('%M', time()) < 10 ? '0' . (int) strftime('%M', time()) : (int) strftime('%M', time()), 'last_day' => 0), 'end' => array('year' => (int) strftime('%Y', time()), 'month' => (int) strftime('%m', time()), 'day' => (int) strftime('%d', time()), 'hour' => (int) strftime('%H', time()), 'min' => (int) strftime('%M', time()) < 10 ? '0' . (int) strftime('%M', time()) : (int) strftime('%M', time()), 'last_day' => 0), 'status' => 1);
         $context['sub']['start']['last_day'] = (int) strftime('%d', mktime(0, 0, 0, $context['sub']['start']['month'] == 12 ? 1 : $context['sub']['start']['month'] + 1, 0, $context['sub']['start']['month'] == 12 ? $context['sub']['start']['year'] + 1 : $context['sub']['start']['year']));
         $context['sub']['end']['last_day'] = (int) strftime('%d', mktime(0, 0, 0, $context['sub']['end']['month'] == 12 ? 1 : $context['sub']['end']['month'] + 1, 0, $context['sub']['end']['month'] == 12 ? $context['sub']['end']['year'] + 1 : $context['sub']['end']['year']));
         if (isset($_GET['uid'])) {
             require_once SUBSDIR . '/Members.subs.php';
             // Get the latest activated member's display name.
             $result = getBasicMemberData((int) $_GET['uid']);
             $context['sub']['username'] = $result['real_name'];
         } else {
             $context['sub']['username'] = '';
         }
     } else {
         $row = getPendingSubscriptions($context['log_id']);
         if (empty($row)) {
             fatal_lang_error('no_access', false);
         }
         // Any pending payments?
         $context['pending_payments'] = array();
         if (!empty($row['pending_details'])) {
             $pending_details = @unserialize($row['pending_details']);
             foreach ($pending_details as $id => $pending) {
                 // Only this type need be displayed.
                 if ($pending[3] == 'payback') {
                     // Work out what the options were.
                     $costs = @unserialize($context['current_subscription']['real_cost']);
                     if ($context['current_subscription']['real_length'] == 'F') {
                         foreach ($costs as $duration => $cost) {
                             if ($cost != 0 && $cost == $pending[1] && $duration == $pending[2]) {
                                 $context['pending_payments'][$id] = array('desc' => sprintf($modSettings['paid_currency_symbol'], $cost . '/' . $txt[$duration]));
                             }
                         }
                     } elseif ($costs['fixed'] == $pending[1]) {
                         $context['pending_payments'][$id] = array('desc' => sprintf($modSettings['paid_currency_symbol'], $costs['fixed']));
                     }
                 }
             }
             // Check if we are adding/removing any.
             if (isset($_GET['pending'])) {
                 foreach ($pending_details as $id => $pending) {
                     // Found the one to action?
                     if ($_GET['pending'] == $id && $pending[3] == 'payback' && isset($context['pending_payments'][$id])) {
                         // Flexible?
                         if (isset($_GET['accept'])) {
                             addSubscription($context['current_subscription']['id'], $row['id_member'], $context['current_subscription']['real_length'] == 'F' ? strtoupper(substr($pending[2], 0, 1)) : 0);
                         }
                         unset($pending_details[$id]);
                         $new_details = serialize($pending_details);
                         // Update the entry.
                         updatePendingSubscription($context['log_id'], $new_details);
                         // Reload
                         redirectexit('action=admin;area=paidsubscribe;sa=modifyuser;lid=' . $context['log_id']);
                     }
                 }
             }
         }
         $context['sub_id'] = $row['id_subscribe'];
         $context['sub'] = array('id' => 0, 'start' => array('year' => (int) strftime('%Y', $row['start_time']), 'month' => (int) strftime('%m', $row['start_time']), 'day' => (int) strftime('%d', $row['start_time']), 'hour' => (int) strftime('%H', $row['start_time']), 'min' => (int) strftime('%M', $row['start_time']) < 10 ? '0' . (int) strftime('%M', $row['start_time']) : (int) strftime('%M', $row['start_time']), 'last_day' => 0), 'end' => array('year' => (int) strftime('%Y', $row['end_time']), 'month' => (int) strftime('%m', $row['end_time']), 'day' => (int) strftime('%d', $row['end_time']), 'hour' => (int) strftime('%H', $row['end_time']), 'min' => (int) strftime('%M', $row['end_time']) < 10 ? '0' . (int) strftime('%M', $row['end_time']) : (int) strftime('%M', $row['end_time']), 'last_day' => 0), 'status' => $row['status'], 'username' => $row['username']);
         $context['sub']['start']['last_day'] = (int) strftime('%d', mktime(0, 0, 0, $context['sub']['start']['month'] == 12 ? 1 : $context['sub']['start']['month'] + 1, 0, $context['sub']['start']['month'] == 12 ? $context['sub']['start']['year'] + 1 : $context['sub']['start']['year']));
         $context['sub']['end']['last_day'] = (int) strftime('%d', mktime(0, 0, 0, $context['sub']['end']['month'] == 12 ? 1 : $context['sub']['end']['month'] + 1, 0, $context['sub']['end']['month'] == 12 ? $context['sub']['end']['year'] + 1 : $context['sub']['end']['year']));
     }
 }
示例#6
0
文件: clubs.php 项目: uakfdotb/oneapp
include "../include/session.php";
include "../include/apply_gen.php";
include "../include/apply_submit.php";
include "../include/subscribe.php";
if (isset($_SESSION['user_id'])) {
    $inform = array();
    if (isset($_POST['club_id'])) {
        $club_data = clubInfo($_POST['club_id']);
        $club_name = $club_data[0];
        if (isset($_POST['sub'])) {
            if ($_POST['sub'] == "on") {
                $out = removeSubscription($_SESSION['user_id'], $_POST['club_id']);
                $inform["success"] = "Unsubscribed from {$club_name}! You will <b>NOT</b> recieve messages from {$club_name}";
            } else {
                if ($_POST['sub'] == "off") {
                    $out = addSubscription($_SESSION['user_id'], $_POST['club_id']);
                    $inform["success"] = "Subscribed to {$club_name}! You will now recieve messages from {$club_name}";
                }
            }
        } else {
            if (isset($_POST['app'])) {
                if ($_POST['app'] == "on") {
                    $out = deleteApplication($_SESSION['user_id'], $_POST['club_id']);
                    if ($out == 0) {
                        $inform["success"] = "Deleted application for {$club_name}!";
                    } else {
                        if ($out == -1) {
                            $inform["warn"] = "You have not started the application for {$club_name}";
                        } else {
                            if ($out == -2) {
                                $inform["error"] = "This club does not exist!";
示例#7
0
function createForumCategory($itemId)
{
    global $h, $db, $config;
    if (!$itemId && !$h->session->isAdmin) {
        return false;
    }
    //invalid request
    if ($itemId) {
        $item = getForumItem($itemId);
        $parent = getForumItem($item['parentId']);
        if ($itemId && !$item || $item['locked']) {
            die;
        }
        //block attempt to create item with nonexisting parent
    }
    $quoteId = 0;
    if (!empty($_GET['q']) && is_numeric($_GET['q'])) {
        $quoteId = $_GET['q'];
    }
    $writeSubject = '';
    $writeBody = '';
    if ($quoteId) {
        /* Quote another message */
        $quoteItem = getForumItem($quoteId);
        $quoteName = $quoteItem['authorName'];
        if ($quoteName && trim($quoteItem['itemBody'])) {
            $writeBody = '[quote name=' . $quoteName . ']' . $quoteItem['itemBody'] . "[/quote]\n\n";
        }
    }
    if (!empty($_POST['subject'])) {
        $writeSubject = $_POST['subject'];
    }
    if (!empty($_POST['body'])) {
        $writeBody = $_POST['body'];
    }
    $createdId = 0;
    $forum_error = '';
    if (!empty($_POST['subject']) || !empty($_POST['body'])) {
        if (strlen($writeBody) <= $config['forum']['maxsize_body']) {
            if ($h->session->isAdmin && ($itemId == 0 || $item['parentId'] == 0)) {
                //Create category or a forum
                if ($writeSubject) {
                    $createdId = addForumFolder($itemId, $writeSubject, $writeBody);
                    goLoc('forum.php?id=' . $createdId);
                    die;
                } else {
                    $forum_error = 'You must write a topic!';
                }
            } else {
                //Create a thread or a post
                if ($parent['parentId'] == 0 && !$writeSubject) {
                    $forum_error = 'You must write a topic!';
                } else {
                    $sticky = 0;
                    if ($h->session->isAdmin && !empty($_POST['sticky'])) {
                        $sticky = $_POST['sticky'];
                    }
                    $createdId = addForumMessage($itemId, $writeSubject, $writeBody, $sticky);
                    if ($createdId) {
                        //attach all FILETYPE_FORUM ownerId =0 to this id
                        $q = 'UPDATE tblFiles SET ownerId=' . $createdId . ' WHERE fileType=' . FILETYPE_FORUM . ' AND ownerId=0 AND uploaderId=' . $h->session->id;
                        $db->update($q);
                    }
                    goLoc('forum.php?id=' . $itemId . '#post' . $createdId);
                    die;
                }
            }
        } else {
            $forum_error = 'The post is too long, the max allowed length are ' . $config['forum']['maxsize_body'] . ' characters, please try to shorten down your text a bit.';
        }
        if (!$forum_error) {
            if (!empty($_POST['subscribehere'])) {
                //Start a subscription of the created topic
                //fixme: make sure we are creating a topic so users cant subscribe to whole forums
                addSubscription(SUBSCRIPTION_FORUM, $itemId);
            }
            if ($itemId == 0 || $item['parentId'] == 0) {
                header('Location: forum.php?id=' . $itemId);
            } else {
                $item = getForumItem($itemId);
                header('Location: forum.php?id=' . $item['parentId'] . '#post' . $itemId);
            }
            die;
        }
    }
    $hide_subject = false;
    if (!empty($forum_error)) {
        echo '<div class="critical">' . $forum_error . '</div>';
    }
    echo '<form method="post" name="newpost" enctype="multipart/form-data" action="' . $_SERVER['PHP_SELF'] . '?id=' . $itemId . '">';
    if ($itemId == 0) {
        //Create root level category (admins only)
        echo 'Forum - Add new root level category<br/><br/>';
        echo t('Name') . ': ' . xhtmlInput('subject', $writeSubject, 60, 50) . '<br/>';
    } else {
        if (!$item['parentId']) {
            //Create a category inside a "root level category" (admins only)
            echo 'Forum - Add new subcategory (under <b>' . getForumName($itemId) . '</b>)<br/><br/>';
            echo t('Subject') . ': <input type="text" size="60" maxlength="50" name="subject" value="' . $writeSubject . '"/><br/>';
            echo t('Description') . ':<br/>';
            echo '<input type="text" name="body" size="60" value="' . $writeBody . '"/><br/><br/>';
        } else {
            if ($parent['parentId'] == 0) {
                //Create a discussion thread (everyone)
                echo 'Add new discussion thread under ' . getForumDepthHTML(FORUM_FOLDER, $itemId) . '<br/><br/>';
                echo t('Subject') . ': <input type="text" size="60" maxlength="50" name="subject" value="' . $writeSubject . '"/><br/>';
                echo '<textarea name="body" cols="60" rows="14">' . $writeBody . '</textarea><br/><br/>';
                if ($h->session->isAdmin) {
                    //Allow admins to create stickies & announcements
                    echo '<input name="sticky" type="radio" class="radio" value="0" id="r0" checked="checked"/><label for="r0">Create a normal thread</label><br/>';
                    echo '<input name="sticky" type="radio" class="radio" value="1" id="r1"/><label for="r1">Admin only: Make the thread a sticky</label><br/>';
                    echo '<input name="sticky" type="radio" class="radio" value="2" id="r2"/><label for="r2">Admin only: Make the thread an announcement</label><br/>';
                }
            } else {
                //Create a post (everyone)
                echo getForumDepthHTML(FORUM_FOLDER, $itemId) . ' - Add a response to this post<br/><br/>';
                echo showForumPost($item, '', false);
                //handle file upload
                if (!empty($_FILES['file1'])) {
                    $h->files->handleUpload($_FILES['file1'], FILETYPE_FORUM, 0);
                }
                $h->files->showAttachments(FILETYPE_FORUM, 0);
                echo '<div id="forum_new_attachment">';
                echo t('Attach a file') . ': ';
                echo '<input type="file" name="file1"/>';
                echo xhtmlSubmit('Upload');
                echo '</div>';
                echo '<textarea name="body" cols="60" rows="14">' . $writeBody . '</textarea><br/><br/>';
            }
        }
    }
    $item = getForumItem($itemId);
    echo '<br/>';
    echo xhtmlSubmit('Save');
    /*
    if (!isSubscribed($itemId, SUBSCRIBE_MAIL)) {
        $content .= '<input name="subscribehere" type="checkbox" class="checkbox">Subscribe to topic';
    } else {
        $content .= '<div class="critical">You are already subscribed to this topic</div>';
    }
    */
    echo '</form><br/>';
    echo '<script type="text/javascript">';
    echo 'if (document.newpost.subject) document.newpost.subject.focus();';
    echo 'else if (document.newpost.body) document.newpost.body.focus();';
    echo '</script>';
}
示例#8
0
$app->post('/api/addRSS', function () use($dbh) {
    $args['user'] = $_SESSION['userLogin'];
    $args['title'] = $_POST['title'];
    $args['category'] = $_POST['category'];
    $args['description'] = $_POST['description'];
    $args['pubDate'] = date('Y-m-d');
    $args['link'] = "_rss/_profiles/_" . $args['user'] . "/rss_" . $args['user'] . ".xml";
    echo json_encode(addRSS($dbh, $args));
});
$app->get('/api/rssExists', function () use($dbh) {
    echo json_encode(rssExists($dbh), JSON_UNESCAPED_SLASHES);
});
$app->post('/api/addSubscription', function () use($dbh) {
    $args[":userID"] = $_SESSION['userID'];
    $args2[':marshalUsername'] = $_POST['marshalUsername'];
    echo json_encode(addSubscription($dbh, $args, $args2), JSON_UNESCAPED_SLASHES);
});
/*
Michael Gilbert
updateUserDetailsHunter
Updates a user's account info
Change code specifies which info is being changed
Codes:
0: username
1: email
2: password
3: username and email
4: username and password
5: email and password
6: username and email and password
Errors: Code is in the format "xxxxxxxx" where each x can be either 0 or 1, and the position is increasing left to right ie "[0][1][2][3][4][5][6][7]"
        echo "<p>Password:<code>" . $IFTTTPassword . "</code></p>";
        echo '<p><a href="' . $iftttBlogUrl . '/logout.php">Logout</a></p>';
        //create table for user activities
        mysql_query("CREATE TABLE IF NOT EXISTS `" . $xml->user->encodedId . "Activities` (\r\n\t\t\t\t\t\t\t`activityId` int(11) NOT NULL,\r\n\t\t\t\t\t\t\t`calories` int(11) NOT NULL,\r\n\t\t\t\t\t\t\t`description` varchar(300) NOT NULL,\r\n\t\t\t\t\t\t\t`distance` int(11) NOT NULL,\r\n\t\t\t\t\t\t\t`duration` int(11) NOT NULL,\r\n\t\t\t\t\t\t\t`name` varchar(100) NOT NULL,\r\n\t\t\t\t\t\t\tPRIMARY KEY (`activityId`)\r\n\t\t\t\t\t\t) ENGINE=InnoDB DEFAULT CHARSET=latin1;");
        //subscribe to user activities
        /**
         * Add subscription
         *
         * @throws FitBitException
         *
         * @param string $id   Subscription Id
         * @param string $path Subscription resource path (beginning with slash). Omit to subscribe to all user updates.
         *
         * @return
         */
        addSubscription($xml->user->encodedId, "/activities", $subscriberId = null);
        echo getSubscriptions();
    } else {
        echo "<h1>Error 1</h1>";
        echo "<p>Current number of beta users maxed out - sorry</p>";
        echo mysql_error();
    }
}
?>

				</p>

				<p><a href="index.html">Back</a> to documentation </p>

			</div>
		</div>
示例#10
0
 function processGroup($xml, $tags = array())
 {
     $errors = array();
     // tags are the words of the outline parent
     if ((string) $xml['title'] && $xml['title'] != '/') {
         $tags[] = (string) $xml['title'];
     }
     foreach ($xml->outline as $outline) {
         if ((string) $outline['type']) {
             $ret = addSubscription($outline, $tags);
             if ($ret !== true) {
                 $errors[] = $ret;
             }
         }
         if ($outline['type'] == 'folder') {
             //folder type, no functionality yet!
             echo "Folder type:<br>";
         } else {
             $ret = processGroup($outline, $tags);
             //$errors = array_merge($errors, $ret);
         }
     }
 }
示例#11
0
<?php

require_once 'find_config.php';
$h->session->requireLoggedIn();
if (!isset($_GET['goto'])) {
    header('Location: index.php');
}
$tourl = $_GET['goto'];
// Start chat between two users
if (isset($_GET['otherid']) && is_numeric($_GET['otherid'])) {
    addSubscription(SUBSCRIPTION_USER_CHATREQ, $h->session->id, $_GET['otherid']);
}
//echo $tourl;
header('Location: ' . $tourl);
示例#12
0
                                         deleteAccount();
                                     } else {
                                         if ($_GET["function"] == "count-unread") {
                                             countUnread();
                                         } else {
                                             if ($_GET["function"] == "load-featured") {
                                                 loadFeatured();
                                             } else {
                                                 if ($_GET["function"] == "load-feed") {
                                                     loadFeed();
                                                 } else {
                                                     if ($_GET["function"] == "load-sidebar") {
                                                         loadSidebar();
                                                     } else {
                                                         if ($_GET["function"] == "add-subscription") {
                                                             addSubscription();
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
示例#13
0
        $club_data = clubInfo($_REQUEST['club']);
        $club_name = $club_data[0];
        if ($_REQUEST['mode'] == "apply") {
            $result = startApplication($_SESSION['user_id'], $_REQUEST['club']);
            if ($result == 0) {
                $inform["success"] = "Started application for {$club_name}!";
            } else {
                if ($result == -1) {
                    $inform["warn"] = "You have already started the application for {$club_name}";
                } else {
                    if ($result == -2) {
                        $inform["error"] = "This club does not exist!";
                    } else {
                        if ($result == -3) {
                            $inform["error"] = "{$club_name} is not open yet! Try again after the open date!";
                        } else {
                            $inform["error"] = "Internal error!";
                        }
                    }
                }
            }
        } else {
            addSubscription($_SESSION['user_id'], $_REQUEST['club']);
            $inform["success"] = "Subscribed to {$club_name}! You will now recieve messages from {$club_name}";
        }
    }
    $clubList = listClubs();
    get_page_advanced("addclub", "apply", array("clubs" => $clubList, "inform" => $inform));
} else {
    get_page_advanced("message", "apply", array("title" => "Not Logged In", "message" => "You cannot access the application because you are not logged in. Please <a href=\"../login.php\">login first</a>."));
}