| 1 |
<?php</span> |
|---|
| 2 |
<span class="code-lang">$root_path = './'; |
|---|
| 3 |
require ($root_path . 'include/config.php'); |
|---|
| 4 |
require ($root_path . 'languages/lang_' . $config['default_lang'] . '/lang_upload_templates.php'); |
|---|
| 5 |
|
|---|
| 6 |
$userdata = session_pagestart($user_ip); |
|---|
| 7 |
init_userprefs($userdata); |
|---|
| 8 |
loggedinorreturn(); |
|---|
| 9 |
|
|---|
| 10 |
$action = ( isset($_POST['action']) ? $_POST['action'] : ( isset($_GET['action']) ? $_GET['action'] : 'add' ) );</span> |
|---|
| 11 |
<span class="code-lang"> |
|---|
| 12 |
if ($userdata['class'] < UC_ADMINISTRATOR) { |
|---|
| 13 |
trigger_error($lang['access_denied']); |
|---|
| 14 |
} |
|---|
| 15 |
|
|---|
| 16 |
switch ($action) { |
|---|
| 17 |
case 'autoadd' : |
|---|
| 18 |
$id = ( isset($_GET['id']) ? intval($_GET['id']) : 0 ); |
|---|
| 19 |
$sql = 'SELECT descr FROM ' . TORRENTS_TABLE . ' WHERE fid = ' . $id; |
|---|
| 20 |
$result = $db->sql_query($sql); |
|---|
| 21 |
if ( !( $row = $db->sql_fetchrow($result) ) ) { |
|---|
| 22 |
trigger_error( sprintf($lang['invalid_id'], $id) ); |
|---|
| 23 |
} |
|---|
| 24 |
|
|---|
| 25 |
if ( ( strpos($row['descr'], $lang['info_about_movie']) ) || ( strpos($row['descr'], $lang['info_about_mult']) ) ) { |
|---|
| 26 |
$type = 'movie'; |
|---|
| 27 |
} |
|---|
| 28 |
elseif ( ( strpos($row['descr'], $lang['developer']) ) && ( strpos($row['descr'], $lang['features_of_game']) ) ) { |
|---|
| 29 |
$type = 'game'; |
|---|
| 30 |
} |
|---|
| 31 |
elseif ( ( strpos($row['descr'], $lang['artist']) ) && ( strpos($row['descr'], $lang['tracklist']) ) ) { |
|---|
| 32 |
$type = 'music'; |
|---|
| 33 |
} |
|---|
| 34 |
else { |
|---|
| 35 |
trigger_error($lang['unable_auto_add']); |
|---|
| 36 |
} |
|---|
| 37 |
$cover = $descr = $imdb_link = ''; |
|---|
| 38 |
$topic_link = 0; |
|---|
| 39 |
switch ( $type ) { |
|---|
| 40 |
case 'movie': |
|---|
| 41 |
|
|---|
| 42 |
if ( preg_match('/\[img\](.*?)\[\/img\]/si', $row['descr'], $matches) ) { |
|---|
| 43 |
$cover = $matches[1]; |
|---|
| 44 |
} |
|---|
| 45 |
|
|---|
| 46 |
if ( preg_match('/(\[b\]' . $lang['genre'] . ": \[\/b\].*?)\n\[url=(http:\/\/(www.|us.|)imdb.com(.*))\]\[b\]IMDB/si", $row['descr'], $matches) ) { |
|---|
| 47 |
$descr = trim($matches[1]); |
|---|
| 48 |
$imdb_link = $matches[2]; |
|---|
| 49 |
} |
|---|
| 50 |
|
|---|
| 51 |
elseif ( preg_match('/(\[b\]' . $lang['genre'] . ": \[\/b\].*?)\n\[b]" . $lang['studio'] . '/si', $row['descr'], $matches) ) { |
|---|
| 52 |
$descr = trim($matches[1]); |
|---|
| 53 |
} |
|---|
| 54 |
break; |
|---|
| 55 |
|
|---|
| 56 |
case 'game': |
|---|
| 57 |
if ( preg_match('/\[img\](.*?)\[\/img\]/si', $row['descr'], $matches) ) { |
|---|
| 58 |
$cover = $matches[1]; |
|---|
| 59 |
} |
|---|
| 60 |
if ( preg_match('/(\[b\]' . $lang['developer'] . ':\[\/b\].*?)\[b\]' . $lang['features_of_game'] . '/si', $row['descr'], $matches) ) { |
|---|
| 61 |
$descr = trim($matches[1]); |
|---|
| 62 |
} |
|---|
| 63 |
break; |
|---|
| 64 |
|
|---|
| 65 |
case 'music': |
|---|
| 66 |
if ( preg_match('/\[img\](.*?)\[\/img\]/si', $row['descr'], $matches) ) { |
|---|
| 67 |
$cover = $matches[1]; |
|---|
| 68 |
} |
|---|
| 69 |
if ( preg_match('/(\[pre\]' . $lang['artist'] . ": .*?)\n" . $lang['tracklist'] . '/si', $row['descr'], $matches) ) { |
|---|
| 70 |
$descr = trim($matches[1]) . '[/pre]'; |
|---|
| 71 |
} |
|---|
| 72 |
break; |
|---|
| 73 |
} |
|---|
| 74 |
|
|---|
| 75 |
if ( !$descr || !$cover ) { |
|---|
| 76 |
trigger_error($lang['unable_auto_add']); |
|---|
| 77 |
} |
|---|
| 78 |
if ( preg_match('/\[url=.*?phpbb2.php\?.*?t=([0-9]+).*?\]\[b\]' . $lang['discussion_of_it_torrent_passes_at_forum'] . '/', $row['descr'], $matches) ) { |
|---|
| 79 |
$topic_link = intval($matches[1]); |
|---|
| 80 |
} |
|---|
| 81 |
|
|---|
| 82 |
elseif ( preg_match('/\[url=.*?phpbb2.php\?.*?p=([0-9]+).*?\]\[b\]' . $lang['discussion_of_it_torrent_passes_at_forum'] . '/', $row['descr'], $matches) ) { |
|---|
| 83 |
$sql = 'SELECT topic_id FROM ' . POSTS_TABLE . ' WHERE post_id = ' . intval($matches[1]); |
|---|
| 84 |
$result = $db->sql_query($sql); |
|---|
| 85 |
$topic_link = ( $topic_row = $db->sql_fetchrow($result) ) ? $topic_row['topic_id'] : 0; |
|---|
| 86 |
} |
|---|
| 87 |
|
|---|
| 88 |
$cache->destroy('sql', INDEXRELEASES_TABLE); |
|---|
| 89 |
|
|---|
| 90 |
$sql = 'INSERT INTO ' . INDEXRELEASES_TABLE . ' ' . $db->sql_build_array('INSERT', array( |
|---|
| 91 |
'cover' => $cover, |
|---|
| 92 |
'description' => $descr, |
|---|
| 93 |
'torrent_id' => $id, |
|---|
| 94 |
'imdb_link' => $imdb_link, |
|---|
| 95 |
'forum_link' => $topic_link )); |
|---|
| 96 |
$db->sql_query($sql); |
|---|
| 97 |
redirect( append_sid('index.php')); |
|---|
| 98 |
break; |
|---|
| 99 |
|
|---|
| 100 |
|
|---|
| 101 |
case 'add': |
|---|
| 102 |
$id = ( isset($_GET['id']) ? intval($_GET['id']) : 0 ); |
|---|
| 103 |
if ( $id ) { |
|---|
| 104 |
$sql = 'SELECT * FROM ' . INDEXRELEASES_TABLE . ' WHERE id=' . $id; |
|---|
| 105 |
$result = $db->sql_query($sql); |
|---|
| 106 |
if ( !( $arr = $db->sql_fetchrow($result) ) ) { |
|---|
| 107 |
trigger_error(sprintf($lang['invalid_id'], $id)); |
|---|
| 108 |
} |
|---|
| 109 |
} |
|---|
| 110 |
if ( isset($_POST['submit']) ) { |
|---|
| 111 |
$name = ( isset($_POST['name']) ? htmlspecialchars(trim($_POST['name'])) : '' ); |
|---|
| 112 |
$cover = ( isset($_POST['cover']) ? htmlspecialchars(trim($_POST['cover'])) : '' ); |
|---|
| 113 |
$descr = ( isset($_POST['description']) ? htmlspecialchars(trim($_POST['description'])) : '' ); |
|---|
| 114 |
$imdb_link = ( isset($_POST['imdb_link']) ? htmlspecialchars(trim($_POST['imdb_link'])) : '' ); |
|---|
| 115 |
$topic_link = ( isset($_POST['forum_link']) ? intval($_POST['forum_link']) : 0 ); |
|---|
| 116 |
$torrent_id = ( isset($_POST['link']) ? intval($_POST['link']) : '' ); |
|---|
| 117 |
|
|---|
| 118 |
if ( !$cover || !$descr ) { |
|---|
| 119 |
trigger_error($lang['post_something']); |
|---|
| 120 |
} |
|---|
| 121 |
$sql = 'SELECT name FROM ' . TORRENTS_TABLE . ' WHERE fid = ' . $torrent_id; |
|---|
| 122 |
$result = $db->sql_query($sql); |
|---|
| 123 |
if ( !($row = $db->sql_fetchrow($result)) ) { |
|---|
| 124 |
trigger_error( sprintf($lang['invalid_id'], $torrent_id) ); |
|---|
| 125 |
} |
|---|
| 126 |
|
|---|
| 127 |
if ( $id ) { |
|---|
| 128 |
$sql = 'UPDATE ' . INDEXRELEASES_TABLE . ' SET ' . $db->sql_build_array('UPDATE', array( |
|---|
| 129 |
'name' => $name, |
|---|
| 130 |
'cover' => $cover, |
|---|
| 131 |
'description' => $descr, |
|---|
| 132 |
'torrent_id' => $torrent_id, |
|---|
| 133 |
'imdb_link' => $imdb_link, |
|---|
| 134 |
'forum_link' => $topic_link )) . ' WHERE id = ' . $id; |
|---|
| 135 |
$db->sql_query($sql); |
|---|
| 136 |
} |
|---|
| 137 |
else { |
|---|
| 138 |
$sql = 'INSERT INTO ' . INDEXRELEASES_TABLE . ' ' . $db->sql_build_array('INSERT', array( |
|---|
| 139 |
'name' => $name, |
|---|
| 140 |
'cover' => $cover, |
|---|
| 141 |
'description' => $descr, |
|---|
| 142 |
'torrent_id' => $torrent_id, |
|---|
| 143 |
'imdb_link' => $imdb_link, |
|---|
| 144 |
'forum_link' => $topic_link )); |
|---|
| 145 |
$db->sql_query($sql); |
|---|
| 146 |
} |
|---|
| 147 |
$cache->destroy('sql', INDEXRELEASES_TABLE); |
|---|
| 148 |
redirect( append_sid('index.php')); |
|---|
| 149 |
} |
|---|
| 150 |
|
|---|
| 151 |
$template->assign_vars( array( |
|---|
| 152 |
'S_FROM_ACTION' => ( $id ? append_sid('releases.php?id=' . $id) : append_sid('releases.php') ), |
|---|
| 153 |
'NAME' => ( isset($arr['name']) ? $arr['name'] : '' ), |
|---|
| 154 |
'IMAGE' => ( isset($arr['cover']) ? $arr['cover'] : '' ), |
|---|
| 155 |
'DESCRIPTION' => ( isset($arr['description']) ? $arr['description'] : '' ), |
|---|
| 156 |
'TORRENT_ID' => ( isset($arr['torrent_id']) ? $arr['torrent_id'] : '' ), |
|---|
| 157 |
'IMDB_LINK' => ( isset($arr['imdb_link']) ? $arr['imdb_link'] : '' ), |
|---|
| 158 |
'FORUM_LINK' => ( isset($arr['forum_link']) ? $arr['forum_link'] : '' ) |
|---|
| 159 |
)); |
|---|
| 160 |
|
|---|
| 161 |
stdhead($lang['release_add']); |
|---|
| 162 |
$template->set_filenames(array( |
|---|
| 163 |
'body' => 'releases.html') |
|---|
| 164 |
); |
|---|
| 165 |
stdfoot(); |
|---|
| 166 |
|
|---|
| 167 |
break; |
|---|
| 168 |
|
|---|
| 169 |
|
|---|
| 170 |
case 'delete': |
|---|
| 171 |
$id = ( isset($_GET['id']) ? intval($_GET['id']) : 0 ); |
|---|
| 172 |
$sure = ( isset($_GET['sure']) ? 1 : 0 ); |
|---|
| 173 |
|
|---|
| 174 |
$sql = 'SELECT * FROM ' . INDEXRELEASES_TABLE . ' WHERE id=' . $id; |
|---|
| 175 |
$result = $db->sql_query($sql); |
|---|
| 176 |
if ( !( $row = $db->sql_fetchrow($result) ) ) { |
|---|
| 177 |
trigger_error(sprintf($lang['invalid_id'], $id)); |
|---|
| 178 |
} |
|---|
| 179 |
if (!$sure){ |
|---|
| 180 |
trigger_error(sprintf($lang['are_you_sure_delete_friend_block'], '', append_sid('releases.php?action=delete&id=' . $id . '&sure=1') )); |
|---|
| 181 |
} |
|---|
| 182 |
$sql = 'DELETE FROM ' . INDEXRELEASES_TABLE . ' WHERE id=' . $id; |
|---|
| 183 |
$db->sql_query($sql); |
|---|
| 184 |
$cache->destroy('sql', INDEXRELEASES_TABLE); |
|---|
| 185 |
|
|---|
| 186 |
redirect( append_sid('index.php')); |
|---|
| 187 |
|
|---|
| 188 |
break; |
|---|
| 189 |
} |
|---|
| 190 |
?> |
|---|