Example #1
0
 function doMethod($methodName, $nvpArray)
 {
     // create final name/value/pair array
     $nvpArray = array_merge(array('METHOD' => $methodName, 'VERSION' => '51.0', 'PWD' => $this->pass, 'USER' => $this->user, 'SIGNATURE' => $this->sig), $nvpArray);
     // make it a urlencoded string
     $nvpStr = ra::toNVP($nvpArray);
     //funx::debug($nvpStr);
     // create curl
     $c = curl_init();
     curl_setopt($c, CURLOPT_URL, $this->endpoint);
     //curl_setopt($c, CURLOPT_VERBOSE, 1);
     curl_setopt($c, CURLOPT_SSL_VERIFYPEER, FALSE);
     curl_setopt($c, CURLOPT_SSL_VERIFYHOST, FALSE);
     curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($c, CURLOPT_POST, 1);
     curl_setopt($c, CURLOPT_POSTFIELDS, $nvpStr);
     // execute method on paypal server
     $response = curl_exec($c);
     // parse the response
     $ret = $response ? ra::fromNVP($response) : array('L_LONGMESSAGE' => 'Couldn\'t talk to payment server. Please try again later. ' . curl_error($c) . '(' . curl_errno($c) . ')');
     // debug message
     funx::debug("Response to {$methodName}: " . var_export($response, true) . "\n" . var_export($ret, true));
     $this->lastErrorTxt = "Response was " . str_replace(array("  '"), array("<br /> &nbsp; '"), var_export($ret, true)) . "<br /><br />" . "NVP was " . var_export(str_replace(array("&", $this->user, $this->pass, $this->sig, urlencode($nvpArray['ACCT'])), array("<br /> &nbsp; &amp;", '', '', '', substr($nvpArray['ACCT'], -5, 5)), $nvpStr), true) . '';
     return $ret;
 }
Example #2
0
 static function parse($fname, $args)
 {
     $msg = explode("\n", funx::inc($fname, $args));
     $subject = trim(array_shift($msg));
     $body = ra::condense($msg, '<br />');
     return array($subject, $body);
 }
Example #3
0
 static function cmd($cmd, $passthru = false)
 {
     if (ini::get('verbose') >= 1) {
         echo $cmd . ($passthru ? ' (passthru)' : '') . "\n";
     }
     // passthru (raw output gets echoed)
     if ($passthru === true or $passthru === 'passthru') {
         passthru($cmd, self::$cmdStatus);
     } elseif ($passthru === 'spawn') {
         $ret = proc_open("{$cmd} &", array(), $foo);
         //proc_close($ret);
         return $ret;
     } else {
         exec($cmd, $output, self::$cmdStatus);
         return ra::condense($output, "\n");
     }
 }
Example #4
0
 static function between($str, $start, $end, &$endPos, $caseInsensitive = false)
 {
     if (!strlen($str) or !strlen($start) or !strlen($end)) {
         return false;
     }
     if (!is_array($start)) {
         $start = array($start);
     }
     if (!is_array($end)) {
         $end = array($end);
     }
     $pos1 = ra::strpos($str, $start, $found, $endPos, $caseInsensitive);
     if ($pos1 === false) {
         return false;
     }
     $pos1 += strlen($found);
     $pos2 = ra::strpos($str, $end, $found, $pos1, $caseInsensitive);
     if ($pos2 === false) {
         return false;
     }
     $endPos = $pos2;
     return substr($str, $pos1, $pos2 - $pos1);
 }
Example #5
0
 private function drawRadio($name, $ra)
 {
     $ret = '';
     $lastK = ra::lastKey($ra['options']);
     foreach ($ra['options'] as $k => $i) {
         $ret .= '<input type="radio"' . ' name="' . $name . '" id="' . $name . '" value="' . $k . '"' . ((strlen($ra['selected']) and $ra['selected'] == $k) ? ' checked' : '') . self::drawIf('onclick', $ra['onclick'][$k]) . ' />' . $i . ($k == $lastK ? '' : '<br />');
     }
     $ret = '<div class="radio_buttons">' . $ret . '</div>';
     return $ret;
 }
Example #6
0
 protected static function strip($ret)
 {
     // erase tabs
     $ret = str_replace(array("\t"), array(''), $ret);
     // strip c++ style comments
     $lines = explode("\n", $ret);
     foreach ($lines as $i => $line) {
         if (($pos = strpos($line, '/' . '/')) !== false) {
             $lines[$i] = substr($line, 0, $pos);
         }
     }
     $ret = ra::condense($lines, "") . "\n";
     return $ret;
 }