*

heebeha

  • **
  • 60
  • Me
When will osdate 3.0 be ready to download?
« on: January 16, 2015, 07:17:00 PM »
We are all waiting with baited breath in anticipation of the new osdate 3.  Please release it or provide me with a beta version to test and report bugs and I will fix issues if needed and report back.  Please

*

Pharg

  • *****
  • 2,060
  • osDate Version: osDate Evo v1.0
Re: When will osdate 3.0 be ready to download?
« Reply #1 on: January 16, 2015, 07:46:34 PM »
Hi heebeha,

There are two versions that have been done, but only one is available in beta version which still has bugs, it's been
online for download since last November from opensource at https://sourceforge.net/projects/osdatepdo/
being osDate Version 3.1beta.

I have tested this version and not all hosts will let you use it, as it uses database Functions to get the data which uses a lot of
the hosts resources so I am told by my own hosting company.

Another version may have to be worked on to get it running on all hosts sorry to say.

As for the second osDate version 3.0 we don't have access to it and don't know if or when it will released
Regards,
Pharg ( Phill )

REMEMBER: ALWAYS BACKUP BEFORE YOU MAKE ANY CHANGES!!

osDate v2.7 & osDateEvo v1.0 | PHP: 5.3.42 & PHP: 5.6.18 | MySQL: 5.5.35

*

heebeha

  • **
  • 60
  • Me
Re: When will osdate 3.0 be ready to download?
« Reply #2 on: January 17, 2015, 03:35:25 PM »
I like the admin side of PDO, front end is very messy, better if I could use a template I built/used on osdate 2.54 or 2.65 but they don't work when I attempt to use them.  Do you know why and how I can fix this?  I simply updated all the files from the download.  Was I supposed to upload a later version of osdate first then upload the DO files over it after I installed it?


*

Pharg

  • *****
  • 2,060
  • osDate Version: osDate Evo v1.0
Re: When will osdate 3.0 be ready to download?
« Reply #3 on: January 17, 2015, 08:29:50 PM »
Hi heebeha,

Fristly, osdate 2.54 / 2.6.5 both use Smarty 2 where as osDatePDO uses Smarty 3

Learn all about Smarty 2 and 3 tags here http://www.smarty.net/

You would have found the answer in this post at http://www.osdateforum.com/announcements-discussion-3/osdate-3-osdatepdo!-beta-is-released!/

It's says there how to set it all up and about the templates being totally different, older templates don't work on this version!

Backup your site fully before installing, it's for testing only!!

This is only a beta version for testing only, not for production sites!

The upgrade path from earlier versions is very limited.

You must have osDate 2.5+ version to directly upgrade. For others, you need to follow the path of export/import of data and ensure the data is adjusted properly using appropriate programs.

Most importantly,
- Only 'default' template is included full functionally. You need to make changes in all other templates as you need it and as you want it to work based on default template design and functioning.

Old Templates are in folder /template/old_templates

- osDatePDO require PHP5+ (PHP5.5+ is better) and mysql 5.1+

- This uses Smarty V 3.1.19

Changes done in osDatePDO.

--------------------------

An API (Application Programming Interface) for osDate is defined.

1. The database interfacing is made more simpler. Following functions are available to manage data.

a. For managing data of a particular table, use the function

manageTableData(action, tablename, tablefields, condition, sortorder, limit)

action = 'selectall' - to select all records from the table
'selectrow' - to select one single row from table
'selectone' - to select one value from the table
'update' - to update table field values
'insert' - to insert records into the table
'delete' - to delete row(s) from table

tablename = the tablename for data management

tablefields = For select oriented queries, this is the array of field list
For update and insert queries, this is the associative array of
field => value pair
For delete, just give false.

condition = This is the associative array of condition (field => value pair)

This function will evaluate only 'equal' condition.

sortorder = Sort order as a text field (this should include the field name and
sort order)

limit = This is the limit of number of records to be selected.

Some examples:

a) To select all records from mailbox table for a user

manageTableData('selectall', MAILBOX_TABLE, false, array('owner'=>$userid));

b) To insert a record in inbox

manageTableData('insert', MAILBOX_TABLE, array('owner'=>$userid, 'folder'=>'inbox',
'senderid'=>$senderid, 'recipientid' => $userid,
'subject'=>$subject, 'message'=>$message, 'sendtime'=>time()));

c) Delete all record from 'sent' folder for the user

manageTableData('delete', MAILBOX_TABLE, false, array('owner'=>$userid,
'folder'=>'sent'));


d) To check if the user is online

manageTableData('selectone', ONLINE_USERS_TABLE, array('is_online'),
array('userid'=>$userid));


b) If the query is not from one table or require complex where condition, use following
functions as needed

a) getAll(qry, substitutevalues) - To select all records resulting from the query
b) getRow(qry, substitutevalues) - To select the row resulting from the query
c) getOne(qry, substitutevalues) - To select one value resulting from the query
d) osd_query(qry, substitutevalues) - To execute a complex query

qry = The sql query
substitutevalues = The parameter values to be substituted in the sql query

c) To manage data from USER table

a) To select details of a particular userid, use the function
getUser(userid)

b) To select some field values for a user, use the function
getUserFields(userid, fields)
where fields is the array of fields to be selected

c) To update some field values in user table, use the function
updateUserFields(userid, fields)
where fields is the associative array of field=>value pair

All sql queries of all PHP programs and plugins are modified to use this intreface.
These interface functions remove the need to use the $osDB variable in any program.

2. Following PHP functions are available for extracting some important data

a. getStates(countrycode, allstates="Y", sortorder="name")
This function returns the array of states defined for the country

b. getCounties(countrycode, statecode, allcounties="Y", sortorder="name")
This function returns the arry of counties defined for the country and state

