Example #1
0
 /**
  * @author Sebastien Piraux <*****@*****.**>
  * @desc Record information for open event (when homepage is opened)
  */
 public static function event_open()
 {
     global $_configuration;
     global $TABLETRACK_OPEN;
     // @getHostByAddr($_SERVER['REMOTE_ADDR']) : will provide host and country information
     // $_SERVER['HTTP_USER_AGENT'] :  will provide browser and os information
     // $_SERVER['HTTP_REFERER'] : provide information about refering url
     if (isset($_SERVER['HTT_REFERER'])) {
         $referer = Database::escape_string($_SERVER['HTTP_REFERER']);
     } else {
         $referer = '';
     }
     // record informations only if user comes from another site
     //if(!eregi($_configuration['root_web'],$referer))
     $pos = strpos($referer, $_configuration['root_web']);
     if ($pos === false && $referer != '') {
         $ip = api_get_real_ip();
         $remhost = @getHostByAddr($ip);
         if ($remhost == $ip) {
             $remhost = "Unknown";
         }
         // don't change this
         $reallyNow = api_get_utc_datetime();
         $params = ['open_remote_host' => $remhost, 'open_agent' => $_SERVER['HTTP_USER_AGENT'], 'open_referer' => $referer, 'open_date' => $reallyNow];
         Database::insert($TABLETRACK_OPEN, $params);
     }
     return 1;
 }
Example #2
0
 public function edit($id = '')
 {
     if ($id == '') {
         $id = $_GET['id'];
     }
     if ($id == '') {
         die('You did not provide an id for this function: Notes->edit($id = \'\')');
     }
     if ($this->nonce('edit') == $_POST['nonce']) {
         $contact_id = $_POST['contact_id'];
         $note_id = $_POST['note_id'];
         $note_text = htmlentities($_POST['note_text']);
         $note_edit_time = time();
         $note_edit_ip = $_SERVER['REMOTE_ADDR'];
         $note_edit_hostname = getHostByAddr($note_edit_ip);
         $sql = "UPDATE " . TBL_NOTES . " SET \n\t\t\t\t\t\t\t\tcontact_id = '{$contact_id}',\n\t\t\t\t\t\t\t\tnote_text = '{$note_text}',\n\t\t\t\t\t\t\t\tnote_edit_time = '{$note_edit_time}',\n\t\t\t\t\t\t\t\tnote_edit_ip = '{$note_edit_ip}',\n\t\t\t\t\t\t\t\tnote_edit_hostname = '{$note_edit_hostname}'\n\t\t\t\t\t\t\t\tWHERE note_id = '{$note_id}'";
         //echo 'sql: ' . $sql . '<br />';
         $result = mysql_query($sql) or die(mysql_error());
         if ($result) {
             echo 'Database updated.';
         } else {
             echo 'Failed to update database.';
         }
     } else {
         $contact = new Contact();
         $return = $this->query($id);
         $row = mysql_fetch_assoc($return);
         include "templates/note.edit.form.php";
     }
 }
/**
 * @author Sebastien Piraux <*****@*****.**>
 * @desc Record information for open event (when homepage is opened)
 */
function event_open()
{
    global $_configuration;
    global $TABLETRACK_OPEN;
    // @getHostByAddr($_SERVER['REMOTE_ADDR']) : will provide host and country information
    // $_SERVER['HTTP_USER_AGENT'] :  will provide browser and os information
    // $_SERVER['HTTP_REFERER'] : provide information about refering url
    if (isset($_SERVER['HTT_REFERER'])) {
        $referer = Database::escape_string($_SERVER['HTTP_REFERER']);
    } else {
        $referer = '';
    }
    // record informations only if user comes from another site
    //if(!eregi($_configuration['root_web'],$referer))
    $pos = strpos($referer, $_configuration['root_web']);
    if ($pos === false && $referer != '') {
        $ip = api_get_real_ip();
        $remhost = @getHostByAddr($ip);
        if ($remhost == $ip) {
            $remhost = "Unknown";
        }
        // don't change this
        $reallyNow = api_get_utc_datetime();
        $sql = "INSERT INTO " . $TABLETRACK_OPEN . "\n        \t\t(open_remote_host,\n        \t\t open_agent,\n        \t\t open_referer,\n        \t\t open_date)\n        \t\tVALUES\n        \t\t('" . $remhost . "',\n        \t\t '" . Database::escape_string($_SERVER['HTTP_USER_AGENT']) . "', '" . Database::escape_string($referer) . "', '{$reallyNow}')";
        $res = Database::query($sql);
    }
    return 1;
}
Example #4
0
function _getHostByAddr_timeout($ip, $timeout = 2, $fallback = false)
{
    static $host_bin = null;
    if ($host_bin === null) {
        $host_bin = find_executable('host', array('/usr/bin/', '/usr/sbin/', '/bin/', '/sbin/'));
        if (empty($host_bin)) {
            $host_bin = false;
        }
    }
    if ($host_bin) {
        $err = 0;
        $out = array();
        exec('LANG=C ' . $host_bin . ' -W ' . (int) abs($timeout) . ' ' . qsa($ip) . ' 2>>/dev/null', $out, $err);
        if ($err == 0) {
            if (preg_match('/pointer ([a-z0-9.\\-_]+)/i', implode("\n", $out), $m)) {
                $host = $m[1];
                if (subStr($host, -1) === '.') {
                    $host = subStr($host, 0, -1);
                }
                return $host;
            }
        }
    } else {
        if ($fallback) {
            $host = getHostByAddr($ip);
            if (empty($host) || $host == $ip) {
                return false;
            }
            return $host;
        }
    }
    return false;
}
    public function create()
    {
        if ($this->nonce('create') == $_POST['nonce']) {
            $app_fname = $_POST['app_fname'];
            $app_lname = $_POST['app_lname'];
            $app_phone = $_POST['app_phone'];
            $app_email = $_POST['app_email'];
            $app_reason = htmlentities($_POST['app_details']);
            $app_user = "******";
            $app_type = "appointment";
            $app_create_time = time();
            $app_create_ip = $_SERVER['REMOTE_ADDR'];
            $app_create_hostname = getHostByAddr($app_create_ip);
            if ($app_fname == '' || $app_lname == '' || $app_phone == '') {
                echo '
						You must enter first name, last name, and phone number. <br />
						Please go back and try again.
					';
                die;
            }
            require_once 'templates/appointment.process.php';
            require_once 'templates/appointment.success.php';
            if ($result) {
                $this->sendemail($app_fname, $app_lname, $app_phone, $app_email, $app_reason);
            }
        } else {
            require_once 'templates/appointment.form.php';
        }
    }
Example #6
0
 /**
  * Initialise dummy $_SERVER parameters if not set (ie command line).
  */
 public static function initialiseServerParameters()
 {
     global $argv;
     if (!isset($_SERVER['REQUEST_METHOD'])) {
         $_SERVER['REQUEST_METHOD'] = 'GET';
     }
     if (!isset($_SERVER['REMOTE_ADDR'])) {
         $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
     }
     if (!isset($_SERVER['REQUEST_URI'])) {
         $_SERVER['REQUEST_URI'] = isset($argv[1]) ? $argv[1] : '/';
     }
     if (!isset($_SERVER['SERVER_NAME'])) {
         $_SERVER['SERVER_NAME'] = getHostByAddr('127.0.0.1');
     }
     if (!isset($_SERVER['SERVER_PORT'])) {
         $_SERVER['SERVER_PORT'] = 80;
     }
     if (!isset($_SERVER['HTTP_ACCEPT'])) {
         $_SERVER['HTTP_ACCEPT'] = 'text/html';
     }
 }
Example #7
0
 function logNotFoundURL($url)
 {
     $file = JPATH_SITE . '/logs/mijosef_404.log';
     if (!empty($this->MijosefConfig->log_404_path) && $this->MijosefConfig->log_404_path != '/home/accountname/public_html/logs/mijosef_404.log') {
         $file = $this->MijosefConfig->log_404_path;
     }
     $empty_file = '';
     if (!JFile::exists($file)) {
         JFile::write($file, $empty_file);
     }
     if (!JFile::exists($file)) {
         return;
     }
     $tab = "\t";
     $log_string = date('Y-m-d H:i:s') . $tab;
     $log_string .= 'URL: ' . $url . $tab;
     $log_string .= getHostByAddr($_SERVER['REMOTE_ADDR']) . $tab;
     $log_string .= $_SERVER['HTTP_USER_AGENT'];
     $log_string .= empty($_SERVER['HTTP_REFERER']) ? "" : $tab . 'Referrer: ' . $_SERVER['HTTP_REFERER'];
     $content = JFile::read($file);
     $content = $content . "\n" . $log_string;
     JFile::write($file, $content);
 }
 protected function _do404(&$uri)
 {
     if (self::$requestParsed) {
         return array();
     }
     // get config objects
     $pageInfo =& Sh404sefFactory::getPageInfo();
     $sefConfig = Sh404sefFactory::getConfig();
     // store the status
     $pageInfo->httpStatus = 404;
     // request path
     $reqPath = $uri->getPath();
     // optionnally log the 404 details
     if ($sefConfig->shLog404Errors && !empty($reqPath)) {
         try {
             $record = Sh404sefHelperDb::selectObject('#__sh404sef_urls', '*', array('oldurl' => $reqPath));
             if (!empty($record)) {
                 // we have, so update counter
                 Sh404sefHelperDb::queryQuote('update ?? set cpt=(cpt+1) where ?? = ?', array('#__sh404sef_urls', 'oldurl'), array($reqPath));
             } else {
                 // record the 404
                 Sh404sefHelperDb::insert('#__sh404sef_urls', array('cpt' => 1, 'rank' => 0, 'oldurl' => $reqPath, 'newurl' => '', 'dateadd' => Sh404sefHelperDate::getUTCNow('Y-m-d')));
             }
             // add more details about 404 into security log file
             if ($sefConfig->shSecEnableSecurity && $sefConfig->shSecLogAttacks) {
                 $sep = "\t";
                 $logData = date('Y-m-d') . $sep . date('H:i:s') . $sep . 'Page not found (404)' . $sep . $_SERVER['REMOTE_ADDR'] . $sep;
                 $logData .= getHostByAddr($_SERVER['REMOTE_ADDR']) . $sep;
                 $userAgent = empty($_SERVER['HTTP_USER_AGENT']) ? 'No user agent' : $_SERVER['HTTP_USER_AGENT'];
                 $logData .= $userAgent . $sep . $_SERVER['REQUEST_METHOD'] . $sep . $_SERVER['REQUEST_URI'];
                 $logData .= empty($_SERVER['HTTP_REFERER']) ? "\n" : $sep . $_SERVER['HTTP_REFERER'] . "\n";
                 shLogToSecFile($logData);
             }
         } catch (Sh404sefExceptionDefault $e) {
             _log(__METHOD__ . '/' . __LINE__ . '/' . __CLASS__ . ': Database error: ' . $e->getMessage());
         }
     }
     // display the error page
     $vars['option'] = 'com_content';
     $vars['view'] = 'article';
     // use provided Itemid
     if (empty($sefConfig->shPageNotFoundItemid)) {
         $shHomePage = JFactory::getApplication()->getMenu()->getDefault();
         $vars['Itemid'] = empty($shHomePage) ? null : $shHomePage->id;
     } else {
         $vars['Itemid'] = $sefConfig->shPageNotFoundItemid;
     }
     // user picked our default 404 error page, read its id from DB
     if ($sefConfig->page404 == '0') {
         try {
             $requestedlanguageTag = JFactory::getLanguage()->getTag();
             $languageTag = JRequest::getString(JUtility::getHash('language'), null, 'cookie');
             if (!empty($languageTag)) {
                 $vars['lang'] = $languageTag;
             }
             $ids = Sh404sefHelperDb::queryQuoteOnly('select ?? from ?? where ?? = ? and ?? in ( ?, ?) order by ?? desc', array('id', '#__content', 'title', 'language', 'language'), array('__404__', $languageTag, '*'))->eLoadResultArray();
             $id = empty($ids[0]) ? null : $ids[0];
         } catch (Sh404sefExceptionDefault $e) {
             _log(__METHOD__ . '/' . __LINE__ . '/' . __CLASS__ . ': Database error: ' . $e->getMessage());
         }
         if (empty($id)) {
             JError::raiseError(404, JText::_('Component Not Found') . ' (' . $pageInfo->getDefaultLiveSite() . '/' . $uri->getPath() . ')');
         }
     } else {
         $id = $sefConfig->page404;
     }
     $vars['id'] = $id;
     $uri = new JURI($pageInfo->getDefaultLiveSite() . '/index.php?' . 'option=com_content&view=article&id=' . $id . (empty($vars['Itemid']) ? '' : '&Itemid=' . $vars['Itemid']) . (empty($vars['lang']) ? '' : '&lang=' . shGetIsoCodeFromName($vars['lang'])));
     $tmpl = str_replace('.php', '', $sefConfig->error404SubTemplate);
     if (!empty($tmpl)) {
         $vars['tmpl'] = $tmpl;
     }
     // and prepare the item for display
     $menus =& JFactory::getApplication()->getMenu();
     $menuItem = $menus->getItem($vars['Itemid']);
     if (!empty($menuItem)) {
         $menus->setActive($vars['Itemid']);
     } else {
         $menuItem = $menus->getDefault();
     }
     if (!empty($menuItem->params)) {
         $disableParams = array('show_title', 'show_category', 'show_author', 'show_create_date', 'show_modify_date', 'show_publish_date', 'show_vote', 'show_readmore', 'show_icons', 'show_hits', 'show_feed_link', 'show_page_heading');
         foreach ($disableParams as $p) {
             $menuItem->params->set($p, 0);
         }
         //set a custom page title
         $menuItem->params->set('page_title', htmlspecialchars($uri->get('_uri')));
     }
     // set the menu query array, J! will use that for breadcrumb
     $menuItem->query = $vars;
     // throw 404 http return code, and prepare for page display
     if (!headers_sent()) {
         JResponse::setHeader('status', '404 NOT FOUND');
         // custom error page, faster than loading Joomla 404 page. Not recommended though, why not show
         // your site ?
         if (is_readable(sh404SEF_FRONT_ABS_PATH . '404-Not-Found.tpl.html')) {
             $errorPage = file_get_contents(sh404SEF_FRONT_ABS_PATH . '404-Not-Found.tpl.html');
             if ($errorPage !== false) {
                 $errorPage = str_replace('%sh404SEF_404_URL%', ' (' . $pageInfo->getDefaultLiveSite() . '/' . $uri->getPath() . ')', $errorPage);
                 $errorPage = str_replace('%sh404SEF_404_SITE_URL%', $pageInfo->getDefaultLiveSite(), $errorPage);
                 $errorPage = str_replace('%sh404SEF_404_SITE_NAME%', JFactory::getApplication()->getCfg('sitename'), $errorPage);
                 echo $errorPage;
                 die;
             }
         }
     } else {
         _log('Headers already sent before getting control on 404 page - message displayed');
         $shUri = new JUri();
         $shOriginalUri = new JURI();
         $url = shSefRelToAbs($pageInfo->getDefaultLiveSite() . "/index.php?" . $_SERVER['QUERY_STRING'], '', $shUri, $shOriginalUri);
         JError::RaiseError(500, "<br />SH404SEF : headers were already sent when I got control!<br />This is not necessarily a sh404sef error. It may have been caused by any of your extensions or even Joomla itself. If there is no error message above this one, providing more details, then you may look inside the error log file of your web server for an indication of what may be breaking things up.<br />URL=" . $url . '<br />');
     }
     return $vars;
 }
