Functions
WebDev/*nix assorted functions & hacks
Search
find all
Array
-
Bash
-
Classes
-
Config
-
DateTime
-
Debug
-
dotjs
-
File
-
foooo
-
Git
-
HTML
-
Images
-
Javascript
-
Linux
-
Math
-
Misc
-
MySQL
-
OS X
-
Reading
-
Redis
-
Shell scripts
-
snippets
-
SQL
-
Strings
-
TextMate
-
Web
-
\(^o^)/ Fun!
-
_Misc hacks
-
_Pages
Shell scripts
* Readme
dict
edit_json (php)
encrypt/decrypt
pdoc
pftp - ftp a file to some place
php fork & IPC
php input cli
phplint
~/bin/inc/lib.php
10
found
auth
Name:
Category: Shell scripts
Body:
#!/usr/bin/php <?php /** * pdoc fetches the first few lines of syntax for given functions from nl.php.net (in English) * Usage: pdoc {function} * Crude, but it works after a fashion, for most functions :-) * Copyright 2004 M.Spreij <mac.com@nemo> under the GPL: http://www.gnu.org/licenses/gpl.txt * * Updated: * 2005-08-31: added html_decode() at final print statement * **/ require_once 'inc/lib.php'; # http://dev.expocom.nl/functions.php?id=61 if ($argc == 1) { echo " pdoc fetches the first few lines of syntax for given functions from nl.php.net (in English)\n". " Usage: pdoc {function}\n"; return; } # Settings ini_set('display_errors', '1'); ini_set('track_errors', '1'); $function = $argv[1]; $url = 'http://nl.php.net/'; $header = "Accept-Language: en-gb, en"; $options = array('CURLOPT_HTTPHEADER' => array($header)); $res = fetch_url($url . $function, $options); if ($res[0] != 200) { if ($res == 302) { echo "Function not found"; }else{ echo "Error fetching syntax, ". $res[1]; } echo "\n"; return false; }else{ if (strtolower($argv[2])=='w') { echo "Opening $url$function.. \n"; shell_exec('open '. $url.$function); die(); } $data = $res[1]; } $start = 'Swedish'; # nice point to start cutting $data = substr($data, strpos($data, $start) + strlen($start), 1000); # cuts underneath the table with 'last updated' and stuff $data = substr($data, strpos(strtolower($data), '</table>') + 8); # replace linebreaks with spaces, fix tags, remove nonbreaking spaces $data = str_replace(array(' ', "\n", ' >'), array(' ', ' ', '>'), nl2unix($data)); # insert linebreaks for paragraph and header tags $data = str_replace(array('<P>', '</P>'), "\n", $data); $data = str_replace(array('<H1>', '</H1>'), "\n", $data); # cut until the first ')' after the description identifier (that's '<H2>') $find = strpos(strtolower($data), '<h2>'); $find = strpos(strtolower($data), ')', $find + 5); $data = substr($data, 0, $find + 1); # then insert linebreaks for <H2> too $data = str_replace(array('<H2>', '</H2>'), "\n", $data); # remove all the tags and remove double returns $data = strip_tags($data); $data = trim(str_replace("\n\n", "\n", $data)); print html_decode($data); # from lib.php echo "\n\n"; ?>
Footer