function upload_save_files() { global $db, $main_smarty, $dblang, $the_template, $linkres, $current_user; $settings = get_upload_settings(); $upload_dir = mnmpath . $settings['directory']; $count = 0; $extensions = split('[ ,.]+', $settings['extensions']); if (is_dir($upload_dir)) { foreach ($_FILES["upload_files"]["error"] as $key => $err) { if ($_FILES["upload_files"]["size"][$key] / 1024 > $settings['filesize']) { $error = "Maximum file size ({$settings['filesize']} Kb) exceeded"; } elseif ($err == UPLOAD_ERR_OK) { $tmp_name = $_FILES["upload_files"]["tmp_name"][$key]; $name = $_FILES["upload_files"]["name"][$key]; if ($ext = strrchr($name, '.')) { $name = str_replace($ext, '', $name); $ext = substr($ext, 1); } if ($ext && in_array(strtolower($ext), $extensions)) { while (file_exists("{$upload_dir}/{$name}{$i}.{$ext}")) { $i++; } $name .= $i; if (@move_uploaded_file($tmp_name, "{$upload_dir}/{$name}.{$ext}")) { $db->query("INSERT INTO " . table_prefix . "files \r\n\t\t\t\t\t\tSET file_size='orig',\r\n\t\t\t\t\t\t file_user_id={$current_user->user_id},\r\n\t\t\t\t\t\t file_link_id={$linkres->id},\r\n\t\t\t\t\t\t file_real_size='{$_FILES["upload_files"]["size"][$key]}',\r\n\t\t\t\t\t\t file_name='" . $db->escape("{$name}.{$ext}") . "'"); $count++; $error = generate_thumbs("{$upload_dir}/{$name}.{$ext}", $linkres->id, $settings, $db->insert_id); } else { $error = "Error copying file to {$upload_dir}/{$name}"; } } else { $error = "Extension .{$ext} is not allowed"; } } } } else { $error = "Directory {$upload_dir} does not exists"; } // Add external links here if ($settings['external']) { foreach ($_POST["upload_urls"] as $url) { if ($count > $settings['maxnumber']) { break; } if (strlen($url) > 10 && strpos($url, 'http') === 0) { $db->query("INSERT INTO " . table_prefix . "files \r\n\t\t\t\t\tSET file_size='orig',\r\n\t\t\t\t\t file_user_id={$current_user->user_id},\r\n\t\t\t\t\t file_link_id={$linkres->id},\r\n\t\t\t\t\t file_name='" . $db->escape($url) . "'"); $count++; $error = generate_thumbs($url, $linkres->id, $settings, $db->insert_id); } } } if ($error) { print $error; exit; } }
module_add_action('comment_deleted', 'upload_comment_delete', ''); $place = get_misc_data('upload_place'); $fileplace = get_misc_data('upload_fileplace'); module_add_action_tpl($place, upload_tpl_path . '/upload_thumb.tpl'); module_add_action_tpl($fileplace, upload_tpl_path . '/upload_links.tpl'); module_add_action_tpl('tpl_header_admin_main_links', upload_tpl_path . 'upload_admin_main_link.tpl'); if ($settings['allow_comment']) { module_add_action('show_comment_content', 'upload_comment_track', ''); module_add_action_tpl($settings['commentplace'], upload_tpl_path . '/upload_comment_thumb.tpl'); module_add_action_tpl($settings['commentfilelist'], upload_tpl_path . '/upload_links.tpl'); } } $include_in_pages = array('submit', 'story', 'edit'); if (do_we_load_module()) { include_once mnmmodules . 'upload/upload_main.php'; module_add_action_tpl('tpl_pligg_submit_step2_after_form', upload_tpl_path . '/upload_files.tpl'); $settings = get_upload_settings(); if ($settings['allow_comment']) { module_add_action('after_comment_submit', 'upload_do_comment_submit', ''); module_add_action('after_comment_edit', 'upload_do_comment_submit', ''); module_add_action_tpl('tpl_pligg_story_comments_form_end', upload_tpl_path . '/upload_comments.tpl'); } } $include_in_pages = array('editlink'); if (do_we_load_module()) { module_add_action('edit_link_hook', 'upload_edit_link', ''); include_once mnmmodules . 'upload/upload_main.php'; module_add_action_tpl('tpl_pligg_submit_step2_after_form', upload_tpl_path . '/upload_files.tpl'); // module_add_action_tpl('submit_step_2_pre_extrafields', upload_tpl_path . '/edit_files.tpl'); } }