function i2c_go() { global $COUNTRY; // Get the real IP of the user $ipnum = i2c_realip(); // User already has a country detected with this IP stored if (!empty($_COOKIE['COUNTRY']) && strpos($_COOKIE['COUNTRY'], ',') !== FALSE) { list($COUNTRY, $storedip) = explode(",", $_COOKIE['COUNTRY']); if ($storedip == $ipnum) { return TRUE; } } // Convert the IP number to some useable form for searching $ipn = (double) sprintf("%u", ip2long($ipnum)); // Find the index to start search from $idx = i2c_search_in_index($ipn); // If we were unable to find any helpful entry // in the index do not search, as it would take // a very long time. It is an error, if we have // not found anything in the index if ($idx !== FALSE) { $country = i2c_search_in_db($ipn, $idx); } else { $country = 'NA'; } // Set global variable for further usage $COUNTRY = $country; // Set the country in a cookie for a week return setcookie("COUNTRY", "{$country},{$ipnum}", 60 * 60 * 24 * 7); }
$ctx = stream_context_create($params); $fp = @fopen($url, 'rb', false, $ctx); if (!$fp) { exit('' . 'Problem with ' . $url . ', ' . $php_errormsg); } $response = @stream_get_contents($fp); if ($response === false) { exit('' . 'Problem reading data from ' . $url . ', ' . $php_errormsg); } return $response; } $do = isset($_POST['do']) ? htmlspecialchars($_POST['do']) : (isset($_GET['do']) ? htmlspecialchars($_GET['do']) : 1); stdhead('Ip to Country'); $errormessage = ''; if ($do == 2) { $ip = (isset($_POST['ip_address']) and !empty($_POST['ip_address'])) ? $_POST['ip_address'] : ((isset($_GET['ip_address']) and !empty($_GET['ip_address'])) ? $_GET['ip_address'] : i2c_realip()); $post_data = array(); $post_data['ip_address'] = $ip; if (function_exists('curl_init') and $ch = curl_init()) { curl_setopt($ch, CURLOPT_URL, 'http://ip-to-country.webhosting.info/node/view/36'); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $postResult = curl_exec($ch); if (curl_errno($ch)) { exit(curl_error($ch)); } curl_close($ch); } else { $postResult = do_post_request('http://ip-to-country.webhosting.info/node/view/36', 'ip_address=' . $ip); }
site_header("Mailing Lists", array("current" => "help")); // Some mailing list is selected for [un]subscription if (isset($_POST['maillist'])) { // No error found yet $error = ""; // Check email address if (empty($_POST['email']) || $_POST['email'] == '*****@*****.**' || $_POST['email'] == '*****@*****.**' || !is_emailable_address($_POST['email'])) { $error = "You forgot to specify an email address to be added to the list, or specified an invalid address." . "<br>Please go back and try again."; } else { // Decide on request mode, email address part and IP address $request = strtolower($_POST['action']); if ($request != "subscribe" && $request != "unsubscribe") { $request = "subscribe"; } $sub = str_replace("@", "=", $_POST['email']); $remote_addr = i2c_realip(); // Get in contact with master server to [un]subscribe the user $result = posttohost("http://master.php.net/entry/subscribe.php", array("request" => $request, "email" => $_POST['email'], "maillist" => $_POST['maillist'], "remoteip" => $remote_addr, "referer" => $MYSITE . "mailing-lists.php")); // Provide error if unable to [un]subscribe if ($result) { $error = "We were unable to subscribe you due to some technical problems.<br>" . "Please try again later."; } } // Give error information or success report if (!empty($error)) { echo "<p class=\"formerror\">{$error}</p>"; } else { ?> <p> A request has been entered into the mailing list processing queue. You should receive an email at <?php