function sendMail($spamlev) { global $xoopsUser; $info = array(); $info['TIME'] = date('r', time()); if (is_object($xoopsUser)) { $info['UID'] = (int) $xoopsUser->uid(); $info['UNAME'] = $xoopsUser->uname(); } else { $info['UID'] = 0; $info['UNAME'] = 'Guest'; } $info['REQUEST_URI'] = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : ''; $info['HTTP_REFERER'] = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''; $info['HTTP_USER_AGENT'] = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; $info['REMOTE_ADDR'] = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ''; $info['SPAM LEVEL'] = $spamlev; $_info = ''; foreach ($info as $key => $value) { $_info .= $key . ': ' . $value . "\n"; } $_info .= str_repeat('-', 30) . "\n"; $post = $_POST; // Key:excerpt があればトラックかも->文字コード変換 if (isset($post['excerpt']) && function_exists('mb_convert_variables')) { if (isset($post['charset']) && $post['charset'] != '') { // TrackBack Ping で指定されていることがある // うまくいかない場合は自動検出に切り替え if (mb_convert_variables($this->encode, $post['charset'], $post) !== $post['charset']) { mb_convert_variables($this->encode, 'auto', $post); } } else { if (!empty($post)) { // 全部まとめて、自動検出/変換 mb_convert_variables($this->encode, 'auto', $post); } } } $message = $_info . '$_POST :' . "\n" . print_r($post, TRUE); $message .= "\n" . str_repeat('=', 30) . "\n\n"; if ($this->send_mail_interval) { $mail_tmp = XOOPS_TRUST_PATH . '/uploads/hyp_common/' . str_replace('/', '_', preg_replace('#https?://#i', '', XOOPS_URL)) . '.SPAM.hyp'; if (!file_exists($mail_tmp)) { HypCommonFunc::flock_put_contents($mail_tmp, $message); return; } else { $mtime = filemtime($mail_tmp); if ($mtime + $this->send_mail_interval * 60 > time()) { if (HypCommonFunc::flock_put_contents($mail_tmp, $message, 'ab')) { HypCommonFunc::touch($mail_tmp, $mtime); } return; } else { $message = HypCommonFunc::flock_get_contents($mail_tmp) . $message; unlink($mail_tmp); } } } $config_handler =& xoops_gethandler('config'); $xoopsConfig =& $config_handler->getConfigsByCat(XOOPS_CONF); $subject = '[' . $xoopsConfig['sitename'] . '] POST Spam Report'; $xoopsMailer =& getMailer(); $xoopsMailer->useMail(); $xoopsMailer->setFromEmail($xoopsConfig['adminmail']); $xoopsMailer->setFromName($xoopsConfig['sitename']); $xoopsMailer->setSubject($subject); $xoopsMailer->setBody($message); $xoopsMailer->setToEmails($xoopsConfig['adminmail']); $xoopsMailer->send(); $xoopsMailer->reset(); }
function flock_put_contents($filename, $src, $mode = 'wb', $maxRetry = 10) { return HypCommonFunc::flock_put_contents($filename, $src, $mode, $maxRetry); }
function save_i4ks($size_file, $size, $mime) { HypCommonFunc::flock_put_contents($size_file, $size[0] . 'x' . $size[1] . "\n" . $mime); }
function ref_save($page) { if ($this->cont['PKWK_READONLY'] || !$this->root->referer || !empty($this->cont['page_show']) || empty($_SERVER['HTTP_REFERER'])) { return TRUE; } $url = $_SERVER['HTTP_REFERER']; // Validate URI (Ignore own) $parse_url = parse_url($url); if (empty($parse_url['host']) || $parse_url['host'] === $_SERVER['HTTP_HOST']) { return TRUE; } if (!is_dir($this->cont['TRACKBACK_DIR'])) { die('No such directory: TRACKBACK_DIR'); } if (!is_writable($this->cont['TRACKBACK_DIR'])) { die('Permission denied to write: TRACKBACK_DIR'); } // Update referer data if (preg_match('/[,"\\n\\r]/', $url)) { $url = '"' . str_replace('"', '""', $url) . '"'; } $filename = $this->tb_get_filename($page, '.ref'); $data = $this->tb_get($filename, 3); $d_url = rawurldecode($url); if (!isset($data[$d_url])) { $data[$d_url] = array('', $this->cont['UTIME'], 0, $url, 1); } $data[$d_url][0] = $this->cont['UTIME']; $data[$d_url][2]++; $text = ''; foreach ($data as $line) { $text .= join(',', $line) . "\n"; } if (!HypCommonFunc::flock_put_contents($filename, $text)) { return FALSE; } // $fp = fopen($filename, 'w'); // if ($fp === FALSE) return FALSE; // set_file_buffer($fp, 0); // flock($fp, LOCK_EX); // rewind($fp); // foreach ($data as $line) // fwrite($fp, join(',', $line) . "\n"); // fclose($fp); return TRUE; }