本文整理汇总了PHP中DbManager::i方法的典型用法代码示例。如果您正苦于以下问题:PHP DbManager::i方法的具体用法?PHP DbManager::i怎么用?PHP DbManager::i使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DbManager
的用法示例。
在下文中一共展示了DbManager::i方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPayments
public function getPayments()
{
$payments = DbManager::i()->select("sf_purchases", array("token", "payerid", "type", "cart", "date", "amount", "pending"), array("userid" => intval($_SESSION['userid'])));
if ($payments !== false) {
$purchases = array();
$pending = array();
if (!is_array($payments)) {
$payments = array($payments);
}
foreach ($payments as $payment) {
$payment->type = base64_decode($payment->type);
$payment->payerid = base64_decode($payment->payerid);
$payment->cart = (array) json_decode(base64_decode(base64_decode($payment->cart)));
if ($payment->pending == 1) {
array_push($pending, $payment);
} else {
array_push($purchases, $payment);
}
}
$ret = json_encode(array("payments" => $purchases, "pending" => $pending));
unset($purchases);
unset($pending);
unset($payments);
return $ret;
}
Logger::i()->writeLog("Could not get payments, error = " . DbManager::i()->error, 'dev');
return null;
}
示例2: writeLog
public function writeLog($message, $mode = 'all')
{
$time = date("F j, Y, g:i a");
$ip = $_SERVER['REMOTE_ADDR'];
$message = basename($_SERVER['SCRIPT_FILENAME']) . " [{$ip}] ({$time}) : " . $message;
$msg = base64_encode(base64_encode(Crypto::EncryptString(base64_decode(base64_decode(ADMIN_KEY)), base64_decode(base64_decode(ADMIN_IV)), $message)));
DbManager::i()->insert("sf_logs", array("message", "mode"), array($msg, $mode));
}
示例3: deleteCustomer
function deleteCustomer($c)
{
$delete = DbManager::i()->delete("sf_members", array("userid" => intval($c)));
if (!$delete) {
Logger::i()->writeLog("Deleting customer {$c} failed, error = " . DbManager::i()->error, 'dev');
return Submission::createResult("Could not delete customer");
}
return Submission::createResult("Customer deleted", true);
}
示例4: __construct
function __construct()
{
$settings = DbManager::i()->select("sf_settings", array("settings"));
if ($settings !== false && !is_array($settings)) {
$prefs = Crypto::DecryptString(base64_decode(base64_decode(ADMIN_KEY)), base64_decode(base64_decode(ADMIN_IV)), base64_decode(base64_decode($settings->settings)));
$prefs = (array) json_decode(base64_decode($prefs));
if (isset($prefs['cms_settings'])) {
$settings = (array) $prefs['cms_settings'];
if (isset($settings['title']) && strlen($settings['title']) > 0) {
$this->title = stripslashes(filter_var(htmlspecialchars($settings['title'])));
}
if (isset($settings['captcha_public']) && strlen($settings['captcha_public']) > 0) {
$this->captcha_public = stripslashes(filter_var(htmlspecialchars($settings['captcha_public'])));
}
if (isset($settings['captcha_secret']) && strlen($settings['captcha_private']) > 0) {
$this->captcha_private = stripslashes(filter_var(htmlspecialchars($settings['captcha_private'])));
}
}
if (isset($prefs['paypal'])) {
$settings = (array) $prefs['paypal'];
if (isset($settings['username']) && strlen($settings['username']) > 0) {
$this->paypal_email = stripslashes(filter_var(htmlspecialchars($settings['username'])));
}
if (isset($settings['password']) && strlen($settings['password']) > 0) {
$this->paypal_api_pass = stripslashes(filter_var(htmlspecialchars($settings['password'])));
}
if (isset($settings['signature']) && strlen($settings['signature']) > 0) {
$this->paypal_api_signature = stripslashes(filter_var(htmlspecialchars($settings['signature'])));
}
}
if (isset($prefs['btc'])) {
$settings = (array) $prefs['btc'];
if (isset($settings['api_key']) && strlen($settings['api_key']) > 0) {
$this->btc_api_key = stripslashes(filter_var(htmlspecialchars($settings['api_key'])));
}
if (isset($settings['api_pin']) && strlen($settings['api_pin']) > 0) {
$this->btc_api_pin = stripslashes(filter_var(htmlspecialchars($settings['api_pin'])));
}
}
unset($prefs);
}
}
示例5: array
if ($find !== false && !is_array($find)) {
//cart already exists for user
if ($find->cart != "e30=" && strlen($find->cart) != 4) {
//not empty cart - overwrite with saved one from DB
$_SESSION['shopping-cart'] = $find->cart;
} else {
//empty cart, use session cart
if (isset($_SESSION['shopping-cart'])) {
DbManager::i()->update("sf_carts", array("cart" => $_SESSION['shopping-cart']), array("userid" => intval($_SESSION['userid'])));
}
}
} else {
if (isset($_SESSION['shopping-cart'])) {
DbManager::i()->insert("sf_carts", array("cart", "userid"), array($_SESSION['shopping-cart'], intval($_SESSION['userid'])));
}
}
} else {
Logger::i()->writeLog("Login is incorrect (" . $login['username'] . ":" . $login['password'] . ")");
echo Submission::createResult("Username or Password are incorrect");
}
} else {
Logger::i()->writeLog("User does not exist: " . $login['username']);
echo Submission::createResult("No user found with this username");
}
} else {
Logger::i()->writeLog("Could not get check for login, error = " . DbManager::i()->error, 'dev');
echo Submission::createResult("Username or Password are incorrect");
}
} else {
echo Submission::createResult("Please fill in all information");
}
示例6: array
die;
}
$response = $paypal->doRequest("DoExpressCheckoutPayment", array("TOKEN" => $response['TOKEN'], "PAYERID" => $response['PAYERID'], "PAYMENTACTION" => "Sale", "PAYMENTREQUEST_0_AMT" => $response['PAYMENTREQUEST_0_AMT'], "PAYMENTREQUEST_0_CURRENCYCODE" => $response['PAYMENTREQUEST_0_CURRENCYCODE']));
if ($response) {
if ($response['PAYMENTINFO_0_PAYMENTSTATUS'] == "Completed" && $response['ACK'] == "Success" && $response['PAYMENTINFO_0_ACK'] == "Success") {
//did pay
$userid = intval($_SESSION['userid']);
if (isset($_SESSION['shopping-cart'])) {
$token = base64_encode(DbManager::i()->escapeString($_GET['token']));
$payerid = base64_encode(DbManager::i()->escapeString($_GET['PayerID']));
$cart = DbManager::i()->escapeString($_SESSION['shopping-cart']);
$amount = floatval($response['PAYMENTINFO_0_AMT']);
DbManager::i()->insert("sf_purchases", array("token", "payerid", "type", "userid", "cart", "date", "ip", "amount", "pending"), array(base64_encode($response['PAYMENTINFO_0_TRANSACTIONID']), $payerid, base64_encode("PayPal"), $userid, $cart, time(), base64_encode($_SERVER['REMOTE_ADDR']), $amount, 0));
$_SESSION['shopping-cart'] = base64_encode("{}");
DbManager::i()->update("sf_carts", array("cart" => $_SESSION['shopping-cart']), array("userid" => $userid));
$find = DbManager::i()->select("sf_members", array("email", "key", "iv"), array("userid" => $_SESSION['userid']));
if ($find !== false && !is_array($find)) {
$recipient = Crypto::DecryptString(base64_decode(base64_decode($find->key)), base64_decode(base64_decode($find->iv)), base64_decode(base64_decode($find->email)));
$subject = Settings::i()->title . ' Payment received';
$message = generateMessage($first_name, (array) json_decode(base64_decode($cart)), $response['PAYMENTINFO_0_TRANSACTIONID']);
$header = 'From: shopfix@' . $_SERVER['SERVER_NAME'] . "\r\n" . 'Reply-To: shopfix@' . $_SERVER['SERVER_NAME'] . "\r\n" . 'X-Mailer: PHP/' . phpversion();
mail($recipient, $subject, $message, $header);
Logger::i()->writeLog("PayPal Transaction registered: " . $response['PAYMENTINFO_0_TRANSACTIONID']);
}
header("Location: index.php");
die;
} else {
header("Location: index.php");
}
} else {
header("Location: index.php");
示例7: die
if ($field = Submission::checkFields(array("title"), (array) $settings['cms_settings'])) {
die(Submission::createResult(ucfirst($field) . " is missing or invalid"));
}
} else {
die(Submission::createResult("Invalid Settings"));
}
}
}
$settings = base64_encode(base64_encode(Crypto::EncryptString(base64_decode(base64_decode(ADMIN_KEY)), base64_decode(base64_decode(ADMIN_IV)), $_POST['settings'])));
$find = DbManager::i()->select("sf_settings", array("settings"));
if ($find !== false && !is_array($find)) {
//settings already exists
$update = DbManager::i()->update("sf_settings", array("settings" => $settings));
if (!$update) {
Logger::i()->writeLog("Could not update settings, error = " . DbManager::i()->error, 'dev');
die;
}
} else {
$insert = DbManager::i()->insert("sf_settings", array("settings"), array($settings));
if (!$insert) {
Logger::i()->writeLog("Could not insert settings, error = " . DbManager::i()->error, 'dev');
die;
}
}
Logger::i()->writeLog("Settings updated");
unset($find);
unset($settings);
die(Submission::createResult("Settings updated successfully", true));
}
}
}
示例8: unset
echo Submission::createResult("Password updated successfully", true);
} else {
Logger::i()->writeLog("User password could not be updated, error = " . DbManager::i()->error);
echo Submission::createResult("Could not update password. Please try again later.");
}
unset($pw);
} else {
if (isset($_POST['email'])) {
$email = base64_decode($_POST['email']);
$email = base64_encode(base64_encode(Crypto::EncryptString(base64_decode(base64_decode($userinfo->key)), base64_decode(base64_decode($userinfo->iv)), $email)));
$update = DbManager::i()->update("sf_members", array("email" => $email), array("userid" => $userid));
if ($update) {
Logger::i()->writeLog("User Email updated, UserID = {$userid}");
echo Submission::createResult("Email updated successfully", true);
} else {
Logger::i()->writeLog("User Email could not be updated, reason = " . DbManager::i()->error);
echo Submission::createResult("Could not update email. Please try again later.");
}
unset($email);
} else {
echo Submission::createResult("Invalid POST Parameter");
}
}
unset($userinfo);
} else {
die(Submission::createResult("Could not find user"));
}
} else {
die(Submission::createResult("Invalid request method"));
}
}
示例9: ReCaptcha
$reCaptcha = new ReCaptcha(Settings::i()->captcha_private);
$resp = $reCaptcha->verifyResponse($_SERVER["REMOTE_ADDR"], $registration['captcha_response']);
if (!$resp->success) {
die(Submission::createResult("Please validate the Captcha"));
}
}
$u = $registration['username'];
$iv = Crypto::GenerateIV();
$key = Crypto::GenerateKey($u);
$username = base64_encode(base64_encode(Crypto::EncryptString($key, $iv, $u)));
$find = DbManager::i()->select("sf_members", array("userid"), array("key" => base64_encode(base64_encode($key))));
if ($find && count($find) > 0) {
die(Submission::createResult("Username is already taken"));
}
$pw = base64_encode(base64_encode(Crypto::EncryptString($key, $iv, $registration['password'])));
$email = base64_encode(base64_encode(Crypto::EncryptString($key, $iv, $registration['email'])));
$ip = base64_encode(base64_encode(Crypto::EncryptString($key, $iv, $_SERVER['REMOTE_ADDR'])));
$key = base64_encode(base64_encode($key));
$iv = base64_encode(base64_encode($iv));
$reg_date = date("Y-m-d");
$insert = DbManager::i()->insert("sf_members", array("username", "email", "password", "key", "iv", "register_date", "ip"), array($username, $email, $pw, $key, $iv, $reg_date, $ip));
if ($insert) {
Logger::i()->writeLog("Account created with username: {$u}");
die(Submission::createResult("Your account has been created successfully", true));
} else {
Logger::i()->writeLog("Could not register user, error = " . DbManager::i()->error, 'dev');
die(Submission::createResult("Could not register account. Please try again later"));
}
} else {
die(Submission::createResult("Please fill in all information"));
}
示例10: die
}
echo Submission::createResult("Missing Shopping Cart");
} else {
if ($request_method == "POST") {
if (!SessionManager::i()->validateToken("CartToken", "token")) {
Logger::i()->writeLog("Token to set cart is missing", 'dev');
die(Submission::createResult("Permission denied"));
}
if (isset($_POST['cart'])) {
$_SESSION['shopping-cart'] = $_POST['cart'];
if (SessionManager::i()->isLoggedIn()) {
$find = DbManager::i()->select("sf_carts", array("cart"), array("userid" => intval($_SESSION['userid'])));
if ($find !== false && !is_array($find)) {
//cart already exists for user
$update = DbManager::i()->update("sf_carts", array("cart" => $_SESSION['shopping-cart']), array("userid" => intval($_SESSION['userid'])));
if (!$update) {
Logger::i()->writeLog("Updating cart failed, error = " . DbManager::i()->error, 'dev');
die(Submission::createResult("Failed to update cart"));
}
} else {
$insert = DbManager::i()->insert("sf_carts", array("cart", "userid"), array($_SESSION['shopping-cart'], intval($_SESSION['userid'])));
if ($insert) {
Logger::i()->writeLog("Inserting cart failed, error = " . DbManager::i()->error, 'dev');
die(Submission::createResult("Failed to insert cart"));
}
}
unset($find);
}
}
}
}
示例11: die
require_once ROOT_DIR . '/class.dbmanager.php';
require_once ROOT_DIR . '/class.logger.php';
require_once ROOT_DIR . '/class.sessionmanager.php';
require_once ROOT_DIR . '/class.submission.php';
if (!SessionManager::i()->isAdminLoggedIn()) {
Logger::i()->writeLog("Tried to access this script without permissions. Was that you?", 'access');
die(Submission::createResult("Permission denied"));
}
if (!SessionManager::i()->validateToken("GetCustomersToken", "token")) {
Logger::i()->writeLog("Token to access customers is missing", 'access');
die(Submission::createResult("Token mismatch"));
}
header("Content-Type: application/json; charset=UTF-8");
$customers = DbManager::i()->select("sf_members", array("userid", "username", "email", "register_date", "ip", "key", "iv"));
if ($customers !== false) {
$members = array();
if (!is_array($customers)) {
$customers = array($customers);
}
foreach ($customers as $customer) {
$key = base64_decode(base64_decode($customer->key));
$iv = base64_decode(base64_decode($customer->iv));
array_push($members, array("customerid" => $customer->userid, "name" => Crypto::DecryptString($key, $iv, base64_decode(base64_decode($customer->username))), "email" => Crypto::DecryptString($key, $iv, base64_decode(base64_decode($customer->email))), "date" => strtotime($customer->register_date) * 1000, "ip" => Crypto::DecryptString($key, $iv, base64_decode(base64_decode($customer->ip)))));
}
echo json_encode(array("customers" => $members));
unset($members);
unset($customers);
} else {
Logger::i()->writeLog("Could not get customers, error = " . DbManager::i()->error, 'dev');
die(Submission::createResult("Could not load customers"));
}
示例12: die
}
}
$imagePath = null;
$bigImagePath = null;
$productPath = null;
if (($res = processImages("bigimage", $imagePath, $bigImagePath)) || is_null($imagePath) || is_null($bigImagePath)) {
die(Submission::createResult("Failed to process image -> " . $res));
}
if (($res = processFile("productfile", $productPath)) || is_null($productPath)) {
die(Submission::createResult("Failed to process Product File -> " . $res));
}
if (floatval($product['price']) == 0) {
die(Submission::createResult("Price can not be 0"));
}
$soldOut = intval($product['available']) == 0 ? 1 : 0;
$insert = DbManager::i()->insert("sf_products", array("name", "price", "description", "available", "image", "bigimage", "file", "soldOut"), array($product['name'], floatval($product['price']), $product['description'], intval($product['available']), $imagePath, $bigImagePath, $productPath, $soldOut));
if ($insert) {
Logger::i()->writeLog("Added Product successfully");
echo Submission::createResult("Product added successfully", true);
} else {
Logger::i()->writeLog("Could not add product. error = " . DbManager::i()->error, 'dev');
echo Submission::createResult("Could not add product");
}
unset($product);
unset($imagePath);
unset($bigImagePath);
unset($productPath);
} else {
Logger::i()->writeLog("Tried to access script without post parameters", 'dev');
echo Submission::createResult("Bad request");
}
示例13: die
}
if (!SessionManager::i()->validateToken("UpdateProductToken", "token")) {
Logger::i()->writeLog("Token to update product is missing", 'dev');
die(Submission::createResult("Token mismatch"));
}
if ($field = Submission::checkFields("action", "product", $_POST)) {
die(Submission::createResult(ucfirst($field) . " is missing or invalid"));
}
$product = (array) json_decode(base64_decode($_POST['product']));
switch ($_POST['action']) {
case 'soldOut':
if (!DbManager::i()->update("sf_products", array("soldOut" => intval($product['soldOut'])), array("productid" => intval($product['productid'])))) {
Logger::i()->writeLog("Marking product as soldOut failed, error = " . DbManager::i()->error, 'dev');
die(Submission::createResult("Failed to mark product as soldOut"));
}
break;
case 'delete':
if (!DbManager::i()->delete("sf_products", array("productid" => intval($product['productid'])))) {
Logger::i()->writeLog("Deleting product failed, error = " . DbManager::i()->error, 'dev');
die(Submission::createResult("Failed to delete product"));
}
break;
case 'product':
if (!DbManager::i()->update("sf_products", $product, array("productid" => intval($product['productid'])))) {
Logger::i()->writeLog("Update Product failed, error = " . DbManager::i()->error, 'dev');
die(Submission::createResult("Failed to update product"));
}
break;
default:
break;
}
示例14: foreach
foreach ($payment->cart as $key => $value) {
if ($key == $_GET['productid']) {
$has_purchased = true;
break;
}
}
if ($has_purchased) {
//purchased
$find = DbManager::i()->select("sf_products", array("file"), array("productid" => intval($_GET['productid'])));
if ($find !== false && !is_array($find)) {
$file_path = $_SERVER['DOCUMENT_ROOT'] . $find->file;
if (file_exists($file_path)) {
header("Content-type: application/force-download");
header("Content-Disposition: attachment; filename=\"" . str_replace(" ", "_", basename($file_path)) . "\"");
echo file_get_contents($file_path);
Logger::i()->writeLog("User " . $_SESSION['userid'] . " downloaded " . basename($file_path));
} else {
Logger::i()->writeLog("Failed to download file " . basename($file_path) . " - it does not exist", 'dev');
header("Location: index.php");
}
}
} else {
Logger::i()->writeLog("User " . $_SESSION['userid'] . " has not purchased the product he/she is trying to download");
header("Location: index.php");
die;
}
} else {
Logger::i()->writeLog("Could not get purchase for transaction_id = " . $_GET['transaction_id'] . ", error = " . DbManager::i()->error, 'dev');
header("Location: index.php");
die;
}
示例15: doPayment
public function doPayment($total)
{
$total = $this->exchangeCurrencyToBTC($total);
$label = "user" . $_SESSION['userid'] . "BTCCheckout_" . rand(0, 100000);
$response = (array) $this->block_io->get_new_address(array("label" => $label));
if ($response['status'] != "success") {
throw new Exception("Failed to create new Bitcoin Address");
}
$responseData = (array) $response['data'];
$address = $responseData['address'];
$insert = DbManager::i()->insert("sf_purchases", array("token", "payerid", "type", "userid", "cart", "date", "ip", "amount", "pending"), array(base64_encode($address), base64_encode($label), base64_encode("Bitcoin"), intval($_SESSION['userid']), base64_encode($_SESSION['shopping-cart']), time(), base64_encode($_SERVER['REMOTE_ADDR']), floatval($total), 1));
if ($insert !== false) {
return json_encode(array("btcamount" => $total, "btcaddress" => $insert ? $address : "error"));
} else {
throw new Exception("Could not insert pending purchase");
}
}