Login
Username: Password:
Remember me

[Sign Up] / [Recover Password]

Theme / Language

Popular
New Torrents
new name
Size: 18.40 MB
Most active
new name
S: 74 L: 3
New Posters
auto detect browser in account-details v
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / v2.08 / v2.08 Mods Completed

Unknown User
2012-12-10 13:16:11
http://devscorner.xyz/uploads/post-38138-0-18445700-1355145413.pnghi, here an alternative way of coding this, for both BROWSER & OS, just use array, its more clean  ;)   :

run this sql :


ALTER TABLE `users` ADD `browser` varchar(20) NOT NULL;

ALTER TABLE `users` ADD `os` varchar(30) NOT NULL;

in functions.php put this WHERE is the previous code, ...  lol  :

EDIT !!!  =>  replace exactly this code

:) :


:) :



if(preg_match("/Opera/u", getenv("HTTP_USER_AGENT"))) $browser = "opera";

else if(preg_match("/Safari/u", getenv("HTTP_USER_AGENT"))) $browser = "safari";

else if(preg_match("/WebTV/u", getenv("HTTP_USER_AGENT"))) $browser = "webtv";

else if(preg_match("/Maxthon/u", getenv("HTTP_USER_AGENT"))) $browser = "maxthon";

else if(preg_match("/Konqueror/u", getenv("HTTP_USER_AGENT"))) $browser = "Konqueror";

else if(preg_match("/Firefox/u", getenv("HTTP_USER_AGENT"))) $browser = "firefox";

else if(preg_match("/MSIE/u", getenv("HTTP_USER_AGENT"))) $browser = "Internet Explorer";

else if(preg_match("/Lynx/u", getenv("HTTP_USER_AGENT"))) $browser = "lynx";

else if((preg_match("/Nav/u", getenv("HTTP_USER_AGENT"))) || (preg_match("/Gold/u", getenv("HTTP_USER_AGENT"))) || (preg_match("/X11/u", getenv("HTTP_USER_AGENT"))) || (preg_match("/Mozilla/u", getenv("HTTP_USER_AGENT"))) || (preg_match("/Netscape/u", getenv("HTTP_USER_AGENT"))) ) $browser = "mozilla";

else $browser = "Autre - Inconnu";

SQL_Query_exec("UPDATE users SET last_access='" . get_date_time() . "', ip=".sqlesc($ip).", browser=".sqlesc($browser).", page=".sqlesc($where)." WHERE id=" . $row["id"]);

by this one :






$user_agent = $_SERVER['HTTP_USER_AGENT'];



// browser detection

$browser = "Unknown Browser";

$browser_array = array(

'/msie/i' => 'Internet Explorer',

'/firefox/i' => 'Firefox',

'/safari/i' => 'Safari',

'/chrome/i' => 'Chrome',

'/opera/i' => 'Opera',

'/netscape/i' => 'Netscape',

'/maxthon/i' => 'Maxthon',

'/konqueror/i' => 'Konqueror',

'/mobile/i' => 'Handheld Browser'

);

foreach ($browser_array as $regex => $value) {

if (preg_match($regex, $user_agent)) {

$browser = $value;

}

}

// OS detection

$os = "Unknown OS Platform";

$os_array = array(

'/windows nt 6.2/i' => 'Windows 8',

'/windows nt 6.1/i' => 'Windows 7',

'/windows nt 6.0/i' => 'Windows Vista',

'/windows nt 5.2/i' => 'Windows Server 2003/XP x64',

'/windows nt 5.1/i' => 'Windows XP',

'/windows xp/i' => 'Windows XP',

'/windows nt 5.0/i' => 'Windows 2000',

'/windows me/i' => 'Windows ME',

'/win98/i' => 'Windows 98',

'/win95/i' => 'Windows 95',

'/win16/i' => 'Windows 3.11',

'/macintosh|mac os x/i' => 'Mac OS X',

'/mac_powerpc/i' => 'Mac OS 9',

'/linux/i' => 'Linux',

'/ubuntu/i' => 'Ubuntu',

'/iphone/i' => 'iPhone',

'/ipod/i' => 'iPod',

'/ipad/i' => 'iPad',

'/android/i' => 'Android',

'/blackberry/i' => 'BlackBerry',

'/webos/i' => 'Mobile'

);