Example #9
0
 public function note()
 {
     $id = $_GET['id'];
     if ($id == "") {
         die('You did not provide an id for this function: Contact->note()');
     }
     if ($this->nonce('note') == $_POST['nonce']) {
         $contact_id = $_POST['contact_id'];
         $note_text = htmlentities($_POST['note_text']);
         $note_user = "******";
         $note_file_type = "note";
         $note_create_time = time();
         $note_create_ip = $_SERVER['REMOTE_ADDR'];
         $note_create_hostname = getHostByAddr($note_create_ip);
         $sql = "INSERT INTO " . TBL_NOTES . " (\n\t\t\t\t\t\t\t\tcontact_id, \n\t\t\t\t\t\t\t\tnote_type, \n\t\t\t\t\t\t\t\tnote_text, \n\t\t\t\t\t\t\t\tnote_user, \n\t\t\t\t\t\t\t\tnote_create_time, \n\t\t\t\t\t\t\t\tnote_create_ip, \n\t\t\t\t\t\t\t\tnote_create_hostname) ";
         $sql .= "VALUES (\n\t\t\t\t\t\t\t\t'{$contact_id}',\n\t\t\t\t\t\t\t\t'{$note_type}',\n\t\t\t\t\t\t\t\t'{$note_text}',\n\t\t\t\t\t\t\t\t'{$note_user}',\n\t\t\t\t\t\t\t\t'{$note_create_time}',\n\t\t\t\t\t\t\t\t'{$note_create_ip}',\n\t\t\t\t\t\t\t\t'{$note_create_hostname}')";
         $result = mysql_query($sql);
         echo '<div class="content-box">';
         if ($result) {
             echo 'Database updated.';
         } else {
             echo 'Failed to update database.';
         }
         echo '</div>';
         $this->cp_upload($contact_id);
     } else {
         $return = $this->query($id);
         $row = mysql_fetch_assoc($return);
         include "templates/note.form.php";
     }
 }
