Jump to content

btray77

Members
  • Posts

    23
  • Joined

  • Last visited

    Never

Everything posted by btray77

  1. Thanks, I completely forgot about that function.. and didn't see it when I was looking on php.net in the date/time functions information. -Brad
  2. how to convert 2009-10-29T06:54:56.000Z to unix time stamp.. thanks
  3. Thanks, what about keeping it as a stdObj? -Brad
  4. I have a datafeed I'm getting data from, and I need to be able to loop though the datafeed and store information in a stdClass object or Array. I've tried: $x = json_decode( $x ); foreach ( $x as $item ) { $info[] = $item; //ERROR } How do I do this? Thanks
  5. found the problem: http://www.website.com/request/findItems= should be http://www.website.com/request?findItems= Thanks if you were working on helping me on this. -Brad
  6. Ruby Code: { "itemFilter" => { "keywords" => "milk" }} my_input = { "itemFilter" => { "keywords" => "milk" }}.to_json # Turn hash input into JSON, store it in variable called "my_input" @http = Net::HTTP.new("website.com") # Open connection to website.com response_code, data = @http.post("/requests", "findItems=#{my_input}") # Post the request to our API, with the "findItems" name and our JSON from above as the value response_code, data = @http.post("/requests", "findItems=#{input}", {'X-CUSTOM-HEADER' => 'MYCUSTOMCODE'}) my_hash = Crack::JSON.parse(data) my_milk = my_hash["findItems"]["item"].first Here's what I have so far, which might be totally wrong.. Any help would be appreciated. <?PHP $requestBody =json_encode(array("itemFilter" => array( "keywords" => "milk" ))); $headers = array ( //set the keys 'X-CUSTOM-HEADER: ' .'MYCUSTOMCODE', ); //initialise a CURL session $connection = curl_init(); //set the server we are using (could be Sandbox or Production server) curl_setopt($connection, CURLOPT_URL, 'http://www.website.com/request/findItems='); //stop CURL from verifying the peer's certificate curl_setopt($connection, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($connection, CURLOPT_SSL_VERIFYHOST, 0); //set the headers using the array of headers curl_setopt($connection, CURLOPT_HTTPHEADER, $headers); //set method as POST curl_setopt($connection, CURLOPT_POST, 1); //set the XML body of the request curl_setopt($connection, CURLOPT_POSTFIELDS, $requestBody); //set it to return the transfer as a string from curl_exec curl_setopt($connection, CURLOPT_RETURNTRANSFER, 1); //Send the Request $response = curl_exec($connection); //close the connection curl_close($connection); print_r($response); Thanks -Brad
  7. No as I had said, It times out... I'm guessing I need something that uses Ajax to re-request the script do something... -Brad
  8. I need to do something other than use set_time_limit(); I still get timeouts on huge database imports. (Command line is not available, and the data feed is not a standard format, so there is no real way of doing mysql's CSV or XML import command) I am importing about 100,000 products, and images from a datafeed. I have NO problems if I don't have to download the images, but the time that it takes to download the images causes the system to timeout. (and it's not from a browser timeout issue, I've got it sending data to the screen each time it does an action) I was thinking about possibly using ajax to call the script to run 1 query at a time, but I'm not sure how to do this. 1. Anyone know of a tutorial on something like this? (I have jquery loaded) 2. If this is not a "good" way, can you give me an idea of how you would do this? Thank you -Brad
  9. I need some help on how to make a class that will parse out FTP MLSD command data (Look at $dirlist for what this data looks like). Below is an example of what I've got so far. I need to be able to easily page though the list and tell if it's a cdir, pdir, size, modified date, and file name. If someone could help me on this I would be grateful. The bad code I have so far: <?php $dirlist = array(); $dirlist[]='size=0;type=cdir;create=20070706174144;modify=20090928144627; .'; $dirlist[]='size=0;type=pdir;create=20070705203844;modify=20091008050005; ..'; $dirlist[]='size=252;type=file;create=20070706174144;modify=20090928144627; 10059-janitorial.zip'; $dirlist[]='size=1946215;type=file;create=20070706174152;modify=20090928144627; 10059-office.zip'; $dirlist[]='size=59658117;type=file;create=20070706174252;modify=20090928144622; 10059.txt'; $dirlist[]='size=6285651;type=file;create=20070706175413;modify=20090928144622; 10059.txt.gz'; $dirlist[]='size=6285853;type=file;create=20070706175529;modify=20090928144624; 10059.zip'; //print_r($dirlist); for($i = 0; $i < sizeof($dirlist); ++$i) { $temp = array(); $temp = explode(';',$dirlist[$i]); for($x = 0; $x < sizeof($temp); ++$x) { $td[$i][$x]=explode('=',$temp[$x]); } //$dirarray[$i] } echo "<PRE>"; //print_r($dirarray); print_r($td); echo "</PRE>"; ?> Thanks
  10. @ ingace Thanks for the information. To do the insert i'm using what I learned from this tutorial.. http://www.softwareprojects.com/resources/programming/t-how-to-use-mysql-fast-load-data-for-updates-1753.html Data insertion is very fast, with this. I just need a way to get the file "fast" programicaly in php or possibly perl VS having to wait a predetermined amount of time with a cron. The updates are not always at the same time. Thanks -Brad
  11. Hi, what would you suggest for downloading a HUGE file from another server? I need to download a large CSV file, about 1.6 GB and insert it into the database. right now I'm FTPing the file over, and using MySQL's LOAD DATA INFILE but I need to automate the downloading of the file. Thanks -Brad
  12. @Zyx That sounds like a great idea except I'm not so good with classes, i'm trying to get away from procedural programming and do the oop but I've yet to figure out everything I need to do. Do you think you could spare the time to put something together on this? I'd appreciate it. -Thanks Brad
  13. @shamuraq I need to be able to populate a database (which I can do) but I need to be able to find out the parent categories from the text file that I'm given. So like before: Cars Cars::4 Door Cars::4 Door::economy Trucks Trucks::4x4 Trucks::4x4::Leather so I need to be able to parse out Cars as a parent, then 4 Door as a child of Cars, and Economy as a child of 4 Door. so the database table would look something like this: catid:int autoinc parent:int default null Name:varchar(100) catid, parent, name 1, null, Cars 2, 1, 4 Door 3, 2, economy 4, null, Truck 5, 4, 4x4 6, 5, Leather I'm having a problem with the logic of exploding the categories out into there parent categories. I think once I sleep on it I will figure it out, but I need to get it done asap. I know it's relatively easy. -Brad
  14. I'm guessing the ads are there because it's the "trial" version. You should purchase it if you do not want the ads. Reverse engineering the code you gave is technically illegal to do in most parts of the world. -Brad
  15. http://www.phpwebcommerce.com/ <-- this is the one I've looked at and followed in the past.. but I've not worked with shopping carts in a while. -Brad
  16. I have gone brain dead.. in the last day.. I've got a list of categories, that I need to figure out the hierarchy for. They are in this format: one one::sub one::sub::subsub two two::sub two::sub::subsub etc.... It's multiple levels deep. I need to be able to figure out what is the parent, child of each level so i can add it to the database. Any ideas on this? I'm guessing using Explode, but I'm lost on how to do this. Thanks -Brad
  17. Thank you for the quick reply! And I believe that will work for me! Now to figure out hot to mark as solved.. Thanks again -Brad
  18. I'm trying to parse out the most common 4 word, 3 word, and 2 word phrases from documents. I've got gigs of documents that I need to recursively parse through (aka, even though the data is from different sources it need to be treated as from a single source.) I've been able to parse out the most common single words, but don't know how to efficiently parse out the most common multiple word combinations. Any help would be appreciated. I was thinking about putting all the documents in to a database file (stripping all unnecessary punctuation, markup, etc). And taking the 1st 4 words and searching for exact results though the database, come up with a number, then take the 2nd 3rd 4th and 5th words and searching again and repeating this through the database.... but this does not seem like the best way to do this. class WordCounter { const ASC=1; const DESC=2; private $words; function __construct($filename) { $file_content = file_get_contents($filename); $this->words = (array_count_values(str_word_count(strtolower ($file_content),1))); } public function count($order) { if ($order==self::ASC) asort($this->words); else if($order==self::DESC) arsort($this->words); foreach ($this->words as $key=>$val) echo $key ." = ". $val."<br/>"; } } Thanks -Brad
  19. Thank you for the help. it works with the demo text, but does not seem to work with the server's live text, even though it's exactly the same. I don't quite understand it. B
  20. I really need to go buy that regex book, but I just don't have the time to read it lately. I'm trying to get the data between these two tags: Tag A: <table style="border-collapse: collapse;" id="table9" bordercolorlight="#FFFFFF" border="1" width="100%"> Tag B: </table> What I want is going to be in "RED". Data Sample: <b>ITEM DESCRIPTION</b></p></td> </tr> </tbody></table> </div> <div align="center"> </div> </div> <div align="left"> <table style="border-collapse: collapse;" id="table9" bordercolorlight="#FFFFFF" border="1" width="100%"> <tbody><tr> <td bgcolor="#ffffff" width="107"> <p></p></td> </tr> <tr> <td bgcolor="#941410" width="107"> <p align="right"><font color="#ffffff"><b>Gender </b></font></p></td> <td bgcolor="#ffc3bd"> MEN</td> </tr> <tr> <td bgcolor="#941410" width="107"> <p align="right"><font color="#ffffff"><b>Name </b></font></p></td> <td bgcolor="#ffc3bd"> VERSACE EAU FRAICHE by VERSACE MAN</td> </tr> <tr> <td bgcolor="#941410" width="107"> <p align="right"><font color="#ffffff"><b>Size </b></font></p></td> <td bgcolor="#ffc3bd"> 3.4 oz EDT SPRAY</td> </tr> <tr> <td bgcolor="#941410" width="107" height="24"> <p align="right"><font color="#ffffff"><b>Packaging </b></font></p></td> <td bgcolor="#ffc3bd" height="24"> BOX</td> </tr> <tr> <td bgcolor="#941410" width="107"> <p align="right"><font color="#ffffff"><b>Condition </b></font></p></td> <td bgcolor="#ffc3bd"> BRAND NEW in BOX ! </td> </tr> </tbody></table> </div> </td> </tr> <tr> <td> <p align="center"> <font style="font-size: 10pt; font-weight: 700;" color="#cc0000" face="Verdana"> Any help will be appreciated.. B
  21. some servers do not allow you to use fsockopen... Like dreamhost...
  22. I have the original code of: if (@fsockopen($_SERVER['SERVER_NAME'], $c[1], $errno, $errstr, $portcheck)) I'm wanting to convert that to use CURL. I've tried the following with no luck. What am I doing wrong? $cx = curl_init($_SERVER['SERVER_NAME']); curl_setopt($cx, CURLOPT_RETURNTRANSFER, 1); curl_setopt($cx,curlOPT_port,$c[1]); curl_setopt($cx, CURLOPT_FAILONERROR,true); curl_setopt($cx, CURLOPT_TIMEOUT, $portcheck); $temp = curl_exec($cx); if (!curl_errno($cx)) There are some ports that should give an error and some that should not. The code it to tell me if the port is giving error or not. (aka is DNS/POP3/SMTP/ETC server up/down) Also second part question. What would I have to do to test to see if I could use fsockopen or if I need to use curl. Thank you -Brad Nissan 350z
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.