Browse Source

Various torrent form fixes

Disables autofill on request format, adds Censored option to Other
category, etc
spaghetti 9 years ago
parent
commit
10f01778d1
3 changed files with 69 additions and 40 deletions
  1. 25
    13
      classes/torrent_form.class.php
  2. 28
    11
      sections/requests/new_edit.php
  3. 16
    16
      sections/schedule/index.php

+ 25
- 13
classes/torrent_form.class.php View File

@@ -61,7 +61,7 @@ class TORRENT_FORM {
61 61
 		$this->ArchivesManga = $ArchivesManga;
62 62
 
63 63
 		if ($this->Torrent && $this->Torrent['GroupID']) {
64
-			$this->Disabled = ' disabled="disabled"';
64
+			$this->Disabled = ' readonly="readonly"';
65 65
 			$this->DisabledFlag = true;
66 66
 		}
67 67
 	}
@@ -103,7 +103,7 @@ class TORRENT_FORM {
103 103
 			if ($this->Torrent && $this->Torrent['GroupID']) {
104 104
 ?>
105 105
 			<input type="hidden" name="groupid" value="<?=display_str($this->Torrent['GroupID'])?>" />
106
-			<input type="hidden" name="type" value="<?=array_search($this->UploadForm, $this->Categories)?>" />
106
+			<input type="hidden" name="type" value="<?=display_str($this->Torrent['CategoryID'])?>" />
107 107
 <?
108 108
 			}
109 109
 			if ($this->Torrent && $this->Torrent['RequestID']) {
@@ -123,7 +123,7 @@ class TORRENT_FORM {
123 123
 			<tr>
124 124
 				<td class="label">Type:</td>
125 125
 				<td>
126
-					<select id="categories" name="type" onchange="Categories()"<?=$this->Disabled?>>
126
+					<select id="categories" name="type" onchange="Categories()"<?=($this->DisabledFlag) ? ' disabled="disabled"' : ''?>>
127 127
 <?
128 128
 			foreach (Misc::display_array($this->Categories) as $Index => $Cat) {
129 129
 				echo "\t\t\t\t\t\t<option value=\"$Index\"";
@@ -203,8 +203,10 @@ class TORRENT_FORM {
203 203
 			<tr id="javdb_tr">
204 204
 				<td class="label tooltip" title='Enter a JAV catalogue number, e.g., "CND-060"'>Catalogue Number:</td>
205 205
 				<td>
206
-					<input type="text" id="catalogue" name="catalogue" size="10" value="<?=display_str($Torrent['CatalogueNumber']) ?>"/>
207
-					 <input type="button" onclick="JavAutofill()" value="Autofill" <?=$this->Disabled?>></input>
206
+					<input type="text" id="catalogue" name="catalogue" size="10" value="<?=display_str($Torrent['CatalogueNumber']) ?>" <?=$this->Disabled?>/>
207
+<? if (!$this->DisabledFlag) { ?>
208
+					<input type="button" onclick="JavAutofill()" value="Autofill"></input>
209
+<? } ?>
208 210
 				</td>
209 211
 			</tr>
210 212
 			<tr id="title_tr">
@@ -403,7 +405,7 @@ class TORRENT_FORM {
403 405
 		G::$Cache->cache_value('genre_tags', $GenreTags, 3600*6);
404 406
 	}
405 407
 ?>
406
-					<select id="genre_tags" name="genre_tags" onchange="add_tag(); return false;">
408
+					<select id="genre_tags" name="genre_tags" onchange="add_tag(); return false;" <?=($this->DisabledFlag) ? ' disabled="disabled"' : ''?>>
407 409
 						<option>---</option>
408 410
 <? foreach (Misc::display_array($GenreTags) as $Genre) { ?>
409 411
 						<option value="<?=$Genre?>"><?=$Genre?></option>
@@ -459,8 +461,10 @@ class TORRENT_FORM {
459 461
 			<tr id="anidb_tr">
460 462
 				<td class="label">AniDB Autofill (optional):</td>
461 463
 				<td>
462
-					<input type="text" id="anidb" size="10" />
463
-					<input type="button" onclick="AnidbAutofill()" value="Autofill" <?=$this->Disabled?>/>
464
+					<input type="text" id="anidb" size="10" <?=$this->Disabled?>/>
465
+<? if (!$this->DisabledFlag) { ?>
466
+					<input type="button" onclick="AnidbAutofill()" value="Autofill"/>
467
+<? } ?>
464 468
 				</td>
465 469
 			</tr>
466 470
 			<tr id="title_tr">
@@ -655,7 +659,7 @@ class TORRENT_FORM {
655 659
 		G::$Cache->cache_value('genre_tags', $GenreTags, 3600*6);
656 660
 	}
657 661
 ?>
658
-					<select id="genre_tags" name="genre_tags" onchange="add_tag(); return false;">
662
+					<select id="genre_tags" name="genre_tags" onchange="add_tag(); return false;" <?=($this->DisabledFlag) ? ' disabled="disabled"' : ''?>>
659 663
 						<option>---</option>
660 664
 <? foreach (Misc::display_array($GenreTags) as $Genre) { ?>
661 665
 						<option value="<?=$Genre?>"><?=$Genre?></option>
@@ -707,7 +711,9 @@ class TORRENT_FORM {
707 711
 				<td class="label">nhentai URL (optional):</td>
708 712
         <td>
709 713
           <input type="text" id="catalogue" size="50" <?=$this->Disabled?> />
710
-					<input type="button" onclick="DoujAutofill()" value="Autofill" <?=$this->Disabled?>/>
714
+<? if (!$this->DisabledFlag) { ?>
715
+					<input type="button" onclick="DoujAutofill()" value="Autofill"/>
716
+<? } ?>
711 717
         </td>
712 718
 			</tr>
713 719
 			<tr id="title_tr">
@@ -832,7 +838,7 @@ class TORRENT_FORM {
832 838
 		G::$Cache->cache_value('genre_tags', $GenreTags, 3600*6);
833 839
 	}
834 840
 ?>
835
-					<select id="genre_tags" name="genre_tags" onchange="add_tag(); return false;">
841
+					<select id="genre_tags" name="genre_tags" onchange="add_tag(); return false;" <?=($this->DisabledFlag) ? ' disabled="disabled"' : ''?>>
836 842
 						<option>---</option>
837 843
 <? foreach (Misc::display_array($GenreTags) as $Genre) { ?>
838 844
 						<option value="<?=$Genre?>"><?=$Genre?></option>
@@ -888,6 +894,12 @@ class TORRENT_FORM {
888 894
 				<td><input type="text" id="title_jp" name="title_jp" size="60" value="<?=display_str($Torrent['TitleJP'])?>" <?=$this->Disabled?>/></td>
889 895
 			</tr>
890 896
 <? } ?>
897
+			<tr>
898
+				<td class="label">Censored?:</td>
899
+				<td>
900
+					<input type="checkbox" name="censored" value="1" <?=(($Torrent['Censored'] ?? 1) ? 'checked ' : '')?>/>
901
+				</td>
902
+			</tr>
891 903
 			<tr>
892 904
 				<td class="label tooltip" title="Comma seperated list of tags">Tags:</td>
893 905
 				<td>
@@ -903,7 +915,7 @@ class TORRENT_FORM {
903 915
 		G::$Cache->cache_value('genre_tags', $GenreTags, 3600*6);
904 916
 	}
905 917
 ?>
906
-					<select id="genre_tags" name="genre_tags" onchange="add_tag(); return false;">
918
+					<select id="genre_tags" name="genre_tags" onchange="add_tag(); return false;" <?=($this->DisabledFlag) ? ' disabled="disabled"' : ''?>>
907 919
 						<option>---</option>
908 920
 <? foreach (Misc::display_array($GenreTags) as $Genre) { ?>
909 921
 						<option value="<?=$Genre?>"><?=$Genre?></option>
@@ -1081,7 +1093,7 @@ new TEXTAREA_PREVIEW('album_desc', 'album_desc', display_str($Torrent['GroupDesc
1081 1093
 		G::$Cache->cache_value('genre_tags', $GenreTags, 3600*6);
1082 1094
 	}
1083 1095
 ?>
1084
-					<select id="genre_tags" name="genre_tags" onchange="add_tag(); return false;">
1096
+					<select id="genre_tags" name="genre_tags" onchange="add_tag(); return false;" <?=($this->DisabledFlag) ? ' disabled="disabled"' : ''?>>
1085 1097
 						<option>---</option>
1086 1098
 <? foreach (Misc::display_array($GenreTags) as $Genre) { ?>
1087 1099
 						<option value="<?=$Genre?>"><?=$Genre?></option>

+ 28
- 11
sections/requests/new_edit.php View File

@@ -16,6 +16,7 @@ if (!$NewRequest) {
16 16
 	}
17 17
 }
18 18
 
19
+$Disabled = "";
19 20
 
20 21
 if ($NewRequest && ($LoggedUser['BytesUploaded'] < 250 * 1024 * 1024 || !check_perms('site_submit_requests'))) {
21 22
 	error('You do not have enough uploaded to make a request.');
@@ -89,6 +90,8 @@ if ($NewRequest && !empty($_GET['artistid']) && is_number($_GET['artistid'])) {
89 90
 		WHERE tg.ID = ".$_GET['groupid']);
90 91
 	if (list($Title, $TitleJP, $Year, $Studio, $Series, $CatalogueNumber, $DLsiteID, $Image, $Tags, $CategoryID) = $DB->next_record()) {
91 92
 		$GroupID = trim($_REQUEST['groupid']);
93
+		$CategoryName = $Categories[$CategoryID - 1];
94
+		$Disabled = 'readonly="readonly"';
92 95
 	}
93 96
 }
94 97
 
@@ -119,7 +122,12 @@ View::show_header(($NewRequest ? 'Create a request' : 'Edit a request'), 'reques
119 122
 						Type
120 123
 					</td>
121 124
 					<td>
125
+<? if (!empty($Disabled)) { ?>
126
+						<input type="hidden" name="type" value="<?=$CategoryName?>" />
127
+						<select id="categories" name="type" onchange="Categories();" disabled="disabled">
128
+<? } else { ?>
122 129
 						<select id="categories" name="type" onchange="Categories();">
130
+<? } ?>
123 131
 <?		foreach (Misc::display_array($Categories) as $Cat) { ?>
124 132
 							<option value="<?=$Cat?>"<?=(!empty($CategoryName) && ($CategoryName === $Cat) ? ' selected="selected"' : '')?>><?=$Cat?></option>
125 133
 <?		} ?>
@@ -129,8 +137,10 @@ View::show_header(($NewRequest ? 'Create a request' : 'Edit a request'), 'reques
129 137
 				<tr id="cataloguenumber_tr">
130 138
 					<td class="label">Catalogue Number</td>
131 139
 					<td>
132
-						<input type="text" id="catalogue" name="cataloguenumber" size="15" value="<?=(isset($CatalogueNumber)?$CatalogueNumber:'') ?>" />
140
+						<input type="text" id="catalogue" name="cataloguenumber" size="15" value="<?=(isset($CatalogueNumber)?$CatalogueNumber:'') ?>" <?=$Disabled?>/>
141
+<? if (empty($Disabled)) { ?>
133 142
 						( <input type="button" onclick="JavAutofill()" value="Autofill" style="font-size:0.8em;"></input> )
143
+<? } ?>
134 144
 					</td>
135 145
 				</tr>
136 146
 				<tr id="artist_tr">
@@ -142,14 +152,16 @@ View::show_header(($NewRequest ? 'Create a request' : 'Edit a request'), 'reques
142 152
 			$First = true;
143 153
 			foreach ($ArtistForm as $Artist) {
144 154
 ?>
145
-						<input type="text" id="artist_0" name="artists[]"<? Users::has_autocomplete_enabled('other'); ?> size="45" value="<?=display_str($Artist['name']) ?>" />
146
-						<? if ($First) { ?><a href="#" onclick="AddArtistField(); return false;" class="brackets">+</a> <a href="#" onclick="RemoveArtistField(); return false;" class="brackets">&minus;</a><? } $First = false; ?>
155
+						<input type="text" id="artist_0" name="artists[]"<? Users::has_autocomplete_enabled('other'); ?> size="45" value="<?=display_str($Artist['name']) ?>" <?=$Disabled?>/>
156
+						<? if (empty($Disabled)) { if ($First) { ?><a href="#" onclick="AddArtistField(); return false;" class="brackets">+</a> <a href="#" onclick="RemoveArtistField(); return false;" class="brackets">&minus;</a><? } $First = false; } ?>
147 157
 						<br />
148 158
 <?
149 159
 			}
150 160
 		} else {
151
-?>						<input type="text" id="artist_0" name="artists[]"<? Users::has_autocomplete_enabled('other'); ?> size="45" onblur="CheckVA();" />
161
+?>						<input type="text" id="artist_0" name="artists[]"<? Users::has_autocomplete_enabled('other'); ?> size="45" onblur="CheckVA();" <?=$Disabled?>/>
162
+<? if (empty($Disabled)) { ?>
152 163
 						<a href="#" onclick="AddArtistField(); return false;" class="brackets">+</a> <a href="#" onclick="RemoveArtistField(); return false;" class="brackets">&minus;</a>
164
+<? } ?>
153 165
 <?
154 166
 		}
155 167
 ?>
@@ -158,19 +170,19 @@ View::show_header(($NewRequest ? 'Create a request' : 'Edit a request'), 'reques
158 170
 				<tr>
159 171
 					<td class="label">Title</td>
160 172
 					<td>
161
-						<input type="text" id="title" name="title" size="45" value="<?=(!empty($Title) ? $Title : '')?>" />
173
+						<input type="text" id="title" name="title" size="45" value="<?=(!empty($Title) ? $Title : '')?>" <?=$Disabled?>/>
162 174
 					</td>
163 175
 				</tr>
164 176
 				<tr>
165 177
 					<td class="label">Japanese Title</td>
166 178
 					<td>
167
-						<input type="text" id="title_jp" name="title_jp" size="45" value="<?=isset($TitleJP)?$TitleJP:''?>" />
179
+						<input type="text" id="title_jp" name="title_jp" size="45" value="<?=isset($TitleJP)?$TitleJP:''?>" <?=$Disabled?>/>
168 180
 					</td>
169 181
 				</tr>
170 182
 				<tr id="dlsiteid_tr">
171 183
 					<td class="label">DLSite ID</td>
172 184
 					<td>
173
-						<input type="text" id="dlsiteid" name="dlsiteid" size="15" value="<?=isset($DLsiteID)?$DLsiteID:''?>" />
185
+						<input type="text" id="dlsiteid" name="dlsiteid" size="15" value="<?=isset($DLsiteID)?$DLsiteID:''?>" <?=$Disabled?>/>
174 186
 					</td>
175 187
 				</tr>
176 188
 <?	} ?>
@@ -178,7 +190,7 @@ View::show_header(($NewRequest ? 'Create a request' : 'Edit a request'), 'reques
178 190
 				<tr id="image_tr">
179 191
 					<td class="label">Image</td>
180 192
 					<td>
181
-						<input type="text" id="image" name="image" size="45" value="<?=(!empty($Image) ? $Image : '')?>" />
193
+						<input type="text" id="image" name="image" size="45" value="<?=(!empty($Image) ? $Image : '')?>" <?=$Disabled?>/>
182 194
 					</td>
183 195
 				</tr>
184 196
 <?	} ?>
@@ -196,14 +208,19 @@ View::show_header(($NewRequest ? 'Create a request' : 'Edit a request'), 'reques
196 208
 		$GenreTags = $DB->collect('Name');
197 209
 		$Cache->cache_value('genre_tags', $GenreTags, 3600 * 6);
198 210
 	}
211
+
212
+	if (!empty($Disabled)) {
199 213
 ?>
200
-						<select id="genre_tags" name="genre_tags" onchange="add_tag(); return false;">
214
+						<select id="genre_tags" name="genre_tags" onchange="add_tag(); return false;" disabled="disabled">
215
+<? } else { ?>
216
+						<select id="genre_tags" name="genre_tags" onchange="add_tag(); return false;" >
217
+<? } ?>
201 218
 							<option>---</option>
202 219
 <?	foreach (Misc::display_array($GenreTags) as $Genre) { ?>
203 220
 							<option value="<?=$Genre?>"><?=$Genre?></option>
204 221
 <?	} ?>
205 222
 						</select>
206
-						<input type="text" id="tags" name="tags" size="45" value="<?=(!empty($Tags) ? display_str($Tags) : '')?>"<? Users::has_autocomplete_enabled('other'); ?> />
223
+						<input type="text" id="tags" name="tags" size="45" value="<?=(!empty($Tags) ? display_str($Tags) : '')?>"<? Users::has_autocomplete_enabled('other'); ?> <?=$Disabled?>/>
207 224
 						<br />
208 225
 						Tags should be comma-separated, and you should use a period (".") to separate words inside a tag&#8202;&mdash;&#8202;e.g. "<strong class="important_text_alt">big.breasts</strong>".
209 226
 						<br /><br />
@@ -222,7 +239,7 @@ View::show_header(($NewRequest ? 'Create a request' : 'Edit a request'), 'reques
222 239
 				<tr>
223 240
 					<td class="label">Torrent group</td>
224 241
 					<td>
225
-						<?=site_url()?>torrents.php?id=<input type="text" name="groupid" value="<?=isset($GroupID)?$GroupID:''?>" size="15" /><br />
242
+						<?=site_url()?>torrents.php?id=<input type="text" name="groupid" value="<?=isset($GroupID)?$GroupID:''?>" size="15"/><br />
226 243
 						If this request matches a torrent group <span style="font-weight: bold;">already existing</span> on the site, please indicate that here.
227 244
 					</td>
228 245
 				</tr>

+ 16
- 16
sections/schedule/index.php View File

@@ -10,7 +10,7 @@ $ScheduleDebug = false;
10 10
 
11 11
 $PCount = chop(shell_exec("/usr/bin/pgrep -cf schedule.php"));
12 12
 if ($PCount > 3) {  // 3 because the cron job starts two processes and pgrep finds itself
13
-	die("schedule.php is already running. Exiting ($PCount)\n");
13
+  die("schedule.php is already running. Exiting ($PCount)\n");
14 14
 }
15 15
 
16 16
 $AS = check_perms('admin_schedule');
@@ -28,18 +28,18 @@ function run_all_in($Dir) {
28 28
 }
29 29
 
30 30
 if ((!isset($_REQUEST['key']) || $_REQUEST['key'] != SCHEDULE_KEY) && !$AS) {
31
-	error(403);
31
+  error(403);
32 32
 }
33 33
 
34 34
 if ($AS) {
35
-	authorize();
36
-	View::show_header();
37
-	echo '<div class="box">';
35
+  authorize();
36
+  View::show_header();
37
+  echo '<div class="box">';
38 38
 }
39 39
 
40 40
 $DB->query("
41
-	SELECT NextHour, NextDay, NextBiWeekly
42
-	FROM schedule");
41
+  SELECT NextHour, NextDay, NextBiWeekly
42
+  FROM schedule");
43 43
 list($Hour, $Day, $BiWeek) = $DB->next_record();
44 44
 
45 45
 $NextHour = date('H', time(date('H') + 1, 0, 0, date('m'), date('d'), date('Y')));
@@ -47,8 +47,8 @@ $NextDay = date('d', time(0, 0, 0, date('m'), date('d') + 1, date('Y')));
47 47
 $NextBiWeek = (date('d') < 22 && date('d') >= 8) ? 22 : 8;
48 48
 
49 49
 $DB->query("
50
-	UPDATE schedule
51
-	SET NextHour = $NextHour, NextDay = $NextDay, NextBiWeekly = $NextBiWeek");
50
+  UPDATE schedule
51
+  SET NextHour = $NextHour, NextDay = $NextDay, NextBiWeekly = $NextBiWeek");
52 52
 
53 53
 $sqltime = sqltime();
54 54
 
@@ -63,13 +63,13 @@ if (!(isset($_GET['notevery']) && $_GET['notevery'])) {
63 63
 //-------------- Run every hour ------------------------------------------//
64 64
 if ($Hour != $NextHour || (isset($_GET['runhour']) && $_GET['runhour'])) {
65 65
   run_all_in('hourly');
66
-	echo "Ran hourly functions".($AS?'<br>':"\n");
66
+  echo "Ran hourly functions".($AS?'<br>':"\n");
67 67
 }
68 68
 
69 69
 //-------------- Run every day -------------------------------------------//
70 70
 if ($Day != $NextDay || (isset($_GET['runday']) && $_GET['runday'])) {
71 71
   run_all_in('daily');
72
-	echo "Ran daily functions".($AS?'<br>':"\n");
72
+  echo "Ran daily functions".($AS?'<br>':"\n");
73 73
 }
74 74
 
75 75
 //-------------- Run every week -------------------------------------------//
@@ -81,24 +81,24 @@ if (($Day != $NextDay && date('w') == 0) || (isset($_GET['runweek']) && $_GET['r
81 81
 //--------------- Run twice per month -------------------------------------//
82 82
 if ($BiWeek != $NextBiWeek || (isset($_GET['runbiweek']) && $_GET['runbiweek'])) {
83 83
   run_all_in('biweekly');
84
-	echo "Ran bi-weekly functions".($AS?'<br>':"\n");
84
+  echo "Ran bi-weekly functions".($AS?'<br>':"\n");
85 85
 }
86 86
 
87 87
 //---------------- Run every month -----------------------------------------//
88 88
 if (($BiWeek != $NextBiWeek && $BiWeek == 8) || (isset($_GET['runmonth']) && $_GET['runmonth'])) {
89 89
   run_all_in('monthly');
90
-	echo "Ran monthly functions".($AS?'<br>':"\n");
90
+  echo "Ran monthly functions".($AS?'<br>':"\n");
91 91
 }
92 92
 
93 93
 //---------------- Run on request ------------------------------------------//
94 94
 if (isset($_GET['runmanual']) && $_GET['runmanual']) {
95 95
   run_all_in('manually');
96
-	echo "Ran manual functions".($AS?'<br>':"\n");
96
+  echo "Ran manual functions".($AS?'<br>':"\n");
97 97
 }
98 98
 
99 99
 if ($AS) {
100
-	echo '</div>';
101
-	View::show_footer();
100
+  echo '</div>';
101
+  View::show_footer();
102 102
 } else {
103 103
   echo "-------------------------\n\n";
104 104
 }

Loading…
Cancel
Save