Advertisement:

Author Topic: What does this code tell me?  (Read 4972 times)

Offline Study Force

  • SMF Hero
  • ******
  • Posts: 3,656
    • StudyForcePS on Facebook
    • @studyforceps on Twitter
What does this code tell me?
« on: March 02, 2011, 11:11:13 PM »
There's a file in a folder within the main directory of my forum /public_html/subs/ipn.php. In ipn.php, it states the following:

Code: [Select]
// Start things rolling by getting SMF alive...
require_once('./../SSI.php');
require_once($sourcedir . '/ManagePaid.php');
loadLanguage('ManagePaid');

I know my SSI.php file is in /public_html/ so does './../SSI.php' accurately represent that? In other words, does './../SSI.php' mean go back 1 directory into the /public_html/ directory?

Offline Bigguy

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 12,955
  • Gender: Male
  • Be nice, or else....
    • smfbigguy on GitHub
    • What's Ur Beef
Re: What does this code tell me?
« Reply #1 on: March 02, 2011, 11:13:30 PM »
SSI.php is located in the root of your SMF install. Where settings.php is.

Offline Study Force

  • SMF Hero
  • ******
  • Posts: 3,656
    • StudyForcePS on Facebook
    • @studyforceps on Twitter
Re: What does this code tell me?
« Reply #2 on: March 02, 2011, 11:18:20 PM »
So should I change './../SSI.php' to '/../SSI.php' or to '/SSI.php' ? ... Remember that this is being called from a directory in the /public_html/ main directory. Or should I leave it as './../SSI.php' ?

Offline Bigguy

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 12,955
  • Gender: Male
  • Be nice, or else....
    • smfbigguy on GitHub
    • What's Ur Beef
Re: What does this code tell me?
« Reply #3 on: March 02, 2011, 11:20:19 PM »
If you installed a mod like paid subscriptions or treasury then the mod should have everything set up for you already.

Offline Study Force

  • SMF Hero
  • ******
  • Posts: 3,656
    • StudyForcePS on Facebook
    • @studyforceps on Twitter
Re: What does this code tell me?
« Reply #4 on: March 02, 2011, 11:32:52 PM »
If you installed a mod like paid subscriptions or treasury then the mod should have everything set up for you already.

I installed paid subscription, but I just want to know what './../SSI.php' means. Does it mean /Public_html/ssi.php ? If so, what is that extra dot './'

Also, in index.template.php, it is written like this:

require_once('SSI.php');

Why is it different than require_once('./../SSI.php')?

Offline Bigguy

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 12,955
  • Gender: Male
  • Be nice, or else....
    • smfbigguy on GitHub
    • What's Ur Beef
Re: What does this code tell me?
« Reply #5 on: March 02, 2011, 11:57:35 PM »
I would think it all depends on where the file is that is calling SSI.php. I'm not quite sure though myself. It could be this:

./../SSI.php

If SSI.php is in the public_html directory then

the ./../

would be

/public_html/subs/

Offline Study Force

  • SMF Hero
  • ******
  • Posts: 3,656
    • StudyForcePS on Facebook
    • @studyforceps on Twitter