c. getCities(countrycode, statecode, countycode, allcities="Y", sortorder="name")
This function returns the array of cities defined for the country and state and county.
If county is omitted, it will return all cities available in the country and state.

d. getZipcodes(countrycode, statecode, countycode, citycode, allzips="Y", sortorder="code")
This function returns the array of zips defined for the country and state and county and city.
If city or county or state is omitted, it will return zip codes for defined combination.

e. getCityName(countrycode, statecode, countycode, citycode)
This function returns the city name for the given combination.

f. getStateName(countrycode, statecode)
This function return the state name

g. getCountyName(countrycode, statecode, countycode)
This function return the county name

h. getCountryName(countrycode)
This function return the country name

i. mailSender($hdr_from, $hdr_to, $email, $subject, $body, $attachment='')
This function sends email to outisde email id of the user
$hdr_from = The from email address
$hdr_to = The to email address
$subject = Subject
$body = The message text
$attachment = The attachment file, if any

j. checkOnlineStats(userid)
This function returns 'online' if the user is online. Otherwise it returns 'offline'.

k. getOnlineStats(userid)
This function returns true if the user is online. Otherwise returns false. This is additionally
defined for checking the online status easily.

3. The javascript library jQuery is implemented along with following jQuery plugins

a) corners
b) select_skin
c) easing
d) jcarousel
e) textlimit
f) jQuery_UI


4. Default skin screens are modified to use the full width of the screen. This change is applicable
to almost all tpl files.

5. All screens and sub sections in the screen is beautified by rounding all corners using CSS framework.

6. Scrollable blocks are implemented to all those portions in the homepage e.g. Featured Profiles display,
New Users display, Random Profiles display, etc.

7. The top menu system is slightly modified. All options in the menu is now shown with rounded background.

8. The news and story blocks in the home page leftcolumn now has scrollable facility.

9. Default homepage header is now modified to remove the partitioned picture and to use
CSS based background rounding for the simple search criteria acceptance part.
Also, the login part is now made as part of header itself.

10. All tabulated displays are now stripe enabled i.e. all rows in the table will display a different
background when cursor is on the row. This will easily identify current row. This is extended
to all those blocks where multiple choices (checkboxed and radio buttons) are being displayed
like advsearch screen.

11. All admin pages are modified to use rounded corners.

12. All plugins are modified to use rounded corners and where ever tables are used, it is modified to
use row level striping.

13. All buttons are beautified.

14. Where ever possible, tabs is implemented to display data (e.g. adv search, edit profile, global
setting editing, etc.)

15. User profile changes are now recorded and kept in system. It works in following way:

a) You can define the user table changes which should he managed using this system, This is the array
given in config.php ($modify_fields ). Please define the exact field names given in the USER table.
Once you define the fields, you need to give the Language specific field names in the array defined in
language file for these fields to be displayed in the screen. (refer $lang['userdatafields'] )

b) When the user make change to any of the fields given in the list ($modify_fields array), it will be
stored in the table USERCHANGES.

c) If approval is not required by admin (i.e. the automatic activation is enabled by admin for profiles),
Then the data will be updated immediately. A mail will be sent to admin and the user about changes made.

d) If approval is needed, it will be kept in abeyance till it is approved by admin. Admin menu have two
new options - Approve User Changes and User Changes. If any approval is pending regarding changes by user,
it will be listed in Approve User Changes. Admin can approve or reject changes. The action will be informed
to user and data will be updated if approved. Admin can view history of user data changes using the option
userchanges.

e) The user menu has the option to view changes done by the user - approved and rejected and pending approval.

16. Displaying of different blocks in homepage is now in a mix of Tabs format and fixed portion format .
The blocks to be displayed in Tabs can be defined in the array ($homepage_blocks) in config.php. You need to
adjust the homepage.tpl to display other blocks not included for Tabs display method. By default, it assumes
all blocks. If any block is not needed in tabs, you will need to explicitely display the block in
homepage.tpl.

In global settings, there is a flag to use Tabs display method for homepage blocks. ('Use TABBED display
method to show information blocks in home page? ). Default is 'Y'.

17. Now a profile can be hidden. The user can opt to hide his/her profile. If hidden, that profile will not
be included in searches, in any of the special display blocks like Featured Profiles display, IP Locationwise
profiles, Newest Profiles, etc. However, this HIDEME function is not applicable in ADMIN section.

18. Now the membership level for visitors are defined in Global Settings. This allows to define membership
levels with various rights and not to define a level with 'Visitor' as name.

19. Default template design is modified. Now the user stats are shown in the header potion after the user log in.
Same way, the quick login screen is moved along with the Special Offer block.

20. Quick search block is improved and is in righthand top corner.

21. In the leftcolumn, there is a block which displays online users which scrolls automatically.

22.   There are some functions defined in database level. This will ease data extraction from database.
   These are defined in the file /sql/osdate_db_functions.sql file.
   
23.   There is a view user_details defined which will contain all user related information. This is an
   extension of user table.
   
24.   Now the server admin can decide how user pictures will be stored. IF in file system, there is an option to
   store pictures entirely in single folder or in sub folder for the user. ALso, if your site has many users,
   you can define parameter to group your users. This will ease file management in server side.
   
25.   Pictures and album management is improved. Now you can define multiple albums and assign same picture to multiple albums. This will reduce disk storage use in server side.

26.   Now same user can give multiple comments to a profile. Also, the rating is separated from comments.

27.   All available plugins are improved for performance and modified to use new defined functions for DB access.


