Jump to content

Archived

This topic is now archived and is closed to further replies.

marcus

Is it possible...

Recommended Posts

...to echo the viewers Town/City and State on a page?

Share this post


Link to post
Share on other sites
Yes, if they've already provided you with the details.

You can ask the user for those details and let them submit them, you can then save them somewhere, like inside a database, then recall them when the user returns.

Regards
Huggie

Share this post


Link to post
Share on other sites
but i've seen places that havent gathered information and have posted my town and state

Share this post


Link to post
Share on other sites
ok, in that case they're psychic websites... Can you provide an example site, I'll check it out.

Regards
Huggie

Share this post


Link to post
Share on other sites
OK, pretty much the only information they can get from you is what your browser provides.  They maybe looking at your IP address and seeing where it's registered or something slightly more advanced, but it's unlikely.

Huggie

Share this post


Link to post
Share on other sites
I do it with users ip's.

But i can not remember the site i got the database dump.

Share this post


Link to post
Share on other sites
I have a old dump from last year that I bought, if you want it, tell me I'll post a link to it. It comes with a image script so you can write the city on to a image file!

me!

Share this post


Link to post
Share on other sites
It will be another 20 minutes before I can get on my server that has the database, I'm doing a backup now so i don't want to login when it running. I will post the download after that...

Here is a simple example, you can use any image, the script uses an array() that sets the writing method (size, center, angles (hoz, vert)!

http://www.dinningoutoftown.com/test.php

example of the script!

[code]
<?
/* protect the include files */

define ( 'SYSTEM_REQUESTED', 1 );

/* the back end */

include_once ( '/home/vhost_27/no_access/ip/geo.php' );

/* begin the image display process */


// the image we are going to write to (must be a PNG)

$img = '/home/vhost_27/no_access/images/example.png';

// the write text array

/*
* see the example image * /geo/example.png * to understand each array value
top =>
array ( 0 => font size,
1 => the text write angle,
2 => text start vertical position
3 => text start writing position (from left edge of image)
4 => the font path and name
},
bottom =>
array ( 0 => font size,
1 => the text write angle,
2 => text start vertical position
3 => text start writing position (from left edge of image)
4 => the font path (full_path) and name
);
*
*/

$ta = array (
'top' => array ( 10, -10, 250, 0, '/home/vhost_27/no_access/fonts/arabolic.ttf' ),
'bottom' => array ( 10, -10, 270, 0, '/home/vhost_27/no_access/fonts/arabolic.ttf' )
);

// the top text

$top = 'I love';

// if a country name needs * the * before it we use this

/* ~ explained! (only used if no city is found and a country is found)
* countries that are a single word -> Canada, do not use $add
* countries that contain more than one word with a space -> United States, use $add
*/

$add = ' the';

// other result

/*
* when no city or country is found we use this
*/

$other = 'you';

// ending for the (bottom) line of text

$end = '!';


/* check for city, if we don't have one, check for a country */

if ( empty ( $data['city'] ) )
{
/* now check for a country, if no country we use $other */

if ( empty ( $data['country'] ) )
{
$text = $other . $end;
}
else
{
/* check if we need to add ($add) or strip (-) */

if ( str_word_count ( $data['country'] ) > 1 )
{
$top .= $add;
$text = $data['country'] . $end;
}
if ( strpos ( $data['country'], '-' ) !== false )
{
$text = str_replace ( '-', ' ', $data['country'] ) . $end;
}
else
{
$text = $data['country'] . $end;
}

}
}
else
{
$text = $data['city'] . $end;
}

/* load the image and set the text colors for writing */

$image = imagecreatefrompng ( $img );

//$backg = imagecolorallocate ( $image, 255, 255, 255 );

$color = imagecolorallocate ( $image, 131, 110, 92 );

/* get the exact position to write our (top) text */

  $center = imagettfbbox ( $ta['top'][0], $ta['top'][1], $ta['top'][4], $top );

$horzp = ( ( imagesx ( $image ) - abs ( $center[4] ) ) / 2 ) - $ta['top'][3];

/* write the (top) text */

imagettftext ( $image, $ta['top'][0], $ta['top'][1], $horzp, $ta['top'][2], $color, $ta['top'][4], $top );


/* get the exact position to write our (bottom) text */

  $center = imagettfbbox ( $ta['bottom'][0], $ta['bottom'][1], $ta['bottom'][4], $text );

$horzp = ( ( imagesx ( $image ) - abs ( $center[4] ) ) / 2 ) - $ta['bottom'][3];

/* write the (bottom) text */

imagettftext ( $image, $ta['bottom'][0], $ta['bottom'][1], $horzp, $ta['bottom'][2], $color, $ta['bottom'][4], $text );

/* write it out to the browser */

header ( 'Content-Type: image/jpeg;' );
imagejpeg ( $image );
imagedestroy ( $image );
?>
[/code]



me!

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.