topic_templates.php ---------------------------- function build_tpl_item ($item, $val) { global $HTTP_POST_FILES; if($item == 'screen_shots') { $screen_shots = ''; for ($i = 0; $i < count($HTTP_POST_FILES['screen_shots']['size']); $i++) { $screen_shots .= upload_file($HTTP_POST_FILES['screen_shots'], $i); } $screen_shots = ($screen_shots) ? "\n" . '[spoiler="'. $GLOBALS['lang']['tpl']['screen_shots'] .'"]'. "\n" .'[align=center]'. "\n" . $screen_shots . "[/align]\n[/spoiler]" : ''; return $screen_shots; } if($item == 'poster') { return upload_file($HTTP_POST_FILES['poster'], 0, 'right'); } -------------- и в конец -------------- function upload_file($files_ary, $idx, $align = false) { global $bb_cfg, $lang; $allowed_ext = array('jpeg', 'jpg', 'png', 'gif'); $max_size = $bb_cfg['pic_max_size']; $dir = $bb_cfg['pic_dir']; $url = make_url('/'); $pic = ''; if ($files_ary['size'][$idx] < $max_size) { $name = strtolower($files_ary['name'][$idx]); $ext = substr(strrchr($name, '.'), 1); $allow = in_array($ext, $allowed_ext); $type = '.'. $ext; if ($allow) { $name = md5_file($files_ary['tmp_name'][$idx]); if (file_exists($dir . $name . $type)) { $pic = $url . $dir . $name . $type; } else { if (copy($files_ary['tmp_name'][$idx], $dir.$name.$type)) { $pic = $url . $dir . $name . $type; } } } if($align) { $pic = ($pic) ? "[hr]\n[img=".$align."]". $pic ."[/img]\n\n" : ''; } else { $pic = ($pic) ? "[img]". $pic ."[/img]\n" : ''; } } return $pic; } --------------------- шаблон.tpl --------------------- {L_PICTURE}: --------------------------------------------------------------------- {L_SCREEN_SHOTS}*:
---------------------- шаблон.php ---------------------- $tpl_items = array( 'poster', 'screen_shots', );