Exemplo n.º 1
0
/**
 * Cleans up the guest array
 * @global array
 * @global resource
 */
function update_guests()
{
    global $config, $database;
    // The time between them
    $time_between = time() - $config['user_online_timeout'];
    $time = time();
    // Clean up the database of old guests
    $result = $database->query("DELETE FROM `guests` WHERE `visit` < '{$time_between}'");
    // Insert a new one
    if (!$_SESSION['logged_in']) {
        $bot_check = is_bot($_SERVER["HTTP_USER_AGENT"]);
        // Are they a bot or a guest?
        if (is_string($bot_check)) {
            $type = $bot_check;
        } else {
            $type = "GUEST";
        }
        // Grab the hostname
        $host = gethostname();
        // Check to see if they already exist.
        $result = $database->query("SELECT * FROM `guests` WHERE `ip` = '{$host}'");
        if ($database->num($result) < 1) {
            // Insert them in there.
            $database->query("INSERT INTO `guests` (`visit`,`ip`,`type`) VALUES ('{$time}', '{$host}', '{$type}')");
        } else {
            // Insert them in there.
            $database->query("UPDATE `guests` SET `visit` = '{$time}' WHERE `ip` = '{$host}'");
        }
    }
}
Exemplo n.º 2
0
function visits($lang, $node_id, $nomore = false)
{
    $visits = node_get_visits($node_id, $lang);
    $visit_page = false;
    if (!$nomore and (!isset($_SESSION['visits']) or !in_array($node_id, $_SESSION['visits'])) and !is_bot() and !is_opengraph()) {
        $visit_page = url('pagevisit', $lang);
        $_SESSION['visited'] = $node_id;
    }
    $output = view('visits', $lang, compact('visits', 'visit_page'));
    return $output;
}
/**
 * Detección de navegadores antiguos con modernizr
 *
 * @return void
 */
function preventOlderBrowsers()
{
    // Impide que los BOTS de los buscadores sean redirigidos a la página de UPS
    if (!is_bot()) {
        // https://github.com/jamesgpearce/modernizr-server
        //include_once 'php/lib/modernizr-server.php';
        // condiciones de modernizr
        /*if ( !$modernizr->flexbox ) {
            	header('location: ' . URL_UPS );
        		exit;
            }*/
    }
}
Exemplo n.º 4
0
function init_lang_code()
{
    global $geoip_record;
    global $lang_codes;
    global $one_lang;
    $lang_code = 'vi';
    $country_code = isset($geoip_record) ? $geoip_record->country_code : 'VN';
    $country_codes = array('vi' => array('VN'), 'en' => array('UK', 'US'), 'ru' => array('RU', 'AM', 'AZ', 'BY', 'KZ', 'KG', 'MD', 'TJ', 'UZ', 'TM', 'UA'), 'es' => array('ES', 'CO', 'PE', 'VE', 'EC', 'GT', 'CU', 'BO', 'HN', 'PY', 'SV', 'CR', 'PA', 'GQ', 'MX', 'AR', 'CL', 'DO', 'NI', 'UY', 'PR'), 'zh' => array('CN', 'HK', 'MO', 'TW', 'SG'), 'ja' => array('JP'));
    if (isset($one_lang)) {
        setcookie('NSH:lang', $one_lang, time() + 10 * 365 * 24 * 60 * 60, '/' . $one_lang . '/');
        $lang_code = $one_lang;
    }
    if (!isset($_COOKIE['NSH:lang'])) {
        if (in_array($country_code, $country_codes['vi']) || is_public_server() || is_bot()) {
            setcookie('NSH:lang', 'vi', time() + 10 * 365 * 24 * 60 * 60, '/');
            $lang_code = 'vi';
        } else {
            if (in_array($country_code, $country_codes['en'])) {
                setcookie('NSH:lang', 'en', time() + 10 * 365 * 24 * 60 * 60, '/');
                $lang_code = 'en';
            } else {
                if (in_array($country_code, $country_codes['ru'])) {
                    setcookie('NSH:lang', 'ru', time() + 10 * 365 * 24 * 60 * 60, '/');
                    $lang_code = 'ru';
                } else {
                    if (in_array($country_code, $country_codes['es'])) {
                        setcookie('NSH:lang', 'es', time() + 10 * 365 * 24 * 60 * 60, '/');
                        $lang_code = 'es';
                    } else {
                        if (in_array($country_code, $country_codes['zh'])) {
                            setcookie('NSH:lang', 'zh', time() + 10 * 365 * 24 * 60 * 60, '/');
                            $lang_code = 'zh';
                        } else {
                            if (in_array($country_code, $country_codes['ja'])) {
                                setcookie('NSH:lang', 'ja', time() + 10 * 365 * 24 * 60 * 60, '/');
                                $lang_code = 'ja';
                            }
                        }
                    }
                }
            }
        }
    } else {
        if (isset($_COOKIE['NSH:lang'])) {
            $lang_code = $_COOKIE['NSH:lang'];
        }
    }
    $lang_code = isset($one_lang) ? $one_lang : (isset($_GET['lang']) && in_array($_GET['lang'], $lang_codes) ? prevent_xss($_GET['lang']) : $lang_code);
    return $lang_code;
}
Exemplo n.º 5
0
 /**
  * Handle error/s for specific error codes
  *
  * @param  object $f3 FatFree instance
  * @return mixed      Custom error/Default FatFree error
  */
 public static function handler($f3)
 {
     // F3 error: code, text, trace
     $error = $f3->get('ERROR');
     $domain = $f3->get("domain");
     error_log("Domain: " . $domain['domainname']);
     //test_array($_SERVER);
     $urls = isset($_SERVER['HTTP_X_ORIGINAL_URL']) ? $_SERVER['HTTP_X_ORIGINAL_URL'] : $_SERVER['REQUEST_URI'];
     $url = clean_url("http" . ($_SERVER['SERVER_PORT'] == 443 ? "s://" : "://") . $_SERVER['HTTP_HOST'] . $urls);
     error_log("URL: " . $url);
     $botText = "";
     if (is_bot()) {
         $botText = '---BOT--- ';
     }
     error_log("HTTP_USER_AGENT: " . $botText . $_SERVER['HTTP_USER_AGENT']);
     // custom error/s
     switch ($error['code']) {
         case 403:
             $f3->reroute("/user/login?return=" . $f3->get("return_here"));
             break;
         case 404:
             //test_array($error);
             $f3->set("SOFTERROR", true);
             $page = models\default_pages::get("error404");
             //$page['js'] = $page['js'].";".$domain['js'];
             //test_array($page);
             $p = new controllers\front\pages();
             $p->load($page, $error);
             break;
         default:
             $errorPath = dirname(ini_get('error_log'));
             ini_set("error_log", $errorPath . DIRECTORY_SEPARATOR . "LIN-Errors-php-error.log");
             // restore F3 error handler (hackish)
             $f3->mset(array('ONERROR' => null, 'ERROR' => null));
             $f3->error($error['code'], $error['text'], $error['trace']);
             exit;
             break;
     }
     // exit after custom action
 }
Exemplo n.º 6
0
function is_bot($user_agent)
{
    //if no user agent is supplied then assume it's a bot
    if ($user_agent == "") {
        return 1;
    }
    //array of bot strings to check for
    $bot_strings = array("google", "bot", "yahoo", "spider", "archiver", "curl", "python", "nambu", "twitt", "perl", "sphere", "PEAR", "java", "wordpress", "radian", "crawl", "yandex", "eventbox", "monitor", "mechanize", "facebookexternal");
    foreach ($bot_strings as $bot) {
        if (strpos($user_agent, $bot) !== false) {
            return 1;
        }
    }
    return 0;
}
if (is_bot($_SERVER['HTTP_USER_AGENT'])) {
    die;
}
$bans = file('ban.txt');
foreach ($bans as $b) {
    if (trim($b) == get_ip()) {
        echo '<H1>F**K YOU!</h1>';
        echo '<H1>Sincerely, Sos ( just.sos.it@gmail.com )</h1>';
        die;
    }
}
function get_db()
{
    global $login, $password, $database;
    $link = mysql_connect('localhost', $login, $password);
    if (!$link) {
Exemplo n.º 7
0
            return true;
        }
        // Это бот
    }
    return false;
    // Не бот
}
if ($_GET['id']) {
    global $modx;
    $id_tv = $modx->getTemplateVarOutput(array('file'), $_GET['id']);
    // Получаем значение TV file
    $file = $id_tv['file'];
    // Получаем путь к файлу
    if (file_exists($file)) {
        // Если файл существует...
        if (!is_bot() && $_GET['go'] == true) {
            // ... а посетитель не бот, и стоит GET-параметр go, то отдаем файл на закачку
            $table = $modx->getFullTableName('downloads');
            $id = $modx->db->escape($_GET['id']);
            $file_path = $modx->db->escape($file);
            $sql = "INSERT INTO {$table} (id, file, count) VALUES ('{$id}', '{$file_path}', 1) ON DUPLICATE KEY UPDATE count=count+1";
            // Готовим строку запроса
            $result = $modx->db->query($sql);
            // Обновляем данные счетчика
            if (!$result) {
                die('Error: Query Failed!');
            }
            $file_name = basename($file);
            // Получаем имя файла
            $fsize = filesize($file);
            // и его размер
Exemplo n.º 8
0
    list($usec, $sec) = explode(' ', microtime());
    return (double) $usec + (double) $sec;
}
//is bot ?
function is_bot($bots = array('googlebot', 'bing', 'msnbot'))
{
    if (isset($_SERVER['HTTP_USER_AGENT'])) {
        return preg_match('/(' . implode('|', $bots) . ')/i', $_SERVER['HTTP_USER_AGENT'] ? $_SERVER['HTTP_USER_AGENT'] : @getenv('HTTP_USER_AGENT')) ? true : false;
    }
    return false;
}
$IS_BOT = is_bot();
$starttm = get_microtime();
//Kill globals varibles
unregister_globals();
if (!is_bot()) {
    @session_name('sid');
    @session_start();
}
//try close it
if (@get_magic_quotes_runtime()) {
    @set_magic_quotes_runtime(0);
}
if (@get_magic_quotes_gpc()) {
    $_GET = stripslashes_our($_GET);
    $_POST = stripslashes_our($_POST);
    $_COOKIE = stripslashes_our($_COOKIE);
    $_REQUEST = stripslashes_our($_REQUEST);
    //we use this sometime
}
//clean string and remove bad chars
Exemplo n.º 9
0
     $human_captcha = explode(':#:', $_SESSION['jrc_captcha']);
     if ($defaults[$human_captcha[0]] == '' || $defaults[$human_captcha[0]] != $human_captcha[1]) {
         $errors['human'] = $human_captcha[0];
     }
 }
 if (count($errors) > 0) {
     /* Outputtng the error messages */
     if ($_SERVER['HTTP_X_REQUESTED_WITH']) {
         header('Cache-Control: no-cache');
         die('{"status":0, "errors":' . json_encode($errors) . '}');
     } else {
         $errors = $errors;
     }
 } else {
     // Now let's check if the ip is ipv4
     if ($ipa && !is_bot()) {
         // Yes, it is
         $ipisvalid = 1;
     } else {
         // Nope, it isn't
         $ipisvalid = 0;
     }
     // if ip is valid do the whole thing
     if ($ipisvalid) {
         if (isset($_COOKIE['WIOgeoData'])) {
             // A "geoData" cookie has been previously set by the script, so we will use it
             // Always escape any user input, including cookies:
             list($city, $countryName, $countryAbbrev, $countryLat, $countryLong) = explode('|', strip_tags(base64_decode($_COOKIE['WIOgeoData'])));
         } else {
             // Making an API call to Hostip:
             $xml = @unserialize(file_get_contents('http://www.geoplugin.net/php.gp?ip=' . $ipa));
Exemplo n.º 10
0
    return $match[1];
}
function is_bot()
{
    $botlist = array("Teoma", "alexa", "froogle", "Gigabot", "inktomi", "looksmart", "URL_Spider_SQL", "Firefly", "NationalDirectory", "Ask Jeeves", "TECNOSEEK", "InfoSeek", "WebFindBot", "girafabot", "crawler", "www.galaxy.com", "Googlebot", "Scooter", "Slurp", "msnbot", "appie", "FAST", "WebBug", "Spade", "ZyBorg", "rabaz", "Baiduspider", "Feedfetcher-Google", "TechnoratiSnoop", "Rankivabot", "Mediapartners-Google", "Sogou web spider", "WebAlta Crawler", "TweetmemeBot", "Butterfly", "Twitturls", "Me.dium", "Twiceler");
    foreach ($botlist as $bot) {
        if (strpos($_SERVER['HTTP_USER_AGENT'], $bot) !== false) {
            return strpos($_SERVER['HTTP_USER_AGENT'], $bot);
        }
    }
    return false;
}
$link = @mysql_connect($dbdb_host, $dbdb_user, $dbdb_pass) or die('Server error');
mysql_set_charset('utf8');
mysql_select_db($dbdb_database, $link);
$isuser = "******";
$isguest = "2";
$isbot = "2";
$user_session = $_SESSION['user_session'];
if (is_bot()) {
    $botname = is_bot();
    $isbot = "1";
} else {
    if (!$user_session) {
        $isguest = "1";
        $toolbar_username = "";
    } else {
        $isuser = "******";
        $toolbar_username = $user_session;
    }
}
Exemplo n.º 11
0
     return $match[1];
 }
 function is_bot()
 {
     /* This function will check whether the visitor is a search engine robot */
     $botlist = array("Teoma", "alexa", "froogle", "Gigabot", "inktomi", "looksmart", "URL_Spider_SQL", "Firefly", "NationalDirectory", "Ask Jeeves", "TECNOSEEK", "InfoSeek", "WebFindBot", "girafabot", "crawler", "www.galaxy.com", "Googlebot", "Scooter", "Slurp", "msnbot", "appie", "FAST", "WebBug", "Spade", "ZyBorg", "rabaz", "Baiduspider", "Feedfetcher-Google", "TechnoratiSnoop", "Rankivabot", "Mediapartners-Google", "Sogou web spider", "WebAlta Crawler", "TweetmemeBot", "Butterfly", "Twitturls", "Me.dium", "Twiceler");
     foreach ($botlist as $bot) {
         if (strpos($_SERVER['HTTP_USER_AGENT'], $bot) !== false) {
             return true;
         }
         // Is a bot
     }
     return false;
     // Not a bot
 }
 if (empty($_REQUEST['action']) || is_bot()) {
     die;
 }
 switch ($_REQUEST['action']) {
     case 'online':
         $stringIp = $_SERVER['REMOTE_ADDR'];
         $intIp = ip2long($stringIp);
         // Checking wheter the visitor is already marked as being online:
         $counted = $AVE_DB->Query("\r\n\t\t\t\tSELECT 1\r\n\t\t\t\tFROM " . PREFIX . "_modul_who_is_online\r\n\t\t\t\tWHERE ip = " . $intIp)->NumRows();
         if (!$counted) {
             // This user is not in the database, so we must fetch
             // the geoip data and insert it into the online table:
             if (!empty($_COOKIE['geoData'])) {
                 // A "geoData" cookie has been previously set by the script, so we will use it
                 // Always escape any user input, including cookies:
                 list($city, $countryName, $countryAbbrev) = explode('|', stripslashes(strip_tags($_COOKIE['geoData'])));
Exemplo n.º 12
0
function welcome_msg()
{
    if (is_bot()) {
        return;
    }
    if ($m = apply_filters('welcome_msg', $string)) {
        return $m;
        return;
    }
    global $referer;
    $referer = $_SERVER['HTTP_REFERER'];
    $hostinfo = parse_url($referer);
    $host_h = $hostinfo["host"];
    $host_p = $hostinfo["path"];
    $host_scheme = $hostinfo['scheme'];
    $host = array($host_h, $host_p);
    $host_hfull = $host_h;
    if (substr($host_h, 0, 4) == 'www.') {
        $host_h = substr($host_h, 4);
    }
    $host_h_url = '<a href="' . $host_scheme . '://' . $host_hfull . '/">$host_h</a>';
    if ($referer == "") {
        $callback = "<!--您直接访问了本站!-->\n";
        if ($_COOKIE["comment_author_" . COOKIEHASH] != "") {
            $callback = 'Howdy, <strong>' . $_COOKIE["comment_author_" . COOKIEHASH] . '</strong>, 欢迎回来';
        } else {
            $callback = "您直接访问了本站!  莫非您记住了我的<strong>域名</strong>.厉害~  我倍感荣幸啊 嘿嘿";
        }
        //搜索引擎
        //baidu
    } elseif (preg_match('/baidu.*/i', $host_h)) {
        $callback = '您通过 <strong>百度</strong> 找到了我,厉害!';
        //360
    } elseif (preg_match('/haosou.*/i', $host_h)) {
        $callback = '您通过 <strong>好搜</strong> 找到了我,厉害!';
        //google
    } elseif (!preg_match('/www\\.google\\.com\\/reader/i', $referer) && preg_match('/google\\./i', $referer)) {
        $callback = '您居然通过 <strong>Google</strong> 找到了我! 一定是个技术宅吧!';
        //yahoo
    } elseif (preg_match('/search\\.yahoo.*/i', $referer) || preg_match('/yahoo.cn/i', $referer)) {
        $callback = '您通过 <strong>Yahoo</strong> 找到了我! 厉害!';
        //阅读器
        //google
    } elseif (preg_match('/google\\.com\\/reader/i', $referer)) {
        $callback = "感谢你通过 <strong>Google</strong> 订阅我!  既然过来读原文了. 欢迎留言指导啊.嘿嘿 ^_^";
        //xianguo
    } elseif (preg_match('/xianguo\\.com\\/reader/i', $referer)) {
        $callback = "感谢你通过 <strong>鲜果</strong> 订阅我!  既然过来读原文了. 欢迎留言指导啊.嘿嘿 ^_^";
        //zhuaxia
    } elseif (preg_match('/zhuaxia\\.com/i', $referer)) {
        $callback = "感谢你通过 <strong>抓虾</strong> 订阅我!  既然过来读原文了. 欢迎留言指导啊.嘿嘿 ^_^";
        //哪吒
    } elseif (preg_match('/inezha\\.com/i', $referer)) {
        $callback = "感谢你通过 <strong>哪吒</strong> 订阅我!  既然过来读原文了. 欢迎留言指导啊.嘿嘿 ^_^";
        //有道
    } elseif (preg_match('/reader\\.youdao/i', $referer)) {
        $callback = "感谢你通过 <strong>有道</strong> 订阅我!  既然过来读原文了. 欢迎留言指导啊.嘿嘿 ^_^";
        //自己
    } elseif (self()) {
        //若来路是自己的网站
        //$callback = "你在找什么呢?试试上面的搜索吧~"."\n";
        $callback = false;
    } elseif (get_option('wp_plus_linkman') == 'checked' && get_bookmarks(array('search' => $host_hfull))) {
        $callback = '欢迎来自友站<strong>' . get_bookmarks(array('search' => $host_hfull))[0]->link_name . '</strong>的小伙伴~ 也请多多关注我哦 ^_^ ';
    } elseif ($_COOKIE["comment_author_" . COOKIEHASH] != "") {
        $callback = 'Howdy, <strong>' . $_COOKIE["comment_author_" . COOKIEHASH] . '</strong>欢迎从<strong>' . $host_h . '</strong>回来';
    } else {
        $callback = '欢迎来自<strong>' . $host_h . '</strong>的朋友. 我经常分享一些好东西哦 ^_^ ';
    }
    return $callback;
}
Exemplo n.º 13
0
function insert_visit()
{
    global $rootId;
    global $userId;
    // facebook userid
    global $userProfile;
    // facebook user profile
    $safeRootId = intval($rootId);
    $fbuserid = intval($userId);
    $fbusername = $fbuseremail = '';
    if (isset($userProfile['name'])) {
        $fbusername = $userProfile['name'];
    }
    if (isset($userProfile['email'])) {
        $fbuseremail = $userProfile['email'];
    }
    if ($_SERVER['REMOTE_ADDR'] == '24.4.196.27') {
        return;
    }
    $ua = $_SERVER['HTTP_USER_AGENT'];
    if (is_bot($ua)) {
        return;
    }
    $sql = 'insert into visit values (null,"' . $_SERVER['REMOTE_ADDR'] . '",now(),' . $safeRootId . ',"' . $fbuserid . '","' . $fbusername . '","' . $fbuseremail . '")';
    //print "sql=$sql";
    Person::connectToDB();
    Person::queryDB($sql);
}
Exemplo n.º 14
0
$ipLite->setKey('ADD_API_KEY_HERE');
//Get errors and locations
$locations = $ipLite->getCity($ip);
$errors = $ipLite->getError();
//Getting the result
if (!empty($locations) && is_array($locations)) {
    foreach ($locations as $field => $val) {
        if ($field == 'countryName') {
            $country = $val;
        }
        if ($field == 'cityName') {
            $city = $val;
        }
    }
}
if (is_bot()) {
    $isbot = 1;
} else {
    $isbot = 0;
}
$date = date("Y-m-d");
$time = date("H:i:s");
global $connection;
$query = "INSERT INTO `tracker` (`date`, `time`, `ip`, `http_referer`, `http_user_agent`, `isbot`)\nVALUES ('{$date}', '{$time}', '{$ip}', '{$http_referer}' ,'{$http_user_agent}' , {$isbot})";
$result = mysqli_query($connection, $query);
include "includes/layouts/header.php";
?>
   
<?php 
include 'includes/layouts/logo.php';
?>
Exemplo n.º 15
0
}
mb_internal_encoding('utf8');
// initialize Haanga
require include_dir . 'Haanga.php';
Haanga::configure(array('template_dir' => 'templates/', 'cache_dir' => 'templates/compiled/', 'compiler' => array('global' => array('settings', 'session'), 'strip_whitespace' => true, 'allow_exec' => false, 'autoescape' => false)));
// initialize the html engine
require classes_dir . 'html.php';
$html = new HTML();
// initiailze session
require classes_dir . 'session.php';
$session = new Session();
$session->init();
// initialize push engine
require classes_dir . 'push.php';
$push = new Push();
$push->init();
// configure gettext's locale
putenv('LC_ALL=' . $settings->locale);
setlocale(LC_ALL, $settings->locale);
bindtextdomain('messages', './locale');
textdomain('messages');
// redir to /login if not in ^/login already
if (!is_bot() && ($settings->privacy_level == 2 && $session->level == 'anonymous' && !preg_match(sprintf('/^%s(login|api|userlogin|_)/', preg_quote($settings->base_url, '/')), $_SERVER['REQUEST_URI']))) {
    $html->do_sysmsg(_('Log in'), _('You must log in to read any quote.'), 403);
}
/* make privacy_level_for_bots effective */
if (is_bot() && $settings->privacy_level_for_bots == 2 && !preg_match(sprintf('/^%s(rss|robots\\.txt)/', preg_quote($settings->base_url, '/')), $_SERVER['REQUEST_URI'])) {
    header('HTTP/1.1 403 Forbidden');
    die('403 Forbidden');
    /* so what */
}
Exemplo n.º 16
0
 function read($results = null)
 {
     global $db, $settings, $session, $memcache;
     /* we may already have results (eg. when called from list.php)
     			but maybe we do not, so fetch from the db */
     if (!$results) {
         /* if we didn't have $results, no id and no permaid, this was a faulty rqeuest. */
         if (!$this->id && !$this->permaid) {
             $session->log('Using read() with no id or permaid and with no prebaked results');
             return false;
         }
         if ($this->id) {
             /* memcache */
             $cached = $memcache->get(sprintf('quote_id_%d_data', $this->id));
             if ($cached !== false) {
                 foreach ($cached as $variable => $value) {
                     $this->{$variable} = ctype_digit($value) ? (int) $value : $value;
                 }
                 return true;
             }
             $results = $db->get_row(Quote::READ_BY_ID, array(array(':id', $this->id, PDO::PARAM_INT), array(':db', $settings->db, PDO::PARAM_STR)));
         } elseif ($this->permaid) {
             /* memcache */
             $cached = $memcache->get(sprintf('quote_permaid_%s_data', $this->permaid));
             if ($cached !== false) {
                 foreach ($cached as $variable => $value) {
                     $this->{$variable} = ctype_digit($value) ? (int) $value : $value;
                 }
                 return true;
             }
             $results = $db->get_row(Quote::READ_BY_PERMAID, array(array(':permaid', $this->permaid, PDO::PARAM_STR), array(':db', $settings->db, PDO::PARAM_STR)));
         }
     }
     /* still no results? return */
     if (!$results) {
         return false;
     }
     foreach ($results as $variable => $value) {
         $this->{$variable} = ctype_digit($value) && !in_array($variable, ['permaid']) ? (int) $value : $value;
     }
     if (preg_match('/^(.*)!/', $this->nick, $matches)) {
         $this->nick = $matches[1];
     }
     // hackish but still right.
     switch (is_bot() ? $settings->privacy_level_for_bots : $settings->privacy_level) {
         case -1:
             $this->hidden = 0;
             break;
         case 1:
             $this->hidden = 1;
             break;
     }
     $this->generate();
     $this->read = true;
     $memcache->set(sprintf('quote_id_%d_data', $this->id), $this);
     $memcache->set(sprintf('quote_permaid_%s_data', $this->permaid), $this);
     return true;
 }
Exemplo n.º 17
0
$secret = "6LfUsPoSAAAAAIYXCy02E_wC48Nv5LKUBE6-Owoo";
//Secret key for accessing Google's reCAPTCHA service
$response_string = $_POST['g-recaptcha-response'];
// User response on reCAPTCHA
$user_ip = $_SERVER['REMOTE_ADDR'];
// Usr IP address
$results = array();
$mailcheck = spamcheck($senderEmail);
// Check if "from" email address is valid
if ($mailcheck == FALSE) {
    info('error', 'Invalid email address.');
    header('Location: contacts');
} else {
    //Verify if user is not a robot
    $jsonresponse = "";
    $response = is_bot($api_url, $secret, $response_string, $user_ip);
    foreach ($response as $value) {
        $jsonresponse .= $value;
    }
    $response = json_decode($jsonresponse, true);
    if ($response['success']) {
        // message lines should not exceed 70 characters (PHP rule), so wrap it
        $message = wordwrap($senderMessage, 70);
        $success = mail($to, $subject, $message, $headers);
        // send mail
        if ($success) {
            $msg = '<div class="message success-notification">' . '<h4>Success Notification</h4>' . '<p>Your email is sent! We will get back to you soon.</p>' . '</div>';
        } else {
            $msg = '<div class="message error-notifiction">';
            $msg .= '<h4>Error Notification</h4>';
            $msg .= '<p>Email not sent due to some errors! Please try again..</p>';