Re: What does this code tell me?
« Reply #6 on: March 03, 2011, 12:03:18 AM »
:(  :'(

Offline Bigguy

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 12,955
  • Gender: Male
  • Be nice, or else....
    • smfbigguy on GitHub
    • What's Ur Beef
Re: What does this code tell me?
« Reply #7 on: March 03, 2011, 12:09:08 AM »
Oh, is that not right, lol. ???

Offline Study Force

  • SMF Hero
  • ******
  • Posts: 3,656
    • StudyForcePS on Facebook
    • @studyforceps on Twitter
Re: What does this code tell me?
« Reply #8 on: March 03, 2011, 12:11:50 AM »
Perhaps I could use:

require_once($forum_dir . '/SSI.php')

Offline Bigguy

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 12,955
  • Gender: Male
  • Be nice, or else....
    • smfbigguy on GitHub
    • What's Ur Beef
Re: What does this code tell me?
« Reply #9 on: March 03, 2011, 12:14:09 AM »
Is the mod not working for you. ??? What version of SMF do you have. ???

Offline Matthew K.

  • SMF Super Hero
  • *******
  • Posts: 12,430
  • Gender: Male
    • matthew.kerle on Facebook
    • @matthew_kerle on Twitter
Re: What does this code tell me?
« Reply #10 on: March 03, 2011, 12:14:58 AM »
$sourcedir needs to be globalized...
Code: (Find) [Select]
// Start things rolling by getting SMF alive...
require_once('./../SSI.php');
require_once($sourcedir . '/ManagePaid.php');
loadLanguage('ManagePaid');
Code: (Replace) [Select]
// Start things rolling by getting SMF alive...
require_once('./../SSI.php');
global $sourcedir;
require_once($sourcedir . '/ManagePaid.php');
loadLanguage('ManagePaid');

Offline Study Force

  • SMF Hero
  • ******
  • Posts: 3,656
    • StudyForcePS on Facebook
    • @studyforceps on Twitter
Re: What does this code tell me?
« Reply #11 on: March 03, 2011, 12:15:43 AM »
$sourcedir needs to be globalized...

What does that mean?

1.1.13

Offline Matthew K.

  • SMF Super Hero
  • *******
  • Posts: 12,430
  • Gender: Male
    • matthew.kerle on Facebook
    • @matthew_kerle on Twitter
Re: What does this code tell me?
« Reply #12 on: March 03, 2011, 12:16:05 AM »
I updated my post for you. That should work.

Offline Study Force

  • SMF Hero
  • ******
  • Posts: 3,656
    • StudyForcePS on Facebook
    • @studyforceps on Twitter
Re: What does this code tell me?
« Reply #13 on: March 03, 2011, 12:17:43 AM »
I updated my post for you. That should work.

Are you sure Labradoodle-360? This came straight from the mod...

Code: [Select]
<?php
/******************************************************************************
* ipn.php                                                                     *
*******************************************************************************
* SMF: Simple Machines Forum                                                  *
* Open-Source Project Inspired by Zef Hemel (zef@zefhemel.com)                *
* =========================================================================== *
* Software Version:           SMF 1.1                                         *
* Software by:                Simple Machines (http://www.simplemachines.org) *
* Copyright 2001-2006 by:     Lewis Media (http://www.lewismedia.com)         *
* Support, News, Updates at:  http://www.simplemachines.org                   *
*******************************************************************************
* This program is free software; you may redistribute it and/or modify it     *
* under the terms of the provided license as published by Lewis Media.        *
*                                                                             *
* This program is distributed in the hope that it is and will be useful,      *
* but WITHOUT ANY WARRANTIES; without even any implied warranty of            *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                        *
*                                                                             *
* See the "license.txt" file for details of the Simple Machines license.      *
* The latest version can always be found at http://www.simplemachines.org.    *
******************************************************************************/

// Start things rolling by getting SMF alive...
require_once('./../SSI.php');
require_once(
$sourcedir '/ManagePaid.php');
loadLanguage('ManagePaid');

// If there's literally nothing coming in, escape!
if (empty($_POST))
exit;

// I assume we're even active?
if (empty($modSettings['paid_enabled']))
exit;

// Verify the incoming string is something we can deal with.
if ((isset($_POST['txn_type']) || isset($_POST['payment_status'])) && !empty($modSettings['paypal_email']) && ((isset($_POST['business']) && $modSettings['paypal_email'] == $_POST['business']) || (isset($_POST['receiver_email']) && $modSettings['paypal_email'] == $_POST['receiver_email'])))
{
if (!isset($_POST['business']))
$_POST['business'] = $_POST['receiver_email'];

$txnType 'paypal';
if (!isset($_POST['txn_type']))
$_POST['txn_type'] = '';
}
elseif (!empty(
$_POST['callbackPW']) && !empty($worldpay_pw) && $_POST['callbackPW'] == $worldpay_pw)
$txnType 'worldpay';
elseif (!empty(
$_POST['x_response_code']) && !empty($modSettings['authorize_id']))
$txnType 'authorize';
// Otherwise hope it's 2co...
elseif (!empty($_POST['x_MD5_Hash']) && !empty($modSettings['2co_id']))
$txnType '2co';
// Or new just in - nochex!
elseif (!empty($_POST['order_id']) && !empty($modSettings['nochex_email']))
$txnType 'nochex';

// Nothing else? EXIT!
else
generateError($txt['paid_unknown_transaction_type']);

if (!
file_exists($txnType '.php'))
generateError(sprintf($txt['paid_missing_transaction_type'], $txnType));

// Create an instance of the class.
require_once($txnType '.php');

// If this is 2co we need to remove the 2!
if ($txnType == '2co')
$txnType 'twoco';
$payType = new $txnType();

// Get the ID_SUB and ID_MEMBER amoungst others...
@list ($ID_SUB$ID_MEMBER) = $payType->precheck();

// This would be bad...
if (empty($ID_MEMBER))
generateError($txt['paid_empty_member']);

// Integer these just incase.
$ID_SUB = (int) $ID_SUB;
$ID_MEMBER = (int) $ID_MEMBER;

// Verify the member.
$request db_query("
SELECT ID_MEMBER, memberName, realName, emailAddress
FROM 
{$db_prefix}members
WHERE ID_MEMBER = 
$ID_MEMBER"__FILE____LINE__);
// Didn't find them?
if (mysql_num_rows($request) == 0)
generateError(sprintf($txt['paid_could_not_find_member'], $ID_MEMBER));
list (
$ID_MEMBER$username$name$email) = mysql_fetch_row($request);
mysql_free_result($request);

// Get the subscription details.
$request db_query("
SELECT cost, active, length, Name, email_complete
FROM 
{$db_prefix}subscriptions
WHERE ID_SUBSCRIBE = 
$ID_SUB"__FILE____LINE__);

// Didn't find it?
if (mysql_num_rows($request) == 0)
generateError(sprintf($txt['paid_count_not_find_subscription'], $ID_MEMBER$ID_SUB));

list (
$cost$active$length$subname$emaildata) = mysql_fetch_row($request);
mysql_free_result($request);

// Is this a refund etc?
if ($payType->isRefund())
{
// Delete user subscription.
removeSubscription($ID_SUB$ID_MEMBER);

db_query("
DELETE FROM 
{$db_prefix}log_subscribed
WHERE ID_SUBSCRIBE = 
$ID_SUB
AND ID_MEMBER = 
$ID_MEMBER
AND status = 0"
__FILE____LINE__);

// Receipt?
if (!empty($modSettings['paid_email']) && $modSettings['paid_email'] == 2)
{
$emailbody $txt['paid_delete_sub_body'];
$emailbody .= "\n\n\t";
$emailbody .= $txt['paid_new_sub_body_sub'] . ' ' $subname;
$emailbody .= "\n\t" $txt['paid_new_sub_body_name'] . ' ' $name ' (' $username ')';
$emailbody .= "\n\t" $txt['paid_new_sub_body_date'] . ' ' timeformat(time(), false);

paidAdminEmail($txt['paid_delete_sub_subject'], $emailbody);
}

}
// Otherwise is it what we want, a purchase?
elseif ($payType->isPayment() || $payType->isSubscription())
{
$cost unserialize($cost);
$totalCost $payType->getCost();
$notify false;

// Is this flexible?
if ($length == 'F')
{
$foundDuration 0;
// This is a little harder, can we find the right duration?
foreach ($cost as $duration => $value)
{
if ($duration == 'fixed')
continue;
elseif ((float) $value == (float) $totalCost)
$foundDuration strtoupper(substr($duration01));
}

// If we have the duration then we're done.
if ($foundDuration !== 0)
{
$notify true;
addSubscription($ID_SUB$ID_MEMBER$foundDuration);
}
}
else
{
$actual_cost $cost['fixed'];
// It must be at least the right amount.
if ($totalCost != && $totalCost >= $actual_cost)
{
// Add the subscription.
$notify true;
addSubscription($ID_SUB$ID_MEMBER);
}
}

// Send a receipt?
if (!empty($modSettings['paid_email']) && $modSettings['paid_email'] == && $notify)
{
$emailbody $txt['paid_new_sub_body'];
$emailbody .= "\n\n\t";
$emailbody .= $txt['paid_new_sub_body_sub'] . ' ' $subname;
$emailbody .= "\n\t" $txt['paid_new_sub_body_price'] . ' ' sprintf($modSettings['currency_symbol'], $totalCost);
$emailbody .= "\n\t" $txt['paid_new_sub_body_name'] . ' ' $name ' (' $username ')';
$emailbody .= "\n\t" $txt['paid_new_sub_body_email'] . ' ' $email;
$emailbody .= "\n\t" $txt['paid_new_sub_body_date'] . ' ' timeformat(time(), false);
$emailbody .= "\n" $txt['paid_new_sub_body_link'] . ":\n\t" $scripturl '?action=profile;u=' $ID_MEMBER;

paidAdminEmail($txt['paid_new_sub_subject'], $emailbody);
}

// Email the user?
if (strlen($emaildata 10) && strpos($emaildata"\n") !== false)
{
$subject substr($emaildata0strpos($emaildata"\n") - 1);
$body substr($emaildatastrpos($emaildata"\n") + 1);

$search = array('{NAME}''{FORUM}');
$replace = array($name$mbname);

$subject str_replace($search$replace$subject);
$body str_replace($search$replace$body);

require_once($sourcedir '/Subs-Post.php');
sendmail($email$subject$body);
}
}

// Incase we have anything specific to do.
$payType->close();

// Log an error then die.
function generateError($text$notify true)
{
global $modSettings$sourcedir$db_prefix$txt;

// Send an email?
if (!empty($modSettings['paid_email']))
paidAdminEmail($txt['paid_error_subject'], $txt['paid_error_body'] . "\n"  "---------------------------------------------\n" $text);

// Otherwise log and die.
log_error($text);
exit;
}

// Send an email to admins.
function paidAdminEmail($subject$body)
{
global $sourcedir$db_prefix$mbname$modSettings;

require_once($sourcedir '/Subs-Post.php');
$request db_query("
SELECT emailAddress, realName
FROM 
{$db_prefix}members
WHERE ID_GROUP = 1"
__FILE____LINE__);
while ($row mysql_fetch_assoc($request))
sendmail($row['emailAddress'], $subject$row['realName'] . "\n\n" $body "\n\n" $mbname);
mysql_free_result($request);

if (!empty($modSettings['paid_email_to']))
{
foreach (explode(','$modSettings['paid_email_to']) as $email)
sendmail(trim($email), $subject$body "\n\n" $mbname);
}
}

?>

Offline Bigguy

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 12,955
  • Gender: Male
  • Be nice, or else....
    • smfbigguy on GitHub
    • What's Ur Beef
Re: What does this code tell me?
« Reply #14 on: March 03, 2011, 12:19:25 AM »
Is the mod working for you right now. ???

Offline Matthew K.

  • SMF Super Hero
  • *******
  • Posts: 12,430
  • Gender: Male
    • matthew.kerle on Facebook
    • @matthew_kerle on Twitter
Re: What does this code tell me?
« Reply #15 on: March 03, 2011, 12:20:55 AM »
You should be fine to change the require for SSI to just "SSI.php"

Offline Study Force

  • SMF Hero
  • ******
  • Posts: 3,656
    • StudyForcePS on Facebook
    • @studyforceps on Twitter
Re: What does this code tell me?
« Reply #16 on: March 03, 2011, 12:27:11 AM »
Is the mod working for you right now. ???

Haven't tried :p, but I would have to make a donation to myself, which is not possible. :S

So...

Code: [Select]
// Start things rolling by getting SMF alive...
require_once('SSI.php');
require_once($sourcedir . '/ManagePaid.php');
loadLanguage('ManagePaid');

?

Offline Bigguy

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 12,955
  • Gender: Male
  • Be nice, or else....
    • smfbigguy on GitHub
    • What's Ur Beef
Re: What does this code tell me?
« Reply #17 on: March 03, 2011, 12:29:48 AM »
There is a test area is there not to test out ipn.php, or I maybe thinking of the treasury mod.

Offline Study Force

  • SMF Hero
  • ******
  • Posts: 3,656
    • StudyForcePS on Facebook
    • @studyforceps on Twitter
Re: What does this code tell me?
« Reply #18 on: March 03, 2011, 12:31:05 AM »
There isn't :(

Offline Bigguy

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 12,955
  • Gender: Male
  • Be nice, or else....
    • smfbigguy on GitHub
    • What's Ur Beef
Re: What does this code tell me?
« Reply #19 on: March 03, 2011, 12:34:50 AM »
That must be in the other mod then, sorry about that. :) Did Labradoodle's suggestion work for you. ???