code
stringlengths 15
9.96M
| docstring
stringlengths 1
10.1k
| func_name
stringlengths 1
124
| language
stringclasses 1
value | repo
stringlengths 7
63
| path
stringlengths 6
186
| url
stringlengths 50
236
| license
stringclasses 4
values |
---|---|---|---|---|---|---|---|
public function AddCustomHeader($custom_header) {
$this->CustomHeader[] = explode(':', $custom_header, 2);
} | Adds a custom header.
@access public
@return void | AddCustomHeader | php | phorgeit/phorge | externals/phpmailer/class.phpmailer.php | https://github.com/phorgeit/phorge/blob/master/externals/phpmailer/class.phpmailer.php | Apache-2.0 |
public function MsgHTML($message, $basedir = '') {
preg_match_all("/(src|background)=\"(.*)\"/Ui", $message, $images);
if(isset($images[2])) {
foreach($images[2] as $i => $url) {
// do not change urls for absolute images (thanks to corvuscorax)
if (!preg_match('#^[A-z]+://#',$url)) {
$filename = basename($url);
$directory = dirname($url);
($directory == '.')?$directory='':'';
$cid = 'cid:' . md5($filename);
$ext = pathinfo($filename, PATHINFO_EXTENSION);
$mimeType = self::_mime_types($ext);
if ( strlen($basedir) > 1 && substr($basedir,-1) != '/') { $basedir .= '/'; }
if ( strlen($directory) > 1 && substr($directory,-1) != '/') { $directory .= '/'; }
if ( $this->AddEmbeddedImage($basedir.$directory.$filename, md5($filename), $filename, 'base64',$mimeType) ) {
$message = preg_replace("/".$images[1][$i]."=\"".preg_quote($url, '/')."\"/Ui", $images[1][$i]."=\"".$cid."\"", $message);
}
}
}
}
$this->IsHTML(true);
$this->Body = $message;
$textMsg = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s','',$message)));
if (!empty($textMsg) && empty($this->AltBody)) {
$this->AltBody = html_entity_decode($textMsg);
}
if (empty($this->AltBody)) {
$this->AltBody = 'To view this email message, open it in a program that understands HTML!' . "\n\n";
}
} | Evaluates the message and returns modifications for inline images and backgrounds
@access public
@return $message | MsgHTML | php | phorgeit/phorge | externals/phpmailer/class.phpmailer.php | https://github.com/phorgeit/phorge/blob/master/externals/phpmailer/class.phpmailer.php | Apache-2.0 |
public static function _mime_types($ext = '') {
$mimes = array(
'hqx' => 'application/mac-binhex40',
'cpt' => 'application/mac-compactpro',
'doc' => 'application/msword',
'bin' => 'application/macbinary',
'dms' => 'application/octet-stream',
'lha' => 'application/octet-stream',
'lzh' => 'application/octet-stream',
'exe' => 'application/octet-stream',
'class' => 'application/octet-stream',
'psd' => 'application/octet-stream',
'so' => 'application/octet-stream',
'sea' => 'application/octet-stream',
'dll' => 'application/octet-stream',
'oda' => 'application/oda',
'pdf' => 'application/pdf',
'ai' => 'application/postscript',
'eps' => 'application/postscript',
'ps' => 'application/postscript',
'smi' => 'application/smil',
'smil' => 'application/smil',
'mif' => 'application/vnd.mif',
'xls' => 'application/vnd.ms-excel',
'ppt' => 'application/vnd.ms-powerpoint',
'wbxml' => 'application/vnd.wap.wbxml',
'wmlc' => 'application/vnd.wap.wmlc',
'dcr' => 'application/x-director',
'dir' => 'application/x-director',
'dxr' => 'application/x-director',
'dvi' => 'application/x-dvi',
'gtar' => 'application/x-gtar',
'php' => 'application/x-httpd-php',
'php4' => 'application/x-httpd-php',
'php3' => 'application/x-httpd-php',
'phtml' => 'application/x-httpd-php',
'phps' => 'application/x-httpd-php-source',
'js' => 'application/x-javascript',
'swf' => 'application/x-shockwave-flash',
'sit' => 'application/x-stuffit',
'tar' => 'application/x-tar',
'tgz' => 'application/x-tar',
'xhtml' => 'application/xhtml+xml',
'xht' => 'application/xhtml+xml',
'zip' => 'application/zip',
'mid' => 'audio/midi',
'midi' => 'audio/midi',
'mpga' => 'audio/mpeg',
'mp2' => 'audio/mpeg',
'mp3' => 'audio/mpeg',
'aif' => 'audio/x-aiff',
'aiff' => 'audio/x-aiff',
'aifc' => 'audio/x-aiff',
'ram' => 'audio/x-pn-realaudio',
'rm' => 'audio/x-pn-realaudio',
'rpm' => 'audio/x-pn-realaudio-plugin',
'ra' => 'audio/x-realaudio',
'rv' => 'video/vnd.rn-realvideo',
'wav' => 'audio/x-wav',
'bmp' => 'image/bmp',
'gif' => 'image/gif',
'jpeg' => 'image/jpeg',
'jpg' => 'image/jpeg',
'jpe' => 'image/jpeg',
'png' => 'image/png',
'tiff' => 'image/tiff',
'tif' => 'image/tiff',
'css' => 'text/css',
'html' => 'text/html',
'htm' => 'text/html',
'shtml' => 'text/html',
'txt' => 'text/plain',
'text' => 'text/plain',
'log' => 'text/plain',
'rtx' => 'text/richtext',
'rtf' => 'text/rtf',
'xml' => 'text/xml',
'xsl' => 'text/xml',
'mpeg' => 'video/mpeg',
'mpg' => 'video/mpeg',
'mpe' => 'video/mpeg',
'qt' => 'video/quicktime',
'mov' => 'video/quicktime',
'avi' => 'video/x-msvideo',
'movie' => 'video/x-sgi-movie',
'word' => 'application/msword',
'xl' => 'application/excel',
'eml' => 'message/rfc822'
);
return (!isset($mimes[strtolower($ext)])) ? 'application/octet-stream' : $mimes[strtolower($ext)];
} | Gets the MIME type of the embedded or inline image
@param string File extension
@access public
@return string MIME type of ext
@static | _mime_types | php | phorgeit/phorge | externals/phpmailer/class.phpmailer.php | https://github.com/phorgeit/phorge/blob/master/externals/phpmailer/class.phpmailer.php | Apache-2.0 |
public function SecureHeader($str) {
$str = str_replace("\r", '', $str);
$str = str_replace("\n", '', $str);
return trim($str);
} | Strips newlines to prevent header injection.
@access public
@param string $str String
@return string | SecureHeader | php | phorgeit/phorge | externals/phpmailer/class.phpmailer.php | https://github.com/phorgeit/phorge/blob/master/externals/phpmailer/class.phpmailer.php | Apache-2.0 |
public function Sign($cert_filename, $key_filename, $key_pass) {
$this->sign_cert_file = $cert_filename;
$this->sign_key_file = $key_filename;
$this->sign_key_pass = $key_pass;
} | Set the private key file and password to sign the message.
@access public
@param string $key_filename Parameter File Name
@param string $key_pass Password for private key | Sign | php | phorgeit/phorge | externals/phpmailer/class.phpmailer.php | https://github.com/phorgeit/phorge/blob/master/externals/phpmailer/class.phpmailer.php | Apache-2.0 |
public function DKIM_QP($txt) {
$line="";
for ($i=0;$i<strlen($txt);$i++) {
$ord=ord($txt[$i]);
if ( ((0x21 <= $ord) && ($ord <= 0x3A)) || $ord == 0x3C || ((0x3E <= $ord) && ($ord <= 0x7E)) ) {
$line.=$txt[$i];
} else {
$line.="=".sprintf("%02X",$ord);
}
}
return $line;
} | Set the private key file and password to sign the message.
@access public
@param string $key_filename Parameter File Name
@param string $key_pass Password for private key | DKIM_QP | php | phorgeit/phorge | externals/phpmailer/class.phpmailer.php | https://github.com/phorgeit/phorge/blob/master/externals/phpmailer/class.phpmailer.php | Apache-2.0 |
public function DKIM_Sign($s) {
$privKeyStr = file_get_contents($this->DKIM_private);
if ($this->DKIM_passphrase!='') {
$privKey = openssl_pkey_get_private($privKeyStr,$this->DKIM_passphrase);
} else {
$privKey = $privKeyStr;
}
if (openssl_sign($s, $signature, $privKey)) {
return base64_encode($signature);
}
} | Generate DKIM signature
@access public
@param string $s Header | DKIM_Sign | php | phorgeit/phorge | externals/phpmailer/class.phpmailer.php | https://github.com/phorgeit/phorge/blob/master/externals/phpmailer/class.phpmailer.php | Apache-2.0 |
public function DKIM_BodyC($body) {
if ($body == '') return "\r\n";
// stabilize line endings
$body=str_replace("\r\n","\n",$body);
$body=str_replace("\n","\r\n",$body);
// END stabilize line endings
while (substr($body,strlen($body)-4,4) == "\r\n\r\n") {
$body=substr($body,0,strlen($body)-2);
}
return $body;
} | Generate DKIM Canonicalization Body
@access public
@param string $body Message Body | DKIM_BodyC | php | phorgeit/phorge | externals/phpmailer/class.phpmailer.php | https://github.com/phorgeit/phorge/blob/master/externals/phpmailer/class.phpmailer.php | Apache-2.0 |
public function __construct() {
$this->smtp_conn = 0;
$this->error = null;
$this->helo_rply = null;
$this->do_debug = 0;
} | Initialize the class so that the data is in a known state.
@access public
@return void | __construct | php | phorgeit/phorge | externals/phpmailer/class.smtp.php | https://github.com/phorgeit/phorge/blob/master/externals/phpmailer/class.smtp.php | Apache-2.0 |
public function Connect($host, $port = 0, $tval = 30) {
// set the error val to null so there is no confusion
$this->error = null;
// make sure we are __not__ connected
if($this->connected()) {
// already connected, generate error
$this->error = array("error" => "Already connected to a server");
return false;
}
if(empty($port)) {
$port = $this->SMTP_PORT;
}
// connect to the smtp server
$this->smtp_conn = @fsockopen($host, // the host of the server
$port, // the port to use
$errno, // error number if any
$errstr, // error message if any
$tval); // give up after ? secs
// verify we connected properly
if(empty($this->smtp_conn)) {
$this->error = array("error" => "Failed to connect to server",
"errno" => $errno,
"errstr" => $errstr);
if($this->do_debug >= 1) {
echo "SMTP -> ERROR: " . $this->error["error"] . ": $errstr ($errno)" . $this->CRLF . '<br />';
}
return false;
}
// SMTP server can take longer to respond, give longer timeout for first read
// Windows does not have support for this timeout function
if(substr(PHP_OS, 0, 3) != "WIN")
socket_set_timeout($this->smtp_conn, $tval, 0);
// get any announcement
$announce = $this->get_lines();
if($this->do_debug >= 2) {
echo "SMTP -> FROM SERVER:" . $announce . $this->CRLF . '<br />';
}
return true;
} | Connect to the server specified on the port specified.
If the port is not specified use the default SMTP_PORT.
If tval is specified then a connection will try and be
established with the server for that number of seconds.
If tval is not specified the default is 30 seconds to
try on the connection.
SMTP CODE SUCCESS: 220
SMTP CODE FAILURE: 421
@access public
@return bool | Connect | php | phorgeit/phorge | externals/phpmailer/class.smtp.php | https://github.com/phorgeit/phorge/blob/master/externals/phpmailer/class.smtp.php | Apache-2.0 |
public function StartTLS() {
$this->error = null; # to avoid confusion
if(!$this->connected()) {
$this->error = array("error" => "Called StartTLS() without being connected");
return false;
}
fputs($this->smtp_conn,"STARTTLS" . $this->CRLF);
$rply = $this->get_lines();
$code = substr($rply,0,3);
if($this->do_debug >= 2) {
echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
}
if($code != 220) {
$this->error =
array("error" => "STARTTLS not accepted from server",
"smtp_code" => $code,
"smtp_msg" => substr($rply,4));
if($this->do_debug >= 1) {
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
}
return false;
}
// Begin encrypted connection
if(!stream_socket_enable_crypto($this->smtp_conn, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) {
return false;
}
return true;
} | Initiate a TLS communication with the server.
SMTP CODE 220 Ready to start TLS
SMTP CODE 501 Syntax error (no parameters allowed)
SMTP CODE 454 TLS not available due to temporary reason
@access public
@return bool success | StartTLS | php | phorgeit/phorge | externals/phpmailer/class.smtp.php | https://github.com/phorgeit/phorge/blob/master/externals/phpmailer/class.smtp.php | Apache-2.0 |
public function Authenticate($username, $password) {
// Start authentication
fputs($this->smtp_conn,"AUTH LOGIN" . $this->CRLF);
$rply = $this->get_lines();
$code = substr($rply,0,3);
if($code != 334) {
$this->error =
array("error" => "AUTH not accepted from server",
"smtp_code" => $code,
"smtp_msg" => substr($rply,4));
if($this->do_debug >= 1) {
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
}
return false;
}
// Send encoded username
fputs($this->smtp_conn, base64_encode($username) . $this->CRLF);
$rply = $this->get_lines();
$code = substr($rply,0,3);
if($code != 334) {
$this->error =
array("error" => "Username not accepted from server",
"smtp_code" => $code,
"smtp_msg" => substr($rply,4));
if($this->do_debug >= 1) {
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
}
return false;
}
// Send encoded password
fputs($this->smtp_conn, base64_encode($password) . $this->CRLF);
$rply = $this->get_lines();
$code = substr($rply,0,3);
if($code != 235) {
$this->error =
array("error" => "Password not accepted from server",
"smtp_code" => $code,
"smtp_msg" => substr($rply,4));
if($this->do_debug >= 1) {
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
}
return false;
}
return true;
} | Performs SMTP authentication. Must be run after running the
Hello() method. Returns true if successfully authenticated.
@access public
@return bool | Authenticate | php | phorgeit/phorge | externals/phpmailer/class.smtp.php | https://github.com/phorgeit/phorge/blob/master/externals/phpmailer/class.smtp.php | Apache-2.0 |
public function Connected() {
if(!empty($this->smtp_conn)) {
$sock_status = socket_get_status($this->smtp_conn);
if($sock_status["eof"]) {
// the socket is valid but we are not connected
if($this->do_debug >= 1) {
echo "SMTP -> NOTICE:" . $this->CRLF . "EOF caught while checking if connected";
}
$this->Close();
return false;
}
return true; // everything looks good
}
return false;
} | Returns true if connected to a server otherwise false
@access public
@return bool | Connected | php | phorgeit/phorge | externals/phpmailer/class.smtp.php | https://github.com/phorgeit/phorge/blob/master/externals/phpmailer/class.smtp.php | Apache-2.0 |
public function Close() {
$this->error = null; // so there is no confusion
$this->helo_rply = null;
if(!empty($this->smtp_conn)) {
// close the connection and cleanup
fclose($this->smtp_conn);
$this->smtp_conn = 0;
}
} | Closes the socket and cleans up the state of the class.
It is not considered good to use this function without
first trying to use QUIT.
@access public
@return void | Close | php | phorgeit/phorge | externals/phpmailer/class.smtp.php | https://github.com/phorgeit/phorge/blob/master/externals/phpmailer/class.smtp.php | Apache-2.0 |
public function Data($msg_data) {
$this->error = null; // so no confusion is caused
if(!$this->connected()) {
$this->error = array(
"error" => "Called Data() without being connected");
return false;
}
fputs($this->smtp_conn,"DATA" . $this->CRLF);
$rply = $this->get_lines();
$code = substr($rply,0,3);
if($this->do_debug >= 2) {
echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
}
if($code != 354) {
$this->error =
array("error" => "DATA command not accepted from server",
"smtp_code" => $code,
"smtp_msg" => substr($rply,4));
if($this->do_debug >= 1) {
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
}
return false;
}
/* the server is ready to accept data!
* according to rfc 821 we should not send more than 1000
* including the CRLF
* characters on a single line so we will break the data up
* into lines by \r and/or \n then if needed we will break
* each of those into smaller lines to fit within the limit.
* in addition we will be looking for lines that start with
* a period '.' and append and additional period '.' to that
* line. NOTE: this does not count towards limit.
*/
// normalize the line breaks so we know the explode works
$msg_data = str_replace("\r\n","\n",$msg_data);
$msg_data = str_replace("\r","\n",$msg_data);
$lines = explode("\n",$msg_data);
/* we need to find a good way to determine is headers are
* in the msg_data or if it is a straight msg body
* currently I am assuming rfc 822 definitions of msg headers
* and if the first field of the first line (':' sperated)
* does not contain a space then it _should_ be a header
* and we can process all lines before a blank "" line as
* headers.
*/
$field = substr($lines[0],0,strpos($lines[0],":"));
$in_headers = false;
if(!empty($field) && !strstr($field," ")) {
$in_headers = true;
}
$max_line_length = 998; // used below; set here for ease in change
foreach($lines as $line) {
$lines_out = null;
if($line == "" && $in_headers) {
$in_headers = false;
}
// ok we need to break this line up into several smaller lines
while(strlen($line) > $max_line_length) {
$pos = strrpos(substr($line,0,$max_line_length)," ");
// Patch to fix DOS attack
if(!$pos) {
$pos = $max_line_length - 1;
$lines_out[] = substr($line,0,$pos);
$line = substr($line,$pos);
} else {
$lines_out[] = substr($line,0,$pos);
$line = substr($line,$pos + 1);
}
/* if processing headers add a LWSP-char to the front of new line
* rfc 822 on long msg headers
*/
if($in_headers) {
$line = "\t" . $line;
}
}
$lines_out[] = $line;
// send the lines to the server
foreach($lines_out as $line_out) {
if(strlen($line_out) > 0)
{
if(substr($line_out, 0, 1) == ".") {
$line_out = "." . $line_out;
}
}
fputs($this->smtp_conn,$line_out . $this->CRLF);
}
}
// message data has been sent
fputs($this->smtp_conn, $this->CRLF . "." . $this->CRLF);
$rply = $this->get_lines();
$code = substr($rply,0,3);
if($this->do_debug >= 2) {
echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
}
if($code != 250) {
$this->error =
array("error" => "DATA not accepted from server",
"smtp_code" => $code,
"smtp_msg" => substr($rply,4));
if($this->do_debug >= 1) {
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
}
return false;
}
return true;
} | Issues a data command and sends the msg_data to the server
finializing the mail transaction. $msg_data is the message
that is to be send with the headers. Each header needs to be
on a single line followed by a <CRLF> with the message headers
and the message body being seperated by and additional <CRLF>.
Implements rfc 821: DATA <CRLF>
SMTP CODE INTERMEDIATE: 354
[data]
<CRLF>.<CRLF>
SMTP CODE SUCCESS: 250
SMTP CODE FAILURE: 552,554,451,452
SMTP CODE FAILURE: 451,554
SMTP CODE ERROR : 500,501,503,421
@access public
@return bool | Data | php | phorgeit/phorge | externals/phpmailer/class.smtp.php | https://github.com/phorgeit/phorge/blob/master/externals/phpmailer/class.smtp.php | Apache-2.0 |
public function Hello($host = '') {
$this->error = null; // so no confusion is caused
if(!$this->connected()) {
$this->error = array(
"error" => "Called Hello() without being connected");
return false;
}
// if hostname for HELO was not specified send default
if(empty($host)) {
// determine appropriate default to send to server
$host = "localhost";
}
// Send extended hello first (RFC 2821)
if(!$this->SendHello("EHLO", $host)) {
if(!$this->SendHello("HELO", $host)) {
return false;
}
}
return true;
} | Sends the HELO command to the smtp server.
This makes sure that we and the server are in
the same known state.
Implements from rfc 821: HELO <SP> <domain> <CRLF>
SMTP CODE SUCCESS: 250
SMTP CODE ERROR : 500, 501, 504, 421
@access public
@return bool | Hello | php | phorgeit/phorge | externals/phpmailer/class.smtp.php | https://github.com/phorgeit/phorge/blob/master/externals/phpmailer/class.smtp.php | Apache-2.0 |
private function SendHello($hello, $host) {
fputs($this->smtp_conn, $hello . " " . $host . $this->CRLF);
$rply = $this->get_lines();
$code = substr($rply,0,3);
if($this->do_debug >= 2) {
echo "SMTP -> FROM SERVER: " . $rply . $this->CRLF . '<br />';
}
if($code != 250) {
$this->error =
array("error" => $hello . " not accepted from server",
"smtp_code" => $code,
"smtp_msg" => substr($rply,4));
if($this->do_debug >= 1) {
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
}
return false;
}
$this->helo_rply = $rply;
return true;
} | Sends a HELO/EHLO command.
@access private
@return bool | SendHello | php | phorgeit/phorge | externals/phpmailer/class.smtp.php | https://github.com/phorgeit/phorge/blob/master/externals/phpmailer/class.smtp.php | Apache-2.0 |
public function Mail($from) {
$this->error = null; // so no confusion is caused
if(!$this->connected()) {
$this->error = array(
"error" => "Called Mail() without being connected");
return false;
}
$useVerp = ($this->do_verp ? "XVERP" : "");
fputs($this->smtp_conn,"MAIL FROM:<" . $from . ">" . $useVerp . $this->CRLF);
$rply = $this->get_lines();
$code = substr($rply,0,3);
if($this->do_debug >= 2) {
echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
}
if($code != 250) {
$this->error =
array("error" => "MAIL not accepted from server",
"smtp_code" => $code,
"smtp_msg" => substr($rply,4));
if($this->do_debug >= 1) {
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
}
return false;
}
return true;
} | Starts a mail transaction from the email address specified in
$from. Returns true if successful or false otherwise. If True
the mail transaction is started and then one or more Recipient
commands may be called followed by a Data command.
Implements rfc 821: MAIL <SP> FROM:<reverse-path> <CRLF>
SMTP CODE SUCCESS: 250
SMTP CODE SUCCESS: 552,451,452
SMTP CODE SUCCESS: 500,501,421
@access public
@return bool | Mail | php | phorgeit/phorge | externals/phpmailer/class.smtp.php | https://github.com/phorgeit/phorge/blob/master/externals/phpmailer/class.smtp.php | Apache-2.0 |
public function Quit($close_on_error = true) {
$this->error = null; // so there is no confusion
if(!$this->connected()) {
$this->error = array(
"error" => "Called Quit() without being connected");
return false;
}
// send the quit command to the server
fputs($this->smtp_conn,"quit" . $this->CRLF);
// get any good-bye messages
$byemsg = $this->get_lines();
if($this->do_debug >= 2) {
echo "SMTP -> FROM SERVER:" . $byemsg . $this->CRLF . '<br />';
}
$rval = true;
$e = null;
$code = substr($byemsg,0,3);
if($code != 221) {
// use e as a tmp var cause Close will overwrite $this->error
$e = array("error" => "SMTP server rejected quit command",
"smtp_code" => $code,
"smtp_rply" => substr($byemsg,4));
$rval = false;
if($this->do_debug >= 1) {
echo "SMTP -> ERROR: " . $e["error"] . ": " . $byemsg . $this->CRLF . '<br />';
}
}
if(empty($e) || $close_on_error) {
$this->Close();
}
return $rval;
} | Sends the quit command to the server and then closes the socket
if there is no error or the $close_on_error argument is true.
Implements from rfc 821: QUIT <CRLF>
SMTP CODE SUCCESS: 221
SMTP CODE ERROR : 500
@access public
@return bool | Quit | php | phorgeit/phorge | externals/phpmailer/class.smtp.php | https://github.com/phorgeit/phorge/blob/master/externals/phpmailer/class.smtp.php | Apache-2.0 |
public function Recipient($to) {
$this->error = null; // so no confusion is caused
if(!$this->connected()) {
$this->error = array(
"error" => "Called Recipient() without being connected");
return false;
}
fputs($this->smtp_conn,"RCPT TO:<" . $to . ">" . $this->CRLF);
$rply = $this->get_lines();
$code = substr($rply,0,3);
if($this->do_debug >= 2) {
echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
}
if($code != 250 && $code != 251) {
$this->error =
array("error" => "RCPT not accepted from server",
"smtp_code" => $code,
"smtp_msg" => substr($rply,4));
if($this->do_debug >= 1) {
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
}
return false;
}
return true;
} | Sends the command RCPT to the SMTP server with the TO: argument of $to.
Returns true if the recipient was accepted false if it was rejected.
Implements from rfc 821: RCPT <SP> TO:<forward-path> <CRLF>
SMTP CODE SUCCESS: 250,251
SMTP CODE FAILURE: 550,551,552,553,450,451,452
SMTP CODE ERROR : 500,501,503,421
@access public
@return bool | Recipient | php | phorgeit/phorge | externals/phpmailer/class.smtp.php | https://github.com/phorgeit/phorge/blob/master/externals/phpmailer/class.smtp.php | Apache-2.0 |
public function Reset() {
$this->error = null; // so no confusion is caused
if(!$this->connected()) {
$this->error = array(
"error" => "Called Reset() without being connected");
return false;
}
fputs($this->smtp_conn,"RSET" . $this->CRLF);
$rply = $this->get_lines();
$code = substr($rply,0,3);
if($this->do_debug >= 2) {
echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
}
if($code != 250) {
$this->error =
array("error" => "RSET failed",
"smtp_code" => $code,
"smtp_msg" => substr($rply,4));
if($this->do_debug >= 1) {
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
}
return false;
}
return true;
} | Sends the RSET command to abort and transaction that is
currently in progress. Returns true if successful false
otherwise.
Implements rfc 821: RSET <CRLF>
SMTP CODE SUCCESS: 250
SMTP CODE ERROR : 500,501,504,421
@access public
@return bool | Reset | php | phorgeit/phorge | externals/phpmailer/class.smtp.php | https://github.com/phorgeit/phorge/blob/master/externals/phpmailer/class.smtp.php | Apache-2.0 |
public function SendAndMail($from) {
$this->error = null; // so no confusion is caused
if(!$this->connected()) {
$this->error = array(
"error" => "Called SendAndMail() without being connected");
return false;
}
fputs($this->smtp_conn,"SAML FROM:" . $from . $this->CRLF);
$rply = $this->get_lines();
$code = substr($rply,0,3);
if($this->do_debug >= 2) {
echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
}
if($code != 250) {
$this->error =
array("error" => "SAML not accepted from server",
"smtp_code" => $code,
"smtp_msg" => substr($rply,4));
if($this->do_debug >= 1) {
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
}
return false;
}
return true;
} | Starts a mail transaction from the email address specified in
$from. Returns true if successful or false otherwise. If True
the mail transaction is started and then one or more Recipient
commands may be called followed by a Data command. This command
will send the message to the users terminal if they are logged
in and send them an email.
Implements rfc 821: SAML <SP> FROM:<reverse-path> <CRLF>
SMTP CODE SUCCESS: 250
SMTP CODE SUCCESS: 552,451,452
SMTP CODE SUCCESS: 500,501,502,421
@access public
@return bool | SendAndMail | php | phorgeit/phorge | externals/phpmailer/class.smtp.php | https://github.com/phorgeit/phorge/blob/master/externals/phpmailer/class.smtp.php | Apache-2.0 |
public function Turn() {
$this->error = array("error" => "This method, TURN, of the SMTP ".
"is not implemented");
if($this->do_debug >= 1) {
echo "SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF . '<br />';
}
return false;
} | This is an optional command for SMTP that this class does not
support. This method is here to make the RFC821 Definition
complete for this class and __may__ be implimented in the future
Implements from rfc 821: TURN <CRLF>
SMTP CODE SUCCESS: 250
SMTP CODE FAILURE: 502
SMTP CODE ERROR : 500, 503
@access public
@return bool | Turn | php | phorgeit/phorge | externals/phpmailer/class.smtp.php | https://github.com/phorgeit/phorge/blob/master/externals/phpmailer/class.smtp.php | Apache-2.0 |
public function getError() {
return $this->error;
} | Get the current error
@access public
@return array | getError | php | phorgeit/phorge | externals/phpmailer/class.smtp.php | https://github.com/phorgeit/phorge/blob/master/externals/phpmailer/class.smtp.php | Apache-2.0 |
private function get_lines() {
$data = "";
while($str = @fgets($this->smtp_conn,515)) {
if($this->do_debug >= 4) {
echo "SMTP -> get_lines(): \$data was \"$data\"" . $this->CRLF . '<br />';
echo "SMTP -> get_lines(): \$str is \"$str\"" . $this->CRLF . '<br />';
}
$data .= $str;
if($this->do_debug >= 4) {
echo "SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF . '<br />';
}
// if 4th character is a space, we are done reading, break the loop
if(substr($str,3,1) == " ") { break; }
}
return $data;
} | Read in as many lines as possible
either before eof or socket timeout occurs on the operation.
With SMTP we can tell if we have more lines to read if the
4th character is '-' symbol. If it is a space then we don't
need to read anything else.
@access private
@return string | get_lines | php | phorgeit/phorge | externals/phpmailer/class.smtp.php | https://github.com/phorgeit/phorge/blob/master/externals/phpmailer/class.smtp.php | Apache-2.0 |
public function __set($k, $v)
{
if ($v === "") {
throw new InvalidArgumentException(
'You cannot set \''.$k.'\'to an empty string. '
.'We interpret empty strings as NULL in requests. '
.'You may set obj->'.$k.' = NULL to delete the property'
);
}
if (self::$nestedUpdatableAttributes->includes($k)
&& isset($this->$k) && is_array($v)) {
$this->$k->replaceWith($v);
} else {
// TODO: may want to clear from $_transientValues (Won't be user-visible).
$this->_values[$k] = $v;
}
if (!self::$permanentAttributes->includes($k))
$this->_unsavedValues->add($k);
} | Standard accessor magic methods | __set | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Object.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Object.php | Apache-2.0 |
public function offsetSet($k, $v)
{
$this->$k = $v;
} | ArrayAccess methods | offsetSet | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Object.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Object.php | Apache-2.0 |
public static function scopedConstructFrom($class, $values, $apiKey=null)
{
$obj = new $class(isset($values['id']) ? $values['id'] : null, $apiKey);
$obj->refreshFrom($values, $apiKey);
return $obj;
} | This unfortunately needs to be public to be used in Util.php
@param string $class
@param array $values
@param string|null $apiKey
@return Stripe_Object The object constructed from the given values. | scopedConstructFrom | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Object.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Object.php | Apache-2.0 |
public static function constructFrom($values, $apiKey=null)
{
return self::scopedConstructFrom(__CLASS__, $values, $apiKey);
} | @param array $values
@param string|null $apiKey
@return Stripe_Object The object of the same class as $this constructed
from the given values. | constructFrom | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Object.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Object.php | Apache-2.0 |
public function serializeParameters()
{
$params = array();
if ($this->_unsavedValues) {
foreach ($this->_unsavedValues->toArray() as $k) {
$v = $this->$k;
if ($v === NULL) {
$v = '';
}
$params[$k] = $v;
}
}
// Get nested updates.
foreach (self::$nestedUpdatableAttributes->toArray() as $property) {
if (isset($this->$property)
&& $this->$property instanceOf Stripe_Object) {
$params[$property] = $this->$property->serializeParameters();
}
}
return $params;
} | @return array A recursive mapping of attributes to values for this object,
including the proper value for deleted attributes. | serializeParameters | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Object.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Object.php | Apache-2.0 |
protected function _lsb($method)
{
$class = get_class($this);
$args = array_slice(func_get_args(), 1);
return call_user_func_array(array($class, $method), $args);
} | Pretend to have late static bindings, even in PHP 5.2 | _lsb | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Object.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Object.php | Apache-2.0 |
public static function retrieve($id, $apiKey=null)
{
$class = get_class();
return self::_scopedRetrieve($class, $id, $apiKey);
} | @param string $id The ID of the transfer to retrieve.
@param string|null $apiKey
@return Stripe_Transfer | retrieve | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Transfer.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Transfer.php | Apache-2.0 |
public static function all($params=null, $apiKey=null)
{
$class = get_class();
return self::_scopedAll($class, $params, $apiKey);
} | @param array|null $params
@param string|null $apiKey
@return array An array of Stripe_Transfers. | all | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Transfer.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Transfer.php | Apache-2.0 |
public static function create($params=null, $apiKey=null)
{
$class = get_class();
return self::_scopedCreate($class, $params, $apiKey);
} | @param array|null $params
@param string|null $apiKey
@return Stripe_Transfer The created transfer. | create | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Transfer.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Transfer.php | Apache-2.0 |
public function cancel()
{
$requestor = new Stripe_ApiRequestor($this->_apiKey);
$url = $this->instanceUrl() . '/cancel';
list($response, $apiKey) = $requestor->request('post', $url);
$this->refreshFrom($response, $apiKey);
return $this;
} | @return Stripe_Transfer The canceled transfer. | cancel | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Transfer.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Transfer.php | Apache-2.0 |
public function save()
{
$class = get_class();
return self::_scopedSave($class);
} | @return Stripe_Transfer The saved transfer. | save | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Transfer.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Transfer.php | Apache-2.0 |
public function instanceUrl()
{
$id = $this['id'];
$charge = $this['charge'];
if (!$id) {
throw new Stripe_InvalidRequestError(
"Could not determine which URL to request: " .
"class instance has invalid ID: $id",
null
);
}
$id = Stripe_ApiRequestor::utf8($id);
$charge = Stripe_ApiRequestor::utf8($charge);
$base = self::classUrl('Stripe_Charge');
$chargeExtn = urlencode($charge);
$extn = urlencode($id);
return "$base/$chargeExtn/refunds/$extn";
} | @return string The API URL for this Stripe refund. | instanceUrl | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Refund.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Refund.php | Apache-2.0 |
public function save()
{
$class = get_class();
return self::_scopedSave($class);
} | @return Stripe_Refund The saved refund. | save | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Refund.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Refund.php | Apache-2.0 |
public static function retrieve($id, $apiKey=null)
{
$class = get_class();
return self::_scopedRetrieve($class, $id, $apiKey);
} | @param string $id The ID of the token to retrieve.
@param string|null $apiKey
@return Stripe_Token | retrieve | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Token.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Token.php | Apache-2.0 |
public static function create($params=null, $apiKey=null)
{
$class = get_class();
return self::_scopedCreate($class, $params, $apiKey);
} | @param array|null $params
@param string|null $apiKey
@return Stripe_Coupon The created token. | create | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Token.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Token.php | Apache-2.0 |
public static function create($params=null, $apiKey=null)
{
$class = get_class();
return self::_scopedCreate($class, $params, $apiKey);
} | @param array|null $params
@param string|null $apiKey
@return Stripe_Invoice The created invoice. | create | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Invoice.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Invoice.php | Apache-2.0 |
public static function retrieve($id, $apiKey=null)
{
$class = get_class();
return self::_scopedRetrieve($class, $id, $apiKey);
} | @param string $id The ID of the invoice to retrieve.
@param string|null $apiKey
@return Stripe_Invoice | retrieve | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Invoice.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Invoice.php | Apache-2.0 |
public static function all($params=null, $apiKey=null)
{
$class = get_class();
return self::_scopedAll($class, $params, $apiKey);
} | @param array|null $params
@param string|null $apiKey
@return array An array of Stripe_Invoices. | all | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Invoice.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Invoice.php | Apache-2.0 |
public static function upcoming($params=null, $apiKey=null)
{
$requestor = new Stripe_ApiRequestor($apiKey);
$url = self::classUrl(get_class()) . '/upcoming';
list($response, $apiKey) = $requestor->request('get', $url, $params);
return Stripe_Util::convertToStripeObject($response, $apiKey);
} | @param array|null $params
@param string|null $apiKey
@return Stripe_Invoice The upcoming invoice. | upcoming | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Invoice.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Invoice.php | Apache-2.0 |
public function save()
{
$class = get_class();
return self::_scopedSave($class);
} | @return Stripe_Invoice The saved invoice. | save | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Invoice.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Invoice.php | Apache-2.0 |
public function pay()
{
$requestor = new Stripe_ApiRequestor($this->_apiKey);
$url = $this->instanceUrl() . '/pay';
list($response, $apiKey) = $requestor->request('post', $url);
$this->refreshFrom($response, $apiKey);
return $this;
} | @return Stripe_Invoice The paid invoice. | pay | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Invoice.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Invoice.php | Apache-2.0 |
public static function retrieve($id, $apiKey=null)
{
$class = get_class();
return self::_scopedRetrieve($class, $id, $apiKey);
} | @param string $id The ID of the event to retrieve.
@param string|null $apiKey
@return Stripe_Event | retrieve | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Event.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Event.php | Apache-2.0 |
public static function all($params=null, $apiKey=null)
{
$class = get_class();
return self::_scopedAll($class, $params, $apiKey);
} | @param array|null $params
@param string|null $apiKey
@return array An array of Stripe_Events. | all | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Event.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Event.php | Apache-2.0 |
public static function isList($array)
{
if (!is_array($array))
return false;
// TODO: generally incorrect, but it's correct given Stripe's response
foreach (array_keys($array) as $k) {
if (!is_numeric($k))
return false;
}
return true;
} | Whether the provided array (or other) is a list rather than a dictionary.
@param array|mixed $array
@return boolean True if the given object is a list. | isList | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Util.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Util.php | Apache-2.0 |
public static function convertStripeObjectToArray($values)
{
$results = array();
foreach ($values as $k => $v) {
// FIXME: this is an encapsulation violation
if ($k[0] == '_') {
continue;
}
if ($v instanceof Stripe_Object) {
$results[$k] = $v->__toArray(true);
} else if (is_array($v)) {
$results[$k] = self::convertStripeObjectToArray($v);
} else {
$results[$k] = $v;
}
}
return $results;
} | Recursively converts the PHP Stripe object to an array.
@param array $values The PHP Stripe object to convert.
@return array | convertStripeObjectToArray | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Util.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Util.php | Apache-2.0 |
public static function convertToStripeObject($resp, $apiKey)
{
$types = array(
'card' => 'Stripe_Card',
'charge' => 'Stripe_Charge',
'customer' => 'Stripe_Customer',
'list' => 'Stripe_List',
'invoice' => 'Stripe_Invoice',
'invoiceitem' => 'Stripe_InvoiceItem',
'event' => 'Stripe_Event',
'transfer' => 'Stripe_Transfer',
'plan' => 'Stripe_Plan',
'recipient' => 'Stripe_Recipient',
'refund' => 'Stripe_Refund',
'subscription' => 'Stripe_Subscription'
);
if (self::isList($resp)) {
$mapped = array();
foreach ($resp as $i)
array_push($mapped, self::convertToStripeObject($i, $apiKey));
return $mapped;
} else if (is_array($resp)) {
if (isset($resp['object'])
&& is_string($resp['object'])
&& isset($types[$resp['object']])) {
$class = $types[$resp['object']];
} else {
$class = 'Stripe_Object';
}
return Stripe_Object::scopedConstructFrom($class, $resp, $apiKey);
} else {
return $resp;
}
} | Converts a response from the Stripe API to the corresponding PHP object.
@param array $resp The response from the Stripe API.
@param string $apiKey
@return Stripe_Object|array | convertToStripeObject | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Util.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Util.php | Apache-2.0 |
public function refresh()
{
$requestor = new Stripe_ApiRequestor($this->_apiKey);
$url = $this->instanceUrl();
list($response, $apiKey) = $requestor->request(
'get',
$url,
$this->_retrieveOptions
);
$this->refreshFrom($response, $apiKey);
return $this;
} | @returns Stripe_ApiResource The refreshed resource. | refresh | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/ApiResource.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/ApiResource.php | Apache-2.0 |
public static function className($class)
{
// Useful for namespaces: Foo\Stripe_Charge
if ($postfixNamespaces = strrchr($class, '\\')) {
$class = substr($postfixNamespaces, 1);
}
// Useful for underscored 'namespaces': Foo_Stripe_Charge
if ($postfixFakeNamespaces = strrchr($class, 'Stripe_')) {
$class = $postfixFakeNamespaces;
}
if (substr($class, 0, strlen('Stripe')) == 'Stripe') {
$class = substr($class, strlen('Stripe'));
}
$class = str_replace('_', '', $class);
$name = urlencode($class);
$name = strtolower($name);
return $name;
} | @param string $class
@returns string The name of the class, with namespacing and underscores
stripped. | className | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/ApiResource.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/ApiResource.php | Apache-2.0 |
public static function classUrl($class)
{
$base = self::_scopedLsb($class, 'className', $class);
return "/v1/${base}s";
} | @param string $class
@returns string The endpoint URL for the given class. | classUrl | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/ApiResource.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/ApiResource.php | Apache-2.0 |
public function instanceUrl()
{
$id = $this['id'];
$class = get_class($this);
if ($id === null) {
$message = "Could not determine which URL to request: "
. "$class instance has invalid ID: $id";
throw new Stripe_InvalidRequestError($message, null);
}
$id = Stripe_ApiRequestor::utf8($id);
$base = $this->_lsb('classUrl', $class);
$extn = urlencode($id);
return "$base/$extn";
} | @returns string The full API URL for this API resource. | instanceUrl | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/ApiResource.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/ApiResource.php | Apache-2.0 |
public static function className($class)
{
return 'application_fee';
} | This is a special case because the application fee endpoint has an
underscore in it. The parent `className` function strips underscores.
@return string The name of the class. | className | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/ApplicationFee.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/ApplicationFee.php | Apache-2.0 |
public static function retrieve($id, $apiKey=null)
{
$class = get_class();
return self::_scopedRetrieve($class, $id, $apiKey);
} | @param string $id The ID of the application fee to retrieve.
@param string|null $apiKey
@return Stripe_ApplicationFee | retrieve | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/ApplicationFee.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/ApplicationFee.php | Apache-2.0 |
public static function all($params=null, $apiKey=null)
{
$class = get_class();
return self::_scopedAll($class, $params, $apiKey);
} | @param string|null $params
@param string|null $apiKey
@return array An array of application fees. | all | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/ApplicationFee.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/ApplicationFee.php | Apache-2.0 |
public function refund($params=null)
{
$requestor = new Stripe_ApiRequestor($this->_apiKey);
$url = $this->instanceUrl() . '/refund';
list($response, $apiKey) = $requestor->request('post', $url, $params);
$this->refreshFrom($response, $apiKey);
return $this;
} | @param string|null $params
@return Stripe_ApplicationFee The refunded application fee. | refund | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/ApplicationFee.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/ApplicationFee.php | Apache-2.0 |
public function instanceUrl()
{
$id = $this['id'];
$customer = $this['customer'];
if (!$id) {
throw new Stripe_InvalidRequestError(
"Could not determine which URL to request: " .
"class instance has invalid ID: $id",
null
);
}
$id = Stripe_ApiRequestor::utf8($id);
$customer = Stripe_ApiRequestor::utf8($customer);
$base = self::classUrl('Stripe_Customer');
$customerExtn = urlencode($customer);
$extn = urlencode($id);
return "$base/$customerExtn/subscriptions/$extn";
} | @return string The API URL for this Stripe subscription. | instanceUrl | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Subscription.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Subscription.php | Apache-2.0 |
public function cancel($params=null)
{
$class = get_class();
return self::_scopedDelete($class, $params);
} | @param array|null $params
@return Stripe_Subscription The deleted subscription. | cancel | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Subscription.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Subscription.php | Apache-2.0 |
public function save()
{
$class = get_class();
return self::_scopedSave($class);
} | @return Stripe_Subscription The saved subscription. | save | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Subscription.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Subscription.php | Apache-2.0 |
public function deleteDiscount()
{
$requestor = new Stripe_ApiRequestor($this->_apiKey);
$url = $this->instanceUrl() . '/discount';
list($response, $apiKey) = $requestor->request('delete', $url);
$this->refreshFrom(array('discount' => null), $apiKey, true);
} | @return Stripe_Subscription The updated subscription. | deleteDiscount | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Subscription.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Subscription.php | Apache-2.0 |
public static function retrieve($id, $apiKey=null)
{
$class = get_class();
return self::_scopedRetrieve($class, $id, $apiKey);
} | @param string $id The ID of the coupon to retrieve.
@param string|null $apiKey
@return Stripe_Coupon | retrieve | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Coupon.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Coupon.php | Apache-2.0 |
public static function create($params=null, $apiKey=null)
{
$class = get_class();
return self::_scopedCreate($class, $params, $apiKey);
} | @param array|null $params
@param string|null $apiKey
@return Stripe_Coupon The created coupon. | create | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Coupon.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Coupon.php | Apache-2.0 |
public function delete($params=null)
{
$class = get_class();
return self::_scopedDelete($class, $params);
} | @param array|null $params
@return Stripe_Coupon The deleted coupon. | delete | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Coupon.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Coupon.php | Apache-2.0 |
public static function all($params=null, $apiKey=null)
{
$class = get_class();
return self::_scopedAll($class, $params, $apiKey);
} | @param array|null $params
@param string|null $apiKey
@return array An array of Stripe_Coupons. | all | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Coupon.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Coupon.php | Apache-2.0 |
public static function retrieve($id, $apiKey=null)
{
$class = get_class();
return self::_scopedRetrieve($class, $id, $apiKey);
} | @param string $id The ID of the customer to retrieve.
@param string|null $apiKey
@return Stripe_Customer | retrieve | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Customer.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Customer.php | Apache-2.0 |
public static function all($params=null, $apiKey=null)
{
$class = get_class();
return self::_scopedAll($class, $params, $apiKey);
} | @param array|null $params
@param string|null $apiKey
@return array An array of Stripe_Customers. | all | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Customer.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Customer.php | Apache-2.0 |
public static function create($params=null, $apiKey=null)
{
$class = get_class();
return self::_scopedCreate($class, $params, $apiKey);
} | @param array|null $params
@param string|null $apiKey
@return Stripe_Customer The created customer. | create | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Customer.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Customer.php | Apache-2.0 |
public function save()
{
$class = get_class();
return self::_scopedSave($class);
} | @returns Stripe_Customer The saved customer. | save | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Customer.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Customer.php | Apache-2.0 |
public function delete($params=null)
{
$class = get_class();
return self::_scopedDelete($class, $params);
} | @param array|null $params
@returns Stripe_Customer The deleted customer. | delete | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Customer.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Customer.php | Apache-2.0 |
public function addInvoiceItem($params=null)
{
if (!$params)
$params = array();
$params['customer'] = $this->id;
$ii = Stripe_InvoiceItem::create($params, $this->_apiKey);
return $ii;
} | @param array|null $params
@returns Stripe_InvoiceItem The resulting invoice item. | addInvoiceItem | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Customer.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Customer.php | Apache-2.0 |
public function invoices($params=null)
{
if (!$params)
$params = array();
$params['customer'] = $this->id;
$invoices = Stripe_Invoice::all($params, $this->_apiKey);
return $invoices;
} | @param array|null $params
@returns array An array of the customer's Stripe_Invoices. | invoices | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Customer.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Customer.php | Apache-2.0 |
public function invoiceItems($params=null)
{
if (!$params)
$params = array();
$params['customer'] = $this->id;
$iis = Stripe_InvoiceItem::all($params, $this->_apiKey);
return $iis;
} | @param array|null $params
@returns array An array of the customer's Stripe_InvoiceItems. | invoiceItems | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Customer.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Customer.php | Apache-2.0 |
public function charges($params=null)
{
if (!$params)
$params = array();
$params['customer'] = $this->id;
$charges = Stripe_Charge::all($params, $this->_apiKey);
return $charges;
} | @param array|null $params
@returns array An array of the customer's Stripe_Charges. | charges | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Customer.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Customer.php | Apache-2.0 |
public function updateSubscription($params=null)
{
$requestor = new Stripe_ApiRequestor($this->_apiKey);
$url = $this->instanceUrl() . '/subscription';
list($response, $apiKey) = $requestor->request('post', $url, $params);
$this->refreshFrom(array('subscription' => $response), $apiKey, true);
return $this->subscription;
} | @param array|null $params
@returns Stripe_Subscription The updated subscription. | updateSubscription | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Customer.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Customer.php | Apache-2.0 |
public function cancelSubscription($params=null)
{
$requestor = new Stripe_ApiRequestor($this->_apiKey);
$url = $this->instanceUrl() . '/subscription';
list($response, $apiKey) = $requestor->request('delete', $url, $params);
$this->refreshFrom(array('subscription' => $response), $apiKey, true);
return $this->subscription;
} | @param array|null $params
@returns Stripe_Subscription The cancelled subscription. | cancelSubscription | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Customer.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Customer.php | Apache-2.0 |
public function deleteDiscount()
{
$requestor = new Stripe_ApiRequestor($this->_apiKey);
$url = $this->instanceUrl() . '/discount';
list($response, $apiKey) = $requestor->request('delete', $url);
$this->refreshFrom(array('discount' => null), $apiKey, true);
} | @param array|null $params
@returns Stripe_Customer The updated customer. | deleteDiscount | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Customer.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Customer.php | Apache-2.0 |
public static function apiUrl($url='')
{
$apiBase = Stripe::$apiBase;
return "$apiBase$url";
} | @param string $url The path to the API endpoint.
@returns string The full path. | apiUrl | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/ApiRequestor.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/ApiRequestor.php | Apache-2.0 |
public static function utf8($value)
{
if (is_string($value)
&& mb_detect_encoding($value, "UTF-8", TRUE) != "UTF-8") {
return utf8_encode($value);
} else {
return $value;
}
} | @param string|mixed $value A string to UTF8-encode.
@returns string|mixed The UTF8-encoded string, or the object passed in if
it wasn't a string. | utf8 | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/ApiRequestor.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/ApiRequestor.php | Apache-2.0 |
public static function encode($arr, $prefix=null)
{
if (!is_array($arr))
return $arr;
$r = array();
foreach ($arr as $k => $v) {
if (is_null($v))
continue;
if ($prefix && $k && !is_int($k))
$k = $prefix."[".$k."]";
else if ($prefix)
$k = $prefix."[]";
if (is_array($v)) {
$r[] = self::encode($v, $k, true);
} else {
$r[] = urlencode($k)."=".urlencode($v);
}
}
return implode("&", $r);
} | @param array $arr An map of param keys to values.
@param string|null $prefix (It doesn't look like we ever use $prefix...)
@returns string A querystring, essentially. | encode | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/ApiRequestor.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/ApiRequestor.php | Apache-2.0 |
public function request($method, $url, $params=null)
{
if (!$params)
$params = array();
list($rbody, $rcode, $myApiKey) =
$this->_requestRaw($method, $url, $params);
$resp = $this->_interpretResponse($rbody, $rcode);
return array($resp, $myApiKey);
} | @param string $method
@param string $url
@param array|null $params
@return array An array whose first element is the response and second
element is the API key used to make the request. | request | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/ApiRequestor.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/ApiRequestor.php | Apache-2.0 |
public function handleApiError($rbody, $rcode, $resp)
{
if (!is_array($resp) || !isset($resp['error'])) {
$msg = "Invalid response object from API: $rbody "
."(HTTP response code was $rcode)";
throw new Stripe_ApiError($msg, $rcode, $rbody, $resp);
}
$error = $resp['error'];
$msg = isset($error['message']) ? $error['message'] : null;
$param = isset($error['param']) ? $error['param'] : null;
$code = isset($error['code']) ? $error['code'] : null;
switch ($rcode) {
case 400:
if ($code == 'rate_limit') {
throw new Stripe_RateLimitError(
$msg, $param, $rcode, $rbody, $resp
);
}
case 404:
throw new Stripe_InvalidRequestError(
$msg, $param, $rcode, $rbody, $resp
);
case 401:
throw new Stripe_AuthenticationError($msg, $rcode, $rbody, $resp);
case 402:
throw new Stripe_CardError($msg, $param, $code, $rcode, $rbody, $resp);
default:
throw new Stripe_ApiError($msg, $rcode, $rbody, $resp);
}
} | @param string $rbody A JSON string.
@param int $rcode
@param array $resp
@throws Stripe_InvalidRequestError if the error is caused by the user.
@throws Stripe_AuthenticationError if the error is caused by a lack of
permissions.
@throws Stripe_CardError if the error is the error code is 402 (payment
required)
@throws Stripe_ApiError otherwise. | handleApiError | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/ApiRequestor.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/ApiRequestor.php | Apache-2.0 |
public function handleCurlError($errno, $message)
{
$apiBase = Stripe::$apiBase;
switch ($errno) {
case CURLE_COULDNT_CONNECT:
case CURLE_COULDNT_RESOLVE_HOST:
case CURLE_OPERATION_TIMEOUTED:
$msg = "Could not connect to Stripe ($apiBase). Please check your "
. "internet connection and try again. If this problem persists, "
. "you should check Stripe's service status at "
. "https://twitter.com/stripestatus, or";
break;
case CURLE_SSL_CACERT:
case CURLE_SSL_PEER_CERTIFICATE:
$msg = "Could not verify Stripe's SSL certificate. Please make sure "
. "that your network is not intercepting certificates. "
. "(Try going to $apiBase in your browser.) "
. "If this problem persists,";
break;
default:
$msg = "Unexpected error communicating with Stripe. "
. "If this problem persists,";
}
$msg .= " let us know at [email protected].";
$msg .= "\n\n(Network error [errno $errno]: $message)";
throw new Stripe_ApiConnectionError($msg);
} | @param number $errno
@param string $message
@throws Stripe_ApiConnectionError | handleCurlError | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/ApiRequestor.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/ApiRequestor.php | Apache-2.0 |
private function checkSslCert($url)
{
if (version_compare(PHP_VERSION, '5.3.0', '<')) {
error_log(
'Warning: This version of PHP is too old to check SSL certificates '.
'correctly. Stripe cannot guarantee that the server has a '.
'certificate which is not blacklisted'
);
return true;
}
if (strpos(PHP_VERSION, 'hiphop') !== false) {
error_log(
'Warning: HHVM does not support Stripe\'s SSL certificate '.
'verification. (See http://docs.hhvm.com/manual/en/context.ssl.php) '.
'Stripe cannot guarantee that the server has a certificate which is '.
'not blacklisted'
);
return true;
}
$url = parse_url($url);
$port = isset($url["port"]) ? $url["port"] : 443;
$url = "ssl://{$url["host"]}:{$port}";
$sslContext = stream_context_create(
array('ssl' => array(
'capture_peer_cert' => true,
'verify_peer' => true,
'cafile' => $this->caBundle(),
))
);
$result = stream_socket_client(
$url, $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $sslContext
);
if ($errno !== 0) {
$apiBase = Stripe::$apiBase;
throw new Stripe_ApiConnectionError(
'Could not connect to Stripe (' . $apiBase . '). Please check your '.
'internet connection and try again. If this problem persists, '.
'you should check Stripe\'s service status at '.
'https://twitter.com/stripestatus. Reason was: '.$errstr
);
}
$params = stream_context_get_params($result);
$cert = $params['options']['ssl']['peer_certificate'];
openssl_x509_export($cert, $pemCert);
if (self::isBlackListed($pemCert)) {
throw new Stripe_ApiConnectionError(
'Invalid server certificate. You tried to connect to a server that '.
'has a revoked SSL certificate, which means we cannot securely send '.
'data to that server. Please email [email protected] if you need '.
'help connecting to the correct API server.'
);
}
return true;
} | Preflight the SSL certificate presented by the backend. This isn't 100%
bulletproof, in that we're not actually validating the transport used to
communicate with Stripe, merely that the first attempt to does not use a
revoked certificate.
Unfortunately the interface to OpenSSL doesn't make it easy to check the
certificate before sending potentially sensitive data on the wire. This
approach raises the bar for an attacker significantly. | checkSslCert | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/ApiRequestor.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/ApiRequestor.php | Apache-2.0 |
public static function classUrl($class)
{
return "/v1/balance/history";
} | @param string $class Ignored.
@return string The class URL for this resource. It needs to be special
cased because it doesn't fit into the standard resource pattern. | classUrl | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/BalanceTransaction.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/BalanceTransaction.php | Apache-2.0 |
public static function retrieve($id, $apiKey=null)
{
$class = get_class();
return self::_scopedRetrieve($class, $id, $apiKey);
} | @param string $id The ID of the balance transaction to retrieve.
@param string|null $apiKey
@return Stripe_BalanceTransaction | retrieve | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/BalanceTransaction.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/BalanceTransaction.php | Apache-2.0 |
public static function all($params=null, $apiKey=null)
{
$class = get_class();
return self::_scopedAll($class, $params, $apiKey);
} | @param array|null $params
@param string|null $apiKey
@return array An array of Stripe_BalanceTransactions. | all | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/BalanceTransaction.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/BalanceTransaction.php | Apache-2.0 |
public static function retrieve($id, $apiKey=null)
{
$class = get_class();
return self::_scopedRetrieve($class, $id, $apiKey);
} | @param string $id The ID of the invoice item to retrieve.
@param string|null $apiKey
@return Stripe_InvoiceItem | retrieve | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/InvoiceItem.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/InvoiceItem.php | Apache-2.0 |
public static function all($params=null, $apiKey=null)
{
$class = get_class();
return self::_scopedAll($class, $params, $apiKey);
} | @param array|null $params
@param string|null $apiKey
@return array An array of Stripe_InvoiceItems. | all | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/InvoiceItem.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/InvoiceItem.php | Apache-2.0 |
public static function create($params=null, $apiKey=null)
{
$class = get_class();
return self::_scopedCreate($class, $params, $apiKey);
} | @param array|null $params
@param string|null $apiKey
@return Stripe_InvoiceItem The created invoice item. | create | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/InvoiceItem.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/InvoiceItem.php | Apache-2.0 |
public function save()
{
$class = get_class();
return self::_scopedSave($class);
} | @return Stripe_InvoiceItem The saved invoice item. | save | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/InvoiceItem.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/InvoiceItem.php | Apache-2.0 |
public function delete($params=null)
{
$class = get_class();
return self::_scopedDelete($class, $params);
} | @return Stripe_InvoiceItem The deleted invoice item. | delete | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/InvoiceItem.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/InvoiceItem.php | Apache-2.0 |
public static function retrieve($id, $apiKey=null)
{
$class = get_class();
return self::_scopedRetrieve($class, $id, $apiKey);
} | @param string $id The ID of the charge to retrieve.
@param string|null $apiKey
@return Stripe_Charge | retrieve | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Charge.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Charge.php | Apache-2.0 |
public static function all($params=null, $apiKey=null)
{
$class = get_class();
return self::_scopedAll($class, $params, $apiKey);
} | @param array|null $params
@param string|null $apiKey
@return array An array of Stripe_Charges. | all | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Charge.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Charge.php | Apache-2.0 |
public static function create($params=null, $apiKey=null)
{
$class = get_class();
return self::_scopedCreate($class, $params, $apiKey);
} | @param array|null $params
@param string|null $apiKey
@return Stripe_Charge The created charge. | create | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Charge.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Charge.php | Apache-2.0 |
public function save()
{
$class = get_class();
return self::_scopedSave($class);
} | @return Stripe_Charge The saved charge. | save | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Charge.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Charge.php | Apache-2.0 |
public function refund($params=null)
{
$requestor = new Stripe_ApiRequestor($this->_apiKey);
$url = $this->instanceUrl() . '/refund';
list($response, $apiKey) = $requestor->request('post', $url, $params);
$this->refreshFrom($response, $apiKey);
return $this;
} | @param array|null $params
@return Stripe_Charge The refunded charge. | refund | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Charge.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Charge.php | Apache-2.0 |
public function capture($params=null)
{
$requestor = new Stripe_ApiRequestor($this->_apiKey);
$url = $this->instanceUrl() . '/capture';
list($response, $apiKey) = $requestor->request('post', $url, $params);
$this->refreshFrom($response, $apiKey);
return $this;
} | @param array|null $params
@return Stripe_Charge The captured charge. | capture | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Charge.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Charge.php | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.