mister X Posted August 4, 2009 Share Posted August 4, 2009 Hi. Im wondering is there any way to make the following code run faster. if($control == "enable" || $control == "disable") { fputs ($fp, "config t\n"); if($protocolType == "RIP") { if($control == "enable" && $networkAdd != "") { fputs ($fp, "router ".$protocolType."\n"); fputs ($fp, "network ".$networkAdd."\n"); $moredetails .= fgets ($fp, 4096); $moredetails .= fgets ($fp, 4096); } elseif($control == "disable" && $networkAdd == "") { fputs ($fp, "no router ".$protocolType."\n"); $moredetails .= fgets ($fp, 4096); } } //set IGRP || EIGRP || BGP if($protocolType == "ISO - IGRP" || $protocolType == "EIGRP" || $protocolType == "BGP") { if($control == "enable" && $networkAdd != "" && $autoSystem != "") { fputs ($fp, "router ".$protocolType." ".$autoSystem."\n"); fputs ($fp, "network ".$networkAdd."\n"); $moredetails .= fgets ($fp, 4096); $moredetails .= fgets ($fp, 4096); } elseif($control == "disable" && $autoSystem != "") { fputs ($fp, "no router ".$protocolType." ".$autoSystem."\n"); $moredetails .= fgets ($fp, 4096); } } //set OSPF if($protocolType == "OSPF") { if($control == "enable" && $processID != "" && $networkAdd != "" && $wlidcardMask != "" && $areaNo != "") { fputs ($fp, "router ".$protocolType." ".$processID."\n"); fputs ($fp, "network ".$networkAdd." ".$wlidcardMask." area"." ".$areaNo."\n"); $moredetails .= fgets ($fp, 4096); $moredetails .= fgets ($fp, 4096); } elseif($control == "disable" && $processID != "") { fputs ($fp, "no router ".$protocolType." ".$processID."\n"); $moredetails .= fgets ($fp, 4096); } } //exit from config. mode fputs ($fp,"exit\n"); fputs ($fp, "\r"); if(stristr($zxc,$routername[0].'(config)#')) { fputs ($fp,"exit\n"); fputs ($fp, "\r"); } } Link to comment https://forums.phpfreaks.com/topic/168767-how-to-make-this-code-run-faster/ Share on other sites More sharing options...
dreamwest Posted August 4, 2009 Share Posted August 4, 2009 Write to database instead of file. Ive tried experiments on speed with ifelse and functions - ifelse wins so you cant do much there. If your using this to display content use flush(); to output the outlay as fast as possible Link to comment https://forums.phpfreaks.com/topic/168767-how-to-make-this-code-run-faster/#findComment-890416 Share on other sites More sharing options...
RichardRotterdam Posted August 4, 2009 Share Posted August 4, 2009 What does this script exactly do? Somehow I get the impression that this is a low level process. Link to comment https://forums.phpfreaks.com/topic/168767-how-to-make-this-code-run-faster/#findComment-890420 Share on other sites More sharing options...
ignace Posted August 4, 2009 Share Posted August 4, 2009 What does this script exactly do? Somehow I get the impression that this is a low level process. It's pretty obvious. It lists all routers with their name, protocol, network and alot of other stuff. Link to comment https://forums.phpfreaks.com/topic/168767-how-to-make-this-code-run-faster/#findComment-890445 Share on other sites More sharing options...
mister X Posted August 5, 2009 Author Share Posted August 5, 2009 Hmm.. the program is suppose to allow user to configure router and switch thru the web.. Link to comment https://forums.phpfreaks.com/topic/168767-how-to-make-this-code-run-faster/#findComment-891002 Share on other sites More sharing options...
mister X Posted August 5, 2009 Author Share Posted August 5, 2009 one more thing is that, when running the program is always hang halfway through. the loading bar wont complete the loading. How can i solve this issue? If needed, i can upload my whole entire coding up.. Link to comment https://forums.phpfreaks.com/topic/168767-how-to-make-this-code-run-faster/#findComment-891042 Share on other sites More sharing options...
ignace Posted August 5, 2009 Share Posted August 5, 2009 Hmm.. the program is suppose to allow user to configure router and switch thru the web.. Then my guess wasn't far off as it lists the router/switch and it's options. Link to comment https://forums.phpfreaks.com/topic/168767-how-to-make-this-code-run-faster/#findComment-891130 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.