faulty.lee
Members-
Content Count
496 -
Joined
-
Last visited
Everything posted by faulty.lee
-
I was surprised by McAfee just 2 days ago, when i have to network 2 pc toghether. Both pc has preinstalled McAfee (with anti virus and firewall). After connecting the 2 pc, i can't access the apache running on one of it. So first thought is ping. Ping didn't work. After testing the network cables with my laptop and my colleague's, we're sure that the cable is working. After a while of tinkering, we finally realized bout McAfee, so went ahead and disabled it, voila, everything works like charm. Where as Norton, i've not use for quite number of years. I used to be a fan of norton when their norton disk doctor was far better then win98's scandisk. Norton speeddisk and my favourite diskedit, i use that to manually recovered data, such as a few harddisk suffered from CIH's attack. That was, i would say legend. Now i don't like norton anymore, same reason with WeaponX, resource hog. And they seems to target fancy UI rather than actual functionality.
-
What Is The MySQL Version @ Asta ? MySQL 4.0.26-Max<br />
faulty.lee replied to faulty.lee's topic in Web Hosting Support
That 2 function TIME_TO_SEC/SEC_TO_TIME is actually very useful for calculating interval. Divide by 60, then you get minute and so on. Really flexible, can get into anything you want to do with date/time I have both the 1st and 2nd edition of the Php Cookbook. The 1st targeting 3.x and 4.x while the 2nd targeting 5.x. Am i allowed to upload pirated/illegal item in this forum? I don't mind to upload. If i'm not allowed to, then i can email to you -
Nothing simpler than that already. By the way, why do you want to do the redirection in the onLoad? If you have nothing you want to show on that page, and want to redirect immediately, put that code in the javascript section at the beginning of the page, that way it doesn't have to wait until the page finished loading. The browser will redirect as soon as it see that code. Good Luck
-
What Is The MySQL Version @ Asta ? MySQL 4.0.26-Max<br />
faulty.lee replied to faulty.lee's topic in Web Hosting Support
Hi, I've found the way to do what i wanted in the first place. TIMEDIFF(t1, t2) can be replace with SEC_TO_TIME(TIME_TO_SEC(t2) - TIME_TO_SEC(t1))simple as that. Never thought of it that way Found that in O'Reilly: MySQL Cookbook. The O'Reilly's series is really good, very thoughtful and well suited problem/solution type of book for programmers. Just have to replace all occurrences of TIMEDIFF with the above. At least that solved part of my problem, now my code can run on MySQL older that 4.1.1. Will have to remember to stick to the lowest possible denominator all time, for portability. Hooray!!!!! -
What Is The MySQL Version @ Asta ? MySQL 4.0.26-Max<br />
faulty.lee replied to faulty.lee's topic in Web Hosting Support
What about the last stable version of 4.x? A lot of new function is introduced since 4.0.26, the version used by Xisto. -
Hi Hercco,I do admit that i wasn't very good with linux and shell script. Just trying to give a working example. I've tested that on a linux server where i've quite a lot of rights given. Anyway, you idea seems cleaner from php point of view.
-
This is a crude method, but i just tested, and works on my side. Save this as /home/myhome/test.php $temp_filename = "webcam-" . date('Y-m-d-G.i') . ".jpg";system('wget -q http://forums.xisto.com/no_longer_exists/ -O /home/myhome/' . $temp_filename);echo "Done fetching " . $temp_filename . "\n"; the code first generate a temp filename from the current server time then call wget to download the image and save as the filename generated edit your crontab as */10 * * * * php < /home/myhome/test.php EDIT: you can refer to crontab here https://en.wikipedia.org/wiki/Cron you can use php or php-cgi the output will be Content-type: text/htmlX-Powered-By: PHP/5.0.4Done fetching webcam-2006-11-23-22.32.jpg If you want to log the output of the php, just add a redirection like this * * * * */10 php < /home/myhome/test.php > /home/myhome/logs That's all. One thing though, i don't know how to remove the http header from the php output. Anyway, the rest is up to you to refine. Good luck
-
I've use cron jobs to access a php script that does something, everyday. It's for my hotel management system, where the system will post the room charges automatically everyday. I didn't call the cgi version, instead i use wget to call the page locally wget -q http://localhost/autopost.php -O - >> /home/myfolder/logsthat way, the page will run exactly the same as if it runs from a browser, and the text output is appended to the logs in myfolder. toby, if the image you're trying to save has static url, then it would be easier. But i'm not sure of the exact way of doing it. If the url is static, maybe you can use fopen() to open the file stream of the image, then save it to another handle to a local file(open with fopen() with mode = x) with fwrite(). Seems complicated. Another way is to use wget to download the file programatically to the temp folder, then use rename() to move that file to your desire destination and at the same time rename it to your choice If the url is not static, things get a bit more complicated, you'll have to parse the page that holds the image manually, to get the url of the image, then continue with the above method. the parse might be able to do with DOM, but i'm not sure and never did. The above is just a suggestion of concept, it's not proven to work. But might give you some idea of where to start. Try read the manual of those mentioned php function, the comment section might provide more hints Good luck
-
What Is The MySQL Version @ Asta ? MySQL 4.0.26-Max<br />
faulty.lee replied to faulty.lee's topic in Web Hosting Support
Thanks, that sure helps. Actually I was also looking for a way to do it in mysql itself, cause my query involve some recursive calculation on date/time. If it were to read the result then process by php, performance will be greatly reduce. Well, if there's no alternative, then that might have to be the only way out.Thanks again -
What Is The MySQL Version @ Asta ? MySQL 4.0.26-Max<br />
faulty.lee replied to faulty.lee's topic in Web Hosting Support
Those are MySQL's functions. I wrote the web software myself. It was working on my machine and on hosting server that provides MySQL version higher than 4.1.1. As also mentioned in MySQL reference manual, those function are only introduce after 4.1.1 -
What Is The MySQL Version @ Asta ? MySQL 4.0.26-Max<br />
faulty.lee replied to faulty.lee's topic in Web Hosting Support
Hi,I have another question. My web page needs to use a few mysql function that's introduce after v4.1.1, since our hosting only provide v4.0.26, just wondering is there any alternative function for :1. DATEDIFF2. TIMEDIFF3. ADDTIME4. SUBTIMEMost important is actually TIMEDIFF. I've googled and no result. Really sad, never thought that i'll actually use a function that's not available in common hosting server -
Need MySQL Alternative To The Syntax "or die()"
faulty.lee replied to bakr_2k5's topic in Programming
You're welcome.Just now I did try $menus_result = mysql_query($query) or NULL;which is suppose to set NULL into $menus_result, but then is_null($menus_result) still return false.I guess if($menus_result) is less picky. Anyway, glad it helps -
Need MySQL Alternative To The Syntax "or die()"
faulty.lee replied to bakr_2k5's topic in Programming
Here, just tested it, and works. I'm using php5 and mysql5 on winxp pro <?php$query = "SELECT * FROM menus ORDER BY id ASC";$menus_result = mysql_query($query);if ($menus_result){ while( $menu=mysql_fetch_array($menus_result) ) { echo $menu['name']."<br />"; }}echo "Next Job";?> You can skip the "or die("Error!");" "die()", according to php's manual is equivalent to "exit()", thus it will terminates execution of the script, skipping the remaining. What i've change is just remove the "or die" and added a check for the returned result from mysql_query(), if mysql_query() failed, nothing will be return into $menus_result, thus skipping the menu code. I did try to use "is_null($menus_result)", but didn't work, not sure why. The if check is actually a good practice so you don't just sit there and wait for mysql_fetch_array to complaint bout the result -> "Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in " Good luck -
Hi,A few question here,1. Just wondering, the MySQL hosted on Xisto.com is actually version "4.0.26-Max" according to phpmyadmin. But why is cPanel showing "4.1.21-standard"?2. Actually i've existing codes that need function introduced after version 4.1.1, is there by any chance Xisto or xisto is going to upgrade the MySQL package?Thanks
-
Hi, This is a bit off topic. I just been to your site http://www.ycoderscookbook.com/ link from another forum topic. Only realize the owner is the same person that i replied on this topic. Very nice site indeed. I'm amaze by the amount of work you actually put into doing that. The design of the site is also very unique. Just some comment, if you have heard of gaim, maybe you can contribute to their project or combine their's with your's Regards Faulty
-
I think it's the physical connection problem, cause you're getting 169.254.x.x. When you configure manually to the same IP range as your router, what did you get when you Ping? If ping fail in this case, it's very likely hardware or driver problem for sure. Security software normally only intervene at the logical layer. But, then i might be wrong. Anyway, good luck
-
How To Boot To Command Prompt
faulty.lee replied to dhanesh1405241511's topic in Websites and Web Designing
Hi masterio, You're right bout this. Just friendly reminder, the "/s" for format is no longer possible from ms-dos prompt since win2k. If you still have access to winme or win98, then formatting is as simple as boot up with F8 and skip the loading of windows to goto "pure" dos-prompt. Which i believe dhanesh doesn't have such option available. No offense masterio. -
How To Boot To Command Prompt
faulty.lee replied to dhanesh1405241511's topic in Websites and Web Designing
If you just want to boot then format, grab a copy of bootdisk from http://bootdisk.com/bootdisk.htm Win98se should do. Then use nero or your favourite cd burning burning software to create a bootable cd "CD-ROM (Boot)". Under the boot tab (refering to nero, other software might have different name, but should be similiar), select image file, that browse for the image you just download. Put in any other file you want to appear along in the cd. Then burn. That's it. If you don't have a burner but have a spare thumbdrive, then you can try USB boot, provided if you laptop support it. You'll need winimage (or other free tools, to dump the image to your thumdrive), the same image and syslinux. This method works for me on my twinhead notebook with apacer 128MB thumbdrive or kingstone 1GB traveller, might or might not works in your case. But it's worth a try, you can always reformat you thumbdrive. Get syslinux from here -> http://freecode.com/projects/syslinux/ First use winimage to create a backup of your thumbdrive. You'll need to do this cause when you dump the image, sometime you'll loose the full size of the thumbdrive, cause the partition table is overwritten. After backup, open the image file you downloaded, then write into your thumbdrive. After that, get to cmd or ms-dos prompt, run "syslinux F:" without the quote and subsitute "F:" with the drive letter of your thumdrive. That's it, now reboot your laptop, it should boot into dos, and you thumbdrive will appear as A: or B: depending on the bios. If it doesn't work, or hang half way during bootup, try run syslinux with "-s" Hope i didn't miss out anything. If you google, you should find a lot other similiar tutorial, i learned from there too. Anyway, the boot cd is less hassle comparing to usb boot. So, unless you're adventurous, try the boot cd method first Good luck -
Can't Able To Access "frequently Asked Questions" Area
faulty.lee replied to niran's topic in Web Hosting Support
I just did some testing. Now even clicking on the FAQ link at the main page also leads to the spam site. http://www.systemdoctor.com/ Weird. When i first posted this problem here, that link still point to the right FAQ page, except for the parse error. How did the spam cropped in anyway? Just wish there's a way to shot and kill these annoying spam site at our will Maybe can organized a DOS attack on it, hehehe -
Sorry, i was very lazy at putting in comment. Anyway, feel free to ask if you don't understand. Or just change the coding around to see how it works.That code has works for me for quite sometime, save a lot of hours of programming also. Glad it helps.
-
When you said "It won't allow us to connect to the router no matter what", do you meant physical connection or logical one? When you plug the LAN into the router, you should see that under the status of your LAN connection, you'll see that it's connected. That's physical connection. If you're use automatic IP configuration, on the "Support" tab in the LAN status, you'll see your IP address auto assign by the router's DHCP. If that IP is properly assign and not 169.x.x.x (this is assign by windows when DHCP is not working), then you have a logical connection working. Now try to ping the "Default Gateway" which should be your router's IP If you get 169.x.x.x as your IP, that means DHCP is not working. You'll have to manually set your IP for the moment so you can connect into your router to turn DHCP on. Make sure you set your IP to the same range as your router, else ping won't work also. Some common router IP is 192.168.0.1 or 192.168.1.1 or 10.0.0.1, so make you IP the same except for the last number. If those above is actually working, can you still cannot browse the internet, try to ping your ISP's IP (you can get the IP by pinging the domain name using another working PC), remember ping by IP, not domain name. If ping by IP works, but you cannot browse the internet, it's your DNS setting that's wrong. Check the DNS setting in your router, or the DNS setting under TCP/IP of your LAN's configuration. You might have automatic IP config, but manually DNS, IP and DNS are configure separately. If you can't get DNS working, try to get the DNS from your ISP (via phone maybe), then key into the DNS section of your LAN config. That should work. If still not working, must have been something else already, which is very unlikely
-
Mount Two Hdd's In One Location
faulty.lee replied to djXternal's topic in Websites and Web Designing
Not sure of the proper way, maybe you can try to mount it as another folder, then copy/move everything over, then mount back as what you just did. Crude, but should work -
Not really an engine per se, but didn't know better words. Use at your own risk, and it's not optimized This is the part in the common file function template_open($filename){ if(!file_exists($filename)) { return false; } $handle = fopen($filename, "r"); $content = ""; while (!feof($handle)){[code] $content = $content . fread($handle, 8192); } fclose($handle); return $content;}function output_page(&$page){ global $username; $page = str_replace("{USERNAME}", $username, $page); echo $page;} This part in the page itself "./index.php" $temp_main = "./templates/index.html";$temp_menu = "./templates/menu.html";$menu = template_open($temp_menu);$page = template_open($temp_main);if ($page){ if ($menu) { $page = str_replace("{CONTENT}", $content, $page); //This one load the "menu" page into "{MENU}" section. //More or less like the "include('page1.php')" $page = str_replace("{MENU}", $menu, $page); output_page(); }} If you need to have processing on the"menu.php", then you can encapsulate it into a function which return the processed HTML as $menu. If you can follow up till here. Then the next part is much more powerful one, it's to generate table with odd or even row. Cause i use diff coloring for each that's why. This part inside common function template2_open($filename, &$row_content_odd, &$row_content_even){ if(!file_exists($filename)) { return false; } $handle = fopen($filename, "r"); $content = ""; while (!feof($handle)){ $content = $content . fread($handle, 8192); } fclose($handle); //$content2 = explode("\n", $content); $start_odd_row_pos = strpos($content, "BEGIN_ODD_ROW"); $start_odd_row_pos = strpos($content, "\n", $start_odd_row_pos); $end_odd_row_pos = strpos($content, "END_ODD_ROW", $start_odd_row_pos); $end_odd_row_pos = strpos($content, "\n", $end_odd_row_pos); $start_even_row_pos = strpos($content, "BEGIN_EVEN_ROW"); $start_even_row_pos = strpos($content, "\n", $start_even_row_pos); $end_even_row_pos = strpos($content, "END_EVEN_ROW", $start_even_row_pos); $end_even_row_pos = strpos($content, "\n", $end_even_row_pos); $row_content_odd = substr($content, $start_odd_row_pos, $end_odd_row_pos - $start_odd_row_pos); $row_content_even = substr($content, $start_even_row_pos, $end_even_row_pos - $start_even_row_pos); $content = substr_replace($content, "{ROW_CONTENT}", $start_odd_row_pos, $end_even_row_pos - $start_odd_row_pos); return $content;} The part of HTML, i only show the table part the 4 tag has to be in new line each <!-- BEGIN_ODD_ROW --><!-- END_ODD_ROW --><!-- BEGIN_EVEN_ROW --><!-- END_EVEN_ROW --> <table><!-- BEGIN_ODD_ROW --> <tr> <td>{COUNTER}</td> <td>This is odd row</td> <td>{DATA}</td> </tr><!-- END_ODD_ROW --><!-- BEGIN_EVEN_ROW --> <tr> <td>{COUNTER}</td> <td>This is even row</td> <td>{DATA}</td> </tr><!-- END_EVEN_ROW --> This is the part in the page. $temp_main = "./templates/index.html";$temp_table = "./templates/table.html";//Use diff function here. and you need to declare the odd and even row first$row_content_odd = "";$row_content_even = "";$row_content = "";$table= template2_open($temp_table, $row_content_odd, $row_content_even);$page = template_open($temp_main);if ($page){ if ($table) { $page = str_replace("{CONTENT}", $content, $page); $row_counter = 0; for ($row_counter = 0; $counter < 10; $counter++) { if ($row_counter % 2 == 0) { $row_content_temp = $row_content_odd; } else { $row_content_temp = $row_content_even; } $row_content_temp = str_replace("{COUNTER}", $counter, $row_content_temp); $row_content_temp = str_replace("{DATA}", "Some data", $row_content_temp); $row_content .= $row_content_temp; $row_counter++; } //"{ROW_CONTENT}" this one you can't change, as it is inserted by template2_open $menu = str_replace("{ROW_CONTENT}", $row_content, $menu); $page = str_replace("{MENU}", $table, $page); output_page(); }} That's it, if you happen to improve this, and if you don't can, please share with me or us, the fellow forumer Good luck.
-
From the "english" point of view, that makes 2 of us, i'm not english, either is my mother language. I'm chineseIn that case, i don't think it's possible. Well i might be wrong. So if you use "ob_start() / ob_end_flush()", you'll have to manipulate the output buffer, which i believe would not worth the trouble. As a general programming guideline, if you program need to do some tweak or something ppl seldom do, you show rethink your design, as there should be a better proven method. (there's an original cooler way of saying this, but i forgot how was it )In that case, i'll recommend you to try the template method, Won't take too long to convert, well unless you have thousand of files, and in that case you should have been using template in the first place. If you want to try my so call engine, let me know, i can post it here.
-
Maybe you can move the whole section from line 56 onwards to before "title", or in other words, delay the output of title after line 64. Whatever that's between line 5 to 56, if it's output of html, can be easily move to after line 56. Another way to prevent such problem next time is to use template engine, or something similiar. I've copied some tactic from some common php template engine and wrote my own one, though less powerful, and not optimize. I split the php and the html. Say if this page is mypage.html, i took out the php code, put inside mypage.php. Replace anything i need to output in the html with {VAR_NAME}, towards the end of the php file, i just read the html into memory, then use str_replace to put in the variable. Then your problem will not appear at all. E.g. HTML :<title>{TITLE}</title>PHP:str_replace("{TITLE}", $var1, $page); After that just print out the html in memory. Another advantage of this method is you don't have to repeatedly add section on the page that appear on every other page. Say you need to print the username at the top of the page. What i did was place the last print out function into another php file, change it into a function, then add str_replace("{USERNAME}, $username, $page);ORstr_replace("{USERNAME}, $_SESSION['username'], $page); before the print out function, that's all, then on those page that i need to display the username, just put in {USERNAME}. Provided you've set the $username or session properly If you suddenly see {SOMETHING}, then you know you've miss something. Or you can place {ANYTHING} at those places you want to put something there, but will only do later, that way you won't forgot to do it. Another benefit of this method is that you can pass the html to a designer to touch up your page, while they don't have to worry that thet'll break you php codes. At the same time, you can still update your php code without waiting for them.