foreach ($os_array as $regex => $value) {

if (preg_match($regex, $user_agent)) {

$os = $value;

}

}



SQL_Query_exec("UPDATE users SET last_access='" . get_date_time() . "', ip=".sqlesc($ip).", browser=".sqlesc($browser).", os=".sqlesc($os).", page=".sqlesc($where)." WHERE id=" . $row["id"]);










then in account.php :



place where you want to show those up :





<?php print("<b>".T_("BROWSER").":</b> " . $CURUSER["browser"] . "n"); ?><br />

<?php print("<b>".T_("OS").":</b> " . $CURUSER["os"] . "n"); ?><br />




EDIT ==> OR if you want to add some icons use this way ( lol coz u'r addicted to pictures ...



<?php echo T_("BROWSER"); ?>: <?php echo $CURUSER["browser"]."&nbsp;&nbsp;<img src='".$site_config['SITEURL']."/images/browsers/".$CURUSER["browser"].".png' width='40' height='40' alt='".$CURUSER["browser"]."' title='Detected Browser : ".$CURUSER["browser"]."'>&nbsp;";?><br />

<?php echo T_("OS"); ?>: <?php echo $CURUSER["os"]."&nbsp;&nbsp;<img src='".$site_config['SITEURL']."/images/oss/".$CURUSER["os"].".png' width='40' height='40' alt='".$CURUSER["os"]."' title='Detected Operating System : ".$CURUSER["os"]."'>&nbsp;";?><br />












and  in account-details.php,

 place where you want to show those up :





<?php echo T_("BROWSER"); ?>: <?php echo htmlspecialchars($user["browser"]);?><br />

<?php echo T_("OS"); ?>: <?php echo htmlspecialchars($user["os"]);?><br />






EDIT ==> OR if you want to add some icons use this way ( lol coz u'r addicted to pictures ...



<?php echo T_("BROWSER"); ?>: <?php echo htmlspecialchars($user["browser"])."&nbsp;&nbsp;<img src='".$site_config['SITEURL']."/images/browsers/".$user["browser"].".png' width='40' height='40' alt='".$user["browser"]."' title='Detected Browser : ".$user["browser"]."'>&nbsp;";?><br />

<?php echo T_("OS"); ?>: <?php echo htmlspecialchars($user["os"])."&nbsp;&nbsp;<img src='".$site_config['SITEURL']."/images/oss/".$user["os"].".png' width='40' height='40' alt='".$user["os"]."' title='Detected Operating System : ".$user["os"]."'>&nbsp;";?><br />






Then, you just have to define the width and height to suits your desire, in my example i put 40 x 40 as you can see,

And google images thoses icons you need and put theme into the corresponding folders :

/images/browsers  &  /images/oss/

i give you those folders along with 1 pic in each to help you start on this  :)

So THIS WAY you really dont need to run another sql request, neither another table in databse, alwasys think about saving your server ressources ...

-------

update your langages files. :)

[url="http://devscorner.xyz/applications/core/interface/file/attachment.php?id=6351"]browsers.rar[/url]

[url="http://devscorner.xyz/applications/core/interface/file/attachment.php?id=6352"]oss.rar[/url]

browser&os.png
browser&os.png
browsers.rar
Download
oss.rar
Download
browsers&osswithicons.png
browsers&osswithicons.png
Unknown User
2012-12-10 14:34:52
"Tiloup, post: 87318":
yes exact...

Database Error in account-details.php on line 58: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 1' at line 1. Query was: SELECT name,browserpic FROM browsers WHERE id= LIMIT 1.
wrong file attached LOL.. line 58 of that one is something to do with stylesheets...

Anyway if using that picture browser thing try this:)





//$browsers

$browser_id = (int) $user[browser];

if ($browser_id > 0) {

   $res = SQL_Query_exec("SELECT name,browserpic FROM browsers WHERE id=$browser_id LIMIT 1");

   if (mysql_num_rows($res) == 1) {

       $arr = mysql_fetch_assoc($res);

       $browser = "$arr[name] <img src=images/browser/$arr[browserpic] height=30 width=30 border=0>";

   } else {

       $browser = "<img src=images/browser/unknown.png height=30 width=30 border=0>";

   }

}


It should not even make an query unless its an # of an id:)

in theory could use the above persons one also if not wanting an pic LOL, but people like pics hehehe
2012-12-10 16:44:56
@Tiloup

my guess is. Because the orginal query didnt set a default browser, so just manually change it to 9 using phpmyadmin or something



ALTER TABLE `users` CHANGE `browser` `browser` VARCHAR( 50 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '9'


TTv3 Micro Edition
Ubuntu 20.04.6 LTS Server
Mysql Version: 10.3.39-MariaDB-0ubuntu0.20.04.2
PHP Version: 7.4.3-4ubuntu2.20
Apache Version: Apache/2.4.59 (Ubuntu)
Unknown User
2012-12-10 18:29:52
hello, i edited my example for those wanting to add icons ....  :)

Quote:
EDIT ==> OR if you want to add some icons use this way ( lol coz u'r addicted to pictures ... :) :
the goal using my version,

is to save the more php code lines, and sql requests as possible ...
2012-12-11 01:27:00
Quote:
It should not even make an query unless its an # of an id:)in theory could use the above persons one also if not wanting an pic LOL, but people like pics hehehe

YES exact! lol,

not need to specify the ID of the row or another, as if you did change is as accurate and useful for everyone!

Thanks ActicWolf :)
2012-12-11 01:29:03
"MicroMonkey, post: 87332":
@Tiloup

my guess is. Because the orginal query didnt set a default browser, so just manually change it to 9 using phpmyadmin or something



ALTER TABLE `users` CHANGE `browser` `browser` VARCHAR( 50 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '9'



First thing I did and the ca not walk, thank you for your support anyway! ;)
2012-12-11 01:44:04
"flameche, post: 87329":
http://devscorner.xyz/uploads/post-38138-0-18445700-1355145413.pnghi, here an alternative way of coding this, for both BROWSER & OS, just use array, its more clean  ;)   :

run this sql :


ALTER TABLE `users` ADD `browser` varchar(20) NOT NULL;

ALTER TABLE `users` ADD `os` varchar(30) NOT NULL;

in functions.php put this WHERE is the previous code, ...  lol  :

:) :



$user_agent = $_SERVER['HTTP_USER_AGENT'];



// browser detection

$browser = "Unknown Browser";

$browser_array = array(

'/msie/i' => 'Internet Explorer',

'/firefox/i' => 'Firefox',

'/safari/i' => 'Safari',

'/chrome/i' => 'Chrome',

'/opera/i' => 'Opera',

'/netscape/i' => 'Netscape',

'/maxthon/i' => 'Maxthon',

'/konqueror/i' => 'Konqueror',

'/mobile/i' => 'Handheld Browser'

);

foreach ($browser_array as $regex => $value) {

if (preg_match($regex, $user_agent)) {

$browser = $value;

}

}

// OS detection

$os = "Unknown OS Platform";

