Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Nov 12th, 2007, 9:48 AM   #1
davil
Newbie
 
Join Date: Nov 2007
Posts: 27
Rep Power: 0 davil is on a distinguished road
Question regarding data input into PHP/Mysql using something other than GET

Hi all,

This is kinda more of a general question than simply a PHP question... I'm fairly decent at PHP and BASIC (I use Freebasic to make simple .exe console apps)
I'm struggling at learning C or C++ - basic just works whereas there are different header files with every tutorial / compiler I get so I'm getting a bit lost.
I haven't had any formal programming training yet so please bear with my stupidity.

Anyway, I have a PHP/MySQL based database system here at work that logs all PC info into the database, in this kind of format to give you an idea:

sql Syntax (Toggle Plain Text)
  1. DROP TABLE IF EXISTS `aidahardware`;
  2. CREATE TABLE `aidahardware` (
  3. `id` int(11) NOT NULL AUTO_INCREMENT,
  4. `datestamp` date DEFAULT NULL,
  5. `timestamp` varchar(25) DEFAULT NULL,
  6. `hostname` varchar(40) DEFAULT NULL,
  7. `serial1` varchar(18) DEFAULT NULL,
  8. `serial2` varchar(18) DEFAULT NULL,
  9. `serial3` varchar(18) DEFAULT NULL,
  10. `primaryip` varchar(15) DEFAULT NULL,
  11. `primarymac` varchar(17) DEFAULT NULL,
  12. `lastuser` varchar(25) DEFAULT NULL,
  13. `make` varchar(40) DEFAULT NULL,
  14. `model` varchar(40) DEFAULT NULL,
  15. `chassis_type` varchar(20) DEFAULT NULL,
  16. `cpu_info` varchar(50) DEFAULT NULL,
  17. `cpu_info2` varchar(50) DEFAULT NULL,
  18. `hdd` varchar(300) DEFAULT NULL,
  19. `optical` varchar(250) DEFAULT NULL,
  20. `ram` int(10) DEFAULT NULL,
  21. `os` varchar(35) DEFAULT NULL,
  22. `sp` varchar(20) DEFAULT NULL,
  23. `iever` varchar(30) DEFAULT NULL,
  24. `av` varchar(35) DEFAULT NULL,
  25. `avver` varchar(35) DEFAULT NULL,
  26. `avdat` varchar(10) DEFAULT NULL,
  27. `monitor` varchar(35) DEFAULT NULL,
  28. `chipset` varchar(35) DEFAULT NULL,
  29. `audio` varchar(65) DEFAULT NULL,
  30. `currproxy` varchar(20) DEFAULT NULL,
  31. `lanproxy` varchar(20) DEFAULT NULL,
  32. PRIMARY KEY (`id`)
  33. ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
  34.  
  35. INSERT INTO `aidahardware` VALUES ('','2007-10-22', '10:29', 'thehostname', 'theserial1', 'theserial2', 'theserial3', '10.175.52.10', '00-14-38-my-mac', 'the username', 'Hewlett-Packard', 'HP Compaq nx8220 (PG802EA#ABU)', 'Notebook', 'Mobile Unknown; 1551 MHz (7.5 x 207)', 'Intel(R) Pentium(R) M processor ', 'C: (NTFS);8172 MB (1277 MB free)£D: (NTFS);49051 MB (47799 MB free)£', 'MATSHITA UJ-822Da£', '512 MB', 'Microsoft Windows XP Professional', 'Service Pack 2', '6.0.2900.2180', 'McAfee VirusScan Enterprise', '8.0.0.912', '2007-09-20', 'Plug and Play Monitor [NoDB]', 'Unknown', 'Intel 82801FB ICH6 - AC97 Audio Controller£', '10.100.1.14:80', '10.100.1.14:80');
  36. etc. etc. etc.

as you may have guessed each machine runs AIDA32 in their logon script, which is the old freeware version of Lavalys Everest and it reports all the hardware info back to CSV files I have on a NAS server...
Every now and then I run a Freebasic EXE that converts all the data in the CSV files into a workable .sql file that I import into my server. (I know how bad of a practice this is but we're very busy here and I find it hard to find the time to learn new languages etc.)
Also as you can see I split certain fields like 'hdd' into sepearate parts using a seperator like £ and/or ; - if you check the SQL above you'll see what I mean. Then I could explode that info into an array for easier use in my PHP. That works a charm currently.

Ok so that's the way it currently works and I have a web-based interface so everybody here in our I.T. department can search for info by pc, or by hostname or by whatever. I have built up many handy SQL queries from the info and even a custom SQL query page so they can do custom queries on the info. We deal with just over 600 PCs in the building so nothing too crazy.
I thought that I should change it to make it dynamic so I don't have to run the exe or schedule it to run but instead, every time a PC logs on it reports directly back to the web server using the console version of curl or whatever.

My latest work on this involved this sort of code

php Syntax (Toggle Plain Text)
  1. $data = explode("/",$HTTP_SERVER_VARS['PATH_INFO']);
  2.  
  3. $datestamp = $data[1];
  4. $timestamp = $data[2];
  5. $hostname = $data[3];
  6. $serial1 = $data[4];
  7. $serial2 = $data[5];
  8. $serial3 = $data[6];
  9. $primaryip = $data[7];
  10. $primarymac = $data[8];
  11. $lastuser = $data[9];
  12. $make = $data[10];
  13. $model = $data[11];
  14. $chassis_type = $data[12];
  15. $cpu_info = $data[13];
  16. $cpu_info2 = $data[14];
  17. $hdd = $data[15];
  18. $optical = $data[16];
  19. $ram = $data[17];
  20. $os = $data[18];
  21. $sp = $data[19];
  22. $iever = $data[20];
  23. $av = $data[21];
  24. $avver = $data[22];
  25. $avdat = $data[23];
  26. $monitor = $data[24];
  27. $chipset = $data[25];
  28. $audio = $data[26];
  29. $cproxy = $data[27];
  30. $lproxy = $data[28];

and using
curl -0 http://mylocalwebserver/newinfo/date...o/hostnameinfo etc etc. etc.

But as you remember from the SQL before I would be passing a fair amount of data and also there are some strange characters in the data so I'm wondering if there's a more effective / efficient way to get this data from AIDA .csv form to the server itself?
The reason I'm not using ODBC on the clients is because we have a mixed environment with NT/2k/XP machines and I prefer to stick to what I know works, like AIDA for example works on all three platforms as does good old freebasic executables and text files (CSV) etc.

So to reiterate my question I'm wondering should I have the text files go to the web server and run some command line PHP that puts the data into the MySql server or maybe even an ODBC link on the server that a Freebasic or simple C++ program that loops and takes each new text file in and puts the info directly into the MySql server and then deletes the text files when it's done. Or should I stick with curl and work out my character problems by using simpler characters?
I just get the feeling that passing all the data through the URL is bad practice. I had also considered there may be a way to bypass curl and send the data using some sort of C++ program using POST rather than GET...

Also I was wondering how simple would it be to write a C++ or C program to extract the info from the BIOS (the info I'm currently using AIDA32 for)

I know it's a lot of questions and I probably have most of this wrong but I'm looking for how a real programmer would do this as I usally fart out some basic+php and meld it all together with sticky tape and hope for the best :-D

Thanks for reading all this....
davil is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Data getting question quantalfred Coder's Corner Lounge 8 Jul 22nd, 2006 3:39 AM
how do i automate text data and input into database? lionel84 C# 0 Jun 26th, 2005 10:35 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 8:29 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC