Adamski Posted May 23, 2007 Author Share Posted May 23, 2007 yeh that's gonna be the fun bit I suppose I will have to parse out the the line rates (don't know how yet) and then run a query of some kind to pull the right pages for my products... there will be a way - it's just finding it. I'll let you know how it goes! 0 Quote Link to comment Share on other sites More sharing options...
trine Posted May 23, 2007 Share Posted May 23, 2007 That should be easy enough to do with a simple preg_match ... for instance: if (preg_match("/exchange is ADSL enabled/",$result)){ then show product signup button } else { contact us link } 0 Quote Link to comment Share on other sites More sharing options...
trine Posted May 23, 2007 Share Posted May 23, 2007 you can also do that for all the speeds and stuff... 0 Quote Link to comment Share on other sites More sharing options...
Adamski Posted May 23, 2007 Author Share Posted May 23, 2007 he he you say easy .. I say eek! Would that preg match be in the script you did? the broadband checker page or the adsl-availability script? But you are right... I will get onto it! trine you've been a life saver today! 0 Quote Link to comment Share on other sites More sharing options...
trine Posted May 23, 2007 Share Posted May 23, 2007 yes, easy as E Z ! If you need I can write it for you too. just PM the match matches that the location (zip or phone) is broadband enabled, and is serviceable. 0 Quote Link to comment Share on other sites More sharing options...
othellotech Posted May 23, 2007 Share Posted May 23, 2007 i'm thinking more on the lines of parsing the xml result from the actual checker called by curl and "limiting" the users choices of options based on that - no point allowing a signup for 8mb if they an only get 2mb - so *probably* instead of fidling with whmcs and the sh!teytemplate system, having our checker allow a selection from valid products only, and a xref table to get the WHMCS links for each product ... 0 Quote Link to comment Share on other sites More sharing options...
Adamski Posted May 23, 2007 Author Share Posted May 23, 2007 mmm interesting... 0 Quote Link to comment Share on other sites More sharing options...
trine Posted May 23, 2007 Share Posted May 23, 2007 Rob, absolutely! that can be done, you just need to define all the speed scenarios which are returned in the xml results. As before, you just match them, or store them in a variable and use case to show exactly which products can be signed up for by a user. 0 Quote Link to comment Share on other sites More sharing options...
Adamski Posted May 31, 2007 Author Share Posted May 31, 2007 Well I started to get too frustrated with making sure I had every variable covered so I'm just going for a quick yes/no solution but I'm stuck. $s_response .= fgets($fsock, 128); $pos = strpos($s_response, "Your Exchange is ADSL enabled"); if ($pos = true) { echo "<p class='text'>", "[img][/img]", " ","Your Exchange is ADSL enabled and you can receive onestopdigital broadband". " ","[url='broadband.php']Visit out Broadband Pages[/url] for more information.","</p>"; break; } else { echo "No Such Luck"; break; } } However the else section doesn't kick in. I think i'm not using the if ($pos = true) properly but I'm a bit stuck now as to how to get it working. I think the code shows what I want to happen. Thanks for any pointers, Adam 0 Quote Link to comment Share on other sites More sharing options...
Adamski Posted June 1, 2007 Author Share Posted June 1, 2007 This was solved by taking the if else statement outside of the while statement Adam 0 Quote Link to comment Share on other sites More sharing options...
trine Posted June 1, 2007 Share Posted June 1, 2007 Adam, are you trying to re-query the result to do that? you could use the result returned with the code I wrote instead. no need to query twice. 0 Quote Link to comment Share on other sites More sharing options...
Adamski Posted June 1, 2007 Author Share Posted June 1, 2007 No only what is echo'd is ouput. It does it's stuff before then. 0 Quote Link to comment Share on other sites More sharing options...
trine Posted June 1, 2007 Share Posted June 1, 2007 ok, but aren't you trying to match the same output? looks like it to me. >> $pos = strpos($s_response, "Your Exchange is ADSL enabled"); and before that you connect again: >> $s_response .= fgets($fsock, 128); instead, you could just do: $pos = strpos($result, "Your Exchange is ADSL enabled"); if ($pos = true){ do stuff } else { do something else } That will avoid connecting again and make it slightly faster! 0 Quote Link to comment Share on other sites More sharing options...
Adamski Posted June 1, 2007 Author Share Posted June 1, 2007 You couldn't as you can't have if ($pos = true) when using strpos it needs to be ===false or an integer match ? I need to have $s_response .= fgets($fsock, 128); otherwise nowhere do I set what the s_response string is. If I take that out strpos is checking against nothing? Is what I thought anwyay Adam 0 Quote Link to comment Share on other sites More sharing options...
trine Posted June 1, 2007 Share Posted June 1, 2007 Adam, the string you are testing is the exact same string as returned by the script I wrote...is it not? If it is, then just use $result, in lieu of $s_response. 0 Quote Link to comment Share on other sites More sharing options...
Adamski Posted June 1, 2007 Author Share Posted June 1, 2007 Yes but your script only deals with the information posted to the page and not the ajax. This way the result is parsed before being returned by either script. Also $result must take its information from $s_response as it returns my custom messages as it is rather than a default response. I don't admit to understanding everything but I know it works 0 Quote Link to comment Share on other sites More sharing options...
trine Posted June 1, 2007 Share Posted June 1, 2007 okay, now I see what you are doing, but that way you are actually connecting twice. 0 Quote Link to comment Share on other sites More sharing options...
Adamski Posted June 1, 2007 Author Share Posted June 1, 2007 I am? How? And there was me happy I had it cracked 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.