Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

I'm not being lazy...

Options
  • 19-12-2010 2:16pm
    #1
    Registered Users Posts: 459 ✭✭


    ...I just a bit of a n00b:rolleyes:

    After three months of trying to grapple with the whole wed dev scene I can honestly say that it's been a steep learning curve. I'm just about finished my second website, which is hosted from home on iis and that in itself I think is an achievement, FTR Apache nearly broke my heart - I can't stand nor understand the whole Linux ethos TBH.

    I won't lie, code is kicking the $hit out of me, partly because the CMS I use has so many different people providing for it, coupled with a general n00b understanding of code structure in the first place.

    I've had one or two Eureka! in notepad2 with php scripts where my basic knowledge allowed me to make basic changes to get the job done - it feels good:cool:

    But; after investing quite some time into my site I've stumbled upon a piece of open source software that suits my needs but has some problems.

    The softwate was written in ~2007 and only runs under legacy in Joomla which runs fine to the point of a plugin which I need to accept payment. The plugin is tied in with the rest of the component which allows time-based subscriptions, so I need it. As far as I can see the plugin is just not creating the tables it should in the first place (jos_mostools) ie: jos_mostools simply is not in the database - thats as far as I understand, I just don't know enough to debug it or how to debug?

    Can anyone point me in the right direction as to what might be wrong with the following code and why Joomla 1.5.2 might not like it?

    [PHP]<?php
    /**
    * @copyright Copyright (C) 2006 - 2010 JoomlaEquipment (http://www.joomlaequipment.com). All rights reserved.
    * @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
    **/
    error_reporting(E_ALL ^E_NOTICE);
    defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

    $_MAMBOTS->registerFunction( 'onPayProsessStart', 'jeProcessPayPalStart' );
    $_MAMBOTS->registerFunction( 'onPayProsessFinish', 'jeProcessPayPalFinish' );
    function jcsPPGetInfo()
    {

    $req = 'cmd=_notify-validate';
    foreach ($_POST as $key => $value) {
    $value = urlencode(stripslashes($value));
    $req .= "&$key=$value";
    }
    $header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
    $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
    $header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
    $fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30);
    if (!$fp) {

    } else {
    fputs ($fp, $header . $req);
    while (!feof($fp)) {
    $res = fgets ($fp, 1024);
    if (strcmp ($res, "VERIFIED") == 0) {

    return $_POST;
    }
    else if (strcmp ($res, "INVALID") == 0) {
    error_log("The response from IPN was: $res\n",3, '/home/virtual/she-makes-the-rules.com/webroot/htdocs/mambots/system/log.txt');
    }
    }
    fclose ($fp);
    }

    return false;
    }

    function jeProcessPayPalFinish()
    {
    Global $my, $database, $mosConfig_live_site;

    $processor = mosGetParam( $_REQUEST, 'processor');
    if($processor != '.paypal') return false;

    $query = "SELECT id"
    . "\n FROM #__mambots"
    . "\n WHERE element = 'joomlaequipment.payprocessor{$params[processor]}'"
    . "\n AND folder = 'system'"
    ;
    $database->setQuery( $query );
    $id = $database->loadResult();
    $mambot = new mosMambot( $database );
    $mambot->load( $id );
    $botParams = new mosParameters( $mambot->params );

    if( mosGetParam( $_REQUEST, 'pay') == 'ipn' || $botParams->get('ipn'))
    {
    $s_info = jcsPPGetInfo();
    //$s_id = jcsGetSubscrId($s_info);
    //$s_info = $_GET;
    $order = mosGetParam( $_REQUEST, 'order_id');
    switch($s_info)
    {

    case "web_accept":
    case "subscr_payment":
    $order = $s_info ? $s_info : $my->id;
    if(key_exists('subscr_id', $s_info))
    {
    $order = $s_info.' '.$s_info;
    }
    else
    {
    $order = $s_info;
    }
    $order = $s_info;
    if($s_info == 'Completed')
    $order = 'success';
    else
    $order = 'fail';
    break;

    case "subscr_failed":
    $order = $s_info ? $s_info : $my->id;
    $order = $s_info;
    $order = $s_info;
    $order = 'fail';
    break;


    case "subscr_eot":
    case "subscr_cancel":
    $sql = "UPDATE #__jcs_user_subscr SET published = 0 WHERE gateway_id LIKE '{$s_info[subscr_id]}%'";
    $database->setQuery($sql);
    $database->query();
    break;
    }
    }
    else
    {
    $order = mosGetParam( $_REQUEST, 'order_id');
    $order = mosGetParam( $_REQUEST, 'pay');
    $order = $processor;
    $order = mosGetParam( $_REQUEST, 'txn_id', date("m-d")."-".$order);
    $order = mosGetParam( $_REQUEST, 'amount');
    }

    //session_start();
    //if((float)$_SESSION != (float)$order)
    //{
    //$order = 'fail';
    //}

    return $order;
    }

    function jeProcessPayPalStart( $params )
    {
    Global $my, $database, $mosConfig_live_site, $mosConfig_absolute_path,
    $JCS_ORDER_COMPLETE, $JCS_ORDER_INCOMPLETE;

    if($params != '.paypal') return;

    if (file_exists( $mosConfig_absolute_path.'/components/com_jcs/languages/'.$mosConfig_lang.'.php' ))
    include_once( $mosConfig_absolute_path.'/components/com_jcs/languages/'.$mosConfig_lang.'.php' );
    else
    require_once( $mosConfig_absolute_path.'/components/com_jcs/languages/english.php' );

    $query = "SELECT id"
    . "\n FROM #__mambots"
    . "\n WHERE element = 'joomlaequipment.payprocessor{$params[processor]}'"
    . "\n AND folder = 'system'"
    ;
    $database->setQuery( $query );
    $id = $database->loadResult();
    $mambot = new mosMambot( $database );
    $mambot->load( $id );
    $botParams = new mosParameters( $mambot->params );
    session_start();
    $_SESSION = $params;

    $param = mosGetParam( $_REQUEST, 'option');
    $param = 'pay';
    $param = $params;
    $param = $params;
    $param = floatval($params);
    $return = urlencode($mosConfig_live_site.'/index.php?'.jpArray2Url($param).'&pay=success');
    $cancel_return = urlencode($mosConfig_live_site.'/index.php?'.jpArray2Url($param).'&pay=fail');

    IF($botParams->get('ipn'))
    {
    $return = urlencode($mosConfig_live_site.'/index.php?option=com_jcs&smsg='.$JCS_ORDER_COMPLETE);
    $cancel_return = urlencode($mosConfig_live_site.'/index.php?option=com_jcs&smsg='.$JCS_ORDER_INCOMPLETE);
    $notify = urlencode($mosConfig_live_site.'/index.php?'.jpArray2Url($param).'&pay=ipn');
    }

    unset($param);

    $param = $notify;
    $param = $return;
    $param = $cancel_return;
    $param = $params;
    $param = "_xclick";
    $param = $my->id;
    $param = "2";
    $param = urlencode($botParams->def( 'email'));
    $param = $botParams->def( 'currency');
    $param = strval($params);

    if($botParams->def('requre'))
    {
    $sql = "SELECT * FROM #__jcs_plans WHERE id = '{$params[order_id]}'";
    $database->setQuery( $sql );
    $rows = $database->loadObjectList();
    $row = $rows[0];

    unset($param);

    $param = "_xclick-subscriptions";
    $param = $params;
    $param = strtoupper(substr($row->days_type,0,1));
    $param = $row->days;
    $param = "1";
    $param = "1";
    $param = "2";
    $param = "1";
    }
    if($botParams->def('tax'))
    {
    $param = $botParams->def('tax');
    }

    if(!$param || !$param || !$param || !$params)
    {
    echo "<P><h1>Error Payment Processing: some of the params passed are empty</h1></P>";
    return;
    }
    //$url = 'https://www.sandbox.paypal.com/cgi-bin/webscr?'.jpArray2Url($param);
    $url = 'https://www.paypal.com/us/cgi-bin/webscr?'.jpArray2Url($param);
    //$url = 'https://www.paypal.com/subscriptions/'.jpArray2Url($param);
    //echo str_replace("&", "<BR>", urldecode($url));
    header("location: $url");
    }

    if(!defined('JP_IMPLODE'))
    {
    define('JP_IMPLODE', 1);
    function jpArray2Url($param)
    {
    foreach($param AS $k => $v)
    {
    $out[] = "$k=$v";
    }
    return implode('&', $out );
    }
    }
    ?>[/PHP]


