} } $exitmode = isset($spam['exitmode']) ? $spam['exitmode'] : ''; // Hack: ignorance several keys if ($_ignore) { $_vars = array(); foreach ($vars as $key => $value) { $_vars[$key] =& $vars[$key]; } foreach ($_ignore as $key) { unset($_vars[$key]); } } else { $_vars =& $vars; } pkwk_spamfilter($method . ' to #' . $_plugin, $_page, $_vars, $_method, $exitmode); } } // If page output, enable session. // NOTE: if action plugin(command) use session, call pkwk_session_start() // in plugin action-API function. pkwk_session_start(); // auth remoteip if (isset($auth_api['remoteip']['use']) && $auth_api['remoteip']['use']) { if (exist_plugin_inline('remoteip')) { do_plugin_inline('remoteip'); } } $is_protect = auth::is_protect(); // Plugin execution if ($plugin != '') {
function attach_doupload(&$file, $page, $pass = NULL, $temp = '', $copyright = FALSE, $notouch = FALSE) { global $_attach_messages; global $notify, $notify_subject, $notify_exclude, $spam; $type = get_mimeinfo($file['tmp_name']); $must_compress = attach_is_compress($type, PLUGIN_ATTACH_UNKNOWN_COMPRESS); if ($must_compress) { // if attach spam, filtering attach file. $vars['uploadname'] = $file['name']; $vars['uploadtext'] = attach_gettext($file['tmp_name']); if ($vars['uploadtext'] === '' || $vars['uploadtext'] === FALSE) { return FALSE; } //global $spam; if ($spam !== 0) { if (isset($spam['method']['attach'])) { $_method =& $spam['method']['attach']; } else { if (isset($spam['method']['_default'])) { $_method =& $spam['method']['_default']; } else { $_method = array(); } } $exitmode = isset($spam['exitmode']) ? $spam['exitmode'] : ''; pkwk_spamfilter('File Attach', $page, $vars, $_method, $exitmode); } } if ($must_compress && is_uploaded_file($file['tmp_name'])) { if (PLUGIN_ATTACH_COMPRESS_TYPE == 'TGZ' && exist_plugin('dump')) { $obj =& new AttachFile($page, $file['name'] . '.tgz'); if ($obj->exist) { return array('result' => FALSE, 'msg' => $_attach_messages['err_exists']); } $tar = new tarlib(); $tar->create(CACHE_DIR, 'tgz') or die_message(_("It failed in the generation of a temporary file.")); $tar->add_file($file['tmp_name'], $file['name']); $tar->close(); @rename($tar->filename, $obj->filename); chmod($obj->filename, PLUGIN_ATTACH_FILE_MODE); @unlink($tar->filename); } else { if (PLUGIN_ATTACH_COMPRESS_TYPE == 'GZ' && extension_loaded('zlib')) { $obj =& new AttachFile($page, $file['name'] . '.gz'); if ($obj->exist) { return array('result' => FALSE, 'msg' => $_attach_messages['err_exists']); } $tp = fopen($file['tmp_name'], 'rb') or die_message(_("The uploaded file cannot be read.")); // アップロードされたファイルが読めません。 $zp = gzopen($obj->filename, 'wb') or die_message(_("The compression file cannot be written.")); // 圧縮ファイルが書けません。 while (!feof($tp)) { gzwrite($zp, fread($tp, 8192)); } gzclose($zp); fclose($tp); chmod($obj->filename, PLUGIN_ATTACH_FILE_MODE); @unlink($file['tmp_name']); } else { if (PLUGIN_ATTACH_COMPRESS_TYPE == 'ZIP' && class_exists('ZipArchive')) { $obj =& new AttachFile($page, $file['name'] . '.zip'); if ($obj->exist) { return array('result' => FALSE, 'msg' => $_attach_messages['err_exists']); } $zip = new ZipArchive(); $zip->addFile($file['tmp_name'], $file['name']); // if ($zip->status !== ZIPARCHIVE::ER_OK) if ($zip->status !== 0) { die_message(_('The error occurred') . '(' . $zip->status . ').'); } $zip->close(); chmod($obj->filename, PLUGIN_ATTACH_FILE_MODE); @unlink($file['tmp_name']); } } } } else { //miko $obj =& new AttachFile($page, $file['name']); if ($obj->exist) { return array('result' => FALSE, 'msg' => $_attach_messages['err_exists']); } if (move_uploaded_file($file['tmp_name'], $obj->filename)) { chmod($obj->filename, PLUGIN_ATTACH_FILE_MODE); } } if (is_page($page)) { touch(get_filename($page)); } $obj->getstatus(); $obj->status['pass'] = $pass !== TRUE && $pass !== NULL ? md5($pass) : ''; $obj->putstatus(); if ($notify) { $notify_exec = TRUE; foreach ($notify_exclude as $exclude) { $exclude = preg_quote($exclude); if (substr($exclude, -1) == '.') { $exclude = $exclude . '*'; } if (preg_match('/^' . $exclude . '/', $_SERVER['REMOTE_ADDR'])) { $notify_exec = FALSE; break; } } } else { $notify_exec = FALSE; } if ($notify_exec !== FALSE) { $footer['ACTION'] = 'File attached'; $footer['FILENAME'] =& $file['name']; $footer['FILESIZE'] =& $file['size']; $footer['PAGE'] =& $page; $footer['URI'] = get_script_absuri() . '?plugin=attach' . '&refer=' . rawurlencode($page) . '&file=' . rawurlencode($file['name']) . '&pcmd=info'; $footer['USER_AGENT'] = TRUE; $footer['REMOTE_ADDR'] = TRUE; pkwk_mail_notify($notify_subject, "\n", $footer); } return array('result' => TRUE, 'msg' => $_attach_messages['msg_uploaded']); }