Jump to content

bcamp1973

Members
  • Posts

    133
  • Joined

  • Last visited

Everything posted by bcamp1973

  1. Got it working! I guess it just took a good night's sleep and fresh eyes I just put the following in a file called getStream.php... set_time_limit(0); $fp = fsockopen("{$_GET['camera']}", 80, $errno, $errstr, 30); if(!$fp) { echo "/public/images/error.jpg"; } else { fputs($fp, "GET //nphMotionJpeg?Resolution=320x240&Quality=Standard HTTP/1.0\r\n\r\n"); while($str = trim(fgets($fp, 4096))) header($str); fpassthru($fp); fclose($fp); } and it's used like so... <img src="getStream.php?camera=office"/> and in my webserver's hosts file I set "office" to match with my cameras internal network IP address...I'm sure i'll bollocks something else up and be back with more questions
  2. I tried your solution and it just hangs on me. I don't think it likes the $content = file_get_contents($imageURL); line. Maybe the MJPEG screws it up? I did some more googling and came across the following link.... http://www.lavrsen.dk/twiki/bin/view/Motion/MjpegFrameGrabPHP As far as i can tell this is exactly what i'm trying to do (first example) but even their example isn't working for me. I know this has to be possible...unfortunately my knowledge of HTTP headers is nil!
  3. I'm using a few of the Panasonic "Pet cams". You can read more about them here... http://bit.ly/11VPeO ...just for a little background, this is a silly pet project of mine. I like the cameras and their features, but i HATE their web interface. I'm trying to bring the cameras together into a more integrated interface that works better on my wife and my phones. It's partly because I want them easier to use, and partly because I'm just having fun tinkering around. In the end none of this is truly "necessary" The cameras provide either motion JPEG images or MPEG-4. Regardless of what it's set to it's marked up in the cameras web server HTML like so... <input type="image" src="nphMotionJpeg?Resolution=320x240&Quality=Standard"> So, again, I need to get access to that stream from within my network. If it was a static image it probably wouldn't be a big issue, but not sure since it's a "stream"? ...oh, and the "b" in "rb" is supposedly to represent "binary"...or so my googling tells me, but you're right, i didn't see mention of it in the PHP manual either
  4. Ok, using @mjdamato's approach, i'm to the point where i can control the camera...hooray! ...now, i want to grab the motion JPEG that the camera returns using a similar method. Here's what i've stared with...which isn't working of course Hopefully this is possible?? header("Content-Type: image/jpeg\n"); fopen("http://192.168.1.112/nphMotionJpeg?Resolution=320x240&Quality=Standard","rb");
  5. @mjdamato, you are correct in your assumption...and thank you for doing a better job of describing it than I did I think your solution makes sense and will do what I'm looking for...I'll keep you posted
  6. @mjdamato, maybe you can dumb this down for me a little further? My impression is that if I'm at work hitting a website on home server (http://mydomain.com), any GET requests made from the website will have to be accessible from wherever I'm accessing the site. If my form's ACTION hits an internal IP (192.168.1.xxx) won't that submission error out outside the network?
  7. Thanks @roopurt18, however I'm getting "Class 'HttpRequest' not found in..." I take it this isn't something that's part of default PHP installs? I'm running PHP 5.3.0 on OS X...
  8. That was my initial thought, however, i'd like to just open up my web server and handle the requests within my network. Otherwise I have to open up the camera to the outside world as well. After i have this figured out i have 3 separate cameras that i'll be attempting to control and each of them would have to bet set up on their own port and accessible to anyone looking to mess with them
  9. I'm trying to control a few functions of my home IP camera via PHP. Commands for the camera are in the form of http://cameraIPaddress/cameraCGI?direction=panLeft ...I don't have to worry about capturing any kind of response etc. I simply want to send the command. I'd also like to authenticate the request, but no idea how to handle that from within the PHP? I've tried fsockopen(), but maybe i'm not doing it right...i worked from this example...it seems like it's overly complex for what i'm trying to do? $fp = fsockopen("www.example.com", 80, $errno, $errstr, 30); if (!$fp) { echo "$errstr ($errno)<br />\n"; } else { $out = "GET / HTTP/1.1\r\n"; $out .= "Host: www.example.com\r\n"; $out .= "Connection: Close\r\n\r\n"; fwrite($fp, $out); while (!feof($fp)) { echo fgets($fp, 128); } fclose($fp); }
  10. wow, ok...i guess i thought i was breaking a whole bunch of rules with my approach. glad I'm not and, i would expect there will rarely be more than 30 to 40 items in a list that's being sorted except in very extreme cases...so, performance was probably never really an issue. just wanted to make sure I'm doing things "right" whenever i can or I'll never learn anything
  11. I have a grid view that allows the user to change the sort order of items (see attached screen shot). I have it working. However, my SQL skills are minimal at best and i fear I've made it far more complicated than it needs to be. Every time a user clicks on an arrow to change an items order I do ALL of the following (FYI $wpdb is a database class for wordpress). $currentorder is obviously the items current "item_order" and $neworder is either $currentorder+1 or $currentorder-1 depending on the direction it's being moved. $wpdb->query("UPDATE table_name SET item_order=9999 WHERE item_order=$currentorder); $wpdb->query("UPDATE table_nameSET item_order=$currentorder WHERE item_order=$neworder); $wpdb->query("UPDATE table_name SET item_order=$neworder WHERE item_order=9999); Of course, if any item is removed from the list, this potentially causes issues...so I then run this so the items are numbered 1-n... $items = $wpdb->get_col("SELECT id FROM table_name ORDER BY item_order ASC"); for($i=0; $i<count($items); $i++){ $wpdb->query("UPDATE table_name SET item_order=".($i+1)." WHERE id=".$items[$i]['id']); } I actually feel unclean after writing this...but I'm not sure how to do this "properly". Any suggestions?
  12. awesome! that works for one instance of %MATCH-XX%. how do i deal with multiple instances?
  13. i want to parse the page content looking for one or more instances of the string %MATCH-XX% where XX is an integer. I then want to replace that string with the code generated from a function that uses the XX integer as it's only argument. So, for example... i start with $content = '<p>This paragraph has a %MATCH-23% in it</p>'; and then my function function parse_match($XX,$content){ // work some magic with $content & $XX return '<span>with a number'.$XX.'</span>'; } produces this <p>This paragraph has a <span>with a number 23</span> in it</p> I need to be able to do this in PHP 4.1 as well...i'm at a loss at this point
  14. I have a new client with a small brick and mortar operation. They want to make the move online and upgrade their POS and inventory system and tie it in with a website CMS. I'm one person. I can round up another developer or two if needed. However, i'd like to use out of the box or OSS solutions where i can to minimize effort so i can focus primarliy on the UI and integration of the solutions. Have any of you had experience with such a task? If so what was your solution? Most of the OSS packages i'm finding are horrible...even the commercial offerings look pretty rough. I want a professional looking solution that won't require a complete facelift so I'm not embarrassed to implement it. I'll design the website UI, but i'd like the POS and admin tools to look like a designer had a say in it's layout I appreciate your thoughts on the matter!
  15. I've come across the reason for it before, but my googling isn't working
  16. i've been banging my head against the wall for the past day and half trying to get a basic time conversion function working. Finally after giving up on finding the error in my own function i compared the output of gmmktime() from my ISP to that of a site online. The output is completely different! Yet gmdate() works fine for me. My ISP is running PHP 4.4.4. Any suggestions?
  17. I was all proud of myself for getting this far with this function and then realized it's not returning the right values. It's purpose is to return the current age of an item based on it's date of creation. Can someone point me in the right direction? function age($startDate,$endDate=NULL){ $text=''; $seconds=strtotime($endDate!='0000-00-00 00:00:00' ? $endDate : gmdate('Y-m-d H:i:s'))-strtotime($startDate); $periods=array('yr'=>31570560,'mon'=>2630880,'day'=>86400,'hr'=>3600,'min'=>60); foreach($periods AS $k=>$v){ if(($temp=$seconds/$v)>=1){ $text.=floor($temp).' '.$k.($temp>=2 ? 's': '').' '; $seconds=$seconds % $v; } } return $text; }
  18. I'm trying to create a function that returns the local date/time if you feed it a GMT date/time and the local offset. For example i live in MST so i think it's GMT-7. This is the function i've created, but it's returning weird values. didn't work for me last night, but mysteriously worked this morning. maybe something screwy with AM vs PM? I'm passing the date in the format "Y-m-d H:i:s". I'm not so good with date calculations obviously... function mydate($date,$offset,$dst){ $date=explode(' ',$date); list($year,$month,$day)=explode('-',$date[0]); list($hour,$minute,$second)=explode(':',$date[1]); if(($hour+$offset)>0){ $hour=$hour+$offset; } else { $hour=($hour+$offset)*-1; $day--; } if($dst) $hour=$hour+date('I'); $yourdate=strtotime($year.'-'.$month.'-'.str_pad($day,2,'0',STR_PAD_LEFT).' '.str_pad($hour,2,'0',STR_PAD_LEFT).':'.$minute.':'.$second); if($day==gmdate('j')){ return 'Today @ '.date('g:i A',$yourdate); } elseif($day==(gmdate('j')-1)){ return 'Yesterday @ '.date('g:i A',$yourdate); } else { return date('M jS, Y @ g:i A',$yourdate); } }
  19. [code]actually, found a shorter solution... function age($startDate,$endDate=NULL){ $text=''; $seconds=strtotime($endDate ? $endDate : gmdate('Y-m-d g:i:s'))-strtotime($startDate); $periods=array('year','month','week','day','hour','minute','second'); $lengths=array(31570560,2630880,604800,86400,3600,60,1); for($x=0; $x<count($periods); $x++){ if(($temp=$seconds/$lengths[$x])>=1){ $text.=floor($temp).' '.$periods[$x].($temp>=2 ? 's': '').' '; $seconds=$seconds % $lengths[$x]; } } return $text.'old'; }[/code]
  20. thanks for the help! i've used one of the functions from the link tippy_102 provided to created the following. however, it's not working. page doesn't even load My ISP is using 4.1.21-standard...not sure if that has anything to do with it? It's not liking the last if() statement where the function calls itself... Any suggestions? function age($startDate,$endDate=NULL){ $difference=strtotime($endDate ? $endDate : gmdate('Y-m-d g:i:s'))-strtotime($startDate); $periods=array('second','minute','hour','day','week','month','year'); $lengths=array(1,60,3600,86400,604800,2630880,31570560); for($val=sizeof($lengths)-1; $val>=0 && ($number=$difference/$lengths[$val])<=1; $val--); if($val<0) $val=0; $new_time=strtotime($endDate)-($difference % $lengths[$val]); $number=floor($number); if($number!=1) $periods[$val].='s'; $text=sprintf('%d %s ',$number,$periods[$val]); if(($val>=1) && ((strtotime($endDate)-$new_time)>0)){ $text.=age($new_time); } return $text; }
  21. that's a pretty strong claim. Ruby on rails has lots of great qualities but it's not perfect either. It's quite a bit more resource intensive than PHP from what I understand. Also it's syntax isn't "typical"...so, if you're new to programming it's supposed to be easier to pick up. However, people with a fair amount of experience will have to rethink things a little. You might spend some time on the official website (http://rubyonrails.org/) and also review some of the rather heated threads on http://slashdot.org regarding Ruby/Rails.
  22. If i have two timestamps, is there a built in function to give me the different between the two as days, hours and seconds?
  23. Thanks! Here's my solution...i just pass the date in the 12 hour format, pass the GMT offset (-7 in my case) and TRUE/FALSE for daylight savings... function mydate($date,$offset,$dst=TRUE){ $date=explode(' ',$date); list($year,$month,$day)=explode('-',$date[0]); list($hour,$minute,$second)=explode(':',$date[1]); if(($hour+$offset)>0){ $hour=$hour+$offset; } else { $hour=($hour+$offset)*-1; $day--; } if($dst) $hour=$hour+date('I'); return $year.'-'.$month.'-'.str_pad($day,2,'0',STR_PAD_LEFT).' '.str_pad($hour,2,'0',STR_PAD_LEFT).':'.$minute.':'.$second; } I'm sure it could be more elegant, but it seems to be working
×
×
  • 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.