Beispiel #1
0
function insert_data($conn, $user, $pass)
{
    $sql = "INSERT INTO id_table (user, pass) VALUES ('{$user}','{$pass}')";
    if ($conn->query($sql) === TRUE) {
        $return_pair = array("strange" => "strange");
        echo json_enode($return_pair);
        //read($conn);
    } else {
        echo "Error: " . $sql . "<br>" . $conn->error;
    }
}
<?php

$route = '/content/:content_id/';
$app->delete($route, function ($content_id) use($app) {
    $host = $_SERVER['HTTP_HOST'];
    $content_id = prepareIdIn($content_id, $host);
    $ReturnObject = array();
    $query = "DELETE FROM content WHERE content_id = " . $content_id;
    //echo $query . "<br />";
    mysql_query($query) or die('Query failed: ' . mysql_error());
    $ReturnObject = array();
    $ReturnObject['message'] = "Note Deleted!";
    $ReturnObject['content_id'] = $content_id;
    $app->response()->header("Content-Type", "application/json");
    echo stripslashes(format_json(json_enode($ReturnObject)));
});
Beispiel #3
0
 /**
  *  a subscription payment has been successfully made
  * @param $listModel
  * @param $request
  * @param $set_list
  * @param $err_msg
  * @return unknown_type
  */
 function txn_type_subscr_payment($listModel, $request, &$set_list, &$err_msg)
 {
     $db = JFactory::getDbo();
     $this->log('fabrik.ipn.txn_type_subscr_payment', json_enode($request));
     $invoice = $this->checkInvoice($request);
     if ($invoice === false) {
         return false;
     }
     // Update subscription details
     $inv = $this->getInvoice($invoice);
     $this->log('fabrik.ipn.txn_type_subscr_payment: invoice', json_enode($inv));
     $sub = $this->getSubscriptionFromInvoice($invoice);
     $this->log('fabrik.ipn.txn_type_subscr_payment: sub', json_enode($sub));
     $now = JFactory::getDate()->toSql();
     $sub->status = 'Active';
     $sub->lastpay_date = $now;
     $sub->store();
     // Update invoice status
     $inv->transaction_date = $now;
     $inv->pp_txn_id = $request['txn_id'];
     $inv->pp_payment_status = $request['payment_status'];
     $inv->pp_payment_amount = $request['mc_gross'];
     $inv->pp_txn_type = $request['txn_type'];
     $inv->pp_fee = $request['mc_fee'];
     $inv->pp_payer_email = $request['payer_email'];
     // $$$ hugh @TODO - make sure payment_amount == amount
     $inv->paid = 1;
     if (!$inv->store()) {
         $this->log('fabrik.ipn.txn_type_subscr_payment: FAILED TO STORE INVOICE', json_enode($inv));
     } else {
         $this->log('fabrik.ipn.txn_type_subscr_payment: invoice stored', json_enode($inv));
     }
     // Set user to desired group
     $subUser = JFactory::getUser($sub->userid);
     $this->log('fabrik.ipn.txn_type_subscr_payment sub userid', $subUser->get('id'));
     $query = $db->getQuery(true);
     $query->select('usergroup AS gid')->from('#__fabrik_subs_subscriptions AS s')->join('INNER', '#__fabrik_subs_plans AS p ON p.id = s.plan')->where('userid = ' . $subUser->get('id'));
     //' and status = "Active"'
     $db->setQuery($query);
     $gid = $db->loadResult();
     $this->log('fabrik.ipn.txn_type_subscr_payment', 'set user group to:' . $gid);
     $this->log('fabrik.ipn.txn_type_subscr_payment gid query', $db->getQuery());
     $this->log('fabrik.ipn.setusergid', $subUser->get('id') . ' set to ' . $gid . "\n " . $db->getQuery() . "\n " . $db->getErrorMsg());
     $subUser->groups = (array) $gid;
     $subUser->save();
     $app = JFactory::getApplication();
     $MailFrom = $app->getCfg('mailfrom');
     $FromName = $app->getCfg('fromname');
     $SiteName = $app->getCfg('sitename');
     $payer_email = $request['payer_email'];
     $subject = "%s - Subscription payment complete";
     $subject = sprintf($subject, $SiteName);
     $subject = html_entity_decode($subject, ENT_QUOTES);
     $msgbuyer = 'Your subscription payment on %s has successfully completed. (Paypal transaction ID: %s)<br /><br />%s';
     $msgbuyer = sprintf($msgbuyer, $SiteName, $txn_id, $SiteName);
     $msgbuyer = html_entity_decode($msgbuyer, ENT_QUOTES);
     JFactory::getMailer()->sendMail($MailFrom, $FromName, $payer_email, $subject, $msgbuyer, true);
     $msgseller = 'Subscription payment success on %s. (Paypal transaction ID: %s)<br /><br />%s';
     $msgseller = sprintf($msgseller, $SiteName, $txn_id, $SiteName);
     $msgseller = html_entity_decode($msgseller, ENT_QUOTES);
     JFactory::getMailer()->sendMail($MailFrom, $FromName, $receiver_email, $subject, $msgseller, true);
     return 'ok';
 }