$os_array = array(

'/windows nt 6.2/i' => 'Windows 8',

'/windows nt 6.1/i' => 'Windows 7',

'/windows nt 6.0/i' => 'Windows Vista',

'/windows nt 5.2/i' => 'Windows Server 2003/XP x64',

'/windows nt 5.1/i' => 'Windows XP',

'/windows xp/i' => 'Windows XP',

'/windows nt 5.0/i' => 'Windows 2000',

'/windows me/i' => 'Windows ME',

'/win98/i' => 'Windows 98',

'/win95/i' => 'Windows 95',

'/win16/i' => 'Windows 3.11',

'/macintosh|mac os x/i' => 'Mac OS X',

'/mac_powerpc/i' => 'Mac OS 9',

'/linux/i' => 'Linux',

'/ubuntu/i' => 'Ubuntu',

'/iphone/i' => 'iPhone',

'/ipod/i' => 'iPod',

'/ipad/i' => 'iPad',

'/android/i' => 'Android',

'/blackberry/i' => 'BlackBerry',

'/webos/i' => 'Mobile'

);

foreach ($os_array as $regex => $value) {

if (preg_match($regex, $user_agent)) {

$os = $value;

}

}



SQL_Query_exec("UPDATE users SET last_access='" . get_date_time() . "', ip=".sqlesc($ip).", browser=".sqlesc($browser).", os=".sqlesc($os).", page=".sqlesc($where)." WHERE id=" . $row["id"]);



then in account.php place where you want to show those up :




<?php print("<b>".T_("BROWSER").":</b> " . $CURUSER["browser"] . "\n"); ?><br />

<?php print("<b>".T_("OS").":</b> " . $CURUSER["os"] . "\n"); ?><br />








and  in account-details.php,  place where you want to show those up :





<?php echo T_("BROWSER"); ?>: <?php echo htmlspecialchars($user["browser"]);?><br />

<?php echo T_("OS"); ?>: <?php echo htmlspecialchars($user["os"]);?><br />






EDIT ==> OR if you want to add some icons use this way ( lol coz u'r addicted to pictures ...



<?php echo T_("BROWSER"); ?>: <?php echo htmlspecialchars($user["browser"])."&nbsp;&nbsp;<img src='".$site_config['SITEURL']."/images/browsers/".$user["browser"].".png' width='40' height='40' alt='".$user["browser"]."' title='Detected Browser : ".$user["browser"]."'>&nbsp;";?><br />

<?php echo T_("OS"); ?>: <?php echo htmlspecialchars($user["os"])."&nbsp;&nbsp;<img src='".$site_config['SITEURL']."/images/oss/".$user["os"].".png' width='40' height='40' alt='".$user["os"]."' title='Detected Operating System : ".$user["os"]."'>&nbsp;";?><br />






Then, you just have to define the width and height to suits your desire, in my example i put 40 x 40 as you can see,

And google images thoses icons you need and put theme into the corresponding folders :

/images/browsers  &  /images/oss/

i give you those folders along with 1 pic in each to help you start on this  :)

So THIS WAY you really dont need to run another sql request, neither another table in databse, alwasys think about saving your server ressources ...

-------

update your langages files.  :)


Cool mode!!  :D

error /functions.php on line 285


Unknown User
2012-12-11 06:43:25
hi tiloup i edited my post to show you exactly wich part of code i replace :)
Unknown User
2012-12-11 07:59:07
"flameche, post: 87329":
http://devscorner.xyz/uploads/post-38138-0-18445700-1355145413.pnghi, here an alternative way of coding this, for both BROWSER & OS, just use array, its more clean  ;)   :

run this sql :


ALTER TABLE `users` ADD `browser` varchar(20) NOT NULL;

ALTER TABLE `users` ADD `os` varchar(30) NOT NULL;


If using this should really put an default... LOL

this code will alter your existing if using his





