The Little Guy Posted January 19, 2012 Share Posted January 19, 2012 Auth: http://tests.phpsnips.com/phpfreaks.txt For the past year or so, I have been working on a library to help people program. It is a fairly easy to use library (In My Opinion), my site has documentation on a fair amount of the library, but the documentation is still not complete. So, I have 2 questions to ask of you: 1. What do you think of the documentation that is there, was it helpful? 2. What do you think of the library its self? What could be improved and what did/din't you like? Some powerful/Useful features in my opinion are: - Easily send mail with 1+ attachments $to = array("Billy Bob", "billybob@example.com"); $from = array("Jimmy", "jimmy@example.com"); $subject = "Hello Billy Bob!"; $message = "Just cheking up on you!"; $files = array("/files/file1.png", "/files/file2.jpg"); $live->mail($to, $from, $subject, $message, MAIL_ATTACHMENT, $files); - Easily zip up some files and download them on the fly $files = array( "/path/to/file1.php" => "file1.php", "/path/to/text/license.txt" => "docs/license.txt", "extensions/" ); $live->zip($files)->download(PHP_TMPFILE, "myFiles.zip"); exit; - Grab all the links from a webpage: print_r($live->getHttp("http://somesite.com")->getLinks()->list); - Some methods have a callback function, such as each(), where the following code can convert a handful links into full URLS (following method format requires php 5.3.x or higher. You could place the function in another function and call the function for php 5.2.x and lower) print_r($live->getHttp("http://phplive.org")->getLinks()->each(function($link){ global $live; $url_info = (object)parse_url($live->endingUrl); $domain = $url_info->scheme."://".$url_info->host; if(preg_match("/^\//", $link)){ return $domain.$link; }elseif(!preg_match("/^http/", $link)){ return $live->endingUrl."/".$link; } return $link; })); There are many other things, such as database methods, threading, mobile device check, operating system check, etc. Here are the related links: Docs: http://tests.phpsnips.com/docs Download: http://tests.phpsnips.com/download.php Thank you for your help! Link to comment https://forums.phpfreaks.com/topic/255382-library/ Share on other sites More sharing options...
trq Posted January 20, 2012 Share Posted January 20, 2012 The use of global in your callback example could (and should) be avoided. print_r($live->getHttp("http://phplive.org")->getLinks()->each(function($link) use ($live) { $url_info = (object)parse_url($live->endingUrl); $domain = $url_info->scheme."://".$url_info->host; if(preg_match("/^\//", $link)){ return $domain.$link; }elseif(!preg_match("/^http/", $link)){ return $live->endingUrl."/".$link; } return $link; })); Link to comment https://forums.phpfreaks.com/topic/255382-library/#findComment-1309449 Share on other sites More sharing options...
The Little Guy Posted January 20, 2012 Author Share Posted January 20, 2012 Okay, I was wondering how I could avoid using that. I will fix that! Thanks! Link to comment https://forums.phpfreaks.com/topic/255382-library/#findComment-1309462 Share on other sites More sharing options...
The Little Guy Posted February 4, 2012 Author Share Posted February 4, 2012 I just added a new feature, that some may like some would be like what ever, but it kind of makes one of the php constructs easier: $value = mt_rand(0, 600); // normal php: if($value == 1 || $value == 10 || $value == 22 || $value == 25 || $value == 567 || $value == 124) // phpLive: if($live->in($value, 1, 10, 22, 25, 567, 124)) Link to comment https://forums.phpfreaks.com/topic/255382-library/#findComment-1314592 Share on other sites More sharing options...
The Little Guy Posted February 13, 2012 Author Share Posted February 13, 2012 I just added a Part 1 tutorial on how to build an extension with my library. Part 2 should hopefully be coming soon! Tutorial: http://phplive.org/tuts/Extensions/BuildAnExtension.php If anyone would like to make their own extension and give me some feed back that would be very helpful! Thanks for any replies! Link to comment https://forums.phpfreaks.com/topic/255382-library/#findComment-1317926 Share on other sites More sharing options...
Christian F. Posted August 14, 2012 Share Posted August 14, 2012 Just wanted to let you know that I'm still looking at your class, in amongst the other stuff I got on my plate. It's a big class, and not a whole lot of comments, so it's slow progress I'm afraid. Anyway, I have noticed some conundrums in your code. For instance at line 252 & 253: if ($string != null) $string = $string; Missing something here, or..? The getCleanData () method also features some unnecessary escaping, plus some missing escaping. Last bit in the RegExp that's meant to remove HTML comments, as you've only escaped one of the dashes. I'm not quite sure the eval () call on line 1061 is necessary either, and I suspect you can do a lot better without it. There's a typo at line 1091, where you've used $im instead of $img. On line 1387 you have used an undefined function: mysql_fetch_fields (). It's strictly a MySQLi function, an the comparable function would be mysql_fetch_object (). Line 1529 has a minor issue, where you've passed a variable by reference without first declaring it. On line 2008, on the other hand, we find this: $this->list = $_GETS; Typo? On lines 2285, 2297, 2312, 2327, 2342, 2357 and 2372 we find another undefined variable, namely $var. Did you meant to use $date instead? On lines 2528-2530 you're sending multiple content-type headers. This has no effect, as the latter one will replace the previous. This means that the only content type that's being sent to the browser, is the last one. As evidenced by this example, where I used these three lines: HTTP/1.1 200 OK Date: Tue, 14 Aug 2012 16:36:58 GMT Server: Apache/2.2.22 (Ubuntu) X-Powered-By: PHP/5.3.14 ZendServer/5.0 Set-Cookie: ZDEDebuggerPresent=php,phtml,php3; path=/ Content-Length: 0 Keep-Alive: timeout=5, max=100 Connection: Keep-Alive Content-Type: application/download; That's the primary look at your code, but I'll go more in depth as soon as I get the time for it. As for the manual, it's quite well written. Though, I'm missing the "why's" behind what you do what you do. Explain a bit more around the reasoning behind the choices, and what happens in the background, and I people will find it a lot easier to really learn from it. Link to comment https://forums.phpfreaks.com/topic/255382-library/#findComment-1369397 Share on other sites More sharing options...
The Little Guy Posted August 15, 2012 Author Share Posted August 15, 2012 I went through the file again, I changed $var to $date, removed any unused variables. Thanks for the feedback, I well be going through the file and looking into your suggestions to help optimize the code. I did move the code to GitHub if anyone would like to fork the code: https://github.com/TheColorRed/phpLive Link to comment https://forums.phpfreaks.com/topic/255382-library/#findComment-1369634 Share on other sites More sharing options...
QuickOldCar Posted August 18, 2012 Share Posted August 18, 2012 You have some dead url's in this area. http://phplive.org/docs/ Link to comment https://forums.phpfreaks.com/topic/255382-library/#findComment-1370412 Share on other sites More sharing options...
Recommended Posts