mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-20 13:24:01 -07:00
Some cleanup (#1255)
This commit is contained in:
parent
912838cd1a
commit
f483aa273b
5 changed files with 11 additions and 77 deletions
|
@ -93,7 +93,7 @@ if ($submit && $mode == 'extensions') {
|
||||||
'group_id' => (int)$extensions['_' . $extension_row[$i]['ext_id']]['group_id']
|
'group_id' => (int)$extensions['_' . $extension_row[$i]['ext_id']]['group_id']
|
||||||
);
|
);
|
||||||
|
|
||||||
$sql = 'UPDATE ' . BB_EXTENSIONS . ' SET ' . attach_mod_sql_build_array('UPDATE', $sql_ary) . '
|
$sql = 'UPDATE ' . BB_EXTENSIONS . ' SET ' . DB()->build_array('UPDATE', $sql_ary) . '
|
||||||
WHERE ext_id = ' . (int)$extension_row[$i]['ext_id'];
|
WHERE ext_id = ' . (int)$extension_row[$i]['ext_id'];
|
||||||
|
|
||||||
if (!DB()->sql_query($sql)) {
|
if (!DB()->sql_query($sql)) {
|
||||||
|
@ -159,7 +159,7 @@ if ($submit && $mode == 'extensions') {
|
||||||
'comment' => (string)$extension_explain
|
'comment' => (string)$extension_explain
|
||||||
);
|
);
|
||||||
|
|
||||||
$sql = 'INSERT INTO ' . BB_EXTENSIONS . ' ' . attach_mod_sql_build_array('INSERT', $sql_ary);
|
$sql = 'INSERT INTO ' . BB_EXTENSIONS . ' ' . DB()->build_array('INSERT', $sql_ary);
|
||||||
|
|
||||||
if (!DB()->sql_query($sql)) {
|
if (!DB()->sql_query($sql)) {
|
||||||
bb_die('Could not add extension');
|
bb_die('Could not add extension');
|
||||||
|
@ -260,7 +260,7 @@ if ($submit && $mode == 'groups') {
|
||||||
'max_filesize' => (int)$filesize_list[$i]
|
'max_filesize' => (int)$filesize_list[$i]
|
||||||
);
|
);
|
||||||
|
|
||||||
$sql = 'UPDATE ' . BB_EXTENSION_GROUPS . ' SET ' . attach_mod_sql_build_array('UPDATE', $sql_ary) . '
|
$sql = 'UPDATE ' . BB_EXTENSION_GROUPS . ' SET ' . DB()->build_array('UPDATE', $sql_ary) . '
|
||||||
WHERE group_id = ' . (int)$group_change_list[$i];
|
WHERE group_id = ' . (int)$group_change_list[$i];
|
||||||
|
|
||||||
if (!DB()->sql_query($sql)) {
|
if (!DB()->sql_query($sql)) {
|
||||||
|
@ -340,7 +340,7 @@ if ($submit && $mode == 'groups') {
|
||||||
'forum_permissions' => ''
|
'forum_permissions' => ''
|
||||||
);
|
);
|
||||||
|
|
||||||
$sql = 'INSERT INTO ' . BB_EXTENSION_GROUPS . ' ' . attach_mod_sql_build_array('INSERT', $sql_ary);
|
$sql = 'INSERT INTO ' . BB_EXTENSION_GROUPS . ' ' . DB()->build_array('INSERT', $sql_ary);
|
||||||
|
|
||||||
if (!DB()->sql_query($sql)) {
|
if (!DB()->sql_query($sql)) {
|
||||||
bb_die('Could not add extension group');
|
bb_die('Could not add extension group');
|
||||||
|
|
|
@ -54,9 +54,7 @@ VALUES ('upload_dir', 'data/torrent_files'),
|
||||||
('img_link_width', '600'),
|
('img_link_width', '600'),
|
||||||
('img_link_height', '400'),
|
('img_link_height', '400'),
|
||||||
('img_create_thumbnail', '1'),
|
('img_create_thumbnail', '1'),
|
||||||
('img_min_thumb_filesize', '12000'),
|
('img_min_thumb_filesize', '12000');
|
||||||
('wma_autoplay', '0'),
|
|
||||||
('flash_autoplay', '0');
|
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Table structure for `bb_attachments_desc`
|
-- Table structure for `bb_attachments_desc`
|
||||||
|
|
|
@ -38,7 +38,7 @@ function process_quota_settings($mode, $id, $quota_type, $quota_limit_id = 0)
|
||||||
'quota_type' => (int)$quota_type,
|
'quota_type' => (int)$quota_type,
|
||||||
'quota_limit_id' => (int)$quota_limit_id
|
'quota_limit_id' => (int)$quota_limit_id
|
||||||
];
|
];
|
||||||
$sql = 'INSERT INTO ' . BB_QUOTA . ' ' . attach_mod_sql_build_array('INSERT', $sql_ary);
|
$sql = 'INSERT INTO ' . BB_QUOTA . ' ' . DB()->build_array('INSERT', $sql_ary);
|
||||||
} else {
|
} else {
|
||||||
$sql = 'UPDATE ' . BB_QUOTA . "
|
$sql = 'UPDATE ' . BB_QUOTA . "
|
||||||
SET quota_limit_id = $quota_limit_id
|
SET quota_limit_id = $quota_limit_id
|
||||||
|
|
|
@ -387,67 +387,3 @@ function get_var($var_name, $default, $multibyte = false)
|
||||||
|
|
||||||
return $var;
|
return $var;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Build sql statement from array for insert/update/select statements
|
|
||||||
*
|
|
||||||
* Idea for this from Ikonboard
|
|
||||||
* Possible query values: INSERT, INSERT_SELECT, MULTI_INSERT, UPDATE, SELECT
|
|
||||||
*/
|
|
||||||
function attach_mod_sql_build_array($query, $assoc_ary = false)
|
|
||||||
{
|
|
||||||
if (!is_array($assoc_ary)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$fields = [];
|
|
||||||
$values = [];
|
|
||||||
if ($query == 'INSERT' || $query == 'INSERT_SELECT') {
|
|
||||||
foreach ($assoc_ary as $key => $var) {
|
|
||||||
$fields[] = $key;
|
|
||||||
|
|
||||||
if (null === $var) {
|
|
||||||
$values[] = 'NULL';
|
|
||||||
} elseif (is_string($var)) {
|
|
||||||
$values[] = "'" . DB()->escape($var) . "'";
|
|
||||||
} elseif (is_array($var) && is_string($var[0])) {
|
|
||||||
$values[] = $var[0];
|
|
||||||
} else {
|
|
||||||
$values[] = (is_bool($var)) ? (int)$var : $var;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$query = ($query == 'INSERT') ? ' (' . implode(', ', $fields) . ') VALUES (' . implode(', ', $values) . ')' : ' (' . implode(', ', $fields) . ') SELECT ' . implode(', ', $values) . ' ';
|
|
||||||
} elseif ($query == 'MULTI_INSERT') {
|
|
||||||
$ary = [];
|
|
||||||
foreach ($assoc_ary as $id => $sql_ary) {
|
|
||||||
$values = [];
|
|
||||||
foreach ($sql_ary as $key => $var) {
|
|
||||||
if (null === $var) {
|
|
||||||
$values[] = 'NULL';
|
|
||||||
} elseif (is_string($var)) {
|
|
||||||
$values[] = "'" . DB()->escape($var) . "'";
|
|
||||||
} else {
|
|
||||||
$values[] = (is_bool($var)) ? (int)$var : $var;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$ary[] = '(' . implode(', ', $values) . ')';
|
|
||||||
}
|
|
||||||
|
|
||||||
$query = ' (' . implode(', ', array_keys($assoc_ary[0])) . ') VALUES ' . implode(', ', $ary);
|
|
||||||
} elseif ($query == 'UPDATE' || $query == 'SELECT') {
|
|
||||||
$values = [];
|
|
||||||
foreach ($assoc_ary as $key => $var) {
|
|
||||||
if (null === $var) {
|
|
||||||
$values[] = "$key = NULL";
|
|
||||||
} elseif (is_string($var)) {
|
|
||||||
$values[] = "$key = '" . DB()->escape($var) . "'";
|
|
||||||
} else {
|
|
||||||
$values[] = (is_bool($var)) ? "$key = " . (int)$var : "$key = $var";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$query = implode(($query == 'UPDATE') ? ', ' : ' AND ', $values);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $query;
|
|
||||||
}
|
|
||||||
|
|
|
@ -454,7 +454,7 @@ class Attach
|
||||||
'thumbnail' => (int)$this->thumbnail
|
'thumbnail' => (int)$this->thumbnail
|
||||||
];
|
];
|
||||||
|
|
||||||
$sql = 'UPDATE ' . BB_ATTACHMENTS_DESC . ' SET ' . attach_mod_sql_build_array('UPDATE', $sql_ary) . '
|
$sql = 'UPDATE ' . BB_ATTACHMENTS_DESC . ' SET ' . DB()->build_array('UPDATE', $sql_ary) . '
|
||||||
WHERE attach_id = ' . (int)$attachment_id;
|
WHERE attach_id = ' . (int)$attachment_id;
|
||||||
|
|
||||||
if (!(DB()->sql_query($sql))) {
|
if (!(DB()->sql_query($sql))) {
|
||||||
|
@ -573,7 +573,7 @@ class Attach
|
||||||
'thumbnail' => (int)$this->attachment_thumbnail_list[$i]
|
'thumbnail' => (int)$this->attachment_thumbnail_list[$i]
|
||||||
];
|
];
|
||||||
|
|
||||||
$sql = 'INSERT INTO ' . BB_ATTACHMENTS_DESC . ' ' . attach_mod_sql_build_array('INSERT', $sql_ary);
|
$sql = 'INSERT INTO ' . BB_ATTACHMENTS_DESC . ' ' . DB()->build_array('INSERT', $sql_ary);
|
||||||
|
|
||||||
if (!(DB()->sql_query($sql))) {
|
if (!(DB()->sql_query($sql))) {
|
||||||
bb_die('Could not store Attachment.<br />Your ' . $message_type . ' has been stored');
|
bb_die('Could not store Attachment.<br />Your ' . $message_type . ' has been stored');
|
||||||
|
@ -593,7 +593,7 @@ class Attach
|
||||||
'user_id_1' => (int)$user_id_1,
|
'user_id_1' => (int)$user_id_1,
|
||||||
];
|
];
|
||||||
|
|
||||||
$sql = 'INSERT INTO ' . BB_ATTACHMENTS . ' ' . attach_mod_sql_build_array('INSERT', $sql_ary);
|
$sql = 'INSERT INTO ' . BB_ATTACHMENTS . ' ' . DB()->build_array('INSERT', $sql_ary);
|
||||||
|
|
||||||
if (!(DB()->sql_query($sql))) {
|
if (!(DB()->sql_query($sql))) {
|
||||||
bb_die('Could not store Attachment.<br />Your ' . $message_type . ' has been stored');
|
bb_die('Could not store Attachment.<br />Your ' . $message_type . ' has been stored');
|
||||||
|
@ -618,7 +618,7 @@ class Attach
|
||||||
'thumbnail' => (int)$this->thumbnail
|
'thumbnail' => (int)$this->thumbnail
|
||||||
];
|
];
|
||||||
|
|
||||||
$sql = 'INSERT INTO ' . BB_ATTACHMENTS_DESC . ' ' . attach_mod_sql_build_array('INSERT', $sql_ary);
|
$sql = 'INSERT INTO ' . BB_ATTACHMENTS_DESC . ' ' . DB()->build_array('INSERT', $sql_ary);
|
||||||
|
|
||||||
// Inform the user that his post has been created, but nothing is attached
|
// Inform the user that his post has been created, but nothing is attached
|
||||||
if (!(DB()->sql_query($sql))) {
|
if (!(DB()->sql_query($sql))) {
|
||||||
|
@ -633,7 +633,7 @@ class Attach
|
||||||
'user_id_1' => (int)$user_id_1,
|
'user_id_1' => (int)$user_id_1,
|
||||||
];
|
];
|
||||||
|
|
||||||
$sql = 'INSERT INTO ' . BB_ATTACHMENTS . ' ' . attach_mod_sql_build_array('INSERT', $sql_ary);
|
$sql = 'INSERT INTO ' . BB_ATTACHMENTS . ' ' . DB()->build_array('INSERT', $sql_ary);
|
||||||
|
|
||||||
if (!(DB()->sql_query($sql))) {
|
if (!(DB()->sql_query($sql))) {
|
||||||
bb_die('Could not store Attachment.<br />Your ' . $message_type . ' has been stored');
|
bb_die('Could not store Attachment.<br />Your ' . $message_type . ' has been stored');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue