GeoIP not showing all info - php

so i have this error , i downloaded the lastest
geoipcity.inc | geoipregionvars.inc | GeoLiteCity.dat
so here is my code :
<?php
/**
* Querying against GeoIP/Lite City
* This will fetch country along with city information
*/
include("geoipcity.inc");
include("geoipregionvars.php");
$giCity = geoip_open("GeoLiteCity.dat",GEOIP_STANDARD);
$ip = "99.99.99.99";
$record = geoip_record_by_addr($giCity, $ip);
echo "Getting Country and City detail by IP Address <br /><br />";
echo "IP: " . $ip . "<br /><br />";
echo "Country Code: " . $record->country_code . "<br />" .
"Country Code3: " . $record->country_code . "<br />" .
"Country Name: " . $record->country_name . "<br />" .
"Region Code: " . $record->region . "<br />" .
"City: " . $record->city . "<br />" .
"Postal Code: " . $record->postal_code . "<br />" .
"Latitude: " . $record->latitude . "<br />" .
"Longitude: " . $record->longitude . "<br />" .
"Metro Code: " . $record->metro_code . "<br />" .
"Area Code: " . $record->area_code . "<br />" ;
geoip_close($giCity);
?>
and here is my problem that
not all resulst are shown :
Country Code: SA
Country Code3: SA
Country Name: Saudi Arabia
Region Code:
City:
Postal Code:
Latitude: 25
Longitude: 45
Metro Code:
Area Code:

Related

HTML & PHP Information Table

So i'm hosting servers and trying to make a table displaying the information server name players etc i have a script that displays this but i suck at css, What i'm trying to get is a little like in this website http://echelon.kthx.at/pubbans.php
<?php
include ("BC2Conn.php");
// opens a connection to gameserver
$BC2Conn = new BC2Conn("31.185.143.136", 48888);
if (!$BC2Conn->isConnected()) {
echo "Connection could not be established. " .
"To debug, set '-d' as 3rd parameter to new connection.<br />" .
"<br />" .
"Example: \$BC2Conn = new BC2Conn(\"127.0.0.1\", 48888, \"-d\");";
return 0; // stop executing this script
}
// secure login
// $BC2Conn->loginSecure("password");
// unsecure login (not salted)
// some random serverinformation
echo "Servername: " . $BC2Conn->getServerName() . "<br />";
echo "Players: " . $BC2Conn->getCurrentPlayers() . "/" . $BC2Conn->getMaxPlayers() . "<br />";
echo "Playmode: " . $BC2Conn->getCurrentPlaymodeName() . "<br />";
echo "Current Map: " . $BC2Conn->getCurrentMapName() . "<br /><br /><br /><u>Players:</u><br /><br />";
// playerlist
$playerNames = $BC2Conn->getPlayerlistNames();
foreach ($playerNames as $key => $content) {
if ($BC2Conn->getPlayerClantag($content) != "") {
echo "[" . $BC2Conn->getPlayerClantag($content) . "]";
}
echo " " . $BC2Conn->getPlayername($content) . " - Kills: ";
echo $BC2Conn->getPlayerKills($content) . " | Deaths: ";
echo $BC2Conn->getPlayerDeaths($content) . " | Score: ";
echo $BC2Conn->getPlayerScore($content) . "<br />";
}
// logout
$BC2Conn->logout();
?>

If statements reading entries from database won't show