Example #10
0
 /**
  * Get the remote domain of the current request
  * @return string
  */
 function getRemoteDomain()
 {
     static $remoteDomain;
     if (!isset($remoteDomain)) {
         $remoteDomain = null;
         $remoteDomain = @getHostByAddr(Request::getRemoteAddr());
         HookRegistry::call('Request::getRemoteDomain', array(&$remoteDomain));
     }
     return $remoteDomain;
 }
Example #11
0
 /**
  * Returns the host of the remote client.
  * @return string|NULL
  */
 public function getRemoteHost()
 {
     if ($this->remoteHost === NULL && $this->remoteAddress !== NULL) {
         $this->remoteHost = getHostByAddr($this->remoteAddress);
     }
     return $this->remoteHost;
 }
Example #12
0
     $results = $database->loadObjectList();
     if ($results) {
         // we have, so update counter
         //$database->setQuery("UPDATE #__redirection SET cpt=(cpt+1) WHERE oldurl = '".$path."'");
         //$database->query();
     } else {
         // record the bad URL
         $query = 'INSERT INTO `#__redirection` ( `cpt` , `rank`, `oldurl` , `newurl` , `dateadd` ) ' . ' VALUES ( \'1\', \'0\',\'' . $path . '\', \'\', CURDATE() );' . ' ';
         $database->setQuery($query);
         $database->query();
     }
     // add more details about 404 into security log file
     if ($sefConfig->shSecEnableSecurity && $sefConfig->shSecLogAttacks) {
         $sep = "\t";
         $logData = date('Y-m-d') . $sep . date('H:i:s') . $sep . 'Page not found (404)' . $sep . $_SERVER['REMOTE_ADDR'] . $sep;
         $logData .= getHostByAddr($_SERVER['REMOTE_ADDR']) . $sep;
         $userAgent = empty($_SERVER['HTTP_USER_AGENT']) ? 'No user agent' : $_SERVER['HTTP_USER_AGENT'];
         $logData .= $userAgent . $sep . $_SERVER['REQUEST_METHOD'] . $sep . $_SERVER['REQUEST_URI'];
         $logData .= empty($_SERVER['HTTP_REFERER']) ? "\n" : $sep . $_SERVER['HTTP_REFERER'] . "\n";
         shLogToSecFile($logData);
     }
 }
 // redirect to the error page
 // You MUST create a static content page with the title 404 for this to work properly
 $mosmsg = ' (' . $GLOBALS['shConfigLiveSite'] . '/' . JString::ltrim($path, '/') . ')';
 // V 1.2.4.t
 $vars['option'] = 'com_content';
 $vars['view'] = 'article';
 // use provided Itemid
 if (empty($sefConfig->shPageNotFoundItemid)) {
     $menu =& shRouter::shGetMenu();
 /**
  * Get the remote domain of the current request
  * @return string
  */
 function getRemoteDomain()
 {
     $_this =& PKPRequest::_checkThis();
     static $remoteDomain;
     if (!isset($remoteDomain)) {
         $remoteDomain = null;
         $remoteDomain = @getHostByAddr($_this->getRemoteAddr());
         HookRegistry::call('Request::getRemoteDomain', array(&$remoteDomain));
     }
     return $remoteDomain;
 }
Example #14
0
function PKWKMAIL_sent($attr)
{
    global $vars, $_pkwkmail_msg, $google_apps, $google_apps_domain, $passwd;
    // digest check - 新規生成するダイジェストとPOST値比較
    $digest = md5(join('', get_source($vars['page'])));
    $s_digest = htmlspecialchars($digest, ENT_QUOTES);
    if ($vars['digest'] != $s_digest) {
        die_message('Invalid digest.');
    }
    $mail_content = array();
    //formatting values: do not open $vars by foreach - POST値等から変数生成
    $mail_content['sendmeacopy'] = isset($vars['sendmeacopy']) ? htmlspecialchars($vars['sendmeacopy'], ENT_QUOTES) : NULL;
    $mail_content['mail_data'] = htmlspecialchars($vars['mail_data'], ENT_QUOTES);
    $mail_content['mail_adrs'] = htmlspecialchars($vars['mail_adrs'], ENT_QUOTES);
    $mail_content['admin_adrs'] = $attr['admin_adrs'];
    $mail_content['admin_reply_to'] = !empty($attr['admin_reply_to']) ? $attr['admin_reply_to'] : $mail_content['mail_adrs'];
    foreach ($mail_content as $key => $value) {
        if (get_magic_quotes_gpc()) {
            $mail_content[$key] = stripslashes($value);
        }
    }
    //preparing rendering data - 画面作成用データ準備
    $mail_content['render_scrn'] = explode('PKWKMAIL_LATER_RETRUN', $mail_content['mail_data']);
    $a = array_pop($mail_content['render_scrn']);
    $scrn_content = '';
    foreach ($mail_content['render_scrn'] as $key => $value) {
        $value = str_replace("\t", '</th><td class="style_td">', $value);
        $value = '<tr><th class="style_th">' . $value . '</td></tr>' . "\n";
        $scrn_content .= $value;
    }
    //preparing sending data - 送信データ準備
    $mail_content['mail_data'] = str_replace("\t", ': ', $mail_content['mail_data']);
    $mail_content['mail_data'] = str_replace('PKWKMAIL_LATER_RETRUN', "\n", $mail_content['mail_data']);
    //formatting madrs: return address - Choose one from plural Address
    // メール投稿者宛に送信する際に、管理者アドレスが複数登録されていた場合 From: ヘッダーに複数人登場するため、管理者アドレスを先頭1名にする
    if (!strpos($mail_content['admin_adrs'], ',') === false) {
        $admin_adrs_return = explode(',', $mail_content['admin_adrs']);
        $admin_adrs_return = $admin_adrs_return[0];
    } else {
        $admin_adrs_return = $mail_content['admin_adrs'];
    }
    //formatting madrs: client address check
    //クライアント側のメールアドレス確認。第2段階のチェックを通り抜けて、かつここのチェックを通らないとしたら、送信画面への直投稿なので die する
    $rc = PKWKMAIL_MailAddrCheck($mail_content['mail_adrs'], $attr['domain_check']);
    if ($rc['err']) {
        die_message(sprintf($_pkwkmail_msg[$rc['msg']], $mail_content['mail_adrs']));
    }
    $mail_to_admin = array();
    //admin side - 管理者への送信内容
    $mail_to_admin = $mail_content['mail_data'] . "\n\n";
    $mail_to_admin = PKWKMAIL_mailformat($mail_to_admin);
    $mail_to_admin .= '-- ' . "\n";
    if ($mail_content['sendmeacopy'] == 1) {
        $mail_to_admin .= 'Copy has been sent.' . "\n";
    } else {
        $mail_to_admin .= 'Copy has not been sent.' . "\n";
    }
    $mail_to_admin .= 'Date: ' . date('Y-m-d (D) H:i:s', UTIME) . "\n";
    $mail_to_admin .= 'Host: ' . getHostByAddr(getenv('REMOTE_ADDR')) . "\n";
    $mail_to_admin .= isset($_SERVER['HTTP_USER_AGENT']) ? 'UA: ' . $_SERVER['HTTP_USER_AGENT'] . "\n" : NULL;
    $mail_to_admin .= 'Powered by PKWKMAIL.' . "\n";
    $mail_to_admin_header = 'From:' . $mail_content['mail_adrs'] . "\n";
    $mail_to_admin_header .= 'Reply-To:' . $mail_content['admin_reply_to'] . "\n";
    $mail_to_admin_header .= 'Return-Path:' . $mail_content['mail_adrs'] . "\n";
    $mail_to_admin_header .= 'Content-Type: text/plain;charset=iso-2022-jp' . "\n";
    $mail_to_admin_header .= 'X-Mailer: PKWKMAIL / PHP ver.' . phpversion();
    //	$mail_to_admin_title = mb_convert_encoding($attr['contact_title_to_admin'], 'ISO-2022-JP', 'auto');
    $mail_to_admin_title = $attr['contact_title_to_admin'];
    $mail_to_admin_title = base64_encode($mail_to_admin_title);
    $mail_to_admin_title = "=?iso-2022-jp?B?" . $mail_to_admin_title . "?=";
    //client side - クライアント側への送信内容
    $mail_to_client = $attr['reply_message'] . "\n\n";
    $mail_to_client .= $mail_content['mail_data'] . "\n\n";
    $mail_to_client .= $attr['reply_message_foot'] . "\n\n";
    $mail_to_client .= '-- ' . "\n";
    // 署名が設定されている場合
    if (!empty($attr['client_signature'])) {
        $mail_to_client .= $attr['client_signature'] . "\n";
    } else {
        $mail_to_client .= 'Date: ' . date('Y-m-d (D) H:i:s', UTIME) . "\n";
    }
    $mail_to_client = PKWKMAIL_mailformat($mail_to_client);
    if ($attr['admin_return_allowed'] == 1) {
        $mail_to_client_header = 'From:' . $admin_adrs_return . "\n";
        $mail_to_client_header .= 'Reply-To:' . $admin_adrs_return . "\n";
    }
    $mail_to_client_header .= 'Content-Type: text/plain;charset=iso-2022-jp' . "\n";
    $mail_to_client_header .= 'X-Mailer: PKWKMAIL';
    //	$mail_to_client_title = mb_convert_encoding($attr['contact_title_to_client'], 'ISO-2022-JP', 'auto');
    $mail_to_client_title = $attr['contact_title_to_client'];
    $mail_to_client_title = base64_encode($mail_to_client_title);
    $mail_to_client_title = '=?iso-2022-jp?B?' . $mail_to_client_title . '?=';
    //mail - 送信
    $send_err_admin = $send_err_client = false;
    //mail to admin
    if ($google_apps && preg_match('/.*@' . $google_apps_domain . '$/', $mail_content['admin_adrs'])) {
        $mail =& new Qdmail();
        $mail->smtp(true);
        $param = array('host' => 'ASPMX.L.GOOGLE.com', 'port' => 25, 'from' => $mail_content['mail_adrs'], 'protocol' => 'SMTP', 'user' => 'root@' . $google_apps_domain, 'pass' => $passwd);
        $mail->smtpServer($param);
        $mail->to($mail_content['admin_adrs']);
        $mail->subject($mail_to_admin_title);
        $mail->from($mail_content['mail_adrs']);
        $mail->text($mail_to_admin);
        $retval = $mail->send();
    } else {
        if (!mail($mail_content['admin_adrs'], $mail_to_admin_title, $mail_to_admin, $mail_to_admin_header)) {
            $send_err_admin = true;
        }
    }
    //mail to client
    if ($mail_content['sendmeacopy'] == 1) {
        if (!mail($mail_content['mail_adrs'], $mail_to_client_title, $mail_to_client, $mail_to_client_header)) {
            $send_err_client = true;
        }
    }
    //rendering - 送信結果画面
    $vars['page'] = $attr['finish_message_title'] . ' - ' . htmlspecialchars($vars['page'], ENT_QUOTES);
    $result_finish = '';
    if (!$send_err_admin && !$send_err_client) {
        $result_finish = $attr['finish_message'];
        $result_finish .= '<table class="' . PKWKMAIL_TABLE_CLASS . '">' . "\n";
        $result_finish .= $scrn_content;
        $result_finish .= '</table>' . "\n";
        $result_finish .= $attr['finish_message_return'];
    }
    if ($send_err_admin) {
        $result_finish .= '<p>' . $_pkwkmail_msg['send_err_admin'] . '</p>' . "\n";
    }
    if ($send_err_client) {
        $result_finish .= '<p>' . $_pkwkmail_msg['send_err'] . '</p>' . "\n";
    }
    return $result_finish;
}
Example #15
0
<?  

$adminaddress = "*****@*****.**"; 
$siteaddress ="http://www.svaasa.com"; 
$sitename = "Ranjit's SVAAS� ~ Heritage Boutique Spa Haveli"; 
$sitedescription = "One of India's Reputed and Leading Heritage Boutique Spa Resorts";

//No need to change anything below ... 
// Gets the date and time from your server
$date = date("m/d/Y H:i:s");

// Gets the IP Address
if ($REMOTE_ADDR == "") $ip = "no ip";
else $ip = getHostByAddr($REMOTE_ADDR);

// Gets the POST Headers - the Flash variables
$action = $HTTP_POST_VARS['action'] ;
$email = $HTTP_POST_VARS['email'] ;
$name = $HTTP_POST_VARS['name'] ;
$mobile = $HTTP_POST_VARS['mobile'] ;
$add = $HTTP_POST_VARS['add'] ;
$comments = $HTTP_POST_VARS['comments'] ;

//Process the form data!
// and send the information collected in the Flash form to Your nominated email address

if ($action == "send") {
	//
	mail ("$adminaddress","New Referral of Ranjit's SVAAS� Website to friends",
	"The following visitor at $sitename has referred a friend to the website :
	
 /**
  * Get visitor IP address
  *
  * This method tests rigorously for the current users IP address
  * It tests the $_SERVER vars to find IP addresses even if they
  * are being proxied, forwarded, or otherwise obscured.
  *
  * @param boolean $getHostByAddr the IP address with hostname
  * @return string $ip the formatted IP address
  */
 private function getIP($getHostByAddr = FALSE)
 {
     foreach (array('HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR') as $key) {
         if (array_key_exists($key, $_SERVER) === true) {
             foreach (array_map('trim', explode(',', $_SERVER[$key])) as $ip) {
                 if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false) {
                     if ($getHostByAddr === TRUE) {
                         return getHostByAddr($ip);
                     } else {
                         return $ip;
                     }
                 }
             }
         }
     }
 }
Example #17
0
 public static function getHostname($default = false)
 {
     return true === isset($_SERVER['REMOTE_ADDR']) ? htmlspecialchars(getHostByAddr($_SERVER['REMOTE_ADDR'])) : $default;
 }
Example #18
0
function sendmail()
{
    mb_language("japanese");
    mb_internal_encoding($GLOBALS['charset']);
    $encSender = mb_convert_kana(escString($GLOBALS['sender']), "rnasK", $GLOBALS['charset']);
    $to = $GLOBALS['myMail'];
    $subject = $GLOBALS['mailTitle'];
    $header = "From:" . mb_encode_mimeheader($encSender, "ISO-2022-JP") . "<" . $_SESSION['remail'] . ">";
    $message = $GLOBALS['mailText'] . "\n\n";
    foreach ($_SESSION['contents'] as $key => $value) {
        $message .= escString($key) . " : " . $value . "\n";
    }
    $message .= "\n\n送信日時 : " . date("Y/m/d (D) H:i:s", time()) . "\n";
    $message .= "ホスト名 : " . getHostByAddr(getenv('REMOTE_ADDR')) . "\n\n";
    $encMsg = mb_convert_kana($message, "rnasK", $GLOBALS['charset']);
    if (mb_send_mail($to, $subject, $encMsg, $header)) {
        echo $GLOBALS['thanks'];
    } else {
        echo $GLOBALS['errorMsg'];
    }
}
Example #19
0
function backup_mail($file_path, $title, $comment, $img_file_path_array)
{
    global $backup_mail, $backup_mail_address;
    mb_language("Ja");
    mb_internal_encoding("utf-8");
    //メール件名
    $subject = "ニュースプログラムに新規書き込みがありました。";
    $body = "--__PHPFACTORY__\r\n";
    $body .= "Content-Type: text/plain; charset=\"ISO-2022-JP\"\r\n";
    $body .= "\r\n";
    $body .= "ニュースプログラムに新規書き込みがありました。\r\n最新のデータファイルをバックアップ用として添付しました。\n万が一サーバ上のデータファイルが消えた場合はこちらのファイルで復旧できます。\n※このメールは設定ファイルで送信しないよう変更可能です。\n※このファイルを開く場合、メモ帳は厳禁です。必ずUTF-8に対応したエディタで開いて下さい。(TeraPad、DW等)\n※このメールの本文は文字装飾を解除したものになります。\n\n";
    $body .= "===========================\n\n";
    $body .= "【タイトル】\n" . $title . "\n\n";
    $comment = str_replace(array('<br />', '<br>'), "\n", $comment);
    $comment = strip_tags($comment);
    $body .= "【本文】\n" . $comment . "\n\n";
    if (count($img_file_path_array) > 0) {
        $req_dir = str_replace('admin.php', '', $_SERVER["REQUEST_URI"]);
        foreach ($img_file_path_array as $key => $val) {
            $key++;
            $body .= "【画像{$key}】\n" . "http://" . $_SERVER["HTTP_HOST"] . $req_dir . $val . "\n";
        }
    } else {
        $body .= "【画像なし】\n";
    }
    $body .= "\n===========================\n";
    $body .= "投稿された日時:" . date("Y/m/d (D) H:i:s", time()) . "\n";
    $body .= "投稿者のIPアドレス:" . $_SERVER["REMOTE_ADDR"] . "\n";
    $body .= "投稿者のホスト名:" . getHostByAddr(getenv('REMOTE_ADDR')) . "\n";
    $body .= "投稿ページのURL:" . "http://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . "\n";
    $body .= "--__PHPFACTORY__\r\n";
    # 添付ファイルへの処理をします。
    $handle = @fopen($file_path, 'r');
    $attachFile = @fread($handle, filesize($file_path));
    @fclose($handle);
    $attachEncode = base64_encode($attachFile);
    $file_name = 'news.dat';
    $body .= "Content-Type: application/octet-stream; name=\"{$file_path}\"\r\n";
    $body .= "Content-Transfer-Encoding: base64\r\n";
    $body .= "Content-Disposition: attachment; filename=\"{$file_name}\"\r\n";
    $body .= "\r\n";
    $body .= chunk_split($attachEncode) . "\r\n";
    $body .= "--__PHPFACTORY__--\r\n";
    $header = "From: {$backup_mail_address}\nReply-To: " . $backup_mail_address . "\n";
    $header .= "MIME-Version: 1.0\r\nContent-Type: multipart/mixed; boundary=\"__PHPFACTORY__\"\r\n";
    if (ini_get('safe_mode')) {
        $result = @mb_send_mail($backup_mail_address, $subject, $body, $header);
    } else {
        $result = @mb_send_mail($backup_mail_address, $subject, $body, $header, '-f' . $backup_mail_address);
    }
    return $result;
}
Example #20
0
function sh_ozh_httpbl_check($ip)
{
    $sefConfig = Sh404sefFactory::getConfig();
    //$ip='203.144.160.250';  // bad address
    //$ip = '84.103.202.172';     // good address
    // build the lookup DNS query
    // Example : for '127.9.1.2' you should query 'abcdefghijkl.2.1.9.127.dnsbl.httpbl.org'
    $lookup = $sefConfig->shSecHoneyPotKey . '.' . implode('.', array_reverse(explode('.', $ip))) . '.dnsbl.httpbl.org';
    // check query response
    $result = explode('.', gethostbyname($lookup));
    if ($result[0] == 127) {
        // query successful !
        $activity = $result[1];
        $threat = $result[2];
        $type = $result[3];
        $typemeaning = '';
        if ($type == 0) {
            $typemeaning .= 'Search Engine, ';
        }
        if ($type & 1) {
            $typemeaning .= 'Suspicious, ';
        }
        if ($type & 2) {
            $typemeaning .= 'Harvester, ';
        }
        if ($type & 4) {
            $typemeaning .= 'Comment Spammer, ';
        }
        $typemeaning = JString::trim($typemeaning, ', ');
        //echo "$type : $typemeaning of level $threat <br />";
        $block = false;
        // Now determine some blocking policy
        if ($type >= 4 && $threat > 0 || $type < 4 && $threat > 20) {
            $block = true;
        }
        if ($block) {
            shDoRestrictedAccess('Caught by Honey Pot Project', 'Type = ' . $type . ' | Threat= ' . $threat . ' | Act.= ' . $activity . ' | ' . $typemeaning, true);
            die;
        } else {
            // always set cookie to save time at next visit
            setCookie('sh404SEF_auto_notabot', 'OK', time() + 86400, '/');
        }
    }
    // debug info
    if (sh404SEF_DEBUG_HONEY_POT) {
        $causeText = 'Debug: project Honey Pot response';
        $sep = "\t";
        $comment = 'PHP query result = ' . $result[0];
        $logData = date('Y-m-d') . $sep . date('H:i:s') . $sep . $causeText . $sep . $_SERVER['REMOTE_ADDR'] . $sep;
        $logData .= getHostByAddr($_SERVER['REMOTE_ADDR']) . $sep;
        $logData .= $_SERVER['HTTP_USER_AGENT'] . $sep . $_SERVER['REQUEST_METHOD'] . $sep . $_SERVER['REQUEST_URI'] . $sep . $comment;
        $logData .= "\n";
        shLogToSecFile($logData);
    }
}
Example #21
0
 /**
  * Returns the host of the remote client.
  *
  * @return string|null
  */
 public function getRemoteHost()
 {
     if (!$this->remote_host) {
         $this->remote_host = $this->remote_address ? getHostByAddr($this->remote_address) : null;
     }
     return $this->remote_host;
 }
Example #22
0
<?php

include '../common.php';
if ($_POST) {
    $contact_id = $_POST['contact_id'];
    $note_user = "******";
    $note_text = htmlentities($_POST['note_text']);
    $note_create_time = time();
    $note_create_ip = $_SERVER['REMOTE_ADDR'];
    $note_create_hostname = getHostByAddr($note_create_ip);
    $sql = "INSERT INTO " . TBL_NOTES . " (contact_id, note_user, note_text, note_create_time, note_create_ip, note_create_hostname) ";
    $sql .= "VALUES('{$contact_id}','{$note_user}','{$note_text}','{$note_create_time}','{$note_create_ip}','{$note_create_hostname}')";
    //echo 'sql: ' . $sql . '<br />';
    $result = mysql_query($sql) or die(mysql_error());
} else {
    echo 'there was an error submitting note<br />';
}
Example #23
0
function LogFailure($user)
{
    global $_SERVER, $DB;
    $timestamp = time();
    $ip = $_SERVER['REMOTE_ADDR'];
    $visitor_host = @getHostByAddr($ip);
    $referer_page = $_SERVER['HTTP_REFERER'];
    $requested_page = $_SERVER['REQUEST_URI'];
    $browser = $_SERVER['HTTP_USER_AGENT'];
    $details = addslashes("Possible intruder's details:\n\n<b>IP Address:</b> {$ip}\n<b>Hostname:</b> {$visitor_host}\n<b>Referer:</b> {$referer_page}\n<b>Requested Page:</b> {$requested_page}\n<b>Browser:</b> {$browser}");
    $DB->Execute("INSERT INTO logs (type,timestamp,summary,details,user,ip) VALUES ('Warning','{$timestamp}','Failed login attempt.','{$details}','{$user}','{$ip}')");
}
Example #24
0
<?php

$ipaddress = $_SERVER['REMOTE_ADDR'];
try {
    $xml = simplexml_load_file("http://www.geoplugin.net/xml.gp?ip={$ipaddress}");
    $country = $xml->geoplugin_countryName;
} catch (Exception $ex) {
    $country = '';
    echo $ex;
}
if (!empty($_SERVER['QUERY_STRING'])) {
    $page = "http://{$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}";
    $page .= "?{$_SERVER['QUERY_STRING']}";
} else {
    $page = "";
}
$referrer = "";
//$_SERVER['HTTP_REFERRER']
$datetime = time();
$useragent = $_SERVER['HTTP_USER_AGENT'];
$remotehost = @getHostByAddr($ipaddress);
mysqli_query($mysqli, "INSERT into visitors(ipaddress,page,ref,visit_time,agent,host,country) values ('{$ipaddress}','{$page}','{$referrer}','{$datetime}','{$useragent}','{$remotehost}','{$country}')");
//--- メールのレイアウトの編集 --- 開始 ------------------->
$body = "「" . $sbj . "」からの発信です\n\n";
$body .= "-------------------------------------------------\n\n";
foreach ($_POST as $key => $var) {
    $key = strtr($key, $string_from, $string_to);
    if (get_magic_quotes_gpc()) {
        $var = stripslashes($var);
    }
    if ($var == "eweb_submit") {
    } else {
        $body .= "[" . $key . "] " . $var . "\n";
    }
}
$body .= "\n-------------------------------------------------\n\n";
$body .= "送信日時:" . date("Y/m/d (D) H:i:s", time()) . "\n";
$body .= "ホスト名:" . getHostByAddr(getenv('REMOTE_ADDR')) . "\n\n";
//--- 終了 --->
if ($remail == 1) {
    //--- 差出人への送信確認メールのレイアウトの編集 --- 開始 ->
    $rebody = "ありがとうございました。\n";
    $rebody .= "以下の内容が送信されました。\n\n";
    $rebody .= "-------------------------------------------------\n\n";
    foreach ($_POST as $key => $var) {
        $key = strtr($key, $string_from, $string_to);
        if (get_magic_quotes_gpc()) {
            $var = stripslashes($var);
        }
        if ($var == "eweb_submit") {
        } else {
            $rebody .= "[" . $key . "] " . $var . "\n";
        }
Example #26
0
function mailToAdmin($arr, $subject, $mailFooterDsp, $mailSignature, $encode, $confirmDsp)
{
    $adminBody = "「" . $subject . "」からメールが届きました\n\n";
    $adminBody .= "===========================\n\n";
    $adminBody .= postToMail($arr);
    //POSTデータを関数からセット
    $adminBody .= "\n===========================\n";
    $adminBody .= "送信された日時:" . date("Y/m/d (D) H:i:s", time()) . "\n";
    $adminBody .= "送信者のIPアドレス:" . @$_SERVER["REMOTE_ADDR"] . "\n";
    $adminBody .= "送信者のホスト名:" . getHostByAddr(getenv('REMOTE_ADDR')) . "\n";
    if ($confirmDsp != 1) {
        $adminBody .= "問い合わせのページURL:" . @$_SERVER['HTTP_REFERER'] . "\n";
    } else {
        $adminBody .= "問い合わせのページURL:" . @$arr['httpReferer'] . "\n";
    }
    if ($mailFooterDsp == 1) {
        $adminBody .= $mailSignature;
    }
    return mb_convert_encoding($adminBody, "JIS", $encode);
}
Example #27
0
 /**
  * Returns the host of the remote client.
  * @return string|NULL
  */
 public function getRemoteHost()
 {
     if (!$this->remoteHost) {
         $this->remoteHost = $this->remoteAddress ? getHostByAddr($this->remoteAddress) : NULL;
     }
     return $this->remoteHost;
 }
$process_data = "";
// because some fools cannot follow
// the mind numbingly simple examples i've been kind enough to include.. ;-)
$_POST["address"] = str_replace("http://", "", $_POST["address"]);
// HTTP
// works fine
// timeout set at 10 seconds.
$fsock = @fsockopen($_POST["address"], $_POST["port"], $errno, $errstr, 10);
if (!$fsock) {
    echo "<b>ERROR</b><br />Could not open connection, are you sure a service is running on that port on that host? Is the host down?<br /><br >";
    //echo "$errstr ($errno)<br />";
} else {
    // send headers to server
    fputs($fsock, $out);
    // find hostname
    $hostname = @getHostByAddr($_POST["address"]);
    if (!$hostname) {
        // we were given the hostname
        $hostname = htmlspecialchars($_POST["address"]);
    }
    // find IP
    $hostip = @getHostByName($_POST["address"]);
    if (!$hostip) {
        // we were given the IP
        $hostip = htmlspecialchars($_POST["address"]);
    }
    // print to screen
    echo "<u>Sent headers to " . $hostname . " (" . $hostip . "):</u><br />";
    echo "<pre>";
    echo htmlspecialchars($out) . "<hr />";
    echo "</pre>";
 /**
  * Returns the host of the remote client.
  * @return string
  */
 public function getRemoteHost()
 {
     if (!isset($_SERVER['REMOTE_HOST'])) {
         if (!isset($_SERVER['REMOTE_ADDR'])) {
             return NULL;
         }
         $_SERVER['REMOTE_HOST'] = getHostByAddr($_SERVER['REMOTE_ADDR']);
     }
     return $_SERVER['REMOTE_HOST'];
 }
Example #30
0
 /**
  * ips::nv_chech_proxy()
  *
  * @return
  *
  */
 public function nv_check_proxy()
 {
     $proxy = 'No';
     if ($this->client_ip != 'none' || $this->forward_ip != 'none') {
         $proxy = 'Lite';
     }
     $host = @getHostByAddr($this->remote_ip);
     if (stristr($host, 'proxy')) {
         $proxy = 'Mild';
     }
     if ($this->remote_ip == $host) {
         $proxy = 'Strong';
     }
     return $proxy;
 }