xoops forums

stevenbinion

Just popping in
Posted on: 2008/4/30 19:41
stevenbinion
stevenbinion (Show more)
Just popping in
Posts: 10
Since: 2008/3/12
#1

Donations Module SQL Errors under PHP5 & MySQL4

I've used the search feature to no avail searching for "Donation Module"

I am using XOOPS 2.0.18.1 with (paypal) Donations Module v1.4. The website is hosed by GoDaddy's Premium Webhosting Plan for Apache / Linux with PHP5 and MySQL4.1

The problem I am having with the module is that it will not save the edits I make to the configuration.

Here are the errors I receive when trying to update the preferences for the module.

All errors (0queries (37blocks (0extra (0timers (3)
Errors
Queries
SELECT 
FROM xoops_config WHERE (conf_modid '0' AND conf_catid '1'ORDER BY conf_order ASC
SELECT sess_data
sess_ip FROM xoops_session WHERE sess_id 'm2ml637nflhrbsc2aj0kb7c880'
SELECT FROM xoops_users WHERE uid=1
SELECT 
FROM xoops_modules WHERE dirname 'donations'
SELECT FROM xoops_group_permission WHERE (gperm_name 'module_admin' AND gperm_modid '1' AND (gperm_groupid '1' OR gperm_groupid '2'))
SELECT FROM xoops_donations_config WHERE subtype ''
SELECT FROM xoops_donations_config WHERE name 'swing_day'
SELECT FROM xoops_donations_config WHERE name 'dm_title'
SELECT FROM xoops_donations_config WHERE name 'dm_num_don'
SELECT FROM xoops_donations_config WHERE name 'dm_show_date'
SELECT FROM xoops_donations_config WHERE name 'dm_show_amt'
SELECT FROM xoops_donations_config WHERE name 'dm_button'
SELECT FROM xoops_donations_config WHERE name 'dm_img_width'
SELECT FROM xoops_donations_config WHERE name 'dm_img_height'
SELECT FROM xoops_donations_config WHERE name 'goal' AND subtype<>'Default'
SELECT FROM xoops_donations_config WHERE name 'don_button_top'
SELECT FROM xoops_donations_config WHERE name 'don_top_img_width'
SELECT FROM xoops_donations_config WHERE name 'don_top_img_height'
SELECT FROM xoops_donations_config WHERE name 'don_button_submit'
SELECT FROM xoops_donations_config WHERE name 'don_sub_img_width'
SELECT FROM xoops_donations_config WHERE name 'don_sub_img_height'
SELECT FROM xoops_donations_config WHERE name 'don_name_prompt'
SELECT FROM xoops_donations_config WHERE name 'don_name_yes'
SELECT FROM xoops_donations_config WHERE name 'don_name_no'
SELECT FROM xoops_donations_config WHERE name 'don_show_date'
SELECT FROM xoops_donations_config WHERE name 'don_show_amt'
SELECT FROM xoops_donations_config WHERE name 'don_text'
SELECT FROM xoops_donations_config WHERE name 'don_amt_checked'
SELECT FROM xoops_donations_config WHERE name 'don_amount' ORDER BY subtype
SELECT 
FROM xoops_donations_config WHERE name 'receiver_email'
SELECT FROM xoops_donations_config WHERE name 'ty_url'
SELECT FROM xoops_donations_config WHERE name 'pp_cancel_url'
SELECT FROM xoops_donations_config WHERE name 'pp_itemname'
SELECT FROM xoops_donations_config WHERE name 'pp_item_num'
SELECT FROM xoops_donations_config WHERE name 'pp_image_url'
SELECT FROM xoops_donations_config WHERE name 'pp_get_addr'
SELECT FROM xoops_donations_config WHERE name 'ipn_log_entries'
Total37 queries

Catzwolf

Home away from home
Posted on: 2008/4/30 19:47
Catzwolf
Catzwolf (Show more)
Home away from home
Posts: 1392
Since: 2007/9/30
#2

Re: Donations Module SQL Errors under PHP5 & MySQL4

Hiya,

From what I can see these are no errors, but just a list of MySQL queries that we performed during that action. From what I can see there, there were no errors produced at all.

Does the module work as expected with all other saves?

stevenbinion

Just popping in
Posted on: 2008/4/30 19:57
stevenbinion
stevenbinion (Show more)
Just popping in
Posts: 10
Since: 2008/3/12
#3

Re: Donations Module SQL Errors under PHP5 & MySQL4

Wow, a rapid response, I was just on my way back to correct that it was just queries and no errors. I've edited the preferences manual. and the module point correctly to my donor address, I've not yet tested this yet to see if the donation would work or not. As I only have the one paypal account, going to see if my wife will test this for me. I'm concerned that if the settings don't save that the donating users won't get the credit for their donations.

trabis

Core Developer
Posted on: 2008/4/30 22:07
trabis
trabis (Show more)
Core Developer
Posts: 2268
Since: 2006/9/1 1
#4

Re: Donations Module SQL Errors under PHP5 & MySQL4

Try change $xoopsDB->query to $xoopsDB->queryF in all inserts, deletes and updates queries. Take a look at admin/index.php, you will find some.(I have looked in xdonations module...)

stevenbinion

Just popping in
Posted on: 2008/5/1 13:37
stevenbinion
stevenbinion (Show more)
Just popping in
Posts: 10
Since: 2008/3/12
#5

Re: Donations Module SQL Errors under PHP5 & MySQL4

Thank you, I'll give that a shot. Is that F a force flag?

stevenbinion

Just popping in
Posted on: 2008/5/1 14:10
stevenbinion
stevenbinion (Show more)
Just popping in
Posts: 10
Since: 2008/3/12
#6

Re: Donations Module SQL Errors under PHP5 & MySQL4

$xoopsDB->queryF didn't make any difference.

stevenbinion

Just popping in
Posted on: 2008/5/10 16:42
stevenbinion
stevenbinion (Show more)
Just popping in
Posts: 10
Since: 2008/3/12
#7

Re: Donations Module SQL Errors under PHP5 & MySQL4

I'm still trying to fix the xdonations 1.9 module. I'm still useing PHP5 & MySQL4. I'm not getting any errors reported of any kind. It's just the the admin/index.php will not post/update/delete.

below is the code.
<?php
/************************************************************************/
/* Donations - Paypal financial management module for XOOPS 2           */
/* Copyright (c) 2004 by Xoops2 Donations Module Dev Team                */
/* http://dev.xoops.org/modules/xfmod/pr ... ;    */
/* $Id: index.php,v 1.14 2004/10/15 17:54:09 blackdeath_csmc Exp $      */
/************************************************************************/
/*                                                                      */
/* Based on NukeTreasury for PHP-Nuke - by Dave Lawrence AKA Thrash     */
/* NukeTreasury - Financial management for PHP-Nuke                     */
/* Copyright (c) 2004 by Dave Lawrence AKA Thrash                       */
/*                       thrash@fragnastika.com                         */
/*                       thrashn8r@hotmail.com                          */
/*                                                                      */
/************************************************************************/
/*                                                                      */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/*                                                                      */
/* This program is distributed in the hope that it will be useful, but  */
/* WITHOUT ANY WARRANTY; without even the implied warranty of           */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU     */
/* General Public License for more details.                             */
/*                                                                      */
/* You should have received a copy of the GNU General Public License    */
/* along with this program; if not, write to the Free Software          */
/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  */
/* USA                                                                  */
/************************************************************************/

include '../../../include/cp_header.php';
if ( 
file_exists("../language/".$xoopsConfig['language']."/main.php") ) {
    include 
"../language/".$xoopsConfig['language']."/main.php";
} else {
    include 
"../language/english/main.php";
}

require(
"../includes/form.inc");
include(
"../includes/functions.php");
xoops_cp_header();
adminmain();

$tr_config configInfo();
//determine the currency
$PP_CURR_CODE explode('|',$tr_config['pp_curr_code']); // [USD,GBP,JPY,CAD,EUR]
$PP_CURR_CODE $PP_CURR_CODE[0];
$curr_sign define_curr($PP_CURR_CODE);

function 
Treasury() 
{
    global 
$tr_config$xoopsDB$modversion$curr_sign;
    
    
// Register paging
    
$maxRows_Recordset1 10;
    
$pageNum_Recordset1 0;
    if (isset(
$_POST['pageNum_Recordset1'])) {
      
$pageNum_Recordset1 $_POST['pageNum_Recordset1'];
    }
    
$startRow_Recordset1 $pageNum_Recordset1 $maxRows_Recordset1;
    
    
$query_Recordset1 "SELECT id, date, DATE_FORMAT(date, '%d-%b-%Y') as fdate, DATE_FORMAT(date, '%d') as day, DATE_FORMAT(date, '%m') as mon, DATE_FORMAT(date, '%Y') as year, num, name, descr, amount FROM ".$xoopsDB->prefix("donations_financial")." order by date DESC";
    
$query_limit_Recordset1 "$query_Recordset1 LIMIT $startRow_Recordset1$maxRows_Recordset1";
    
$Recordset1 $xoopsDB->query($query_limit_Recordset1);
    
$row_Recordset1 $xoopsDB->fetchArray($Recordset1);
    
    if (isset(
$_POST['totalRows_Recordset1'])) {
      
$totalRows_Recordset1 $_POST['totalRows_Recordset1'];
    } else {
      
$all_Recordset1 $xoopsDB->query($query_Recordset1);
      
$totalRows_Recordset1 $xoopsDB->getRowsNum($all_Recordset1);
    }
    
$totalPages_Recordset1 ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
    
$queryString_Recordset1 "&totalRows_Recordset1=".$totalRows_Recordset1."#AdminTop";

    
// Collect IPN reconcile data
    // First, get the date of the last time we reconciled
    
$query_Recordset2 "SELECT `date` as recdate FROM ".$xoopsDB->prefix("donations_financial")." WHERE name = 'PayPal IPN' ORDER BY date DESC LIMIT 1";
    
$Recordset2 $xoopsDB->query($query_Recordset2);
    
$row_Recordset2 $xoopsDB->fetchArray($Recordset2);
    
$recdate $row_Recordset2['recdate'];
    
    
// Get the date of the last donation
    
$query_Recordset2 "SELECT `payment_date` as curdate FROM ".$xoopsDB->prefix("donations_transactions")." WHERE payment_status = 'Completed' AND (txn_type = 'send_money' OR txn_type = 'web_accept' ) ORDER BY payment_date DESC LIMIT 1";
    
$Recordset2 $xoopsDB->query($query_Recordset2);
    
$row_Recordset2 $xoopsDB->fetchArray($Recordset2);
    
$curdate $row_Recordset2['curdate'];

    
// Collect the IPN transactions between recdate and curdate
    
$query_Recordset2 "SELECT custom, SUM(mc_gross) AS gross, SUM(mc_gross - mc_fee) AS net FROM ".$xoopsDB->prefix("donations_transactions")." WHERE (payment_date > '".$recdate."' AND payment_date <= '".$curdate."') GROUP BY txn_id";
    
$Recordset2 $xoopsDB->query($query_Recordset2);

    
// Iterate over the records skipping the ones that total out to zero(refunds)
    
$ipn_tot 0;
    
$num_ipn 0;
    while( 
$row_Recordset2 $xoopsDB->fetchArray($Recordset2) )
    {
        if( 
$row_Recordset2['gross'] > )
        {
            
$ipn_tot += $row_Recordset2['net'];
            
$num_ipn++;
        }
    }

    
// Get the register balance
    
$query_Recordset4 "SELECT SUM(amount) as total FROM ".$xoopsDB->prefix("donations_financial")."";
    
$Recordset4 $xoopsDB->query($query_Recordset4);
    
$row_Recordset4 $xoopsDB->fetchArray($Recordset4);
    
$total $row_Recordset4['total'];
    
    
// Query to remove the Edit/Delete buttons if no results will be listed.
    
$queryRec "select * from ".$xoopsDB->prefix("donations_financial")."";
    
$RecordsetQ $xoopsDB->query($queryRec);
    
$numRec $xoopsDB->getRowsNum($RecordsetQ);

// Output the page
    
echo "<table border='1' width='90%' align='center'><tr><td>";
    echo 
"<table border="0" cellpadding="0" cellspacing="0" align='center'>";
    echo 
"<tr><td width="100%">";
    echo 
"<center><font class="option"><b>"._DM_TREASURY_F_REGISTER."</b></font></center></td></tr>";
    echo 
"<tr><td width="100%">Number of new IPN records: $num_ipn - Totaling ".$curr_sign.$ipn_tot;
    echo 
"</td></tr>";
    echo 
"<tr><td width="100%" align='center'>";
    echo 
"<form action="index.php?op=IpnRec#AdminTop" method="post">";
    
echo "<input type="hidden" name="op" value="IpnRec">"
        
."<input type="submit" value="PayPal IPN reconcile" onClick="return confirm('This action will total up all recent PayPal IPN" . 'n' . "transactions and post them here in the register." . 'nn' . "Are you sure you want to do this now?')">"
        
."</form>";
    echo 
"</td></tr></table>";

    echo 
"<table border="0" align='center'><tr>";
    if( 
$pageNum_Recordset1 )
    {
        echo 
'<td><form action="index.php#AdminTop" method="post">'
           
'<input type="hidden" name="op" value="Treasury">'
           
'<input type="hidden" name="pageNum_Recordset1" value="0">'
           
'<input type="hidden" name="totalRows_Recordset1" value="' $totalRows_Recordset1 '">'
           
'<input type="submit" name="navig" value="|<" title="Current"></form></td>';
        echo 
'<td><form action="index.php#AdminTop" method="post">'
           
'<input type="hidden" name="op" value="Treasury">'
           
'<input type="hidden" name="pageNum_Recordset1" value="' max(0$pageNum_Recordset1 1) . '">'
           
'<input type="hidden" name="totalRows_Recordset1" value="' $totalRows_Recordset1 '">'
           
'<input type="submit" name="navig" value="<" title="Next newest"></form></td>';
    }
    if( 
$pageNum_Recordset1 $totalPages_Recordset1 )
    {
        echo 
'<td><form action="index.php#AdminTop" method="post">'
           
'<input type="hidden" name="op" value="Treasury">'
           
'<input type="hidden" name="pageNum_Recordset1" value="' min($totalPages_Recordset1$pageNum_Recordset1 1) . '">'
           
'<input type="hidden" name="totalRows_Recordset1" value="' $totalRows_Recordset1 '">'
           
'<input type="submit" name="navig" value=">" title="Next Oldest"></form></td>';
        echo 
'<td><form action="index.php#AdminTop" method="post">'
           
'<input type="hidden" name="op" value="Treasury">'
           
'<input type="hidden" name="pageNum_Recordset1" value="' $totalPages_Recordset1 '">'
           
'<input type="hidden" name="totalRows_Recordset1" value="' $totalRows_Recordset1 '">'
           
'<input type="submit" name="navig" value=">|" title="Oldest"></form></td>';
    }
    echo 
"</tr></table>";
    
    echo 
"<table border="1" width="100%" align="center"><tr>"
    
."<td align="center" width="4"><b>&nbsp;</b></td>"
    
."<td align="center"><b>Date</b></td>"
    
."<td align="center"><b>Num</b></td>"
    
."<td align="center"><b>Name</b></td>"
    
."<td align="center"><b>Description</b></td>"
    
."<td align="center"><b>Amount</b></td></tr><tr>";

    
$row=0;
do {
    
$row += 1;
    echo 
"<tr>"
    
."<td align="center">";
    if(
$numRec!=0){
        echo 
"<A HREF="javascriptvoid 0" onclick=""
        ."
document.recedit.id.value '$row_Recordset1[id]'"
        ."
document.recedit.StartMonth.value '$row_Recordset1[mon]'"
        ."
document.recedit.StartDay.value '$row_Recordset1[day]'"
        ."
document.recedit.StartYear.value '$row_Recordset1[year]'"
        ."
document.recedit.Num.value '$row_Recordset1[num]'"
        ."
document.recedit.Name.value '$row_Recordset1[name]'"
        ."
document.recedit.Descr.value '$row_Recordset1[descr]'"
        ."
document.recedit.Amount.value '$row_Recordset1[amount]'"
        ."
document.recedit.Submit.value 'Modify'"
        ."
document.recedit.op.value 'FinRegEdit'"            
        ."
return false;">"
        
."<img border="0" width="12" height="13" src="../images/admin/treasury_edit.png"></a>&nbsp;"
        
."<a href="index.php?op=FinRegDel&id=$row_Recordset1[id]">"
        
."<img border="0" width="12" height="13" src="../images/admin/treasury_drop.png" onClick="return confirm('Are you sure you want to delete this record?" . 'nn' . "Are you sure you want to do this now?')""
        
."></a>";
    }
    echo 
"</td>"      
    
."<td align="left">$row_Recordset1[fdate]</td>"
    
."<td align="left" width="8">$row_Recordset1[num]</td>"
    
."<td align="left">$row_Recordset1[name]</td>"
    
."<td align="left">$row_Recordset1[descr]</td>"
    
."<td align="right"><font ";
    
$amt =  sprintf("%10.2f",$row_Recordset1['amount']);
    if( 
$amt )
        echo 
"color="#FF0000"";
    
echo ">$curr_sign$amt</font></td></tr>";
} while (
$row_Recordset1 $xoopsDB->fetchArray($Recordset1));

    echo 
"</table><table width="100%" align='center'><tr><td align="right"><b>Net Balance&nbsp;&nbsp;&nbsp;$curr_sign";
    echo 
sprintf("%0.2f"$total) . "&nbsp;</b></td>";
    echo 
"</tr></table>";

    echo 
"<table align='center'><tr>"
    
."<td align="center"><b>Date</b></td>"
    
."<td align="center"><b>Num</b></td>"
    
."<td align="center"><b>Name</b></td>"
    
."<td align="center"><b>Description</b></td>"
    
."<td align="center"><b>Amount</b></td></tr><tr>"
    
."<form action="index.php" method="post" name="recedit">"
    
."<td align="left"><input name="id" type="hidden">";
    
$Form = new FormSolution// 2004-04-02 18:40:55    year-month-day 
    
$Form->DateTimeOptionList('month''C''StartMonth''N'0'N');
    
$Form->DateTimeOptionList('day''C''StartDay''N'0'N');
    
$Form->DateTimeOptionList('year''C','StartYear','N',0,'N',20033'','the_id');
    echo 
"<td align="left" width="8"><input name="Num" type="text" size="8"></td>"
    
."<td align="left"><input name="Name" type="text"></td>"
    
."<td align="left"><input name="Descr" type="text"></td>"
    
."<td align="right"><input name="Amount" type="text" size="8"></td></tr>";
    echo 
"</tr>";
    echo 
"<tr><td align="right" colspan="5">"
    
."<input name="" type="reset" value="Reset" onclick=""
    ."
document.recedit.Submit.value 'Add'"
    ."
document.recedit.op.value 'FinRegAdd'"
    ."
return true;">&nbsp;"
    
."<input type="hidden" name="op" value="FinRegAdd"><input name="Submit" type="submit" value="Add"></td></tr>"
    
."</form>";
    
    echo 
"</table>";
    echo 
"</td></tr></table>";

}

function 
FinancialRegAdd()
{
    global 
$tr_config$modversion$xoopsDB;

    
$time date("h:i:s");
    
$nTime $_POST['StartYear'].'-'.$_POST['StartMonth'].'-'.$_POST['StartDay'].' '.$time;
    
$nTime strtotime($nTime);
    if(
$nTime == -1)
        echo 
"Invalid Date format<br>";
    else
    if( 
strlen($_POST['Name']) == 0)
        echo 
"The Name field cannot be blank<br>";
    else
    if( !
is_numeric($_POST['Amount']))
        echo 
"Invalid Amount field<br>";
    else
    {
        echo 
"Field passed validation!<br>";

        echo 
strftime("%Y-%m-%d"$nTime) . $_POST[Num] $_POST[Name] $_POST[Descr] $_POST[Amount]<br><br>";

        
$insert_Recordset "INSERT INTO `".$xoopsDB->prefix("donations_financial")."` VALUES "
                            
."(NULL, '" strftime("%Y-%m-%d %H:%M:%S"$nTime) . "','" $_POST['Num'] . "','" $_POST['Name']
                            .
"','" $_POST['Descr'] . "','" $_POST['Amount'] . "')";

        echo 
"$insert_Recordset";
        
$rvalue $xoopsDB->queryF($insert_Recordset);

        echo 
strftime("%Y-%m-%d"$nTime) . $_POST[Num] $_POST[Name] $_POST[Descr] $_POST[Amount]<br><br>$insert_Recordset";

        
Header("Location: index.php?op=Treasury#AdminTop");

    }
}    


function 
FinancialRegDel()
{
    global 
$tr_config$modversion$xoopsDB;

    echo 
"Field passed validation!<br>";

    if( !(
is_numeric($_GET['id']) && $_GET['id']>0))
    {
        echo 
"<br>Invalid record id specified, operation aborted<br>";
    } else
    {
        
$del_Recordset "DELETE FROM `".$xoopsDB->prefix("donations_financial")."` WHERE `id`='$_GET[id]' LIMIT 1";
        
$rvalue $xoopsDB->queryF($del_Recordset);

        
Header("Location: index.php?op=Treasury#AdminTop");
    }
}


function 
FinancialRegEdit()
{
    global 
$tr_config$modversion$xoopsDB;

    
$time date("h:i:s");
    
$nTime $_POST['StartYear'].'-'.$_POST['StartMonth'].'-'.$_POST['StartDay'].' '.$time;
    
$nTime strtotime($nTime);
    
//$nTime = strtotime($_POST[Date]);
    
if($nTime == -1)
        echo 
"Invalid Date format<br>";
    else
    if( 
strlen($_POST['Name']) == 0)
        echo 
"The Name field cannot be blank<br>";
    else
    if( !
is_numeric($_POST['Amount']))
        echo 
"Invalid Amount field, do not use any characters other than -.0123456789<br>";
    else
    {
        echo 
"Field passed validation!<br>";

        echo 
strftime("%Y-%m-%d"$nTime) . $_POST[Num] $_POST[Name] $_POST[Descr] $_POST[Amount]<br><br>";

        
$insert_Recordset "UPDATE `".$xoopsDB->prefix("donations_financial")."` SET date='"strftime("%Y-%m-%d %H:%M:%S"$nTime) . "', num='$_POST[Num]', Name='$_POST[Name]', "
                            
."descr='$_POST[Descr]', amount='$_POST[Amount]' WHERE id='$_POST[id]' LIMIT 1";

        echo 
"$insert_Recordset";
        
$rvalue $xoopsDB->queryF($insert_Recordset);

        echo 
"$_POST[id]strftime("%Y-%m-%d"$nTime) . $_POST[Num] $_POST[Name] $_POST[Descr] $_POST[Amount]<br><br>$insert_Recordset";

        
Header("Location: index.php?op=Treasury#AdminTop");

    }
}    


function 
Config()
{
    global 
$tr_config$modversion$xoopsDB;

?>
<script Language="JavaScript">
function isEmailAddr(email)
{
  var result = false;
  var theStr = new String(email);
  var index = theStr.indexOf("@");
  if (index > 0)
  {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
    result = true;
  }
  return result;
}

function validRequired(formField,fieldLabel)
{
    var result = true;
    
    if (formField.value == "")
    {
        alert('Please enter a value for the "' + fieldLabel +'" field.');
        formField.focus();
        result = false;
    }
    
    return result;
}

function allDigits(str)
{
    return inValidCharSet(str,"0123456789");
}

function inValidCharSet(str,charset)
{
    var result = true;

    // Note: doesn't use regular expressions to avoid early Mac browser bugs    
    for (var i=0;i<str.length;i++)
        if (charset.indexOf(str.substr(i,1))<0)
        {
            result = false;
            break;
        }
    
    return result;
}

function validInt(formField,fieldLabel,required)
{
    var result = true;

    if (required && !validRequired(formField,fieldLabel))
        result = false;

     if (result)
     {
//         var num = parseInt(formField.value,10);
         if (!allDigits(formField.value))
         {
            if(required)
            {
                 alert('Please enter a number for the "' + fieldLabel +'" field.');
                formField.focus();        
                result = false;
            }
            else if ( formField.value == "" )
            {
                return true;
            }
            else
             {
                alert('Please enter a number or a blank for the "' + fieldLabel +'" field.');
                formField.focus();        
                result = false;
            }
        }
    } 
    
    return result;
}


function validdateURL(formField, value, secure)
{
    var match = /https/i.test(value);

    if( value != "" && !/^http/i.test(value) ) 
    {
        alert('The URL must start with http://');
        formField.focus();        
        return false;
    }

    if( secure && value != "" && !/^https/i.test(value) ) 
    {
//        alert('This should reside on a HTTPS server.  Users will be warned about viewing secure and non-secure data on the same page');

        return confirm('This URL does not begin with https://nThis image should&n ... sp;use this URL, users will receive a warningnabout viewing secure and non-secure data on the same page.nn  Are you sure you want to continue?');
    }
        
    return true;
}


function checkCancelledURL()
{
    if( document.tr_configs.var_pp_image_url.value == "")
        alert('There is no URL for a Cancelled payment.  If you do not enterna URL for cancelled payments PayPal will also usenthis URL for cancelled payments.');
    return true;
}
</script>
<?php

    
echo '<form name="tr_configs" action="index.php" method="post">'
    
'<input type="hidden" name="op" value="ConfigUpdate">';
    echo 
'<table border='1' width='90%' align='center'><tr><td>';
    echo 
'<center><font class="title"><b>Donations Module Config</b></font></center><br>';
    echo 
'<table border="1" align='center'><tr>';

    
ShowTextBox('don_button_top''<b>Donations page top button</b>''''70''onChange="return validdateURL(this,this.value);"');
    
ShowImgXYBox('don_top_img_width''don_top_img_height''<b>Image dimensions</b>''4''onChange="return validInt(this,'Image Dimension',0);"');
    
ShowTextBox('don_button_submit''<b>Donations page "submit" button</b>''''70''onChange="return validdateURL(this,this.value);"');
    
ShowImgXYBox('don_sub_img_width''don_sub_img_height''<b>Image dimensions</b>''4''onChange="return validInt(this,'Image Dimension',0);"');
    
ShowTextBox('don_name_prompt''<b>Prompt to use username</b>''''70''');
    
ShowTextBox('don_name_yes''<b>Username request: "YES" Response</b>''''50''');
    
ShowTextBox('don_name_no''<b>Username request: "NO" Response</b>''''50''');

    
$desc 'This is where you can appeal to your
users and your community for donations.
Suggestion: Explain why you need donations, 
what you do with the money and how you
manage it. Make them comfortable that
they are not throwing their money away.'
;

    
$sql "SELECT * FROM ".$xoopsDB->prefix("donations_config")." WHERE name = 'don_text'";
    
$Recordset $xoopsDB->query($sql);
    
$row $xoopsDB->fetchArray($Recordset);
    
$DON_TEXT $row['text'];
    echo 
'<tr>'
    
."<td title="$desc" align="right"><b>Donations page text</b></td>"
    
."<td title="$desc" align="left">"
    
."<textarea name="var_don_text-rawtext-txt" cols="100" rows="20">$DON_TEXT</textarea></td></tr>";

    
ShowTextBox('don_amt_checked''<b>Which donation amount below<br>is checked by default?</b>''''4''onChange="return validInt(this,'Donation Default',1);"');

    echo 
'</table><br>';

    
$query_Recordset1 "SELECT * FROM ".$xoopsDB->prefix("donations_config")." WHERE name = 'don_amount' ORDER BY subtype";
    
$Recordset1 $xoopsDB->query($query_Recordset1);
    
$row_Recordset1 $xoopsDB->fetchArray($Recordset1);
    
$totalRows_Recordset1 $xoopsDB->getRowsNum($Recordset1);
    
$desc htmlentities($row_Recordset1['text']);
    
    echo 
'<table border="1" width="100" align='center'>';
    echo 
'<tr><td align='center' width='100%' colspan='8'><b>Suggested Donation amounts</b></td></tr><br>';
    
$row1 '<tr><td title="' $desc '" align="center"><b></b></td>';
    
$row2 '<tr><td title="' $desc '" align="center"><b>Amount</b></td>';
    do {
        
$row1 .= "<td title="$desc" align="center">$row_Recordset1[subtype]</td>";
        
$row2 .= "<td title="$desc" align="center"><input size="4" name="var_don_amount-$row_Recordset1[subtype]" type="text" value="$row_Recordset1[value]" onChange="return validInt(this,'Suggested Donation Amount #$row_Recordset1[subtype]',1);"></td>";
    }
    while (
$row_Recordset1 $xoopsDB->fetchArray($Recordset1));
    
$row1 .= '</tr>';
    
$row2 .= '</tr>';
    echo 
"$row1 $row2";

    echo 
'</table><br>';
    echo 
'<tr><td align='center' width='100%'><input type="submit" value="Submit"></td></tr>';
    echo 
'</td></tr></table><br><br>';
    echo 
'<table border='1' width='90%' align='center'><tr><td>';
    echo 
'<center><font class="title"><b>PayPal Configuration</b></font></center><br>';
    echo 
'<table border="1" align='center'><tr>';

    
$rsql "SELECT rank_id, rank_title FROM ".$xoopsDB->prefix('ranks')."";
    
$rresult $xoopsDB->query($rsql);
    
$r_array = array();
    while( 
$r_row $xoopsDB->fetchRow($rresult) ){
        
$r_array[] = $r_row;
    }
    
ShowDropBox('paypal_url''<b>Please choose which Paypal IPN url you will use.</b>''''''');
    
ShowTextBox('receiver_email''<b>PayPal Receiver Email</b>''''40''');
    
ShowTextBox('ty_url'"<b>URL for Donation 'Thank You'</b>"'''80''onChange="checkCancelledURL(); return validdateURL(this,this.value);"');
    
ShowTextBox('pp_cancel_url''<b>URL for cancelled donation</b>''''80''onChange="return validdateURL(this,this.value);"');
    
ShowTextBox('pp_itemname''<b>PayPal Item Name</b>''''20''');
    
ShowTextBox('pp_item_num''<b>PayPal Item Number</b>''''20''');
    
ShowTextBox('pp_image_url''<b>URL of image to display in PayPal</b>''''60''');
    
ShowYNBox('pp_get_addr''<b>Ask user for postal address</b>''''''');
    
ShowDropBox('pp_curr_code''<b>Choose your currency</b>''''''');
    
$gsql "SELECT groupid, name FROM ".$xoopsDB->prefix('groups')." WHERE groupid>3";
    
$gresult $xoopsDB->query($gsql);
    
$g_array = array();
    while( 
$g_row $xoopsDB->fetchRow($gresult) ){
        
$g_array[] = $g_row;
    }
    
ShowArrayDropBox('assign_group''<b>Select a Group to assign donators to.</b>'''''''$g_array);
    
$rsql "SELECT rank_id, rank_title FROM ".$xoopsDB->prefix('ranks')."";
    
$rresult $xoopsDB->query($rsql);
    
$r_array = array();
    while( 
$r_row $xoopsDB->fetchRow($rresult) ){
        
$r_array[] = $r_row;
    }
    
ShowArrayDropBox('assign_rank''<b>Select a Rank to assign donators to.</b>'''''''$r_array);

    echo 
'</table><br>';
    
    echo 
'<table border="1" width="100" align="center">';
    echo 
'<tr><td align="center" width="100%" colspan="2"><b>IPN Logging Options</b></td></tr><br>';
    echo 
'<tr>'
    
.'<td align="right"><b>Logging level</b></td>'
    
.'<td align="left">'
    
.'<select size="1" name="var_ipn_dbg_lvl">';
    echo 
'<option ' ;
    if(
$tr_config['ipn_dbg_lvl']==0) echo "selected ";
    echo 
'value="0">Off</option>';
    echo 
'<option ' ;
    if(
$tr_config['ipn_dbg_lvl']==1) echo "selected ";
    echo 
'value="1">Only log errors</option>';
    echo 
'<option ' ;
    if(
$tr_config['ipn_dbg_lvl']==2) echo "selected ";
    echo 
'value="2">Log everything</option>';
    echo 
'</select></td></tr>';
    
    
ShowTextBox('ipn_log_entries''<nobr><b>Keep this many log entries</b></nobr>''''4''');

    
    
$desc 'This box shows the link to the IPN recorder.
    This link must be pasted EXACTLY as it is
    into your PayPal IPN profile.  You can click
    on the "test" link to the right to verify
    that the IPN recorder is functioning correctly.'
;
    
$desc htmlentities($desc);
    echo 
'<tr>'
     
."<td title ="$desc" align="right"><b>IPN link for PayPal</b></td>"
     
."<td title ="$desc" align="left">&nbsp;".XOOPS_URL."/modules/xdonations/ipnppd.php&nbsp;&nbsp;<br><a href="".XOOPS_URL."/modules/xdonations/ipnppd.php?dbg=1" target="_blank"><b><i>Click here to test IPN</i></b></a></td>"
     
'</td></tr>';
    echo 
'</table><br>';
    echo 
'<tr><td align='center' width='100%'><input type="submit" value="Submit"></td></tr>';
    echo 
'</td></tr></table><br><br>';

    echo 
'<table border='1' width='90%' align='center'><tr><td>';
    echo 
'<center><font class="title"><b>Goal Preferences</b></font></center><br>';
    echo 
'<table border="1" align='center'><tr>';

    echo 
'<table border="1" align="center">';
    
ShowDropBox('use_goal''<b>Choose which goal type you would like to use.</b>''''''');
    echo 
'</table>';

    
$query_Recordset1 "SELECT * FROM ".$xoopsDB->prefix("donations_config")." WHERE name = 'week_goal' AND subtype<>'Default'";
    
$Recordset1 $xoopsDB->query($query_Recordset1);
    
$row_Recordset1 $xoopsDB->fetchArray($Recordset1);
    
$totalRows_Recordset1 $xoopsDB->getRowsNum($Recordset1);
    
$desc htmlentities($row_Recordset1['text']);

    echo 
'<table border="1" width="100" align='center'>';
    echo 
'<tr><td align='center' width='100%' colspan='13'><b>Donation goals by week (4 weeks in a month)</b></td></tr><br>';
    
$row1 '<tr><td align="center"><b>Week</b></td>';
    
$row2 '<tr><td align="center"><b>Goal</b></td>';
    do {
        
$row1 .= "<td title="$desc" align="center">$row_Recordset1[subtype]</td>";
        
$row2 .= "<td title="$desc" align="center"><input size="4" name="var_week_goal-$row_Recordset1[subtype]" type="text" value="$row_Recordset1[value]" onChange="return validInt(this,'$row_Recordset1[subtype] Donation Goal',1);"></td>";
    }
    while (
$row_Recordset1 $xoopsDB->fetchArray($Recordset1));
    
$row1 .= '</tr>';
    
$row2 .= '</tr>';
    echo 
"$row1 $row2";

    echo 
'</table>';

    
$query_Recordset1 "SELECT * FROM ".$xoopsDB->prefix("donations_config")." WHERE name = 'month_goal' AND subtype<>'Default'";
    
$Recordset1 $xoopsDB->query($query_Recordset1);
    
$row_Recordset1 $xoopsDB->fetchArray($Recordset1);
    
$totalRows_Recordset1 $xoopsDB->getRowsNum($Recordset1);
    
$desc htmlentities($row_Recordset1['text']);

    echo 
'<table border="1" width="100" align='center'>';
    echo 
'<tr><td align='center' width='100%' colspan='13'><b>Donation goals by month</b></td></tr><br>';
    
$row1 '<tr><td align="center"><b>Month</b></td>';
    
$row2 '<tr><td align="center"><b>Goal</b></td>';
    do {
        
$row1 .= "<td title="$desc" align="center">$row_Recordset1[subtype]</td>";
        
$row2 .= "<td title="$desc" align="center"><input size="4" name="var_month_goal-$row_Recordset1[subtype]" type="text" value="$row_Recordset1[value]" onChange="return validInt(this,'$row_Recordset1[subtype] Donation Goal',1);"></td>";
    }
    while (
$row_Recordset1 $xoopsDB->fetchArray($Recordset1));
    
$row1 .= '</tr>';
    
$row2 .= '</tr>';
    echo 
"$row1 $row2";

    echo 
'</table>';
    echo 
'<table border="1" width="100" align='center'>';
    
ShowTextBox('swing_day''<b>Month Swing Day</b>''175''4''onChange="return validInt(this,'Swing Day',1);"');
    echo 
'</table>';

    
$query_Recordset1 "SELECT * FROM ".$xoopsDB->prefix("donations_config")." WHERE name = 'quarter_goal' AND subtype<>'Default'";
    
$Recordset1 $xoopsDB->query($query_Recordset1);
    
$row_Recordset1 $xoopsDB->fetchArray($Recordset1);
    
$totalRows_Recordset1 $xoopsDB->getRowsNum($Recordset1);
    
$desc htmlentities($row_Recordset1['text']);

    echo 
'<table border="1" width="100" align='center'>';
    echo 
'<tr><td align='center' width='100%' colspan='13'><b>Donation goals by quarter</b></td></tr><br>';
    
$row1 '<tr><td align="center"><b>Quarter</b></td>';
    
$row2 '<tr><td align="center"><b>Goal</b></td>';
    do {
        
$row1 .= "<td title="$desc" align="center">$row_Recordset1[subtype]</td>";
        
$row2 .= "<td title="$desc" align="center"><input size="4" name="var_quarter_goal-$row_Recordset1[subtype]" type="text" value="$row_Recordset1[value]" onChange="return validInt(this,'$row_Recordset1[subtype] Donation Goal',1);"></td>";
    }
    while (
$row_Recordset1 $xoopsDB->fetchArray($Recordset1));
    
$row1 .= '</tr>';
    
$row2 .= '</tr>';
    echo 
"$row1 $row2";

    echo 
'</table><br>';
    echo 
'<tr><td align='center' width='100%'><input type="submit" value="Submit"></td></tr>';
    echo 
'</td></tr></table>';
    echo 
'</form>';
}


function 
ConfigUpdate()
{
    global 
$tr_config$modversion$xoopsDB;

    echo 
"<br><font color="#0000FF"><b>If you see this screen then an SQL error was encountered</b></br>"
       
"You should see a message in <font color="#FF0000">RED</font> below indicating what the error is</font><br><br>";
    
$ERR 1;
    
$ilog="";

    
$ilog .= "<br>";

    foreach( 
$_POST as $option => $value )
    {
        
/// Look for form variables
        
if( preg_match("/var_/",$option))
        { 
            
$varnm preg_replace("/var_/","",$option);
            
// Check for subtype field
            
            
if( preg_match("/-(.*)/",$varnm,$subtype) )
            {
                echo 
"<br>subtype = $subtype[1] <br>";
                
$temp $varnm;
                
$varnm preg_replace("/-.*/","",$temp);
                
// Is this is a text field?
                
if( preg_match("/([^-]*)-txt/",$subtype[1], $subtype2) )
                {
                    if (!
get_magic_quotes_gpc()) {
                       
$textarea addslashes($value);
                    } else {
                       
$textarea $value;
                    }
                    
                    echo 
"$varnm $subtype2[1] text=> " nl2br(htmlspecialchars($textarea)) . "<br>";
                    
$ERR &= UpdateDb($varnm$subtype2[1], "0"$textarea);
                } else {
                    echo 
"$varnm $subtype[1] => $value<br>";
                    
$ERR &= UpdateDbShort($varnm$subtype[1], $value"");
                }
            } else
            {
                echo 
"$varnm => $value<br>";
                
$ERR &= UpdateDbShort($varnm""$value"");
            }
        }
    }

    
// If there were no errors
    
if( $ERR == )
        
Header("Location: index.php?op=Config#AdminTop");
}

function 
IpnRec()
{
    global 
$tr_config$modversion$xoopsDB$curr_sign;
    
$query_Recordset1 "select `date` as recdate from ".$xoopsDB->prefix("donations_financial").""
    
." where name='PayPal IPN' order by date desc limit 1";
    
$Recordset1 $xoopsDB->query($query_Recordset1);
    
$row_Recordset1 $xoopsDB->fetchArray($Recordset1);
    if(
$row_Recordset1){
        
$recdate "payment_date > '".$row_Recordset1['recdate']."' and";
    }else{
        
$recdate '';
    }

    
$query_Recordset1 "select `payment_date` as curdate from ".$xoopsDB->prefix("donations_transactions").""
    
." where payment_status='Completed' and (txn_type='send_money' or txn_type='web_accept')"
    
." order by payment_date desc limit 1";
    
$Recordset1 $xoopsDB->query($query_Recordset1);
    
$row_Recordset1 $xoopsDB->fetchArray($Recordset1);
    
$curdate $row_Recordset1['curdate'];
    
$query_Recordset1 "select sum(mc_gross - mc_fee) as ipn_total, count(*) as numrecs"
    
." from ".$xoopsDB->prefix("donations_transactions")." where ($recdate payment_date <= '$curdate')"
    
." and payment_status = 'Completed' and (txn_type='send_money' or txn_type='web_accept')";
    
$Recordset1 $xoopsDB->query($query_Recordset1);
    
$row_Recordset1 $xoopsDB->fetchArray($Recordset1);

    echo 
"<center><font class="title"><b>Update register with PayPal IPN</b></font></center><br><br>";
    if( 
$row_Recordset1['numrecs'] == )
        echo 
"There are no new IPN records to import! ";
    else
    {
        
$insert_set "INSERT INTO `".$xoopsDB->prefix("donations_financial")."` (`date`,`num`,`name`,`descr`,`amount`) VALUES ('$curdate','','PayPal IPN','Auto-Reconcile','".$row_Recordset1['ipn_total']."')";

        if(
$xoopsDB->queryF($insert_set))
            echo 
"<b>$row_Recordset1[numrecs]</b> IPN records have been imported for a total of $curr_signsprintf("%0.2f"$row_Recordset1['ipn_total']);
        else
            echo 
"<b> ERROR : There are $row_Recordset1[numrecs] to import, but there was an<br>"
                
."error encoutered during db record insertion into Financial table.  Insertion<br>" 
                
."FAILED";
    }
        
    echo 
"<br><br><form action="index.php?op=Treasury#AdminTop" method="post">";
    
echo "<input type="hidden" name="op" value="Treasury">"
        
."<input type="submit" value="Return"">"
        ."
</form>";


}

function adminmain() {
    global 
$tr_config$modversion$xoopsDB;

    echo "
<table align='center' border='1' cellpadding='2' cellspacing='2' width='90%'>n";
    echo "
<tr>n";
    echo "
<td align='center' width='50%'><a href='index.php?op=Treasury'>Treasury</a></td>n";
    echo "
<td align='center' width='50%'><a href='index.php?op=Config'>Config</a></td>n";
    echo "
</tr>n";
    echo "
</table>n";
    echo "
<br>";
}

if(!isset(
$HTTP_POST_VARS['op'])) {
    
$op = isset($_GET['op']) ? $_GET['op'] : 'Treasury';
} else {
    
$op = $_POST['op'];
}
Switch(
$op
{
    default:
    case "
Treasury":
        Treasury();
        break;
    
    case "
FinRegAdd":
        FinancialRegAdd();
        break;
        
    case "
FinRegEdit":
        FinancialRegEdit();
        break;
        
    case "
FinRegDel":
        FinancialRegDel();
        break;
        
    case "
Config":
        Config();
        break;
        
    case "
ConfigUpdate":
        ConfigUpdate();
        break;

    case "
IpnRec":
        IpnRec();
        break;
}
xoops_cp_footer();

?>

stevenbinion

Just popping in
Posted on: 2008/5/11 0:17
stevenbinion
stevenbinion (Show more)
Just popping in
Posts: 10
Since: 2008/3/12
#8

Re: Donations Module SQL Errors under PHP5 & MySQL4

Just got done checking the admin/index.php to make sure that $_post & $_get are not set as globals. They are not. so this isn't the issue.

stevenbinion

Just popping in
Posted on: 2008/5/29 17:43
stevenbinion
stevenbinion (Show more)
Just popping in
Posts: 10
Since: 2008/3/12
#9

Re: Donations Module SQL Errors under PHP5 & MySQL4

I've tried using Method="POST" rather then method="post" and I've also replace all entries of $_GET with $_POST. I'm still getting no closer the donations working with PHP5.

stevenbinion

Just popping in
Posted on: 2008/5/30 13:36
stevenbinion
stevenbinion (Show more)
Just popping in
Posts: 10
Since: 2008/3/12
#10

Re: Donations Module SQL Errors under PHP5 & MySQL4

All right, in a despirate move I change my server from php4 rather then php5 now the donations module seems to work just fine, the settings save, which means the donations can be made correctly to me. however. IPN Reconsile is not adding the donation to the list in the treasure so the donors can get credit.

I've even tried using the same email for the donors module as I have in XOOPS admin email address.

and I double checked the url in the IPN config at paypal.com