function google_search($q) { $rtrn = std_feed_parse(yubnubcmd('cmd2rss g ' . $q)); foreach ($rtrn['items'] as $id => $item) { $rtrn['items'][$id]['description'] = preg_replace('/<a[^\\f]*?<\\/a>/', '', $item['description']); $rtrn['items'][$id]['description'] = strip_tags($rtrn['items'][$id]['description']); if ($rtrn['items'][$id]['description'] == $rtrn['items'][$id]['title']) { $rtrn['items'][$id]['description'] = ''; } else { $rtrn['items'][$id]['description'] = substr($rtrn['items'][$id]['description'], 0, strlen($rtrn['items'][$id]['description']) - 6); } $rtrn['items'][$id]['title'] = html_entity_decode($item['title']); } //end foreach return $rtrn['items']; }
function process_script($shebang, $code) { $code = str_replace("\r\n", "\n", $code); if (substr($shebang, -1, 1) == '#') { $byline = true; } $shebang = explode('#', $shebang); $postvar = $shebang[1]; $shebang = $shebang[0]; if (substr($shebang, 0, 7) == 'yubnub:') { $shebang = str_replace('yubnub:', '', str_replace('yubnub://', '', $shebang)); $shebang = yubnubcmd($shebang, true); } //end if yubnub: $rtrn = ''; if ($byline) { $code = explode("\n", $code); } else { $code = array($code); } foreach ($code as $line) { if (!$line) { continue; } $curl = curl_init(); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); if ($postvar) { curl_setopt($curl, CURLOPT_URL, $shebang); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, $postvar . '=' . urlencode($line)); } else { curl_setopt($curl, CURLOPT_URL, $shebang . urlencode($line)); } $rtrn .= "\n" . curl_exec($curl); curl_close($curl); } //end foreach code return $rtrn; }
$rtrn = curl_exec($curl); curl_close($curl); return $rtrn; } //end function yubnubcmd require 'yubnub2phparray.php'; require 'php2yubnubarray.php'; $items = yubnub2phparray($_REQUEST['data']); $_REQUEST['cmd'] = str_replace('%25s', '%s', $_REQUEST['cmd']); $cmdsep = $_REQUEST['as'] == '<space>' ? ' ' : "\n"; if ($_REQUEST['as'] == 'null') { $cmdsep = ''; } foreach ($items as $item) { $cmd = stristr($_REQUEST['cmd'], '%s') ? str_replace('%s', $item, $_REQUEST['cmd']) : $_REQUEST['cmd'] . ' ' . $item; $cmd = str_replace('[|', '{', $cmd); $cmd = str_replace('|]', '}', $cmd); if ($_REQUEST['as'] != 'array') { $data .= yubnubcmd($cmd) . $cmdsep; } else { $data[] = yubnubcmd($cmd); } } //end foreach items $_REQUEST['type'] ? $_REQUEST['type'] : ($_REQUEST['type'] = 'xml'); if ($_REQUEST['as'] != 'array') { header('Content-Type: text/plain;charset=utf-8'); echo $data; } else { echo php2yubnubarray($data, $_REQUEST['type'], $_REQUEST['callback']); }
<?php function yubnubcmd($cmd) { $curl = curl_init('http://yubnub.org/parser/parse?command=' . urlencode($cmd)); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); $rtrn = curl_exec($curl); curl_close($curl); return $rtrn; } //end function yubnubcmd header('Content-Type: text/plain;charset=utf-8'); require 'yubnub2phparray.php'; $items = yubnub2phparray(yubnubcmd('var ' . $_REQUEST['var'])); $items[] = $_REQUEST['append']; require 'php2yubnubarray.php'; echo yubnubcmd('var ' . $_REQUEST['var'] . ' -set ' . php2yubnubarray($items));
<?php XN_Application::includeFile('xoxotools', '/OutlineClasses/Outline.php'); function yubnubcmd($cmd) { if ($cmd[0] == '"') { return substr($cmd, 1, strlen($cmd) - 2); } $curl = curl_init('http://yubnub.org/parser/parse?command=' . urlencode($cmd)); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); $rtrn = curl_exec($curl); curl_close($curl); return $rtrn; } //end function yubnubcmd header('Content-Type: text/javascript;charset=utf-8'); $struct = new Outline(); $struct->addField('cmd', $_REQUEST['cmd']); if (!isset($_REQUEST['nodata'])) { $struct->addField('data', yubnubcmd($_REQUEST['cmd'])); } $struct->addField('url', yubnubcmd('url ' . $_REQUEST['cmd'])); if ($_REQUEST['callback']) { echo $_REQUEST['callback'] . '('; } echo $struct->toJSON(); if ($_REQUEST['callback']) { echo ')'; }