Installation Notes:
-------------------
To install osDatePDO, follow these steps:
a) If you already have osDatev2.6 site and want to upgrade this to osDatePDO,
   - then copy all your files to the osDatePDO root folder. Ensure /temp folder is copied over fully.
   - Give 777 rights to all files/folders under /temp folder.
   - Rename existing /temp/myconfig/config.php as /temp/myconfig/config_bkp.php
   - copy /temp/myconfig/config_bkp.php as /temp/myconfig/config.php and edit /temp/myconfig/config.php and remove all lines from the file except those which define database details as given below
   define( 'DB_USER', '' );
   define( 'DB_NAME', '' );
   define( 'DB_HOST', 'localhost' );
   define( 'DB_PASS', '' );
   define( 'DB_TYPE', 'mysql' );

   Give correct values for these fields.
   
b)   Copy all files from the osDatePDO distribution set to respective folders under osDatePDO root folder.

c) If you are installing fresh, then just run the installer and follow steps. If you are upgrading, run installer and choose upgrade mode and follow steps.

d) Rename /install.php and /install folders to install_bkp.php and install_bkp folder.

e)   Give appropriate rights to folders and files.

f)    Take a full backup of your installation (files and folders and mysql database).

Now you are ready to use new system and test this version.
« Last Edit: January 17, 2015, 10:36:09 PM by Pharg »
Regards,
Pharg ( Phill )

REMEMBER: ALWAYS BACKUP BEFORE YOU MAKE ANY CHANGES!!

osDate v2.7 & osDateEvo v1.0 | PHP: 5.3.42 & PHP: 5.6.18 | MySQL: 5.5.35

*

heebeha

  • **
  • 60
  • Me
Re: When will osdate 3.0 be ready to download?
« Reply #4 on: January 24, 2015, 06:11:37 PM »
Great feedback and instructions buddy.  Anyway we could get the old templates to work on the new PDO version?

*

CBG

  • *****
  • 673
    • osDate Forum
Re: When will osdate 3.0 be ready to download?
« Reply #5 on: January 24, 2015, 07:06:01 PM »
Great feedback and instructions buddy.  Anyway we could get the old templates to work on the new PDO version?
Only way is to remake them, as it is Smarty 3.
Regards,
CBG (Garry)
osDate: 2.6.5, 2.7 & Evo
PHP: 5.5.x/5.6.x (5.3.x to 5.6.x) | MySQL: 5.5.34-cll

*

heebeha

  • **
  • 60
  • Me
Re: When will osdate 3.0 be ready to download?
« Reply #6 on: January 24, 2015, 07:12:18 PM »
Can things be reverted back to use smarty 2.0 somehow?

*

Pharg

  • *****
  • 2,060
  • osDate Version: osDate Evo v1.0
Re: When will osdate 3.0 be ready to download?
« Reply #7 on: January 24, 2015, 09:21:02 PM »
Can things be reverted back to use smarty 2.0 somehow?


Hi heebeha,

Yes, go back to osDate 2.6.5 and wait for the updates ;)
Regards,
Pharg ( Phill )

REMEMBER: ALWAYS BACKUP BEFORE YOU MAKE ANY CHANGES!!

osDate v2.7 & osDateEvo v1.0 | PHP: 5.3.42 & PHP: 5.6.18 | MySQL: 5.5.35

*

heebeha

  • **
  • 60
  • Me