the below code contains if statements depending on usertype and status. It won't display anything. In the code above i had usertype==1 and status==1 and it is working as it should but this below code won't work. Any suggestions? Please ignore the code i have as i am a beginner and the code is messy.
} else if ($usertype == 2) {
$server1 = "localhost";
$user1 = "r";
$pass1 = "";
$db1 = "";
$db4 = "";
$user5 = $_SESSION['username'];
$mysqli = new Mysqli($server1, $user1, $pass1, $db1) or mysqli_error($mysqli);
$mysqli6 = new Mysqli($server1, $user1, $pass1, $db4) or mysqli_error($mysqli);
$name2= $mysqli6->query("SELECT name FROM head WHERE username= '$user5'")->fetch_object()->name2;
$status2 = $mysqli->query("SELECT status FROM Overrides WHERE head = '$name2'")->fetch_object()->status2;
$headforms = $mysqli->query("SELECT * FROM Overrides WHERE head = '$name2' ");
$num_rows2 = mysqli_num_rows($headforms);
if ($status2 == 2) {
echo "Overrides today: " . $num_rows2;
while($row2 = mysqli_fetch_array($headforms)) {
echo "<br /><br />First Name: " . $row2['name'] . "<br />";
echo "<br />Middle Name: " . $row2['mname'] . "<br />";
echo "<br />Family Name: " . $row2['fname'] . "<br />";
echo "<br />Student ID: " . $row2['sid'] . "<br />";
echo "<br />Scolarship: " . $row2['sc'] . "<br />";
echo "<br />Phone No: " . $row2['phone'] . "<br />";
echo "<br />Email: " . $row2['email'] . "<br />";
echo "<br />Class: " . $row2['class'] . "<br />";
echo "<br />Section: " . $row2['section'] . "<br />";
echo "<br />Semester: " . $row2['semester'] . "<br />";
}
}
?>
Concerning the database entries and data, i have checked them and i'm 100% sure it should display correct info.
I did a test : i tried doing print_r($status2); and print_r($name2); but page is empty, could the problem be with the userype == 2 since it's displaying nothing.
errors:
Notice: Undefined property: stdClass::$name2 in /home/aukwizcq/public_html/override.php on line 310
Notice: Trying to get property of non-object in /home/aukwizcq/public_html/override.php on line 311

How to configure FFMPEG with Xampp in Ubuntu

Hi i am i trying to merge videos using ffmpeg with Php.Now i installed Xampp in ubuntu.and FFMEPG also i installed in Ubuntu.I searched ffmpeg.dll file but its not dound in the directory.but i add the extension in the php.ini file like below my code
;extension=php_bz2.dll
;extension=php_ffmpeg.dll
;extension=php_curl.dll
;extension=php_dba.dll
;extension=php_exif.dll
;extension=php_fileinfo.dll
This is my test code for ffmpeg.
<?php
extension_loaded('ffmpeg') or die('Error in loading ffmpeg');
$vid = realpath('1.mp4');
$ffmpegInstance = new ffmpeg_movie($vid);
echo "getDuration: " . $ffmpegInstance->getDuration() . "<br />".
"getFrameCount: " . $ffmpegInstance->getFrameCount() . "<br />".
"getFrameRate: " . $ffmpegInstance->getFrameRate() . "<br />".
"getFilename: " . $ffmpegInstance->getFilename() . "<br />".
"getComment: " . $ffmpegInstance->getComment() . "<br />".
"getTitle: " . $ffmpegInstance->getTitle() . "<br />".
"getAuthor: " . $ffmpegInstance->getAuthor() . "<br />".
"getCopyright: " . $ffmpegInstance->getCopyright() . "<br />".
"getArtist: " . $ffmpegInstance->getArtist() . "<br />".
"getGenre: " . $ffmpegInstance->getGenre() . "<br />".
"getTrackNumber: " . $ffmpegInstance->getTrackNumber() . "<br />".
"getYear: " . $ffmpegInstance->getYear() . "<br />".
"getFrameHeight: " . $ffmpegInstance->getFrameHeight() . "<br />".
"getFrameWidth: " . $ffmpegInstance->getFrameWidth() . "<br />".
"getPixelFormat: " . $ffmpegInstance->getPixelFormat() . "<br />".
"getBitRate: " . $ffmpegInstance->getBitRate() . "<br />".
"getVideoBitRate: " . $ffmpegInstance->getVideoBitRate() . "<br />".
"getAudioBitRate: " . $ffmpegInstance->getAudioBitRate() . "<br />".
"getAudioSampleRate: " . $ffmpegInstance->getAudioSampleRate() . "<br />".
"getVideoCodec: " . $ffmpegInstance->getVideoCodec() . "<br />".
"getAudioCodec: " . $ffmpegInstance->getAudioCodec() . "<br />".
"getAudioChannels: " . $ffmpegInstance->getAudioChannels() . "<br />".
"hasAudio: " . $ffmpegInstance->hasAudio();?>
When i run this in xammp the output coming like this
Error in loading ffmpeg
kindly give some solution for me
thanks in advance.

fwrite function writes nothing to the file

I am trying to write data into a txt file, but It won't work. there is no error. it just won't work.
here is the code
if (isset($_REQUEST['submit']))
{
$hour = $_REQUEST['hour'];
$family = $_REQUEST['family'];
$how = $_REQUEST['how'];
$will = $_REQUEST['will'];
$fun = $_REQUEST['fun'];
$kind = $_REQUEST['kind'];
$device = $_REQUEST['device'];
$study = $_REQUEST['study'];
$agree = $_REQUEST['agree'];
$text = "hour :" . $hour . "<br />" . "family" . $family . "<br />" . "تطابفق با درس" . $how . "<br />" . "سرگرمی های غیر مجازی : " . $will . "<br />" . "نوع سرگرمی :" . $fun . "<br />" . "kind : " . $kind . "<br />" . "device " . $device . "<br />" . "اثیر بر درس" . $study . "<br />" . "کنترل " . $agree . "<br />" ;
fopen('/1.txt', "r");
fwrite('/1.txt',"hour :" . $hour . "<br />" . "family" . $family . "<br />" . "تطابفق با درس" . $how . "<br />" . "سرگرمی های غیر مجازی : " . $will . "<br />" . "نوع سرگرمی :" . $fun . "<br />" . "kind : " . $kind . "<br />" . "device " . $device . "<br />" . "اثیر بر درس" . $study . "<br />" . "کنترل " . $agree . "<br />");
fclose('/1.txt');
}
do note that there is an "else" that includes all the aforementioned input fields that I used in the code , and that I am executing on localhost.
thanks
You cannot write to it since you are opening it as read-only:
$handle = fopen('/1.txt', "r");
Instead:
$handle = fopen('/1.txt', "w"); // to write only, if you need to read and write use 'w+'
You also need to store fopen in a $handle so you can write to it later.
Documentation: http://www.php.net/manual/en/function.fopen.php
Now the first parameter for fwrite should be $handle:
fwrite($handle, "hour :" . $hour . "<br />" . "family" . $family . "<br />" . "تطابفق با درس" . $how . "<br />" . "سرگرمی های غیر مجازی : " . $will . "<br />" . "نوع سرگرمی :" . $fun . "<br />" . "kind : " . $kind . "<br />" . "device " . $device . "<br />" . "اثیر بر درس" . $study . "<br />" . "کنترل " . $agree . "<br />");
Documentation: http://www.php.net/manual/en/function.fwrite.php
At the end you should also close with $handle:
fclose($handle);
Documentation: http://www.php.net/manual/en/function.fclose.php
You are opening the file as read-only, with the ruse w instead. And you need to pass fwrite the return of fopen as first argument, not the filename:
$f = fopen('/1.txt', "w");
fwrite($f,"hour :" . $hour . "<br />" . "family" . $family . "<br />" . "تطابفق با درس" . $how . "<br />" . "سرگرمی های غیر مجازی : " . $will . "<br />" . "نوع سرگرمی :" . $fun . "<br />" . "kind : " . $kind . "<br />" . "device " . $device . "<br />" . "اثیر بر درس" . $study . "<br />" . "کنترل " . $agree . "<br />");
fclose($f);
You have to pass in a 'w' to write to a file.
$handle = fopen('/1.txt', "w");
Passing in 'r' makes it so you are opening a 'read-only' file.
Much simpler:
file_put_contents('/1.txt', $text);

How to obtain latitude and longitude of a user by IP address or pinpoint location

I want to get the geolocation (latitude and longitude) of a computer user by a php script. I was using this one
<?php
// Get lat and long by address
$address = $dlocation; // Google HQ
$prepAddr = str_replace(' ','+',$address);
$geocode=file_get_contents('http://maps.google.com/maps/api/geocode/json?address='.$prepAddr.'&sensor=false');
$output= json_decode($geocode);
$latitude = $output->results[0]->geometry->location->lat;
$longitude = $output->results[0]->geometry->location->lng;
?>
but the problem is that this uses real adresses and I just want the user to log in, ask him for the permission to track him (allow location) and if he accepts obtain the desired values (longitude and latitude). It could be by an IP adress or another way to pinpoint his location but the thing is I wanted this method to be pratically flawless regarding proxies and fakies. Any idea on how I could do this? Thank you very much!
I think this is what you want.simple and easy to use.Thanks to HTML5 see source here
<html>
<body>
<p id="demo">Click the button to get your coordinates:</p>
<button onclick="getLocation()">Try It</button>
<script>
var x=document.getElementById("demo");
function getLocation()
{
if (navigator.geolocation)
{
navigator.geolocation.getCurrentPosition(showPosition);
}
else{x.innerHTML="Geolocation is not supported by this browser.";}
}
function showPosition(position)
{
x.innerHTML="Latitude: " + position.coords.latitude +
"<br>Longitude: " + position.coords.longitude;
}
</script>
</body>
</html>
download geoip.inc - http://www.maxmind.com/download/geoip/api/php-20120410/geoip.inc,
geoipcity.inc - http://www.maxmind.com/download/geoip/api/php-20120410/geoipcity.inc,
geoipregionvars.php - http://www.maxmind.com/download/geoip/api/php-20120410/geoipregionvars.php,
GeoLiteCity.dat - http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
please convert GeoLiteCity.dat.gz to GeoLiteCity.dat and
put in geoip named folder
include("application/libraries/geoip/geoipcity.inc");
include("application/libraries/geoip/geoipregionvars.php");
$giCity = geoip_open("application/libraries/geoip/GeoLiteCity.dat", GEOIP_STANDARD);
$ip =$_SERVER['REMOTE_ADDR'];
$record = geoip_record_by_addr($giCity, $ip);
echo "Getting Country and City detail by IP Address <br /><br />";
echo "IP: " . $ip . "<br /><br />";
echo "Country Code: " . $record->country_code . "<br />" .
"Country Code3: " . $record->country_code . "<br />" .
"Country Name: " . $record->country_name . "<br />" .
"Region Code: " . $record->region . "<br />" .
"Region Name: " . $GEOIP_REGION_NAME[$record->country_code][$record->region] . "<br />" .
"City: " . $record->city . "<br />" .
"Postal Code: " . $record->postal_code . "<br />" .
"Latitude: " . $record->latitude . "<`enter code here`br />" .
"Longitude: " . $record->longitude . "<br />" .
"Metro Code: " . $record->metro_code . "<br />" .
"Area Code: " . $record->area_code . "<br />" ;

Categories