[ Index ] |
|
Code source de e107 0.7.8 |
1 <?php 2 /* 3 + ----------------------------------------------------------------------------+ 4 | e107 website system 5 | 6 | ©Steve Dunstan 2001-2002 7 | http://e107.org 8 | jalist@e107.org 9 | 10 | Released under the terms and conditions of the 11 | GNU General Public License (http://gnu.org). 12 | 13 | $Source: /cvsroot/e107/e107_0.7/e107_files/shortcode/batch/download_shortcodes.php,v $ 14 | $Revision: 1.25 $ 15 | $Date: 2007/02/04 15:27:28 $ 16 | $Author: e107steved $ 17 +----------------------------------------------------------------------------+ 18 */ 19 if (!defined('e107_INIT')) { exit; } 20 include_once(e_HANDLER.'shortcode_handler.php'); 21 $download_shortcodes = $tp -> e_sc -> parse_scbatch(__FILE__); 22 /* 23 SC_BEGIN DOWNLOAD_LIST_NAME 24 global $row,$tp,$pref; 25 if($parm == "nolink"){ 26 return $tp->toHTML($row['download_name'],TRUE,"no_hook"); 27 } 28 if($parm == "request"){ 29 30 $agreetext = $tp->toJS($tp->toHTML($pref['agree_text'],FALSE,"parse_sc, defs")); 31 if($row['download_mirror_type']){ 32 $text = ($pref['agree_flag'] ? "<a href='".e_BASE."download.php?mirror.".$row['download_id']."' onclick= \"return confirm('{$agreetext}');\">" : "<a href='".e_BASE."download.php?mirror.".$row['download_id']."' title='".LAN_dl_32."'>"); 33 }else{ 34 $text = ($pref['agree_flag'] ? "<a href='".e_BASE."request.php?".$row['download_id']."' onclick= \"return confirm('{$agreetext}');\">" : "<a href='".e_BASE."request.php?".$row['download_id']."' title='".LAN_dl_32."'>"); 35 } 36 $text .= $tp->toHTML($row['download_name'])."</a>"; 37 return $text; 38 } 39 40 return "<a href='".e_BASE."download.php?view.".$row['download_id']."'>".$tp->toHTML($row['download_name'],TRUE,"no_hook")."</a>"; 41 SC_END 42 43 44 SC_BEGIN DOWNLOAD_LIST_AUTHOR 45 global $row; 46 return $row['download_author']; 47 SC_END 48 49 50 SC_BEGIN DOWNLOAD_LIST_REQUESTED 51 global $row; 52 return $row['download_requested']; 53 SC_END 54 55 56 SC_BEGIN DOWNLOAD_LIST_ICON 57 global $row; 58 $img = "<img src='".IMAGE_DOWNLOAD."' alt='' style='border:0' title='".LAN_dl_32."' />"; 59 if($parm == "link"){ 60 return "<a href='".e_BASE."download.php?view.".$row['download_id']."' >".$img."</a>"; 61 }else{ 62 return $img; 63 } 64 return; 65 SC_END 66 67 68 SC_BEGIN DOWNLOAD_LIST_NEWICON 69 global $row; 70 return (USER && $row['download_datestamp'] > USERLV ? "<img src='".IMAGE_NEW."' alt='' style='vertical-align:middle' />" : ""); 71 SC_END 72 73 74 SC_BEGIN DOWNLOAD_LIST_FILESIZE 75 global $row; 76 return parsesize($row['download_filesize']); 77 SC_END 78 79 80 SC_BEGIN DOWNLOAD_LIST_DATESTAMP 81 global $row; 82 $gen = new convert; 83 return $gen->convert_date($row['download_datestamp'], "short"); 84 SC_END 85 86 87 SC_BEGIN DOWNLOAD_LIST_THUMB 88 global $row; 89 $img = ($row['download_thumb']) ? "<img src='".e_FILE."downloadthumbs/".$row['download_thumb']."' alt='' style='".DL_IMAGESTYLE."' />" : ""; 90 if($parm == "link" && $row['download_thumb']){ 91 return "<a href='".e_BASE."download.php?view.".$row['download_id']."'>".$img."</a>"; 92 }else{ 93 return $img; 94 } 95 SC_END 96 97 98 SC_BEGIN DOWNLOAD_LIST_ID 99 global $row; 100 return $row['download_id']; 101 SC_END 102 103 104 SC_BEGIN DOWNLOAD_LIST_RATING 105 global $row; 106 $rater = new rater; 107 $ratearray = $rater->getrating("download", $row['download_id']); 108 if (!$ratearray[0]) { 109 return LAN_dl_13; 110 } else { 111 return ($ratearray[2] ? "{$ratearray[1]}.{$ratearray[2]}/{$ratearray[0]}" : "{$ratearray[1]}/{$ratearray[0]}"); 112 } 113 SC_END 114 115 116 SC_BEGIN DOWNLOAD_LIST_LINK 117 global $tp,$row,$pref; 118 $agreetext = $tp->toJS($tp->toHTML($pref['agree_text'],FALSE,"parse_sc, defs")); 119 if($row['download_mirror_type']){ 120 return ($pref['agree_flag'] ? "<a href='".e_BASE."download.php?mirror.".$row['download_id']."' onclick= \"return confirm('{$agreetext}');\">" : "<a href='".e_BASE."download.php?mirror.".$row['download_id']."' >"); 121 }else{ 122 return ($pref['agree_flag'] ? "<a href='".e_BASE."request.php?".$row['download_id']."' onclick= \"return confirm('{$agreetext}');\">" : "<a href='".e_BASE."request.php?".$row['download_id']."' >"); 123 } 124 SC_END 125 126 127 128 // ---------------------- Download View ---------------------------------------- 129 130 SC_BEGIN DOWNLOAD_VIEW_ID 131 global $dl; 132 return $dl['download_id']; 133 SC_END 134 135 136 SC_BEGIN DOWNLOAD_ADMIN_EDIT 137 global $dl; 138 return (ADMIN && getperms('6')) ? "<a href='".e_ADMIN."download.php?create.edit.".$dl['download_id']."' title='edit'><img src='".e_IMAGE."generic/lite/edit.png' alt='' style='padding:0px;border:0px' /></a>" : ""; 139 SC_END 140 141 SC_BEGIN DOWNLOAD_CATEGORY 142 global $dl; 143 return $dl['download_category_name']; 144 SC_END 145 146 SC_BEGIN DOWNLOAD_CATEGORY_ICON 147 global $dl; 148 list($present,$missing) = explode(chr(1),$dl['download_category_icon']); 149 if($present) 150 { 151 return "<img class='dl_cat_icon' src='".e_IMAGE."icons/".$present."' alt='' />"; 152 } 153 154 SC_END 155 156 SC_BEGIN DOWNLOAD_CATEGORY_DESCRIPTION 157 global $tp,$dl; 158 $text = $tp -> toHTML($dl['download_category_description'], TRUE,'description'); 159 if($parm){ 160 return substr($text,0,$parm); 161 }else{ 162 return $text; 163 } 164 SC_END 165 166 SC_BEGIN DOWNLOAD_VIEW_NAME 167 global $dl; 168 $link['view'] = "<a href='".e_BASE."download.php?view.".$dl['download_id']."'>".$dl['download_name']."</a>"; 169 $link['request'] = "<a href='".e_BASE."request.php?".$dl['download_id']."' title='".LAN_dl_46."'>".$dl['download_name']."</a>"; 170 171 if($parm){ 172 return $link[$parm]; 173 } 174 return $dl['download_name']; 175 SC_END 176 177 SC_BEGIN DOWNLOAD_VIEW_NAME_LINKED 178 global $pref,$dl,$tp; 179 if ($pref['agree_flag'] == 1) { 180 return "<a href='".e_BASE."request.php?".$dl['download_id']."' onclick= \"return confirm('".$tp->toJS($tp->toHTML($pref['agree_text'],FALSE,"parse_sc, defs"))."' title='".LAN_dl_46."'>".$dl['download_name']."</a>"; 181 } else { 182 return "<a href='".e_BASE."request.php?".$dl['download_id']."' title='".LAN_dl_46."'>".$dl['download_name']."</a>"; 183 } 184 SC_END 185 186 SC_BEGIN DOWNLOAD_VIEW_AUTHOR 187 global $dl; 188 return ($dl['download_author'] ? $dl['download_author'] : ""); 189 SC_END 190 191 192 SC_BEGIN DOWNLOAD_VIEW_AUTHOREMAIL 193 global $tp,$dl; 194 return ($dl['download_author_email']) ? $tp -> toHTML($dl['download_author_email'], TRUE) : ""; 195 SC_END 196 197 SC_BEGIN DOWNLOAD_VIEW_AUTHORWEBSITE 198 global $tp,$dl; 199 return ($dl['download_author_website']) ? $tp -> toHTML($dl['download_author_website'], TRUE) : ""; 200 SC_END 201 202 203 204 SC_BEGIN DOWNLOAD_VIEW_DESCRIPTION 205 global $tp, $dl; 206 $maxlen = ($parm ? intval($parm) : 0); 207 $text = ($dl['download_description'] ? $tp->toHTML($dl['download_description'], TRUE, 'description') : ""); 208 if($maxlen){ 209 return substr($text, 0, $maxlen); 210 }else{ 211 return $text; 212 } 213 return $text; 214 SC_END 215 216 SC_BEGIN DOWNLOAD_VIEW_DATE 217 global $gen,$dl; 218 return ($dl['download_datestamp']) ? $gen->convert_date($dl['download_datestamp'], $parm) : ""; 219 SC_END 220 221 SC_BEGIN DOWNLOAD_VIEW_DATE_SHORT 222 // deprecated: DOWNLOAD_VIEW_DATE should be used instead. 223 global $gen,$dl; 224 return ($dl['download_datestamp']) ? $gen->convert_date($dl['download_datestamp'], "short") : ""; 225 SC_END 226 227 SC_BEGIN DOWNLOAD_VIEW_DATE_LONG 228 // deprecated: DOWNLOAD_VIEW_DATE should be used instead. 229 global $gen,$dl; 230 return ($dl['download_datestamp']) ? $gen->convert_date($dl['download_datestamp'], "long") : ""; 231 SC_END 232 233 234 235 SC_BEGIN DOWNLOAD_VIEW_IMAGE 236 global $dl; 237 if ($dl['download_thumb']) { 238 return ($dl['download_image'] ? "<a href='".e_BASE."request.php?download.".$dl['download_id']."'><img class='dl_image' src='".e_FILE."downloadthumbs/".$dl['download_thumb']."' alt='' style='".DL_IMAGESTYLE."' /></a>" : "<img class='dl_image' src='".e_FILE."downloadthumbs/".$dl['download_thumb']."' alt='' style='".DL_IMAGESTYLE."' />"); 239 } 240 else if($dl['download_image']) { 241 return "<a href='".e_BASE."request.php?download.".$dl['download_id']."'>".LAN_dl_40."</a>"; 242 } 243 else 244 { 245 return LAN_dl_75; 246 } 247 SC_END 248 249 SC_BEGIN DOWNLOAD_VIEW_IMAGEFULL 250 global $dl; 251 return ($dl['download_image']) ? "<img class='dl_image' src='".e_FILE."downloadimages/".$dl['download_image']."' alt='' style='".DL_IMAGESTYLE."' />" : ""; 252 SC_END 253 254 SC_BEGIN DOWNLOAD_VIEW_LINK 255 global $pref,$dl,$tp; 256 if ($pref['agree_flag'] == 1) { 257 $dnld_link = "<a href='".e_BASE."request.php?".$dl['download_id']."' onclick= \"return confirm('".$tp->toJS($tp->toHTML($pref['agree_text'],FALSE,"parse_sc, defs"))."');\">"; 258 } else { 259 $dnld_link = "<a href='".e_BASE."request.php?".$dl['download_id']."'>"; 260 } 261 262 if($dl['download_mirror']) 263 { 264 if($dl['download_mirror_type']) 265 { 266 return "<a href='".e_BASE."download.php?mirror.".$dl['download_id']."'>".LAN_dl_66."</a>"; 267 } 268 else 269 { 270 return $dnld_link." <img src='".IMAGE_DOWNLOAD."' alt='' style='border:0' /></a>"; 271 } 272 } 273 else 274 { 275 return $dnld_link." <img src='".IMAGE_DOWNLOAD."' alt='' style='border:0' /></a>"; 276 } 277 SC_END 278 279 SC_BEGIN DOWNLOAD_VIEW_FILESIZE 280 global $dl; 281 return ($dl['download_filesize']) ? parsesize($dl['download_filesize']) : ""; 282 SC_END 283 284 SC_BEGIN DOWNLOAD_VIEW_RATING 285 require_once(e_HANDLER."rate_class.php"); 286 $rater = new rater; 287 global $dl; 288 $text = " 289 <table style='width:100%'> 290 <tr> 291 <td style='width:50%'>"; 292 293 if ($ratearray = $rater->getrating("download", $dl['download_id'])) { 294 for($c = 1; $c <= $ratearray[1]; $c++) { 295 $text .= "<img src='".e_IMAGE."rate/".IMODE."/star.png' alt='' />"; 296 } 297 if ($ratearray[2]) { 298 $text .= "<img src='".e_IMAGE."rate/".IMODE."/".$ratearray[2].".png' alt='' />"; 299 } 300 if ($ratearray[2] == "") { 301 $ratearray[2] = 0; 302 } 303 $text .= " ".$ratearray[1].".".$ratearray[2]." - ".$ratearray[0]." "; 304 $text .= ($ratearray[0] == 1 ? LAN_dl_43 : LAN_dl_44); 305 } else { 306 $text .= LAN_dl_13; 307 } 308 $text .= "</td><td style='width:50%; text-align:right'>"; 309 310 if (!$rater->checkrated("download", $dl['download_id']) && USER) { 311 $text .= $rater->rateselect(" <b>".LAN_dl_14, "download", $dl['download_id'])."</b>"; 312 } 313 else if(!USER) { 314 $text .= " "; 315 } else { 316 $text .= LAN_dl_15; 317 } 318 $text .= "</td></tr></table>"; 319 return $text; 320 SC_END 321 322 SC_BEGIN DOWNLOAD_REPORT_LINK 323 global $dl,$pref; 324 return (check_class($pref['download_reportbroken'])) ? "<a href='".e_BASE."download.php?report.".$dl['download_id']."'>".LAN_dl_45."</a>" : ""; 325 SC_END 326 327 SC_BEGIN DOWNLOAD_VIEW_CAPTION 328 global $dl; 329 $text = $dl['download_category_name']; 330 $text .= ($dl['download_category_description']) ? " [ ".$dl['download_category_description']." ]" : ""; 331 return $text; 332 SC_END 333 334 335 // --------- Download View Lans ----------------------------- 336 337 SC_BEGIN DOWNLOAD_VIEW_AUTHOR_LAN 338 global $dl; 339 return ($dl['download_author']) ? LAN_dl_24 : ""; 340 SC_END 341 342 SC_BEGIN DOWNLOAD_VIEW_AUTHOREMAIL_LAN 343 global $dl; 344 return ($dl['download_author_email']) ? LAN_dl_30 : ""; 345 SC_END 346 347 SC_BEGIN DOWNLOAD_VIEW_AUTHORWEBSITE_LAN 348 global $dl; 349 return ($dl['download_author_website']) ? LAN_dl_31 : ""; 350 SC_END 351 352 SC_BEGIN DOWNLOAD_VIEW_DATE_LAN 353 global $dl; 354 return ($dl['download_datestamp']) ? LAN_dl_22 : ""; 355 SC_END 356 357 SC_BEGIN DOWNLOAD_VIEW_IMAGE_LAN 358 return LAN_dl_11; 359 SC_END 360 361 SC_BEGIN DOWNLOAD_VIEW_REQUESTED 362 global $dl; 363 return $dl['download_requested']; 364 SC_END 365 366 SC_BEGIN DOWNLOAD_VIEW_RATING_LAN 367 return LAN_dl_12; 368 SC_END 369 370 SC_BEGIN DOWNLOAD_VIEW_FILESIZE_LAN 371 return LAN_dl_10; 372 SC_END 373 374 SC_BEGIN DOWNLOAD_VIEW_DESCRIPTION_LAN 375 return LAN_dl_7; 376 SC_END 377 378 SC_BEGIN DOWNLOAD_VIEW_REQUESTED_LAN 379 return LAN_dl_77; 380 SC_END 381 382 SC_BEGIN DOWNLOAD_VIEW_LINK_LAN 383 return LAN_dl_32; 384 SC_END 385 386 387 388 // ----------- Download View : Previous and Next --------------- 389 390 SC_BEGIN DOWNLOAD_VIEW_PREV 391 global $dl,$sql; 392 393 $dl_id = intval($dl['download_id']); 394 395 if ($sql->db_Select("download", "*", "download_category='".intval($dl['download_category_id'])."' AND download_id < {$dl_id} AND download_active > 0 && download_visible IN (".USERCLASS_LIST.") ORDER BY download_datestamp DESC LIMIT 1")) { 396 $row = $sql->db_Fetch(); 397 return "<a href='".e_BASE."download.php?view.".$row['download_id']."'><< ".LAN_dl_33." [".$row['download_name']."]</a>\n"; 398 } else { 399 return " "; 400 } 401 SC_END 402 403 SC_BEGIN DOWNLOAD_VIEW_NEXT 404 global $dl,$sql; 405 $dl_id = intval($dl['download_id']); 406 if ($sql->db_Select("download", "*", "download_category='".intval($dl['download_category_id'])."' AND download_id > {$dl_id} AND download_active > 0 && download_visible IN (".USERCLASS_LIST.") ORDER BY download_datestamp ASC LIMIT 1")) { 407 $row = $sql->db_Fetch(); 408 extract($row); 409 return "<a href='".e_BASE."download.php?view.".$row['download_id']."'>[".$row['download_name']."] ".LAN_dl_34." >></a>\n"; 410 } else { 411 return " "; 412 } 413 SC_END 414 415 416 SC_BEGIN DOWNLOAD_BACK_TO_LIST 417 global $dl; 418 return "<a href='".e_BASE."download.php?list.".$dl['download_category']."'>".LAN_dl_35."</a>"; 419 SC_END 420 421 422 // --------------- Download - Admin ----------------------------------- 423 424 SC_BEGIN DOWNLOAD_CATEGORY_SELECT 425 global $sql; 426 $cdc = $parm; 427 428 $boxinfo = "\n"; 429 $qry = " 430 SELECT dc.download_category_name, dc.download_category_order, dc.download_category_id, dc.download_category_parent, 431 dc1.download_category_parent AS d_parent1 432 FROM #download_category AS dc 433 LEFT JOIN #download_category as dc1 ON dc1.download_category_id=dc.download_category_parent AND dc1.download_category_class IN (".USERCLASS_LIST.") 434 LEFT JOIN #download_category as dc2 ON dc2.download_category_id=dc1.download_category_parent "; 435 if (ADMIN === FALSE) $qry .= " WHERE dc.download_category_class IN (".USERCLASS_LIST.") "; 436 $qry .= " ORDER by dc2.download_category_order, dc1.download_category_order, dc.download_category_order"; // This puts main categories first, then sub-cats, then sub-sub cats 437 438 if (!$sql->db_Select_gen($qry)) 439 { 440 return "Error reading categories<br />"; 441 exit; 442 } 443 444 $boxinfo .= "<select name='download_category' class='tbox'> 445 <option value=''> </option>\n"; 446 447 // Its a structured display option - need a 2-step process to create a tree 448 $catlist = array(); 449 while ($row = $sql->db_Fetch()) 450 { 451 $tmp = $row['download_category_parent']; 452 if ($tmp == '0') 453 { 454 $row['subcats'] = array(); 455 $catlist[$row['download_category_id']] = $row; 456 } 457 else 458 { 459 if (isset($catlist[$tmp])) 460 { // Sub-Category 461 $catlist[$tmp]['subcats'][$row['download_category_id']] = $row; 462 $catlist[$tmp]['subcats'][$row['download_category_id']]['subsubcats'] = array(); 463 } 464 else 465 { // Its a sub-sub category 466 if (isset($catlist[$row['d_parent1']]['subcats'][$tmp])) 467 { 468 $catlist[$row['d_parent1']]['subcats'][$tmp]['subsubcats'][$row['download_category_id']] = $row; 469 } 470 } 471 } 472 } 473 474 // Now generate the options 475 foreach ($catlist as $thiscat) 476 { // Main categories 477 // Could add a display class to the group, but the default looked OK 478 $boxinfo .= "<optgroup label='".htmlspecialchars($thiscat['download_category_name'])."'>\n"; 479 $scprefix = ''; 480 481 foreach ($thiscat['subcats'] as $sc) 482 { // Sub-categories 483 $sscprefix = '--> '; 484 $boxinfo .= "<option value='".$sc['download_category_id']."'"; 485 if ($cdc == $sc['download_category_id']) { $boxinfo .= " selected='selected'"; } 486 $boxinfo .= ">".$scprefix.htmlspecialchars($sc['download_category_name'])."</option>\n"; 487 foreach ($sc['subsubcats'] as $ssc) 488 { // Sub-sub categories 489 $boxinfo .= "<option value='".$ssc['download_category_id']."'"; 490 if ($cdc == $ssc['download_category_id']) { $boxinfo .= " selected='selected'"; } 491 $boxinfo .= ">".htmlspecialchars($sscprefix.$ssc['download_category_name'])."</option>\n"; 492 } 493 } 494 $boxinfo .= "</optgroup>\n"; 495 } 496 497 $boxinfo .= "</select>\n"; 498 return $boxinfo; 499 500 SC_END 501 502 503 504 505 506 507 */ 508 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Apr 1 01:23:32 2007 | par Balluche grâce à PHPXref 0.7 |