Comments

  • Registered Users Posts: 171 ✭✭conorcan2


    I think the first step would be to create those tables. Then, if you're getting error messages describe the messages or state how the software isn't behaving as you'd expect.

    To create the tables, you're looking for their definition or an .sql file. Where did you get the software from?


  • Registered Users Posts: 459 ✭✭CSU


    I can't distinguish what the tables and values should be from that code? Compared to other code where the sql databese tables are clearly marked but here I just can't understand what is going on...

    I got the software from www.joomlaequipment.com and It's pretty dead over there on forum.

    I could just throw money at it but...you know... nothing would have been learned.

    Could you elaborate on manual creation of jos_mambot tables creation and it's values?

    E;

    Just noticed this .xml file in the plugin folder:
    [PHP]<?xml version="1.0" encoding="iso-8859-1"?>
    <mosinstall version="1.0.0" type="mambot" group="system">
    <name>Payment Processor [PayPal]</name>
    <license>GNU/GPL http://www.gnu.org/copyleft/gpl.html</license&gt;
    <author>JoomlaEquipment</author>
    <authorEmail>serg4172@mail.ru</authorEmail>
    <authorUrl>http://www.joomlaequipment.com</authorUrl&gt;
    <creationDate>2006-05-28</creationDate>
    <copyright>Joomla Equipment</copyright>
    <version>1.16</version>
    <description><![CDATA[
    <h1>PayPal Configuration Instruction</h1>
    <p>nstall plugin
    <p>Edit plugind and enter your paypal email, currency and choose if you wish your payments be recurring. This means that purchasing subscription on your site customer will create paypal subscription that will bill him automatically until one cancel subscription on PayPal.
    <p>Login to pay pal and go to profile section
    <p>Click on Instant Payment Notification and enable IPN. As IPN URL enter homepage of your site.
    <p><B>NOTE!! Plugin Will not work whithout IPN activated!!!</B>
    ]]></description>
    <files>
    <filename mambot="joomlaequipment.payprocessor.paypal">joomlaequipment.payprocessor.paypal.php</filename>
    </files>
    <params>
    <param name="email" type="text" default="" label="PayPal Account (E-mail)" />

    <param name="currency" type="list" default="USD" label="Transaction currency" description="">
    <option value="USD">U.S. Dollars (USD)</option>
    <option value="EUR">Euros (EUR)</option>
    <option value="GBP">Pounds Sterling (GBP)</option>
    <option value="CAD">Canadian Dollars (CAD)</option>
    <option value="JPY">Yen (JPY)</option>
    <option value="AUD">Australian Dollars (AUD)</option>
    <option value="NZD">New Zealand Dollars (NZD)</option>
    <option value="CHF">Swiss Francs (CHF)</option>
    <option value="HKD">Hong Kong Dollars (HKD)</option>
    <option value="SGD">Singapore Dollars (SGD)</option>
    <option value="SEK">Swedish Kronor (SEK)</option>
    <option value="DKK">Danish Kroner (DKK)</option>
    <option value="PLZ">Polish Zloty (PLZ)</option>
    <option value="NOK">Norwegian Kroner (NOK)</option>
    <option value="HUF">Hungarian Forint (HUF)</option>
    <option value="CZK">Czech Koruna (CZK)</option>
    </param>
    <param name="requre" type="radio" default="0" label="User Recurring payments(Subscriptions)" description="">
    <option value="1">Yes</option>
    <option value="0">No</option>
    </param>
    <param name="ipn" type="radio" default="1" label="Use IPN method" description="">
    <option value="1">Yes</option>
    <option value="0">No</option>
    </param>

    <param name="tax" type="text" default="0.00" label="Tax (E.g. 0.55)" />

    </params>
    </mosinstall>[/PHP]


  • Registered Users Posts: 171 ✭✭conorcan2


    Did you follow the instructions in the users guide? Did you get errors when trying to follow those instructions? Have you checked your Apache logs?


  • Registered Users Posts: 459 ✭✭CSU


    conorcan2 wrote: »
    Did you follow the instructions in the users guide? Did you get errors when trying to follow those instructions? Have you checked your Apache logs?

    The guide was written in '07 for an older version of the CMS so info particular to my problem now is not there. No PHP errors are triggered nor error tracing in iis has much to say...

    I just cant figure out what mambots fields and values the script creates for sql in the script in the OP, the second .xml looks like parameters for running the script which is no help.

    If I could decipher fields and values from the script I could manually create jos_mambots and test it... :confused:


  • Registered Users Posts: 171 ✭✭conorcan2


    Try installing it on an older version of Joomla and then doing a mysql dump of the database? It seems like you're going to have to dig deeper with their code. Are you sure there aren't alternative modules that are better maintained?


  • Advertisement
  • Registered Users Posts: 459 ✭✭CSU


    conorcan2 wrote: »
    Try installing it on an older version of Joomla and then doing a mysql dump of the database? It seems like you're going to have to dig deeper with their code. Are you sure there aren't alternative modules that are better maintained?

    Thanks, I'll run it on an older version and see what happens - as far as alternatives go I'm digging through hotscripts.com atm...might turn up something.

    Thanks conorcan2


  • Registered Users Posts: 171 ✭✭conorcan2


    You're welcome.
    CSU wrote: »
    I can't stand nor understand the whole Linux ethos TBH.

    I wouldn't worry too much about Linux, it can bog you down and I survived without it for many years. My own philosophy was a 'need to know' basis, so I learned in increments. It's easy to set up PHP/MySQL/Apache on Windows and 99% of the coding is the same for Linux (for you average web script).


  • Registered Users Posts: 647 ✭✭✭Freddio


    CSU wrote: »

    else if (strcmp ($res, "INVALID") == 0) {

    error_log("The response from IPN was: $res\n",3, '/home/virtual/she-makes-the-rules.com/webroot/htdocs/mambots/system/log.txt');

    }
    Does this path and file exist on your server?


  • Registered Users Posts: 459 ✭✭CSU


    Freddio wrote: »
    Does this path and file exist on your server?

    nope...

    I've abandoned the software as it's written for an older version of the CMS, which works on it's own but lacks the ability to run alongside simple newer applications - thanks anyway.

    FTR - the mostools reference I believe was when Joomla called "plugins" > "mambots" which is no longer supported...


Advertisement