예제 #1
0
/**
* Set/Change Quotas
*/
function process_quota_settings($mode, $id, $quota_type, $quota_limit_id = 0)
{
    global $db;
    $id = (int) $id;
    $quota_type = (int) $quota_type;
    $quota_limit_id = (int) $quota_limit_id;
    if ($mode == 'user') {
        if (!$quota_limit_id) {
            $sql = 'DELETE FROM ' . QUOTA_TABLE . "\n\t\t\t\tWHERE user_id = {$id}\n\t\t\t\t\tAND quota_type = {$quota_type}";
        } else {
            // Check if user is already entered
            $sql = 'SELECT user_id 
				FROM ' . QUOTA_TABLE . " \n\t\t\t\tWHERE user_id = {$id}\n\t\t\t\t\tAND quota_type = {$quota_type}";
            if (!($result = $db->sql_query($sql))) {
                message_die(GENERAL_ERROR, 'Could not get Entry', '', __LINE__, __FILE__, $sql);
            }
            if ($db->sql_numrows($result) == 0) {
                $sql_ary = array('user_id' => (int) $id, 'group_id' => 0, 'quota_type' => (int) $quota_type, 'quota_limit_id' => (int) $quota_limit_id);
                $sql = 'INSERT INTO ' . QUOTA_TABLE . ' ' . attach_mod_sql_build_array('INSERT', $sql_ary);
            } else {
                $sql = 'UPDATE ' . QUOTA_TABLE . "\n\t\t\t\t\tSET quota_limit_id = {$quota_limit_id}\n\t\t\t\t\tWHERE user_id = {$id}\n\t\t\t\t\t\tAND quota_type = {$quota_type}";
            }
            $db->sql_freeresult($result);
        }
        if (!($result = $db->sql_query($sql))) {
            message_die(GENERAL_ERROR, 'Unable to update quota Settings', '', __LINE__, __FILE__, $sql);
        }
    } else {
        if ($mode == 'group') {
            if (!$quota_limit_id) {
                $sql = 'DELETE FROM ' . QUOTA_TABLE . " \n\t\t\t\tWHERE group_id = {$id} \n\t\t\t\t\tAND quota_type = {$quota_type}";
                if (!($result = $db->sql_query($sql))) {
                    message_die(GENERAL_ERROR, 'Unable to delete quota Settings', '', __LINE__, __FILE__, $sql);
                }
            } else {
                // Check if user is already entered
                $sql = 'SELECT group_id 
				FROM ' . QUOTA_TABLE . " \n\t\t\t\tWHERE group_id = {$id} \n\t\t\t\t\tAND quota_type = {$quota_type}";
                if (!($result = $db->sql_query($sql))) {
                    message_die(GENERAL_ERROR, 'Could not get Entry', '', __LINE__, __FILE__, $sql);
                }
                if ($db->sql_numrows($result) == 0) {
                    $sql = 'INSERT INTO ' . QUOTA_TABLE . " (user_id, group_id, quota_type, quota_limit_id) \n\t\t\t\t\tVALUES (0, {$id}, {$quota_type}, {$quota_limit_id})";
                } else {
                    $sql = 'UPDATE ' . QUOTA_TABLE . " SET quota_limit_id = {$quota_limit_id} \n\t\t\t\t\tWHERE group_id = {$id} AND quota_type = {$quota_type}";
                }
                if (!$db->sql_query($sql)) {
                    message_die(GENERAL_ERROR, 'Unable to update quota Settings', '', __LINE__, __FILE__, $sql);
                }
            }
        }
    }
}
예제 #2
0
/**
* Set/Change Quotas
*/
function process_quota_settings($mode, $id, $quota_type, $quota_limit_id = 0)
{
    $id = (int) $id;
    $quota_type = (int) $quota_type;
    $quota_limit_id = (int) $quota_limit_id;
    if ($mode == 'user') {
        if (!$quota_limit_id) {
            $sql = 'DELETE FROM ' . BB_QUOTA . "\n\t\t\t\tWHERE user_id = {$id}\n\t\t\t\t\tAND quota_type = {$quota_type}";
        } else {
            // Check if user is already entered
            $sql = 'SELECT user_id
				FROM ' . BB_QUOTA . "\n\t\t\t\tWHERE user_id = {$id}\n\t\t\t\t\tAND quota_type = {$quota_type}";
            if (!($result = DB()->sql_query($sql))) {
                bb_die('Could not get entry #1');
            }
            if (DB()->num_rows($result) == 0) {
                $sql_ary = array('user_id' => (int) $id, 'group_id' => 0, 'quota_type' => (int) $quota_type, 'quota_limit_id' => (int) $quota_limit_id);
                $sql = 'INSERT INTO ' . BB_QUOTA . ' ' . attach_mod_sql_build_array('INSERT', $sql_ary);
            } else {
                $sql = 'UPDATE ' . BB_QUOTA . "\n\t\t\t\t\tSET quota_limit_id = {$quota_limit_id}\n\t\t\t\t\tWHERE user_id = {$id}\n\t\t\t\t\t\tAND quota_type = {$quota_type}";
            }
            DB()->sql_freeresult($result);
        }
        if (!($result = DB()->sql_query($sql))) {
            bb_die('Unable to update quota settings');
        }
    } else {
        if ($mode == 'group') {
            if (!$quota_limit_id) {
                $sql = 'DELETE FROM ' . BB_QUOTA . "\n\t\t\t\tWHERE group_id = {$id}\n\t\t\t\t\tAND quota_type = {$quota_type}";
                if (!($result = DB()->sql_query($sql))) {
                    bb_die('Unable to delete quota settings');
                }
            } else {
                // Check if user is already entered
                $sql = 'SELECT group_id
				FROM ' . BB_QUOTA . "\n\t\t\t\tWHERE group_id = {$id}\n\t\t\t\t\tAND quota_type = {$quota_type}";
                if (!($result = DB()->sql_query($sql))) {
                    bb_die('Could not get entry #2');
                }
                if (DB()->num_rows($result) == 0) {
                    $sql = 'INSERT INTO ' . BB_QUOTA . " (user_id, group_id, quota_type, quota_limit_id)\n\t\t\t\t\tVALUES (0, {$id}, {$quota_type}, {$quota_limit_id})";
                } else {
                    $sql = 'UPDATE ' . BB_QUOTA . " SET quota_limit_id = {$quota_limit_id}\n\t\t\t\t\tWHERE group_id = {$id} AND quota_type = {$quota_type}";
                }
                if (!DB()->sql_query($sql)) {
                    bb_die('Unable to update quota settings');
                }
            }
        }
    }
}
        $db->sql_freeresult($result);
        if ($num_rows > 0) {
            for ($i = 0; $i < $num_rows; $i++) {
                if ($row[$i]['group_name'] == $extension_group) {
                    $error = TRUE;
                    if (isset($error_msg)) {
                        $error_msg .= '<br />';
                    }
                    $error_msg .= sprintf($lang['Extension_group_exist'], $extension_group);
                }
            }
        }
        if (!$error) {
            $filesize = $size_select == 'kb' ? round($filesize * 1024) : ($size_select == 'mb' ? round($filesize * 1048576) : $filesize);
            $sql_ary = array('group_name' => (string) $extension_group, 'cat_id' => (int) $cat_id, 'allow_group' => (int) $is_allowed, 'download_mode' => (int) $download_mode, 'upload_icon' => (string) $upload_icon, 'max_filesize' => (int) $filesize, 'forum_permissions' => '');
            $sql = 'INSERT INTO ' . EXTENSION_GROUPS_TABLE . ' ' . attach_mod_sql_build_array('INSERT', $sql_ary);
            if (!$db->sql_query($sql)) {
                message_die(GENERAL_ERROR, 'Could not add Extension Group', '', __LINE__, __FILE__, $sql);
            }
        }
    }
    if (!$error) {
        $message = $lang['Attach_config_updated'] . '<br /><br />' . sprintf($lang['Click_return_attach_config'], '<a href="' . append_sid("admin_extensions.{$phpEx}?mode=groups") . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid("index.{$phpEx}?pane=right") . '">', '</a>');
        message_die(GENERAL_MESSAGE, $message);
    }
}
if ($mode == 'groups') {
    // Extension Groups
    $template->set_filenames(array('body' => 'admin/attach_extension_groups.tpl'));
    if (!$size && !$submit) {
        $max_add_filesize = $attach_config['max_filesize'];
 /**
  * Basic Insert Attachment Handling for all Message Types
  */
 function do_insert_attachment($mode, $message_type, $message_id)
 {
     global $db, $upload_dir;
     if (intval($message_id) < 0) {
         return FALSE;
     }
     if ($message_type == 'pm') {
         global $userdata, $to_userdata;
         $post_id = 0;
         $privmsgs_id = (int) $message_id;
         $user_id_1 = (int) $userdata['user_id'];
         $user_id_2 = (int) $to_userdata['user_id'];
     } else {
         if ($message_type = 'post') {
             global $post_info, $userdata;
             $post_id = (int) $message_id;
             $privmsgs_id = 0;
             $user_id_1 = isset($post_info['poster_id']) ? (int) $post_info['poster_id'] : 0;
             $user_id_2 = 0;
             if (!$user_id_1) {
                 $user_id_1 = (int) $userdata['user_id'];
             }
         }
     }
     if ($mode == 'attach_list') {
         for ($i = 0; $i < sizeof($this->attachment_list); $i++) {
             if ($this->attachment_id_list[$i]) {
                 // update entry in db if attachment already stored in db and filespace
                 $sql = 'UPDATE ' . ATTACHMENTS_DESC_TABLE . " \n\t\t\t\t\t\tSET comment = '" . attach_mod_sql_escape($this->attachment_comment_list[$i]) . "'\n\t\t\t\t\t\tWHERE attach_id = " . $this->attachment_id_list[$i];
                 if (!$db->sql_query($sql)) {
                     message_die(GENERAL_ERROR, 'Unable to update the File Comment.', '', __LINE__, __FILE__, $sql);
                 }
             } else {
                 // insert attachment into db
                 $sql_ary = array('physical_filename' => (string) basename($this->attachment_list[$i]), 'real_filename' => (string) basename($this->attachment_filename_list[$i]), 'comment' => (string) $this->attachment_comment_list[$i], 'extension' => (string) strtolower($this->attachment_extension_list[$i]), 'mimetype' => (string) strtolower($this->attachment_mimetype_list[$i]), 'filesize' => (int) $this->attachment_filesize_list[$i], 'filetime' => (int) $this->attachment_filetime_list[$i], 'thumbnail' => (int) $this->attachment_thumbnail_list[$i]);
                 $sql = 'INSERT INTO ' . ATTACHMENTS_DESC_TABLE . ' ' . attach_mod_sql_build_array('INSERT', $sql_ary);
                 if (!$db->sql_query($sql)) {
                     message_die(GENERAL_ERROR, 'Couldn\'t store Attachment.<br />Your ' . $message_type . ' has been stored.', '', __LINE__, __FILE__, $sql);
                 }
                 $attach_id = $db->sql_nextid();
                 $sql_ary = array('attach_id' => (int) $attach_id, 'post_id' => (int) $post_id, 'privmsgs_id' => (int) $privmsgs_id, 'user_id_1' => (int) $user_id_1, 'user_id_2' => (int) $user_id_2);
                 $sql = 'INSERT INTO ' . ATTACHMENTS_TABLE . ' ' . attach_mod_sql_build_array('INSERT', $sql_ary);
                 if (!$db->sql_query($sql)) {
                     message_die(GENERAL_ERROR, 'Couldn\'t store Attachment.<br />Your ' . $message_type . ' has been stored.', '', __LINE__, __FILE__, $sql);
                 }
             }
         }
         return TRUE;
     }
     if ($mode == 'last_attachment') {
         if ($this->post_attach && !isset($HTTP_POST_VARS['update_attachment'])) {
             // insert attachment into db, here the user submited it directly
             $sql_ary = array('physical_filename' => (string) basename($this->attach_filename), 'real_filename' => (string) basename($this->filename), 'comment' => (string) $this->file_comment, 'extension' => (string) strtolower($this->extension), 'mimetype' => (string) strtolower($this->type), 'filesize' => (int) $this->filesize, 'filetime' => (int) $this->filetime, 'thumbnail' => (int) $this->thumbnail);
             $sql = 'INSERT INTO ' . ATTACHMENTS_DESC_TABLE . ' ' . attach_mod_sql_build_array('INSERT', $sql_ary);
             // Inform the user that his post has been created, but nothing is attached
             if (!$db->sql_query($sql)) {
                 message_die(GENERAL_ERROR, 'Couldn\'t store Attachment.<br />Your ' . $message_type . ' has been stored.', '', __LINE__, __FILE__, $sql);
             }
             $attach_id = $db->sql_nextid();
             $sql_ary = array('attach_id' => (int) $attach_id, 'post_id' => (int) $post_id, 'privmsgs_id' => (int) $privmsgs_id, 'user_id_1' => (int) $user_id_1, 'user_id_2' => (int) $user_id_2);
             $sql = 'INSERT INTO ' . ATTACHMENTS_TABLE . ' ' . attach_mod_sql_build_array('INSERT', $sql_ary);
             if (!$db->sql_query($sql)) {
                 message_die(GENERAL_ERROR, 'Couldn\'t store Attachment.<br />Your ' . $message_type . ' has been stored.', '', __LINE__, __FILE__, $sql);
             }
         }
     }
 }
예제 #5
0
    /**
     * Duplicate Attachment for sent PM
     */
    function duplicate_attachment_pm($switch_attachment, $original_privmsg_id, $new_privmsg_id)
    {
        global $db, $privmsg, $folder;
        if (($privmsg['privmsgs_type'] == PRIVMSGS_NEW_MAIL || $privmsg['privmsgs_type'] == PRIVMSGS_UNREAD_MAIL) && $folder == 'inbox' && intval($switch_attachment) == 1) {
            $sql = 'SELECT *
				FROM ' . ATTACHMENTS_TABLE . '
				WHERE privmsgs_id = ' . (int) $original_privmsg_id;
            if (!($result = $db->sql_query($sql))) {
                message_die(GENERAL_ERROR, 'Couldn\'t query Attachment Table', '', __LINE__, __FILE__, $sql);
            }
            $rows = $db->sql_fetchrowset($result);
            $num_rows = $db->sql_numrows($result);
            $db->sql_freeresult($result);
            if ($num_rows > 0) {
                for ($i = 0; $i < $num_rows; $i++) {
                    $sql_ary = array('attach_id' => (int) $rows[$i]['attach_id'], 'post_id' => (int) $rows[$i]['post_id'], 'privmsgs_id' => (int) $new_privmsg_id, 'user_id_1' => (int) $rows[$i]['user_id_1'], 'user_id_2' => (int) $rows[$i]['user_id_2']);
                    $sql = 'INSERT INTO ' . ATTACHMENTS_TABLE . ' ' . attach_mod_sql_build_array('INSERT', $sql_ary);
                    if (!($result = $db->sql_query($sql))) {
                        message_die(GENERAL_ERROR, 'Couldn\'t store Attachment for sent Private Message', '', __LINE__, __FILE__, $sql);
                    }
                }
                $sql = 'UPDATE ' . PRIVMSGS_TABLE . '
					SET privmsgs_attachment = 1
					WHERE privmsgs_id = ' . (int) $new_privmsg_id;
                if (!$db->sql_query($sql)) {
                    message_die(GENERAL_ERROR, 'Unable to update Private Message Table.', '', __LINE__, __FILE__, $sql);
                }
            }
        }
    }
예제 #6
0
 /**
  * Basic Insert Attachment Handling for all Message Types
  */
 function do_insert_attachment($mode, $message_type, $message_id)
 {
     global $upload_dir;
     if (intval($message_id) < 0) {
         return FALSE;
     }
     global $post_info, $userdata;
     $post_id = (int) $message_id;
     $user_id_1 = isset($post_info['poster_id']) ? (int) $post_info['poster_id'] : 0;
     if (!$user_id_1) {
         $user_id_1 = (int) $userdata['user_id'];
     }
     if ($mode == 'attach_list') {
         for ($i = 0; $i < sizeof($this->attachment_list); $i++) {
             if ($this->attachment_id_list[$i]) {
                 //bt
                 if ($this->attachment_extension_list[$i] === TORRENT_EXT && !defined('TORRENT_ATTACH_ID')) {
                     define('TORRENT_ATTACH_ID', $this->attachment_id_list[$i]);
                 }
                 //bt end
                 // update entry in db if attachment already stored in db and filespace
                 $sql = 'UPDATE ' . BB_ATTACHMENTS_DESC . "\n\t\t\t\t\t\tSET comment = '" . @attach_mod_sql_escape($this->attachment_comment_list[$i]) . "'\n\t\t\t\t\t\tWHERE attach_id = " . $this->attachment_id_list[$i];
                 if (!DB()->sql_query($sql)) {
                     bb_die('Unable to update the file comment');
                 }
             } else {
                 if (empty($this->attachment_mimetype_list[$i]) && $this->attachment_extension_list[$i] === TORRENT_EXT) {
                     $this->attachment_mimetype_list[$i] = 'application/x-bittorrent';
                 }
                 // insert attachment into db
                 $sql_ary = array('physical_filename' => (string) basename($this->attachment_list[$i]), 'real_filename' => (string) basename($this->attachment_filename_list[$i]), 'comment' => (string) @$this->attachment_comment_list[$i], 'extension' => (string) strtolower($this->attachment_extension_list[$i]), 'mimetype' => (string) strtolower($this->attachment_mimetype_list[$i]), 'filesize' => (int) $this->attachment_filesize_list[$i], 'filetime' => (int) $this->attachment_filetime_list[$i], 'thumbnail' => (int) $this->attachment_thumbnail_list[$i]);
                 $sql = 'INSERT INTO ' . BB_ATTACHMENTS_DESC . ' ' . attach_mod_sql_build_array('INSERT', $sql_ary);
                 if (!DB()->sql_query($sql)) {
                     bb_die('Could not store Attachment.<br />Your ' . $message_type . ' has been stored');
                 }
                 $attach_id = DB()->sql_nextid();
                 //bt
                 if ($this->attachment_extension_list[$i] === TORRENT_EXT && !defined('TORRENT_ATTACH_ID')) {
                     define('TORRENT_ATTACH_ID', $attach_id);
                 }
                 //bt end
                 $sql_ary = array('attach_id' => (int) $attach_id, 'post_id' => (int) $post_id, 'user_id_1' => (int) $user_id_1);
                 $sql = 'INSERT INTO ' . BB_ATTACHMENTS . ' ' . attach_mod_sql_build_array('INSERT', $sql_ary);
                 if (!DB()->sql_query($sql)) {
                     bb_die('Could not store Attachment.<br />Your ' . $message_type . ' has been stored');
                 }
             }
         }
         return TRUE;
     }
     if ($mode == 'last_attachment') {
         if ($this->post_attach && !isset($_POST['update_attachment'])) {
             // insert attachment into db, here the user submited it directly
             $sql_ary = array('physical_filename' => (string) basename($this->attach_filename), 'real_filename' => (string) basename($this->filename), 'comment' => (string) $this->file_comment, 'extension' => (string) strtolower($this->extension), 'mimetype' => (string) strtolower($this->type), 'filesize' => (int) $this->filesize, 'filetime' => (int) $this->filetime, 'thumbnail' => (int) $this->thumbnail);
             $sql = 'INSERT INTO ' . BB_ATTACHMENTS_DESC . ' ' . attach_mod_sql_build_array('INSERT', $sql_ary);
             // Inform the user that his post has been created, but nothing is attached
             if (!DB()->sql_query($sql)) {
                 bb_die('Could not store Attachment.<br />Your ' . $message_type . ' has been stored');
             }
             $attach_id = DB()->sql_nextid();
             $sql_ary = array('attach_id' => (int) $attach_id, 'post_id' => (int) $post_id, 'user_id_1' => (int) $user_id_1);
             $sql = 'INSERT INTO ' . BB_ATTACHMENTS . ' ' . attach_mod_sql_build_array('INSERT', $sql_ary);
             if (!DB()->sql_query($sql)) {
                 bb_die('Could not store Attachment.<br />Your ' . $message_type . ' has been stored');
             }
         }
     }
 }