Re: When will osdate 3.0 be ready to download?
« Reply #8 on: January 25, 2015, 12:25:32 AM »
:(  I need that PayPal reoccurring fix.  Anyone know how to fix it so PayPal payment reoccur and updates the users membership accordingly?

*

Pharg

  • *****
  • 2,060
  • osDate Version: osDate Evo v1.0
Re: When will osdate 3.0 be ready to download?
« Reply #9 on: January 25, 2015, 01:57:10 AM »
:(  I need that PayPal reoccurring fix.  Anyone know how to fix it so PayPal payment reoccur and updates the users membership accordingly?

Hi heebeha,

For which version osDate are you talking about??
If you put it in your questions maybe we could answer better without asking all the time?
Regards,
Pharg ( Phill )

REMEMBER: ALWAYS BACKUP BEFORE YOU MAKE ANY CHANGES!!

osDate v2.7 & osDateEvo v1.0 | PHP: 5.3.42 & PHP: 5.6.18 | MySQL: 5.5.35

*

CBG

  • *****
  • 673
    • osDate Forum
Re: When will osdate 3.0 be ready to download?
« Reply #10 on: January 25, 2015, 02:13:56 PM »
:(  I need that PayPal reoccurring fix.  Anyone know how to fix it so PayPal payment reoccur and updates the users membership accordingly?

Hi heebeha,

As Pharg said you either best of adding the osDate version into the post or create a signature with the version you use.

Looking back at my save Tufat forum pages, there was a post in November 2009 by brilovett about recurring PayPal payments.
Please note I have note tested this, in one way shape of form.

A general list of functionality:

1.Ability to make one-time and recurring payments

2.Ability for recurring payments to be automatically received from PayPal and add the appropriate additional membership days to the user's account

3.Ability to maintain a transaction log of all transactions received from PayPal (these are called Instant Payment Notifications, or IPN)

4.Ability to automatically send an e-mail to a user when their one-time or recurring payment is declined, with a copy of the e-mail going to the admin

5.Ability to create unique invoice numbers for recurring payments that are tied back to the original payment (S for single, one-time only payments, M for monthly recurring payments, and Y for annually recurring payments; additionally, it increments existing invoice numbers by 1 for recurring payments so you can always see the original invoice it's tied to)

6.Ability to log any transactions that PayPal sends that aren't handled by the script (or that may have been sent by a hacker)

7.Ability to send an automatic email to the admin when a transaction is received that isn't handled by the script so that the admin can investigate further

8.Ability to ignore certain PayPal transactions (e.g., when a user creates a recurring/subscription payment, PayPal sends a transaction that this was created - this transaction can be ignored)
I have done my best to comment the design extensively in the primary script (paypal_ipn.php) to not only make it easier to add enhancements, but also to make it easier to use this as a basis for developing recurring payments with other payment modules.

Though I have tested it extensively, I certainly would appreciate anyone who uses it to post defects. Using PayPal's sandbox, I'm able to simulate quite a few different things. However, the sandbox does not automatically send recurring payment notifications. (You can create simulated transactions using their IPN simulator, and so the best I could do was generate hundreds of simulated tests that should look like the recurring payments.)

Please note that, if a user cancels their OSDate membership but has recurring payments setup through PayPal, these payments will continue unless the user goes into their PayPal account and cancels the subscription. Therefore, you might want to notify the user of this in the cancel.tpl file.

Additionally, for this script, I have changed the way OSDate processes membership changes. You certainly don't have to include those changes. (I did them because I thought it was fairer to the user and enhanced the value offered, even if they got something extra that they didn't pay for.) The way it works is as follows:

If a user has days left on his membership but purchases a different membership (e.g., an upgrade), this script will change the remaining days they had to the new membership level, as well as add on the additional days purchased (e.g., if a user is currently a silver member with 15 remaining days and purchases a gold 30-day membership, once their payment is processed, they will have 45 days at the gold level).
Call it an added bonus for upgrading.

I have placed all of the English text displayed to the user in the various files rather than adding it to the language file. Obviously, it would be better to add it to the language file, but I wanted to make this script somewhat self-contained in case it does not get incorporated into the release. (This would make it easier to continue to use the script as new OSDate versions are released.)

P.S. - For some reason, the word SITENAME in the subject that is emailed to users and the admin doesn't seem to work, but I haven't figured out why yet. It's a small defect, but it's a defect.
Regards,
CBG (Garry)
osDate: 2.6.5, 2.7 & Evo
PHP: 5.5.x/5.6.x (5.3.x to 5.6.x) | MySQL: 5.5.34-cll

*

CBG

  • *****
  • 673
    • osDate Forum
Re: When will osdate 3.0 be ready to download?
« Reply #11 on: January 25, 2015, 02:16:12 PM »
MAKE A BACKUP OF ALL FILES FIRST!

You must turn on IPN in PayPal and turn off Instant Data Transfer. The URL for IPN should be http://[your site name].com/paypal_ipn.php.

paymentconfirmation.php changes:
Add the following lines after $t->assign( 'currency', $row['currency'] ); (line 44)

Code: [Select]
$recurring_unit = 'S';
if ($_POST['purchase_duration'] == 'Recurring') {
if (stristr($row['name'],'monthly')) {
$recurring_unit = 'M';
} elseif (stristr($row['name'],'annual')) {
$recurring_unit = 'Y';
}
}
if ($recurring_unit == 'S') $duration = '(a one-time only payment will be made)';
if ($recurring_unit == 'M') $duration = '(a recurring, monthly payment will be set-up and made automatically)';
if ($recurring_unit == 'Y') $duration = '(a recurring, annual payment will be set-up and made automatically)';
$t->assign( 'duration', $duration );
$t->assign( 'recurring_unit', $recurring_unit );
$t->assign( 'purchase_duration', $_POST['purchase_duration'] );

Change $invoice_no = $_SESSION['UserId']."-".time(); (line 54) to:

Code: [Select]
$invoice_no = $_SESSION['UserId']."-".time()."-".$recurring_unit."-000";

checkout_process.php changes:

Change if (isset($_REQUEST['payment_cancel']) && $_REQUEST['payment_cancel'] == 1) { (line 42) to:

Code: [Select]
if (isset($_REQUEST['payment_cancel']) && $_REQUEST['payment_cancel'] == '1') {

Move lines 38 - 40 that contain:

Code: [Select]
if (!isset($paid_thru) || $paid_thru == '') {$paid_thru = $_REQUEST['paid_thru']; }

if (isset($_REQUEST['rtnlink']) ) { $rtnlink = $_REQUEST['rtnlink']; }
to line 56 (after the } )

Change if (isset($_REQUEST['payment_status']) ) { (line 78) to:

Code: [Select]
if (isset($_REQUEST['payment_status']) ) $payment_status = $_REQUEST['payment_status'];

Delete (or comment out) lines 79 - 92

Change if ($paid_thru == 'pm2checkout' or $paid_thru == 'egold' or $paid_thru = 'paypal' or $paid_thru == 'free') { (line 116) to:

Code: [Select]
if ($paid_thru == 'pm2checkout' or $paid_thru == 'egold' or $paid_thru == 'free') {

payment.tpl changes:

NOTE: If you're using more than the PayPal payment module (e.g., authorize.net, egold), you are likely going to want to make the following changes to paypal_checkout.tpl instead of payment.tpl. Otherwise, you will have a one-time/recurring drop down on the page that you have another payment module and this will confuse the user (because it won't work for that other payment module).

Add the following at line 96:

Code: [Select]
<div style="text-align:left">
<table border="0" width="100%">
<tr>
<td width ="35%">Choose:&nbsp;&nbsp;
<select name="purchase_duration">
<option value="Recurring">Recurring</option>
<option value="One-time">One-time purchase</option>
</select></td>
<td width ="65%"><input class="formbutton" type="submit" value="Confirm purchase --&gt;"/></b></td>
</tr>
</table>
</div>

Delete lines 94 - 96

paypal_checkout.tpl changes:

Replace the whole file with:

Code: [Select]
{strip}
{assign var="page_hdr01_text" value="{lang mkey='confirmation'}"}
{include file="page_hdr01.tpl"}
<div class="module_detail" style="vertical-align:top; padding:6px;">
{if $test_mode == 'test'}
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
{else}
<form action="https://secure.paypal.com/cgi-bin/webscr" method="post">
{/if}

<input type="hidden" name="add" value="1" />
<input type="hidden" name="rm" value="2" />
<input type="hidden" name="business" value="{$email}" />
<input type="hidden" name="pay_mod" value="paypal" />
  <input type="hidden" name="return" value="http://{$smarty.server.SERVER_NAME}{$docroot}checkout_process.php?pay_txn_id={$pay_txn_id}&amp;paid_thru=paypal" />
{* used by checkout_process.php to validate order *}
<input type="hidden" name="item_name" value="{lang mkey='change_mship_to'} {$item_name}" />
<input type="hidden" name="user_id" value="{$smarty.session.UserId}" />
<input type="hidden" name="user_level" value="{$item_no}" />
<input type="hidden" name="invoice" value="{$invoice_no}" />
<input type="hidden" name="no_shipping" value="1" />
<input type="hidden" name="custom" value="{$pay_txn_id}" />

{if $purchase_duration == 'One-time'}
<input type="hidden" name="amount" value="{$amount}" />
<input type="hidden" name="cmd" value="_xclick" />
{else}
<input type="hidden" name="cmd" value="_xclick-subscriptions" />
<input type="hidden" name="a3" value="{$amount}" />
<input type="hidden" name="src" value="1" />
<input type="hidden" name="t3" value="{$recurring_unit}" />
<input type="hidden" name="sra" value="0" />
<input type="hidden" name="p3" value="1" />
{/if}

  <input type="hidden" name="cancel_return" value="http://{$smarty.server.SERVER_NAME}{$docroot}checkout_process.php?payment_cancel=1&amp;pay_txn_id={$pay_txn_id}" />
<input type="hidden" name="no_note" value="1" />
{if $currency == 'UKP'} {assign var="currency" value="GBP"}
{elseif $currency == 'CD'} {assign var="currency" value='CAD'}{/if}
<input type="hidden" name="currency_code" value="{$currency}" />

<div class="line_outer">
<div class="line_top_bottom_pad">
{lang mkey='info_confirm'}<br /><br />
</div>
<table border="0" cellpadding="{$config.cellpadding}" cellspacing="{$config.cellspacing}" width="75%">
<tr><td><b>Method of payment:</b></td><td><b>PayPal</b> (you will be transferred to PayPal to complete your payment)</td></tr>
<tr><td colspan="2">&nbsp;</td></tr>
<tr><td><b>Purchase duration:</b></td><td><b>{$purchase_duration}</b> {$duration}</td></tr>
<tr><td colspan="2">&nbsp;</td></tr>
<tr><td><b>{lang mkey='amount'}</b></td><td><b>{$currency_is}{$amount}</b></td></tr>
<tr><td colspan="2">&nbsp;</td></tr>
<tr><td><b>{lang mkey='change_mship_to'}</b></td><td><b>{$item_name}</b></td></tr>
<tr>
<td colspan="2"><br /><center><input type="submit" class="formbutton" value="{lang mkey='confirm'}" /></center></td>
</tr>
</table>
</div>
</form>
{/strip}

(It was easier to do it this way than show you each change to make.)
« Last Edit: January 26, 2015, 07:24:10 PM by CBG »
Regards,
CBG (Garry)
osDate: 2.6.5, 2.7 & Evo
PHP: 5.5.x/5.6.x (5.3.x to 5.6.x) | MySQL: 5.5.34-cll

*

CBG

  • *****
  • 673
    • osDate Forum
Re: When will osdate 3.0 be ready to download?
« Reply #12 on: January 25, 2015, 02:16:18 PM »

paypal_ipn.php - new file:

Create a new file which will reside in your root directory called paypal_ipn.php with the following:

Code: [Select]
<?php

// PREPARE THE OSDATE SESSION ON THE SERVER

if ( !defined'SMARTY_DIR' ) ) {
include_once( 'minimum_init.php' );
}

// RECEIVE THE IPN FROM PAYPAL

// read the post from PayPal system and add 'cmd'
$req 'cmd=_notify-validate';

foreach ($_POST as $key => $value) {
$value urlencode(stripslashes($value));
$req .= "&$key=$value";
}

$vars urldecode(str_replace ('&'"\n"$req)) ;

// capture post in log file to look at - useful for troubleshooting but can be deleted/commented out; suggest CHMOD file to 600 so no prying eyes can see
$myFile "paypal_ipn_log.txt";
$fh fopen($myFile'a') or die("cannot open file");
$stringData $vars;
fwrite($fh"IPN data received from PayPal:\n------------------------------\n");
fwrite($fh$stringData."\n------------------------------\n");
fclose($fh);

// SEND A RESPONSE BACK TO THEM

// post back to PayPal system to validate
$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 ('ssl://www.paypal.com'443$errno$errstr30);

// PREPARE THE IPN FOR PROCESSING INTO OSDATE

// assign posted variables to local variables
$payment_status = isset($_POST['payment_status'])?$_POST['payment_status']:'NA';
$pay_txn_id = isset($_POST['custom'])?$_POST['custom']:'NA';
$email = isset($_POST['payer_email'])?$_POST['payer_email']:'NA';
$txn_id = isset($_POST['txn_id'])?$_POST['txn_id']:'NA';
$total = isset($_POST['mc_gross'])?$_POST['mc_gross']:'0';
$invoice_no = isset($_POST['invoice'])?$_POST['invoice']:'NA';
$txn_type = isset($_POST['txn_type'])?$_POST['txn_type']:'NA';

// will use later if it's a good transaction
$params = array();

$params['pay_txn_id'] = $pay_txn_id;
$params['paid_thru'] = 'paypal';
$params['txn_id'] = $txn_id;
$params['amount'] = $total;
$params['payment_status'] = $payment_status;
$params['valid'] = true;
$params['email'] = $email;
$params['vars'] = $vars;

// for this release, we're only going to check for/process certain transactions
// a user can only cancel a recurring payment through PayPal - cancelling through OSDate will not cancel the recurring subscription; suggest putting
// a note in the cancel.tpl file that says that, if the member is using PayPal for a recurring payment, they must also cancel through PayPal
// they can visit PayPal's help center at https://www.paypal.com/helpcenter/main.jsp?cmd=_help-ext&t=solutionTab&solutionId=11750 for more information
// for a future release, when a user cancels, we can add functionality to check if they have a recurring payment with PayPal and send a cancel transaction
$valid_txn_types = array("express_checkout""merch_pmt""recurring_payment""subscr_payment""cart""web_accept""virtual_terminal");

// however, there are some transactions that we won't log in the invalid_paypal_transactions.txt file because they will happen often and they can be ignored
$ignore_txn_types = array("subscr_signup");

// the payment_statuses this script will process
$valid_payment_statuses = array("Completed""Denied");

// IF THE PAYPAL TRANSACTION IS VALID AND A TRANSACTION TYPE THAT IS PROCESSED BY THIS SCRIPT

// can remove || $_POST['test_ipn'] == '1' as this is for testing
if ($_POST['test_ipn'] == '1' || (in_array($txn_type$valid_txn_types) && (strcmp ($res"VERIFIED") == && in_array($payment_status$valid_payment_statuses)))) {

// GET OLD TRANSACTION

// get the transaction and see what its status is, as well as the associated user (which we may use later)
$transaction $osDB->getRow('select invoice_no, user_id, txn_id, payment_status, to_membership, amount_paid from ! where id = ?', array(TRANSACTIONS_TABLE$pay_txn_id) );
$user $osDB->getRow('select username, firstname, email from ! where id = ?', array(USER_TABLE$transaction['user_id']) );

// IF TRANSACTION STATUS IS COMPLETED, THEN THE IPN THAT PAYPAL JUST SENT IS A SUBSCRIPTION/RECURRING PAYMENT

if ($transaction['payment_status'] == 'Completed') {

// this is an automatically created recurring payment and doesn't have a transaction record yet
$create_new_transaction 'Y';

// create a new invoice number by getting the last 3 numbers of the last invoice and incrementing
$invoice_prefix substr($transaction['invoice_no'], 0, -4);
$search_len strlen($transaction['invoice_no']) - 4;
$last_invoice $osDB->getRow('select id, invoice_no from ! where left(invoice_no, ?) = ? order by id desc', array(TRANSACTIONS_TABLE$search_len$invoice_prefix));
$old_i intval(substr($last_invoice['invoice_no'],-3,3));
$old_i++;
if ($old_i 10$old_i "00".$old_i;
if (($old_i 100) && ($old_i 9)) $old_i "0".$old_i;
if (($old_i 1000) && ($old_i 99)) $old_i $old_i;
$invoice_no substr_replace($transaction['invoice_no'],$old_i,-3,3);

// IF THE IPN PAYMENT STATUS IS COMPLETED, THEN WE GOT PAID
// Note:  We assume the amount is correct because it's an automated payment; probably need to check with PayPal to see if a user can change a
// subscription by himself - if so, we'll need to verify the amount and deal with the results

if ($payment_status == 'Completed') {

// CREATE A NEW TRANSACTION/INVOICE

$osDB->query('insert into ! (txn_id, user_id, payment_email, invoice_no, from_membership, to_membership, amount_paid, txn_date, payment_mod, payment_status, payment_vars ) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', array(TRANSACTIONS_TABLE$txn_id$transaction['user_id'], $email$invoice_no$transaction['to_membership'], $transaction['to_membership'], $totaldate('Ymd'), 'paypal''Started'$vars));
$pay_txn_id $osDB->getOne('select id from ! where invoice_no = ?',array(TRANSACTIONS_TABLE$invoice_no));

// EXTEND THE TERM OF THE USER'S MEMBERSHIP

// Just added new transaction so we need to change the pay_txn_id to the record just created
$params['pay_txn_id'] = $pay_txn_id;

process_payment_info($params);

// ELSE, THE IPN PAYMENT STATUS MUST HAVE BEEN DENIED, SO WE DIDN'T GET PAID
// Note:  Technically, the payment status probably could be something other than denied (e.g., pending, refund), but that will have to be
// developed in a later release; right now, we're just going to send everything else to the admin to investigate

} elseif ($payment_status == 'Denied') {

// CREATE A NEW TRANSACTION/INVOICE

$osDB->query('insert into ! (txn_id, user_id, payment_email, invoice_no, from_membership, to_membership, amount_paid, txn_date, payment_mod, payment_status, payment_vars ) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', array(TRANSACTIONS_TABLE$txn_id$transaction['user_id'], $email$invoice_no$transaction['to_membership'], $transaction['to_membership'], $totaldate('Ymd'), 'paypal''Declined'$vars));

// SEND A MESSAGE TO THE USER THAT THEIR RECURRING PAYMENT WAS DECLINED
// Note:  This text should really go in the language file, but I'm putting it here to minimize the amount of changes elsewhere

$mail_sub 'SITENAME Message:  There was a problem with your PayPal payment';
$mail_body '<table border=0 cellpadding="0" cellspacing="0" width="570"><tr><td height="25" width="100%"><div class="module_head"><table border=0 cellspacing=0 cellpadding=0 width="100%"><tr><td width="77" height="25"><div class="module_head">#email_hdr_left#</div></td><td width="493" class="module_head" ><div class="module_head">Recurring payment problem for #UserName#</div></td></tr></table></div></td></tr>
<tr><td width="570" class="evenrow" colspan="2" ><div class="evenrow" ><table border="0" cellspacing="0" cellpadding="5"><tr><td height="1"></td></tr><tr><td class="evenrow">Dear #FirstName#,<br><br>Your membership is setup to automatically bill through PayPal. Unfortunately, the most recent transaction (invoice number #Invoice#) for $#Amount# was denied. We suggest contacting PayPal to discuss the issue further.<br><br>#siteName#<br></td></tr>
</td></tr></table></div> </td></tr></table>'
;

$From $config['admin_email']; // might want to change to billing@sitename.com
$To $user['email'];
$message $mail_body;
$message str_replace('#FirstName#'$user['firstname'] ,$message);
$message str_replace('#Invoice#'$invoice_no$message);
$message str_replace('#Amount#'$transaction['amount_paid'], $message);
$message str_replace('#UserName#'$user['username'], $message);

mailSender($From$To$user['email'], $mail_sub$message);

// SEND A COPY OF THE MESSAGE TO THE ADMIN AS AN FYI

$mail_sub 'SITENAME Message:  Copy of e-mail sent to user regarding problem with PayPal payment';

mailSender($From$From$From$mail_sub$message);

// CREATE A NEW TRANSACTION/INVOICE

// ELSE, IF THE TRANSACTION STATUS IS STARTED, THEN THIS IS EITHER A SINGLE PURCHASE OR A NEW SUBSCRIPTION INITIATED BY THE USER JUST NOW

} elseif ($transaction['payment_status'] == 'Started') { // transaction['payment_status'] != 'Completed'

// IF THE IPN PAYMENT STATUS IS COMPLETED, THEN WE GOT PAID

if ($payment_status == 'Completed') {

// UPDATE THE EXISTING TRANSACTION/INVOICE, CHANGE THE USER'S MEMBERSHIP (IF NECESSARY), ADD ON THE PURCHASED DAYS

process_payment_info($params);

// ELSE, THE IPN PAYMENT STATUS MUST HAVE BEEN DENIED, SO WE DIDN'T GET PAID
// Note:  Technically, the payment status probably could be something other than denied (e.g., pending, refund), but that will have to be
// developed in a later release; right now, we're just going to send everything else to the admin to investigate

} elseif ($payment_status == 'Denied') {

// UPDATE THE EXISTING TRANSACTION/INVOICE

$osDB->query('update ! set payment_status= ?, payment_email, amount_paid= ?, txn_date= ?, txn_id= ?, payment_vars= ? where id = ?', array(TRANSACTIONS_TABLE'Declined'$email$totaldate('Y-m-d'), $payment_status$vars$pay_txn_id) );

// SEND A MESSAGE TO THE USER THAT THEIR PAYMENT WAS DECLINED

$mail_sub 'SITENAME Message:  There was a problem with your PayPal payment';
$mail_body '<table border=0 cellpadding="0" cellspacing="0" width="570"><tr><td height="25" width="100%"><div class="module_head"><table border=0 cellspacing=0 cellpadding=0 width="100%"><tr><td width="77" height="25"><div class="module_head">#email_hdr_left#</div></td><td width="493" class="module_head" ><div class="module_head">Payment problem for #UserName#</div></td></tr></table></div></td></tr>
<tr><td width="570" class="evenrow" colspan="2" ><div class="evenrow" ><table border="0" cellspacing="0" cellpadding="5"><tr><td height="1"></td></tr><tr><td class="evenrow">Dear #FirstName#,<br><br>Unfortunately, your recent PayPal payment (invoice number #Invoice#) for $#Amount# was denied. We suggest contacting PayPal to discuss the issue further. As a result, your membership purchase/renewal did not go through.<br><br>#siteName#<br></td></tr>
</td></tr></table></div> </td></tr></table>'
;

$From $config['admin_email']; // might want to change to billing@sitename.com
$To $user['email'];
$message $mail_body;
$message str_replace('#FirstName#'$user['firstname'] ,$message);
$message str_replace('#Invoice#'$invoice_no$message);
$message str_replace('#Amount#'$transaction['amount_paid'], $message);
$message str_replace('#UserName#'$user['username'], $message);

mailSender($From$To$user['email'], $mail_sub$message);

// SEND A COPY OF THE MESSAGE TO THE ADMIN AS AN FYI

$mail_sub 'SITENAME Message:  Copy of e-mail sent to user regarding problem with PayPal payment';

mailSender($From$From$From$mail_sub$message);

// payment_status != 'Completed'

// transaction['payment_status'] != 'Started' or 'Completed'

// ELSE, THE PAYPAL TRANSACTION IS INVALID OR A TRANSACTION NOT PROCESSED BY THIS SCRIPT

} elseif (!in_array($txn_type$ignore_txn_types)) { // strcmp ($res, "VERIFIED") != 0

// Log for manual investigation; why is PayPal sending us invalid transactions? Is it really a hacker?
// It might just be a transaction type or payment status that this script doesn't process
$myFile "investigate_paypal_transactions.txt"// Suggest CHMOD file to 600 so no prying eyes can see
$fh fopen($myFile'a') or die("cannot open file");
fwrite($fh"Invalid, unknown, or unworkable transaction received from PayPal - please investigate:\n--------------------------------------------------------------------------------------\n");
fwrite($fh$stringData."\n--------------------------------------------------------------------------------------\n");
fclose($fh);

//send message to admin to look
$mail_sub 'SITENAME Message:  Investigate PayPal transaction received via IPN';
$message "Please review the investigate PayPal transaction log (investigate_paypal_transactions.txt in your root directory). The details are as follows:\n\n".$stringData;

mailSender($config['admin_email'], $config['admin_email'], $config['admin_email'], $mail_sub$message);

// !in_array($txn_type, $ignore_txn_types)

?>


NOTE: Please read through the comments as there are a few things in there that I used for testing but can probably be taken out if you're not testing. The only one that might be slightly dangerous to leave in is the $_POST['test_ipn'] == '1' ||  because a hacker could use this create an IPN simulated test transaction that would upgrade his membership and add days.


functions.php

 NOTE: This is the part that changes any remaining days of their current membership to the new membership. If you don't want this functionality and would rather leave it as is, I don't believe you need to make these changes. However, I haven't tested what happens if you don't. If someone doesn't make these changes, please post back as to what happens.

ANOTHER NOTE: Please pay close attention to this line:

if ( $levelend < time() || $curlevel['level'] == '4') {


The number 4 is the id for 'free.' If this is not the id for your free membership, you must change it to the proper number.

Replace lines 531 - 556 with the following:

Code: [Select]
// determine when this user's membership was to expire, then extend it by $activedays days

if (trim($params['payment_status']) == 'Completed') {
$curlevel = $osDB->getRow( 'select levelend, level from ! where id = ?', array( USER_TABLE, $user_id ) );

$levelend = $curlevel['levelend'];

$diff=$levelend - (time()+0);

$bal_days = round($diff/86400,0);

if ($bal_days == -0) $bal_days=0;

if ( $levelend < time() || $curlevel['level'] == '4') {
$levelend = time();
}

// new expiration date for this member

$levelend = strtotime( "+$activedays day", $levelend );

$osDB->query( 'UPDATE ! SET level = ?, levelend = ? WHERE id = ?', array( USER_TABLE, $user_level, $levelend, $user_id ) );

$osDB->query( 'update ! set payment_email = ?, amount_paid = ?, txn_id = ?, txn_date = ?, payment_vars = ?, payment_status=? where id = ?', array( TRANSACTIONS_TABLE, $params['email'], $params['amount'], $params['txn_id'], date('Y-m-d'), $params['vars'], $params['payment_status'], $params['pay_txn_id'] ) );


 For reference purposes, these links will be helpful for anyone who wants to understand the variables in the script more closely

https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_Appx_websitestandard_htmlvariables#id08A6HI00JQU

https://www.paypal.com/us/cgi-bin/webscr?cmd=p/acc/ipn-subscriptions-outside

https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_IPNandPDTVariables

Regards,
CBG (Garry)
osDate: 2.6.5, 2.7 & Evo
PHP: 5.5.x/5.6.x (5.3.x to 5.6.x) | MySQL: 5.5.34-cll

*

heebeha

  • **
  • 60
  • Me
Re: When will osdate 3.0 be ready to download?
« Reply #13 on: January 26, 2015, 04:36:42 PM »
WOW.  I am using osdate 2.65  Is this all for osdate 2.65 to get it to the PayPal reoccurring module to function correctly?

Anyway you could upload all the updated files in a zip file to assure I don't screw this up?

Thank you so much

*

heebeha

  • **
  • 60
  • Me
Re: When will osdate 3.0 be ready to download?
« Reply #14 on: January 26, 2015, 04:39:31 PM »
I installed this a while back and it does not work.


:(  I need that PayPal reoccurring fix.  Anyone know how to fix it so PayPal payment reoccur and updates the users membership accordingly?

Hi heebeha,

As Pharg said you either best of adding the osDate version into the post or create a signature with the version you use.

Looking back at my save Tufat forum pages, there was a post in November 2009 by brilovett about recurring PayPal payments.
Please note I have note tested this, in one way shape of form.

A general list of functionality:

1.Ability to make one-time and recurring payments

2.Ability for recurring payments to be automatically received from PayPal and add the appropriate additional membership days to the user's account

3.Ability to maintain a transaction log of all transactions received from PayPal (these are called Instant Payment Notifications, or IPN)

4.Ability to automatically send an e-mail to a user when their one-time or recurring payment is declined, with a copy of the e-mail going to the admin

5.Ability to create unique invoice numbers for recurring payments that are tied back to the original payment (S for single, one-time only payments, M for monthly recurring payments, and Y for annually recurring payments; additionally, it increments existing invoice numbers by 1 for recurring payments so you can always see the original invoice it's tied to)

6.Ability to log any transactions that PayPal sends that aren't handled by the script (or that may have been sent by a hacker)

7.Ability to send an automatic email to the admin when a transaction is received that isn't handled by the script so that the admin can investigate further

8.Ability to ignore certain PayPal transactions (e.g., when a user creates a recurring/subscription payment, PayPal sends a transaction that this was created - this transaction can be ignored)
I have done my best to comment the design extensively in the primary script (paypal_ipn.php) to not only make it easier to add enhancements, but also to make it easier to use this as a basis for developing recurring payments with other payment modules.

Though I have tested it extensively, I certainly would appreciate anyone who uses it to post defects. Using PayPal's sandbox, I'm able to simulate quite a few different things. However, the sandbox does not automatically send recurring payment notifications. (You can create simulated transactions using their IPN simulator, and so the best I could do was generate hundreds of simulated tests that should look like the recurring payments.)

Please note that, if a user cancels their OSDate membership but has recurring payments setup through PayPal, these payments will continue unless the user goes into their PayPal account and cancels the subscription. Therefore, you might want to notify the user of this in the cancel.tpl file.

Additionally, for this script, I have changed the way OSDate processes membership changes. You certainly don't have to include those changes. (I did them because I thought it was fairer to the user and enhanced the value offered, even if they got something extra that they didn't pay for.) The way it works is as follows:

If a user has days left on his membership but purchases a different membership (e.g., an upgrade), this script will change the remaining days they had to the new membership level, as well as add on the additional days purchased (e.g., if a user is currently a silver member with 15 remaining days and purchases a gold 30-day membership, once their payment is processed, they will have 45 days at the gold level).
Call it an added bonus for upgrading.

I have placed all of the English text displayed to the user in the various files rather than adding it to the language file. Obviously, it would be better to add it to the language file, but I wanted to make this script somewhat self-contained in case it does not get incorporated into the release. (This would make it easier to continue to use the script as new OSDate versions are released.)

P.S. - For some reason, the word SITENAME in the subject that is emailed to users and the admin doesn't seem to work, but I haven't figured out why yet. It's a small defect, but it's a defect.