ALTER TABLE `users` CHANGE `os` `os` VARCHAR( 30 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT 'Unknown OS Platform',

CHANGE `browser` `browser` VARCHAR( 20 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT 'Unknown Browser';

If not done the sql yet and want to use it use




ALTER TABLE `users` ADD `browser` varchar(20) NOT NULL  DEFAULT 'Unknown Browser';

ALTER TABLE `users` ADD `os` varchar(30) NOT NULL DEFAULT 'Unknown OS Platform';



and dont try and use the version the person 1st said with the new changes... 1 bug I dont like about all these changes people seem to use the same database users key "browser"... You try and use the version that needs an number and its text it will error out.. you try and use the last version that needs text and when you view other people that have not visited after you change it the browser info will be wrong or prob errored out...
Unknown User
2012-12-11 08:20:23
Quote:
and dont try and use the version the person 1st said with the new changes... 1 bug I dont like about all these changes people seem to use the same database users key "browser"... You try and use the version that needs an number and its text it will error out.. you try and use the last version that needs text and when you view other people that have not visited after you change it the browser info will be wrong or prob errored out...

1) there are no errors on the code i gave, its perfectly running !

generally a user create an account and connect to , nope ???  lolll

anyway, no errors will get out with my code, just think about before criticising for nothing

2) ok about the default value, its a good idea

3) my code does not use any additional sql request, and its more clean to use arrays ;)
2012-12-12 01:33:13
Big Thanks you flameche   :)  Works very well with update!  :D

...a big thank you also to ArticWolf.

v2.08
Unknown User
2012-12-12 02:11:25
.. no errors lol i tried your code on my dev site without changing an thing  and it gave invalid pics...... so that is an error... .jpg LOL..... I love it when people have like 2 posts and they "think" they know more the an moderator of an place..............  anyway np  tiloup nice to see someone saying thanks for all the stuff I do:)

And default things are used every time you add a new field or drop an existing field to re-add it................. and also when 1st creating an record aka when someone signup or gets an account created...
2012-12-12 02:29:20
"ArcticWolf, post: 87357":
.. no errors lol i tried your code on my dev site without changing an thing and it gave invalid pics...... so that is an error... .jpg LOL..... I love it when people have like 2 posts and they "think" they know more the an moderator of an place.............. anyway np tiloup nice to see someone saying thanks for all the stuff I do:)

And default things are used every time you add a new field or drop an existing field to re-add it................. and also when 1st creating an record aka when someone signup or gets an account created...

Yes, thanks!





[url="http://devscorner.xyz/applications/core/interface/file/attachment.php?id=6957"]browsers+oss+Unknown.rar[/url]
#11.PNG
#11.PNG
22.PNG
22.PNG
browsers+oss+Unknown.rar
Download

2012-12-13 01:20:10
I agree with tiloup. It does work with tiloup oss folder and a few of the edits from flameche. Thanks tiloup and flameche and ArcticWolf  :)

in account-details.php, you can just use this. I removed and changed a few parts of flameche edit. 30 x 30 looks best I feel



<?php echo T_("OS"); ?>: <?php echo htmlspecialchars($user["os"])."&nbsp;&nbsp;<img src='".$site_config['SITEURL']."/images/oss/".$user["os"].".png' width='30' height='30'>&nbsp;";?><br />

I didn't do any edits for account.php, since the only person that sees that file is yourself





If you already ran the SQL from FLAMECHE post earlier, run this SQL to add a DEFAULT value to that column




ALTER TABLE `users` CHANGE `os` `os` VARCHAR( 30 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'Unknown'



then add the attached PNG to your images/oss folder, or feel free to find another image of your own liking, just make sure you name it exactly Unknown.png, if you use the DEFAULT value I posted above in the SQL

Unknown.png
Unknown.png

TTv3 Micro Edition
Ubuntu 20.04.6 LTS Server
Mysql Version: 10.3.39-MariaDB-0ubuntu0.20.04.2
PHP Version: 7.4.3-4ubuntu2.20
Apache Version: Apache/2.4.59 (Ubuntu)
Unknown User
2012-12-22 02:35:08
thank you
Users online

No users online

Search



Statistics

    Torrents

  • Tracking: 3
  • Todays torrents: 0
  • Seeders: 0
  • Leechers: 0
  • Peers: 0
  • Downloaded: 89.96 GB
  • Uploaded: 9.86 GB

  • Members

  • We have: 838
  • New today: 0
  • Guest today: 9

  • Online

  • Total online: 1
  • Members: 0
  • Guests online: 1
  • Comments: 3
  • Messages: 1,728