parent
5813b1109f
commit
43077b57ed
@ -0,0 +1,15 @@ |
|||||||
|
# Development security |
||||||
|
# Protect .git, .env files |
||||||
|
<Files "\.*"> |
||||||
|
Order deny,allow |
||||||
|
Deny From All |
||||||
|
</Files> |
||||||
|
|
||||||
|
# Clouddesk URL Support |
||||||
|
RewriteEngine ON |
||||||
|
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-f |
||||||
|
RewriteCond %{REQUEST_FILENAME} !-d |
||||||
|
RewriteRule . index.php [L] |
||||||
|
|
||||||
|
ErrorDocument 404 /404/ |
@ -0,0 +1,51 @@ |
|||||||
|
<!DOCTYPE html> |
||||||
|
<html lang="<?php echo $BT_LANGUAGE;?>">
|
||||||
|
<head> |
||||||
|
<meta charset="utf-8"> |
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge"> |
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> |
||||||
|
<meta name="author" content="Live Chat Business"> |
||||||
|
<title><?php echo $jkl["g2"];?> - <?php echo JAK_TITLE;?></title>
|
||||||
|
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon"> |
||||||
|
<link rel="stylesheet" href="<?php echo BASE_URL;?>css/compress.css.php" media="screen">
|
||||||
|
|
||||||
|
<!--[if lt IE 9]> |
||||||
|
<script src="https://html5shiv.googlecode.com/svn/trunk/html5.js"></script> |
||||||
|
<![endif]--> |
||||||
|
|
||||||
|
<?php if ($jkl["rtlsupport"]) { ?> |
||||||
|
<!-- RTL Support --> |
||||||
|
<link rel="stylesheet" href="<?php echo BASE_URL;?>css/style-rtl.css?=<?php echo JAK_UPDATED;?>" type="text/css" media="screen">
|
||||||
|
<!-- End RTL Support --> |
||||||
|
<?php } ?> |
||||||
|
|
||||||
|
<!-- Le fav and touch icons --> |
||||||
|
<link rel="shortcut icon" href="<?php echo BASE_URL;?>img/ico/favicon.ico">
|
||||||
|
|
||||||
|
</head> |
||||||
|
<body> |
||||||
|
|
||||||
|
<div class="navbar navbar-default"> |
||||||
|
<div class="container"> |
||||||
|
<div class="navbar-header"> |
||||||
|
<a class="navbar-brand" href="<?php echo $_SERVER['REQUEST_URI'];?>"><?php echo $jkl["g2"];?></a> - <a class="navbar-brand" href="<?php echo BASE_URL;?>"><?php echo JAK_TITLE;?></a>
|
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
|
||||||
|
<div class="container"> |
||||||
|
<div class="row"> |
||||||
|
<div class="col-md-12"> |
||||||
|
<p><?php echo $jkl["e5"];?> |
||||||
|
<ul> |
||||||
|
<li><?php echo $jkl["e6"];?></li>
|
||||||
|
<li><?php echo $jkl["e7"];?></li>
|
||||||
|
<li><?php echo $jkl["e8"];?></li>
|
||||||
|
</ul> |
||||||
|
</p> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
|
||||||
|
</div> |
||||||
|
</body> |
||||||
|
</html> |
@ -0,0 +1,18 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
/*===============================================*\ |
||||||
|
|| ############################################# || |
||||||
|
|| # JAKWEB.CH / Version 1.0 # || |
||||||
|
|| # ----------------------------------------- # || |
||||||
|
|| # Copyright 2019 JAKWEB All Rights Reserved # || |
||||||
|
|| ############################################# || |
||||||
|
\*===============================================*/ |
||||||
|
|
||||||
|
if (!file_exists('config.php')) die('[_showfile.php] config.php not exist'); |
||||||
|
require_once 'config.php'; |
||||||
|
|
||||||
|
$thedata = explode(":#:", jak_encrypt_decrypt($_GET["i"], false)); |
||||||
|
|
||||||
|
jak_load_external_file($thedata[0], $thedata[1], $thedata[2]); |
||||||
|
|
||||||
|
?> |
@ -0,0 +1,324 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
/*===============================================*\ |
||||||
|
|| ############################################# || |
||||||
|
|| # JAKWEB.CH / Version 2.1.3 # || |
||||||
|
|| # ----------------------------------------- # || |
||||||
|
|| # Copyright 2022 JAKWEB All Rights Reserved # || |
||||||
|
|| ############################################# || |
||||||
|
\*===============================================*/ |
||||||
|
|
||||||
|
// Check if the file is accessed only via index.php if not stop the script from running |
||||||
|
if (!defined('JAK_PREVENT_ACCESS')) die('You cannot access this file directly.'); |
||||||
|
|
||||||
|
// All the tables we need for this plugin |
||||||
|
$jaktable = 'clients'; |
||||||
|
$jaktable1 = 'support_tickets'; |
||||||
|
$jaktable2 = 'ticket_answers'; |
||||||
|
$jakfield = 'email'; |
||||||
|
$errors = array(); |
||||||
|
|
||||||
|
// We need to check if the call is coming thru get |
||||||
|
if ($_SERVER["REQUEST_METHOD"] == 'GET' && $page1) { |
||||||
|
|
||||||
|
// Get the api and sid key |
||||||
|
$api_key = hash_hmac('md5', FULL_SITE_DOMAIN.JAK_O_NUMBER, DB_PASS_HASH); |
||||||
|
$api_key1 = hash_hmac('md5', JAK_O_NUMBER.FULL_SITE_DOMAIN, DB_PASS_HASH); |
||||||
|
|
||||||
|
// Rebuild the decryption because of PHP 7.2 |
||||||
|
$query = ""; |
||||||
|
$c = base64_decode(strtr($page1, '._-', '+/=')); |
||||||
|
$ivlen = openssl_cipher_iv_length($cipher="AES-128-CBC"); |
||||||
|
$iv = substr($c, 0, $ivlen); |
||||||
|
$hmac = substr($c, $ivlen, $sha2len=32); |
||||||
|
$ciphertext_raw = substr($c, $ivlen+$sha2len); |
||||||
|
$original_plaintext = openssl_decrypt($ciphertext_raw, $cipher, $api_key, $options=OPENSSL_RAW_DATA, $iv); |
||||||
|
$calcmac = hash_hmac('sha256', $ciphertext_raw, $api_key, $as_binary=true); |
||||||
|
if (hash_equals($hmac, $calcmac))//PHP 5.6+ timing attack safe comparison |
||||||
|
{ |
||||||
|
$query = $original_plaintext; |
||||||
|
} |
||||||
|
|
||||||
|
parse_str($query, $jkp); |
||||||
|
|
||||||
|
// Set the project id |
||||||
|
$pid = $jkp['pid'] ? $jkp['pid'] : JAK_STANDARD_SUPPORT_DEP; |
||||||
|
|
||||||
|
if ($jkp['sid'] = $api_key1) { |
||||||
|
|
||||||
|
switch ($jkp['action']) { |
||||||
|
|
||||||
|
case 'new': |
||||||
|
|
||||||
|
$row = $jakdb->get($jaktable, ["id", "opid", "chat_dep", "support_dep", "faq_cat", "paid_until"], ["email" => $jkp['email']]); |
||||||
|
|
||||||
|
if ($row) { |
||||||
|
|
||||||
|
if ($row["opid"] != filter_var($jkp["mainopid"], FILTER_SANITIZE_NUMBER_INT)) exit(); |
||||||
|
|
||||||
|
// Ok we update the credits |
||||||
|
if (JAK_BILLING_MODE == 1 && isset($jkp["credits"]) && !empty($jkp["credits"]) && $jkp["credits"] != 0) { |
||||||
|
|
||||||
|
$jakdb->update($jaktable, ["credits[+]" => $jkp["credits"]], ["id" => $row["id"]]); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
// We update the membership access |
||||||
|
if (JAK_BILLING_MODE == 2 && isset($jkp["valid"]) && !empty($jkp["valid"])) { |
||||||
|
// Get the new date |
||||||
|
if (strtotime($row["paid_until"]) > time()) { |
||||||
|
$paidunix = strtotime($jkp["valid"], strtotime($row["paid_until"])); |
||||||
|
} else { |
||||||
|
$paidunix = strtotime($jkp["valid"]); |
||||||
|
} |
||||||
|
$paidtill = date('Y-m-d', $paidunix); |
||||||
|
$jakdb->update($jaktable, ["paid_until" => $paidtill], ["id" => $row["id"]]); |
||||||
|
} |
||||||
|
|
||||||
|
// Update the password |
||||||
|
if (isset($jkp["pass"]) && !empty($jkp["pass"])) { |
||||||
|
$jakdb->update($jaktable, ["password" => $jkp['pass']], ["id" => $row["id"]]); |
||||||
|
} |
||||||
|
|
||||||
|
// Update the chat departments if set so |
||||||
|
if (isset($jkp["chatdep"]) && !empty($jkp["chatdep"])) { |
||||||
|
$jakdb->update($jaktable, ["chat_dep" => $jkp['chatdep']], ["id" => $row["id"]]); |
||||||
|
} |
||||||
|
|
||||||
|
// Update the support departments if set so |
||||||
|
if (isset($jkp["supportdep"]) && !empty($jkp["supportdep"])) { |
||||||
|
$jakdb->update($jaktable, ["support_dep" => $jkp['supportdep']], ["id" => $row["id"]]); |
||||||
|
} |
||||||
|
|
||||||
|
// Update the faq categories if set so |
||||||
|
if (isset($jkp["faqcat"]) && !empty($jkp["faqcat"])) { |
||||||
|
$jakdb->update($jaktable, ["faq_cat" => $jkp['faqcat']], ["id" => $row["id"]]); |
||||||
|
} |
||||||
|
|
||||||
|
// Finally we update the rest |
||||||
|
$jakdb->update($jaktable, ["name" => $jkp['name'], "email" => $jkp['email']], ["id" => $row["id"]]); |
||||||
|
|
||||||
|
} else { |
||||||
|
|
||||||
|
if (empty($jkp['name'])) { |
||||||
|
$errors['e'] = $jkl['e']; |
||||||
|
} |
||||||
|
|
||||||
|
if (JAK_EMAIL_BLOCK) { |
||||||
|
$blockede = explode(',', JAK_EMAIL_BLOCK); |
||||||
|
if (in_array($jkp['email'], $blockede) || in_array(strrchr($jkp['email'], "@"), $blockede)) { |
||||||
|
$errors['e1'] = $jkl['e10']; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
if ($jkp['email'] == '' || !filter_var($jkp['email'], FILTER_VALIDATE_EMAIL)) { |
||||||
|
$errors['e2'] = $jkl['e1']; |
||||||
|
} |
||||||
|
|
||||||
|
if (jak_field_not_exist(strtolower($jkp['email']),$jaktable,$jakfield)) { |
||||||
|
$errors['e3'] = $jkl['hd35']; |
||||||
|
} |
||||||
|
|
||||||
|
if (count($errors) == 0) { |
||||||
|
|
||||||
|
// We have no errors we insert the user |
||||||
|
|
||||||
|
// create new password |
||||||
|
if ($jkp["pass"]) { |
||||||
|
$password = $jkl['hd58']; |
||||||
|
$passcrypt = $jkp["pass"]; |
||||||
|
} else { |
||||||
|
$password = jak_password_creator(); |
||||||
|
$passcrypt = hash_hmac('sha256', $password, DB_PASS_HASH); |
||||||
|
} |
||||||
|
|
||||||
|
$result = $jakdb->insert($jaktable, [ |
||||||
|
"opid" => filter_var($jkp["mainopid"], FILTER_SANITIZE_NUMBER_INT), |
||||||
|
"chat_dep" => ($jkp["chatdep"] ? $jkp["chatdep"] : JAK_STANDARD_CHAT_DEP), |
||||||
|
"support_dep" => ($jkp["supportdep"] ? $jkp["supportdep"] : JAK_STANDARD_SUPPORT_DEP), |
||||||
|
"faq_cat" => ($jkp["faqcat"] ? $jkp["faqcat"] : JAK_STANDARD_FAQ_CAT), |
||||||
|
"name" => filter_var($jkp["name"], FILTER_SANITIZE_FULL_SPECIAL_CHARS), |
||||||
|
"email" => filter_var($jkp["email"], FILTER_SANITIZE_EMAIL), |
||||||
|
"password" => $passcrypt, |
||||||
|
"credits" => ($jkp["credits"] ? $jkp["credits"] : 0), |
||||||
|
"paid_until" => ($jkp["valid"] ? $jkp["valid"] : "1980-05-06"), |
||||||
|
"canupload" => 1, |
||||||
|
"access" => 1, |
||||||
|
"time" => $jakdb->raw("NOW()")]); |
||||||
|
|
||||||
|
$uid = $jakdb->id(); |
||||||
|
|
||||||
|
// Get the email template |
||||||
|
$nlhtml = file_get_contents(APP_PATH.'template/'.JAK_FRONT_TEMPLATE.'/email/index.html'); |
||||||
|
|
||||||
|
if (!$result) { |
||||||
|
|
||||||
|
// We will need to inform the operator if set so |
||||||
|
if (JAK_TICKET_INFORM_R) { |
||||||
|
|
||||||
|
// Change fake vars into real ones. |
||||||
|
$cssAtt = array('{emailcontent}', '{weburl}', '{title}', '{emailtpllogo}', '{emailtplcopy}'); |
||||||
|
$cssUrl = array("There has been an error when creating following user: ".$jkp['email'], BASE_URL, JAK_TITLE, JAK_EMAILTPLLOGO, JAK_EMAILTPLCOPY); |
||||||
|
$nlcontent = str_replace($cssAtt, $cssUrl, $nlhtml); |
||||||
|
|
||||||
|
$body = str_ireplace("[\]", "", $nlcontent); |
||||||
|
|
||||||
|
// We need the reply to the department |
||||||
|
$emailreply = ""; |
||||||
|
if (isset($HD_SUPPORT_DEPARTMENTS) && is_array($HD_SUPPORT_DEPARTMENTS)) foreach ($HD_SUPPORT_DEPARTMENTS as $v) { |
||||||
|
|
||||||
|
if ($v["id"] == $accounts["depid"]) { |
||||||
|
if ($v["email"]) $emailreply = $v["email"]; |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
// Ok, we send the email // email address, cc email address, reply to, subject, message, attachment |
||||||
|
jak_send_email($semail, explode(',', JAK_EMAILCC), $emailreply, JAK_TITLE.' - API Error', $body, ""); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
} else { |
||||||
|
|
||||||
|
$newuserpath = APP_PATH.JAK_FILES_DIRECTORY.'/clients/'.$uid; |
||||||
|
|
||||||
|
if (!is_dir($newuserpath)) { |
||||||
|
mkdir($newuserpath, 0755); |
||||||
|
copy(APP_PATH.JAK_FILES_DIRECTORY."/index.html", $newuserpath."/index.html"); |
||||||
|
} |
||||||
|
|
||||||
|
// Change fake vars into real ones. |
||||||
|
if (!empty($HD_ANSWERS) && is_array($HD_ANSWERS)) foreach ($HD_ANSWERS as $v) { |
||||||
|
if ($v["msgtype"] == 14 && $v["lang"] == JAK_LANG) { |
||||||
|
$phold = array('{url}', '{title}', '{cname}', '{cemail}', '{cpassword}', '{email}'); |
||||||
|
$replace = array(BASE_URL, JAK_TITLE, $jkp['name'], $jkp['email'], $password, JAK_EMAIL); |
||||||
|
$regtext = str_replace($phold, $replace, $v["message"]); |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// Change fake vars into real ones. |
||||||
|
$cssAtt = array('{emailcontent}', '{weburl}', '{title}', '{emailtpllogo}', '{emailtplcopy}'); |
||||||
|
$cssUrl = array($regtext, BASE_URL, JAK_TITLE, JAK_EMAILTPLLOGO, JAK_EMAILTPLCOPY); |
||||||
|
$nlcontent = str_replace($cssAtt, $cssUrl, $nlhtml); |
||||||
|
|
||||||
|
$body = str_ireplace("[\]", "", $nlcontent); |
||||||
|
|
||||||
|
// Ok, we send the email // email address, cc email address, reply to, subject, message, attachment |
||||||
|
jak_send_email($jkp['email'], "", "", JAK_TITLE.' - '.$jkl['hd33'], $body, ""); |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
exit(); |
||||||
|
|
||||||
|
break; |
||||||
|
|
||||||
|
case 'update': |
||||||
|
|
||||||
|
// Collect the information from the old email address |
||||||
|
$row = $jakdb->get($jaktable, ["id", "opid", "chat_dep", "support_dep", "faq_cat", "paid_until"], ["email" => $jkp['oldemail']]); |
||||||
|
|
||||||
|
if ($row) { |
||||||
|
|
||||||
|
if ($row["opid"] != filter_var($jkp["mainopid"], FILTER_SANITIZE_NUMBER_INT)) exit(); |
||||||
|
|
||||||
|
// Ok we update the credits |
||||||
|
if (JAK_BILLING_MODE == 1 && isset($jkp["credits"]) && !empty($jkp["credits"]) && $jkp["credits"] != 0) { |
||||||
|
|
||||||
|
$jakdb->update($jaktable, ["credits[+]" => $jkp["credits"]], ["id" => $row["id"]]); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
// We update the membership access |
||||||
|
if (JAK_BILLING_MODE == 2 && isset($jkp["valid"]) && !empty($jkp["valid"])) { |
||||||
|
// Get the new date |
||||||
|
if (strtotime($row["paid_until"]) > time()) { |
||||||
|
$paidunix = strtotime($jkp["valid"], strtotime($row["paid_until"])); |
||||||
|
} else { |
||||||
|
$paidunix = strtotime($jkp["valid"]); |
||||||
|
} |
||||||
|
$paidtill = date('Y-m-d', $paidunix); |
||||||
|
$jakdb->update($jaktable, ["paid_until" => $paidtill], ["id" => $row["id"]]); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
// Update the password |
||||||
|
if (isset($jkp["pass"]) && !empty($jkp["pass"])) { |
||||||
|
$jakdb->update($jaktable, ["password" => $jkp['pass']], ["id" => $row["id"]]); |
||||||
|
} |
||||||
|
|
||||||
|
// Update the chat departments if set so |
||||||
|
if (isset($jkp["chatdep"]) && !empty($jkp["chatdep"])) { |
||||||
|
$jakdb->update($jaktable, ["chat_dep" => $jkp['chatdep']], ["id" => $row["id"]]); |
||||||
|
} |
||||||
|
|
||||||
|
// Update the support departments if set so |
||||||
|
if (isset($jkp["supportdep"]) && !empty($jkp["supportdep"])) { |
||||||
|
$jakdb->update($jaktable, ["support_dep" => $jkp['supportdep']], ["id" => $row["id"]]); |
||||||
|
} |
||||||
|
|
||||||
|
// Update the faq categories if set so |
||||||
|
if (isset($jkp["faqcat"]) && !empty($jkp["faqcat"])) { |
||||||
|
$jakdb->update($jaktable, ["faq_cat" => $jkp['faqcat']], ["id" => $row["id"]]); |
||||||
|
} |
||||||
|
|
||||||
|
// Finally we update the rest |
||||||
|
$jakdb->update($jaktable, ["name" => $jkp['name'], "email" => $jkp['email']], ["id" => $row["id"]]); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
exit(); |
||||||
|
|
||||||
|
break; |
||||||
|
|
||||||
|
case 'delete': |
||||||
|
|
||||||
|
$row = $jakdb->get($jaktable, ["id", "opid", "chat_dep", "support_dep", "faq_cat", "paid_until"], ["email" => $jkp['email']]); |
||||||
|
|
||||||
|
if ($row) { |
||||||
|
|
||||||
|
if ($row["opid"] != filter_var($jkp["mainopid"], FILTER_SANITIZE_NUMBER_INT)) exit(); |
||||||
|
|
||||||
|
$jakdb->delete($jaktable, ["id" => $row["id"]]); |
||||||
|
|
||||||
|
// Delete Avatar and folder |
||||||
|
$targetPath = APP_PATH.JAK_FILES_DIRECTORY.'/clients/'.$row["id"].'/'; |
||||||
|
$removedouble = str_replace("//","/",$targetPath); |
||||||
|
foreach(glob($removedouble.'*.*') as $jak_unlink) { |
||||||
|
|
||||||
|
@unlink($jak_unlink); |
||||||
|
|
||||||
|
@unlink($targetPath); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
// Find tickets from this user and set to 0 |
||||||
|
$jakdb->update($jaktable1, ["clientid" => 0], ["clientid" => $row["id"]]); |
||||||
|
$jakdb->update($jaktable2, ["clientid" => 0], ["clientid" => $row["id"]]); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
exit(); |
||||||
|
|
||||||
|
break; |
||||||
|
|
||||||
|
default: |
||||||
|
|
||||||
|
// We could print an error here |
||||||
|
|
||||||
|
exit(); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} else { |
||||||
|
// Wrong api key we can print an error here |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} else { |
||||||
|
// Some access to the api but it failed |
||||||
|
} |
||||||
|
?> |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,28 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
/*===============================================*\ |
||||||
|
|| ############################################# || |
||||||
|
|| # JAKWEB.CH / Version 1.1.1 # || |
||||||
|
|| # ----------------------------------------- # || |
||||||
|
|| # Copyright 2020 JAKWEB All Rights Reserved # || |
||||||
|
|| ############################################# || |
||||||
|
\*===============================================*/ |
||||||
|
|
||||||
|
class JAK_client { |
||||||
|
|
||||||
|
private $data; |
||||||
|
private $lsvar = 0; |
||||||
|
|
||||||
|
public function __construct($row) { |
||||||
|
$this->data = $row; |
||||||
|
} |
||||||
|
|
||||||
|
function getVar($lsvar) { |
||||||
|
|
||||||
|
// Setting up an alias, so we don't have to write $this->data every time: |
||||||
|
$d = $this->data; |
||||||
|
|
||||||
|
return (isset($d[$lsvar]) && !empty($d[$lsvar]) ? $d[$lsvar] : false); |
||||||
|
} |
||||||
|
} |
||||||
|
?> |
@ -0,0 +1,279 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
/*===============================================*\ |
||||||
|
|| ############################################# || |
||||||
|
|| # JAKWEB.CH / Version 2.1.2 # || |
||||||
|
|| # ----------------------------------------- # || |
||||||
|
|| # Copyright 2023 JAKWEB All Rights Reserved # || |
||||||
|
|| ############################################# || |
||||||
|
\*===============================================*/ |
||||||
|
|
||||||
|
class JAK_clientlogin { |
||||||
|
|
||||||
|
protected $name = '', $pass = '', $time = ''; |
||||||
|
var $email; //Username given on sign-up |
||||||
|
|
||||||
|
public function __construct() { |
||||||
|
$this->email = ''; |
||||||
|
} |
||||||
|
|
||||||
|
function jakChecklogged() { |
||||||
|
|
||||||
|
/* Check if user has been remembered */ |
||||||
|
if (isset($_COOKIE['jak_lcpc_cookname']) && isset($_COOKIE['jak_lcpc_cookid'])) { |
||||||
|
$_SESSION['jak_lcpc_email'] = $_COOKIE['jak_lcpc_cookname']; |
||||||
|
$_SESSION['jak_lcpc_idhash'] = $_COOKIE['jak_lcpc_cookid']; |
||||||
|
} |
||||||
|
|
||||||
|
/* Username and idhash have been set */ |
||||||
|
if (isset($_SESSION['jak_lcpc_email']) && isset($_SESSION['jak_lcpc_idhash']) && $_SESSION['jak_lcpc_email'] != $this->email) { |
||||||
|
/* Confirm that email and userid are valid */ |
||||||
|
if (!JAK_clientlogin::jakConfirmidhash($_SESSION['jak_lcpc_email'], $_SESSION['jak_lcpc_idhash'])) { |
||||||
|
/* Variables are incorrect, user not logged in */ |
||||||
|
unset($_SESSION['jak_lcpc_email']); |
||||||
|
unset($_SESSION['jak_lcpc_idhash']); |
||||||
|
|
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
// Return the user data |
||||||
|
return JAK_clientlogin::jakUserinfo($_SESSION['jak_lcpc_email']); |
||||||
|
|
||||||
|
/* User not logged in */ |
||||||
|
} else { |
||||||
|
return false; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
function jakCheckrestlogged($userid, $hash) { |
||||||
|
|
||||||
|
/* UserID and Hash have been set */ |
||||||
|
global $jakdb; |
||||||
|
$datauinfo = $jakdb->get("clients", "*", ["AND" => ["id" => $userid, "idhash" => $hash]]); |
||||||
|
if (isset($datauinfo) && !empty($datauinfo)) { |
||||||
|
|
||||||
|
// Return the user data |
||||||
|
return $datauinfo; |
||||||
|
|
||||||
|
/* User not logged in */ |
||||||
|
} else { |
||||||
|
return false; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public static function jakCheckuserdata($email, $pass) { |
||||||
|
|
||||||
|
// The new password encrypt with hash_hmac |
||||||
|
$passcrypt = hash_hmac('sha256', $pass, DB_PASS_HASH); |
||||||
|
|
||||||
|
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
global $jakdb; |
||||||
|
$datausr = $jakdb->get("clients", "id", ["AND" => ["email" => strtolower($email), "password" => $passcrypt, "access" => 1]]); |
||||||
|
if ($datausr) { |
||||||
|
return true; |
||||||
|
} else { |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public static function jakLogin($email, $pass, $remember) { |
||||||
|
|
||||||
|
// The new password encrypt with hash_hmac |
||||||
|
$passcrypt = hash_hmac('sha256', $pass, DB_PASS_HASH); |
||||||
|
|
||||||
|
global $jakdb; |
||||||
|
|
||||||
|
// Get the stuff out the database |
||||||
|
$datausr = $jakdb->get("clients", ["idhash", "logins"], ["AND" => ["email" => $email, "password" => $passcrypt]]); |
||||||
|
|
||||||
|
if ($datausr['logins'] % 10 == 0) { |
||||||
|
|
||||||
|
// Generate new idhash |
||||||
|
$nidhash = JAK_clientlogin::generateRandID(); |
||||||
|
|
||||||
|
} else { |
||||||
|
|
||||||
|
if (isset($datausr['idhash']) && !empty($datausr['idhash']) && $datausr['idhash'] != "NULL") { |
||||||
|
|
||||||
|
// Take old idhash |
||||||
|
$nidhash = $datausr['idhash']; |
||||||
|
|
||||||
|
} else { |
||||||
|
|
||||||
|
// Generate new idhash |
||||||
|
$nidhash = JAK_clientlogin::generateRandID(); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
// Set session in database |
||||||
|
$jakdb->update("clients", ["session" => session_id(), "idhash" => $nidhash, "logins[+]" => 1, "forgot" => 0, "lastactivity" => time()], ["AND" => ["email" => $email, "password" => $passcrypt, "access" => 1]]); |
||||||
|
|
||||||
|
$_SESSION['jak_lcpc_email'] = $email; |
||||||
|
$_SESSION['jak_lcpc_idhash'] = $nidhash; |
||||||
|
|
||||||
|
// Check if cookies are set previous (wrongly) and delete |
||||||
|
if (isset($_COOKIE['jak_lcpc_cookname']) || isset($_COOKIE['jak_lcpc_cookid'])) { |
||||||
|
|
||||||
|
JAK_base::jakCookie('jak_lcpc_cookname', $email, JAK_COOKIE_TIME, JAK_COOKIE_PATH); |
||||||
|
JAK_base::jakCookie('jak_lcpc_cookid', $nidhash, JAK_COOKIE_TIME, JAK_COOKIE_PATH); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
// Now check if remember is selected and set cookies new... |
||||||
|
if ($remember) { |
||||||
|
|
||||||
|
JAK_base::jakCookie('jak_lcpc_cookname', $email, JAK_COOKIE_TIME, JAK_COOKIE_PATH); |
||||||
|
JAK_base::jakCookie('jak_lcpc_cookid', $nidhash, JAK_COOKIE_TIME, JAK_COOKIE_PATH); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public static function jakConfirmidhash($email, $idhash) { |
||||||
|
|
||||||
|
global $jakdb; |
||||||
|
|
||||||
|
if (isset($email) && !empty($email)) { |
||||||
|
|
||||||
|
$datausr = $jakdb->get("clients", "idhash", ["AND" => ["email" => $email, "access" => 1]]); |
||||||
|
|
||||||
|
if ($datausr) { |
||||||
|
|
||||||
|
$datausr = stripslashes($datausr); |
||||||
|
$idhash = stripslashes($idhash); |
||||||
|
|
||||||
|
/* Validate that userid is correct */ |
||||||
|
if(!is_null($datausr) && $idhash == $datausr) { |
||||||
|
return true; //Success! Username and idhash confirmed |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
return false; |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public static function jakUserinfo($email) { |
||||||
|
|
||||||
|
global $jakdb; |
||||||
|
$datauinfo = $jakdb->get("clients", "*", ["AND" => ["email" => $email, "access" => 1]]); |
||||||
|
if ($datauinfo) { |
||||||
|
return $datauinfo; |
||||||
|
} else { |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public static function jakUpdatelastactivity($clientid) { |
||||||
|
|
||||||
|
global $jakdb; |
||||||
|
if (is_numeric($clientid)) $jakdb->update("clients", ["lastactivity" => time()], ["id" => $clientid]); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public static function jakForgotpassword($email, $time) { |
||||||
|
|
||||||
|
global $jakdb; |
||||||
|
if ($jakdb->has("clients", ["AND" => ["email" => $email, "access" => 1]])) { |
||||||
|
if ($time != 0) $jakdb->update("clients", ["forgot" => $time], ["email" => $email]); |
||||||
|
return true; |
||||||
|
} else { |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public static function jakForgotactive($forgotid) { |
||||||
|
|
||||||
|
global $jakdb; |
||||||
|
if ($jakdb->has("clients", ["AND" => ["forgot" => $forgotid, "access" => 1]])) { |
||||||
|
return true; |
||||||
|
} else |
||||||
|
return false; |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public static function jakForgotcheckuser($email, $forgotid) { |
||||||
|
|
||||||
|
global $jakdb; |
||||||
|
if ($jakdb->has("clients", ["AND" => ["email" => $email, "forgot" => $forgotid, "access" => 1]])) { |
||||||
|
return true; |
||||||
|
} else |
||||||
|
return false; |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public static function jakWriteloginlog($email, $url, $ip, $agent, $success) { |
||||||
|
|
||||||
|
global $jakdb; |
||||||
|
if ($success == 1) { |
||||||
|
$jakdb->update("loginlog", ["access" => 1], ["AND" => ["ip" => $ip, "time" => $jakdb->raw("NOW()")]]); |
||||||
|
} else { |
||||||
|
$jakdb->insert("loginlog", ["name" => $email, "fromwhere" => $url, "usragent" => $agent, "ip" => $ip, "time" => $jakdb->raw("NOW()"), "access" => 0]); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public static function jakLogout($userid) { |
||||||
|
|
||||||
|
global $jakdb; |
||||||
|
|
||||||
|
// Delete cookies from this page |
||||||
|
JAK_base::jakCookie('jak_lcpc_cookname', '', -JAK_COOKIE_TIME, JAK_COOKIE_PATH); |
||||||
|
JAK_base::jakCookie('jak_lcpc_cookid', '', -JAK_COOKIE_TIME, JAK_COOKIE_PATH); |
||||||
|
|
||||||
|
// Update Database to session NULL |
||||||
|
$jakdb->update("clients", ["session" => $jakdb->raw("NULL"), "idhash" => $jakdb->raw("NULL")], ["id" => $userid]); |
||||||
|
|
||||||
|
// Unset the main sessions |
||||||
|
unset($_SESSION['jak_lcpc_email']); |
||||||
|
unset($_SESSION['jak_lcpc_idhash']); |
||||||
|
unset($_SESSION['jak_lcpc_lang']); |
||||||
|
|
||||||
|
// Destroy session and generate new one for that user |
||||||
|
session_destroy(); |
||||||
|
|
||||||
|
// Start new session |
||||||
|
session_start(); |
||||||
|
session_regenerate_id(); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public static function jakLogoutRest($userid) { |
||||||
|
|
||||||
|
global $jakdb; |
||||||
|
|
||||||
|
// Update Database to session NULL |
||||||
|
$jakdb->update("clients", ["session" => $jakdb->raw("NULL"), "idhash" => $jakdb->raw("NULL")], ["id" => $userid]); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public static function generateRandStr($length) { |
||||||
|
$randstr = ""; |
||||||
|
for($i=0; $i<$length; $i++){ |
||||||
|
$randnum = mt_rand(0,61); |
||||||
|
if($randnum < 10){ |
||||||
|
$randstr .= chr($randnum+48); |
||||||
|
}else if($randnum < 36){ |
||||||
|
$randstr .= chr($randnum+55); |
||||||
|
}else{ |
||||||
|
$randstr .= chr($randnum+61); |
||||||
|
} |
||||||
|
} |
||||||
|
return $randstr; |
||||||
|
} |
||||||
|
|
||||||
|
private static function generateRandID() { |
||||||
|
return md5(JAK_clientlogin::generateRandStr(16)); |
||||||
|
} |
||||||
|
} |
||||||
|
?> |
@ -0,0 +1,263 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
/*===============================================*\ |
||||||
|
|| ############################################# || |
||||||
|
|| # JAKWEB.CH / Version 1.0.1 # || |
||||||
|
|| # ----------------------------------------- # || |
||||||
|
|| # Copyright 2019 JAKWEB All Rights Reserved # || |
||||||
|
|| ############################################# || |
||||||
|
\*===============================================*/ |
||||||
|
|
||||||
|
class JAK_comment |
||||||
|
{ |
||||||
|
private $data = array(); |
||||||
|
|
||||||
|
// Get the lang into the class |
||||||
|
|
||||||
|
public function __construct($id, $field, $var, $ptime, $pdate, $admin, $nested = true) { |
||||||
|
/* |
||||||
|
/ The constructor |
||||||
|
*/ |
||||||
|
|
||||||
|
global $jakdb; |
||||||
|
$getID = $jakdata = array(); |
||||||
|
if ($admin) { |
||||||
|
$result = $jakdb->select("blogcomments", ["[>]user" => ["operatorid" => "id"], "[>]clients" => ["clientid" => "id"]], ["blogcomments.id", "blogcomments.commentid", "blogcomments.message", "blogcomments.votes", "blogcomments.approve", "blogcomments.time", "blogcomments.session", "user.id(oid)", "user.name(oname)", "user.picture(opicture)", "clients.id(cid)", "clients.name(cname)", "clients.picture(cpicture)"], ["blogcomments.".$field => $id]); |
||||||
|
} else { |
||||||
|
$result = $jakdb->select("blogcomments", ["[>]user" => ["operatorid" => "id"], "[>]clients" => ["clientid" => "id"]], ["blogcomments.id", "blogcomments.commentid", "blogcomments.message", "blogcomments.votes", "blogcomments.approve", "blogcomments.time", "blogcomments.session", "user.id(oid)", "user.name(oname)", "user.picture(opicture)", "clients.id(cid)", "clients.name(cname)", "clients.picture(cpicture)"], ["AND" => ["OR" => ["blogcomments.session" => session_id(), "blogcomments.approve" => 1], "blogcomments.".$field => $id]]); |
||||||
|
} |
||||||
|
|
||||||
|
if (isset($result) && !empty($result)) foreach ($result as $row) { |
||||||
|
|
||||||
|
if ($row['oid'] && $row['opicture'] && $row['opicture'] != "/standard.jpg") { |
||||||
|
$row['avatar'] = BASE_URL.JAK_FILES_DIRECTORY.$row['opicture']; |
||||||
|
} elseif ($row['cid'] && $row['cpicture'] && $row['cpicture'] != "/standard.jpg") { |
||||||
|
$row['avatar'] = BASE_URL.JAK_FILES_DIRECTORY.'/'.$row['cpicture']; |
||||||
|
} else { |
||||||
|
$row['avatar'] = BASE_URL.JAK_FILES_DIRECTORY.'/standard.jpg'; |
||||||
|
} |
||||||
|
|
||||||
|
$row['username'] = ($row['oname'] ? $row['oname'] : $row['cname']); |
||||||
|
|
||||||
|
$row['created'] = JAK_base::jakTimesince($row['time'], $ptime, $pdate); |
||||||
|
|
||||||
|
// Sanitize the message |
||||||
|
$row["message"] = jak_secure_site($row['message']); |
||||||
|
|
||||||
|
// There should be always a varname in categories and check if seo is valid |
||||||
|
$row["parseurl1"] = JAK_rewrite::jakParseurl($var, 'del', $row['id']); |
||||||
|
$row["parseurl2"] = JAK_rewrite::jakParseurl($var, 'report', $row['id']); |
||||||
|
|
||||||
|
// collect each record into $jakdata |
||||||
|
$jakdata[] = $row; |
||||||
|
|
||||||
|
// Do we have nested comments |
||||||
|
if ($nested) $getID = $row["id"]; |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
// now we go nested because we have a reply |
||||||
|
if ($nested && !empty($getID)) { |
||||||
|
|
||||||
|
if ($admin) { |
||||||
|
$resnes = $jakdb->select("blogcomments", ["[>]user" => ["operatorid" => "id"], "[>]clients" => ["clientid" => "id"]], ["blogcomments.id", "blogcomments.commentid", "blogcomments.message", "blogcomments.votes", "blogcomments.approve", "blogcomments.time", "blogcomments.session", "user.id(oid)", "user.name(oname)", "user.picture(opicture)", "clients.id(cid)", "clients.name(cname)", "clients.picture(cpicture)"], ["blogcomments.commentid" => [$getID]]); |
||||||
|
} else { |
||||||
|
$resnes = $jakdb->select("blogcomments", ["[>]user" => ["operatorid" => "id"], "[>]clients" => ["clientid" => "id"]], ["blogcomments.id", "blogcomments.commentid", "blogcomments.message", "blogcomments.votes", "blogcomments.approve", "blogcomments.time", "blogcomments.session", "user.id(oid)", "user.name(oname)", "user.picture(opicture)", "clients.id(cid)", "clients.name(cname)", "clients.picture(cpicture)"], ["AND" => ["OR" => ["blogcomments.session" => session_id(), "blogcomments.approve" => 1], "blogcomments.commentid" => [$getID]]]); |
||||||
|
} |
||||||
|
|
||||||
|
if (isset($resnes) && !empty($resnes)) foreach ($resnes as $nes) { |
||||||
|
|
||||||
|
if ($nes['oid'] && $nes['opicture'] && $nes['opicture'] != "/standard.jpg") { |
||||||
|
$nes['avatar'] = BASE_URL.JAK_FILES_DIRECTORY.$nes['opicture']; |
||||||
|
} elseif ($row['cid'] && $nes['cpicture'] && $nes['cpicture'] != "/standard.jpg") { |
||||||
|
$nes['avatar'] = BASE_URL.JAK_FILES_DIRECTORY.'/'.$nes['cpicture']; |
||||||
|
} else { |
||||||
|
$nes['avatar'] = BASE_URL.JAK_FILES_DIRECTORY.'/standard.jpg'; |
||||||
|
} |
||||||
|
|
||||||
|
$nes['username'] = ($nes['oname'] ? $nes['oname'] : $nes['cname']); |
||||||
|
|
||||||
|
$nes['created'] = JAK_base::jakTimesince($nes['time'], $ptime, $pdate, $timeago); |
||||||
|
|
||||||
|
// Sanitize the message |
||||||
|
$nes["message"] = jak_secure_site($nes['message']); |
||||||
|
|
||||||
|
// There should be always a varname in categories and check if seo is valid |
||||||
|
$nes["parseurl1"] = JAK_rewrite::jakParseurl($var, 'del', $nes['id']); |
||||||
|
$nes["parseurl2"] = JAK_rewrite::jakParseurl($var, 'report', $nes['id']); |
||||||
|
|
||||||
|
// collect each record into $jakdata |
||||||
|
$jakdata[] = $nes; |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
$this->data = $jakdata; |
||||||
|
} |
||||||
|
|
||||||
|
public function get_comments() |
||||||
|
{ |
||||||
|
|
||||||
|
// Setting up an alias, so we don't have to write $this->data every time: |
||||||
|
$d = &$this->data; |
||||||
|
|
||||||
|
return $d; |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public function get_commentajax($lang) { |
||||||
|
|
||||||
|
foreach($this->data as $d) { |
||||||
|
|
||||||
|
if ($d['oid'] && $d['opicture'] && $d['opicture'] != '/standard.jpg') { |
||||||
|
$avatar = '<img src="'.str_replace("class/", "", BASE_URL).JAK_FILES_DIRECTORY.$d['opicture'].'" alt="avatar">'; |
||||||
|
} elseif ($d['cid'] && $d['cpicture'] && $d['cpicture'] != '/standard.jpg') { |
||||||
|
$avatar = '<img src="'.str_replace("class/", "", BASE_URL).JAK_FILES_DIRECTORY.'/'.$d['cpicture'].'" alt="avatar">'; |
||||||
|
} else { |
||||||
|
$avatar = '<img src="'.str_replace("class/", "", BASE_URL).JAK_FILES_DIRECTORY.'/standard.jpg" alt="avatar">'; |
||||||
|
} |
||||||
|
|
||||||
|
$approve = ""; |
||||||
|
if ($d['approve'] == 0) { |
||||||
|
$approve = '<div class="alert alert-info">'.$lang.'</div>'; |
||||||
|
} |
||||||
|
|
||||||
|
return '<div class="comment-wrapper"> |
||||||
|
<div class="comment-author">'.$avatar.' <span class="comment-user">'.($d['cname'] ? $d['cname'] : $d['oname']).'</span> <span class="comment-date">'.$d['created'].'</span></div> |
||||||
|
<div class="com">'.stripslashes($d['message']).$approve.'</div> |
||||||
|
</div>'; |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public function get_commentajax_modern($lang) { |
||||||
|
|
||||||
|
foreach($this->data as $d) { |
||||||
|
|
||||||
|
if ($d['oid'] && $d['opicture'] && $d['opicture'] != '/standard.jpg') { |
||||||
|
$avatar = str_replace("class/", "", BASE_URL).JAK_FILES_DIRECTORY.'/operator/'.$d['opicture']; |
||||||
|
} elseif ($d['cid'] && $d['cpicture'] && $d['cpicture'] != '/standard.jpg') { |
||||||
|
$avatar = str_replace("class/", "", BASE_URL).JAK_FILES_DIRECTORY.'/'.$d['cpicture']; |
||||||
|
} else { |
||||||
|
$avatar = str_replace("class/", "", BASE_URL).JAK_FILES_DIRECTORY.'/standard.jpg'; |
||||||
|
} |
||||||
|
|
||||||
|
$approve = ""; |
||||||
|
if ($d['approve'] == 0) { |
||||||
|
$approve = '<div class="alert alert-info">'.$lang.'</div>'; |
||||||
|
} |
||||||
|
|
||||||
|
return '<div class="media"> |
||||||
|
<a class="float-left" href="javascript:void(0)"> |
||||||
|
<div class="avatar"> |
||||||
|
<img class="media-object" src="'.$avatar.'" alt="'.($d['cname'] ? $d['cname'] : $d['oname']).'"> |
||||||
|
</div> |
||||||
|
</a> |
||||||
|
<div class="media-body"> |
||||||
|
<h4 class="media-heading">'.($d['cname'] ? $d['cname'] : $d['oname']).' |
||||||
|
<small>'.$d['created'].'</small> |
||||||
|
</h4> |
||||||
|
<h6 class="text-muted"></h6> |
||||||
|
'.stripslashes($d['message']).$approve.' |
||||||
|
</div> |
||||||
|
</div>'; |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public function get_total() { |
||||||
|
// Setting up an alias, so we don't have to write $this->data every time: |
||||||
|
$d = $this->data; |
||||||
|
|
||||||
|
if ($d) { |
||||||
|
|
||||||
|
foreach($d as $t) { |
||||||
|
$total[] = $t['id']; |
||||||
|
} |
||||||
|
|
||||||
|
// get the total user in one var. |
||||||
|
$total = count($total, COUNT_RECURSIVE); |
||||||
|
|
||||||
|
} else { |
||||||
|
|
||||||
|
$total = 0; |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
return $total; |
||||||
|
} |
||||||
|
|
||||||
|
public static function validate_form(&$arr, $maxpost, $epost, $maxtxt) { |
||||||
|
/* |
||||||
|
/ This method is used to validate the data sent via AJAX. |
||||||
|
/ |
||||||
|
/ It return true/false depending on whether the data is valid, and populates |
||||||
|
/ the $arr array passed as a paremter (notice the ampersand above) with |
||||||
|
/ either the valid input data, or the error messages. |
||||||
|
*/ |
||||||
|
|
||||||
|
global $jkv; |
||||||
|
$errors = array(); |
||||||
|
$data = array(); |
||||||
|
|
||||||
|
// Using the filter with a custom callback function: |
||||||
|
if (!($data['bmessage'] = filter_input(INPUT_POST, 'bmessage', FILTER_CALLBACK, array('options'=>'JAK_comment::validate_text')))) { |
||||||
|
$errors['bmesssage'] = $epost; |
||||||
|
} |
||||||
|
|
||||||
|
// Subcomments |
||||||
|
if (filter_input(INPUT_POST , 'comanswerid')) { |
||||||
|
$data['comanswerid'] = filter_input(INPUT_POST , 'comanswerid'); |
||||||
|
} |
||||||
|
|
||||||
|
// Subcomments |
||||||
|
if (filter_input(INPUT_POST , 'editpostid')) { |
||||||
|
$data['editpostid'] = filter_input(INPUT_POST , 'editpostid'); |
||||||
|
} |
||||||
|
|
||||||
|
// Count comment charactars |
||||||
|
if (!empty($maxpost)) { |
||||||
|
$countI = strlen($data['bmessage']); |
||||||
|
|
||||||
|
if ($countI > $maxpost) { |
||||||
|
$errors['bmessage'] = $emaxpost.$maxpost.' '.sprintf($maxtxt,$countI); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
if (!empty($errors)) { |
||||||
|
|
||||||
|
// If there are errors, copy the $errors array to $arr: |
||||||
|
$arr = $errors; |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
// If the data is valid, sanitize all the data and copy it to $arr: |
||||||
|
|
||||||
|
foreach($data as $k=>$v) { |
||||||
|
$arr[$k] = $v; |
||||||
|
} |
||||||
|
|
||||||
|
return true; |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
private static function validate_text($str) |
||||||
|
{ |
||||||
|
/* |
||||||
|
/ This method is used internally as a FILTER_CALLBACK |
||||||
|
*/ |
||||||
|
|
||||||
|
if (mb_strlen($str, 'utf8') < 1) return false; |
||||||
|
|
||||||
|
$str = htmlspecialchars($str); |
||||||
|
|
||||||
|
// Remove the new line characters that are left |
||||||
|
$str = str_replace(array(chr(10), chr(13)), '', $str); |
||||||
|
|
||||||
|
return $str; |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
?> |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,7 @@ |
|||||||
|
<?php |
||||||
|
require_once(__DIR__ . '/emoji/RulesetInterface.php'); |
||||||
|
require_once(__DIR__ . '/emoji/ClientInterface.php'); |
||||||
|
require_once(__DIR__ . '/emoji/Client.php'); |
||||||
|
require_once(__DIR__ . '/emoji/Ruleset.php'); |
||||||
|
require_once(__DIR__ . '/emoji/Emojione.php'); |
||||||
|
?> |
@ -0,0 +1,47 @@ |
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*===============================================*\ |
||||||
|
|| ############################################# || |
||||||
|
|| # JAKWEB.CH # || |
||||||
|
|| # ----------------------------------------- # || |
||||||
|
|| # Copyright 2019 JAKWEB All Rights Reserved # || |
||||||
|
|| ############################################# || |
||||||
|
\*===============================================*/ |
||||||
|
|
||||||
|
class emailExport { |
||||||
|
|
||||||
|
public static function createFile($arrays, $filename = 'chat_emails.csv') { |
||||||
|
|
||||||
|
$string = ''; |
||||||
|
$b = 0; |
||||||
|
|
||||||
|
foreach($arrays as $array) { |
||||||
|
$val_array = array(); |
||||||
|
$key_array = array(); |
||||||
|
foreach($array as $key => $val) { |
||||||
|
$key_array[] = $key; |
||||||
|
$val = str_replace('"', '""', $val); |
||||||
|
$val_array[] = "\"$val\""; |
||||||
|
} |
||||||
|
if($b == 0) { |
||||||
|
$string .= implode(",", $key_array)."\n"; |
||||||
|
} |
||||||
|
$string .= implode(",", $val_array)."\n"; |
||||||
|
$b++; |
||||||
|
} |
||||||
|
emailExport::downloadFile($string, $filename); |
||||||
|
} |
||||||
|
|
||||||
|
private static function downloadFile($string, $filename) { |
||||||
|
header("Pragma: public"); |
||||||
|
header("Expires: 0"); |
||||||
|
header("Cache-Control: private"); |
||||||
|
header("Content-type: application/octet-stream"); |
||||||
|
header("Content-Disposition: attachment; filename=$filename"); |
||||||
|
header("Accept-Ranges: bytes"); |
||||||
|
echo $string; |
||||||
|
exit; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
?> |
@ -0,0 +1,734 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
/** |
||||||
|
* Helper class for imap access |
||||||
|
* |
||||||
|
* @package protocols |
||||||
|
* @copyright Copyright (c) Tobias Zeising (http://www.aditu.de) |
||||||
|
* @license GPLv3 (http://www.gnu.org/licenses/gpl-3.0.html) |
||||||
|
* @author Tobias Zeising <tobias.zeising@aditu.de> |
||||||
|
* @modified JAKWEB / Version 1.2 |
||||||
|
*/ |
||||||
|
class Imap { |
||||||
|
|
||||||
|
/** |
||||||
|
* imap connection |
||||||
|
*/ |
||||||
|
protected $imap = false; |
||||||
|
|
||||||
|
/** |
||||||
|
* mailbox url string |
||||||
|
*/ |
||||||
|
protected $mailbox = ""; |
||||||
|
|
||||||
|
/** |
||||||
|
* currentfolder |
||||||
|
*/ |
||||||
|
protected $folder = "Inbox"; |
||||||
|
|
||||||
|
/** |
||||||
|
* initialize imap helper |
||||||
|
* |
||||||
|
* @return void |
||||||
|
* @param $mailbox imap_open string |
||||||
|
* @param $username |
||||||
|
* @param $password |
||||||
|
* @param $encryption ssl or tls |
||||||
|
*/ |
||||||
|
public function __construct($mailbox, $username, $password, $encryption = false) { |
||||||
|
$enc = ''; |
||||||
|
if($encryption!=null && isset($encryption) && $encryption=='ssl') |
||||||
|
$enc = '/imap/ssl/novalidate-cert'; |
||||||
|
else if($encryption!=null && isset($encryption) && $encryption=='tls') |
||||||
|
$enc = '/imap/tls/novalidate-cert'; |
||||||
|
$this->mailbox = "{" . $mailbox . $enc . "}"; |
||||||
|
$this->imap = @imap_open($this->mailbox, $username, $password); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* close connection |
||||||
|
*/ |
||||||
|
function __destruct() { |
||||||
|
if($this->imap !== false) imap_close($this->imap); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* returns true after successfull connection |
||||||
|
* |
||||||
|
* @return bool true on success |
||||||
|
*/ |
||||||
|
public function isConnected() { |
||||||
|
return $this->imap !== false; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* returns last imap error |
||||||
|
* |
||||||
|
* @return string error message |
||||||
|
*/ |
||||||
|
public function getError() { |
||||||
|
return imap_last_error(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* select given folder |
||||||
|
* |
||||||
|
* @return bool successfull opened folder |
||||||
|
* @param $folder name |
||||||
|
*/ |
||||||
|
public function selectFolder($folder) { |
||||||
|
$result = imap_reopen($this->imap, $this->mailbox . $folder); |
||||||
|
if($result === true) |
||||||
|
$this->folder = $folder; |
||||||
|
return $result; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* returns all available folders |
||||||
|
* |
||||||
|
* @return array with foldernames |
||||||
|
*/ |
||||||
|
public function getFolders() { |
||||||
|
$folders = imap_list($this->imap, $this->mailbox, "*"); |
||||||
|
return str_replace($this->mailbox, "", $folders); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* returns the number of messages in the current folder |
||||||
|
* |
||||||
|
* @return int message count |
||||||
|
*/ |
||||||
|
public function countMessages() { |
||||||
|
return imap_num_msg($this->imap); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* returns the number of unread messages in the current folder |
||||||
|
* |
||||||
|
* @return int message count |
||||||
|
*/ |
||||||
|
public function countUnreadMessages() { |
||||||
|
$result = imap_search($this->imap, 'UNSEEN'); |
||||||
|
if($result===false) |
||||||
|
return 0; |
||||||
|
return count($result); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* returns unseen emails in the current folder |
||||||
|
* |
||||||
|
* @return array messages |
||||||
|
* @param $withbody without body |
||||||
|
*/ |
||||||
|
public function getUnreadMessages($withbody=true){ |
||||||
|
$emails = array(); |
||||||
|
$result = imap_search($this->imap, 'UNSEEN'); |
||||||
|
if($result){ |
||||||
|
foreach($result as $k=>$i){ |
||||||
|
$emails[]= $this->formatMessage($i, $withbody); |
||||||
|
} |
||||||
|
} |
||||||
|
return $emails; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* returns all emails in the current folder |
||||||
|
* |
||||||
|
* @return array messages |
||||||
|
* @param $withbody without body |
||||||
|
*/ |
||||||
|
public function getMessages($withbody = true) { |
||||||
|
$count = $this->countMessages(); |
||||||
|
$emails = array(); |
||||||
|
for($i=1;$i<=$count;$i++) { |
||||||
|
$emails[]= $this->formatMessage($i, $withbody); |
||||||
|
} |
||||||
|
|
||||||
|
// sort emails descending by date |
||||||
|
// usort($emails, function($a, $b) { |
||||||
|
// try { |
||||||
|
// $datea = new \DateTime($a['date']); |
||||||
|
// $dateb = new \DateTime($b['date']); |
||||||
|
// } catch(\Exception $e) { |
||||||
|
// return 0; |
||||||
|
// } |
||||||
|
// if ($datea == $dateb) |
||||||
|
// return 0; |
||||||
|
// return $datea < $dateb ? 1 : -1; |
||||||
|
// }); |
||||||
|
|
||||||
|
return $emails; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* returns email by given id |
||||||
|
* |
||||||
|
* @return array messages |
||||||
|
* @param $id |
||||||
|
* @param $withbody without body |
||||||
|
*/ |
||||||
|
public function getMessage($id, $withbody = true) { |
||||||
|
return $this->formatMessage($id, $withbody); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @param $id |
||||||
|
* @param bool $withbody |
||||||
|
* @return array |
||||||
|
*/ |
||||||
|
protected function formatMessage($id, $withbody=true){ |
||||||
|
$header = imap_headerinfo($this->imap, $id); |
||||||
|
|
||||||
|
// fetch unique uid |
||||||
|
$uid = imap_uid($this->imap, $id); |
||||||
|
|
||||||
|
// Get the header from simply |
||||||
|
$fromname = $fromaddress = ''; |
||||||
|
foreach ($header->from as $id => $object) { |
||||||
|
$fromname = $object->personal; |
||||||
|
$fromaddress = $object->mailbox . "@" . $object->host; |
||||||
|
} |
||||||
|
|
||||||
|
// get email data |
||||||
|
$subject = ''; |
||||||
|
if ( isset($header->subject) && strlen($header->subject) > 0 ) { |
||||||
|
foreach(imap_mime_header_decode($header->subject) as $obj){ |
||||||
|
$subject .= $obj->text; |
||||||
|
} |
||||||
|
} |
||||||
|
$subject = $this->convertToUtf8($subject); |
||||||
|
$email = array( |
||||||
|
'to' => isset($header->to) ? $this->arrayToAddress($header->to) : '', |
||||||
|
'from' => $this->convertToUtf8($fromaddress), |
||||||
|
'fromname' => $this->convertToUtf8($fromname), |
||||||
|
'date' => $header->date, |
||||||
|
'subject' => $subject, |
||||||
|
'uid' => $uid, |
||||||
|
'unread' => strlen(trim($header->Unseen))>0, |
||||||
|
'answered' => strlen(trim($header->Answered))>0, |
||||||
|
'deleted' => strlen(trim($header->Deleted))>0 |
||||||
|
); |
||||||
|
if(isset($header->cc)) |
||||||
|
$email['cc'] = $this->arrayToAddress($header->cc); |
||||||
|
|
||||||
|
// get email body |
||||||
|
if($withbody===true) { |
||||||
|
$body = $this->getBody($uid); |
||||||
|
$email['body'] = $body['body']; |
||||||
|
$email['html'] = $body['html']; |
||||||
|
} |
||||||
|
|
||||||
|
return $email; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* delete given message |
||||||
|
* |
||||||
|
* @return bool success or not |
||||||
|
* @param $id of the message |
||||||
|
*/ |
||||||
|
public function deleteMessage($id) { |
||||||
|
return $this->deleteMessages(array($id)); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* delete messages |
||||||
|
* |
||||||
|
* @return bool success or not |
||||||
|
* @param $ids array of ids |
||||||
|
*/ |
||||||
|
public function deleteMessages($ids) { |
||||||
|
if( imap_mail_move($this->imap, implode(",", $ids), $this->getTrash(), CP_UID) == false) |
||||||
|
return false; |
||||||
|
return imap_expunge($this->imap); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* move given message in new folder |
||||||
|
* |
||||||
|
* @return bool success or not |
||||||
|
* @param $id of the message |
||||||
|
* @param $target new folder |
||||||
|
*/ |
||||||
|
public function moveMessage($id, $target) { |
||||||
|
return $this->moveMessages(array($id), $target); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* move given message in new folder |
||||||
|
* |
||||||
|
* @return bool success or not |
||||||
|
* @param $ids array of message ids |
||||||
|
* @param $target new folder |
||||||
|
*/ |
||||||
|
public function moveMessages($ids, $target) { |
||||||
|
if(imap_mail_move($this->imap, implode(",", $ids), $target, CP_UID)===false) |
||||||
|
return false; |
||||||
|
return imap_expunge($this->imap); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* mark message as read |
||||||
|
* |
||||||
|
* @return bool success or not |
||||||
|
* @param $id of the message |
||||||
|
* @param $seen true = message is read, false = message is unread |
||||||
|
*/ |
||||||
|
public function setUnseenMessage($id, $seen = true) { |
||||||
|
$header = $this->getMessageHeader($id); |
||||||
|
if($header==false) |
||||||
|
return false; |
||||||
|
|
||||||
|
$flags = ""; |
||||||
|
$flags .= (strlen(trim($header->Answered))>0 ? "\\Answered " : ''); |
||||||
|
$flags .= (strlen(trim($header->Flagged))>0 ? "\\Flagged " : ''); |
||||||
|
$flags .= (strlen(trim($header->Deleted))>0 ? "\\Deleted " : ''); |
||||||
|
$flags .= (strlen(trim($header->Draft))>0 ? "\\Draft " : ''); |
||||||
|
|
||||||
|
$flags .= (($seen == true) ? '\\Seen ' : ' '); |
||||||
|
//echo "\n<br />".$id.": ".$flags; |
||||||
|
imap_clearflag_full($this->imap, $id, '\\Seen', ST_UID); |
||||||
|
return imap_setflag_full($this->imap, $id, trim($flags), ST_UID); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* return content of messages attachment |
||||||
|
* |
||||||
|
* @return binary attachment |
||||||
|
* @param $id of the message |
||||||
|
* @param $index of the attachment (default: first attachment) |
||||||
|
*/ |
||||||
|
public function getAttachment($id, $structureToExplore = null) { |
||||||
|
|
||||||
|
$messageIndex = imap_msgno($this->imap, $id); |
||||||
|
if ($structureToExplore != null) { |
||||||
|
$structure = $structureToExplore; |
||||||
|
} else { |
||||||
|
$structure = imap_fetchstructure($this->imap, $messageIndex); |
||||||
|
} |
||||||
|
|
||||||
|
$attachments = array(); |
||||||
|
|
||||||
|
if (isset($structure->parts) && count($structure->parts)) { |
||||||
|
|
||||||
|
for($i = 0; $i < count($structure->parts); $i++) { |
||||||
|
|
||||||
|
if ($structure->parts && is_array($structure->parts[$i]) && count($structure->parts[$i])>0) { |
||||||
|
$toAdd = $this->getAttachment($id, $structure->parts[$i]); |
||||||
|
if (count($toAdd)>0) { |
||||||
|
foreach ($toAdd as $att) array_push($attachments, $att); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
$attachment = array( |
||||||
|
'is_attachment' => false, |
||||||
|
'filename' => '', |
||||||
|
'name' => '', |
||||||
|
'attachment' => '' |
||||||
|
); |
||||||
|
|
||||||
|
if ($structure->parts[$i]->ifdparameters) { |
||||||
|
foreach($structure->parts[$i]->dparameters as $object) { |
||||||
|
if(strtolower($object->attribute) == 'filename') { |
||||||
|
$attachment['is_attachment'] = true; |
||||||
|
$attachment['filename'] = $object->value; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
if ($structure->parts[$i]->ifparameters) { |
||||||
|
foreach($structure->parts[$i]->parameters as $object) { |
||||||
|
if(strtolower($object->attribute) == 'name') { |
||||||
|
$attachment['is_attachment'] = true; |
||||||
|
$attachment['name'] = $object->value; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
if ($attachment['is_attachment']) { |
||||||
|
// get attachment body |
||||||
|
|
||||||
|
// First we try the html body |
||||||
|
$message = imap_fetchbody($this->imap, $messageIndex, $i+1.2); |
||||||
|
|
||||||
|
if (empty($message)) { |
||||||
|
// Then we try the text body |
||||||
|
$message = imap_fetchbody($this->imap, $messageIndex, $i+1.1); |
||||||
|
} |
||||||
|
|
||||||
|
if (empty($message)) { |
||||||
|
// Then we try the text body |
||||||
|
$message = imap_fetchbody($this->imap, $messageIndex, $i+1); |
||||||
|
} |
||||||
|
|
||||||
|
switch ($structure->parts[$i]->encoding) { |
||||||
|
case 0: |
||||||
|
case 1: |
||||||
|
$message = imap_8bit($message); |
||||||
|
break; |
||||||
|
case 2: |
||||||
|
$message = imap_binary($message); |
||||||
|
break; |
||||||
|
case 3: |
||||||
|
$message = base64_decode($message); |
||||||
|
break; |
||||||
|
case 4: |
||||||
|
$message = quoted_printable_decode($message); |
||||||
|
break; |
||||||
|
case 5: |
||||||
|
$message = imap_base64($message); |
||||||
|
break; |
||||||
|
} |
||||||
|
|
||||||
|
$attachment['attachment'] = $message; |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
array_push($attachments,$attachment); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
return $attachments; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* add new folder |
||||||
|
* |
||||||
|
* @return bool success or not |
||||||
|
* @param $name of the folder |
||||||
|
* @param $subscribe immediately subscribe to folder |
||||||
|
*/ |
||||||
|
public function addFolder($name, $subscribe = false) { |
||||||
|
$success = imap_createmailbox($this->imap, $this->mailbox . $name); |
||||||
|
|
||||||
|
if ($success && $subscribe) { |
||||||
|
$success = imap_subscribe($this->imap, $this->mailbox . $name); |
||||||
|
} |
||||||
|
|
||||||
|
return $success; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* remove folder |
||||||
|
* |
||||||
|
* @return bool success or not |
||||||
|
* @param $name of the folder |
||||||
|
*/ |
||||||
|
public function removeFolder($name) { |
||||||
|
return imap_deletemailbox($this->imap, $this->mailbox . $name); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* rename folder |
||||||
|
* |
||||||
|
* @return bool success or not |
||||||
|
* @param $name of the folder |
||||||
|
* @param $newname of the folder |
||||||
|
*/ |
||||||
|
public function renameFolder($name, $newname) { |
||||||
|
return imap_renamemailbox($this->imap, $this->mailbox . $name, $this->mailbox . $newname); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* clean folder content of selected folder |
||||||
|
* |
||||||
|
* @return bool success or not |
||||||
|
*/ |
||||||
|
public function purge() { |
||||||
|
// delete trash and spam |
||||||
|
if($this->folder==$this->getTrash() || strtolower($this->folder)=="spam") { |
||||||
|
if(imap_delete($this->imap,'1:*')===false) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
return imap_expunge($this->imap); |
||||||
|
|
||||||
|
// move others to trash |
||||||
|
} else { |
||||||
|
if( imap_mail_move($this->imap,'1:*', $this->getTrash()) == false) |
||||||
|
return false; |
||||||
|
return imap_expunge($this->imap); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* returns all email addresses |
||||||
|
* |
||||||
|
* @return array with all email addresses or false on error |
||||||
|
*/ |
||||||
|
public function getAllEmailAddresses() { |
||||||
|
$saveCurrentFolder = $this->folder; |
||||||
|
$emails = array(); |
||||||
|
foreach($this->getFolders() as $folder) { |
||||||
|
$this->selectFolder($folder); |
||||||
|
foreach($this->getMessages(false) as $message) { |
||||||
|
$emails[] = $message['from']; |
||||||
|
$emails = array_merge($emails, $message['to']); |
||||||
|
if(isset($message['cc'])) |
||||||
|
$emails = array_merge($emails, $message['cc']); |
||||||
|
} |
||||||
|
} |
||||||
|
$this->selectFolder($saveCurrentFolder); |
||||||
|
return array_unique($emails); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* save email in sent |
||||||
|
* |
||||||
|
* @return void |
||||||
|
* @param $header |
||||||
|
* @param $body |
||||||
|
*/ |
||||||
|
public function saveMessageInSent($header, $body) { |
||||||
|
return imap_append($this->imap, $this->mailbox . $this->getSent(), $header . "\r\n" . $body . "\r\n", "\\Seen"); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* explicitly close imap connection |
||||||
|
*/ |
||||||
|
public function close() { |
||||||
|
if($this->imap!==false) |
||||||
|
imap_close($this->imap); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// protected helpers |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* get trash folder name or create new trash folder |
||||||
|
* |
||||||
|
* @return trash folder name |
||||||
|
*/ |
||||||
|
protected function getTrash() { |
||||||
|
foreach($this->getFolders() as $folder) { |
||||||
|
if(strtolower($folder)==="trash" || strtolower($folder)==="papierkorb") |
||||||
|
return $folder; |
||||||
|
} |
||||||
|
|
||||||
|
// no trash folder found? create one |
||||||
|
$this->addFolder('Trash'); |
||||||
|
|
||||||
|
return 'Trash'; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* get sent folder name or create new sent folder |
||||||
|
* |
||||||
|
* @return sent folder name |
||||||
|
*/ |
||||||
|
protected function getSent() { |
||||||
|
foreach($this->getFolders() as $folder) { |
||||||
|
if(strtolower($folder)==="sent" || strtolower($folder)==="gesendet") |
||||||
|
return $folder; |
||||||
|
} |
||||||
|
|
||||||
|
// no sent folder found? create one |
||||||
|
$this->addFolder('Sent'); |
||||||
|
|
||||||
|
return 'Sent'; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* fetch message by id |
||||||
|
* |
||||||
|
* @return header |
||||||
|
* @param $id of the message |
||||||
|
*/ |
||||||
|
protected function getMessageHeader($id) { |
||||||
|
$count = $this->countMessages(); |
||||||
|
for($i=1;$i<=$count;$i++) { |
||||||
|
$uid = imap_uid($this->imap, $i); |
||||||
|
if($uid==$id) { |
||||||
|
$header = imap_headerinfo($this->imap, $i); |
||||||
|
return $header; |
||||||
|
} |
||||||
|
} |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* convert imap given address in string |
||||||
|
* |
||||||
|
* @return string in format "Name <email@bla.de>" |
||||||
|
* @param $headerinfos the infos given by imap |
||||||
|
*/ |
||||||
|
protected function toAddress($headerinfos) { |
||||||
|
$email = ""; |
||||||
|
$name = ""; |
||||||
|
if(isset($headerinfos->mailbox) && isset($headerinfos->host)) { |
||||||
|
$email = $headerinfos->mailbox . "@" . $headerinfos->host; |
||||||
|
} |
||||||
|
|
||||||
|
if(!empty($headerinfos->personal)) { |
||||||
|
$name = imap_mime_header_decode($headerinfos->personal); |
||||||
|
$name = $name[0]->text; |
||||||
|
} else { |
||||||
|
$name = $email; |
||||||
|
} |
||||||
|
|
||||||
|
$name = $this->convertToUtf8($name); |
||||||
|
|
||||||
|
return $name . " <" . $email . ">"; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* converts imap given array of addresses in strings |
||||||
|
* |
||||||
|
* @return array with strings (e.g. ["Name <email@bla.de>", "Name2 <email2@bla.de>"] |
||||||
|
* @param $addresses imap given addresses as array |
||||||
|
*/ |
||||||
|
protected function arrayToAddress($addresses) { |
||||||
|
$addressesAsString = array(); |
||||||
|
foreach($addresses as $address) { |
||||||
|
$addressesAsString[] = $this->toAddress($address); |
||||||
|
} |
||||||
|
return $addressesAsString; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* returns body of the email. First search for html version of the email, then the plain part. |
||||||
|
* |
||||||
|
* @return string email body |
||||||
|
* @param $uid message id |
||||||
|
*/ |
||||||
|
protected function getBody($uid) { |
||||||
|
$body = $this->get_part($this->imap, $uid, "TEXT/PLAIN"); |
||||||
|
$html = false; |
||||||
|
// if text body is empty, try getting text body |
||||||
|
if ($body == "") { |
||||||
|
$body = $this->get_part($this->imap, $uid, "TEXT/HTML"); |
||||||
|
$html = true; |
||||||
|
} |
||||||
|
$body = $this->convertToUtf8($body); |
||||||
|
return array( 'body' => $body, 'html' => $html); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* convert to utf8 if necessary. |
||||||
|
* |
||||||
|
* @return true or false |
||||||
|
* @param $string utf8 encoded string |
||||||
|
*/ |
||||||
|
protected function convertToUtf8($string) { |
||||||
|
$newString = ''; |
||||||
|
$elements = imap_mime_header_decode($string); |
||||||
|
|
||||||
|
for($i = 0; $i < count($elements); $i++) { |
||||||
|
$newString .= $this->convertStringEncoding($elements[$i]->text); |
||||||
|
} |
||||||
|
return $newString; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Converts a string from one encoding to another. |
||||||
|
* @param string $string |
||||||
|
* @return string Converted string if conversion was successful, or the original string if not |
||||||
|
*/ |
||||||
|
protected function convertStringEncoding($string) { |
||||||
|
|
||||||
|
if (extension_loaded('mbstring') && mb_detect_encoding($string, "UTF-8, ISO-8859-1, GBK")!="UTF-8") { |
||||||
|
$string = utf8_encode($string); |
||||||
|
} |
||||||
|
$string = iconv('UTF-8', 'UTF-8//IGNORE', $string); |
||||||
|
return $string; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* returns a part with a given mimetype |
||||||
|
* taken from http://www.sitepoint.com/exploring-phps-imap-library-2/ |
||||||
|
* |
||||||
|
* @return string email body |
||||||
|
* @param $imap imap stream |
||||||
|
* @param $uid message id |
||||||
|
* @param $mimetype |
||||||
|
*/ |
||||||
|
protected function get_part($imap, $uid, $mimetype, $structure = false, $partNumber = false) { |
||||||
|
if (!$structure) { |
||||||
|
$structure = imap_fetchstructure($imap, $uid, FT_UID); |
||||||
|
} |
||||||
|
if ($structure) { |
||||||
|
if ($mimetype == $this->get_mime_type($structure)) { |
||||||
|
if (!$partNumber) { |
||||||
|
$partNumber = 1; |
||||||
|
} |
||||||
|
$text = imap_fetchbody($imap, $uid, $partNumber, FT_UID | FT_PEEK); |
||||||
|
switch ($structure->encoding) { |
||||||
|
case 3: return imap_base64($text); |
||||||
|
case 4: return imap_qprint($text); |
||||||
|
default: return $text; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// multipart |
||||||
|
if ($structure->type == 1) { |
||||||
|
foreach ($structure->parts as $index => $subStruct) { |
||||||
|
$prefix = ""; |
||||||
|
if ($partNumber) { |
||||||
|
$prefix = $partNumber . "."; |
||||||
|
} |
||||||
|
$data = $this->get_part($imap, $uid, $mimetype, $subStruct, $prefix . ($index + 1)); |
||||||
|
if ($data) { |
||||||
|
return $data; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* extract mimetype |
||||||
|
* taken from http://www.sitepoint.com/exploring-phps-imap-library-2/ |
||||||
|
* |
||||||
|
* @return string mimetype |
||||||
|
* @param $structure |
||||||
|
*/ |
||||||
|
protected function get_mime_type($structure) { |
||||||
|
$primaryMimetype = array("TEXT", "MULTIPART", "MESSAGE", "APPLICATION", "AUDIO", "IMAGE", "VIDEO", "OTHER"); |
||||||
|
|
||||||
|
if ($structure->subtype) { |
||||||
|
return $primaryMimetype[(int)$structure->type] . "/" . $structure->subtype; |
||||||
|
} |
||||||
|
return "TEXT/PLAIN"; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* Return general mailbox statistics |
||||||
|
* |
||||||
|
* @return bool | StdClass object |
||||||
|
*/ |
||||||
|
public function getMailboxStatistics() { |
||||||
|
return $this->isConnected() ? imap_mailboxmsginfo($this->imap) : false ; |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
?> |
@ -0,0 +1,161 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
/*===============================================*\ |
||||||
|
|| ############################################# || |
||||||
|
|| # JAKWEB.CH / Version 2.1.1 # || |
||||||
|
|| # ----------------------------------------- # || |
||||||
|
|| # Copyright 2023 JAKWEB All Rights Reserved # || |
||||||
|
|| ############################################# || |
||||||
|
\*===============================================*/ |
||||||
|
|
||||||
|
include_once 'class.rewrite.php'; |
||||||
|
|
||||||
|
class JAK_base |
||||||
|
{ |
||||||
|
private $data = array(); |
||||||
|
private $usraccesspl = array(); |
||||||
|
private $case; |
||||||
|
private $lsvar; |
||||||
|
private $lsvar1; |
||||||
|
protected $table = '', $itemid = '', $select = '', $where = '', $dseo = ''; |
||||||
|
|
||||||
|
// This constructor can be used for all classes: |
||||||
|
|
||||||
|
public function __construct(array $options){ |
||||||
|
|
||||||
|
foreach($options as $k=>$v){ |
||||||
|
if(isset($this->$k)){ |
||||||
|
$this->$k = $v; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public static function pluralize($count, $text, $plural) { |
||||||
|
return $count . ( ( $count == 1 ) ? ( " $text" ) : ( " {$plural}" ) ); |
||||||
|
} |
||||||
|
|
||||||
|
public static function jakTimesince($mysqlstamp, $date, $time) { |
||||||
|
|
||||||
|
$today = time(); /* Current unix time */ |
||||||
|
if (is_numeric($mysqlstamp)) { |
||||||
|
$unixtime = $mysqlstamp; |
||||||
|
//$mysqlstamp = date('Y-m-d H:i:s', $mysqlstamp); |
||||||
|
} else { |
||||||
|
$unixtime = strtotime($mysqlstamp); |
||||||
|
} |
||||||
|
|
||||||
|
// Return date time |
||||||
|
return date(($date && $time ? $date.' ' : $date).$time, (int)$unixtime); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public static function jakCheckSession($convid, $restoreid) |
||||||
|
{ |
||||||
|
|
||||||
|
global $jakdb; |
||||||
|
if ($jakdb->has("sessions", ["id" => $convid, "uniqueid" => $restoreid, "status" => 1])) { |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public static function jakWriteinCache($file, $content, $extra) { |
||||||
|
|
||||||
|
if ($file && $content) { |
||||||
|
|
||||||
|
if (isset($extra)) { |
||||||
|
file_put_contents($file, $content, FILE_APPEND | LOCK_EX); |
||||||
|
} else { |
||||||
|
file_put_contents($file, $content, LOCK_EX); |
||||||
|
} |
||||||
|
|
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public static function jakAvailableHours($hours,$available) { |
||||||
|
|
||||||
|
$ohours = ""; |
||||||
|
if (isset($hours) && !empty($hours)) $ohours = json_decode($hours, true); |
||||||
|
|
||||||
|
// get the php str |
||||||
|
$dtime = new DateTime($available); |
||||||
|
|
||||||
|
// Days of the week |
||||||
|
$daysaweekid = array(0 => "Mon", 1 => "Tue", 2 => "Wed", 3 => "Thu", 4 => "Fri", 5 => "Sat", 6 => "Sun"); |
||||||
|
|
||||||
|
// Return the correct day |
||||||
|
$day = array_search($dtime->format('D'), $daysaweekid); |
||||||
|
|
||||||
|
$nobh = false; |
||||||
|
|
||||||
|
// Check if the day is active and proceed |
||||||
|
if (isset($ohours[$day]["isActive"]) && !empty($ohours[$day]["isActive"])) { |
||||||
|
|
||||||
|
// Now we need to check the time |
||||||
|
if (!empty($ohours[$day]["timeFrom"]) && !empty($ohours[$day]["timeTill"])) { |
||||||
|
|
||||||
|
if ($ohours[$day]["timeTill"] == "24:00") $ohours[$day]["timeTill"] = "23.59"; |
||||||
|
|
||||||
|
if (($ohours[$day]["timeFrom"] <= $dtime->format('H:i')) && ($ohours[$day]["timeTill"] >= $dtime->format('H:i'))) $nobh = true; |
||||||
|
} |
||||||
|
|
||||||
|
if (!$nobh && !empty($ohours[$day]["timeFroma"]) && !empty($ohours[$day]["timeTilla"])) { |
||||||
|
|
||||||
|
if ($ohours[$day]["timeTilla"] == "24:00") $ohours[$day]["timeTilla"] = "23.59"; |
||||||
|
|
||||||
|
if (($ohours[$day]["timeFroma"] <= $dtime->format('H:i')) && ($ohours[$day]["timeTilla"] >= $dtime->format('H:i'))) $nobh = true; |
||||||
|
} |
||||||
|
|
||||||
|
return $nobh; |
||||||
|
|
||||||
|
} else { |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public static function jakWhatslog($guestid, $opcache, $opid, $clientid, $whatsid, $itemid, $location, $email, $url, $ip, $agent) { |
||||||
|
|
||||||
|
global $jakdb; |
||||||
|
|
||||||
|
// We are calling the geo |
||||||
|
if (isset($location) && !empty($location)) { |
||||||
|
list($city, $country_name, $country_code, $country_lat, $country_lng) = explode('|', strip_tags(base64_decode($location))); |
||||||
|
} else { |
||||||
|
// Country Stuff |
||||||
|
$country_name = 'Disabled'; |
||||||
|
$country_code = 'xx'; |
||||||
|
$city = 'Disabled'; |
||||||
|
$country_lng = $country_lat = ''; |
||||||
|
} |
||||||
|
|
||||||
|
if ($whatsid == 2 || $whatsid == 5) { |
||||||
|
$jakdb->update("whatslog", ["opid" => $opcache, "operatorid" => $opid, "clientid" => $clientid, "whatsid" => $whatsid], ["AND" => ["ip" => $ip, "name" => $email, "time" => $jakdb->raw("NOW()")]]); |
||||||
|
} else { |
||||||
|
$jakdb->insert("whatslog", ["guestid" => $guestid, "opid" => $opcache, "operatorid" => $opid, "clientid" => $clientid, "whatsid" => $whatsid, "itemid" => $itemid, "country" => $country_name, "city" => $city, "countrycode" => $country_code, "latitude" => $country_lat, "longitude" => $country_lng, "name" => $email, "fromwhere" => $url, "usragent" => $agent, "ip" => $ip, "time" => $jakdb->raw("NOW()")]); |
||||||
|
} |
||||||
|
|
||||||
|
return true; |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public static function jakCookie($cookiename, $value, $expires, $path) { |
||||||
|
|
||||||
|
if (version_compare(PHP_VERSION, '7.3', '>=')) { |
||||||
|
|
||||||
|
setcookie($cookiename, $value, [ |
||||||
|
'expires' => time() + $expires, |
||||||
|
'path' => $path, |
||||||
|
'httponly' => true, |
||||||
|
'samesite' => 'None', |
||||||
|
'secure' => true]); |
||||||
|
|
||||||
|
} else { |
||||||
|
|
||||||
|
setcookie($cookiename, $value, time() + $expires, $path.'; SameSite=None; Secure'); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
?> |
@ -0,0 +1,568 @@ |
|||||||
|
<?php if(count(get_included_files()) == 1) exit("No direct script access allowed"); |
||||||
|
|
||||||
|
/*===============================================*\ |
||||||
|
|| ############################################# || |
||||||
|
|| # JAKWEB.CH / Version 2.1.1 # || |
||||||
|
|| # ----------------------------------------- # || |
||||||
|
|| # Copyright 2023 JAKWEB All Rights Reserved # || |
||||||
|
|| ############################################# || |
||||||
|
\*===============================================*/ |
||||||
|
|
||||||
|
define("LB_API_DEBUG", false); |
||||||
|
define("LB_SHOW_UPDATE_PROGRESS", true); |
||||||
|
|
||||||
|
define("LB_TEXT_CONNECTION_FAILED", 'License Server is unavailable at the moment, please try again.'); |
||||||
|
define("LB_TEXT_INVALID_RESPONSE", 'Invalid license, please register bellow or contact <a href="https://jakweb.ch">support</a>.'); |
||||||
|
define("LB_TEXT_VERIFIED_RESPONSE", 'Verified! Thanks for purchasing Cloud Desk 3.'); |
||||||
|
define("LB_TEXT_PREPARING_MAIN_DOWNLOAD", 'Preparing to download main update...'); |
||||||
|
define("LB_TEXT_MAIN_UPDATE_SIZE", 'Main Update size:'); |
||||||
|
define("LB_TEXT_DONT_REFRESH", '(Please do not refresh the page).'); |
||||||
|
define("LB_TEXT_DOWNLOADING_MAIN", 'Downloading main update...'); |
||||||
|
define("LB_TEXT_UPDATE_PERIOD_EXPIRED", 'Your update period has ended or your license is invalid, please contact support.'); |
||||||
|
define("LB_TEXT_UPDATE_PATH_ERROR", 'Folder does not have write permission or the update file path could not be resolved, please contact support.'); |
||||||
|
define("LB_TEXT_MAIN_UPDATE_DONE", 'Main update files downloaded, extracted and installed.'); |
||||||
|
define("LB_TEXT_UPDATE_EXTRACTION_ERROR", 'Update zip extraction failed.'); |
||||||
|
define("LB_TEXT_PREPARING_SQL_DOWNLOAD", 'Preparing to download database update...'); |
||||||
|
define("LB_TEXT_SQL_UPDATE_SIZE", 'Database update size:'); |
||||||
|
define("LB_TEXT_DOWNLOADING_SQL", 'Downloading database update...'); |
||||||
|
define("LB_TEXT_SQL_UPDATE_DONE", 'Database update file downloaded.'); |
||||||
|
define("LB_TEXT_UPDATE_WITH_SQL_DONE", 'Update successful, files and database have been updated.'); |
||||||
|
define("LB_TEXT_UPDATE_WITHOUT_SQL_DONE", 'Update successful, files have been updated there were no database updates.'); |
||||||
|
|
||||||
|
if(!LB_API_DEBUG){ |
||||||
|
@ini_set('display_errors', 0); |
||||||
|
} |
||||||
|
|
||||||
|
if((@ini_get('max_execution_time')!=='0')&&(@ini_get('max_execution_time'))<600){ |
||||||
|
@ini_set('max_execution_time', 600); |
||||||
|
} |
||||||
|
@ini_set('memory_limit', '256M'); |
||||||
|
|
||||||
|
class JAKLicenseAPI{ |
||||||
|
|
||||||
|
private $product_id; |
||||||
|
private $api_url; |
||||||
|
private $api_key; |
||||||
|
private $api_language; |
||||||
|
private $current_version; |
||||||
|
private $verify_type; |
||||||
|
private $verification_period; |
||||||
|
private $root_path; |
||||||
|
private $license_file; |
||||||
|
|
||||||
|
public function __construct(){ |
||||||
|
$this->product_id = 'CD3_CA82F2FF'; |
||||||
|
$this->api_url = 'https://license.jakweb.ch/'; |
||||||
|
$this->api_key = 'B505125128CDA848466F'; |
||||||
|
$this->api_language = 'english'; |
||||||
|
$this->current_version = 'v'.(defined('JAK_VERSION') ? JAK_VERSION : ''); |
||||||
|
$this->verify_type = 'envato'; |
||||||
|
$this->verification_period = 30; |
||||||
|
$this->root_path = APP_PATH.JAK_FILES_DIRECTORY.'/updates/'; |
||||||
|
$this->license_file = APP_PATH.JAK_FILES_DIRECTORY.'/updates/.lic'; |
||||||
|
} |
||||||
|
|
||||||
|
public function check_local_license_exist(){ |
||||||
|
return is_file($this->license_file); |
||||||
|
} |
||||||
|
|
||||||
|
public function get_current_version(){ |
||||||
|
return $this->current_version; |
||||||
|
} |
||||||
|
|
||||||
|
private function call_api($method, $url, $data){ |
||||||
|
$curl = curl_init(); |
||||||
|
switch ($method){ |
||||||
|
case "POST": |
||||||
|
curl_setopt($curl, CURLOPT_POST, 1); |
||||||
|
if($data) |
||||||
|
curl_setopt($curl, CURLOPT_POSTFIELDS, $data); |
||||||
|
break; |
||||||
|
case "PUT": |
||||||
|
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT"); |
||||||
|
if($data) |
||||||
|
curl_setopt($curl, CURLOPT_POSTFIELDS, $data); |
||||||
|
break; |
||||||
|
default: |
||||||
|
if($data) |
||||||
|
$url = sprintf("%s?%s", $url, http_build_query($data)); |
||||||
|
} |
||||||
|
$this_server_name = getenv('SERVER_NAME')?: |
||||||
|
$_SERVER['SERVER_NAME']?: |
||||||
|
getenv('HTTP_HOST')?: |
||||||
|
$_SERVER['HTTP_HOST']; |
||||||
|
$this_http_or_https = (( |
||||||
|
(isset($_SERVER['HTTPS'])&&($_SERVER['HTTPS']=="on"))or |
||||||
|
(isset($_SERVER['HTTP_X_FORWARDED_PROTO'])and |
||||||
|
$_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') |
||||||
|
)?'https://':'http://'); |
||||||
|
$this_url = $this_http_or_https.$this_server_name.$_SERVER['REQUEST_URI']; |
||||||
|
$this_ip = getenv('SERVER_ADDR')?: |
||||||
|
$_SERVER['SERVER_ADDR']?: |
||||||
|
$this->get_ip_from_third_party()?: |
||||||
|
gethostbyname(gethostname()); |
||||||
|
curl_setopt($curl, CURLOPT_HTTPHEADER, |
||||||
|
array('Content-Type: application/json', |
||||||
|
'LB-API-KEY: '.$this->api_key, |
||||||
|
'LB-URL: '.$this_url, |
||||||
|
'LB-IP: '.$this_ip, |
||||||
|
'LB-LANG: '.$this->api_language) |
||||||
|
); |
||||||
|
curl_setopt($curl, CURLOPT_URL, $url); |
||||||
|
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); |
||||||
|
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 30); |
||||||
|
curl_setopt($curl, CURLOPT_TIMEOUT, 30); |
||||||
|
$result = curl_exec($curl); |
||||||
|
if(!$result&&!LB_API_DEBUG){ |
||||||
|
$rs = array( |
||||||
|
'status' => FALSE, |
||||||
|
'message' => LB_TEXT_CONNECTION_FAILED |
||||||
|
); |
||||||
|
return json_encode($rs); |
||||||
|
} |
||||||
|
$http_status = curl_getinfo($curl, CURLINFO_HTTP_CODE); |
||||||
|
if($http_status != 200){ |
||||||
|
if(LB_API_DEBUG){ |
||||||
|
$temp_decode = json_decode($result, true); |
||||||
|
$rs = array( |
||||||
|
'status' => FALSE, |
||||||
|
'message' => ((!empty($temp_decode['error']))? |
||||||
|
$temp_decode['error']: |
||||||
|
$temp_decode['message']) |
||||||
|
); |
||||||
|
return json_encode($rs); |
||||||
|
}else{ |
||||||
|
$rs = array( |
||||||
|
'status' => FALSE, |
||||||
|
'message' => LB_TEXT_INVALID_RESPONSE |
||||||
|
); |
||||||
|
return json_encode($rs); |
||||||
|
} |
||||||
|
} |
||||||
|
curl_close($curl); |
||||||
|
return $result; |
||||||
|
} |
||||||
|
|
||||||
|
public function check_connection(){ |
||||||
|
$data_array = array(); |
||||||
|
$get_data = $this->call_api( |
||||||
|
'POST', |
||||||
|
$this->api_url.'api/check_connection_ext', |
||||||
|
json_encode($data_array) |
||||||
|
); |
||||||
|
$response = json_decode($get_data, true); |
||||||
|
return $response; |
||||||
|
} |
||||||
|
|
||||||
|
public function get_latest_version(){ |
||||||
|
$data_array = array( |
||||||
|
"product_id" => $this->product_id |
||||||
|
); |
||||||
|
$get_data = $this->call_api( |
||||||
|
'POST', |
||||||
|
$this->api_url.'api/latest_version', |
||||||
|
json_encode($data_array) |
||||||
|
); |
||||||
|
$response = json_decode($get_data, true); |
||||||
|
return $response; |
||||||
|
} |
||||||
|
|
||||||
|
public function activate_license($license, $client, $create_lic = true){ |
||||||
|
$data_array = array( |
||||||
|
"product_id" => $this->product_id, |
||||||
|
"license_code" => $license, |
||||||
|
"client_name" => $client, |
||||||
|
"verify_type" => $this->verify_type |
||||||
|
); |
||||||
|
$get_data = $this->call_api( |
||||||
|
'POST', |
||||||
|
$this->api_url.'api/activate_license', |
||||||
|
json_encode($data_array) |
||||||
|
); |
||||||
|
$response = json_decode($get_data, true); |
||||||
|
if(!empty($create_lic)){ |
||||||
|
if($response['status']){ |
||||||
|
$licfile = trim($response['lic_response']); |
||||||
|
file_put_contents($this->license_file, $licfile, LOCK_EX); |
||||||
|
}else{ |
||||||
|
@chmod($this->license_file, 0777); |
||||||
|
if(is_writeable($this->license_file)){ |
||||||
|
unlink($this->license_file); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
return $response; |
||||||
|
} |
||||||
|
|
||||||
|
public function verify_license($time_based_check = false, $license = false, $client = false){ |
||||||
|
if(!empty($license)&&!empty($client)){ |
||||||
|
$data_array = array( |
||||||
|
"product_id" => $this->product_id, |
||||||
|
"license_file" => null, |
||||||
|
"license_code" => $license, |
||||||
|
"client_name" => $client |
||||||
|
); |
||||||
|
}else{ |
||||||
|
if(is_file($this->license_file)){ |
||||||
|
$data_array = array( |
||||||
|
"product_id" => $this->product_id, |
||||||
|
"license_file" => file_get_contents($this->license_file), |
||||||
|
"license_code" => null, |
||||||
|
"client_name" => null |
||||||
|
); |
||||||
|
}else{ |
||||||
|
$data_array = array(); |
||||||
|
} |
||||||
|
} |
||||||
|
$res = array('status' => TRUE, 'message' => LB_TEXT_VERIFIED_RESPONSE); |
||||||
|
if($time_based_check && $this->verification_period > 0){ |
||||||
|
ob_start(); |
||||||
|
if(session_status() == PHP_SESSION_NONE){ |
||||||
|
session_start(); |
||||||
|
} |
||||||
|
$type = (int) $this->verification_period; |
||||||
|
$today = date('d-m-Y'); |
||||||
|
if(empty($_SESSION["c7f9c6b8b03214d"])){ |
||||||
|
$_SESSION["c7f9c6b8b03214d"] = '00-00-0000'; |
||||||
|
} |
||||||
|
if($type == 1){ |
||||||
|
$type_text = '1 day'; |
||||||
|
}elseif($type == 3){ |
||||||
|
$type_text = '3 days'; |
||||||
|
}elseif($type == 7){ |
||||||
|
$type_text = '1 week'; |
||||||
|
}elseif($type == 30){ |
||||||
|
$type_text = '1 month'; |
||||||
|
}elseif($type == 90){ |
||||||
|
$type_text = '3 months'; |
||||||
|
}elseif($type == 365) { |
||||||
|
$type_text = '1 year'; |
||||||
|
}else{ |
||||||
|
$type_text = $type.' days'; |
||||||
|
} |
||||||
|
if(strtotime($today) >= strtotime($_SESSION["c7f9c6b8b03214d"])){ |
||||||
|
$get_data = $this->call_api( |
||||||
|
'POST', |
||||||
|
$this->api_url.'api/verify_license', |
||||||
|
json_encode($data_array) |
||||||
|
); |
||||||
|
$res = json_decode($get_data, true); |
||||||
|
if($res['status']==true){ |
||||||
|
$tomo = date('d-m-Y', strtotime($today. ' + '.$type_text)); |
||||||
|
$_SESSION["c7f9c6b8b03214d"] = $tomo; |
||||||
|
} |
||||||
|
} |
||||||
|
ob_end_clean(); |
||||||
|
}else{ |
||||||
|
$get_data = $this->call_api( |
||||||
|
'POST', |
||||||
|
$this->api_url.'api/verify_license', |
||||||
|
json_encode($data_array) |
||||||
|
); |
||||||
|
$res = json_decode($get_data, true); |
||||||
|
} |
||||||
|
return $res; |
||||||
|
} |
||||||
|
|
||||||
|
public function deactivate_license($license = false, $client = false){ |
||||||
|
if(!empty($license)&&!empty($client)){ |
||||||
|
$data_array = array( |
||||||
|
"product_id" => $this->product_id, |
||||||
|
"license_file" => null, |
||||||
|
"license_code" => $license, |
||||||
|
"client_name" => $client |
||||||
|
); |
||||||
|
}else{ |
||||||
|
if(is_file($this->license_file)){ |
||||||
|
$data_array = array( |
||||||
|
"product_id" => $this->product_id, |
||||||
|
"license_file" => file_get_contents($this->license_file), |
||||||
|
"license_code" => null, |
||||||
|
"client_name" => null |
||||||
|
); |
||||||
|
}else{ |
||||||
|
$data_array = array(); |
||||||
|
} |
||||||
|
} |
||||||
|
$get_data = $this->call_api( |
||||||
|
'POST', |
||||||
|
$this->api_url.'api/deactivate_license', |
||||||
|
json_encode($data_array) |
||||||
|
); |
||||||
|
$response = json_decode($get_data, true); |
||||||
|
if($response['status']){ |
||||||
|
@chmod($this->license_file, 0777); |
||||||
|
if(is_writeable($this->license_file)){ |
||||||
|
unlink($this->license_file); |
||||||
|
} |
||||||
|
} |
||||||
|
return $response; |
||||||
|
} |
||||||
|
|
||||||
|
public function check_update(){ |
||||||
|
$data_array = array( |
||||||
|
"product_id" => $this->product_id, |
||||||
|
"current_version" => $this->current_version |
||||||
|
); |
||||||
|
$get_data = $this->call_api( |
||||||
|
'POST', |
||||||
|
$this->api_url.'api/check_update', |
||||||
|
json_encode($data_array) |
||||||
|
); |
||||||
|
$response = json_decode($get_data, true); |
||||||
|
return $response; |
||||||
|
} |
||||||
|
|
||||||
|
public function download_update($update_id, $type, $version, $license = false, $client = false){ |
||||||
|
if(!empty($license)&&!empty($client)){ |
||||||
|
$data_array = array( |
||||||
|
"license_file" => null, |
||||||
|
"license_code" => $license, |
||||||
|
"client_name" => $client |
||||||
|
); |
||||||
|
}else{ |
||||||
|
if(is_file($this->license_file)){ |
||||||
|
$data_array = array( |
||||||
|
"license_file" => file_get_contents($this->license_file), |
||||||
|
"license_code" => null, |
||||||
|
"client_name" => null |
||||||
|
); |
||||||
|
}else{ |
||||||
|
$data_array = array(); |
||||||
|
} |
||||||
|
} |
||||||
|
ob_end_flush(); |
||||||
|
ob_implicit_flush(true); |
||||||
|
$version = str_replace(".", "_", $version); |
||||||
|
ob_start(); |
||||||
|
$source_size = $this->api_url."api/get_update_size/main/".$update_id; |
||||||
|
echo LB_TEXT_PREPARING_MAIN_DOWNLOAD."<br>"; |
||||||
|
if(LB_SHOW_UPDATE_PROGRESS){echo '<script>document.getElementById("updprog").style.width = "1%";document.getElementById("updprogval").textContent="1%";</script>';} |
||||||
|
ob_flush(); |
||||||
|
echo LB_TEXT_MAIN_UPDATE_SIZE." ".$this->get_remote_filesize($source_size)." ".LB_TEXT_DONT_REFRESH."<br>"; |
||||||
|
if(LB_SHOW_UPDATE_PROGRESS){echo '<script>document.getElementById("updprog").style.width = "5%";document.getElementById("updprogval").textContent="5%";</script>';} |
||||||
|
ob_flush(); |
||||||
|
$temp_progress = ''; |
||||||
|
$ch = curl_init(); |
||||||
|
$source = $this->api_url."api/download_update/main/".$update_id; |
||||||
|
curl_setopt($ch, CURLOPT_URL, $source); |
||||||
|
curl_setopt($ch, CURLOPT_POST, 1); |
||||||
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_array); |
||||||
|
$this_server_name = getenv('SERVER_NAME')?: |
||||||
|
$_SERVER['SERVER_NAME']?: |
||||||
|
getenv('HTTP_HOST')?: |
||||||
|
$_SERVER['HTTP_HOST']; |
||||||
|
$this_http_or_https = (( |
||||||
|
(isset($_SERVER['HTTPS'])&&($_SERVER['HTTPS']=="on"))or |
||||||
|
(isset($_SERVER['HTTP_X_FORWARDED_PROTO'])and |
||||||
|
$_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') |
||||||
|
)?'https://':'http://'); |
||||||
|
$this_url = $this_http_or_https.$this_server_name.$_SERVER['REQUEST_URI']; |
||||||
|
$this_ip = getenv('SERVER_ADDR')?: |
||||||
|
$_SERVER['SERVER_ADDR']?: |
||||||
|
$this->get_ip_from_third_party()?: |
||||||
|
gethostbyname(gethostname()); |
||||||
|
curl_setopt($ch, CURLOPT_HTTPHEADER, array( |
||||||
|
'LB-API-KEY: '.$this->api_key, |
||||||
|
'LB-URL: '.$this_url, |
||||||
|
'LB-IP: '.$this_ip, |
||||||
|
'LB-LANG: '.$this->api_language) |
||||||
|
); |
||||||
|
if(LB_SHOW_UPDATE_PROGRESS){curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, array($this, 'progress'));} |
||||||
|
if(LB_SHOW_UPDATE_PROGRESS){curl_setopt($ch, CURLOPT_NOPROGRESS, false);} |
||||||
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
||||||
|
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); |
||||||
|
echo LB_TEXT_DOWNLOADING_MAIN."<br>"; |
||||||
|
if(LB_SHOW_UPDATE_PROGRESS){echo '<script>document.getElementById("updprog").style.width = "10%";document.getElementById("updprogval").textContent="10%";</script>';} |
||||||
|
ob_flush(); |
||||||
|
$data = curl_exec($ch); |
||||||
|
$http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
||||||
|
if($http_status != 200){ |
||||||
|
if($http_status == 401){ |
||||||
|
curl_close($ch); |
||||||
|
exit("<br>".LB_TEXT_UPDATE_PERIOD_EXPIRED); |
||||||
|
}else{ |
||||||
|
curl_close($ch); |
||||||
|
exit("<br>".LB_TEXT_INVALID_RESPONSE); |
||||||
|
} |
||||||
|
} |
||||||
|
curl_close($ch); |
||||||
|
$destination = $this->root_path."/update_main_".$version.".zip"; |
||||||
|
$file = fopen($destination, "w+"); |
||||||
|
if(!$file){ |
||||||
|
exit("<br>".LB_TEXT_UPDATE_PATH_ERROR); |
||||||
|
} |
||||||
|
fputs($file, $data); |
||||||
|
fclose($file); |
||||||
|
if(LB_SHOW_UPDATE_PROGRESS){echo '<script>document.getElementById("updprog").style.width = "65%";document.getElementById("updprogval").textContent="65%";</script>';} |
||||||
|
ob_flush(); |
||||||
|
$zip = new ZipArchive; |
||||||
|
$res = $zip->open($destination); |
||||||
|
if($res === TRUE){ |
||||||
|
$zip->extractTo(APP_PATH); |
||||||
|
$zip->close(); |
||||||
|
unlink($destination); |
||||||
|
echo LB_TEXT_MAIN_UPDATE_DONE."<br><br>"; |
||||||
|
if(LB_SHOW_UPDATE_PROGRESS){echo '<script>document.getElementById("updprog").style.width = "75%";document.getElementById("updprogval").textContent="75%";</script>';} |
||||||
|
ob_flush(); |
||||||
|
}else{ |
||||||
|
echo LB_TEXT_UPDATE_EXTRACTION_ERROR."<br><br>"; |
||||||
|
ob_flush(); |
||||||
|
} |
||||||
|
if($type == true){ |
||||||
|
$source_size = $this->api_url."api/get_update_size/sql/".$update_id; |
||||||
|
echo LB_TEXT_PREPARING_SQL_DOWNLOAD."<br>"; |
||||||
|
ob_flush(); |
||||||
|
echo LB_TEXT_SQL_UPDATE_SIZE." ".$this->get_remote_filesize($source_size)." ".LB_TEXT_DONT_REFRESH."<br>"; |
||||||
|
if(LB_SHOW_UPDATE_PROGRESS){echo '<script>document.getElementById("updprog").style.width = "85%";document.getElementById("updprogval").textContent="85%";</script>';} |
||||||
|
ob_flush(); |
||||||
|
$temp_progress = ''; |
||||||
|
$ch = curl_init(); |
||||||
|
$source = $this->api_url."api/download_update/sql/".$update_id; |
||||||
|
curl_setopt($ch, CURLOPT_URL, $source); |
||||||
|
curl_setopt($ch, CURLOPT_POST, 1); |
||||||
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_array); |
||||||
|
$this_server_name = getenv('SERVER_NAME')?: |
||||||
|
$_SERVER['SERVER_NAME']?: |
||||||
|
getenv('HTTP_HOST')?: |
||||||
|
$_SERVER['HTTP_HOST']; |
||||||
|
$this_http_or_https = (( |
||||||
|
(isset($_SERVER['HTTPS'])&&($_SERVER['HTTPS']=="on"))or |
||||||
|
(isset($_SERVER['HTTP_X_FORWARDED_PROTO'])and |
||||||
|
$_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') |
||||||
|
)?'https://':'http://'); |
||||||
|
$this_url = $this_http_or_https.$this_server_name.$_SERVER['REQUEST_URI']; |
||||||
|
$this_ip = getenv('SERVER_ADDR')?: |
||||||
|
$_SERVER['SERVER_ADDR']?: |
||||||
|
$this->get_ip_from_third_party()?: |
||||||
|
gethostbyname(gethostname()); |
||||||
|
curl_setopt($ch, CURLOPT_HTTPHEADER, array( |
||||||
|
'LB-API-KEY: '.$this->api_key, |
||||||
|
'LB-URL: '.$this_url, |
||||||
|
'LB-IP: '.$this_ip, |
||||||
|
'LB-LANG: '.$this->api_language) |
||||||
|
); |
||||||
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
||||||
|
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); |
||||||
|
echo LB_TEXT_DOWNLOADING_SQL."<br>"; |
||||||
|
if(LB_SHOW_UPDATE_PROGRESS){echo '<script>document.getElementById("updprog").style.width = "90%";document.getElementById("updprogval").textContent="90%";</script>';} |
||||||
|
ob_flush(); |
||||||
|
$data = curl_exec($ch); |
||||||
|
$http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
||||||
|
if($http_status!=200){ |
||||||
|
curl_close($ch); |
||||||
|
exit(LB_TEXT_INVALID_RESPONSE); |
||||||
|
} |
||||||
|
curl_close($ch); |
||||||
|
$destination = $this->root_path."/update_sql_".$version.".sql"; |
||||||
|
$file = fopen($destination, "w+"); |
||||||
|
if(!$file){ |
||||||
|
exit(LB_TEXT_UPDATE_PATH_ERROR); |
||||||
|
} |
||||||
|
fputs($file, $data); |
||||||
|
fclose($file); |
||||||
|
// We run the real database update file |
||||||
|
$dbupdatefile = APP_PATH.'update.php'; |
||||||
|
if (file_exists($dbupdatefile)) { |
||||||
|
global $jakdb; |
||||||
|
include($dbupdatefile); |
||||||
|
unlink($dbupdatefile); |
||||||
|
} |
||||||
|
echo LB_TEXT_SQL_UPDATE_DONE."<br><br>"; |
||||||
|
if(LB_SHOW_UPDATE_PROGRESS){echo '<script>document.getElementById("updprog").style.width = "100%";document.getElementById("updprogval").textContent="100%";</script>';} |
||||||
|
echo LB_TEXT_UPDATE_WITH_SQL_DONE; |
||||||
|
ob_flush(); |
||||||
|
}else{ |
||||||
|
if(LB_SHOW_UPDATE_PROGRESS){echo '<script>document.getElementById("updprog").style.width = "100%";document.getElementById("updprogval").textContent="100%";</script>';} |
||||||
|
echo LB_TEXT_UPDATE_WITHOUT_SQL_DONE; |
||||||
|
ob_flush(); |
||||||
|
} |
||||||
|
ob_end_flush(); |
||||||
|
} |
||||||
|
|
||||||
|
private function progress($resource, $download_size, $downloaded, $upload_size, $uploaded){ |
||||||
|
static $prev = 0; |
||||||
|
if($download_size == 0){ |
||||||
|
$progress = 0; |
||||||
|
}else{ |
||||||
|
$progress = round( $downloaded * 100 / $download_size ); |
||||||
|
} |
||||||
|
if(($progress!=$prev) && ($progress == 25)){ |
||||||
|
$prev = $progress; |
||||||
|
echo '<script>document.getElementById("updprog").style.width = "25%";document.getElementById("updprogval").textContent="25%";</script>'; |
||||||
|
ob_flush(); |
||||||
|
} |
||||||
|
if(($progress!=$prev) && ($progress == 50)){ |
||||||
|
$prev=$progress; |
||||||
|
echo '<script>document.getElementById("updprog").style.width = "50%";document.getElementById("updprogval").textContent="50%";</script>'; |
||||||
|
ob_flush(); |
||||||
|
} |
||||||
|
if(($progress!=$prev) && ($progress == 75)){ |
||||||
|
$prev=$progress; |
||||||
|
echo '<script>document.getElementById("updprog").style.width = "75%";document.getElementById("updprogval").textContent="75%";</script>'; |
||||||
|
ob_flush(); |
||||||
|
} |
||||||
|
if(($progress!=$prev) && ($progress == 100)){ |
||||||
|
$prev=$progress; |
||||||
|
echo '<script>document.getElementById("updprog").style.width = "100%";document.getElementById("updprogval").textContent="100%";</script>'; |
||||||
|
ob_flush(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private function get_ip_from_third_party(){ |
||||||
|
$curl = curl_init (); |
||||||
|
curl_setopt($curl, CURLOPT_URL, "http://ipecho.net/plain"); |
||||||
|
curl_setopt($curl, CURLOPT_HEADER, 0); |
||||||
|
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); |
||||||
|
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10); |
||||||
|
curl_setopt($curl, CURLOPT_TIMEOUT, 10); |
||||||
|
$response = curl_exec($curl); |
||||||
|
curl_close($curl); |
||||||
|
return $response; |
||||||
|
} |
||||||
|
|
||||||
|
private function get_remote_filesize($url){ |
||||||
|
$curl = curl_init(); |
||||||
|
curl_setopt($curl, CURLOPT_HEADER, TRUE); |
||||||
|
curl_setopt($curl, CURLOPT_URL, $url); |
||||||
|
curl_setopt($curl, CURLOPT_NOBODY, TRUE); |
||||||
|
$this_server_name = getenv('SERVER_NAME')?: |
||||||
|
$_SERVER['SERVER_NAME']?: |
||||||
|
getenv('HTTP_HOST')?: |
||||||
|
$_SERVER['HTTP_HOST']; |
||||||
|
$this_http_or_https = (( |
||||||
|
(isset($_SERVER['HTTPS'])&&($_SERVER['HTTPS']=="on"))or |
||||||
|
(isset($_SERVER['HTTP_X_FORWARDED_PROTO'])and |
||||||
|
$_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') |
||||||
|
)?'https://':'http://'); |
||||||
|
$this_url = $this_http_or_https.$this_server_name.$_SERVER['REQUEST_URI']; |
||||||
|
$this_ip = getenv('SERVER_ADDR')?: |
||||||
|
$_SERVER['SERVER_ADDR']?: |
||||||
|
$this->get_ip_from_third_party()?: |
||||||
|
gethostbyname(gethostname()); |
||||||
|
curl_setopt($curl, CURLOPT_HTTPHEADER, array( |
||||||
|
'LB-API-KEY: '.$this->api_key, |
||||||
|
'LB-URL: '.$this_url, |
||||||
|
'LB-IP: '.$this_ip, |
||||||
|
'LB-LANG: '.$this->api_language) |
||||||
|
); |
||||||
|
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); |
||||||
|
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 30); |
||||||
|
$result = curl_exec($curl); |
||||||
|
$filesize = curl_getinfo($curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD); |
||||||
|
if ($filesize){ |
||||||
|
switch ($filesize){ |
||||||
|
case $filesize < 1024: |
||||||
|
$size = $filesize .' B'; break; |
||||||
|
case $filesize < 1048576: |
||||||
|
$size = round($filesize / 1024, 2) .' KB'; break; |
||||||
|
case $filesize < 1073741824: |
||||||
|
$size = round($filesize / 1048576, 2) . ' MB'; break; |
||||||
|
case $filesize < 1099511627776: |
||||||
|
$size = round($filesize / 1073741824, 2) . ' GB'; break; |
||||||
|
} |
||||||
|
return $size; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
?> |
@ -0,0 +1,84 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
/*===============================================*\ |
||||||
|
|| ############################################# || |
||||||
|
|| # JAKWEB.CH / Version 2.1.2 # || |
||||||
|
|| # ----------------------------------------- # || |
||||||
|
|| # Copyright 2023 JAKWEB All Rights Reserved # || |
||||||
|
|| ############################################# || |
||||||
|
\*===============================================*/ |
||||||
|
|
||||||
|
#[AllowDynamicProperties] |
||||||
|
class JAK_Paginator{ |
||||||
|
|
||||||
|
var $items_total; |
||||||
|
var $current_page; |
||||||
|
var $num_pages; |
||||||
|
var $mid_range; |
||||||
|
var $low; |
||||||
|
var $high; |
||||||
|
var $limit; |
||||||
|
var $return; |
||||||
|
var $items_per_page; |
||||||
|
var $jak_get_page; |
||||||
|
var $jak_where; |
||||||
|
var $jak_prevstyle = 'prev-button'; |
||||||
|
var $jak_nextstyle = 'next-button'; |
||||||
|
var $jak_prevtext = '«'; |
||||||
|
var $jak_nexttext = '»'; |
||||||
|
|
||||||
|
public function __construct() |
||||||
|
{ |
||||||
|
$this->current_page = 1; |
||||||
|
$this->mid_range = 3; |
||||||
|
} |
||||||
|
|
||||||
|
public function paginate() |
||||||
|
{ |
||||||
|
$this->num_pages = ceil($this->items_total/$this->items_per_page); |
||||||
|
$this->current_page = (int) $this->jak_get_page; // must be numeric > 0 |
||||||
|
if($this->current_page < 1 Or !is_numeric($this->current_page)) $this->current_page = 1; |
||||||
|
if($this->current_page > $this->num_pages) $this->current_page = $this->num_pages; |
||||||
|
$prev_page = $this->current_page-1; |
||||||
|
$next_page = $this->current_page+1; |
||||||
|
|
||||||
|
if($this->num_pages > 1) { |
||||||
|
|
||||||
|
$this->return = ($this->current_page != 1 And $this->items_total >= 2) ? ' <nav aria-label="Page navigation"><ul class="pagination"><li class="page-item"><a class="page-link '.$this->jak_prevstyle.'" href="'.$this->jak_where.JAK_rewrite::jakParseurlpaginate($prev_page).'">'.$this->jak_prevtext.'</a></li>' : '<nav aria-label="Page navigation"><ul class="pagination">'; |
||||||
|
|
||||||
|
$this->start_range = $this->current_page - floor($this->mid_range/2); |
||||||
|
$this->end_range = $this->current_page + floor($this->mid_range/2); |
||||||
|
|
||||||
|
if($this->start_range <= 0) |
||||||
|
{ |
||||||
|
$this->end_range += abs($this->start_range)+1; |
||||||
|
$this->start_range = 1; |
||||||
|
} |
||||||
|
if($this->end_range > $this->num_pages) |
||||||
|
{ |
||||||
|
$this->start_range -= $this->end_range-$this->num_pages; |
||||||
|
$this->end_range = $this->num_pages; |
||||||
|
} |
||||||
|
$this->range = range($this->start_range,$this->end_range); |
||||||
|
|
||||||
|
for($i=1;$i<=$this->num_pages;$i++) |
||||||
|
{ |
||||||
|
// loop through all pages. if first, last, or in range, display |
||||||
|
if($i==1 Or $i==$this->num_pages Or in_array($i,$this->range)) |
||||||
|
{ |
||||||
|
$this->return .= ($i == $this->current_page) ? '<li class="page-item active"><a class="page-link" title="Go to page '.$i.' of '.$this->num_pages.'" href="'.$this->jak_where.JAK_rewrite::jakParseurlpaginate($i).'">'.$i.'</a></li>' : '<li class="page-item"><a class="page-link" title="Go to page '.$i.' of '.$this->num_pages.'" href="'.$this->jak_where.JAK_rewrite::jakParseurlpaginate($i).'">'.$i.'</a></li>'; |
||||||
|
} |
||||||
|
} |
||||||
|
$this->return .= ($this->current_page != $this->num_pages And $this->items_total >= 2) ? '<li class="page-item"><a href="'.$this->jak_where.JAK_rewrite::jakParseurlpaginate($next_page).'" class="page-link">'.$this->jak_nexttext.'</a></li></ul></nav>' : '</ul></nav>'; |
||||||
|
} |
||||||
|
$this->low = ($this->current_page-1) * $this->items_per_page; |
||||||
|
$this->high = ($this->current_page * $this->items_per_page)-1; |
||||||
|
$this->limit = [$this->low,$this->items_per_page]; |
||||||
|
} |
||||||
|
|
||||||
|
public function display_pages() |
||||||
|
{ |
||||||
|
return $this->return; |
||||||
|
} |
||||||
|
} |
||||||
|
?> |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,285 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
/*===============================================*\ |
||||||
|
|| ############################################# || |
||||||
|
|| # JAKWEB.CH / Version 2.1.1 # || |
||||||
|
|| # ----------------------------------------- # || |
||||||
|
|| # Copyright 2023 JAKWEB All Rights Reserved # || |
||||||
|
|| ############################################# || |
||||||
|
\*===============================================*/ |
||||||
|
|
||||||
|
class JAK_rewrite { |
||||||
|
|
||||||
|
private $url_seg; |
||||||
|
private $data = array(); |
||||||
|
|
||||||
|
// This constructor can be used for all classes: |
||||||
|
public function __construct( |
||||||
|
public string $url |
||||||
|
) {} |
||||||
|
|
||||||
|
function jakGetseg($var) { |
||||||
|
|
||||||
|
if (isset($var)) { |
||||||
|
|
||||||
|
if (JAK_USE_APACHE) { |
||||||
|
|
||||||
|
$url = (defined('_APP_MAIN_DIR') ? str_replace(_APP_MAIN_DIR, '', $this->url) : str_replace(SITE_SUBFOLDER, '', $this->url)); |
||||||
|
$_tmp = explode('?', $url); |
||||||
|
$url = $_tmp[0]; |
||||||
|
|
||||||
|
if ($url = explode('/', $url)) { |
||||||
|
foreach ($url as $d) { |
||||||
|
if ($d) { |
||||||
|
$data[] = $d; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
if (!empty($data[$var])) $url_seg = $data[$var]; |
||||||
|
|
||||||
|
} else { |
||||||
|
|
||||||
|
// get the url and parse it |
||||||
|
$parseurl = parse_url($this->url); |
||||||
|
|
||||||
|
if (!empty($parseurl["query"])) { |
||||||
|
// get only the query |
||||||
|
$parameters = $parseurl["query"]; |
||||||
|
parse_str($parameters, $data); |
||||||
|
|
||||||
|
// Now we have to set the array to basic keys |
||||||
|
if (!empty($data)) foreach($data as $d) { |
||||||
|
$data[] = $d; |
||||||
|
} |
||||||
|
|
||||||
|
if (!empty($data[$var])) $url_seg = $data[$var]; |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
if (!empty($url_seg)) return $url_seg; |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public static function jakCleanurl($str, $options = array()) { |
||||||
|
|
||||||
|
$defaults = array( |
||||||
|
'delimiter' => '-', |
||||||
|
'limit' => null, |
||||||
|
'lowercase' => true, |
||||||
|
'replacements' => array(), |
||||||
|
'transliterate' => true, |
||||||
|
); |
||||||
|
|
||||||
|
// Merge options |
||||||
|
$options = array_merge($defaults, $options); |
||||||
|
|
||||||
|
$char_map = array( |
||||||
|
// Latin |
||||||
|
'À' => 'A', 'Á' => 'A', 'Â' => 'A', 'Ã' => 'A', 'Ä' => 'A', 'Å' => 'A', 'Æ' => 'AE', 'Ç' => 'C', |
||||||
|
'È' => 'E', 'É' => 'E', 'Ê' => 'E', 'Ë' => 'E', 'Ì' => 'I', 'Í' => 'I', 'Î' => 'I', 'Ï' => 'I', |
||||||
|
'Ð' => 'D', 'Ñ' => 'N', 'Ò' => 'O', 'Ó' => 'O', 'Ô' => 'O', 'Õ' => 'O', 'Ö' => 'O', 'Ő' => 'O', |
||||||
|
'Ø' => 'O', 'Ù' => 'U', 'Ú' => 'U', 'Û' => 'U', 'Ü' => 'U', 'Ű' => 'U', 'Ý' => 'Y', 'Þ' => 'TH', |
||||||
|
'ß' => 'ss', |
||||||
|
'à' => 'a', 'á' => 'a', 'â' => 'a', 'ã' => 'a', 'ä' => 'a', 'å' => 'a', 'æ' => 'ae', 'ç' => 'c', |
||||||
|
'è' => 'e', 'é' => 'e', 'ê' => 'e', 'ë' => 'e', 'ì' => 'i', 'í' => 'i', 'î' => 'i', 'ï' => 'i', |
||||||
|
'ð' => 'd', 'ñ' => 'n', 'ò' => 'o', 'ó' => 'o', 'ô' => 'o', 'õ' => 'o', 'ö' => 'o', 'ő' => 'o', |
||||||
|
'ø' => 'o', 'ù' => 'u', 'ú' => 'u', 'û' => 'u', 'ü' => 'u', 'ű' => 'u', 'ý' => 'y', 'þ' => 'th', |
||||||
|
'ÿ' => 'y', |
||||||
|
|
||||||
|
// Latin symbols |
||||||
|
'©' => '(c)', |
||||||
|
|
||||||
|
// Greek |
||||||
|
'Α' => 'A', 'Β' => 'B', 'Γ' => 'G', 'Δ' => 'D', 'Ε' => 'E', 'Ζ' => 'Z', 'Η' => 'H', 'Θ' => '8', |
||||||
|
'Ι' => 'I', 'Κ' => 'K', 'Λ' => 'L', 'Μ' => 'M', 'Ν' => 'N', 'Ξ' => '3', 'Ο' => 'O', 'Π' => 'P', |
||||||
|
'Ρ' => 'R', 'Σ' => 'S', 'Τ' => 'T', 'Υ' => 'Y', 'Φ' => 'F', 'Χ' => 'X', 'Ψ' => 'PS', 'Ω' => 'W', |
||||||
|
'Ά' => 'A', 'Έ' => 'E', 'Ί' => 'I', 'Ό' => 'O', 'Ύ' => 'Y', 'Ή' => 'H', 'Ώ' => 'W', 'Ϊ' => 'I', |
||||||
|
'Ϋ' => 'Y', |
||||||
|
'α' => 'a', 'β' => 'b', 'γ' => 'g', 'δ' => 'd', 'ε' => 'e', 'ζ' => 'z', 'η' => 'h', 'θ' => '8', |
||||||
|
'ι' => 'i', 'κ' => 'k', 'λ' => 'l', 'μ' => 'm', 'ν' => 'n', 'ξ' => '3', 'ο' => 'o', 'π' => 'p', |
||||||
|
'ρ' => 'r', 'σ' => 's', 'τ' => 't', 'υ' => 'y', 'φ' => 'f', 'χ' => 'x', 'ψ' => 'ps', 'ω' => 'w', |
||||||
|
'ά' => 'a', 'έ' => 'e', 'ί' => 'i', 'ό' => 'o', 'ύ' => 'y', 'ή' => 'h', 'ώ' => 'w', 'ς' => 's', |
||||||
|
'ϊ' => 'i', 'ΰ' => 'y', 'ϋ' => 'y', 'ΐ' => 'i', |
||||||
|
|
||||||
|
// Turkish |
||||||
|
'Ş' => 'S', 'İ' => 'I', 'Ç' => 'C', 'Ü' => 'U', 'Ö' => 'O', 'Ğ' => 'G', |
||||||
|
'ş' => 's', 'ı' => 'i', 'ç' => 'c', 'ü' => 'u', 'ö' => 'o', 'ğ' => 'g', |
||||||
|
|
||||||
|
// Russian |
||||||
|
'А' => 'A', 'Б' => 'B', 'В' => 'V', 'Г' => 'G', 'Д' => 'D', 'Е' => 'E', 'Ё' => 'Yo', 'Ж' => 'Zh', |
||||||
|
'З' => 'Z', 'И' => 'I', 'Й' => 'J', 'К' => 'K', 'Л' => 'L', 'М' => 'M', 'Н' => 'N', 'О' => 'O', |
||||||
|
'П' => 'P', 'Р' => 'R', 'С' => 'S', 'Т' => 'T', 'У' => 'U', 'Ф' => 'F', 'Х' => 'H', 'Ц' => 'C', |
||||||
|
'Ч' => 'Ch', 'Ш' => 'Sh', 'Щ' => 'Sh', 'Ъ' => '', 'Ы' => 'Y', 'Ь' => '', 'Э' => 'E', 'Ю' => 'Yu', |
||||||
|
'Я' => 'Ya', |
||||||
|
'а' => 'a', 'б' => 'b', 'в' => 'v', 'г' => 'g', 'д' => 'd', 'е' => 'e', 'ё' => 'yo', 'ж' => 'zh', |
||||||
|
'з' => 'z', 'и' => 'i', 'й' => 'j', 'к' => 'k', 'л' => 'l', 'м' => 'm', 'н' => 'n', 'о' => 'o', |
||||||
|
'п' => 'p', 'р' => 'r', 'с' => 's', 'т' => 't', 'у' => 'u', 'ф' => 'f', 'х' => 'h', 'ц' => 'c', |
||||||
|
'ч' => 'ch', 'ш' => 'sh', 'щ' => 'sh', 'ъ' => '', 'ы' => 'y', 'ь' => '', 'э' => 'e', 'ю' => 'yu', |
||||||
|
'я' => 'ya', |
||||||
|
|
||||||
|
// Ukrainian |
||||||
|
'Є' => 'Ye', 'І' => 'I', 'Ї' => 'Yi', 'Ґ' => 'G', |
||||||
|
'є' => 'ye', 'і' => 'i', 'ї' => 'yi', 'ґ' => 'g', |
||||||
|
|
||||||
|
// Czech |
||||||
|
'Č' => 'C', 'Ď' => 'D', 'Ě' => 'E', 'Ň' => 'N', 'Ř' => 'R', 'Š' => 'S', 'Ť' => 'T', 'Ů' => 'U', |
||||||
|
'Ž' => 'Z', |
||||||
|
'č' => 'c', 'ď' => 'd', 'ě' => 'e', 'ň' => 'n', 'ř' => 'r', 'š' => 's', 'ť' => 't', 'ů' => 'u', |
||||||
|
'ž' => 'z', |
||||||
|
|
||||||
|
// Polish |
||||||
|
'Ą' => 'A', 'Ć' => 'C', 'Ę' => 'e', 'Ł' => 'L', 'Ń' => 'N', 'Ó' => 'o', 'Ś' => 'S', 'Ź' => 'Z', |
||||||
|
'Ż' => 'Z', |
||||||
|
'ą' => 'a', 'ć' => 'c', 'ę' => 'e', 'ł' => 'l', 'ń' => 'n', 'ó' => 'o', 'ś' => 's', 'ź' => 'z', |
||||||
|
'ż' => 'z', |
||||||
|
|
||||||
|
// Latvian |
||||||
|
'Ā' => 'A', 'Č' => 'C', 'Ē' => 'E', 'Ģ' => 'G', 'Ī' => 'i', 'Ķ' => 'k', 'Ļ' => 'L', 'Ņ' => 'N', |
||||||
|
'Š' => 'S', 'Ū' => 'u', 'Ž' => 'Z', |
||||||
|
'ā' => 'a', 'č' => 'c', 'ē' => 'e', 'ģ' => 'g', 'ī' => 'i', 'ķ' => 'k', 'ļ' => 'l', 'ņ' => 'n', |
||||||
|
'š' => 's', 'ū' => 'u', 'ž' => 'z' |
||||||
|
); |
||||||
|
|
||||||
|
// Make custom replacements |
||||||
|
if (!empty($options['replacements'])) { |
||||||
|
$str = preg_replace(array_keys($options['replacements']), $options['replacements'], $str); |
||||||
|
} |
||||||
|
|
||||||
|
// Transliterate characters to ASCII |
||||||
|
if ($options['transliterate']) { |
||||||
|
$str = str_replace(array_keys($char_map), $char_map, $str); |
||||||
|
} |
||||||
|
|
||||||
|
// Replace non-alphanumeric characters with our delimiter |
||||||
|
$str = preg_replace('/[^\p{L}\p{Nd}]+/u', $options['delimiter'], $str); |
||||||
|
|
||||||
|
// Remove duplicate delimiters |
||||||
|
$str = preg_replace('/(' . preg_quote($options['delimiter'], '/') . '){2,}/', '$1', $str); |
||||||
|
|
||||||
|
// Truncate slug to max. characters |
||||||
|
$str = mb_substr($str, 0, ($options['limit'] ? $options['limit'] : mb_strlen($str, 'UTF-8')), 'UTF-8'); |
||||||
|
|
||||||
|
// Remove delimiter from ends |
||||||
|
$str = trim($str, $options['delimiter']); |
||||||
|
|
||||||
|
return $options['lowercase'] ? mb_strtolower($str, 'UTF-8') : $str; |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public static function jakParseurl($var, $var1 = '', $var2 = '', $var3 = '', $var4 = '', $var5 = '', $var6 = '', $var7 = '') |
||||||
|
{ |
||||||
|
|
||||||
|
// Global |
||||||
|
global $BASE_URL; |
||||||
|
|
||||||
|
// Set v to zero |
||||||
|
$v = $v1 = $v2 = $v3 = $v4 = $v5 = $v6 = $v7 = $varname = ''; |
||||||
|
|
||||||
|
// Check if is/not apache and create url |
||||||
|
if (!JAK_USE_APACHE) { |
||||||
|
|
||||||
|
if ($var1) { |
||||||
|
$v = '&sp='.htmlspecialchars($var1); |
||||||
|
} |
||||||
|
if ($var2) { |
||||||
|
$v1 = '&ssp='.htmlspecialchars($var2); |
||||||
|
} |
||||||
|
if ($var3) { |
||||||
|
$v2 = '&sssp='.htmlspecialchars($var3); |
||||||
|
} |
||||||
|
|
||||||
|
if ($var4) { |
||||||
|
$v3 = '&ssssp='.htmlspecialchars($var4); |
||||||
|
} |
||||||
|
|
||||||
|
if ($var5) { |
||||||
|
$v4 = '&sssssp='.htmlspecialchars($var5); |
||||||
|
} |
||||||
|
|
||||||
|
if ($var6) { |
||||||
|
$v5 = '&sssssp='.htmlspecialchars($var6); |
||||||
|
} |
||||||
|
|
||||||
|
if ($var7) { |
||||||
|
$v6 = '&sssssp='.htmlspecialchars($var7); |
||||||
|
} |
||||||
|
|
||||||
|
// if not apache add some stuff to the url |
||||||
|
if ($var) { |
||||||
|
if ($var == JAK_OPERATOR_LOC) { |
||||||
|
$var = JAK_OPERATOR_LOC.'/index.php?p='.htmlspecialchars($var1); |
||||||
|
$varname = (defined('BASE_URL') ? BASE_URL : $BASE_URL).html_entity_decode($var.$v1.$v2.$v3.$v4.$v5.$v6); |
||||||
|
} else { |
||||||
|
$var = 'index.php?p='.htmlspecialchars($var); |
||||||
|
$varname = (defined('BASE_URL') ? BASE_URL : $BASE_URL).html_entity_decode($var.$v.$v1.$v2.$v3.$v4.$v5.$v6); |
||||||
|
} |
||||||
|
} else { |
||||||
|
$var = '/'; |
||||||
|
$varname = (defined('BASE_URL') ? BASE_URL : $BASE_URL).html_entity_decode($var.$v.$v1.$v2.$v3.$v4.$v5.$v6); |
||||||
|
} |
||||||
|
|
||||||
|
} else { |
||||||
|
|
||||||
|
if ($var1) { |
||||||
|
$v = '/'.htmlspecialchars($var1); |
||||||
|
} |
||||||
|
if ($var2) { |
||||||
|
$v1 = '/'.htmlspecialchars($var2); |
||||||
|
} |
||||||
|
if ($var3) { |
||||||
|
$v2 = '/'.htmlspecialchars($var3); |
||||||
|
} |
||||||
|
if ($var4) { |
||||||
|
$v3 = '/'.htmlspecialchars($var4); |
||||||
|
} |
||||||
|
if ($var5) { |
||||||
|
$v4 = '/'.htmlspecialchars($var5); |
||||||
|
} |
||||||
|
if ($var6) { |
||||||
|
$v5 = '/'.htmlspecialchars($var6); |
||||||
|
} |
||||||
|
if ($var7) { |
||||||
|
$v6 = '/'.htmlspecialchars($var7); |
||||||
|
} |
||||||
|
|
||||||
|
// page is always the same |
||||||
|
$var = htmlspecialchars($var); |
||||||
|
|
||||||
|
// Now se the var for apache |
||||||
|
$varname = (defined('BASE_URL') ? BASE_URL : $BASE_URL).$var.$v.$v1.$v2.$v3.$v4.$v5.$v6; |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
if (!empty($varname)) return $varname; |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public static function jakParseurlpaginate($var) { |
||||||
|
|
||||||
|
$varname = ''; |
||||||
|
|
||||||
|
if ($var != 1) { |
||||||
|
// Check if is/not apache and create url |
||||||
|
if (!JAK_USE_APACHE && $var) { |
||||||
|
// Now se the var for none apache |
||||||
|
$varname = '&page='.$var; |
||||||
|
} else { |
||||||
|
// Now se the var for seo apache |
||||||
|
$varname = '/'.$var; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
return $varname; |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public function jakRealrequest() |
||||||
|
{ |
||||||
|
return str_replace(_APP_MAIN_DIR, '', $this->url); |
||||||
|
} |
||||||
|
} |
||||||
|
?> |
@ -0,0 +1,45 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
/*===============================================*\ |
||||||
|
|| ############################################# || |
||||||
|
|| # JAKWEB.CH / Version 1.1 # || |
||||||
|
|| # ----------------------------------------- # || |
||||||
|
|| # Copyright 2020 JAKWEB All Rights Reserved # || |
||||||
|
|| ############################################# || |
||||||
|
\*===============================================*/ |
||||||
|
|
||||||
|
class JAK_user |
||||||
|
{ |
||||||
|
private $data; |
||||||
|
private $lsvar = 0; |
||||||
|
private $username = ''; |
||||||
|
|
||||||
|
public function __construct($row) { |
||||||
|
$this->data = $row; |
||||||
|
} |
||||||
|
|
||||||
|
function jakSuperadminaccess($lsvar) { |
||||||
|
$useridarray = explode(',', JAK_SUPERADMIN); |
||||||
|
// check if userid exist in db.php |
||||||
|
if (in_array($lsvar, $useridarray)) { |
||||||
|
return true; |
||||||
|
} else { |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
function getVar($lsvar) { |
||||||
|
|
||||||
|
// Setting up an alias, so we don't have to write $this->data every time: |
||||||
|
$d = $this->data; |
||||||
|
|
||||||
|
if (isset($d[$lsvar])) { |
||||||
|
return $d[$lsvar]; |
||||||
|
} else { |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
?> |
@ -0,0 +1,362 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
/*===============================================*\ |
||||||
|
|| ############################################# || |
||||||
|
|| # JAKWEB.CH / Version 2.1.2 # || |
||||||
|
|| # ----------------------------------------- # || |
||||||
|
|| # Copyright 2023 JAKWEB All Rights Reserved # || |
||||||
|
|| ############################################# || |
||||||
|
\*===============================================*/ |
||||||
|
|
||||||
|
class JAK_userlogin { |
||||||
|
|
||||||
|
protected $name = '', $email = '', $pass = '', $time = ''; |
||||||
|
var $username; //Username given on sign-up |
||||||
|
|
||||||
|
public function __construct() { |
||||||
|
$this->username = ''; |
||||||
|
} |
||||||
|
|
||||||
|
function jakChecklogged() { |
||||||
|
|
||||||
|
/* Check if user has been remembered */ |
||||||
|
if (isset($_COOKIE['jak_lcp_cookname']) && isset($_COOKIE['jak_lcp_cookid'])) { |
||||||
|
$_SESSION['jak_lcp_username'] = $_COOKIE['jak_lcp_cookname']; |
||||||
|
$_SESSION['jak_lcp_idhash'] = $_COOKIE['jak_lcp_cookid']; |
||||||
|
} |
||||||
|
|
||||||
|
/* Username and idhash have been set */ |
||||||
|
if (isset($_SESSION['jak_lcp_username']) && isset($_SESSION['jak_lcp_idhash']) && $_SESSION['jak_lcp_username'] != $this->username) { |
||||||
|
/* Confirm that username and userid are valid */ |
||||||
|
if (!JAK_userlogin::jakConfirmidhash($_SESSION['jak_lcp_username'], $_SESSION['jak_lcp_idhash'])) { |
||||||
|
/* Variables are incorrect, user not logged in */ |
||||||
|
unset($_SESSION['jak_lcp_username']); |
||||||
|
unset($_SESSION['jak_lcp_idhash']); |
||||||
|
|
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
// Return the user data |
||||||
|
return JAK_userlogin::jakUserinfo($_SESSION['jak_lcp_username']); |
||||||
|
|
||||||
|
/* User not logged in */ |
||||||
|
} else { |
||||||
|
return false; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
function jakCheckrestlogged($userid, $hash) { |
||||||
|
|
||||||
|
/* UserID and Hash have been set */ |
||||||
|
global $jakdb; |
||||||
|
$datauinfo = $jakdb->get("user", "*", ["AND" => ["id" => $userid, "idhash" => $hash]]); |
||||||
|
if (isset($datauinfo) && !empty($datauinfo)) { |
||||||
|
|
||||||
|
// Return the user data |
||||||
|
return $datauinfo; |
||||||
|
|
||||||
|
/* User not logged in */ |
||||||
|
} else { |
||||||
|
return false; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public static function jakCheckuserdata($username, $pass) { |
||||||
|
|
||||||
|
// The new password encrypt with hash_hmac |
||||||
|
$passcrypt = hash_hmac('sha256', $pass, DB_PASS_HASH); |
||||||
|
|
||||||
|
if (!filter_var($username, FILTER_VALIDATE_EMAIL)) { |
||||||
|
|
||||||
|
if (!preg_match('/^([a-zA-Z0-9\-_])+$/', $username)) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
global $jakdb; |
||||||
|
$datausr = $jakdb->get("user", ["id", "username"], ["AND" => ["OR" => ["username" => strtolower($username), "email" => strtolower($username)], "password" => $passcrypt, "access" => 1]]); |
||||||
|
if ($datausr) { |
||||||
|
return $datausr; |
||||||
|
} else { |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public static function jakLogin($name, $pass, $remember) { |
||||||
|
|
||||||
|
// The new password encrypt with hash_hmac |
||||||
|
$passcrypt = hash_hmac('sha256', $pass, DB_PASS_HASH); |
||||||
|
|
||||||
|
global $jakdb; |
||||||
|
|
||||||
|
// Get the stuff out the database |
||||||
|
$datausr = $jakdb->get("user", ["idhash", "logins"], ["AND" => ["username" => $name, "password" => $passcrypt]]); |
||||||
|
|
||||||
|
if ($datausr['logins'] % 10 == 0) { |
||||||
|
|
||||||
|
// Generate new idhash |
||||||
|
$nidhash = JAK_userlogin::generateRandID(); |
||||||
|
|
||||||
|
} else { |
||||||
|
|
||||||
|
if (isset($datausr['idhash']) && !empty($datausr['idhash']) && $datausr['idhash'] != "NULL") { |
||||||
|
|
||||||
|
// Take old idhash |
||||||
|
$nidhash = $datausr['idhash']; |
||||||
|
|
||||||
|
} else { |
||||||
|
|
||||||
|
// Generate new idhash |
||||||
|
$nidhash = JAK_userlogin::generateRandID(); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
// Set session in database |
||||||
|
$jakdb->update("user", ["session" => session_id(), "idhash" => $nidhash, "logins[+]" => 1, "available" => 1, "forgot" => 0, "lastactivity" => time()], ["AND" => ["username" => $name, "password" => $passcrypt]]); |
||||||
|
|
||||||
|
$_SESSION['jak_lcp_username'] = $name; |
||||||
|
$_SESSION['jak_lcp_idhash'] = $nidhash; |
||||||
|
|
||||||
|
// Check if cookies are set previous (wrongly) and delete |
||||||
|
if (isset($_COOKIE['jak_lcp_cookname']) || isset($_COOKIE['jak_lcp_cookid'])) { |
||||||
|
|
||||||
|
JAK_base::jakCookie('jak_lcp_cookname', $name, JAK_COOKIE_TIME, JAK_COOKIE_PATH); |
||||||
|
JAK_base::jakCookie('jak_lcp_cookid', $nidhash, JAK_COOKIE_TIME, JAK_COOKIE_PATH); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
// Now check if remember is selected and set cookies new... |
||||||
|
if ($remember) { |
||||||
|
|
||||||
|
JAK_base::jakCookie('jak_lcp_cookname', $name, JAK_COOKIE_TIME, JAK_COOKIE_PATH); |
||||||
|
JAK_base::jakCookie('jak_lcp_cookid', $nidhash, JAK_COOKIE_TIME, JAK_COOKIE_PATH); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public static function jakrestLogin($name, $pass) { |
||||||
|
|
||||||
|
// The new password encrypt with hash_hmac |
||||||
|
$passcrypt = hash_hmac('sha256', $pass, DB_PASS_HASH); |
||||||
|
|
||||||
|
global $jakdb; |
||||||
|
|
||||||
|
// Get the stuff out the database |
||||||
|
$datausr = $jakdb->get("user",["idhash", "logins"], ["AND" => ["username" => $name, "password" => $passcrypt]]); |
||||||
|
|
||||||
|
if ($datausr['logins'] % 10 == 0) { |
||||||
|
|
||||||
|
// Generate new idhash |
||||||
|
$nidhash = JAK_userlogin::generateRandID(); |
||||||
|
|
||||||
|
} else { |
||||||
|
|
||||||
|
if (isset($datausr['idhash']) && !empty($datausr['idhash']) && $datausr['idhash'] != "NULL") { |
||||||
|
|
||||||
|
// Take old idhash |
||||||
|
$nidhash = $datausr['idhash']; |
||||||
|
|
||||||
|
} else { |
||||||
|
|
||||||
|
// Generate new idhash |
||||||
|
$nidhash = JAK_userlogin::generateRandID(); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
// Set session in database |
||||||
|
$jakdb->update("user", ["session" => session_id(), "idhash" => $nidhash, "logins[+]" => 1, "available" => 1, "forgot" => 0, "lastactivity" => time()], ["AND" => ["username" => $name, "password" => $passcrypt]]); |
||||||
|
|
||||||
|
// Return the user data |
||||||
|
return JAK_userlogin::jakUserinfo($name); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public static function jakWriteDeviceToken($userid, $opid, $device, $token, $appname, $appversion) { |
||||||
|
|
||||||
|
// Check the data before we run any queries |
||||||
|
$allowed_device_types = ['ios', 'android']; |
||||||
|
if (in_array($device, $allowed_device_types) === false) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
if ((strlen(trim($token)) === 0) || (strlen(trim($token)) > 250)) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
$allowed_app_versions = ['LC3', 'HD3']; |
||||||
|
if (in_array($appname, $allowed_app_versions) === false) { |
||||||
|
$appname = 'LC3'; |
||||||
|
} |
||||||
|
|
||||||
|
// trim token |
||||||
|
$token = trim($token); |
||||||
|
|
||||||
|
global $jakdb; |
||||||
|
// Get the info out the database |
||||||
|
$pushid = $jakdb->get("push_notification_devices", "id", ["token" => $token]); |
||||||
|
|
||||||
|
if (isset($pushid) && !empty($pushid)) { |
||||||
|
$jakdb->update("push_notification_devices", ["lastedit" => $jakdb->raw("NOW()")], ["id" => $pushid]); |
||||||
|
} else { |
||||||
|
// We have no entry at all |
||||||
|
$jakdb->insert("push_notification_devices", ["userid" => $userid, "opid" => $opid, "ostype" => $device, "token" => $token, "appname" => $appname, "appversion" => $appversion, "lastedit" => $jakdb->raw("NOW()"), "created" => $jakdb->raw("NOW()")]); |
||||||
|
} |
||||||
|
|
||||||
|
// Remove old entries older than 4 weeks |
||||||
|
$deleteold = strtotime("-4 weeks"); |
||||||
|
$deleteoldmysql = date('Y-m-d H:i:s', $deleteold); |
||||||
|
$jakdb->delete("push_notification_devices", ["lastedit[<]" => $deleteoldmysql]); |
||||||
|
|
||||||
|
return true; |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public static function jakConfirmidhash($username, $idhash) { |
||||||
|
|
||||||
|
global $jakdb; |
||||||
|
|
||||||
|
if (isset($username) && !empty($username)) { |
||||||
|
|
||||||
|
$datausr = $jakdb->get("user","idhash",["AND" => ["username" => $username, "access" => 1]]); |
||||||
|
|
||||||
|
if ($datausr) { |
||||||
|
|
||||||
|
$datausr = stripslashes($datausr); |
||||||
|
$idhash = stripslashes($idhash); |
||||||
|
|
||||||
|
/* Validate that userid is correct */ |
||||||
|
if(!is_null($datausr) && $idhash == $datausr) { |
||||||
|
return true; //Success! Username and idhash confirmed |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
return false; |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public static function jakUserinfo($username) { |
||||||
|
|
||||||
|
global $jakdb; |
||||||
|
$datauinfo = $jakdb->get("user", "*", ["AND" => ["username" => $username, "access" => 1]]); |
||||||
|
if ($datauinfo) { |
||||||
|
return $datauinfo; |
||||||
|
} else { |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public static function jakUpdatelastactivity($userid) { |
||||||
|
|
||||||
|
global $jakdb; |
||||||
|
if (is_numeric($userid)) $jakdb->update("user", ["lastactivity" => time()], ["id" => $userid]); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public static function jakForgotpassword($email, $time) { |
||||||
|
|
||||||
|
global $jakdb; |
||||||
|
if ($jakdb->has("user", ["AND" => ["email" => $email, "access" => 1]])) { |
||||||
|
if ($time != 0) $jakdb->update("user", ["forgot" => $time], ["email" => $email]); |
||||||
|
return true; |
||||||
|
} else { |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public static function jakForgotactive($forgotid) { |
||||||
|
|
||||||
|
global $jakdb; |
||||||
|
if ($jakdb->has("user", ["AND" => ["forgot" => $forgotid, "access" => 1]])) { |
||||||
|
return true; |
||||||
|
} else |
||||||
|
return false; |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public static function jakForgotcheckuser($email, $forgotid) { |
||||||
|
|
||||||
|
global $jakdb; |
||||||
|
if ($jakdb->has("user", ["AND" => ["email" => $email, "forgot" => $forgotid, "access" => 1]])) { |
||||||
|
return true; |
||||||
|
} else |
||||||
|
return false; |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public static function jakWriteloginlog($username, $url, $ip, $agent, $success) { |
||||||
|
|
||||||
|
global $jakdb; |
||||||
|
if ($success == 1) { |
||||||
|
$jakdb->update("loginlog", ["access" => 1], ["AND" => ["ip" => $ip, "time" => $jakdb->raw("NOW()")]]); |
||||||
|
} else { |
||||||
|
$jakdb->insert("loginlog", ["name" => $username, "fromwhere" => $url, "usragent" => $agent, "ip" => $ip, "time" => $jakdb->raw("NOW()"), "access" => 0]); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public static function jakLogout($userid) { |
||||||
|
|
||||||
|
global $jakdb; |
||||||
|
|
||||||
|
// Delete cookies from this page |
||||||
|
JAK_base::jakCookie('jak_lcp_cookname', '', -JAK_COOKIE_TIME, JAK_COOKIE_PATH); |
||||||
|
JAK_base::jakCookie('jak_lcp_cookid', '', - JAK_COOKIE_TIME, JAK_COOKIE_PATH); |
||||||
|
|
||||||
|
// Update Database to session NULL |
||||||
|
$jakdb->update("user", ["session" => $jakdb->raw("NULL"), "idhash" => $jakdb->raw("NULL"), "available" => 0], ["id" => $userid]); |
||||||
|
|
||||||
|
// Unset the main sessions |
||||||
|
unset($_SESSION['jak_lcp_username']); |
||||||
|
unset($_SESSION['jak_lcp_idhash']); |
||||||
|
unset($_SESSION['jak_lcp_lang']); |
||||||
|
|
||||||
|
// Destroy session and generate new one for that user |
||||||
|
session_destroy(); |
||||||
|
|
||||||
|
// Start new session |
||||||
|
session_start(); |
||||||
|
session_regenerate_id(); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public static function jakLogoutRest($userid) { |
||||||
|
|
||||||
|
global $jakdb; |
||||||
|
|
||||||
|
// Update Database to session NULL |
||||||
|
$jakdb->update("user", ["session" => $jakdb->raw("NULL"), "idhash" => $jakdb->raw("NULL"), "available" => 0], ["id" => $userid]); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public static function generateRandStr($length) { |
||||||
|
$randstr = ""; |
||||||
|
for($i=0; $i<$length; $i++){ |
||||||
|
$randnum = mt_rand(0,61); |
||||||
|
if($randnum < 10){ |
||||||
|
$randstr .= chr($randnum+48); |
||||||
|
}else if($randnum < 36){ |
||||||
|
$randstr .= chr($randnum+55); |
||||||
|
}else{ |
||||||
|
$randstr .= chr($randnum+61); |
||||||
|
} |
||||||
|
} |
||||||
|
return $randstr; |
||||||
|
} |
||||||
|
|
||||||
|
private static function generateRandID() { |
||||||
|
return md5(JAK_userlogin::generateRandStr(16)); |
||||||
|
} |
||||||
|
} |
||||||
|
?> |
@ -0,0 +1,480 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace Emojione; |
||||||
|
|
||||||
|
/** |
||||||
|
* Client for Emojione |
||||||
|
*/ |
||||||
|
|
||||||
|
class Client implements ClientInterface |
||||||
|
{ |
||||||
|
public $ascii = false; // convert ascii smileys? |
||||||
|
public $unicodeAlt = true; // use the unicode char as the alt attribute (makes copy and pasting the resulting text better) |
||||||
|
public $imageType = 'png'; // or svg |
||||||
|
public $cacheBustParam = '?v=2.2.5'; |
||||||
|
public $sprites = false; |
||||||
|
public $imagePathPNG = '//cdn.jsdelivr.net/emojione/assets/png/'; |
||||||
|
public $imagePathSVG = '//cdn.jsdelivr.net/emojione/assets/svg/'; |
||||||
|
public $imagePathSVGSprites = './../../assets/sprites/emojione.sprites.svg'; |
||||||
|
public $unicode_replaceWith = false; |
||||||
|
public $ignoredRegexp = '<object[^>]*>.*?<\/object>|<span[^>]*>.*?<\/span>|<(?:object|embed|svg|img|div|span|p|a)[^>]*>'; |
||||||
|
public $unicodeRegexp = '([*#0-9](?>\\xEF\\xB8\\x8F)?\\xE2\\x83\\xA3|\\xC2[\\xA9\\xAE]|\\xE2..(\\xF0\\x9F\\x8F[\\xBB-\\xBF])?(?>\\xEF\\xB8\\x8F)?|\\xE3(?>\\x80[\\xB0\\xBD]|\\x8A[\\x97\\x99])(?>\\xEF\\xB8\\x8F)?|\\xF0\\x9F(?>[\\x80-\\x86].(?>\\xEF\\xB8\\x8F)?|\\x87.\\xF0\\x9F\\x87.|..((\\xE2\\x80\\x8D\\xF0\\x9F\\x97\\xA8)|(\\xF0\\x9F\\x8F[\\xBB-\\xBF])|(\\xE2\\x80\\x8D\\xF0\\x9F\\x91[\\xA6-\\xA9]){2,3}|(\\xE2\\x80\\x8D\\xE2\\x9D\\xA4\\xEF\\xB8\\x8F\\xE2\\x80\\x8D\\xF0\\x9F..(\\xE2\\x80\\x8D\\xF0\\x9F\\x91[\\xA6-\\xA9])?))?))'; |
||||||
|
|
||||||
|
public $shortcodeRegexp = ':([-+\\w]+):'; |
||||||
|
|
||||||
|
protected $ruleset = null; |
||||||
|
|
||||||
|
public function __construct(RulesetInterface $ruleset = null) |
||||||
|
{ |
||||||
|
if ( ! is_null($ruleset) ) |
||||||
|
{ |
||||||
|
$this->ruleset = $ruleset; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// ########################################## |
||||||
|
// ######## core methods |
||||||
|
// ########################################## |
||||||
|
|
||||||
|
/** |
||||||
|
* First pass changes unicode characters into emoji markup. |
||||||
|
* Second pass changes any shortnames into emoji markup. |
||||||
|
* |
||||||
|
* @param string $string The input string. |
||||||
|
* @return string String with appropriate html for rendering emoji. |
||||||
|
*/ |
||||||
|
public function toImage($string) |
||||||
|
{ |
||||||
|
$string = $this->unicodeToImage($string); |
||||||
|
$string = $this->shortnameToImage($string); |
||||||
|
return $string; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Uses toShort to transform all unicode into a standard shortname |
||||||
|
* then transforms the shortname into unicode. |
||||||
|
* This is done for standardization when converting several unicode types. |
||||||
|
* |
||||||
|
* @param string $string The input string. |
||||||
|
* @return string String with standardized unicode. |
||||||
|
*/ |
||||||
|
public function unifyUnicode($string) |
||||||
|
{ |
||||||
|
$string = $this->toShort($string); |
||||||
|
$string = $this->shortnameToUnicode($string); |
||||||
|
return $string; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* This will output unicode from shortname input. |
||||||
|
* If Client/$ascii is true it will also output unicode from ascii. |
||||||
|
* This is useful for sending emojis back to mobile devices. |
||||||
|
* |
||||||
|
* @param string $string The input string. |
||||||
|
* @return string String with unicode replacements. |
||||||
|
*/ |
||||||
|
public function shortnameToUnicode($string) |
||||||
|
{ |
||||||
|
$string = preg_replace_callback('/'.$this->ignoredRegexp.'|('.$this->shortcodeRegexp.')/Si', array($this, 'shortnameToUnicodeCallback'), $string); |
||||||
|
|
||||||
|
if ($this->ascii) |
||||||
|
{ |
||||||
|
$ruleset = $this->getRuleset(); |
||||||
|
$asciiRegexp = $ruleset->getAsciiRegexp(); |
||||||
|
|
||||||
|
$string = preg_replace_callback('/'.$this->ignoredRegexp.'|((\\s|^)'.$asciiRegexp.'(?=\\s|$|[!,.?]))/S', array($this, 'asciiToUnicodeCallback'), $string); |
||||||
|
} |
||||||
|
|
||||||
|
return $string; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* This will replace shortnames with their ascii equivalent. |
||||||
|
* ex. :wink: --> ;^) |
||||||
|
* This is useful for systems that don't support unicode or images. |
||||||
|
* |
||||||
|
* @param string $string The input string. |
||||||
|
* @return string String with ascii replacements. |
||||||
|
*/ |
||||||
|
public function shortnameToAscii($string) |
||||||
|
{ |
||||||
|
$string = preg_replace_callback('/'.$this->ignoredRegexp.'|('.$this->shortcodeRegexp.')/Si', array($this, 'shortnameToAsciiCallback'), $string); |
||||||
|
|
||||||
|
return $string; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* This will output image markup (for png or svg) from shortname input. |
||||||
|
* |
||||||
|
* @param string $string The input string. |
||||||
|
* @return string String with appropriate html for rendering emoji. |
||||||
|
*/ |
||||||
|
public function shortnameToImage($string) |
||||||
|
{ |
||||||
|
$string = preg_replace_callback('/'.$this->ignoredRegexp.'|('.$this->shortcodeRegexp.')/Si', array($this, 'shortnameToImageCallback'), $string); |
||||||
|
|
||||||
|
if ($this->ascii) |
||||||
|
{ |
||||||
|
$ruleset = $this->getRuleset(); |
||||||
|
$asciiRegexp = $ruleset->getAsciiRegexp(); |
||||||
|
|
||||||
|
$string = preg_replace_callback('/'.$this->ignoredRegexp.'|((\\s|^)'.$asciiRegexp.'(?=\\s|$|[!,.?]))/S', array($this, 'asciiToImageCallback'), $string); |
||||||
|
} |
||||||
|
|
||||||
|
return $string; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* This will return the shortname from unicode input. |
||||||
|
* |
||||||
|
* @param string $string The input string. |
||||||
|
* @return string shortname |
||||||
|
*/ |
||||||
|
public function toShort($string) |
||||||
|
{ |
||||||
|
return preg_replace_callback('/'.$this->ignoredRegexp.'|'.$this->unicodeRegexp.'/S', array($this, 'toShortCallback'), $string); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* This will output image markup (for png or svg) from unicode input. |
||||||
|
* |
||||||
|
* @param string $string The input string. |
||||||
|
* @return string String with appropriate html for rendering emoji. |
||||||
|
*/ |
||||||
|
public function unicodeToImage($string) |
||||||
|
{ |
||||||
|
return preg_replace_callback('/'.$this->ignoredRegexp.'|'.$this->unicodeRegexp.'/S', array($this, 'unicodeToImageCallback'), $string); |
||||||
|
} |
||||||
|
|
||||||
|
// ########################################## |
||||||
|
// ######## preg_replace callbacks |
||||||
|
// ########################################## |
||||||
|
|
||||||
|
/** |
||||||
|
* @param array $m Results of preg_replace_callback(). |
||||||
|
* @return string Ascii replacement result. |
||||||
|
*/ |
||||||
|
public function shortnameToAsciiCallback($m) |
||||||
|
{ |
||||||
|
if ((!is_array($m)) || (!isset($m[1])) || (empty($m[1]))) |
||||||
|
{ |
||||||
|
return $m[0]; |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
$ruleset = $this->getRuleset(); |
||||||
|
$shortcode_replace = $ruleset->getShortcodeReplace(); |
||||||
|
$ascii_replace = $ruleset->getAsciiReplace(); |
||||||
|
|
||||||
|
$aflipped = array_flip($ascii_replace); |
||||||
|
|
||||||
|
$shortname = $m[0]; |
||||||
|
|
||||||
|
if (!isset($shortcode_replace[$shortname])) |
||||||
|
{ |
||||||
|
return $m[0]; |
||||||
|
} |
||||||
|
|
||||||
|
$unicode = $shortcode_replace[$shortname]; |
||||||
|
|
||||||
|
return isset($aflipped[$unicode]) ? $aflipped[$unicode] : $m[0]; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @param array $m Results of preg_replace_callback(). |
||||||
|
* @return string Unicode replacement result. |
||||||
|
*/ |
||||||
|
public function shortnameToUnicodeCallback($m) |
||||||
|
{ |
||||||
|
if ((!is_array($m)) || (!isset($m[1])) || (empty($m[1]))) { |
||||||
|
return $m[0]; |
||||||
|
} |
||||||
|
else { |
||||||
|
$ruleset = $this->getRuleset(); |
||||||
|
$unicode_replace = $ruleset->getUnicodeReplace(); |
||||||
|
|
||||||
|
|
||||||
|
$shortname = $m[1]; |
||||||
|
|
||||||
|
if (!array_key_exists($shortname, $unicode_replace)) { |
||||||
|
return $m[0]; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
$unicode = $unicode_replace[$shortname]; |
||||||
|
|
||||||
|
return $unicode; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @param array $m Results of preg_replace_callback(). |
||||||
|
* @return string Image HTML replacement result. |
||||||
|
*/ |
||||||
|
public function shortnameToImageCallback($m) |
||||||
|
{ |
||||||
|
if ((!is_array($m)) || (!isset($m[1])) || (empty($m[1]))) { |
||||||
|
return $m[0]; |
||||||
|
} |
||||||
|
else { |
||||||
|
$ruleset = $this->getRuleset(); |
||||||
|
$shortcode_replace = $ruleset->getShortcodeReplace(); |
||||||
|
|
||||||
|
$shortname = $m[1]; |
||||||
|
|
||||||
|
if (!isset($shortcode_replace[$shortname])) |
||||||
|
{ |
||||||
|
return $m[0]; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
$unicode = $shortcode_replace[$shortname]; |
||||||
|
$filename = $unicode; |
||||||
|
|
||||||
|
if ($this->unicodeAlt) |
||||||
|
{ |
||||||
|
$alt = $this->convert($unicode); |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
$alt = $shortname; |
||||||
|
} |
||||||
|
|
||||||
|
if ($this->imageType == 'png') |
||||||
|
{ |
||||||
|
if ($this->sprites) |
||||||
|
{ |
||||||
|
return '<span class="emojione emojione-'.$unicode.'" title="'.htmlspecialchars($shortname).'">'.$alt.'</span>'; |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
return '<img class="emojione" data-shortname="'.$shortname.'" alt="'.$alt.'" src="'.$this->imagePathPNG.$filename.'.png'.$this->cacheBustParam.'"/>'; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
if ($this->sprites) |
||||||
|
{ |
||||||
|
return '<svg class="emojione"><description>'.$alt.'</description><use xlink:href="'.$this->imagePathSVGSprites.'#emoji-'.$unicode.'"></use></svg>'; |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
return '<object class="emojione" data="'.$this->imagePathSVG.$filename.'.svg'.$this->cacheBustParam.'" type="image/svg+xml" standby="'.$alt.'">'.$alt.'</object>'; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @param array $m Results of preg_replace_callback(). |
||||||
|
* @return string Unicode replacement result. |
||||||
|
*/ |
||||||
|
public function asciiToUnicodeCallback($m) |
||||||
|
{ |
||||||
|
if ((!is_array($m)) || (!isset($m[3])) || (empty($m[3]))) |
||||||
|
{ |
||||||
|
return $m[0]; |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
$ruleset = $this->getRuleset(); |
||||||
|
$ascii_replace = $ruleset->getAsciiReplace(); |
||||||
|
|
||||||
|
$shortname = $m[3]; |
||||||
|
$unicode = $ascii_replace[$shortname]; |
||||||
|
return $m[2].$this->convert($unicode); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @param array $m Results of preg_replace_callback(). |
||||||
|
* @return string Image HTML replacement result. |
||||||
|
*/ |
||||||
|
public function asciiToImageCallback($m) |
||||||
|
{ |
||||||
|
if ((!is_array($m)) || (!isset($m[3])) || (empty($m[3]))) |
||||||
|
{ |
||||||
|
return $m[0]; |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
$ruleset = $this->getRuleset(); |
||||||
|
$ascii_replace = $ruleset->getAsciiReplace(); |
||||||
|
|
||||||
|
$shortname = html_entity_decode($m[3]); |
||||||
|
$unicode = $ascii_replace[$shortname]; |
||||||
|
|
||||||
|
// unicode char or shortname for the alt tag? (unicode is better for copying and pasting the resulting text) |
||||||
|
if ($this->unicodeAlt) |
||||||
|
{ |
||||||
|
$alt = $this->convert($unicode); |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
$alt = htmlspecialchars($shortname); |
||||||
|
} |
||||||
|
|
||||||
|
if ($this->imageType == 'png') |
||||||
|
{ |
||||||
|
if ($this->sprites) |
||||||
|
{ |
||||||
|
return $m[2].'<span class="emojione emojione-'.$unicode.'" title="'.htmlspecialchars($shortname).'">'.$alt.'</span>'; |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
return $m[2].'<img class="emojione" alt="'.$alt.'" src="'.$this->imagePathPNG.$unicode.'.png'.$this->cacheBustParam.'"/>'; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
if ($this->sprites) |
||||||
|
{ |
||||||
|
return $m[2].'<svg class="emojione"><description>'.$alt.'</description><use xlink:href="'.$this->imagePathSVGSprites.'#emoji-'.$unicode.'"></use></svg>'; |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
return $m[2].'<object class="emojione" data="'.$this->imagePathSVG.$unicode.'.svg'.$this->cacheBustParam.'" type="image/svg+xml" standby="'.$alt.'">'.$alt.'</object>'; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @param array $m Results of preg_replace_callback(). |
||||||
|
* @return string shortname result |
||||||
|
*/ |
||||||
|
public function toShortCallback($m) |
||||||
|
{ |
||||||
|
if ((!is_array($m)) || (!isset($m[1])) || (empty($m[1]))) |
||||||
|
{ |
||||||
|
return $m[0]; |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
$ruleset = $this->getRuleset(); |
||||||
|
$unicode_replace = $ruleset->getUnicodeReplace(); |
||||||
|
|
||||||
|
$unicode = $m[1]; |
||||||
|
|
||||||
|
if (!in_array($unicode, $unicode_replace)) |
||||||
|
{ |
||||||
|
$unicode .= "\xEF\xB8\x8F"; |
||||||
|
|
||||||
|
if (!in_array($unicode, $unicode_replace)) |
||||||
|
{ |
||||||
|
$unicode = substr($m[1], 0, 4); |
||||||
|
|
||||||
|
if (!in_array($unicode, $unicode_replace)) |
||||||
|
{ |
||||||
|
return $m[0]; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
return array_search($unicode, $unicode_replace); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @param array $m Results of preg_replace_callback(). |
||||||
|
* @return string Image HTML replacement result. |
||||||
|
*/ |
||||||
|
public function unicodeToImageCallback($m) |
||||||
|
{ |
||||||
|
if ((!is_array($m)) || (!isset($m[1])) || (empty($m[1]))) |
||||||
|
{ |
||||||
|
return $m[0]; |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
$ruleset = $this->getRuleset(); |
||||||
|
$shortcode_replace = $ruleset->getShortcodeReplace(); |
||||||
|
$unicode_replace = $ruleset->getUnicodeReplace(); |
||||||
|
|
||||||
|
$unicode = $m[1]; |
||||||
|
|
||||||
|
if (!in_array($unicode, $unicode_replace)) |
||||||
|
{ |
||||||
|
$unicode .= "\xEF\xB8\x8F"; |
||||||
|
|
||||||
|
if (!in_array($unicode, $unicode_replace)) |
||||||
|
{ |
||||||
|
$unicode = substr($m[1], 0, 4); |
||||||
|
|
||||||
|
if (!in_array($unicode, $unicode_replace)) |
||||||
|
{ |
||||||
|
return $m[0]; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
$shortname = array_search($unicode, $unicode_replace); |
||||||
|
$filename = $shortcode_replace[$shortname]; |
||||||
|
|
||||||
|
if ($this->unicodeAlt) |
||||||
|
{ |
||||||
|
$alt = $unicode; |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
$alt = $shortname; |
||||||
|
} |
||||||
|
|
||||||
|
if ($this->imageType == 'png') |
||||||
|
{ |
||||||
|
if ($this->sprites) |
||||||
|
{ |
||||||
|
return '<span class="emojione emojione-'.$filename.'" title="'.htmlspecialchars($shortname).'">'.$alt.'</span>'; |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
return '<img class="emojione" alt="'.$alt.'" src="'.$this->imagePathPNG.$filename.'.png'.$this->cacheBustParam.'"/>'; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
if ($this->sprites) |
||||||
|
{ |
||||||
|
return '<svg class="emojione"><description>'.$alt.'</description><use xlink:href="'.$this->imagePathSVGSprites.'#emoji-'.$filename.'"></use></svg>'; |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
return '<object class="emojione" data="'.$this->imagePathSVG.$filename.'.svg'.$this->cacheBustParam.'" type="image/svg+xml" standby="'.$alt.'">'.$alt.'</object>'; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// ########################################## |
||||||
|
// ######## helper methods |
||||||
|
// ########################################## |
||||||
|
|
||||||
|
/** |
||||||
|
* Converts from unicode to hexadecimal NCR. |
||||||
|
* |
||||||
|
* @param string $unicode unicode character/s |
||||||
|
* @return string hexadecimal NCR |
||||||
|
* */ |
||||||
|
public function convert($unicode) |
||||||
|
{ |
||||||
|
if (stristr($unicode,'-')) |
||||||
|
{ |
||||||
|
$pairs = explode('-',$unicode); |
||||||
|
return '&#x'.implode(';&#x',$pairs).';'; |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
return '&#x'.$unicode.';'; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the Ruleset |
||||||
|
* |
||||||
|
* @return RulesetInterface The Ruleset |
||||||
|
*/ |
||||||
|
public function getRuleset() |
||||||
|
{ |
||||||
|
if ( $this->ruleset === null ) |
||||||
|
{ |
||||||
|
$this->ruleset = new Ruleset; |
||||||
|
} |
||||||
|
|
||||||
|
return $this->ruleset; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,70 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace Emojione; |
||||||
|
|
||||||
|
|
||||||
|
interface ClientInterface |
||||||
|
{ |
||||||
|
/** |
||||||
|
* First pass changes unicode characters into emoji markup. |
||||||
|
* Second pass changes any shortnames into emoji markup. |
||||||
|
* |
||||||
|
* @param string $string The input string. |
||||||
|
* @return string String with appropriate html for rendering emoji. |
||||||
|
*/ |
||||||
|
public function toImage($string); |
||||||
|
|
||||||
|
/** |
||||||
|
* Uses toShort to transform all unicode into a standard shortname |
||||||
|
* then transforms the shortname into unicode. |
||||||
|
* This is done for standardization when converting several unicode types. |
||||||
|
* |
||||||
|
* @param string $string The input string. |
||||||
|
* @return string String with standardized unicode. |
||||||
|
*/ |
||||||
|
public function unifyUnicode($string); |
||||||
|
|
||||||
|
/** |
||||||
|
* This will output unicode from shortname input. |
||||||
|
* If Client/$ascii is true it will also output unicode from ascii. |
||||||
|
* This is useful for sending emojis back to mobile devices. |
||||||
|
* |
||||||
|
* @param string $string The input string. |
||||||
|
* @return string String with unicode replacements. |
||||||
|
*/ |
||||||
|
public function shortnameToUnicode($string); |
||||||
|
|
||||||
|
/** |
||||||
|
* This will replace shortnames with their ascii equivalent. |
||||||
|
* ex. :wink: --> ;^) |
||||||
|
* This is useful for systems that don't support unicode or images. |
||||||
|
* |
||||||
|
* @param string $string The input string. |
||||||
|
* @return string String with ascii replacements. |
||||||
|
*/ |
||||||
|
public function shortnameToAscii($string); |
||||||
|
|
||||||
|
/** |
||||||
|
* This will output image markup (for png or svg) from shortname input. |
||||||
|
* |
||||||
|
* @param string $string The input string. |
||||||
|
* @return string String with appropriate html for rendering emoji. |
||||||
|
*/ |
||||||
|
public function shortnameToImage($string); |
||||||
|
|
||||||
|
/** |
||||||
|
* This will return the shortname from unicode input. |
||||||
|
* |
||||||
|
* @param string $string The input string. |
||||||
|
* @return string shortname |
||||||
|
*/ |
||||||
|
public function toShort($string); |
||||||
|
|
||||||
|
/** |
||||||
|
* This will output image markup (for png or svg) from unicode input. |
||||||
|
* |
||||||
|
* @param string $string The input string. |
||||||
|
* @return string String with appropriate html for rendering emoji. |
||||||
|
*/ |
||||||
|
public function unicodeToImage($string); |
||||||
|
} |
@ -0,0 +1,116 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace Emojione; |
||||||
|
|
||||||
|
class Emojione |
||||||
|
{ |
||||||
|
public static $ascii = false; // convert ascii smileys? |
||||||
|
public static $unicodeAlt = true; // use the unicode char as the alt attribute (makes copy and pasting the resulting text better) |
||||||
|
public static $imageType = 'png'; |
||||||
|
public static $cacheBustParam = '?v=2.2.5'; |
||||||
|
public static $sprites = false; |
||||||
|
public static $imagePathPNG = '//cdn.jsdelivr.net/emojione/assets/png/'; |
||||||
|
public static $imagePathSVG = '//cdn.jsdelivr.net/emojione/assets/svg/'; |
||||||
|
public static $imagePathSVGSprites = './../../assets/sprites/emojione.sprites.svg'; |
||||||
|
public static $ignoredRegexp = '<object[^>]*>.*?<\/object>|<span[^>]*>.*?<\/span>|<(?:object|embed|svg|img|div|span|p|a)[^>]*>'; |
||||||
|
public static $unicodeRegexp = '([*#0-9](?>\\xEF\\xB8\\x8F)?\\xE2\\x83\\xA3|\\xC2[\\xA9\\xAE]|\\xE2..(\\xF0\\x9F\\x8F[\\xBB-\\xBF])?(?>\\xEF\\xB8\\x8F)?|\\xE3(?>\\x80[\\xB0\\xBD]|\\x8A[\\x97\\x99])(?>\\xEF\\xB8\\x8F)?|\\xF0\\x9F(?>[\\x80-\\x86].(?>\\xEF\\xB8\\x8F)?|\\x87.\\xF0\\x9F\\x87.|..((\\xE2\\x80\\x8D\\xF0\\x9F\\x97\\xA8)|(\\xF0\\x9F\\x8F[\\xBB-\\xBF])|(\\xE2\\x80\\x8D\\xF0\\x9F\\x91[\\xA6-\\xA9]){2,3}|(\\xE2\\x80\\x8D\\xE2\\x9D\\xA4\\xEF\\xB8\\x8F\\xE2\\x80\\x8D\\xF0\\x9F..(\\xE2\\x80\\x8D\\xF0\\x9F\\x91[\\xA6-\\xA9])?))?))'; |
||||||
|
public static $shortcodeRegexp = ':([-+\\w]+):'; |
||||||
|
|
||||||
|
protected static $client = null; |
||||||
|
|
||||||
|
/** |
||||||
|
* Magic caller |
||||||
|
* |
||||||
|
* @throws \BadMethodCallException If the method doesn't exists in client |
||||||
|
*/ |
||||||
|
public static function __callStatic($method, $args) |
||||||
|
{ |
||||||
|
$client = static::getClient(); |
||||||
|
|
||||||
|
// DEPRECATED |
||||||
|
static::updateConfig($client); |
||||||
|
|
||||||
|
if ( ! method_exists($client, $method) ) |
||||||
|
{ |
||||||
|
throw new \BadMethodCallException('The method "' . $method . '" does not exist.'); |
||||||
|
} |
||||||
|
|
||||||
|
return call_user_func_array(array($client, $method), $args); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the Client |
||||||
|
* |
||||||
|
* @return ClientInterface The Client |
||||||
|
*/ |
||||||
|
public static function getClient() |
||||||
|
{ |
||||||
|
if ( static::$client === null ) |
||||||
|
{ |
||||||
|
static::setClient(new Client); |
||||||
|
} |
||||||
|
|
||||||
|
return static::$client; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Set the Client |
||||||
|
* |
||||||
|
* @param ClientInterface $client The Client |
||||||
|
* @return void |
||||||
|
*/ |
||||||
|
public static function setClient(ClientInterface $client) |
||||||
|
{ |
||||||
|
// DEPRECATED |
||||||
|
static::loadConfig($client); |
||||||
|
|
||||||
|
static::$client = $client; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Load config from Client |
||||||
|
* |
||||||
|
* @deprecated |
||||||
|
* |
||||||
|
* @param ClientInterface $client The Client |
||||||
|
* @return self |
||||||
|
*/ |
||||||
|
protected static function loadConfig(ClientInterface $client) |
||||||
|
{ |
||||||
|
static::$ascii = $client->ascii; |
||||||
|
static::$unicodeAlt = $client->unicodeAlt; |
||||||
|
static::$imageType = $client->imageType; |
||||||
|
static::$cacheBustParam = $client->cacheBustParam; |
||||||
|
static::$sprites = $client->sprites; |
||||||
|
static::$imagePathPNG = $client->imagePathPNG; |
||||||
|
static::$imagePathSVG = $client->imagePathSVG; |
||||||
|
static::$imagePathSVGSprites = $client->imagePathSVGSprites; |
||||||
|
static::$ignoredRegexp = $client->ignoredRegexp; |
||||||
|
static::$unicodeRegexp = $client->unicodeRegexp; |
||||||
|
static::$shortcodeRegexp = $client->shortcodeRegexp; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Update config in Client |
||||||
|
* |
||||||
|
* @deprecated |
||||||
|
* |
||||||
|
* @param ClientInterface $client The Client |
||||||
|
* @return self |
||||||
|
*/ |
||||||
|
protected static function updateConfig(ClientInterface $client) |
||||||
|
{ |
||||||
|
$client->ascii = static::$ascii; |
||||||
|
$client->unicodeAlt = static::$unicodeAlt; |
||||||
|
$client->imageType = static::$imageType; |
||||||
|
$client->cacheBustParam = static::$cacheBustParam; |
||||||
|
$client->sprites = static::$sprites; |
||||||
|
$client->imagePathPNG = static::$imagePathPNG; |
||||||
|
$client->imagePathSVG = static::$imagePathSVG; |
||||||
|
$client->imagePathSVGSprites = static::$imagePathSVGSprites; |
||||||
|
$client->ignoredRegexp = static::$ignoredRegexp; |
||||||
|
$client->unicodeRegexp = static::$unicodeRegexp; |
||||||
|
$client->shortcodeRegexp = static::$shortcodeRegexp; |
||||||
|
} |
||||||
|
} |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,34 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace Emojione; |
||||||
|
|
||||||
|
interface RulesetInterface |
||||||
|
{ |
||||||
|
/** |
||||||
|
* Returns the shortcode unicode replacement rules |
||||||
|
* |
||||||
|
* @return array The shortcode unicode rules |
||||||
|
*/ |
||||||
|
public function getShortcodeReplace(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Returns the ascii unicode replacement rules |
||||||
|
* |
||||||
|
* @return array The ascii unicode rules |
||||||
|
*/ |
||||||
|
public function getAsciiReplace(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Returns the unicode shortcode replacement rules |
||||||
|
* |
||||||
|
* @return array The unicode shortcode rules |
||||||
|
*/ |
||||||
|
public function getUnicodeReplace(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Returns the regexp to find ascii smilies |
||||||
|
* |
||||||
|
* @return string The regexp |
||||||
|
*/ |
||||||
|
public function getAsciiRegexp(); |
||||||
|
} |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,21 @@ |
|||||||
|
The MIT License |
||||||
|
|
||||||
|
Copyright (c) 2012 - 2Checkout.com, Inc. |
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy |
||||||
|
of this software and associated documentation files (the "Software"), to deal |
||||||
|
in the Software without restriction, including without limitation the rights |
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||||
|
copies of the Software, and to permit persons to whom the Software is |
||||||
|
furnished to do so, subject to the following conditions: |
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all |
||||||
|
copies or substantial portions of the Software. |
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
||||||
|
SOFTWARE. |
@ -0,0 +1,310 @@ |
|||||||
|
2Checkout PHP Library |
||||||
|
===================== |
||||||
|
|
||||||
|
This library provides developers with a simple set of bindings to the 2Checkout Payment API, Hosted Checkout, Instant Notification Service and Admin API. |
||||||
|
|
||||||
|
To use, download or clone the repository. |
||||||
|
|
||||||
|
```shell |
||||||
|
git clone https://github.com/2Checkout/2checkout-php.git |
||||||
|
``` |
||||||
|
|
||||||
|
Require in your php script. |
||||||
|
|
||||||
|
```php |
||||||
|
require_once("/path/to/2checkout-php/lib/Twocheckout.php"); |
||||||
|
``` |
||||||
|
|
||||||
|
All methods return an Array by default or you can set the format to 'json' to get a JSON response. |
||||||
|
**Example:** |
||||||
|
```php |
||||||
|
<?php |
||||||
|
Twocheckout::format('json'); |
||||||
|
``` |
||||||
|
|
||||||
|
|
||||||
|
Credentials and Options |
||||||
|
----------------- |
||||||
|
|
||||||
|
Methods are provided to set the following credentials and options. |
||||||
|
|
||||||
|
```php |
||||||
|
<?php |
||||||
|
|
||||||
|
// Your sellerId(account number) and privateKey are required to make the Payment API Authorization call. |
||||||
|
Twocheckout::privateKey('BE632CB0-BB29-11E3-AFB6-D99C28100996'); |
||||||
|
Twocheckout::sellerId('901248204'); |
||||||
|
|
||||||
|
// Your username and password are required to make any Admin API call. |
||||||
|
Twocheckout::username('testlibraryapi901248204'); |
||||||
|
Twocheckout::password('testlibraryapi901248204PASS'); |
||||||
|
|
||||||
|
// If you want to turn off SSL verification (Please don't do this in your production environment) |
||||||
|
Twocheckout::verifySSL(false); // this is set to true by default |
||||||
|
|
||||||
|
// To use your sandbox account set sandbox to true |
||||||
|
Twocheckout::sandbox(true); |
||||||
|
|
||||||
|
// All methods return an Array by default or you can set the format to 'json' to get a JSON response. |
||||||
|
Twocheckout::format('json'); |
||||||
|
|
||||||
|
``` |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Full documentation for each binding is provided in the **[wiki](https://github.com/2Checkout/2checkout-php/wiki)**. |
||||||
|
|
||||||
|
Example Payment API Usage |
||||||
|
----------------- |
||||||
|
|
||||||
|
*Example Request:* |
||||||
|
|
||||||
|
```php |
||||||
|
<?php |
||||||
|
|
||||||
|
Twocheckout::privateKey('BE632CB0-BB29-11E3-AFB6-D99C28100996'); |
||||||
|
Twocheckout::sellerId('901248204'); |
||||||
|
|
||||||
|
try { |
||||||
|
$charge = Twocheckout_Charge::auth(array( |
||||||
|
"sellerId" => "901248204", |
||||||
|
"merchantOrderId" => "123", |
||||||
|
"token" => 'MjFiYzIzYjAtYjE4YS00ZmI0LTg4YzYtNDIzMTBlMjc0MDlk', |
||||||
|
"currency" => 'USD', |
||||||
|
"total" => '10.00', |
||||||
|
"billingAddr" => array( |
||||||
|
"name" => 'Testing Tester', |
||||||
|
"addrLine1" => '123 Test St', |
||||||
|
"city" => 'Columbus', |
||||||
|
"state" => 'OH', |
||||||
|
"zipCode" => '43123', |
||||||
|
"country" => 'USA', |
||||||
|
"email" => 'testingtester@2co.com', |
||||||
|
"phoneNumber" => '555-555-5555' |
||||||
|
), |
||||||
|
"shippingAddr" => array( |
||||||
|
"name" => 'Testing Tester', |
||||||
|
"addrLine1" => '123 Test St', |
||||||
|
"city" => 'Columbus', |
||||||
|
"state" => 'OH', |
||||||
|
"zipCode" => '43123', |
||||||
|
"country" => 'USA', |
||||||
|
"email" => 'testingtester@2co.com', |
||||||
|
"phoneNumber" => '555-555-5555' |
||||||
|
) |
||||||
|
)); |
||||||
|
$this->assertEquals('APPROVED', $charge['response']['responseCode']); |
||||||
|
} catch (Twocheckout_Error $e) { |
||||||
|
$this->assertEquals('Unauthorized', $e->getMessage()); |
||||||
|
} |
||||||
|
``` |
||||||
|
|
||||||
|
*Example Response:* |
||||||
|
|
||||||
|
```php |
||||||
|
Array |
||||||
|
( |
||||||
|
[validationErrors] => |
||||||
|
[exception] => |
||||||
|
[response] => Array |
||||||
|
( |
||||||
|
[type] => AuthResponse |
||||||
|
[lineItems] => Array |
||||||
|
( |
||||||
|
[0] => Array |
||||||
|
( |
||||||
|
[options] => Array |
||||||
|
( |
||||||
|
) |
||||||
|
|
||||||
|
[price] => 10.00 |
||||||
|
[quantity] => 1 |
||||||
|
[recurrence] => |
||||||
|
[startupFee] => |
||||||
|
[productId] => |
||||||
|
[tangible] => N |
||||||
|
[name] => 123 |
||||||
|
[type] => product |
||||||
|
[description] => |
||||||
|
[duration] => |
||||||
|
) |
||||||
|
|
||||||
|
) |
||||||
|
|
||||||
|
[transactionId] => 205181140830 |
||||||
|
[billingAddr] => Array |
||||||
|
( |
||||||
|
[addrLine1] => 123 Test St |
||||||
|
[addrLine2] => |
||||||
|
[city] => Columbus |
||||||
|
[zipCode] => 43123 |
||||||
|
[phoneNumber] => 555-555-5555 |
||||||
|
[phoneExtension] => |
||||||
|
[email] => testingtester@2co.com |
||||||
|
[name] => Testing Tester |
||||||
|
[state] => OH |
||||||
|
[country] => USA |
||||||
|
) |
||||||
|
|
||||||
|
[shippingAddr] => Array |
||||||
|
( |
||||||
|
[addrLine1] => 123 Test St |
||||||
|
[addrLine2] => |
||||||
|
[city] => Columbus |
||||||
|
[zipCode] => 43123 |
||||||
|
[phoneNumber] => |
||||||
|
[phoneExtension] => |
||||||
|
[email] => |
||||||
|
[name] => Testing Tester |
||||||
|
[state] => OH |
||||||
|
[country] => USA |
||||||
|
) |
||||||
|
|
||||||
|
[merchantOrderId] => 123 |
||||||
|
[orderNumber] => 205181140821 |
||||||
|
[recurrentInstallmentId] => |
||||||
|
[responseMsg] => Successfully authorized the provided credit card |
||||||
|
[responseCode] => APPROVED |
||||||
|
[total] => 10.00 |
||||||
|
[currencyCode] => USD |
||||||
|
[errors] => |
||||||
|
) |
||||||
|
|
||||||
|
) |
||||||
|
``` |
||||||
|
|
||||||
|
Example Admin API Usage |
||||||
|
----------------- |
||||||
|
|
||||||
|
*Example Request:* |
||||||
|
|
||||||
|
```php |
||||||
|
<?php |
||||||
|
|
||||||
|
Twocheckout::username('testlibraryapi901248204'); |
||||||
|
Twocheckout::password('testlibraryapi901248204PASS'); |
||||||
|
|
||||||
|
$args = array( |
||||||
|
'sale_id' => 4834917619 |
||||||
|
); |
||||||
|
try { |
||||||
|
$result = Twocheckout_Sale::stop($args); |
||||||
|
} catch (Twocheckout_Error $e) { |
||||||
|
$e->getMessage(); |
||||||
|
} |
||||||
|
``` |
||||||
|
|
||||||
|
*Example Response:* |
||||||
|
|
||||||
|
```php |
||||||
|
<?php |
||||||
|
|
||||||
|
[response_code] => OK |
||||||
|
[response_message] => Array |
||||||
|
( |
||||||
|
[0] => 4834917634 |
||||||
|
[1] => 4834917646 |
||||||
|
[2] => 4834917658 |
||||||
|
) |
||||||
|
``` |
||||||
|
|
||||||
|
Example Checkout Usage: |
||||||
|
----------------------- |
||||||
|
|
||||||
|
*Example Request:* |
||||||
|
|
||||||
|
```php |
||||||
|
<?php |
||||||
|
$params = array( |
||||||
|
'sid' => '1817037', |
||||||
|
'mode' => '2CO', |
||||||
|
'li_0_name' => 'Test Product', |
||||||
|
'li_0_price' => '0.01' |
||||||
|
); |
||||||
|
Twocheckout_Charge::form($params, 'auto'); |
||||||
|
``` |
||||||
|
|
||||||
|
*Example Response:* |
||||||
|
```php |
||||||
|
<form id="2checkout" action="https://www.2checkout.com/checkout/spurchase" method="post"> |
||||||
|
<input type="hidden" name="sid" value="1817037"/> |
||||||
|
<input type="hidden" name="mode" value="2CO"/> |
||||||
|
<input type="hidden" name="li_0_name" value="Test Product"/> |
||||||
|
<input type="hidden" name="li_0_price" value="0.01"/> |
||||||
|
<input type="submit" value="Click here if you are not redirected automatically" /></form> |
||||||
|
<script type="text/javascript">document.getElementById('2checkout').submit();</script> |
||||||
|
``` |
||||||
|
|
||||||
|
Example Return Usage: |
||||||
|
--------------------- |
||||||
|
|
||||||
|
*Example Request:* |
||||||
|
|
||||||
|
```php |
||||||
|
<?php |
||||||
|
|
||||||
|
$params = array(); |
||||||
|
foreach ($_REQUEST as $k => $v) { |
||||||
|
$params[$k] = $v; |
||||||
|
} |
||||||
|
$passback = Twocheckout_Return::check($params, "tango"); |
||||||
|
``` |
||||||
|
|
||||||
|
*Example Response:* |
||||||
|
|
||||||
|
```php |
||||||
|
<?php |
||||||
|
|
||||||
|
[response_code] => Success |
||||||
|
[response_message] => Hash Matched |
||||||
|
``` |
||||||
|
|
||||||
|
Example INS Usage: |
||||||
|
------------------ |
||||||
|
|
||||||
|
*Example Request:* |
||||||
|
|
||||||
|
```php |
||||||
|
<?php |
||||||
|
|
||||||
|
$params = array(); |
||||||
|
foreach ($_POST as $k => $v) { |
||||||
|
$params[$k] = $v; |
||||||
|
} |
||||||
|
$passback = Twocheckout_Notification::check($params, "tango"); |
||||||
|
``` |
||||||
|
|
||||||
|
*Example Response:* |
||||||
|
|
||||||
|
```php |
||||||
|
<?php |
||||||
|
|
||||||
|
[response_code] => Success |
||||||
|
[response_message] => Hash Matched |
||||||
|
``` |
||||||
|
|
||||||
|
Exceptions: |
||||||
|
----------- |
||||||
|
Twocheckout_Error exceptions are thrown by if an error has returned. It is best to catch these exceptions so that they can be gracefully handled in your application. |
||||||
|
|
||||||
|
*Example Usage* |
||||||
|
|
||||||
|
```php |
||||||
|
<?php |
||||||
|
|
||||||
|
Twocheckout::username('testlibraryapi901248204'); |
||||||
|
Twocheckout::password('testlibraryapi901248204PASS'); |
||||||
|
|
||||||
|
$params = array( |
||||||
|
'sale_id' => 4774380224, |
||||||
|
'category' => 1, |
||||||
|
'comment' => 'Order never sent.' |
||||||
|
); |
||||||
|
try { |
||||||
|
$sale = Twocheckout_Sale::refund($params); |
||||||
|
} catch (Twocheckout_Error $e) { |
||||||
|
$e->getMessage(); |
||||||
|
} |
||||||
|
``` |
||||||
|
|
||||||
|
Full documentation for each binding is provided in the **[wiki](https://github.com/2Checkout/2checkout-php/wiki)**. |
@ -0,0 +1,54 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
abstract class Twocheckout |
||||||
|
{ |
||||||
|
public static $sid; |
||||||
|
public static $privateKey; |
||||||
|
public static $username; |
||||||
|
public static $password; |
||||||
|
public static $verifySSL = true; |
||||||
|
public static $baseUrl = 'https://www.2checkout.com'; |
||||||
|
public static $error; |
||||||
|
public static $format = 'array'; |
||||||
|
const VERSION = '0.4.0'; |
||||||
|
|
||||||
|
public static function sellerId($value = null) { |
||||||
|
self::$sid = $value; |
||||||
|
} |
||||||
|
|
||||||
|
public static function privateKey($value = null) { |
||||||
|
self::$privateKey = $value; |
||||||
|
} |
||||||
|
|
||||||
|
public static function username($value = null) { |
||||||
|
self::$username = $value; |
||||||
|
} |
||||||
|
|
||||||
|
public static function password($value = null) { |
||||||
|
self::$password = $value; |
||||||
|
} |
||||||
|
|
||||||
|
public static function verifySSL($value = null) { |
||||||
|
if ($value == 0 || $value == false) { |
||||||
|
self::$verifySSL = false; |
||||||
|
} else { |
||||||
|
self::$verifySSL = true; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public static function format($value = null) { |
||||||
|
self::$format = $value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
require(dirname(__FILE__) . '/Twocheckout/Api/TwocheckoutAccount.php'); |
||||||
|
require(dirname(__FILE__) . '/Twocheckout/Api/TwocheckoutPayment.php'); |
||||||
|
require(dirname(__FILE__) . '/Twocheckout/Api/TwocheckoutApi.php'); |
||||||
|
require(dirname(__FILE__) . '/Twocheckout/Api/TwocheckoutSale.php'); |
||||||
|
require(dirname(__FILE__) . '/Twocheckout/Api/TwocheckoutProduct.php'); |
||||||
|
require(dirname(__FILE__) . '/Twocheckout/Api/TwocheckoutUtil.php'); |
||||||
|
require(dirname(__FILE__) . '/Twocheckout/Api/TwocheckoutError.php'); |
||||||
|
require(dirname(__FILE__) . '/Twocheckout/TwocheckoutReturn.php'); |
||||||
|
require(dirname(__FILE__) . '/Twocheckout/TwocheckoutNotification.php'); |
||||||
|
require(dirname(__FILE__) . '/Twocheckout/TwocheckoutCharge.php'); |
||||||
|
require(dirname(__FILE__) . '/Twocheckout/TwocheckoutMessage.php'); |
@ -0,0 +1,25 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
class Twocheckout_Company extends Twocheckout |
||||||
|
{ |
||||||
|
|
||||||
|
public static function retrieve() |
||||||
|
{ |
||||||
|
$request = new Twocheckout_Api_Requester(); |
||||||
|
$urlSuffix = '/api/acct/detail_company_info'; |
||||||
|
$result = $request->doCall($urlSuffix); |
||||||
|
return Twocheckout_Util::returnResponse($result); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
class Twocheckout_Contact extends Twocheckout |
||||||
|
{ |
||||||
|
|
||||||
|
public static function retrieve() |
||||||
|
{ |
||||||
|
$request = new Twocheckout_Api_Requester(); |
||||||
|
$urlSuffix = '/api/acct/detail_contact_info'; |
||||||
|
$result = $request->doCall($urlSuffix); |
||||||
|
return Twocheckout_Util::returnResponse($result); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,55 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
class Twocheckout_Api_Requester |
||||||
|
{ |
||||||
|
public $baseUrl; |
||||||
|
public $environment; |
||||||
|
private $user; |
||||||
|
private $pass; |
||||||
|
private $sid; |
||||||
|
private $privateKey; |
||||||
|
|
||||||
|
function __construct() { |
||||||
|
$this->user = Twocheckout::$username; |
||||||
|
$this->pass = Twocheckout::$password; |
||||||
|
$this->sid = Twocheckout::$sid; |
||||||
|
$this->baseUrl = Twocheckout::$baseUrl; |
||||||
|
$this->verifySSL = Twocheckout::$verifySSL; |
||||||
|
$this->privateKey = Twocheckout::$privateKey; |
||||||
|
} |
||||||
|
|
||||||
|
function doCall($urlSuffix, $data=array()) |
||||||
|
{ |
||||||
|
$url = $this->baseUrl . $urlSuffix; |
||||||
|
$ch = curl_init($url); |
||||||
|
if (isset($data['api'])) { |
||||||
|
unset( $data['api'] ); |
||||||
|
$data['privateKey'] = $this->privateKey; |
||||||
|
$data['sellerId'] = $this->sid; |
||||||
|
$data = json_encode($data); |
||||||
|
$header = array("content-type:application/json","content-length:".strlen($data)); |
||||||
|
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); |
||||||
|
} else { |
||||||
|
$header = array("Accept: application/json"); |
||||||
|
curl_setopt($ch, CURLOPT_HEADER, 0); |
||||||
|
curl_setopt($ch, CURLOPT_POST, 0); |
||||||
|
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); |
||||||
|
curl_setopt($ch, CURLOPT_USERPWD, "{$this->user}:{$this->pass}"); |
||||||
|
} |
||||||
|
if ($this->verifySSL == false) { |
||||||
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); |
||||||
|
} |
||||||
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
||||||
|
curl_setopt($ch, CURLOPT_HTTPHEADER, $header); |
||||||
|
curl_setopt($ch, CURLOPT_USERAGENT, "2Checkout PHP/0.1.0%s"); |
||||||
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $data); |
||||||
|
$resp = curl_exec($ch); |
||||||
|
curl_close($ch); |
||||||
|
if ($resp === FALSE) { |
||||||
|
throw new Twocheckout_Error("cURL call failed", "403"); |
||||||
|
} else { |
||||||
|
return utf8_encode($resp); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,14 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
class Twocheckout_Error extends Exception |
||||||
|
{ |
||||||
|
public function __construct($message, $code = 0) |
||||||
|
{ |
||||||
|
parent::__construct($message, $code); |
||||||
|
} |
||||||
|
|
||||||
|
public function __toString() |
||||||
|
{ |
||||||
|
return __CLASS__ . ": [{$this->code}]: {$this->message}\n"; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,24 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
class Twocheckout_Payment extends Twocheckout |
||||||
|
{ |
||||||
|
|
||||||
|
public static function retrieve() |
||||||
|
{ |
||||||
|
$request = new Twocheckout_Api_Requester(); |
||||||
|
$urlSuffix = '/api/acct/list_payments'; |
||||||
|
$result = $request->doCall($urlSuffix); |
||||||
|
$response = Twocheckout_Util::returnResponse($result); |
||||||
|
return $response; |
||||||
|
} |
||||||
|
|
||||||
|
public static function pending() |
||||||
|
{ |
||||||
|
$request = new Twocheckout_Api_Requester(); |
||||||
|
$urlSuffix = '/api/acct/detail_pending_payment'; |
||||||
|
$result = $request->doCall($urlSuffix); |
||||||
|
$response = Twocheckout_Util::returnResponse($result); |
||||||
|
return $response; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,42 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
class Twocheckout_Product extends Twocheckout |
||||||
|
{ |
||||||
|
|
||||||
|
public static function create($params=array()) |
||||||
|
{ |
||||||
|
$request = new Twocheckout_Api_Requester(); |
||||||
|
$urlSuffix = '/api/products/create_product'; |
||||||
|
$result = $request->doCall($urlSuffix, $params); |
||||||
|
return Twocheckout_Util::returnResponse($result); |
||||||
|
} |
||||||
|
|
||||||
|
public static function retrieve($params=array()) |
||||||
|
{ |
||||||
|
$request = new Twocheckout_Api_Requester(); |
||||||
|
if(array_key_exists("product_id",$params)) { |
||||||
|
$urlSuffix = '/api/products/detail_product'; |
||||||
|
} else { |
||||||
|
$urlSuffix = '/api/products/list_products'; |
||||||
|
} |
||||||
|
$result = $request->doCall($urlSuffix, $params); |
||||||
|
return Twocheckout_Util::returnResponse($result); |
||||||
|
} |
||||||
|
|
||||||
|
public static function update($params=array()) |
||||||
|
{ |
||||||
|
$request = new Twocheckout_Api_Requester(); |
||||||
|
$urlSuffix = '/api/products/update_product'; |
||||||
|
$result = $request->doCall($urlSuffix, $params); |
||||||
|
return Twocheckout_Util::returnResponse($result); |
||||||
|
} |
||||||
|
|
||||||
|
public static function delete($params=array()) |
||||||
|
{ |
||||||
|
$request = new Twocheckout_Api_Requester(); |
||||||
|
$urlSuffix = '/api/products/delete_product'; |
||||||
|
$result = $request->doCall($urlSuffix, $params); |
||||||
|
return Twocheckout_Util::returnResponse($result); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,96 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
class Twocheckout_Sale extends Twocheckout |
||||||
|
{ |
||||||
|
|
||||||
|
public static function retrieve($params=array()) |
||||||
|
{ |
||||||
|
$request = new Twocheckout_Api_Requester(); |
||||||
|
if(array_key_exists("sale_id",$params) || array_key_exists("invoice_id",$params)) { |
||||||
|
$urlSuffix = '/api/sales/detail_sale'; |
||||||
|
} else { |
||||||
|
$urlSuffix = '/api/sales/list_sales'; |
||||||
|
} |
||||||
|
$result = $request->doCall($urlSuffix, $params); |
||||||
|
return Twocheckout_Util::returnResponse($result); |
||||||
|
} |
||||||
|
|
||||||
|
public static function refund($params=array()) { |
||||||
|
$request = new Twocheckout_Api_Requester(); |
||||||
|
if(array_key_exists("lineitem_id",$params)) { |
||||||
|
$urlSuffix ='/api/sales/refund_lineitem'; |
||||||
|
$result = $request->doCall($urlSuffix, $params); |
||||||
|
} elseif(array_key_exists("invoice_id",$params) || array_key_exists("sale_id",$params)) { |
||||||
|
$urlSuffix ='/api/sales/refund_invoice'; |
||||||
|
$result = $request->doCall($urlSuffix, $params); |
||||||
|
} else { |
||||||
|
$result = Twocheckout_Message::message('Error', 'You must pass a sale_id, invoice_id or lineitem_id to use this method.'); |
||||||
|
} |
||||||
|
return Twocheckout_Util::returnResponse($result); |
||||||
|
} |
||||||
|
|
||||||
|
public static function stop($params=array()) { |
||||||
|
$request = new Twocheckout_Api_Requester(); |
||||||
|
$urlSuffix ='/api/sales/stop_lineitem_recurring'; |
||||||
|
if(array_key_exists("lineitem_id",$params)) { |
||||||
|
$result = $request->doCall($urlSuffix, $params); |
||||||
|
} elseif(array_key_exists("sale_id",$params)) { |
||||||
|
$result = Twocheckout_Sale::retrieve($params); |
||||||
|
if (!is_array($result)) { |
||||||
|
$result = Twocheckout_Util::returnResponse($result, 'array'); |
||||||
|
} |
||||||
|
$lineitemData = Twocheckout_Util::getRecurringLineitems($result); |
||||||
|
if (isset($lineitemData[0])) { |
||||||
|
$stoppedLineitems = array(); |
||||||
|
foreach( $lineitemData as $value ) |
||||||
|
{ |
||||||
|
$params = array('lineitem_id' => $value); |
||||||
|
$result = $request->doCall($urlSuffix, $params); |
||||||
|
$result = json_decode($result, true); |
||||||
|
if ($result['response_code'] == "OK") { |
||||||
|
$stoppedLineitems[] = $value; |
||||||
|
} |
||||||
|
} |
||||||
|
$result = Twocheckout_Message::message('OK', $stoppedLineitems); |
||||||
|
} else { |
||||||
|
throw new Twocheckout_Error("No recurring lineitems to stop."); |
||||||
|
} |
||||||
|
} else { |
||||||
|
throw new Twocheckout_Error('You must pass a sale_id or lineitem_id to use this method.'); |
||||||
|
} |
||||||
|
return Twocheckout_Util::returnResponse($result); |
||||||
|
} |
||||||
|
|
||||||
|
public static function active($params=array()) { |
||||||
|
if(array_key_exists("sale_id",$params)) { |
||||||
|
$result = Twocheckout_Sale::retrieve($params); |
||||||
|
if (!is_array($result)) { |
||||||
|
$result = Twocheckout_Util::returnResponse($result, 'array'); |
||||||
|
} |
||||||
|
$lineitemData = Twocheckout_Util::getRecurringLineitems($result); |
||||||
|
if (isset($lineitemData[0])) { |
||||||
|
$result = Twocheckout_Message::message('OK', $lineitemData); |
||||||
|
return Twocheckout_Util::returnResponse($result); |
||||||
|
} else { |
||||||
|
throw new Twocheckout_Error("No active recurring lineitems."); |
||||||
|
} |
||||||
|
} else { |
||||||
|
throw new Twocheckout_Error("You must pass a sale_id to use this method."); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public static function comment($params=array()) { |
||||||
|
$request = new Twocheckout_Api_Requester(); |
||||||
|
$urlSuffix ='/api/sales/create_comment'; |
||||||
|
$result = $request->doCall($urlSuffix, $params); |
||||||
|
return Twocheckout_Util::returnResponse($result); |
||||||
|
} |
||||||
|
|
||||||
|
public static function ship($params=array()) { |
||||||
|
$request = new Twocheckout_Api_Requester(); |
||||||
|
$urlSuffix ='/api/sales/mark_shipped'; |
||||||
|
$result = $request->doCall($urlSuffix, $params); |
||||||
|
return Twocheckout_Util::returnResponse($result); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,74 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
class Twocheckout_Util extends Twocheckout |
||||||
|
{ |
||||||
|
|
||||||
|
static function returnResponse($contents, $format=null) { |
||||||
|
$format = $format == null ? Twocheckout::$format : $format; |
||||||
|
switch ($format) { |
||||||
|
case "array": |
||||||
|
$response = self::objectToArray($contents); |
||||||
|
self::checkError($response); |
||||||
|
break; |
||||||
|
case "force_json": |
||||||
|
$response = self::objectToJson($contents); |
||||||
|
break; |
||||||
|
default: |
||||||
|
$response = self::objectToArray($contents); |
||||||
|
self::checkError($response); |
||||||
|
$response = json_encode($contents); |
||||||
|
$response = json_decode($response); |
||||||
|
} |
||||||
|
return $response; |
||||||
|
} |
||||||
|
|
||||||
|
public static function objectToArray($object) |
||||||
|
{ |
||||||
|
$object = json_decode($object, true); |
||||||
|
$array=array(); |
||||||
|
foreach($object as $member=>$data) |
||||||
|
{ |
||||||
|
$array[$member]=$data; |
||||||
|
} |
||||||
|
return $array; |
||||||
|
} |
||||||
|
|
||||||
|
public static function objectToJson($object) |
||||||
|
{ |
||||||
|
return json_encode($object); |
||||||
|
} |
||||||
|
|
||||||
|
public static function getRecurringLineitems($saleDetail) { |
||||||
|
$i = 0; |
||||||
|
$invoiceData = array(); |
||||||
|
|
||||||
|
while (isset($saleDetail['sale']['invoices'][$i])) { |
||||||
|
$invoiceData[$i] = $saleDetail['sale']['invoices'][$i]; |
||||||
|
$i++; |
||||||
|
} |
||||||
|
|
||||||
|
$invoice = max($invoiceData); |
||||||
|
$i = 0; |
||||||
|
$lineitemData = array(); |
||||||
|
|
||||||
|
while (isset($invoice['lineitems'][$i])) { |
||||||
|
if ($invoice['lineitems'][$i]['billing']['recurring_status'] == "active") { |
||||||
|
$lineitemData[] = $invoice['lineitems'][$i]['billing']['lineitem_id']; |
||||||
|
} |
||||||
|
$i++; |
||||||
|
}; |
||||||
|
|
||||||
|
return $lineitemData; |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public static function checkError($contents) |
||||||
|
{ |
||||||
|
if (isset($contents['errors'])) { |
||||||
|
throw new Twocheckout_Error($contents['errors'][0]['message']); |
||||||
|
} elseif (isset($contents['exception'])) { |
||||||
|
throw new Twocheckout_Error($contents['exception']['errorMsg'], $contents['exception']['errorCode']); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,69 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
class Twocheckout_Charge extends Twocheckout |
||||||
|
{ |
||||||
|
|
||||||
|
public static function form($params, $type='Checkout') |
||||||
|
{ |
||||||
|
echo '<form id="2checkout" action="'.Twocheckout::$baseUrl.'/checkout/purchase" method="post">'; |
||||||
|
|
||||||
|
foreach ($params as $key => $value) |
||||||
|
{ |
||||||
|
echo '<input type="hidden" name="'.htmlspecialchars($key, ENT_QUOTES, 'UTF-8').'" value="'.htmlspecialchars($value, ENT_QUOTES, 'UTF-8').'"/>'; |
||||||
|
} |
||||||
|
if ($type == 'auto') { |
||||||
|
echo '<input type="submit" value="Click here if you are not redirected automatically" /></form>'; |
||||||
|
echo '<script type="text/javascript">document.getElementById("2checkout").submit();</script>'; |
||||||
|
} else { |
||||||
|
echo '<input type="submit" value="'.$type.'" />'; |
||||||
|
echo '</form>'; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public static function direct($params, $type='Checkout') |
||||||
|
{ |
||||||
|
echo '<form id="2checkout" action="'.Twocheckout::$baseUrl.'/checkout/purchase" method="post">'; |
||||||
|
|
||||||
|
foreach ($params as $key => $value) |
||||||
|
{ |
||||||
|
echo '<input type="hidden" name="'.$key.'" value="'.$value.'"/>'; |
||||||
|
} |
||||||
|
|
||||||
|
if ($type == 'auto') { |
||||||
|
echo '<input type="submit" value="Click here if the payment form does not open automatically." /></form>'; |
||||||
|
echo '<script type="text/javascript"> |
||||||
|
function submitForm() { |
||||||
|
document.getElementById("tco_lightbox").style.display = "block"; |
||||||
|
document.getElementById("2checkout").submit(); |
||||||
|
} |
||||||
|
setTimeout("submitForm()", 2000); |
||||||
|
</script>'; |
||||||
|
} else { |
||||||
|
echo '<input type="submit" value="'.$type.'" />'; |
||||||
|
echo '</form>'; |
||||||
|
} |
||||||
|
|
||||||
|
echo '<script src="'.Twocheckout::$baseUrl.'/static/checkout/javascript/direct.min.js"></script>'; |
||||||
|
} |
||||||
|
|
||||||
|
public static function link($params) |
||||||
|
{ |
||||||
|
$url = Twocheckout::$baseUrl.'/checkout/purchase?'.http_build_query($params, '', '&'); |
||||||
|
return $url; |
||||||
|
} |
||||||
|
|
||||||
|
public static function redirect($params) |
||||||
|
{ |
||||||
|
$url = Twocheckout::$baseUrl.'/checkout/purchase?'.http_build_query($params, '', '&'); |
||||||
|
header("Location: $url"); |
||||||
|
} |
||||||
|
|
||||||
|
public static function auth($params=array()) |
||||||
|
{ |
||||||
|
$params['api'] = 'checkout'; |
||||||
|
$request = new Twocheckout_Api_Requester(); |
||||||
|
$result = $request->doCall('/checkout/api/1/'.self::$sid.'/rs/authService', $params); |
||||||
|
return Twocheckout_Util::returnResponse($result); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,13 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
class Twocheckout_Message |
||||||
|
{ |
||||||
|
public static function message($code, $message) |
||||||
|
{ |
||||||
|
$response = array(); |
||||||
|
$response['response_code'] = $code; |
||||||
|
$response['response_message'] = $message; |
||||||
|
$response = json_encode($response); |
||||||
|
return $response; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,20 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
class Twocheckout_Notification extends Twocheckout |
||||||
|
{ |
||||||
|
|
||||||
|
public static function check($insMessage=array(), $secretWord) |
||||||
|
{ |
||||||
|
$hashSid = $insMessage['vendor_id']; |
||||||
|
$hashOrder = $insMessage['sale_id']; |
||||||
|
$hashInvoice = $insMessage['invoice_id']; |
||||||
|
$StringToHash = strtoupper(md5($hashOrder . $hashSid . $hashInvoice . $secretWord)); |
||||||
|
if ($StringToHash != $insMessage['md5_hash']) { |
||||||
|
$result = Twocheckout_Message::message('Fail', 'Hash Mismatch'); |
||||||
|
} else { |
||||||
|
$result = Twocheckout_Message::message('Success', 'Hash Matched'); |
||||||
|
} |
||||||
|
return Twocheckout_Util::returnResponse($result); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,21 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
class Twocheckout_Return extends Twocheckout |
||||||
|
{ |
||||||
|
|
||||||
|
public static function check($params=array(), $secretWord) |
||||||
|
{ |
||||||
|
$hashSecretWord = $secretWord; |
||||||
|
$hashSid = $params['sid']; |
||||||
|
$hashTotal = $params['total']; |
||||||
|
$hashOrder = $params['order_number']; |
||||||
|
$StringToHash = strtoupper(md5($hashSecretWord . $hashSid . $hashOrder . $hashTotal)); |
||||||
|
if ($StringToHash != $params['key']) { |
||||||
|
$result = Twocheckout_Message::message('Fail', 'Hash Mismatch'); |
||||||
|
} else { |
||||||
|
$result = Twocheckout_Message::message('Success', 'Hash Matched'); |
||||||
|
} |
||||||
|
return Twocheckout_Util::returnResponse($result); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,12 @@ |
|||||||
|
*.DS_Store |
||||||
|
composer.lock |
||||||
|
vendor |
||||||
|
phpunit.xml |
||||||
|
tests/log |
||||||
|
build |
||||||
|
phplog |
||||||
|
|
||||||
|
# Ignore eclipse project files |
||||||
|
.buildpath |
||||||
|
.project |
||||||
|
.settings |
@ -0,0 +1,3 @@ |
|||||||
|
[submodule "sample-code-php"] |
||||||
|
path = sample-code-php |
||||||
|
url = https://github.com/AuthorizeNet/sample-code-php.git |
@ -0,0 +1,17 @@ |
|||||||
|
checks: |
||||||
|
php: |
||||||
|
code_rating: true |
||||||
|
duplication: true |
||||||
|
|
||||||
|
tools: |
||||||
|
php_mess_detector: true |
||||||
|
php_code_sniffer: true |
||||||
|
sensiolabs_security_checker: true |
||||||
|
php_cpd: true |
||||||
|
php_loc: true |
||||||
|
php_pdepend: true |
||||||
|
external_code_coverage: |
||||||
|
timeout: 1500 #15 min |
||||||
|
filter: |
||||||
|
paths: |
||||||
|
- lib/* |
@ -0,0 +1,37 @@ |
|||||||
|
language: php |
||||||
|
|
||||||
|
sudo: false |
||||||
|
|
||||||
|
dist: trusty |
||||||
|
|
||||||
|
env: |
||||||
|
- TEST_SUITE=samples |
||||||
|
|
||||||
|
php: |
||||||
|
- 5.6 |
||||||
|
- 7.0 |
||||||
|
- 7.1 |
||||||
|
|
||||||
|
before_install: |
||||||
|
# execute all of the commands which need to be executed |
||||||
|
# before installing dependencies |
||||||
|
- composer validate # make sure that our composer.json file is valid for packaging |
||||||
|
|
||||||
|
install: |
||||||
|
# install all of the dependencies we need here |
||||||
|
- pecl install xmldiff |
||||||
|
- composer install --prefer-dist |
||||||
|
|
||||||
|
before_script: |
||||||
|
# execute all of the commands which need to be executed |
||||||
|
# before running actual tests |
||||||
|
- git submodule update --remote --recursive |
||||||
|
|
||||||
|
script: |
||||||
|
# execute all of the tests or other commands to determine |
||||||
|
# whether the build will pass or fail |
||||||
|
- if [[ "$TEST_SUITE" == "samples" ]]; then phpenv config-rm xdebug.ini; cp -R lib sample-code-php/; cp -R vendor sample-code-php/; cd sample-code-php; vendor/phpunit/phpunit/phpunit test-runner.php .; fi |
||||||
|
|
||||||
|
after_script: |
||||||
|
# - if [[ "$TEST_SUITE" == "coverage" ]]; then wget https://scrutinizer-ci.com/ocular.phar; fi |
||||||
|
# - if [[ "$TEST_SUITE" == "coverage" ]]; then php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,9 @@ |
|||||||
|
Thanks for contributing to the Authorize.Net PHP SDK. |
||||||
|
|
||||||
|
Before you submit a pull request, we ask that you consider the following: |
||||||
|
|
||||||
|
- Submit an issue to state the problem your pull request solves or the funtionality that it adds. We can then advise on the feasability of the pull request, and let you know if there are other possible solutions. |
||||||
|
- Part of the SDK is auto-generated based on the XML schema. Due to this auto-generation, we cannot merge contributions for request or response classes. You are welcome to open an issue to report problems or suggest improvements. Auto-generated classes include all files inside [contract/v1](https://github.com/AuthorizeNet/sdk-php/tree/master/lib/net/authorize/api/contract/v1) and [controller](https://github.com/AuthorizeNet/sdk-php/tree/master/lib/net/authorize/api/controller) folders, except [controller/base](https://github.com/AuthorizeNet/sdk-php/tree/master/lib/net/authorize/api/controller/base). |
||||||
|
- Files marked as deprecated are no longer supported. Issues and pull requests for changes to these deprecated files will be closed. |
||||||
|
- Recent changes will be in future branch. Check the code in *future* branch first to see if a fix has already been merged, before suggesting changes to a file. |
||||||
|
- **Always create pull request to the future branch.** The pull request will be merged to future, and later pushed to master as part of the next release. |
@ -0,0 +1,85 @@ |
|||||||
|
# Migrating from Legacy Authorize.Net Classes |
||||||
|
|
||||||
|
Authorize.Net no longer supports several legacy classes, including AuthorizeNetAIM.php, AuthorizenetSIM.php, and others listed below, as part of PHP-SDK. If you are using any of these, we recommend that you update your code to use the new Authorize.Net API classes. |
||||||
|
|
||||||
|
**For details on the deprecation and replacement of legacy Authorize.Net APIs, visit https://developer.authorize.net/api/upgrade_guide/.** |
||||||
|
|
||||||
|
## Full list of classes that are no longer supported |
||||||
|
| Class | New Feature | Sample Codes directory/repository | |
||||||
|
|----------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------| |
||||||
|
| AuthorizeNetAIM.php | [PaymentTransactions](https://developer.authorize.net/api/reference/index.html#payment-transactions) | [sample-code-php/PaymentTransactions](https://github.com/AuthorizeNet/sample-code-php/tree/master/PaymentTransactions) | |
||||||
|
| AuthorizeNetARB.php | [RecurringBilling](https://developer.authorize.net/api/reference/index.html#recurring-billing) | [sample-code-php/RecurringBilling](https://github.com/AuthorizeNet/sample-code-php/tree/master/RecurringBilling) | |
||||||
|
| AuthorizeNetCIM.php | [CustomerProfiles](https://developer.authorize.net/api/reference/index.html#customer-profiles) | [sample-code-php/CustomerProfiles](https://github.com/AuthorizeNet/sample-code-php/tree/master/CustomerProfiles) | |
||||||
|
| Hosted CIM | [Accept Customer](https://developer.authorize.net/content/developer/en_us/api/reference/features/customer_profiles.html#Using_the_Accept_Customer_Hosted_Form) | Not available | |
||||||
|
| AuthorizeNetCP.php | [PaymentTransactions](https://developer.authorize.net/api/reference/index.html#payment-transactions) | [sample-code-php/PaymentTransactions](https://github.com/AuthorizeNet/sample-code-php/tree/master/PaymentTransactions) | |
||||||
|
| AuthorizeNetDPM.php | [Accept.JS](https://developer.authorize.net/api/reference/features/acceptjs.html) | [Sample Accept Application](https://github.com/AuthorizeNet/accept-sample-app) | |
||||||
|
| AuthorizeNetSIM.php | [Accept Hosted](https://developer.authorize.net/content/developer/en_us/api/reference/features/accept_hosted.html) | Not available | |
||||||
|
| AuthorizeNetSOAP.php | [PaymentTransactions](https://developer.authorize.net/api/reference/index.html#payment-transactions) | [sample-code-php/PaymentTransactions](https://github.com/AuthorizeNet/sample-code-php/tree/master/PaymentTransactions) | |
||||||
|
| AuthorizeNetTD.php | [TransactionReporting](https://developer.authorize.net/api/reference/index.html#transaction-reporting) | [sample-code-php/TransactionReporting/](https://github.com/AuthorizeNet/sample-code-php/tree/master/TransactionReporting) | |
||||||
|
|
||||||
|
## Example |
||||||
|
#### Old AuthorizeNetAIM example: |
||||||
|
```php |
||||||
|
define("AUTHORIZENET_API_LOGIN_ID", "YOURLOGIN"); |
||||||
|
define("AUTHORIZENET_TRANSACTION_KEY", "YOURKEY"); |
||||||
|
define("AUTHORIZENET_SANDBOX", true); |
||||||
|
$sale = new AuthorizeNetAIM; |
||||||
|
$sale->amount = "5.99"; |
||||||
|
$sale->card_num = '6011000000000012'; |
||||||
|
$sale->exp_date = '04/15'; |
||||||
|
$response = $sale->authorizeAndCapture(); |
||||||
|
if ($response->approved) { |
||||||
|
$transaction_id = $response->transaction_id; |
||||||
|
} |
||||||
|
``` |
||||||
|
#### Corresponding new model code (charge-credit-card): |
||||||
|
```php |
||||||
|
require 'vendor/autoload.php'; |
||||||
|
use net\authorize\api\contract\v1 as AnetAPI; |
||||||
|
use net\authorize\api\controller as AnetController; |
||||||
|
|
||||||
|
define("AUTHORIZENET_LOG_FILE", "phplog"); |
||||||
|
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); |
||||||
|
$merchantAuthentication->setName("YOURLOGIN"); |
||||||
|
$merchantAuthentication->setTransactionKey("YOURKEY"); |
||||||
|
// Create the payment data for a credit card |
||||||
|
$creditCard = new AnetAPI\CreditCardType(); |
||||||
|
$creditCard->setCardNumber("6011000000000012"); |
||||||
|
$creditCard->setExpirationDate("2015-04"); |
||||||
|
$creditCard->setCardCode("123"); |
||||||
|
|
||||||
|
// Add the payment data to a paymentType object |
||||||
|
$paymentOne = new AnetAPI\PaymentType(); |
||||||
|
$paymentOne->setCreditCard($creditCard); |
||||||
|
|
||||||
|
$transactionRequestType = new AnetAPI\TransactionRequestType(); |
||||||
|
$transactionRequestType->setTransactionType("authCaptureTransaction"); |
||||||
|
$transactionRequestType->setAmount("5.99"); |
||||||
|
$transactionRequestType->setPayment($paymentOne); |
||||||
|
|
||||||
|
// Assemble the complete transaction request |
||||||
|
$request = new AnetAPI\CreateTransactionRequest(); |
||||||
|
$request->setMerchantAuthentication($merchantAuthentication); |
||||||
|
$request->setTransactionRequest($transactionRequestType); |
||||||
|
|
||||||
|
// Create the controller and get the response |
||||||
|
$controller = new AnetController\CreateTransactionController($request); |
||||||
|
$response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX); |
||||||
|
|
||||||
|
if ($response != null) { |
||||||
|
// Check to see if the API request was successfully received and acted upon |
||||||
|
if ($response->getMessages()->getResultCode() == "Ok") { |
||||||
|
// Since the API request was successful, look for a transaction response |
||||||
|
// and parse it to display the results of authorizing the card |
||||||
|
$tresponse = $response->getTransactionResponse(); |
||||||
|
|
||||||
|
if ($tresponse != null && $tresponse->getMessages() != null) { |
||||||
|
echo " Successfully created transaction with Transaction ID: " . $tresponse->getTransId() . "\n"; |
||||||
|
echo " Transaction Response Code: " . $tresponse->getResponseCode() . "\n"; |
||||||
|
echo " Message Code: " . $tresponse->getMessages()[0]->getCode() . "\n"; |
||||||
|
echo " Auth Code: " . $tresponse->getAuthCode() . "\n"; |
||||||
|
echo " Description: " . $tresponse->getMessages()[0]->getDescription() . "\n"; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
``` |
@ -0,0 +1,178 @@ |
|||||||
|
# Authorize.Net PHP SDK |
||||||
|
|
||||||
|
[](https://travis-ci.org/AuthorizeNet/sdk-php) |
||||||
|
[](https://scrutinizer-ci.com/g/AuthorizeNet/sdk-php/?branch=master) |
||||||
|
[](https://packagist.org/packages/authorizenet/authorizenet) |
||||||
|
|
||||||
|
## Requirements |
||||||
|
* PHP 5.6+ |
||||||
|
* cURL PHP Extension |
||||||
|
* JSON PHP Extension |
||||||
|
* An Authorize.Net account (see _Registration & Configuration_ section below) |
||||||
|
* TLS 1.2 capable versions of libcurl and OpenSSL (or its equivalent) |
||||||
|
|
||||||
|
### Migrating from older versions |
||||||
|
Since August 2018, the Authorize.Net API has been reorganized to be more merchant focused. Authorize.Net AIM, ARB, CIM, Transaction Reporting, and SIM classes have been deprecated in favor of net\authorize\api. To see the full list of mapping of new features corresponding to the deprecated features, see [MIGRATING.md](MIGRATING.md). |
||||||
|
|
||||||
|
### Contribution |
||||||
|
- If you need information or clarification about Authorize.Net features, create an issue with your question. You can also search the [Authorize.Net developer community](https://community.developer.authorize.net/)for discussions related to your question. |
||||||
|
- Before creating pull requests, read [the contributors guide](CONTRIBUTING.md) |
||||||
|
|
||||||
|
### TLS 1.2 |
||||||
|
The Authorize.Net APIs only support connections using the TLS 1.2 security protocol. Make sure to upgrade all required components to support TLS 1.2. Keep these components up to date to mitigate the risk of new security flaws. |
||||||
|
|
||||||
|
To test whether your current installation is capable of communicating to our servers using TLS 1.2, run the following PHP code and examine the output for the TLS version: |
||||||
|
```php |
||||||
|
<?php |
||||||
|
$ch = curl_init('https://apitest.authorize.net/xml/v1/request.api'); |
||||||
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
||||||
|
curl_setopt($ch, CURLOPT_VERBOSE, true); |
||||||
|
$data = curl_exec($ch); |
||||||
|
curl_close($ch); |
||||||
|
``` |
||||||
|
|
||||||
|
If curl is unable to connect to our URL (as given in the previous sample), it's likely that your system is not able to connect using TLS 1.2, or does not have a supported cipher installed. To verify what TLS version your connection _does_ support, run the following PHP code: |
||||||
|
```php |
||||||
|
<?php |
||||||
|
$ch = curl_init('https://www.howsmyssl.com/a/check'); |
||||||
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
||||||
|
$data = curl_exec($ch); |
||||||
|
curl_close($ch); |
||||||
|
|
||||||
|
$json = json_decode($data); |
||||||
|
echo "Connection uses " . $json->tls_version ."\n"; |
||||||
|
``` |
||||||
|
|
||||||
|
|
||||||
|
## Installation |
||||||
|
|
||||||
|
### Composer |
||||||
|
We recommend using [`Composer`](http://getcomposer.org). *(Note: we never recommend you |
||||||
|
override the new secure-http default setting)*. |
||||||
|
*Update your composer.json file as per the example below and then run for this specific release |
||||||
|
`composer update`.* |
||||||
|
|
||||||
|
```json |
||||||
|
{ |
||||||
|
"require": { |
||||||
|
"php": ">=5.6", |
||||||
|
"authorizenet/authorizenet": "2.0.1" |
||||||
|
} |
||||||
|
} |
||||||
|
``` |
||||||
|
|
||||||
|
After installation through Composer, |
||||||
|
don't forget to require its autoloader in your script or bootstrap file: |
||||||
|
```php |
||||||
|
require 'vendor/autoload.php'; |
||||||
|
``` |
||||||
|
|
||||||
|
### Custom SPL Autoloader |
||||||
|
Alternatively, we provide a custom `SPL` autoloader for you to reference from within your PHP file: |
||||||
|
```php |
||||||
|
require 'path/to/anet_php_sdk/autoload.php'; |
||||||
|
``` |
||||||
|
This autoloader still requires the `vendor` directory and all of its dependencies to exist. |
||||||
|
However, this is a possible solution for cases where composer can't be run on a given system. |
||||||
|
You can run composer locally or on another system to build the directory, then copy the |
||||||
|
`vendor` directory to the desired system. |
||||||
|
|
||||||
|
|
||||||
|
## Registration & Configuration |
||||||
|
Use of this SDK and the Authorize.Net APIs requires having an account on the Authorize.Net system. You can find these details in the Settings section. If you don't currently have a production Authorize.Net account, [sign up for a sandbox account](https://developer.authorize.net/sandbox/). |
||||||
|
|
||||||
|
### Authentication |
||||||
|
To authenticate with the Authorize.Net API, use your account's API Login ID and Transaction Key. If you don't have these credentials, obtain them from the Merchant Interface. For production accounts, the Merchant Interface is located at (https://account.authorize.net/), and for sandbox accounts, at (https://sandbox.authorize.net). |
||||||
|
|
||||||
|
After you have your credentials, load them into the appropriate variables in your code. The below sample code shows how to set the credentials as part of the API request. |
||||||
|
|
||||||
|
#### To set your API credentials for an API request: |
||||||
|
... |
||||||
|
```php |
||||||
|
use net\authorize\api\contract\v1 as AnetAPI; |
||||||
|
``` |
||||||
|
... |
||||||
|
|
||||||
|
```php |
||||||
|
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); |
||||||
|
$merchantAuthentication->setName("YOURLOGIN"); |
||||||
|
$merchantAuthentication->setTransactionKey("YOURKEY"); |
||||||
|
``` |
||||||
|
... |
||||||
|
|
||||||
|
```php |
||||||
|
$request = new AnetAPI\CreateTransactionRequest(); |
||||||
|
$request->setMerchantAuthentication($merchantAuthentication); |
||||||
|
``` |
||||||
|
... |
||||||
|
|
||||||
|
You should never include your Login ID and Transaction Key directly in a PHP file that's in a publically accessible portion of your website. A better practice would be to define these in a constants file, and then reference those constants in the appropriate place in your code. |
||||||
|
|
||||||
|
### Switching between the sandbox environment and the production environment |
||||||
|
Authorize.Net maintains a complete sandbox environment for testing and development purposes. The sandbox environment is an exact replica of our production environment, with simulated transaction authorization and settlement. By default, this SDK is configured to use the sandbox environment. To switch to the production environment, replace the environment constant in the execute method. For example: |
||||||
|
```php |
||||||
|
// For PRODUCTION use |
||||||
|
$response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::PRODUCTION); |
||||||
|
``` |
||||||
|
|
||||||
|
API credentials are different for each environment, so be sure to switch to the appropriate credentials when switching environments. |
||||||
|
|
||||||
|
|
||||||
|
## SDK Usage Examples and Sample Code |
||||||
|
To get started using this SDK, it's highly recommended to download our sample code repository: |
||||||
|
* [Authorize.Net PHP Sample Code Repository (on GitHub)](https://github.com/AuthorizeNet/sample-code-php) |
||||||
|
|
||||||
|
In that respository, we have comprehensive sample code for all common uses of our API: |
||||||
|
|
||||||
|
Additionally, you can find details and examples of how our API is structured in our API Reference Guide: |
||||||
|
* [Developer Center API Reference](http://developer.authorize.net/api/reference/index.html) |
||||||
|
|
||||||
|
The API Reference Guide provides examples of what information is needed for a particular request and how that information would be formatted. Using those examples, you can easily determine what methods would be necessary to include that information in a request using this SDK. |
||||||
|
|
||||||
|
|
||||||
|
## Building & Testing the SDK |
||||||
|
Integration tests for the AuthorizeNet SDK are in the `tests` directory. These tests |
||||||
|
are mainly for SDK development. However, you can also browse through them to find |
||||||
|
more usage examples for the various APIs. |
||||||
|
|
||||||
|
- Run `composer update --dev` to load the `PHPUnit` test library. |
||||||
|
- Copy the `phpunit.xml.dist` file to `phpunit.xml` and enter your merchant |
||||||
|
credentials in the constant fields. |
||||||
|
- Run `vendor/bin/phpunit` to run the test suite. |
||||||
|
|
||||||
|
*You'll probably want to disable emails on your sandbox account.* |
||||||
|
|
||||||
|
### Testing Guide |
||||||
|
For additional help in testing your own code, Authorize.Net maintains a [comprehensive testing guide](http://developer.authorize.net/hello_world/testing_guide/) that includes test credit card numbers to use and special triggers to generate certain responses from the sandbox environment. |
||||||
|
|
||||||
|
|
||||||
|
## Logging |
||||||
|
The SDK generates a log with masking for sensitive data like credit card, expiration dates. The provided levels for logging are |
||||||
|
`debug`, `info`, `warn`, `error`. Add ````use \net\authorize\util\LogFactory;````. Logger can be initialized using `$logger = LogFactory::getLog(get_class($this));` |
||||||
|
The default log file `phplog` gets generated in the current folder. The subsequent logs are appended to the same file, unless the execution folder is changed, and a new log file is generated. |
||||||
|
|
||||||
|
### Usage Examples |
||||||
|
- Logging a string message `$logger->debug("Sending 'XML' Request type");` |
||||||
|
- Logging xml strings `$logger->debug($xmlRequest);` |
||||||
|
- Logging using formatting `$logger->debugFormat("Integer: %d, Float: %f, Xml-Request: %s\n", array(100, 1.29f, $xmlRequest));` |
||||||
|
|
||||||
|
### Customizing Sensitive Tags |
||||||
|
A local copy of [AuthorizedNetSensitiveTagsConfig.json](/lib/net/authorize/util/ANetSensitiveFields.php) gets generated when code invoking the logger first gets executed. The local file can later be edited by developer to re-configure what is masked and what is visible. (*Do not edit the JSON in the SDK*). |
||||||
|
- For each element of the `sensitiveTags` array, |
||||||
|
- `tagName` field corresponds to the name of the property in object, or xml-tag that should be hidden entirely ( *XXXX* shown if no replacement specified ) or masked (e.g. showing the last 4 digits of credit card number). |
||||||
|
- `pattern`[<sup>[Note]</sup>](#regex-note) and `replacement`[<sup>[Note]</sup>](#regex-note) can be left `""`, if the default is to be used (as defined in [Log.php](/lib/net/authorize/util/Log.php)). `pattern` gives the regex to identify, while `replacement` defines the visible part. |
||||||
|
- `disableMask` can be set to *true* to allow the log to fully display that property in an object, or tag in a xml string. |
||||||
|
- `sensitiveStringRegexes`[<sup>[Note]</sup>](#regex-note) has list of credit-card regexes. So if credit-card number is not already masked, it would get entirely masked. |
||||||
|
- Take care of non-ascii characters (refer [manual](http://php.net/manual/en/regexp.reference.unicode.php)) while defining the regex, e.g. use |
||||||
|
`"pattern": "(\\p{N}+)(\\p{N}{4})"` instead of `"pattern": "(\\d+)(\\d{4})"`. Also note `\\` escape sequence is used. |
||||||
|
|
||||||
|
**<a name="regex-note">Note</a>:** |
||||||
|
**For any regex, no starting or ending '/' or any other delimiter should be defined. The '/' delimiter and unicode flag is added in the code.** |
||||||
|
|
||||||
|
|
||||||
|
### Transaction Hash Upgrade |
||||||
|
Authorize.Net is phasing out the MD5 based `transHash` element in favor of the SHA-512 based `transHashSHA2`. The setting in the Merchant Interface which controlled the MD5 Hash option is no longer available, and the `transHash` element will stop returning values at a later date to be determined. For information on how to use `transHashSHA2`, see the [Transaction Hash Upgrade Guide] (https://developer.authorize.net/support/hash_upgrade/). |
||||||
|
|
||||||
|
|
||||||
|
## License |
||||||
|
This repository is distributed under a proprietary license. See the provided [`LICENSE.txt`](/LICENSE.txt) file. |
@ -0,0 +1,18 @@ |
|||||||
|
<?php |
||||||
|
/** |
||||||
|
* Custom SPL autoloader for the AuthorizeNet SDK |
||||||
|
* |
||||||
|
* @package AuthorizeNet |
||||||
|
*/ |
||||||
|
|
||||||
|
spl_autoload_register(function($className) { |
||||||
|
static $classMap; |
||||||
|
|
||||||
|
if (!isset($classMap)) { |
||||||
|
$classMap = require __DIR__ . DIRECTORY_SEPARATOR . 'classmap.php'; |
||||||
|
} |
||||||
|
|
||||||
|
if (isset($classMap[$className])) { |
||||||
|
include $classMap[$className]; |
||||||
|
} |
||||||
|
}); |
@ -0,0 +1,302 @@ |
|||||||
|
<?php |
||||||
|
spl_autoload_extensions(".php"); // comma-separated list |
||||||
|
spl_autoload_register(); |
||||||
|
|
||||||
|
/** |
||||||
|
* A map of classname => filename for SPL autoloading. |
||||||
|
* |
||||||
|
* @package AuthorizeNet |
||||||
|
*/ |
||||||
|
|
||||||
|
$baseDir = __DIR__ ; |
||||||
|
$libDir = $baseDir . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR; |
||||||
|
$vendorDir = $baseDir . '/vendor'; |
||||||
|
|
||||||
|
return array( |
||||||
|
|
||||||
|
// Following section contains the new controller model classes needed |
||||||
|
//Utils |
||||||
|
//'net\authorize\util\ObjectToXml' => $libDir . 'net/authorize/util/ObjectToXml.php', |
||||||
|
'net\authorize\util\HttpClient' => $libDir . 'net/authorize/util/HttpClient.php', |
||||||
|
'net\authorize\util\Helpers' => $libDir . 'net/authorize/util/Helpers.php', |
||||||
|
'net\authorize\util\Log' => $libDir . 'net/authorize/util/Log.php', |
||||||
|
'net\authorize\util\LogFactory' => $libDir . 'net/authorize/util/LogFactory.php', |
||||||
|
'net\authorize\util\ANetSensitiveFields' => $libDir . 'net/authorize/util/ANetSensitiveFields.php', |
||||||
|
'net\authorize\util\SensitiveTag' => $libDir . 'net/authorize/util/SensitiveTag.php', |
||||||
|
'net\authorize\util\SensitiveDataConfigType' => $libDir . 'net/authorize/util/SensitiveDataConfigType.php', |
||||||
|
'net\authorize\util\Mapper' => $libDir . 'net/authorize/util/Mapper.php', |
||||||
|
'net\authorize\util\MapperObj' => $libDir . 'net/authorize/util/MapperObj.php', |
||||||
|
|
||||||
|
//constants |
||||||
|
'net\authorize\api\constants\ANetEnvironment' => $libDir . 'net/authorize/api/constants/ANetEnvironment.php', |
||||||
|
|
||||||
|
//base classes |
||||||
|
'net\authorize\api\controller\base\IApiOperation' => $libDir . 'net/authorize/api/controller/base/IApiOperation.php', |
||||||
|
'net\authorize\api\controller\base\ApiOperationBase' => $libDir . 'net/authorize/api/controller/base/ApiOperationBase.php', |
||||||
|
|
||||||
|
//following are generated class mappings |
||||||
|
'net\authorize\api\contract\v1\ANetApiRequestType' => $libDir . 'net/authorize/api/contract/v1/ANetApiRequestType.php', |
||||||
|
'net\authorize\api\contract\v1\ANetApiResponseType' => $libDir . 'net/authorize/api/contract/v1/ANetApiResponseType.php', |
||||||
|
'net\authorize\api\contract\v1\ARBCancelSubscriptionRequest' => $libDir . 'net/authorize/api/contract/v1/ARBCancelSubscriptionRequest.php', |
||||||
|
'net\authorize\api\contract\v1\ARBCancelSubscriptionResponse' => $libDir . 'net/authorize/api/contract/v1/ARBCancelSubscriptionResponse.php', |
||||||
|
'net\authorize\api\contract\v1\ARBCreateSubscriptionRequest' => $libDir . 'net/authorize/api/contract/v1/ARBCreateSubscriptionRequest.php', |
||||||
|
'net\authorize\api\contract\v1\ARBCreateSubscriptionResponse' => $libDir . 'net/authorize/api/contract/v1/ARBCreateSubscriptionResponse.php', |
||||||
|
'net\authorize\api\contract\v1\ARBGetSubscriptionListRequest' => $libDir . 'net/authorize/api/contract/v1/ARBGetSubscriptionListRequest.php', |
||||||
|
'net\authorize\api\contract\v1\ARBGetSubscriptionListResponse' => $libDir . 'net/authorize/api/contract/v1/ARBGetSubscriptionListResponse.php', |
||||||
|
'net\authorize\api\contract\v1\ARBGetSubscriptionListSortingType' => $libDir . 'net/authorize/api/contract/v1/ARBGetSubscriptionListSortingType.php', |
||||||
|
'net\authorize\api\contract\v1\ARBGetSubscriptionRequest' => $libDir . 'net/authorize/api/contract/v1/ARBGetSubscriptionRequest.php', |
||||||
|
'net\authorize\api\contract\v1\ARBGetSubscriptionResponse' => $libDir . 'net/authorize/api/contract/v1/ARBGetSubscriptionResponse.php', |
||||||
|
'net\authorize\api\contract\v1\ARBGetSubscriptionStatusRequest' => $libDir . 'net/authorize/api/contract/v1/ARBGetSubscriptionStatusRequest.php', |
||||||
|
'net\authorize\api\contract\v1\ARBGetSubscriptionStatusResponse' => $libDir . 'net/authorize/api/contract/v1/ARBGetSubscriptionStatusResponse.php', |
||||||
|
'net\authorize\api\contract\v1\ARBSubscriptionMaskedType' => $libDir . 'net/authorize/api/contract/v1/ARBSubscriptionMaskedType.php', |
||||||
|
'net\authorize\api\contract\v1\ARBSubscriptionType' => $libDir . 'net/authorize/api/contract/v1/ARBSubscriptionType.php', |
||||||
|
'net\authorize\api\contract\v1\ArbTransactionType' => $libDir . 'net/authorize/api/contract/v1/ArbTransactionType.php', |
||||||
|
'net\authorize\api\contract\v1\ARBUpdateSubscriptionRequest' => $libDir . 'net/authorize/api/contract/v1/ARBUpdateSubscriptionRequest.php', |
||||||
|
'net\authorize\api\contract\v1\ARBUpdateSubscriptionResponse' => $libDir . 'net/authorize/api/contract/v1/ARBUpdateSubscriptionResponse.php', |
||||||
|
'net\authorize\api\contract\v1\ArrayOfSettingType' => $libDir . 'net/authorize/api/contract/v1/ArrayOfSettingType.php', |
||||||
|
'net\authorize\api\contract\v1\AuthenticateTestRequest' => $libDir . 'net/authorize/api/contract/v1/AuthenticateTestRequest.php', |
||||||
|
'net\authorize\api\contract\v1\AuthenticateTestResponse' => $libDir . 'net/authorize/api/contract/v1/AuthenticateTestResponse.php', |
||||||
|
'net\authorize\api\contract\v1\BankAccountMaskedType' => $libDir . 'net/authorize/api/contract/v1/BankAccountMaskedType.php', |
||||||
|
'net\authorize\api\contract\v1\BankAccountType' => $libDir . 'net/authorize/api/contract/v1/BankAccountType.php', |
||||||
|
'net\authorize\api\contract\v1\BatchDetailsType' => $libDir . 'net/authorize/api/contract/v1/BatchDetailsType.php', |
||||||
|
'net\authorize\api\contract\v1\BatchStatisticType' => $libDir . 'net/authorize/api/contract/v1/BatchStatisticType.php', |
||||||
|
'net\authorize\api\contract\v1\CardArtType' => $libDir . 'net/authorize/api/contract/v1/CardArtType.php', |
||||||
|
'net\authorize\api\contract\v1\CcAuthenticationType' => $libDir . 'net/authorize/api/contract/v1/CcAuthenticationType.php', |
||||||
|
'net\authorize\api\contract\v1\CreateCustomerPaymentProfileRequest' => $libDir . 'net/authorize/api/contract/v1/CreateCustomerPaymentProfileRequest.php', |
||||||
|
'net\authorize\api\contract\v1\CreateCustomerPaymentProfileResponse' => $libDir . 'net/authorize/api/contract/v1/CreateCustomerPaymentProfileResponse.php', |
||||||
|
'net\authorize\api\contract\v1\CreateCustomerProfileFromTransactionRequest' => $libDir . 'net/authorize/api/contract/v1/CreateCustomerProfileFromTransactionRequest.php', |
||||||
|
'net\authorize\api\contract\v1\CreateCustomerProfileRequest' => $libDir . 'net/authorize/api/contract/v1/CreateCustomerProfileRequest.php', |
||||||
|
'net\authorize\api\contract\v1\CreateCustomerProfileResponse' => $libDir . 'net/authorize/api/contract/v1/CreateCustomerProfileResponse.php', |
||||||
|
'net\authorize\api\contract\v1\CreateCustomerProfileTransactionRequest' => $libDir . 'net/authorize/api/contract/v1/CreateCustomerProfileTransactionRequest.php', |
||||||
|
'net\authorize\api\contract\v1\CreateCustomerProfileTransactionResponse' => $libDir . 'net/authorize/api/contract/v1/CreateCustomerProfileTransactionResponse.php', |
||||||
|
'net\authorize\api\contract\v1\CreateCustomerShippingAddressRequest' => $libDir . 'net/authorize/api/contract/v1/CreateCustomerShippingAddressRequest.php', |
||||||
|
'net\authorize\api\contract\v1\CreateCustomerShippingAddressResponse' => $libDir . 'net/authorize/api/contract/v1/CreateCustomerShippingAddressResponse.php', |
||||||
|
'net\authorize\api\contract\v1\CreateProfileResponseType' => $libDir . 'net/authorize/api/contract/v1/CreateProfileResponseType.php', |
||||||
|
'net\authorize\api\contract\v1\CreateTransactionRequest' => $libDir . 'net/authorize/api/contract/v1/CreateTransactionRequest.php', |
||||||
|
'net\authorize\api\contract\v1\CreateTransactionResponse' => $libDir . 'net/authorize/api/contract/v1/CreateTransactionResponse.php', |
||||||
|
'net\authorize\api\contract\v1\CreditCardMaskedType' => $libDir . 'net/authorize/api/contract/v1/CreditCardMaskedType.php', |
||||||
|
'net\authorize\api\contract\v1\CreditCardSimpleType' => $libDir . 'net/authorize/api/contract/v1/CreditCardSimpleType.php', |
||||||
|
'net\authorize\api\contract\v1\CreditCardTrackType' => $libDir . 'net/authorize/api/contract/v1/CreditCardTrackType.php', |
||||||
|
'net\authorize\api\contract\v1\CreditCardType' => $libDir . 'net/authorize/api/contract/v1/CreditCardType.php', |
||||||
|
'net\authorize\api\contract\v1\CustomerAddressExType' => $libDir . 'net/authorize/api/contract/v1/CustomerAddressExType.php', |
||||||
|
'net\authorize\api\contract\v1\CustomerAddressType' => $libDir . 'net/authorize/api/contract/v1/CustomerAddressType.php', |
||||||
|
'net\authorize\api\contract\v1\CustomerDataType' => $libDir . 'net/authorize/api/contract/v1/CustomerDataType.php', |
||||||
|
'net\authorize\api\contract\v1\CustomerProfileIdType' => $libDir . 'net/authorize/api/contract/v1/CustomerProfileIdType.php', |
||||||
|
'net\authorize\api\contract\v1\CustomerPaymentProfileBaseType' => $libDir . 'net/authorize/api/contract/v1/CustomerPaymentProfileBaseType.php', |
||||||
|
'net\authorize\api\contract\v1\CustomerPaymentProfileExType' => $libDir . 'net/authorize/api/contract/v1/CustomerPaymentProfileExType.php', |
||||||
|
'net\authorize\api\contract\v1\CustomerPaymentProfileListItemType' => $libDir . 'net/authorize/api/contract/v1/CustomerPaymentProfileListItemType.php', |
||||||
|
'net\authorize\api\contract\v1\CustomerPaymentProfileMaskedType' => $libDir . 'net/authorize/api/contract/v1/CustomerPaymentProfileMaskedType.php', |
||||||
|
'net\authorize\api\contract\v1\CustomerPaymentProfileSortingType' => $libDir . 'net/authorize/api/contract/v1/CustomerPaymentProfileSortingType.php', |
||||||
|
'net\authorize\api\contract\v1\CustomerPaymentProfileType' => $libDir . 'net/authorize/api/contract/v1/CustomerPaymentProfileType.php', |
||||||
|
'net\authorize\api\contract\v1\CustomerProfileBaseType' => $libDir . 'net/authorize/api/contract/v1/CustomerProfileBaseType.php', |
||||||
|
'net\authorize\api\contract\v1\CustomerProfileExType' => $libDir . 'net/authorize/api/contract/v1/CustomerProfileExType.php', |
||||||
|
'net\authorize\api\contract\v1\CustomerProfileMaskedType' => $libDir . 'net/authorize/api/contract/v1/CustomerProfileMaskedType.php', |
||||||
|
'net\authorize\api\contract\v1\CustomerProfilePaymentType' => $libDir . 'net/authorize/api/contract/v1/CustomerProfilePaymentType.php', |
||||||
|
'net\authorize\api\contract\v1\CustomerProfileSummaryType' => $libDir . 'net/authorize/api/contract/v1/CustomerProfileSummaryType.php', |
||||||
|
'net\authorize\api\contract\v1\CustomerProfileType' => $libDir . 'net/authorize/api/contract/v1/CustomerProfileType.php', |
||||||
|
'net\authorize\api\contract\v1\CustomerType' => $libDir . 'net/authorize/api/contract/v1/CustomerType.php', |
||||||
|
'net\authorize\api\contract\v1\DecryptPaymentDataRequest' => $libDir . 'net/authorize/api/contract/v1/DecryptPaymentDataRequest.php', |
||||||
|
'net\authorize\api\contract\v1\DecryptPaymentDataResponse' => $libDir . 'net/authorize/api/contract/v1/DecryptPaymentDataResponse.php', |
||||||
|
'net\authorize\api\contract\v1\DeleteCustomerPaymentProfileRequest' => $libDir . 'net/authorize/api/contract/v1/DeleteCustomerPaymentProfileRequest.php', |
||||||
|
'net\authorize\api\contract\v1\DeleteCustomerPaymentProfileResponse' => $libDir . 'net/authorize/api/contract/v1/DeleteCustomerPaymentProfileResponse.php', |
||||||
|
'net\authorize\api\contract\v1\DeleteCustomerProfileRequest' => $libDir . 'net/authorize/api/contract/v1/DeleteCustomerProfileRequest.php', |
||||||
|
'net\authorize\api\contract\v1\DeleteCustomerProfileResponse' => $libDir . 'net/authorize/api/contract/v1/DeleteCustomerProfileResponse.php', |
||||||
|
'net\authorize\api\contract\v1\DeleteCustomerShippingAddressRequest' => $libDir . 'net/authorize/api/contract/v1/DeleteCustomerShippingAddressRequest.php', |
||||||
|
'net\authorize\api\contract\v1\DeleteCustomerShippingAddressResponse' => $libDir . 'net/authorize/api/contract/v1/DeleteCustomerShippingAddressResponse.php', |
||||||
|
'net\authorize\api\contract\v1\DriversLicenseMaskedType' => $libDir . 'net/authorize/api/contract/v1/DriversLicenseMaskedType.php', |
||||||
|
'net\authorize\api\contract\v1\DriversLicenseType' => $libDir . 'net/authorize/api/contract/v1/DriversLicenseType.php', |
||||||
|
'net\authorize\api\contract\v1\EmailSettingsType' => $libDir . 'net/authorize/api/contract/v1/EmailSettingsType.php', |
||||||
|
'net\authorize\api\contract\v1\EncryptedTrackDataType' => $libDir . 'net/authorize/api/contract/v1/EncryptedTrackDataType.php', |
||||||
|
'net\authorize\api\contract\v1\EnumCollection' => $libDir . 'net/authorize/api/contract/v1/EnumCollection.php', |
||||||
|
'net\authorize\api\contract\v1\ErrorResponse' => $libDir . 'net/authorize/api/contract/v1/ErrorResponse.php', |
||||||
|
'net\authorize\api\contract\v1\ExtendedAmountType' => $libDir . 'net/authorize/api/contract/v1/ExtendedAmountType.php', |
||||||
|
'net\authorize\api\contract\v1\FDSFilterType' => $libDir . 'net/authorize/api/contract/v1/FDSFilterType.php', |
||||||
|
'net\authorize\api\contract\v1\FingerPrintType' => $libDir . 'net/authorize/api/contract/v1/FingerPrintType.php', |
||||||
|
'net\authorize\api\contract\v1\FraudInformationType'=> $libDir . 'net/authorize/api/contract/v1/FraudInformationType.php', |
||||||
|
'net\authorize\api\contract\v1\GetBatchStatisticsRequest' => $libDir . 'net/authorize/api/contract/v1/GetBatchStatisticsRequest.php', |
||||||
|
'net\authorize\api\contract\v1\GetBatchStatisticsResponse' => $libDir . 'net/authorize/api/contract/v1/GetBatchStatisticsResponse.php', |
||||||
|
'net\authorize\api\contract\v1\GetCustomerPaymentProfileListRequest' => $libDir . 'net/authorize/api/contract/v1/GetCustomerPaymentProfileListRequest.php', |
||||||
|
'net\authorize\api\contract\v1\GetCustomerPaymentProfileListResponse' => $libDir . 'net/authorize/api/contract/v1/GetCustomerPaymentProfileListResponse.php', |
||||||
|
'net\authorize\api\contract\v1\GetCustomerPaymentProfileRequest' => $libDir . 'net/authorize/api/contract/v1/GetCustomerPaymentProfileRequest.php', |
||||||
|
'net\authorize\api\contract\v1\GetCustomerPaymentProfileResponse' => $libDir . 'net/authorize/api/contract/v1/GetCustomerPaymentProfileResponse.php', |
||||||
|
'net\authorize\api\contract\v1\GetCustomerProfileIdsRequest' => $libDir . 'net/authorize/api/contract/v1/GetCustomerProfileIdsRequest.php', |
||||||
|
'net\authorize\api\contract\v1\GetCustomerProfileIdsResponse' => $libDir . 'net/authorize/api/contract/v1/GetCustomerProfileIdsResponse.php', |
||||||
|
'net\authorize\api\contract\v1\GetCustomerProfileRequest' => $libDir . 'net/authorize/api/contract/v1/GetCustomerProfileRequest.php', |
||||||
|
'net\authorize\api\contract\v1\GetCustomerProfileResponse' => $libDir . 'net/authorize/api/contract/v1/GetCustomerProfileResponse.php', |
||||||
|
'net\authorize\api\contract\v1\GetCustomerShippingAddressRequest' => $libDir . 'net/authorize/api/contract/v1/GetCustomerShippingAddressRequest.php', |
||||||
|
'net\authorize\api\contract\v1\GetCustomerShippingAddressResponse' => $libDir . 'net/authorize/api/contract/v1/GetCustomerShippingAddressResponse.php', |
||||||
|
'net\authorize\api\contract\v1\GetHostedPaymentPageRequest'=> $libDir . 'net/authorize/api/contract/v1/GetHostedPaymentPageRequest.php', |
||||||
|
'net\authorize\api\contract\v1\GetHostedPaymentPageResponse'=> $libDir . 'net/authorize/api/contract/v1/GetHostedPaymentPageResponse.php', |
||||||
|
'net\authorize\api\contract\v1\GetHostedProfilePageRequest' => $libDir . 'net/authorize/api/contract/v1/GetHostedProfilePageRequest.php', |
||||||
|
'net\authorize\api\contract\v1\GetHostedProfilePageResponse' => $libDir . 'net/authorize/api/contract/v1/GetHostedProfilePageResponse.php', |
||||||
|
'net\authorize\api\contract\v1\GetMerchantDetailsRequest'=> $libDir . 'net/authorize/api/contract/v1/GetMerchantDetailsRequest.php', |
||||||
|
'net\authorize\api\contract\v1\GetMerchantDetailsResponse'=> $libDir . 'net/authorize/api/contract/v1/GetMerchantDetailsResponse.php', |
||||||
|
'net\authorize\api\contract\v1\GetSettledBatchListRequest' => $libDir . 'net/authorize/api/contract/v1/GetSettledBatchListRequest.php', |
||||||
|
'net\authorize\api\contract\v1\GetSettledBatchListResponse' => $libDir . 'net/authorize/api/contract/v1/GetSettledBatchListResponse.php', |
||||||
|
'net\authorize\api\contract\v1\GetTransactionDetailsRequest' => $libDir . 'net/authorize/api/contract/v1/GetTransactionDetailsRequest.php', |
||||||
|
'net\authorize\api\contract\v1\GetTransactionDetailsResponse' => $libDir . 'net/authorize/api/contract/v1/GetTransactionDetailsResponse.php', |
||||||
|
'net\authorize\api\contract\v1\GetTransactionListRequest' => $libDir . 'net/authorize/api/contract/v1/GetTransactionListRequest.php', |
||||||
|
'net\authorize\api\contract\v1\GetTransactionListResponse' => $libDir . 'net/authorize/api/contract/v1/GetTransactionListResponse.php', |
||||||
|
'net\authorize\api\contract\v1\GetUnsettledTransactionListRequest' => $libDir . 'net/authorize/api/contract/v1/GetUnsettledTransactionListRequest.php', |
||||||
|
'net\authorize\api\contract\v1\GetUnsettledTransactionListResponse' => $libDir . 'net/authorize/api/contract/v1/GetUnsettledTransactionListResponse.php', |
||||||
|
'net\authorize\api\contract\v1\HeldTransactionRequestType'=> $libDir . 'net/authorize/api/contract/v1/HeldTransactionRequestType.php', |
||||||
|
'net\authorize\api\contract\v1\ImpersonationAuthenticationType' => $libDir . 'net/authorize/api/contract/v1/ImpersonationAuthenticationType.php', |
||||||
|
'net\authorize\api\contract\v1\IsAliveRequest' => $libDir . 'net/authorize/api/contract/v1/IsAliveRequest.php', |
||||||
|
'net\authorize\api\contract\v1\IsAliveResponse' => $libDir . 'net/authorize/api/contract/v1/IsAliveResponse.php', |
||||||
|
'net\authorize\api\contract\v1\KeyBlockType' => $libDir . 'net/authorize/api/contract/v1/KeyBlockType.php', |
||||||
|
'net\authorize\api\contract\v1\KeyManagementSchemeType' => $libDir . 'net/authorize/api/contract/v1/KeyManagementSchemeType.php', |
||||||
|
'net\authorize\api\contract\v1\KeyValueType' => $libDir . 'net/authorize/api/contract/v1/KeyValueType.php', |
||||||
|
'net\authorize\api\contract\v1\LineItemType' => $libDir . 'net/authorize/api/contract/v1/LineItemType.php', |
||||||
|
'net\authorize\api\contract\v1\LogoutRequest' => $libDir . 'net/authorize/api/contract/v1/LogoutRequest.php', |
||||||
|
'net\authorize\api\contract\v1\LogoutResponse' => $libDir . 'net/authorize/api/contract/v1/LogoutResponse.php', |
||||||
|
'net\authorize\api\contract\v1\MerchantAuthenticationType' => $libDir . 'net/authorize/api/contract/v1/MerchantAuthenticationType.php', |
||||||
|
'net\authorize\api\contract\v1\MerchantContactType' => $libDir . 'net/authorize/api/contract/v1/MerchantContactType.php', |
||||||
|
'net\authorize\api\contract\v1\MessagesType' => $libDir . 'net/authorize/api/contract/v1/MessagesType.php', |
||||||
|
'net\authorize\api\contract\v1\MobileDeviceLoginRequest' => $libDir . 'net/authorize/api/contract/v1/MobileDeviceLoginRequest.php', |
||||||
|
'net\authorize\api\contract\v1\MobileDeviceLoginResponse' => $libDir . 'net/authorize/api/contract/v1/MobileDeviceLoginResponse.php', |
||||||
|
'net\authorize\api\contract\v1\MobileDeviceRegistrationRequest' => $libDir . 'net/authorize/api/contract/v1/MobileDeviceRegistrationRequest.php', |
||||||
|
'net\authorize\api\contract\v1\MobileDeviceRegistrationResponse' => $libDir . 'net/authorize/api/contract/v1/MobileDeviceRegistrationResponse.php', |
||||||
|
'net\authorize\api\contract\v1\MobileDeviceType' => $libDir . 'net/authorize/api/contract/v1/MobileDeviceType.php', |
||||||
|
'net\authorize\api\contract\v1\NameAndAddressType' => $libDir . 'net/authorize/api/contract/v1/NameAndAddressType.php', |
||||||
|
'net\authorize\api\contract\v1\OpaqueDataType' => $libDir . 'net/authorize/api/contract/v1/OpaqueDataType.php', |
||||||
|
'net\authorize\api\contract\v1\OrderExType' => $libDir . 'net/authorize/api/contract/v1/OrderExType.php', |
||||||
|
'net\authorize\api\contract\v1\OrderType' => $libDir . 'net/authorize/api/contract/v1/OrderType.php', |
||||||
|
'net\authorize\api\contract\v1\PagingType' => $libDir . 'net/authorize/api/contract/v1/PagingType.php', |
||||||
|
'net\authorize\api\contract\v1\PaymentDetailsType' => $libDir . 'net/authorize/api/contract/v1/PaymentDetailsType.php', |
||||||
|
'net\authorize\api\contract\v1\PaymentMaskedType' => $libDir . 'net/authorize/api/contract/v1/PaymentMaskedType.php', |
||||||
|
'net\authorize\api\contract\v1\PaymentProfileType' => $libDir . 'net/authorize/api/contract/v1/PaymentProfileType.php', |
||||||
|
'net\authorize\api\contract\v1\PaymentScheduleType' => $libDir . 'net/authorize/api/contract/v1/PaymentScheduleType.php', |
||||||
|
'net\authorize\api\contract\v1\PaymentSimpleType' => $libDir . 'net/authorize/api/contract/v1/PaymentSimpleType.php', |
||||||
|
'net\authorize\api\contract\v1\PaymentType' => $libDir . 'net/authorize/api/contract/v1/PaymentType.php', |
||||||
|
'net\authorize\api\contract\v1\PayPalType' => $libDir . 'net/authorize/api/contract/v1/PayPalType.php', |
||||||
|
'net\authorize\api\contract\v1\PermissionType' => $libDir . 'net/authorize/api/contract/v1/PermissionType.php', |
||||||
|
'net\authorize\api\contract\v1\ProcessorType'=> $libDir . 'net/authorize/api/contract/v1/ProcessorType.php', |
||||||
|
'net\authorize\api\contract\v1\ProfileTransactionType' => $libDir . 'net/authorize/api/contract/v1/ProfileTransactionType.php', |
||||||
|
'net\authorize\api\contract\v1\ProfileTransAmountType' => $libDir . 'net/authorize/api/contract/v1/ProfileTransAmountType.php', |
||||||
|
'net\authorize\api\contract\v1\ProfileTransAuthCaptureType' => $libDir . 'net/authorize/api/contract/v1/ProfileTransAuthCaptureType.php', |
||||||
|
'net\authorize\api\contract\v1\ProfileTransAuthOnlyType' => $libDir . 'net/authorize/api/contract/v1/ProfileTransAuthOnlyType.php', |
||||||
|
'net\authorize\api\contract\v1\ProfileTransCaptureOnlyType' => $libDir . 'net/authorize/api/contract/v1/ProfileTransCaptureOnlyType.php', |
||||||
|
'net\authorize\api\contract\v1\ProfileTransOrderType' => $libDir . 'net/authorize/api/contract/v1/ProfileTransOrderType.php', |
||||||
|
'net\authorize\api\contract\v1\ProfileTransPriorAuthCaptureType' => $libDir . 'net/authorize/api/contract/v1/ProfileTransPriorAuthCaptureType.php', |
||||||
|
'net\authorize\api\contract\v1\ProfileTransRefundType' => $libDir . 'net/authorize/api/contract/v1/ProfileTransRefundType.php', |
||||||
|
'net\authorize\api\contract\v1\ProfileTransVoidType' => $libDir . 'net/authorize/api/contract/v1/ProfileTransVoidType.php', |
||||||
|
'net\authorize\api\contract\v1\ReturnedItemType' => $libDir . 'net/authorize/api/contract/v1/ReturnedItemType.php', |
||||||
|
'net\authorize\api\contract\v1\SearchCriteriaCustomerProfileType' => $libDir . 'net/authorize/api/contract/v1/SearchCriteriaCustomerProfileType.php', |
||||||
|
'net\authorize\api\contract\v1\SecurePaymentContainerErrorType' => $libDir . 'net/authorize/api/contract/v1/SecurePaymentContainerErrorType.php', |
||||||
|
'net\authorize\api\contract\v1\SecurePaymentContainerRequest' => $libDir . 'net/authorize/api/contract/v1/SecurePaymentContainerRequest.php', |
||||||
|
'net\authorize\api\contract\v1\SecurePaymentContainerResponse' => $libDir . 'net/authorize/api/contract/v1/SecurePaymentContainerResponse.php', |
||||||
|
'net\authorize\api\contract\v1\SendCustomerTransactionReceiptRequest' => $libDir . 'net/authorize/api/contract/v1/SendCustomerTransactionReceiptRequest.php', |
||||||
|
'net\authorize\api\contract\v1\SendCustomerTransactionReceiptResponse' => $libDir . 'net/authorize/api/contract/v1/SendCustomerTransactionReceiptResponse.php', |
||||||
|
'net\authorize\api\contract\v1\SettingType' => $libDir . 'net/authorize/api/contract/v1/SettingType.php', |
||||||
|
'net\authorize\api\contract\v1\SolutionType' => $libDir . 'net/authorize/api/contract/v1/SolutionType.php', |
||||||
|
'net\authorize\api\contract\v1\SubMerchantType' => $libDir . 'net/authorize/api/contract/v1/SubMerchantType.php', |
||||||
|
'net\authorize\api\contract\v1\SubscriptionCustomerProfileType' => $libDir . 'net/authorize/api/contract/v1/SubscriptionCustomerProfileType.php', |
||||||
|
'net\authorize\api\contract\v1\SubscriptionDetailType' => $libDir . 'net/authorize/api/contract/v1/SubscriptionDetailType.php', |
||||||
|
'net\authorize\api\contract\v1\SubscriptionPaymentType' => $libDir . 'net/authorize/api/contract/v1/SubscriptionPaymentType.php', |
||||||
|
'net\authorize\api\contract\v1\TokenMaskedType' => $libDir . 'net/authorize/api/contract/v1/TokenMaskedType.php', |
||||||
|
'net\authorize\api\contract\v1\TransactionDetailsType' => $libDir . 'net/authorize/api/contract/v1/TransactionDetailsType.php', |
||||||
|
'net\authorize\api\contract\v1\TransactionListSortingType'=> $libDir . 'net/authorize/api/contract/v1/TransactionListSortingType.php', |
||||||
|
'net\authorize\api\contract\v1\TransactionRequestType' => $libDir . 'net/authorize/api/contract/v1/TransactionRequestType.php', |
||||||
|
'net\authorize\api\contract\v1\TransactionResponseType' => $libDir . 'net/authorize/api/contract/v1/TransactionResponseType.php', |
||||||
|
'net\authorize\api\contract\v1\TransactionSummaryType' => $libDir . 'net/authorize/api/contract/v1/TransactionSummaryType.php', |
||||||
|
'net\authorize\api\contract\v1\TransRetailInfoType' => $libDir . 'net/authorize/api/contract/v1/TransRetailInfoType.php', |
||||||
|
'net\authorize\api\contract\v1\UpdateCustomerPaymentProfileRequest' => $libDir . 'net/authorize/api/contract/v1/UpdateCustomerPaymentProfileRequest.php', |
||||||
|
'net\authorize\api\contract\v1\UpdateCustomerPaymentProfileResponse' => $libDir . 'net/authorize/api/contract/v1/UpdateCustomerPaymentProfileResponse.php', |
||||||
|
'net\authorize\api\contract\v1\UpdateCustomerProfileRequest' => $libDir . 'net/authorize/api/contract/v1/UpdateCustomerProfileRequest.php', |
||||||
|
'net\authorize\api\contract\v1\UpdateCustomerProfileResponse' => $libDir . 'net/authorize/api/contract/v1/UpdateCustomerProfileResponse.php', |
||||||
|
'net\authorize\api\contract\v1\UpdateCustomerShippingAddressRequest' => $libDir . 'net/authorize/api/contract/v1/UpdateCustomerShippingAddressRequest.php', |
||||||
|
'net\authorize\api\contract\v1\UpdateCustomerShippingAddressResponse' => $libDir . 'net/authorize/api/contract/v1/UpdateCustomerShippingAddressResponse.php', |
||||||
|
'net\authorize\api\contract\v1\UpdateHeldTransactionRequest'=> $libDir . 'net/authorize/api/contract/v1/UpdateHeldTransactionRequest.php', |
||||||
|
'net\authorize\api\contract\v1\UpdateHeldTransactionResponse'=> $libDir . 'net/authorize/api/contract/v1/UpdateHeldTransactionResponse.php', |
||||||
|
'net\authorize\api\contract\v1\UpdateSplitTenderGroupRequest' => $libDir . 'net/authorize/api/contract/v1/UpdateSplitTenderGroupRequest.php', |
||||||
|
'net\authorize\api\contract\v1\UpdateSplitTenderGroupResponse' => $libDir . 'net/authorize/api/contract/v1/UpdateSplitTenderGroupResponse.php', |
||||||
|
'net\authorize\api\contract\v1\UserFieldType' => $libDir . 'net/authorize/api/contract/v1/UserFieldType.php', |
||||||
|
'net\authorize\api\contract\v1\ValidateCustomerPaymentProfileRequest' => $libDir . 'net/authorize/api/contract/v1/ValidateCustomerPaymentProfileRequest.php', |
||||||
|
'net\authorize\api\contract\v1\ValidateCustomerPaymentProfileResponse' => $libDir . 'net/authorize/api/contract/v1/ValidateCustomerPaymentProfileResponse.php', |
||||||
|
'net\authorize\api\contract\v1\WebCheckOutDataType' => $libDir . 'net/authorize/api/contract/v1/WebCheckOutDataType.php', |
||||||
|
'net\authorize\api\contract\v1\KeyManagementSchemeType\DUKPTAType' => $libDir . 'net/authorize/api/contract/v1/KeyManagementSchemeType/DUKPTAType.php', |
||||||
|
'net\authorize\api\contract\v1\KeyManagementSchemeType\DUKPTAType\DeviceInfoAType' => $libDir . 'net/authorize/api/contract/v1/KeyManagementSchemeType/DUKPTAType/DeviceInfoAType.php', |
||||||
|
'net\authorize\api\contract\v1\KeyManagementSchemeType\DUKPTAType\EncryptedDataAType' => $libDir . 'net/authorize/api/contract/v1/KeyManagementSchemeType/DUKPTAType/EncryptedDataAType.php', |
||||||
|
'net\authorize\api\contract\v1\KeyManagementSchemeType\DUKPTAType\ModeAType' => $libDir . 'net/authorize/api/contract/v1/KeyManagementSchemeType/DUKPTAType/ModeAType.php', |
||||||
|
'net\authorize\api\contract\v1\MessagesType\MessageAType' => $libDir . 'net/authorize/api/contract/v1/MessagesType/MessageAType.php', |
||||||
|
'net\authorize\api\contract\v1\PaymentScheduleType\IntervalAType' => $libDir . 'net/authorize/api/contract/v1/PaymentScheduleType/IntervalAType.php', |
||||||
|
'net\authorize\api\contract\v1\TransactionRequestType\UserFieldsAType' => $libDir . 'net/authorize/api/contract/v1/TransactionRequestType/UserFieldsAType.php', |
||||||
|
'net\authorize\api\contract\v1\TransactionResponseType\ErrorsAType' => $libDir . 'net/authorize/api/contract/v1/TransactionResponseType/ErrorsAType.php', |
||||||
|
'net\authorize\api\contract\v1\TransactionResponseType\MessagesAType' => $libDir . 'net/authorize/api/contract/v1/TransactionResponseType/MessagesAType.php', |
||||||
|
'net\authorize\api\contract\v1\TransactionResponseType\PrePaidCardAType' => $libDir . 'net/authorize/api/contract/v1/TransactionResponseType/PrePaidCardAType.php', |
||||||
|
'net\authorize\api\contract\v1\TransactionResponseType\SecureAcceptanceAType' => $libDir . 'net/authorize/api/contract/v1/TransactionResponseType/SecureAcceptanceAType.php', |
||||||
|
'net\authorize\api\contract\v1\TransactionResponseType\SplitTenderPaymentsAType' => $libDir . 'net/authorize/api/contract/v1/TransactionResponseType/SplitTenderPaymentsAType.php', |
||||||
|
'net\authorize\api\contract\v1\TransactionResponseType\UserFieldsAType' => $libDir . 'net/authorize/api/contract/v1/TransactionResponseType/UserFieldsAType.php', |
||||||
|
'net\authorize\api\contract\v1\TransactionResponseType\ErrorsAType\ErrorAType' => $libDir . 'net/authorize/api/contract/v1/TransactionResponseType/ErrorsAType/ErrorAType.php', |
||||||
|
'net\authorize\api\contract\v1\TransactionResponseType\MessagesAType\MessageAType' => $libDir . 'net/authorize/api/contract/v1/TransactionResponseType/MessagesAType/MessageAType.php', |
||||||
|
'net\authorize\api\contract\v1\TransactionResponseType\SplitTenderPaymentsAType\SplitTenderPaymentAType' => $libDir . 'net/authorize/api/contract/v1/TransactionResponseType/SplitTenderPaymentsAType/SplitTenderPaymentAType.php', |
||||||
|
'net\authorize\api\contract\v1\WebCheckOutDataType\TokenAType' => $libDir . 'net/authorize/api/contract/v1/WebCheckOutDataType/TokenAType.php', |
||||||
|
'net\authorize\api\contract\v1\GetTransactionListForCustomerRequest' => $libDir . 'net/authorize/api/contract/v1/GetTransactionListForCustomerRequest.php', |
||||||
|
|
||||||
|
'net\authorize\api\contract\v1\GetAUJobSummaryRequest' => $libDir . 'net/authorize/api/contract/v1/getAUJobSummaryRequest.php', |
||||||
|
'net\authorize\api\contract\v1\GetAUJobSummaryResponse' => $libDir . 'net/authorize/api/contract/v1/GetAUJobSummaryResponse.php', |
||||||
|
'net\authorize\api\contract\v1\GetAUJobDetailsRequest' => $libDir . 'net/authorize/api/contract/v1/GetAUJobDetailsRequest.php', |
||||||
|
'net\authorize\api\contract\v1\GetAUJobDetailsResponse' => $libDir . 'net/authorize/api/contract/v1/GetAUJobDetailsResponse.php', |
||||||
|
|
||||||
|
'net\authorize\api\contract\v1\AuDeleteType' => $libDir . 'net/authorize/api/contract/v1/AuDeleteType.php', |
||||||
|
'net\authorize\api\contract\v1\AuDetailsType' => $libDir . 'net/authorize/api/contract/v1/AuDetailsType.php', |
||||||
|
'net\authorize\api\contract\v1\AuResponseType' => $libDir . 'net/authorize/api/contract/v1/AuResponseType.php', |
||||||
|
'net\authorize\api\contract\v1\AuUpdateType' => $libDir . 'net/authorize/api/contract/v1/AuUpdateType.php', |
||||||
|
|
||||||
|
'net\authorize\api\contract\v1\ListOfAUDetailsType' => $libDir . 'net/authorize/api/contract/v1/ListOfAUDetailsType.php', |
||||||
|
'net\authorize\api\contract\v1\EmvTagType' => $libDir . 'net/authorize/api/contract/v1/EmvTagType.php', |
||||||
|
'net\authorize\api\contract\v1\PaymentEmvType' => $libDir . 'net/authorize/api/contract/v1/PaymentEmvType.php', |
||||||
|
'net\authorize\api\contract\v1\OtherTaxType' => $libDir . 'net/authorize/api/contract/v1/OtherTaxType.php', |
||||||
|
'net\authorize\api\contract\v1\UpdateMerchantDetailsRequest' => $libDir . 'net/authorize/api/contract/v1/UpdateMerchantDetailsRequest.php', |
||||||
|
'net\authorize\api\contract\v1\UpdateMerchantDetailsResponse' => $libDir . 'net/authorize/api/contract/v1/UpdateMerchantDetailsResponse.php', |
||||||
|
'net\authorize\api\contract\v1\WebCheckOutDataTypeTokenType' => $libDir . 'net/authorize/api/contract/v1/WebCheckOutDataTypeTokenType.php', |
||||||
|
|
||||||
|
//Controllers |
||||||
|
'net\authorize\api\controller\ARBCancelSubscriptionController' => $libDir . 'net/authorize/api/controller/ARBCancelSubscriptionController.php', |
||||||
|
'net\authorize\api\controller\ARBCreateSubscriptionController' => $libDir . 'net/authorize/api/controller/ARBCreateSubscriptionController.php', |
||||||
|
'net\authorize\api\controller\ARBGetSubscriptionController' => $libDir . 'net/authorize/api/controller/ARBGetSubscriptionController.php', |
||||||
|
'net\authorize\api\controller\ARBGetSubscriptionListController' => $libDir . 'net/authorize/api/controller/ARBGetSubscriptionListController.php', |
||||||
|
'net\authorize\api\controller\ARBGetSubscriptionStatusController' => $libDir . 'net/authorize/api/controller/ARBGetSubscriptionStatusController.php', |
||||||
|
'net\authorize\api\controller\ARBUpdateSubscriptionController' => $libDir . 'net/authorize/api/controller/ARBUpdateSubscriptionController.php', |
||||||
|
'net\authorize\api\controller\AuthenticateTestController' => $libDir . 'net/authorize/api/controller/AuthenticateTestController.php', |
||||||
|
'net\authorize\api\controller\CreateCustomerPaymentProfileController' => $libDir . 'net/authorize/api/controller/CreateCustomerPaymentProfileController.php', |
||||||
|
'net\authorize\api\controller\CreateCustomerProfileController' => $libDir . 'net/authorize/api/controller/CreateCustomerProfileController.php', |
||||||
|
'net\authorize\api\controller\CreateCustomerProfileFromTransactionController' => $libDir . 'net/authorize/api/controller/CreateCustomerProfileFromTransactionController.php', |
||||||
|
'net\authorize\api\controller\CreateCustomerProfileTransactionController' => $libDir . 'net/authorize/api/controller/CreateCustomerProfileTransactionController.php', |
||||||
|
'net\authorize\api\controller\CreateCustomerShippingAddressController' => $libDir . 'net/authorize/api/controller/CreateCustomerShippingAddressController.php', |
||||||
|
'net\authorize\api\controller\CreateTransactionController' => $libDir . 'net/authorize/api/controller/CreateTransactionController.php', |
||||||
|
'net\authorize\api\controller\DecryptPaymentDataController' => $libDir . 'net/authorize/api/controller/DecryptPaymentDataController.php', |
||||||
|
'net\authorize\api\controller\DeleteCustomerPaymentProfileController' => $libDir . 'net/authorize/api/controller/DeleteCustomerPaymentProfileController.php', |
||||||
|
'net\authorize\api\controller\DeleteCustomerProfileController' => $libDir . 'net/authorize/api/controller/DeleteCustomerProfileController.php', |
||||||
|
'net\authorize\api\controller\DeleteCustomerShippingAddressController' => $libDir . 'net/authorize/api/controller/DeleteCustomerShippingAddressController.php', |
||||||
|
'net\authorize\api\controller\GetAUJobDetailsController' => $libDir . 'net/authorize/api/controller/GetAUJobDetailsController.php', |
||||||
|
'net\authorize\api\controller\GetAUJobSummaryController' => $libDir . 'net/authorize/api/controller/GetAUJobSummaryController.php', |
||||||
|
'net\authorize\api\controller\GetBatchStatisticsController' => $libDir . 'net/authorize/api/controller/GetBatchStatisticsController.php', |
||||||
|
'net\authorize\api\controller\GetCustomerPaymentProfileController' => $libDir . 'net/authorize/api/controller/GetCustomerPaymentProfileController.php', |
||||||
|
'net\authorize\api\controller\GetCustomerPaymentProfileListController' => $libDir . 'net/authorize/api/controller/GetCustomerPaymentProfileListController.php', |
||||||
|
'net\authorize\api\controller\GetCustomerProfileController' => $libDir . 'net/authorize/api/controller/GetCustomerProfileController.php', |
||||||
|
'net\authorize\api\controller\GetCustomerProfileIdsController' => $libDir . 'net/authorize/api/controller/GetCustomerProfileIdsController.php', |
||||||
|
'net\authorize\api\controller\GetCustomerShippingAddressController' => $libDir . 'net/authorize/api/controller/GetCustomerShippingAddressController.php', |
||||||
|
'net\authorize\api\controller\GetHostedPaymentPageController' => $libDir . 'net/authorize/api/controller/GetHostedPaymentPageController.php', |
||||||
|
'net\authorize\api\controller\GetHostedProfilePageController' => $libDir . 'net/authorize/api/controller/GetHostedProfilePageController.php', |
||||||
|
'net\authorize\api\controller\GetMerchantDetailsController' => $libDir . 'net/authorize/api/controller/GetMerchantDetailsController.php', |
||||||
|
'net\authorize\api\controller\GetSettledBatchListController' => $libDir . 'net/authorize/api/controller/GetSettledBatchListController.php', |
||||||
|
'net\authorize\api\controller\GetTransactionDetailsController' => $libDir . 'net/authorize/api/controller/GetTransactionDetailsController.php', |
||||||
|
'net\authorize\api\controller\GetTransactionListController' => $libDir . 'net/authorize/api/controller/GetTransactionListController.php', |
||||||
|
'net\authorize\api\controller\GetTransactionListForCustomerController' => $libDir . 'net/authorize/api/controller/GetTransactionListForCustomerController.php', |
||||||
|
'net\authorize\api\controller\GetUnsettledTransactionListController' => $libDir . 'net/authorize/api/controller/GetUnsettledTransactionListController.php', |
||||||
|
'net\authorize\api\controller\IsAliveController' => $libDir . 'net/authorize/api/controller/IsAliveController.php', |
||||||
|
'net\authorize\api\controller\LogoutController' => $libDir . 'net/authorize/api/controller/LogoutController.php', |
||||||
|
'net\authorize\api\controller\MobileDeviceLoginController' => $libDir . 'net/authorize/api/controller/MobileDeviceLoginController.php', |
||||||
|
'net\authorize\api\controller\MobileDeviceRegistrationController' => $libDir . 'net/authorize/api/controller/MobileDeviceRegistrationController.php', |
||||||
|
'net\authorize\api\controller\SecurePaymentContainerController' => $libDir . 'net/authorize/api/controller/SecurePaymentContainerController.php', |
||||||
|
'net\authorize\api\controller\SendCustomerTransactionReceiptController' => $libDir . 'net/authorize/api/controller/SendCustomerTransactionReceiptController.php', |
||||||
|
'net\authorize\api\controller\UpdateCustomerPaymentProfileController' => $libDir . 'net/authorize/api/controller/UpdateCustomerPaymentProfileController.php', |
||||||
|
'net\authorize\api\controller\UpdateCustomerProfileController' => $libDir . 'net/authorize/api/controller/UpdateCustomerProfileController.php', |
||||||
|
'net\authorize\api\controller\UpdateCustomerShippingAddressController' => $libDir . 'net/authorize/api/controller/UpdateCustomerShippingAddressController.php', |
||||||
|
'net\authorize\api\controller\UpdateHeldTransactionController' => $libDir . 'net/authorize/api/controller/UpdateHeldTransactionController.php', |
||||||
|
'net\authorize\api\controller\UpdateMerchantDetailsController' => $libDir . 'net/authorize/api/controller/UpdateMerchantDetailsController.php', |
||||||
|
'net\authorize\api\controller\UpdateSplitTenderGroupController' => $libDir . 'net/authorize/api/controller/UpdateSplitTenderGroupController.php', |
||||||
|
'net\authorize\api\controller\ValidateCustomerPaymentProfileController' => $libDir . 'net/authorize/api/controller/ValidateCustomerPaymentProfileController.php' |
||||||
|
|
||||||
|
); |
@ -0,0 +1,11 @@ |
|||||||
|
<?php |
||||||
|
namespace net\authorize\api\constants; |
||||||
|
|
||||||
|
class ANetEnvironment |
||||||
|
{ |
||||||
|
const CUSTOM = "http://wwww.myendpoint.com"; |
||||||
|
const SANDBOX = "https://apitest.authorize.net"; |
||||||
|
const PRODUCTION = "https://api2.authorize.net"; |
||||||
|
|
||||||
|
const VERSION = "2.0.1"; |
||||||
|
} |
@ -0,0 +1,75 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace net\authorize\api\contract\v1; |
||||||
|
|
||||||
|
/** |
||||||
|
* Class representing ARBCancelSubscriptionRequest |
||||||
|
*/ |
||||||
|
class ARBCancelSubscriptionRequest extends ANetApiRequestType |
||||||
|
{ |
||||||
|
|
||||||
|
/** |
||||||
|
* @property string $subscriptionId |
||||||
|
*/ |
||||||
|
private $subscriptionId = null; |
||||||
|
|
||||||
|
/** |
||||||
|
* Gets as subscriptionId |
||||||
|
* |
||||||
|
* @return string |
||||||
|
*/ |
||||||
|
public function getSubscriptionId() |
||||||
|
{ |
||||||
|
return $this->subscriptionId; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Sets a new subscriptionId |
||||||
|
* |
||||||
|
* @param string $subscriptionId |
||||||
|
* @return self |
||||||
|
*/ |
||||||
|
public function setSubscriptionId($subscriptionId) |
||||||
|
{ |
||||||
|
$this->subscriptionId = $subscriptionId; |
||||||
|
return $this; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
// Json Serialize Code |
||||||
|
public function jsonSerialize(){ |
||||||
|
$values = array_filter((array)get_object_vars($this), |
||||||
|
function ($val){ |
||||||
|
return !is_null($val); |
||||||
|
}); |
||||||
|
$mapper = \net\authorize\util\Mapper::Instance(); |
||||||
|
foreach($values as $key => $value){ |
||||||
|
$classDetails = $mapper->getClass(get_class() , $key); |
||||||
|
if (isset($value)){ |
||||||
|
if ($classDetails->className === 'Date'){ |
||||||
|
$dateTime = $value->format('Y-m-d'); |
||||||
|
$values[$key] = $dateTime; |
||||||
|
} |
||||||
|
else if ($classDetails->className === 'DateTime'){ |
||||||
|
$dateTime = $value->format('Y-m-d\TH:i:s\Z'); |
||||||
|
$values[$key] = $dateTime; |
||||||
|
} |
||||||
|
if (is_array($value)){ |
||||||
|
if (!$classDetails->isInlineArray){ |
||||||
|
$subKey = $classDetails->arrayEntryname; |
||||||
|
$subArray = [$subKey => $value]; |
||||||
|
$values[$key] = $subArray; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
if (get_parent_class() == ""){ |
||||||
|
return $values; |
||||||
|
} |
||||||
|
else{ |
||||||
|
return array_merge(parent::jsonSerialize(), $values); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
@ -0,0 +1,75 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace net\authorize\api\contract\v1; |
||||||
|
|
||||||
|
/** |
||||||
|
* Class representing ARBCreateSubscriptionRequest |
||||||
|
*/ |
||||||
|
class ARBCreateSubscriptionRequest extends ANetApiRequestType |
||||||
|
{ |
||||||
|
|
||||||
|
/** |
||||||
|
* @property \net\authorize\api\contract\v1\ARBSubscriptionType $subscription |
||||||
|
*/ |
||||||
|
private $subscription = null; |
||||||
|
|
||||||
|
/** |
||||||
|
* Gets as subscription |
||||||
|
* |
||||||
|
* @return \net\authorize\api\contract\v1\ARBSubscriptionType |
||||||
|
*/ |
||||||
|
public function getSubscription() |
||||||
|
{ |
||||||
|
return $this->subscription; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Sets a new subscription |
||||||
|
* |
||||||
|
* @param \net\authorize\api\contract\v1\ARBSubscriptionType $subscription |
||||||
|
* @return self |
||||||
|
*/ |
||||||
|
public function setSubscription(\net\authorize\api\contract\v1\ARBSubscriptionType $subscription) |
||||||
|
{ |
||||||
|
$this->subscription = $subscription; |
||||||
|
return $this; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
// Json Serialize Code |
||||||
|
public function jsonSerialize(){ |
||||||
|
$values = array_filter((array)get_object_vars($this), |
||||||
|
function ($val){ |
||||||
|
return !is_null($val); |
||||||
|
}); |
||||||
|
$mapper = \net\authorize\util\Mapper::Instance(); |
||||||
|
foreach($values as $key => $value){ |
||||||
|
$classDetails = $mapper->getClass(get_class() , $key); |
||||||
|
if (isset($value)){ |
||||||
|
if ($classDetails->className === 'Date'){ |
||||||
|
$dateTime = $value->format('Y-m-d'); |
||||||
|
$values[$key] = $dateTime; |
||||||
|
} |
||||||
|
else if ($classDetails->className === 'DateTime'){ |
||||||
|
$dateTime = $value->format('Y-m-d\TH:i:s\Z'); |
||||||
|
$values[$key] = $dateTime; |
||||||
|
} |
||||||
|
if (is_array($value)){ |
||||||
|
if (!$classDetails->isInlineArray){ |
||||||
|
$subKey = $classDetails->arrayEntryname; |
||||||
|
$subArray = [$subKey => $value]; |
||||||
|
$values[$key] = $subArray; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
if (get_parent_class() == ""){ |
||||||
|
return $values; |
||||||
|
} |
||||||
|
else{ |
||||||
|
return array_merge(parent::jsonSerialize(), $values); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
@ -0,0 +1,130 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace net\authorize\api\contract\v1; |
||||||
|
|
||||||
|
/** |
||||||
|
* Class representing ARBGetSubscriptionListRequest |
||||||
|
*/ |
||||||
|
class ARBGetSubscriptionListRequest extends ANetApiRequestType |
||||||
|
{ |
||||||
|
|
||||||
|
/** |
||||||
|
* @property string $searchType |
||||||
|
*/ |
||||||
|
private $searchType = null; |
||||||
|
|
||||||
|
/** |
||||||
|
* @property \net\authorize\api\contract\v1\ARBGetSubscriptionListSortingType |
||||||
|
* $sorting |
||||||
|
*/ |
||||||
|
private $sorting = null; |
||||||
|
|
||||||
|
/** |
||||||
|
* @property \net\authorize\api\contract\v1\PagingType $paging |
||||||
|
*/ |
||||||
|
private $paging = null; |
||||||
|
|
||||||
|
/** |
||||||
|
* Gets as searchType |
||||||
|
* |
||||||
|
* @return string |
||||||
|
*/ |
||||||
|
public function getSearchType() |
||||||
|
{ |
||||||
|
return $this->searchType; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Sets a new searchType |
||||||
|
* |
||||||
|
* @param string $searchType |
||||||
|
* @return self |
||||||
|
*/ |
||||||
|
public function setSearchType($searchType) |
||||||
|
{ |
||||||
|
$this->searchType = $searchType; |
||||||
|
return $this; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Gets as sorting |
||||||
|
* |
||||||
|
* @return \net\authorize\api\contract\v1\ARBGetSubscriptionListSortingType |
||||||
|
*/ |
||||||
|
public function getSorting() |
||||||
|
{ |
||||||
|
return $this->sorting; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Sets a new sorting |
||||||
|
* |
||||||
|
* @param \net\authorize\api\contract\v1\ARBGetSubscriptionListSortingType $sorting |
||||||
|
* @return self |
||||||
|
*/ |
||||||
|
public function setSorting(\net\authorize\api\contract\v1\ARBGetSubscriptionListSortingType $sorting) |
||||||
|
{ |
||||||
|
$this->sorting = $sorting; |
||||||
|
return $this; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Gets as paging |
||||||
|
* |
||||||
|
* @return \net\authorize\api\contract\v1\PagingType |
||||||
|
*/ |
||||||
|
public function getPaging() |
||||||
|
{ |
||||||
|
return $this->paging; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Sets a new paging |
||||||
|
* |
||||||
|
* @param \net\authorize\api\contract\v1\PagingType $paging |
||||||
|
* @return self |
||||||
|
*/ |
||||||
|
public function setPaging(\net\authorize\api\contract\v1\PagingType $paging) |
||||||
|
{ |
||||||
|
$this->paging = $paging; |
||||||
|
return $this; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
// Json Serialize Code |
||||||
|
public function jsonSerialize(){ |
||||||
|
$values = array_filter((array)get_object_vars($this), |
||||||
|
function ($val){ |
||||||
|
return !is_null($val); |
||||||
|
}); |
||||||
|
$mapper = \net\authorize\util\Mapper::Instance(); |
||||||
|
foreach($values as $key => $value){ |
||||||
|
$classDetails = $mapper->getClass(get_class() , $key); |
||||||
|
if (isset($value)){ |
||||||
|
if ($classDetails->className === 'Date'){ |
||||||
|
$dateTime = $value->format('Y-m-d'); |
||||||
|
$values[$key] = $dateTime; |
||||||
|
} |
||||||
|
else if ($classDetails->className === 'DateTime'){ |
||||||
|
$dateTime = $value->format('Y-m-d\TH:i:s\Z'); |
||||||
|
$values[$key] = $dateTime; |
||||||
|
} |
||||||
|
if (is_array($value)){ |
||||||
|
if (!$classDetails->isInlineArray){ |
||||||
|
$subKey = $classDetails->arrayEntryname; |
||||||
|
$subArray = [$subKey => $value]; |
||||||
|
$values[$key] = $subArray; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
if (get_parent_class() == ""){ |
||||||
|
return $values; |
||||||
|
} |
||||||
|
else{ |
||||||
|
return array_merge(parent::jsonSerialize(), $values); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
@ -0,0 +1,102 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace net\authorize\api\contract\v1; |
||||||
|
|
||||||
|
/** |
||||||
|
* Class representing ARBGetSubscriptionRequest |
||||||
|
*/ |
||||||
|
class ARBGetSubscriptionRequest extends ANetApiRequestType |
||||||
|
{ |
||||||
|
|
||||||
|
/** |
||||||
|
* @property string $subscriptionId |
||||||
|
*/ |
||||||
|
private $subscriptionId = null; |
||||||
|
|
||||||
|
/** |
||||||
|
* @property boolean $includeTransactions |
||||||
|
*/ |
||||||
|
private $includeTransactions = null; |
||||||
|
|
||||||
|
/** |
||||||
|
* Gets as subscriptionId |
||||||
|
* |
||||||
|
* @return string |
||||||
|
*/ |
||||||
|
public function getSubscriptionId() |
||||||
|
{ |
||||||
|
return $this->subscriptionId; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Sets a new subscriptionId |
||||||
|
* |
||||||
|
* @param string $subscriptionId |
||||||
|
* @return self |
||||||
|
*/ |
||||||
|
public function setSubscriptionId($subscriptionId) |
||||||
|
{ |
||||||
|
$this->subscriptionId = $subscriptionId; |
||||||
|
return $this; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Gets as includeTransactions |
||||||
|
* |
||||||
|
* @return boolean |
||||||
|
*/ |
||||||
|
public function getIncludeTransactions() |
||||||
|
{ |
||||||
|
return $this->includeTransactions; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Sets a new includeTransactions |
||||||
|
* |
||||||
|
* @param boolean $includeTransactions |
||||||
|
* @return self |
||||||
|
*/ |
||||||
|
public function setIncludeTransactions($includeTransactions) |
||||||
|
{ |
||||||
|
$this->includeTransactions = $includeTransactions; |
||||||
|
return $this; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
// Json Serialize Code |
||||||
|
public function jsonSerialize(){ |
||||||
|
$values = array_filter((array)get_object_vars($this), |
||||||
|
function ($val){ |
||||||
|
return !is_null($val); |
||||||
|
}); |
||||||
|
$mapper = \net\authorize\util\Mapper::Instance(); |
||||||
|
foreach($values as $key => $value){ |
||||||
|
$classDetails = $mapper->getClass(get_class() , $key); |
||||||
|
if (isset($value)){ |
||||||
|
if ($classDetails->className === 'Date'){ |
||||||
|
$dateTime = $value->format('Y-m-d'); |
||||||
|
$values[$key] = $dateTime; |
||||||
|
} |
||||||
|
else if ($classDetails->className === 'DateTime'){ |
||||||
|
$dateTime = $value->format('Y-m-d\TH:i:s\Z'); |
||||||
|
$values[$key] = $dateTime; |
||||||
|
} |
||||||
|
if (is_array($value)){ |
||||||
|
if (!$classDetails->isInlineArray){ |
||||||
|
$subKey = $classDetails->arrayEntryname; |
||||||
|
$subArray = [$subKey => $value]; |
||||||
|
$values[$key] = $subArray; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
if (get_parent_class() == ""){ |
||||||
|
return $values; |
||||||
|
} |
||||||
|
else{ |
||||||
|
return array_merge(parent::jsonSerialize(), $values); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
@ -0,0 +1,75 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace net\authorize\api\contract\v1; |
||||||
|
|
||||||
|
/** |
||||||
|
* Class representing ARBGetSubscriptionStatusRequest |
||||||
|
*/ |
||||||
|
class ARBGetSubscriptionStatusRequest extends ANetApiRequestType |
||||||
|
{ |
||||||
|
|
||||||
|
/** |
||||||
|
* @property string $subscriptionId |
||||||
|
*/ |
||||||
|
private $subscriptionId = null; |
||||||
|
|
||||||
|
/** |
||||||
|
* Gets as subscriptionId |
||||||
|
* |
||||||
|
* @return string |
||||||
|
*/ |
||||||
|
public function getSubscriptionId() |
||||||
|
{ |
||||||
|
return $this->subscriptionId; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Sets a new subscriptionId |
||||||
|
* |
||||||
|
* @param string $subscriptionId |
||||||
|
* @return self |
||||||
|
*/ |
||||||
|
public function setSubscriptionId($subscriptionId) |
||||||
|
{ |
||||||
|
$this->subscriptionId = $subscriptionId; |
||||||
|
return $this; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
// Json Serialize Code |
||||||
|
public function jsonSerialize(){ |
||||||
|
$values = array_filter((array)get_object_vars($this), |
||||||
|
function ($val){ |
||||||
|
return !is_null($val); |
||||||
|
}); |
||||||
|
$mapper = \net\authorize\util\Mapper::Instance(); |
||||||
|
foreach($values as $key => $value){ |
||||||
|
$classDetails = $mapper->getClass(get_class() , $key); |
||||||
|
if (isset($value)){ |
||||||
|
if ($classDetails->className === 'Date'){ |
||||||
|
$dateTime = $value->format('Y-m-d'); |
||||||
|
$values[$key] = $dateTime; |
||||||
|
} |
||||||
|
else if ($classDetails->className === 'DateTime'){ |
||||||
|
$dateTime = $value->format('Y-m-d\TH:i:s\Z'); |
||||||
|
$values[$key] = $dateTime; |
||||||
|
} |
||||||
|
if (is_array($value)){ |
||||||
|
if (!$classDetails->isInlineArray){ |
||||||
|
$subKey = $classDetails->arrayEntryname; |
||||||
|
$subArray = [$subKey => $value]; |
||||||
|
$values[$key] = $subArray; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
if (get_parent_class() == ""){ |
||||||
|
return $values; |
||||||
|
} |
||||||
|
else{ |
||||||
|
return array_merge(parent::jsonSerialize(), $values); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
@ -0,0 +1,102 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace net\authorize\api\contract\v1; |
||||||
|
|
||||||
|
/** |
||||||
|
* Class representing ARBUpdateSubscriptionRequest |
||||||
|
*/ |
||||||
|
class ARBUpdateSubscriptionRequest extends ANetApiRequestType |
||||||
|
{ |
||||||
|
|
||||||
|
/** |
||||||
|
* @property string $subscriptionId |
||||||
|
*/ |
||||||
|
private $subscriptionId = null; |
||||||
|
|
||||||
|
/** |
||||||
|
* @property \net\authorize\api\contract\v1\ARBSubscriptionType $subscription |
||||||
|
*/ |
||||||
|
private $subscription = null; |
||||||
|
|
||||||
|
/** |
||||||
|
* Gets as subscriptionId |
||||||
|
* |
||||||
|
* @return string |
||||||
|
*/ |
||||||
|
public function getSubscriptionId() |
||||||
|
{ |
||||||
|
return $this->subscriptionId; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Sets a new subscriptionId |
||||||
|
* |
||||||
|
* @param string $subscriptionId |
||||||
|
* @return self |
||||||
|
*/ |
||||||
|
public function setSubscriptionId($subscriptionId) |
||||||
|
{ |
||||||
|
$this->subscriptionId = $subscriptionId; |
||||||
|
return $this; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Gets as subscription |
||||||
|
* |
||||||
|
* @return \net\authorize\api\contract\v1\ARBSubscriptionType |
||||||
|
*/ |
||||||
|
public function getSubscription() |
||||||
|
{ |
||||||
|
return $this->subscription; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Sets a new subscription |
||||||
|
* |
||||||
|
* @param \net\authorize\api\contract\v1\ARBSubscriptionType $subscription |
||||||
|
* @return self |
||||||
|
*/ |
||||||
|
public function setSubscription(\net\authorize\api\contract\v1\ARBSubscriptionType $subscription) |
||||||
|
{ |
||||||
|
$this->subscription = $subscription; |
||||||
|
return $this; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
// Json Serialize Code |
||||||
|
public function jsonSerialize(){ |
||||||
|
$values = array_filter((array)get_object_vars($this), |
||||||
|
function ($val){ |
||||||
|
return !is_null($val); |
||||||
|
}); |
||||||
|
$mapper = \net\authorize\util\Mapper::Instance(); |
||||||
|
foreach($values as $key => $value){ |
||||||
|
$classDetails = $mapper->getClass(get_class() , $key); |
||||||
|
if (isset($value)){ |
||||||
|
if ($classDetails->className === 'Date'){ |
||||||
|
$dateTime = $value->format('Y-m-d'); |
||||||
|
$values[$key] = $dateTime; |
||||||
|
} |
||||||
|
else if ($classDetails->className === 'DateTime'){ |
||||||
|
$dateTime = $value->format('Y-m-d\TH:i:s\Z'); |
||||||
|
$values[$key] = $dateTime; |
||||||
|
} |
||||||
|
if (is_array($value)){ |
||||||
|
if (!$classDetails->isInlineArray){ |
||||||
|
$subKey = $classDetails->arrayEntryname; |
||||||
|
$subArray = [$subKey => $value]; |
||||||
|
$values[$key] = $subArray; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
if (get_parent_class() == ""){ |
||||||
|
return $values; |
||||||
|
} |
||||||
|
else{ |
||||||
|
return array_merge(parent::jsonSerialize(), $values); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
@ -0,0 +1,48 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace net\authorize\api\contract\v1; |
||||||
|
|
||||||
|
/** |
||||||
|
* Class representing AuthenticateTestRequest |
||||||
|
*/ |
||||||
|
class AuthenticateTestRequest extends ANetApiRequestType |
||||||
|
{ |
||||||
|
|
||||||
|
|
||||||
|
// Json Serialize Code |
||||||
|
public function jsonSerialize(){ |
||||||
|
$values = array_filter((array)get_object_vars($this), |
||||||
|
function ($val){ |
||||||
|
return !is_null($val); |
||||||
|
}); |
||||||
|
$mapper = \net\authorize\util\Mapper::Instance(); |
||||||
|
foreach($values as $key => $value){ |
||||||
|
$classDetails = $mapper->getClass(get_class() , $key); |
||||||
|
if (isset($value)){ |
||||||
|
if ($classDetails->className === 'Date'){ |
||||||
|
$dateTime = $value->format('Y-m-d'); |
||||||
|
$values[$key] = $dateTime; |
||||||
|
} |
||||||
|
else if ($classDetails->className === 'DateTime'){ |
||||||
|
$dateTime = $value->format('Y-m-d\TH:i:s\Z'); |
||||||
|
$values[$key] = $dateTime; |
||||||
|
} |
||||||
|
if (is_array($value)){ |
||||||
|
if (!$classDetails->isInlineArray){ |
||||||
|
$subKey = $classDetails->arrayEntryname; |
||||||
|
$subArray = [$subKey => $value]; |
||||||
|
$values[$key] = $subArray; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
if (get_parent_class() == ""){ |
||||||
|
return $values; |
||||||
|
} |
||||||
|
else{ |
||||||
|
return array_merge(parent::jsonSerialize(), $values); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
@ -0,0 +1,130 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace net\authorize\api\contract\v1; |
||||||
|
|
||||||
|
/** |
||||||
|
* Class representing CreateCustomerPaymentProfileRequest |
||||||
|
*/ |
||||||
|
class CreateCustomerPaymentProfileRequest extends ANetApiRequestType |
||||||
|
{ |
||||||
|
|
||||||
|
/** |
||||||
|
* @property string $customerProfileId |
||||||
|
*/ |
||||||
|
private $customerProfileId = null; |
||||||
|
|
||||||
|
/** |
||||||
|
* @property \net\authorize\api\contract\v1\CustomerPaymentProfileType |
||||||
|
* $paymentProfile |
||||||
|
*/ |
||||||
|
private $paymentProfile = null; |
||||||
|
|
||||||
|
/** |
||||||
|
* @property string $validationMode |
||||||
|
*/ |
||||||
|
private $validationMode = null; |
||||||
|
|
||||||
|
/** |
||||||
|
* Gets as customerProfileId |
||||||
|
* |
||||||
|
* @return string |
||||||
|
*/ |
||||||
|
public function getCustomerProfileId() |
||||||
|
{ |
||||||
|
return $this->customerProfileId; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Sets a new customerProfileId |
||||||
|
* |
||||||
|
* @param string $customerProfileId |
||||||
|
* @return self |
||||||
|
*/ |
||||||
|
public function setCustomerProfileId($customerProfileId) |
||||||
|
{ |
||||||
|
$this->customerProfileId = $customerProfileId; |
||||||
|
return $this; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Gets as paymentProfile |
||||||
|
* |
||||||
|
* @return \net\authorize\api\contract\v1\CustomerPaymentProfileType |
||||||
|
*/ |
||||||
|
public function getPaymentProfile() |
||||||
|
{ |
||||||
|
return $this->paymentProfile; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Sets a new paymentProfile |
||||||
|
* |
||||||
|
* @param \net\authorize\api\contract\v1\CustomerPaymentProfileType $paymentProfile |
||||||
|
* @return self |
||||||
|
*/ |
||||||
|
public function setPaymentProfile(\net\authorize\api\contract\v1\CustomerPaymentProfileType $paymentProfile) |
||||||
|
{ |
||||||
|
$this->paymentProfile = $paymentProfile; |
||||||
|
return $this; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Gets as validationMode |
||||||
|
* |
||||||
|
* @return string |
||||||
|
*/ |
||||||
|
public function getValidationMode() |
||||||
|
{ |
||||||
|
return $this->validationMode; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Sets a new validationMode |
||||||
|
* |
||||||
|
* @param string $validationMode |
||||||
|
* @return self |
||||||
|
*/ |
||||||
|
public function setValidationMode($validationMode) |
||||||
|
{ |
||||||
|
$this->validationMode = $validationMode; |
||||||
|
return $this; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
// Json Serialize Code |
||||||
|
public function jsonSerialize(){ |
||||||
|
$values = array_filter((array)get_object_vars($this), |
||||||
|
function ($val){ |
||||||
|
return !is_null($val); |
||||||
|
}); |
||||||
|
$mapper = \net\authorize\util\Mapper::Instance(); |
||||||
|
foreach($values as $key => $value){ |
||||||
|
$classDetails = $mapper->getClass(get_class() , $key); |
||||||
|
if (isset($value)){ |
||||||
|
if ($classDetails->className === 'Date'){ |
||||||
|
$dateTime = $value->format('Y-m-d'); |
||||||
|
$values[$key] = $dateTime; |
||||||
|
} |
||||||
|
else if ($classDetails->className === 'DateTime'){ |
||||||
|
$dateTime = $value->format('Y-m-d\TH:i:s\Z'); |
||||||
|
$values[$key] = $dateTime; |
||||||
|
} |
||||||
|
if (is_array($value)){ |
||||||
|
if (!$classDetails->isInlineArray){ |
||||||
|
$subKey = $classDetails->arrayEntryname; |
||||||
|
$subArray = [$subKey => $value]; |
||||||
|
$values[$key] = $subArray; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
if (get_parent_class() == ""){ |
||||||
|
return $values; |
||||||
|
} |
||||||
|
else{ |
||||||
|
return array_merge(parent::jsonSerialize(), $values); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
@ -0,0 +1,210 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace net\authorize\api\contract\v1; |
||||||
|
|
||||||
|
/** |
||||||
|
* Class representing CreateCustomerProfileFromTransactionRequest |
||||||
|
*/ |
||||||
|
class CreateCustomerProfileFromTransactionRequest extends ANetApiRequestType |
||||||
|
{ |
||||||
|
|
||||||
|
/** |
||||||
|
* @property string $transId |
||||||
|
*/ |
||||||
|
private $transId = null; |
||||||
|
|
||||||
|
/** |
||||||
|
* @property \net\authorize\api\contract\v1\CustomerProfileBaseType $customer |
||||||
|
*/ |
||||||
|
private $customer = null; |
||||||
|
|
||||||
|
/** |
||||||
|
* @property string $customerProfileId |
||||||
|
*/ |
||||||
|
private $customerProfileId = null; |
||||||
|
|
||||||
|
/** |
||||||
|
* @property boolean $defaultPaymentProfile |
||||||
|
*/ |
||||||
|
private $defaultPaymentProfile = null; |
||||||
|
|
||||||
|
/** |
||||||
|
* @property boolean $defaultShippingAddress |
||||||
|
*/ |
||||||
|
private $defaultShippingAddress = null; |
||||||
|
|
||||||
|
/** |
||||||
|
* @property string $profileType |
||||||
|
*/ |
||||||
|
private $profileType = null; |
||||||
|
|
||||||
|
/** |
||||||
|
* Gets as transId |
||||||
|
* |
||||||
|
* @return string |
||||||
|
*/ |
||||||
|
public function getTransId() |
||||||
|
{ |
||||||
|
return $this->transId; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Sets a new transId |
||||||
|
* |
||||||
|
* @param string $transId |
||||||
|
* @return self |
||||||
|
*/ |
||||||
|
public function setTransId($transId) |
||||||
|
{ |
||||||
|
$this->transId = $transId; |
||||||
|
return $this; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Gets as customer |
||||||
|
* |
||||||
|
* @return \net\authorize\api\contract\v1\CustomerProfileBaseType |
||||||
|
*/ |
||||||
|
public function getCustomer() |
||||||
|
{ |
||||||
|
return $this->customer; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Sets a new customer |
||||||
|
* |
||||||
|
* @param \net\authorize\api\contract\v1\CustomerProfileBaseType $customer |
||||||
|
* @return self |
||||||
|
*/ |
||||||
|
public function setCustomer(\net\authorize\api\contract\v1\CustomerProfileBaseType $customer) |
||||||
|
{ |
||||||
|
$this->customer = $customer; |
||||||
|
return $this; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Gets as customerProfileId |
||||||
|
* |
||||||
|
* @return string |
||||||
|
*/ |
||||||
|
public function getCustomerProfileId() |
||||||
|
{ |
||||||
|
return $this->customerProfileId; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Sets a new customerProfileId |
||||||
|
* |
||||||
|
* @param string $customerProfileId |
||||||
|
* @return self |
||||||
|
*/ |
||||||
|
public function setCustomerProfileId($customerProfileId) |
||||||
|
{ |
||||||
|
$this->customerProfileId = $customerProfileId; |
||||||
|
return $this; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Gets as defaultPaymentProfile |
||||||
|
* |
||||||
|
* @return boolean |
||||||
|
*/ |
||||||
|
public function getDefaultPaymentProfile() |
||||||
|
{ |
||||||
|
return $this->defaultPaymentProfile; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Sets a new defaultPaymentProfile |
||||||
|
* |
||||||
|
* @param boolean $defaultPaymentProfile |
||||||
|
* @return self |
||||||
|
*/ |
||||||
|
public function setDefaultPaymentProfile($defaultPaymentProfile) |
||||||
|
{ |
||||||
|
$this->defaultPaymentProfile = $defaultPaymentProfile; |
||||||
|
return $this; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Gets as defaultShippingAddress |
||||||
|
* |
||||||
|
* @return boolean |
||||||
|
*/ |
||||||
|
public function getDefaultShippingAddress() |
||||||
|
{ |
||||||
|
return $this->defaultShippingAddress; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Sets a new defaultShippingAddress |
||||||
|
* |
||||||
|
* @param boolean $defaultShippingAddress |
||||||
|
* @return self |
||||||
|
*/ |
||||||
|
public function setDefaultShippingAddress($defaultShippingAddress) |
||||||
|
{ |
||||||
|
$this->defaultShippingAddress = $defaultShippingAddress; |
||||||
|
return $this; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Gets as profileType |
||||||
|
* |
||||||
|
* @return string |
||||||
|
*/ |
||||||
|
public function getProfileType() |
||||||
|
{ |
||||||
|
return $this->profileType; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Sets a new profileType |
||||||
|
* |
||||||
|
* @param string $profileType |
||||||
|
* @return self |
||||||
|
*/ |
||||||
|
public function setProfileType($profileType) |
||||||
|
{ |
||||||
|
$this->profileType = $profileType; |
||||||
|
return $this; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
// Json Serialize Code |
||||||
|
public function jsonSerialize(){ |
||||||
|
$values = array_filter((array)get_object_vars($this), |
||||||
|
function ($val){ |
||||||
|
return !is_null($val); |
||||||
|
}); |
||||||
|
$mapper = \net\authorize\util\Mapper::Instance(); |
||||||
|
foreach($values as $key => $value){ |
||||||
|
$classDetails = $mapper->getClass(get_class() , $key); |
||||||
|
if (isset($value)){ |
||||||
|
if ($classDetails->className === 'Date'){ |
||||||
|
$dateTime = $value->format('Y-m-d'); |
||||||
|
$values[$key] = $dateTime; |
||||||
|
} |
||||||
|
else if ($classDetails->className === 'DateTime'){ |
||||||
|
$dateTime = $value->format('Y-m-d\TH:i:s\Z'); |
||||||
|
$values[$key] = $dateTime; |
||||||
|
} |
||||||
|
if (is_array($value)){ |
||||||
|
if (!$classDetails->isInlineArray){ |
||||||
|
$subKey = $classDetails->arrayEntryname; |
||||||
|
$subArray = [$subKey => $value]; |
||||||
|
$values[$key] = $subArray; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
if (get_parent_class() == ""){ |
||||||
|
return $values; |
||||||
|
} |
||||||
|
else{ |
||||||
|
return array_merge(parent::jsonSerialize(), $values); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
@ -0,0 +1,102 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace net\authorize\api\contract\v1; |
||||||
|
|
||||||
|
/** |
||||||
|
* Class representing CreateCustomerProfileRequest |
||||||
|
*/ |
||||||
|
class CreateCustomerProfileRequest extends ANetApiRequestType |
||||||
|
{ |
||||||
|
|
||||||
|
/** |
||||||
|
* @property \net\authorize\api\contract\v1\CustomerProfileType $profile |
||||||
|
*/ |
||||||
|
private $profile = null; |
||||||
|
|
||||||
|
/** |
||||||
|
* @property string $validationMode |
||||||
|
*/ |
||||||
|
private $validationMode = null; |
||||||
|
|
||||||
|
/** |
||||||
|
* Gets as profile |
||||||
|
* |
||||||
|
* @return \net\authorize\api\contract\v1\CustomerProfileType |
||||||
|
*/ |
||||||
|
public function getProfile() |
||||||
|
{ |
||||||
|
return $this->profile; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Sets a new profile |
||||||
|
* |
||||||
|
* @param \net\authorize\api\contract\v1\CustomerProfileType $profile |
||||||
|
* @return self |
||||||
|
*/ |
||||||
|
public function setProfile(\net\authorize\api\contract\v1\CustomerProfileType $profile) |
||||||
|
{ |
||||||
|
$this->profile = $profile; |
||||||
|
return $this; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Gets as validationMode |
||||||
|
* |
||||||
|
* @return string |
||||||
|
*/ |
||||||
|
public function getValidationMode() |
||||||
|
{ |
||||||
|
return $this->validationMode; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Sets a new validationMode |
||||||
|
* |
||||||
|
* @param string $validationMode |
||||||
|
* @return self |
||||||
|
*/ |
||||||
|
public function setValidationMode($validationMode) |
||||||
|
{ |
||||||
|
$this->validationMode = $validationMode; |
||||||
|
return $this; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
// Json Serialize Code |
||||||
|
public function jsonSerialize(){ |
||||||
|
$values = array_filter((array)get_object_vars($this), |
||||||
|
function ($val){ |
||||||
|
return !is_null($val); |
||||||
|
}); |
||||||
|
$mapper = \net\authorize\util\Mapper::Instance(); |
||||||
|
foreach($values as $key => $value){ |
||||||
|
$classDetails = $mapper->getClass(get_class() , $key); |
||||||
|
if (isset($value)){ |
||||||
|
if ($classDetails->className === 'Date'){ |
||||||
|
$dateTime = $value->format('Y-m-d'); |
||||||
|
$values[$key] = $dateTime; |
||||||
|
} |
||||||
|
else if ($classDetails->className === 'DateTime'){ |
||||||
|
$dateTime = $value->format('Y-m-d\TH:i:s\Z'); |
||||||
|
$values[$key] = $dateTime; |
||||||
|
} |
||||||
|
if (is_array($value)){ |
||||||
|
if (!$classDetails->isInlineArray){ |
||||||
|
$subKey = $classDetails->arrayEntryname; |
||||||
|
$subArray = [$subKey => $value]; |
||||||
|
$values[$key] = $subArray; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
if (get_parent_class() == ""){ |
||||||
|
return $values; |
||||||
|
} |
||||||
|
else{ |
||||||
|
return array_merge(parent::jsonSerialize(), $values); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
@ -0,0 +1,102 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace net\authorize\api\contract\v1; |
||||||
|
|
||||||
|
/** |
||||||
|
* Class representing CreateCustomerProfileTransactionRequest |
||||||
|
*/ |
||||||
|
class CreateCustomerProfileTransactionRequest extends ANetApiRequestType |
||||||
|
{ |
||||||
|
|
||||||
|
/** |
||||||
|
* @property \net\authorize\api\contract\v1\ProfileTransactionType $transaction |
||||||
|
*/ |
||||||
|
private $transaction = null; |
||||||
|
|
||||||
|
/** |
||||||
|
* @property string $extraOptions |
||||||
|
*/ |
||||||
|
private $extraOptions = null; |
||||||
|
|
||||||
|
/** |
||||||
|
* Gets as transaction |
||||||
|
* |
||||||
|
* @return \net\authorize\api\contract\v1\ProfileTransactionType |
||||||
|
*/ |
||||||
|
public function getTransaction() |
||||||
|
{ |
||||||
|
return $this->transaction; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Sets a new transaction |
||||||
|
* |
||||||
|
* @param \net\authorize\api\contract\v1\ProfileTransactionType $transaction |
||||||
|
* @return self |
||||||
|
*/ |
||||||
|
public function setTransaction(\net\authorize\api\contract\v1\ProfileTransactionType $transaction) |
||||||
|
{ |
||||||
|
$this->transaction = $transaction; |
||||||
|
return $this; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Gets as extraOptions |
||||||
|
* |
||||||
|
* @return string |
||||||
|
*/ |
||||||
|
public function getExtraOptions() |
||||||
|
{ |
||||||
|
return $this->extraOptions; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Sets a new extraOptions |
||||||
|
* |
||||||
|
* @param string $extraOptions |
||||||
|
* @return self |
||||||
|
*/ |
||||||
|
public function setExtraOptions($extraOptions) |
||||||
|
{ |
||||||
|
$this->extraOptions = $extraOptions; |
||||||
|
return $this; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
// Json Serialize Code |
||||||
|
public function jsonSerialize(){ |
||||||
|
$values = array_filter((array)get_object_vars($this), |
||||||
|
function ($val){ |
||||||
|
return !is_null($val); |
||||||
|
}); |
||||||
|
$mapper = \net\authorize\util\Mapper::Instance(); |
||||||
|
foreach($values as $key => $value){ |
||||||
|
$classDetails = $mapper->getClass(get_class() , $key); |
||||||
|
if (isset($value)){ |
||||||
|
if ($classDetails->className === 'Date'){ |
||||||
|
$dateTime = $value->format('Y-m-d'); |
||||||
|
$values[$key] = $dateTime; |
||||||
|
} |
||||||
|
else if ($classDetails->className === 'DateTime'){ |
||||||
|
$dateTime = $value->format('Y-m-d\TH:i:s\Z'); |
||||||
|
$values[$key] = $dateTime; |
||||||
|
} |
||||||
|
if (is_array($value)){ |
||||||
|
if (!$classDetails->isInlineArray){ |
||||||
|
$subKey = $classDetails->arrayEntryname; |
||||||
|
$subArray = [$subKey => $value]; |
||||||
|
$values[$key] = $subArray; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
if (get_parent_class() == ""){ |
||||||
|
return $values; |
||||||
|
} |
||||||
|
else{ |
||||||
|
return array_merge(parent::jsonSerialize(), $values); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
@ -0,0 +1,129 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace net\authorize\api\contract\v1; |
||||||
|
|
||||||
|
/** |
||||||
|
* Class representing CreateCustomerShippingAddressRequest |
||||||
|
*/ |
||||||
|
class CreateCustomerShippingAddressRequest extends ANetApiRequestType |
||||||
|
{ |
||||||
|
|
||||||
|
/** |
||||||
|
* @property string $customerProfileId |
||||||
|
*/ |
||||||
|
private $customerProfileId = null; |
||||||
|
|
||||||
|
/** |
||||||
|
* @property \net\authorize\api\contract\v1\CustomerAddressType $address |
||||||
|
*/ |
||||||
|
private $address = null; |
||||||
|
|
||||||
|
/** |
||||||
|
* @property boolean $defaultShippingAddress |
||||||
|
*/ |
||||||
|
private $defaultShippingAddress = null; |
||||||
|
|
||||||
|
/** |
||||||
|
* Gets as customerProfileId |
||||||
|
* |
||||||
|
* @return string |
||||||
|
*/ |
||||||
|
public function getCustomerProfileId() |
||||||
|
{ |
||||||
|
return $this->customerProfileId; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Sets a new customerProfileId |
||||||
|
* |
||||||
|
* @param string $customerProfileId |
||||||
|
* @return self |
||||||
|
*/ |
||||||
|
public function setCustomerProfileId($customerProfileId) |
||||||
|
{ |
||||||
|
$this->customerProfileId = $customerProfileId; |
||||||
|
return $this; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Gets as address |
||||||
|
* |
||||||
|
* @return \net\authorize\api\contract\v1\CustomerAddressType |
||||||
|
*/ |
||||||
|
public function getAddress() |
||||||
|
{ |
||||||
|
return $this->address; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Sets a new address |
||||||
|
* |
||||||
|
* @param \net\authorize\api\contract\v1\CustomerAddressType $address |
||||||
|
* @return self |
||||||
|
*/ |
||||||
|
public function setAddress(\net\authorize\api\contract\v1\CustomerAddressType $address) |
||||||
|
{ |
||||||
|
$this->address = $address; |
||||||
|
return $this; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Gets as defaultShippingAddress |
||||||
|
* |
||||||
|
* @return boolean |
||||||
|
*/ |
||||||
|
public function getDefaultShippingAddress() |
||||||
|
{ |
||||||
|
return $this->defaultShippingAddress; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Sets a new defaultShippingAddress |
||||||
|
* |
||||||
|
* @param boolean $defaultShippingAddress |
||||||
|
* @return self |
||||||
|
*/ |
||||||
|
public function setDefaultShippingAddress($defaultShippingAddress) |
||||||
|
{ |
||||||
|
$this->defaultShippingAddress = $defaultShippingAddress; |
||||||
|
return $this; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
// Json Serialize Code |
||||||
|
public function jsonSerialize(){ |
||||||
|
$values = array_filter((array)get_object_vars($this), |
||||||
|
function ($val){ |
||||||
|
return !is_null($val); |
||||||
|
}); |
||||||
|
$mapper = \net\authorize\util\Mapper::Instance(); |
||||||
|
foreach($values as $key => $value){ |
||||||
|
$classDetails = $mapper->getClass(get_class() , $key); |
||||||
|
if (isset($value)){ |
||||||
|
if ($classDetails->className === 'Date'){ |
||||||
|
$dateTime = $value->format('Y-m-d'); |
||||||
|
$values[$key] = $dateTime; |
||||||
|
} |
||||||
|
else if ($classDetails->className === 'DateTime'){ |
||||||
|
$dateTime = $value->format('Y-m-d\TH:i:s\Z'); |
||||||
|
$values[$key] = $dateTime; |
||||||
|
} |
||||||
|
if (is_array($value)){ |
||||||
|
if (!$classDetails->isInlineArray){ |
||||||
|
$subKey = $classDetails->arrayEntryname; |
||||||
|
$subArray = [$subKey => $value]; |
||||||
|
$values[$key] = $subArray; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
if (get_parent_class() == ""){ |
||||||
|
return $values; |
||||||
|
} |
||||||
|
else{ |
||||||
|
return array_merge(parent::jsonSerialize(), $values); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
@ -0,0 +1,76 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace net\authorize\api\contract\v1; |
||||||
|
|
||||||
|
/** |
||||||
|
* Class representing CreateTransactionRequest |
||||||
|
*/ |
||||||
|
class CreateTransactionRequest extends ANetApiRequestType |
||||||
|
{ |
||||||
|
|
||||||
|
/** |
||||||
|
* @property \net\authorize\api\contract\v1\TransactionRequestType |
||||||
|
* $transactionRequest |
||||||
|
*/ |
||||||
|
private $transactionRequest = null; |
||||||
|
|
||||||
|
/** |
||||||
|
* Gets as transactionRequest |
||||||
|
* |
||||||
|
* @return \net\authorize\api\contract\v1\TransactionRequestType |
||||||
|
*/ |
||||||
|
public function getTransactionRequest() |
||||||
|
{ |
||||||
|
return $this->transactionRequest; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Sets a new transactionRequest |
||||||
|
* |
||||||
|
* @param \net\authorize\api\contract\v1\TransactionRequestType $transactionRequest |
||||||
|
* @return self |
||||||
|
*/ |
||||||
|
public function setTransactionRequest(\net\authorize\api\contract\v1\TransactionRequestType $transactionRequest) |
||||||
|
{ |
||||||
|
$this->transactionRequest = $transactionRequest; |
||||||
|
return $this; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
// Json Serialize Code |
||||||
|
public function jsonSerialize(){ |
||||||
|
$values = array_filter((array)get_object_vars($this), |
||||||
|
function ($val){ |
||||||
|
return !is_null($val); |
||||||
|
}); |
||||||
|
$mapper = \net\authorize\util\Mapper::Instance(); |
||||||
|
foreach($values as $key => $value){ |
||||||
|
$classDetails = $mapper->getClass(get_class() , $key); |
||||||
|
if (isset($value)){ |
||||||
|
if ($classDetails->className === 'Date'){ |
||||||
|
$dateTime = $value->format('Y-m-d'); |
||||||
|
$values[$key] = $dateTime; |
||||||
|
} |
||||||
|
else if ($classDetails->className === 'DateTime'){ |
||||||
|
$dateTime = $value->format('Y-m-d\TH:i:s\Z'); |
||||||
|
$values[$key] = $dateTime; |
||||||
|
} |
||||||
|
if (is_array($value)){ |
||||||
|
if (!$classDetails->isInlineArray){ |
||||||
|
$subKey = $classDetails->arrayEntryname; |
||||||
|
$subArray = [$subKey => $value]; |
||||||
|
$values[$key] = $subArray; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
if (get_parent_class() == ""){ |
||||||
|
return $values; |
||||||
|
} |
||||||
|
else{ |
||||||
|
return array_merge(parent::jsonSerialize(), $values); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue