Exemplo n.º 1
0
                //delete the item from the db
                $sql = 'DELETE FROM ' . EMAILSHOT_ATTACHMENTS . ' WHERE mailshot_id=' . $_GET['mail_id'];
                $res = wrap_db_query($sql);
            }
        }
        $page_info_message = 'E-mail deleted successfully.';
    }
}
//check for email mailshot form submission
if ($_POST['send_mail'] == 'yes') {
    //store the mail in the db
    $query = "INSERT INTO " . EMAILSHOT_SENT_EMAILS . " ( email_id, sent_by_user_id, from_name, from_email, cc_me, subject, body, sent ) VALUES ( '', '" . $user_info['user_id'] . "', '" . mysql_real_escape_string($_POST['email_from_name']) . "', '" . mysql_real_escape_string($_POST['email_from_email']) . "', '" . mysql_real_escape_string($_POST['email_cc_me']) . "', '" . mysql_real_escape_string($_POST['email_subject']) . "', '" . mysql_real_escape_string($_POST['email_body']) . "', NOW() );";
    //echo "<hr>$query" ;
    if ($result = wrap_db_query($query)) {
        //get the email_id (auto) for the mail just added to the sent emails table
        $thisEmailID = wrap_db_insert_id();
        //link in all the groups this mail is being sent to
        $numGroupIDs = count($_POST['group_ids']);
        for ($g = 0; $g < $numGroupIDs; $g++) {
            $query = "INSERT INTO " . EMAILSHOT_SENT_TO_GROUPS . " ( id, email_id, group_id ) VALUES ( '', '" . $thisEmailID . "', '" . mysql_real_escape_string($_POST['group_ids'][$g]) . "' );";
            //echo "<hr>$query" ;
            $result = wrap_db_query($query);
        }
        //link in all the users this mail is being sent to
        $numUserIDs = count($_POST['user_ids']);
        for ($u = 0; $u < $numUserIDs; $u++) {
            $query = "INSERT INTO " . EMAILSHOT_SENT_TO_USERS . " ( id, email_id, user_id ) VALUES ( '', '" . $thisEmailID . "', '" . mysql_real_escape_string($_POST['user_ids'][$u]) . "' );";
            //echo "<hr>$query" ;
            $result = wrap_db_query($query);
        }
        //link in any attachments and map these into an attacments array at the same time ready for passing to the send_mail function
Exemplo n.º 2
0
function add_event($username, $scheduled_date_time_data, $subject, $location, $starting_date_time, $ending_date_time, $recur_interval, $recur_freq, $recur_until_date, $description, $bookingOptions)
{
    // Add new want to the database
    // Use global $location_db_name
    global $location_db_name;
    // Check for repeat event; 'double click'
    // This might be removed in the future due to a future JavaScript function.
    $result = wrap_db_query("SELECT event_id FROM " . BOOKING_USER_TABLE . ", " . BOOKING_EVENT_TABLE . "\n\t\t\t\t\t\tWHERE " . BOOKING_USER_TABLE . ".username='******' AND\n\t\t\t\t\t\t" . BOOKING_USER_TABLE . ".user_id = " . BOOKING_EVENT_TABLE . ".user_id AND\n\t\t\t\t\t\t" . BOOKING_EVENT_TABLE . ".subject = '" . $subject . "' AND\n\t\t\t\t\t\t" . BOOKING_EVENT_TABLE . ".location = '" . $location . "' AND\n\t\t\t\t\t\t" . BOOKING_EVENT_TABLE . ".starting_date_time = '" . $starting_date_time . "' AND\n\t\t\t\t\t\t" . BOOKING_EVENT_TABLE . ".ending_date_time = '" . $ending_date_time . "' AND\n\t\t\t\t\t\t" . BOOKING_EVENT_TABLE . ".recur_interval = '" . $recur_interval . "' AND\n\t\t\t\t\t\t" . BOOKING_EVENT_TABLE . ".recur_freq = " . $recur_freq . " AND\n\t\t\t\t\t\t" . BOOKING_EVENT_TABLE . ".recur_until_date = '" . $recur_until_date . "' AND\n\t\t\t\t\t\t" . BOOKING_EVENT_TABLE . ".description = '" . $description . "'");
    //echo "Duplicate Rows: " . wrap_db_num_rows($result) . "<br />";
    if ($result && wrap_db_num_rows($result) > 0) {
        return false;
    }
    // get user_id based on current $username
    $user_id = get_user_id($username);
    if (empty($user_id)) {
        return false;
    }
    // insert the new bookmark
    $result = wrap_db_query("INSERT INTO " . BOOKING_EVENT_TABLE . " SET\n\t\t\t\t\t\tuser_id = " . $user_id . ",\n\t\t\t\t\t\tsubject = '" . $subject . "',\n\t\t\t\t\t\tlocation = '" . $location . "',\n\t\t\t\t\t\tstarting_date_time = '" . $starting_date_time . "',\n\t\t\t\t\t\tending_date_time = '" . $ending_date_time . "',\n\t\t\t\t\t\trecur_interval = '" . $recur_interval . "',\n\t\t\t\t\t\trecur_freq = " . $recur_freq . ",\n\t\t\t\t\t\trecur_until_date = '" . $recur_until_date . "',\n\t\t\t\t\t\tdescription = '" . $description . "',\n\t\t\t\t\t\tdate_time_added = NOW(),\n\t\t\t\t\t\tlast_mod_by_id = '" . $user_id . "',\n\t\t\t\t\t\tlast_mod_date_time = NOW()");
    if (!$result) {
        return false;
    }
    // Get the event_id (auto) for the event just added to the event table.
    $event_id = wrap_db_insert_id();
    // Insert the event_id into the schedule table at the appropriate date-time slots.
    $add_date_time_error = false;
    foreach ($scheduled_date_time_data as $date_time) {
        $result = wrap_db_query("UPDATE " . DATE_TIME_SCHEDULE_TABLE . "\n\t\t\t\t\t\tSET " . $location_db_name[$location] . " = " . $event_id . "\n\t\t\t\t\t\tWHERE schedule_date_time = '" . $date_time . "' AND\n\t\t\t\t\t\t" . $location_db_name[$location] . " = 0");
        //echo "location: $location, event_id: $event_id <br />";
        if (!$result) {
            $add_date_time_error = true;
        }
    }
    if ($add_date_time_error == true) {
        // Delete Event Info Function needs to be added here!
        echo "ERROR! A date and time slot could not be filled properly!<br />";
        return false;
    }
    //add the option id's chosen to go with this booking
    $numBookingOptions = count($bookingOptions);
    for ($o = 0; $o < $numBookingOptions; $o++) {
        $query = "INSERT INTO " . BOOKING_EVENT_OPTIONS_TABLE . " SET event_id = " . $event_id . ", option_id = '" . $bookingOptions[$o] . "'";
        wrap_db_query($query);
    }
    // Table maintenance
    if (!defined(PURGE_TABLE_SCHEDULE_DAYS)) {
        define(PURGE_TABLE_SCHEDULE_DAYS, 365);
    }
    $result = wrap_db_query("DELETE FROM " . DATE_TIME_SCHEDULE_TABLE . " WHERE schedule_date_time < DATE_SUB(CURDATE(), INTERVAL " . PURGE_TABLE_SCHEDULE_DAYS . " DAY )");
    $result = wrap_db_query("ALTER TABLE " . DATE_TIME_SCHEDULE_TABLE . " ORDER BY schedule_date_time");
    $result = wrap_db_query("OPTIMIZE TABLE " . DATE_TIME_SCHEDULE_TABLE);
    return $event_id;
}
Exemplo n.º 3
0
function add_event($username, $scheduled_date_time_data, $subject, $location, $starting_date_time, $ending_date_time, $recur_interval, $recur_freq, $recur_until_date, $description)
{
    // Add new event to the database
    // Use global $location_db_name
    global $location_db_name;
    // Check for repeat event; 'double click'
    // This might be removed in the future due to a future JavaScript function.
    $result = wrap_db_query("SELECT event_id FROM " . BOOKING_USER_TABLE . ", " . BOOKING_EVENT_TABLE . " \r\n\t\t\t\t\t\tWHERE " . BOOKING_USER_TABLE . ".username='******' AND\r\n\t\t\t\t\t\t" . BOOKING_USER_TABLE . ".user_id = " . BOOKING_EVENT_TABLE . ".user_id AND \r\n\t\t\t\t\t\t" . BOOKING_EVENT_TABLE . ".subject = '" . wrap_db_escape_string($subject) . "' AND \r\n\t\t\t\t\t\t" . BOOKING_EVENT_TABLE . ".location = '" . wrap_db_escape_string($location) . "' AND \r\n\t\t\t\t\t\t" . BOOKING_EVENT_TABLE . ".starting_date_time = '" . wrap_db_escape_string($starting_date_time) . "' AND \r\n\t\t\t\t\t\t" . BOOKING_EVENT_TABLE . ".ending_date_time = '" . wrap_db_escape_string($ending_date_time) . "' AND \r\n\t\t\t\t\t\t" . BOOKING_EVENT_TABLE . ".recur_interval = '" . wrap_db_escape_string($recur_interval) . "' AND \r\n\t\t\t\t\t\t" . BOOKING_EVENT_TABLE . ".recur_freq = " . wrap_db_escape_string($recur_freq) . " AND \r\n\t\t\t\t\t\t" . BOOKING_EVENT_TABLE . ".recur_until_date = '" . wrap_db_escape_string($recur_until_date) . "' AND \r\n\t\t\t\t\t\t" . BOOKING_EVENT_TABLE . ".description = '" . wrap_db_escape_string($description) . "'");
    //echo "Duplicate Rows: " . wrap_db_num_rows($result) . "<br />";
    if ($result && wrap_db_num_rows($result) > 0) {
        return false;
    }
    // get user_id based on current $username
    $user_id = get_user_id($username);
    if (empty($user_id)) {
        return false;
    }
    // insert the new event
    $result = wrap_db_query("INSERT INTO " . BOOKING_EVENT_TABLE . " SET \r\n\t\t\t\t\t\tuser_id = " . wrap_db_escape_string($user_id) . ", \r\n\t\t\t\t\t\tsubject = '" . wrap_db_escape_string($subject) . "', \r\n\t\t\t\t\t\tlocation = '" . wrap_db_escape_string($location) . "', \r\n\t\t\t\t\t\tstarting_date_time = '" . wrap_db_escape_string($starting_date_time) . "', \r\n\t\t\t\t\t\tending_date_time = '" . wrap_db_escape_string($ending_date_time) . "', \r\n\t\t\t\t\t\trecur_interval = '" . wrap_db_escape_string($recur_interval) . "', \r\n\t\t\t\t\t\trecur_freq = " . wrap_db_escape_string($recur_freq) . ", \r\n\t\t\t\t\t\trecur_until_date = '" . wrap_db_escape_string($recur_until_date) . "', \r\n\t\t\t\t\t\tdescription = '" . wrap_db_escape_string($description) . "', \r\n\t\t\t\t\t\tdate_time_added = NOW(), \r\n\t\t\t\t\t\tlast_mod_by_id = '', \r\n\t\t\t\t\t\tlast_mod_date_time = '0000-00-00 00:00:00'");
    if (!$result) {
        return false;
    }
    // Get the event_id (auto) for the event just added to the event table.
    $event_id = wrap_db_insert_id();
    // Insert the event_id into the schedule table at the appropriate date-time slots.
    $add_date_time_error = false;
    foreach ($scheduled_date_time_data as $date_time) {
        $result = wrap_db_query("UPDATE " . DATE_TIME_SCHEDULE_TABLE . " \r\n\t\t\t\t\t\tSET " . $location_db_name[$location] . " = " . wrap_db_escape_string($event_id) . " \r\n\t\t\t\t\t\tWHERE schedule_date_time = '" . wrap_db_escape_string($date_time) . "' AND \r\n\t\t\t\t\t\t" . $location_db_name[$location] . " = 0");
        //echo "location: $location, event_id: $event_id <br />";
        if (!$result) {
            $add_date_time_error = true;
        }
    }
    if ($add_date_time_error == true) {
        // Delete Event Info Function needs to be added here!
        echo "ERROR! A date and time slot could not be filled properly!<br />";
        return false;
    }
    return $event_id;
}