function plugin_attachref_action() { global $vars; global $_attachref_messages; $retval['msg'] = $_attachref_messages['msg_title']; $retval['body'] = ''; $refer = isset($vars['refer']) ? $vars['refer'] : false; if (isset($_FILES[PLUGIN_ATTACH_FILE_FIELD_NAME]) && $refer !== false) { $wiki = Factory::Wiki($refer); if (!$wiki->isValied()) { Utility::dieMessage('#attachref : invalied page.'); } $file = $_FILES[PLUGIN_ATTACH_FILE_FIELD_NAME]; $attachname = $file['name'][0]; $filename = preg_replace('/\\..+$/', '', $attachname, 1); // If exist file, add a name '_0', '_1', ... $count = '_0'; while (file_exists(UPLOAD_DIR . encode($refer) . '_' . encode($attachname))) { $attachname = preg_replace('/^[^\\.]+/', $filename . $count++, $attachname); } $file['name'][0] = $attachname; $attach_filename = attachref_get_attach_filename($file); $pass = isset($vars['pass']) ? md5($vars['pass']) : NULL; $retval = attach_upload($refer, $pass); if ($retval['result'] == TRUE) { $retval = attachref_insert_ref($attach_filename); } Utility::redirect($wiki->uri()); } else { $retval = attachref_showform(); } return $retval; }
function plugin_attachref_action() { global $script, $vars; global $_attachref_messages; global $pkwk_dtd; $retval['msg'] = $_attachref_messages['msg_title']; $retval['body'] = ''; if (isset($_FILES['attach_file']) && isset($vars['refer']) && is_page($vars['refer'])) { $file = $_FILES['attach_file']; $attachname = $file['name']; $filename = preg_replace('/\\..+$/', '', $attachname, 1); // If exist file, add a name '_0', '_1', ... $count = '_0'; while (file_exists(UPLOAD_DIR . encode($vars['refer']) . '_' . encode($attachname))) { $attachname = preg_replace('/^[^\\.]+/', $filename . $count++, $file['name']); } $file['name'] = $attachname; require_once PLUGIN_DIR . 'attach.inc.php'; if (!exist_plugin('attach') or !function_exists('attach_upload')) { return array('msg' => 'attach.inc.php not found or not correct version.'); } $attach_filename = attachref_get_attach_filename($file); $pass = isset($vars['pass']) ? md5($vars['pass']) : NULL; $retval = attach_upload($file, $vars['refer'], $pass); if ($retval['result'] == TRUE) { $retval = attachref_insert_ref($attach_filename); } } else { $retval = attachref_showform(); // XHTML 1.0 Transitional if (!isset($pkwk_dtd) || $pkwk_dtd == PKWK_DTD_XHTML_1_1) { $pkwk_dtd = PKWK_DTD_XHTML_1_0_TRANSITIONAL; } } return $retval; }