Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Nuke Treasury
Author Message
akrantz
New Member
New Member



Joined: Oct 01, 2009
Posts: 13

PostPosted: Sat Oct 03, 2009 5:11 pm Reply with quote

Hi!

I have finally got the treasury installed and it works fine donating (took me many hours lol).

Now i need help with some configurations! In the donatometer.html it shows the rows $DM_GOAL, $DM_LEFT etc...

I´ve made some "try donations" but they dont show up! Also, the text shows up like for example $DM_GOAL on the website! How do i fix this?

Regards
/
AKrantz
 
View user's profile Send private message
akrantz







PostPosted: Wed Oct 07, 2009 12:58 am Reply with quote

No replys!

I guess either no one knows or its to obvious what i haft to do so no one answers lol!

No but seriously I need help with this!

The thing is that i know that the ipn is correct (i can see the transaction messages in ipn history - paypal).

It seems like MySQL and treasury/config.inc.php isnt communicating.....Since in the database the goals are set, but does not show up in the html page! It shows up as $DM_GOAL but should show up as for example $100
 
Dawg
RavenNuke(tm) Development Team



Joined: Nov 07, 2003
Posts: 928

PostPosted: Wed Oct 07, 2009 3:27 am Reply with quote

There are about 500 version of treasury in the world....To know which one you are using is the first problem.

Second....
What version of RN are you using?

Third....
I have a feeling that the issue is with the OLD database connections....
Try this...


Look in mainfile.php and uncomment these two lines....

Code:
 * The following two lines of code were moved and commented out in RN 2.30.00 to "test the waters" on

 * finding out what old modules/blocks/hacks/etc. are still using this SQL layer that is so
 * old it should be obsoleted.  If you really need these back, uncomment them back.  We will keep this
 * code this way for one more major release as well as keep the includes/sql_layer.php script.
 */
@require_once(INCLUDE_PATH.'includes/sql_layer.php');
$dbi = sql_connect($dbhost, $dbuname, $dbpass, $dbname);



If that works what you really need to do is this.... [ Only registered users can see links on this board! Get registered or login! ]

Dawg
 
View user's profile Send private message
akrantz







PostPosted: Wed Oct 07, 2009 5:02 am Reply with quote

Dawg thanks for your reply!

This might be good; NukeTreasuryV1.1 is the one im having problems with!

And the problem is thay it seems like MySQL and treasury/config.inc.php isnt communicating.....Since in the database the goals are set, but does not show up in the html page! It shows up as $DM_GOAL but should show up as for example $100
 
duck
Involved
Involved



Joined: Jul 03, 2006
Posts: 273

PostPosted: Wed Oct 07, 2009 12:02 pm Reply with quote

Sounds to me like your code has error. Post code of file for a look.
 
View user's profile Send private message
akrantz







PostPosted: Wed Oct 07, 2009 12:13 pm Reply with quote

The file that i think is causing this problem is treasury.php

Im guessing that it has something to do with either the gathering of data from MySQL or problems with ipnppd settings.

Heres the code for treasury.php
Code:


<?php
/************************************************************************/
/* 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                                                                  */
/* Upgraded and cleaned up by Telli http://codezwiz.com                 */
/************************************************************************/

if (!eregi("admin.php", $_SERVER['PHP_SELF'])) { die ("Access Denied"); }
$result = sql_query("select radminsuper from ".$prefix."_authors where aid='$aid'", $dbi);
list($radminsuper) = sql_fetch_row($result, $dbi);

if ( !$radminsuper == 1 )
{
    echo "Access Denied";
}


function Treasury()
{
    global $admin, $bgcolor2, $prefix, $dbi, $currentlang, $multilingual;
    include ("header.php");
   include("http://www.iforclan.net/Donation-stats/html/modules/Donations/config.inc.php");
   
   if( !$ipnppd )
   {
      echo "<br><br>NukeTreasury FATAL ERROR: Unable to connect to SQL database.  Please check your settings in modules/Donations/config.inc.php<br><br>";
      return;
   }      

   $currentPage = $HTTP_SERVER_VARS["PHP_SELF"];
   
   // Register paging
   $maxRows_Recordset1 = 10;
   $pageNum_Recordset1 = 0;
   if (isset($_POST['pageNum_Recordset1'])) {
     $pageNum_Recordset1 = $_POST['pageNum_Recordset1'];
   }
   $startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;
   
   mysql_select_db($database_ipnppd, $ipnppd);
   $query_Recordset1 = "SELECT id, date, DATE_FORMAT(date, '%d-%b-%Y') as fdate, num, name, descr, amount FROM financial order by date DESC";
   $query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
   $Recordset1 = mysql_query($query_limit_Recordset1, $ipnppd) or die(mysql_error());
   $row_Recordset1 = mysql_fetch_assoc($Recordset1);
   
   if (isset($_POST['totalRows_Recordset1'])) {
     $totalRows_Recordset1 = $_POST['totalRows_Recordset1'];
   } else {
     $all_Recordset1 = mysql_query($query_Recordset1);
     $totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
   }
   $totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
   $queryString_Recordset1 = sprintf("&totalRows_Recordset1=%d#AdminTop", $totalRows_Recordset1);

   // Collect IPN reconcile data
   // First, get the date of the last time we reconciled
   $query_Recordset2 = 'SELECT `date` as recdate'
        . ' FROM financial'
        . ' WHERE name = \'PayPal IPN\''
        . ' ORDER BY date DESC '
        . ' LIMIT 1 ';
   $Recordset2 = mysql_query($query_Recordset2, $ipnppd) or die(mysql_error());
   $row_Recordset2 = mysql_fetch_assoc($Recordset2);
   $recdate = $row_Recordset2[recdate];
   
   // Get the date of the last donation
   $query_Recordset2 = 'SELECT `payment_date` as curdate'
        . ' FROM transactions'
        . ' WHERE payment_status = \'Completed\' AND ( transactions.txn_type = \'send_money\' OR transactions.txn_type = \'web_accept\' )'
        . ' ORDER BY payment_date DESC '
        . ' LIMIT 1 ';
   $Recordset2 = mysql_query($query_Recordset2, $ipnppd) or die(mysql_error());
   $row_Recordset2 = mysql_fetch_assoc($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 transactions '
      . ' WHERE ( payment_Date > \'' . $recdate . '\' AND payment_date <= \'' . $curdate . '\' ) '
      . ' GROUP  BY txn_id ';
   $Recordset2 = mysql_query($query_Recordset2, $ipnppd) or die(mysql_error());

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

   // Get the register balance
   $query_Recordset4 = "SELECT SUM(amount) as total FROM financial";
   $Recordset4 = mysql_query($query_Recordset4, $ipnppd) or die(mysql_error());
   $row_Recordset4 = mysql_fetch_assoc($Recordset4);
   $total = $row_Recordset4[total];

   // Output the page
    GraphicAdmin();
   echo "<a name=\"AdminTop\"></a>";
    OpenTable();
    echo "<center><font class=\"title\"><b>Treasury Administration</b></font></center>";
    CloseTable();
    echo "<br>";
    OpenTable();
    echo "<center><font class=\"option\"><b>Treasury Financial Register</b></font></center><br>";

    echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
    echo "<tr><td width=\"100%\">";
   echo "<form action=\"admin.php?op=Config#AdminTop\" method=\"post\">";
   echo "<input type=\"hidden\" name=\"op\" value=\"Config\"><input type=\"submit\" value=\"Config\"></form>";
   echo "</td></tr>";

    echo "<tr><td width=\"100%\">";
   echo "Number of new IPN records: $num_ipn - Totaling \$$ipn_tot";
   echo "</td></tr>";
    echo "<tr><td width=\"100%\">";
   echo "<form action=\"admin.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." . '\n\n' . "Are you sure you want to do this now?')\">"
      ."</form>";
   echo "</td></tr></table>";

$currentPage = "admin.php?op=Treasury";
   echo "<center><table border=\"0\"><tr>";
   if( $pageNum_Recordset1 > 0 )
   {
      echo '<td><form action="admin.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="|&lt;" title="Current"></form></td>';
      echo '<td><form action="admin.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="&lt;" title="Next newest"></form></td>';
   }
   if( $pageNum_Recordset1 < $totalPages_Recordset1 )
   {
      echo '<td><form action="admin.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="&gt;" title="Next Oldest"></form></td>';
      echo '<td><form action="admin.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="&gt;|" title="Oldest"></form></td>';
   }
   echo "</tr></table></center>";
   
    echo "<table border=\"1\" width=\"100%\" align=\"center\"><tr>"
    ."<td bgcolor=\"$bgcolor2\" align=\"center\" width=\"4\"><b>&nbsp;</b></td>"
    ."<td bgcolor=\"$bgcolor2\" align=\"center\"><b>Date</b></td>"
    ."<td bgcolor=\"$bgcolor2\" align=\"center\"><b>Num</b></td>"
    ."<td bgcolor=\"$bgcolor2\" align=\"center\"><b>Name</b></td>"
    ."<td bgcolor=\"$bgcolor2\" align=\"center\"><b>Decsription</b></td>"
    ."<td bgcolor=\"$bgcolor2\" align=\"center\"><b>Amount</b></td></tr><tr>";

   $row=0;
do {
   $row += 1;
    echo "<tr>"
       ."<td align=\"center\">"
        ."<A HREF=\"javascript: void 0\" onclick=\""
          ."document.recedit.id.value = '$row_Recordset1[id]'; "
          ."document.recedit.Date.value = '$row_Recordset1[fdate]'; "
          ."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=\"admin.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?" . '\n\n' . "Are you sure you want to do this now?')\""
      ."></a></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 < 0 )
      echo "color=\"#FF0000\"";
   echo ">\$$amt</font></td></tr>";
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));

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

    echo "<table><tr>"
       ."<td bgcolor=\"$bgcolor2\" align=\"center\"><b>Date</b></td>"
       ."<td bgcolor=\"$bgcolor2\" align=\"center\"><b>Num</b></td>"
       ."<td bgcolor=\"$bgcolor2\" align=\"center\"><b>Name</b></td>"
       ."<td bgcolor=\"$bgcolor2\" align=\"center\"><b>Description</b></td>"
       ."<td bgcolor=\"$bgcolor2\" align=\"center\"><b>Amount</b></td></tr><tr>"
      ."<form action=\"admin.php\" method=\"post\" name=\"recedit\">"
        ."<td align=\"left\" width=\"8\"><input name=\"id\" type=\"hidden\">"
        ."<input name=\"Date\" type=\"text\" size=\"11\"></td>"
        ."<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>";

    CloseTable();
    echo "<br>";

    include("footer.php");
   mysql_free_result($Recordset1);

}

function FinancialRegAdd()
{
    global $admin, $bgcolor2, $prefix, $dbi, $currentlang, $multilingual;
    include ("header.php");
   include("http://www.iforclan.net/Donation-stats/html/modules/Donations/config.inc.php");

   $ipnppd = mysql_pconnect($hostname_ipnppd, $username_ipnppd, $password_ipnppd) or die(mysql_error());

    GraphicAdmin();
    OpenTable();
    echo "<center><font class=\"title\"><b>Treasury Record add</b></font></center>";
    CloseTable();
    echo "<br>";
    OpenTable();

   $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<br>";
   else
   {
      echo "Field passed validation!<br>";

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

      mysql_select_db($database_ipnppd, $ipnppd);
      $insert_Recordset = "INSERT INTO  `financial` VALUES "
                     ."(NULL, '" . strftime("%Y-%m-%d", $nTime) . "','" . $_POST[Num] . "','" . $_POST[Name]
                     ."','" . $_POST[Descr] . "','" . $_POST[Amount] . "')";

      echo "$insert_Recordset";
      $rvalue = mysql_query($insert_Recordset, $ipnppd) or die(mysql_error());

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

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

   }
}   


function FinancialRegDel()
{
    global $admin, $bgcolor2, $prefix, $dbi, $currentlang, $multilingual;
    include ("header.php");
   include("http://www.iforclan.net/Donation-stats/html/modules/Donations/config.inc.php");

   $ipnppd = mysql_pconnect($hostname_ipnppd, $username_ipnppd, $password_ipnppd) or die(mysql_error());

    GraphicAdmin();
    OpenTable();
    echo "<center><font class=\"title\"><b>Treasury Record Delete</b></font></center>";
    CloseTable();
    echo "<br>";
    OpenTable();

   echo "Field passed validation!<br>";

   mysql_select_db($database_ipnppd, $ipnppd);

   if( !(is_numeric($_GET[id]) && $_GET[id]>0))
   {
      echo "<br>Invalid record id specified, operation aborted<br>";
   } else
   {
      $del_Recordset = "DELETE FROM `financial` WHERE `id`='$_GET[id]' LIMIT 1";
      $rvalue = mysql_query($del_Recordset, $ipnppd) or die(mysql_error());

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


function FinancialRegEdit()
{
    global $admin, $bgcolor2, $prefix, $dbi, $currentlang, $multilingual;
    include ("header.php");
   include("http://www.iforclan.net/Donation-stats/html/modules/Donations/config.inc.php");

   $ipnppd = mysql_pconnect($hostname_ipnppd, $username_ipnppd, $password_ipnppd) or die(mysql_error());

    GraphicAdmin();
    OpenTable();
    echo "<center><font class=\"title\"><b>Treasury Record Edit</b></font></center>";
    CloseTable();
    echo "<br>";
    OpenTable();

//    echo "$_POST[Date] $_POST[Num] $_POST[Name] $_POST[Descr] $_POST[Amount]<br><br>";
   $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>";

      mysql_select_db($database_ipnppd, $ipnppd);
      $insert_Recordset = "UPDATE `financial` SET date='". strftime("%Y-%m-%d", $nTime) . "', num='$_POST[Num]', Name='$_POST[Name]', "
                     ."descr='$_POST[Descr]', amount='$_POST[Amount]' WHERE id='$_POST[id]' LIMIT 1";

      echo "$insert_Recordset";
      $rvalue = mysql_query($insert_Recordset, $ipnppd) or die(mysql_error());

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

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

   }
}   


function SelectYN($nm, $val)
{
   echo '<select size="1" name="' . $nm . '">';
   if( $val )
   {
      echo '<option selected value="1">Yes</option>'
      . '<option value="0">No</option>';
   } else {
      echo '<option value="1">Yes</option>'
      . '<option selected value="0">No</option>';
   }   
   echo '</select>';
}


function ShowYNBox($name, $desc, $tdWidth, $inpSize, $inpJava)
{
   global $ipnppd, $bgcolor2;
   
   $query_cfg = "SELECT * FROM config WHERE name = '$name'";
   $cfgset = mysql_query($query_cfg, $ipnppd);
   if( !$cfgset )
      return;

   $cfg = mysql_fetch_assoc($cfgset);
   $text = htmlentities($cfg[text]);
    echo "<tr>"
    ."<td title=\"$text\" bgcolor=\"$bgcolor2\" align=\"right\">$desc</td>"
    ."<td title=\"$text\" align=\"left\">";
   echo '<select size="1" name="var_' . $name . '">';
   if( $cfg[value] )
   {
      echo '<option selected value="1">Yes</option>'
      . '<option value="0">No</option>';
   } else {
      echo '<option value="1">Yes</option>'
      . '<option selected value="0">No</option>';
   }   
   echo '</select>';
//   SelectYN("var_dm_show_date", $tr_config[dm_show_date]);
}


function ShowTextBox($name, $desc, $tdWidth, $inpSize, $inpJava)
{
   global $ipnppd, $bgcolor2;
   
   $query_cfg = "SELECT * FROM config WHERE name = '$name'";
   $cfgset = mysql_query($query_cfg, $ipnppd);
   if( !$cfgset )
      return;
   $cfg = mysql_fetch_assoc($cfgset);
   $text = htmlentities($cfg[text]);
    echo "<tr>"
    ."<td title=\"$text\" bgcolor=\"$bgcolor2\" align=\"right\" width=\"$tdWidth\">$desc</td>"
    ."<td title=\"$text\" align=\"left\">"
   ."<input size=\"$inpSize\" name=\"var_$name\" type=\"text\" value=\"$cfg[value]\"  $inpJava></td></tr>";
}


function ShowImgXYBox($xnm, $ynm, $desc, $inpSize, $inpJava)
{
   global $ipnppd, $bgcolor2;
   
   $query_cfg = "SELECT * FROM config WHERE name = '$xnm'";
   $cfgset = mysql_query($query_cfg, $ipnppd);

   if( $cfgset)
   {
      $cfg = mysql_fetch_assoc($cfgset);

      $text = htmlentities($cfg[text]);
      echo "<tr>"
      ."<td title=\"$text\" bgcolor=\"$bgcolor2\" align=\"right\">$desc</td><td title=\"$text\" align=\"left\">";
   
      echo "&nbsp;Width&nbsp;"
      ."<input size=\"$inpSize\" name=\"var_$cfg[name]\" type=\"text\" value=\"$cfg[value]\" $inpJava>";

      $query_cfg = "SELECT * FROM config WHERE name = '$ynm'";
      $cfgset = mysql_query($query_cfg, $ipnppd);
      if( $cfgset)
      {
         $cfg = mysql_fetch_assoc($cfgset);
         echo "&nbsp;&nbsp;Height&nbsp;"
         ."<input size=\"$inpSize\" name=\"var_$cfg[name]\" type=\"text\" value=\"$cfg[value]\" $inpJava>";
      }
      echo "</td></tr>";
   }
}


function Config()
{
    global $admin, $bgcolor2, $prefix, $dbi, $currentlang, $multilingual;
    include ("header.php");
   include("http://www.iforclan.net/Donation-stats/html/modules/Donations/config.inc.php");

?>
<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 reside on an HTTPS server.\nIf you use this URL, users will receive a warning\nabout viewing secure and non-secure data on the same page.\n\n  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 enter\na URL for cancelled payments PayPal will also use\nthis URL for cancelled payments.');
   return true;
}
</script>
<?php

    GraphicAdmin();
    OpenTable();
    echo "<center><font class=\"title\"><b>Treasury Configuration</b></font></center>";
    CloseTable();
    echo "<br>";
   echo "<form name=\"tr_configs\" action=\"admin.php\" method=\"post\">"
   . "<input type=\"hidden\" name=\"op\" value=\"ConfigUpdate\">";

    OpenTable();
    echo "<center><font class=\"title\"><b>Donat-o-Meter Config</b></font></center><br>";

   mysql_select_db($database_ipnppd, $ipnppd);

    echo "<table border=\"1\" >";

   ShowTextBox("swing_day", "<b>Swing Day</b>", "175", "4", "onChange=\"return validInt(this,'Swing Day',1);\"");
   ShowTextBox("dm_title", "<b>Donat-o-Meter Title</b>", "", "40", "");
   ShowTextBox("dm_num_don", "<b>Number of donators to list</b>", "", "4", "");
   ShowYNBox("dm_show_date", "<b>Reveal dates in DM</b>", "", "", "");
   ShowYNBox("dm_show_amt", "<b>Reveal Amounts in DM</b>", "", "", "");
   ShowTextBox("dm_button", "<b>URL for button image</b>", "", "70", "onChange=\"return validdateURL(this,this.value);\"");
   ShowImgXYBox("dm_img_width", "dm_img_height", "<b>Image dimensions</b>", "4", "onChange=\"return validInt(this,'Image Dimension',0);\"");

   echo "</table><br>";

   $query_Recordset1 = "SELECT * FROM config WHERE config.name = 'goal'  AND config.subtype<>'Default'";
   $Recordset1 = mysql_query($query_Recordset1, $ipnppd) or die(mysql_error());
   $row_Recordset1 = mysql_fetch_assoc($Recordset1);
   $totalRows_Recordset1 = mysql_num_rows($Recordset1);
   $desc = htmlentities($row_Recordset1[text]);

   echo "Donation goals by month<br>";
    echo "<table border=\"1\" width=\"100\">";
   $row1 = '<tr><td bgcolor=\"$bgcolor2\" align=\"center\"><b>Month</b></td>';
   $row2 = '<tr><td bgcolor=\"$bgcolor2\" 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_goal-$row_Recordset1[subtype]\" type=\"text\" value=\"$row_Recordset1[value]\" onChange=\"return validInt(this,'$row_Recordset1[subtype] Donation Goal',1);\"></td>";
   } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
   $row1 .= '</tr>';
   $row2 .= '</tr>';
   echo "$row1 $row2";
   echo "</table><br>";

   echo "<input type=\"submit\" value=\"Submit\">";
    CloseTable();

    OpenTable();
    echo "<center><font class=\"title\"><b>Donations Module Config</b></font></center><br>";
    echo "<table border=\"1\" ><tr><form action=\"admin.php\" method=\"post\">";

   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 &quot;submit&quot; 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: &quot;YES&quot; Response</b>", "", "50", "");
   ShowTextBox("don_name_no", "<b>Username request: &quot;NO&quot; Response</b>", "", "50", "");
   ShowYNBox("don_show_date", "<b>Reveal dates</b>", "", "", "");
   ShowYNBox("don_show_amt", "<b>Reveal Amounts</b>", "", "", "");

   $desc = "Your Donation will keep [IFOR] servers online and our community alive";

   $sql = $sql = "SELECT * FROM config WHERE name = 'don_text'";
   $Recordset = mysql_query($sql, $ipnppd) or die(mysql_error());
   $row = mysql_fetch_assoc($Recordset);
   $DON_TEXT = $row[text];
    echo "<tr>"
    ."<td title=\"$desc\" bgcolor=\"$bgcolor2\" 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>";

   echo "Suggested Donation amounts<br>";
   $query_Recordset1 = "SELECT * FROM config WHERE config.name = 'don_amount' ORDER BY config.subtype";
   $Recordset1 = mysql_query($query_Recordset1, $ipnppd) or die(mysql_error());
   $row_Recordset1 = mysql_fetch_assoc($Recordset1);
   $totalRows_Recordset1 = mysql_num_rows($Recordset1);
   $desc = htmlentities($row_Recordset1[text]);
   
    echo "<table border=\"1\" width=\"100\">";
   $row1 = '<tr><td title="' . $desc . '" bgcolor=\"$bgcolor2\" align=\"center\"><b></b></td>';
   $row2 = '<tr><td title="' . $desc . '" bgcolor=\"$bgcolor2\" 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 = mysql_fetch_assoc($Recordset1));
   $row1 .= '</tr>';
   $row2 .= '</tr>';
   echo "$row1 $row2";

   echo "</table><br>";

   echo "<input type=\"submit\" value=\"Submit\">";
    CloseTable();

    OpenTable();
    echo "<center><font class=\"title\"><b>PayPal Configuration</b></font></center><br>";
    echo "<table border=\"1\" ><tr><form action=\"admin.php\" method=\"post\">";

   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>", "", "", "");

   echo "</table><br>";
   
    echo "<br><font class=\"title\"><b>IPN Logging options</b></font>";

    echo "<table border=\"1\" ><tr><form action=\"admin.php\" method=\"post\">";
    echo "<tr>"
    ."<td bgcolor=\"$bgcolor2\" 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", "<b>Keep this many log entries</b>", "", "4", "");

   global $nukeurl;
   $desc = 'http://www.iforclan.net/Donation-stats/html/modules/Donations/ipn/ipnppd.php';
$desc = htmlentities($desc);
    echo "<tr>"
     ."<td title =\"$desc\" bgcolor=\"$bgcolor2\" align=\"right\"><b>IPN link for PayPal</b></td>"
     ."<td title =\"$desc\" align=\"left\">&nbsp;
   
   
   
   
    &nbsp;&nbsp;<a href=\"$nukeurl/modules/Donations/ipn/ipnppd.php?dbg=1\" target=\"_blank\"><b><i>Click here to test IPN</i></b></a></td>"
    . "</td></tr>";
   echo "</table><br>";

   echo "<input type=\"submit\" value=\"Submit\">";
    CloseTable();

   echo "</form>";

   mysql_free_result($Recordset1);
    include("footer.php");
}

function UpdateDb($db,$nm, $sub, $val, $txt)
{
      global $ilog;
      $insert_Recordset = "UPDATE `config` SET `value`='$val', `text`='$txt' WHERE `name`='$nm' AND `subtype`='$sub'";

      $ilog .= "$insert_Recordset<br><br>";
      echo "$insert_Recordset<br><br><font color=\"#FF0000\"><b>";
      $rvalue = mysql_query($insert_Recordset, $db) or die(mysql_error());
      echo "</b></font>";
}
function UpdateDbShort($db,$nm, $sub, $val, $txt)
{
      global $ilog;
      $insert_Recordset = "UPDATE `config` SET `value`='$val' WHERE `name`='$nm' AND `subtype`='$sub'";

      $ilog .= "$insert_Recordset<br><br>";
      echo "$insert_Recordset<br><br><font color=\"#FF0000\"><b>";
      $rvalue = mysql_query($insert_Recordset, $db) or die(mysql_error());
      echo "</b></font>";
}


function ConfigUpdate()
{
    global $admin, $bgcolor2, $prefix, $dbi, $currentlang, $multilingual;
    include ("header.php");
   include("http://www.iforclan.net/Donation-stats/html/modules/Donations/config.inc.php");

    GraphicAdmin();
    OpenTable();
    echo "<center><font class=\"title\"><b>Treasury Configuration Error</b></font></center>";
   echo "<br><font color=\"#0000FF\"><b>If you see this screen then an SQL error was encountered</b></br>"
      . "You shoud see a message in <font color=\"#FF0000\">RED</font> below indicating what the error is</font><br><br>";
    CloseTable();
//    echo "<br>";
    OpenTable();
   $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($ipnppd, $varnm, $subtype2[1], "0", $textarea);
            } else {
               echo "$varnm $subtype[1] => $value<br>";
               $ERR &= UpdateDbShort($ipnppd, $varnm, $subtype[1], $value, "");
            }
         } else
         {
            echo "$varnm => $value<br>";
            $ERR &= UpdateDbShort($ipnppd,$varnm, "", $value, "");
         }
      }
   }

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

function IpnRec()
{
   include("http://www.iforclan.net/Donation-stats/html/modules/Donations/config.inc.php");
   $ipnppd = mysql_pconnect($hostname_ipnppd, $username_ipnppd, $password_ipnppd) or die(mysql_error());
   mysql_select_db($database_ipnppd, $ipnppd);

   $query_Recordset1 = 'SELECT `date` as recdate'
        . ' FROM financial'
        . ' WHERE name = \'PayPal IPN\''
        . ' ORDER BY date DESC '
        . ' LIMIT 1 ';
   $Recordset1 = mysql_query($query_Recordset1, $ipnppd) or die(mysql_error());
   $row_Recordset1 = mysql_fetch_assoc($Recordset1);
   $recdate = $row_Recordset1[recdate];
   
   $query_Recordset1 = 'SELECT `payment_date` as curdate'
        . ' FROM transactions'
        . ' WHERE payment_status = \'Completed\' AND ( transactions.txn_type = \'send_money\' OR transactions.txn_type = \'web_accept\' )'
        . ' ORDER BY payment_date DESC '
        . ' LIMIT 1 ';
   $Recordset1 = mysql_query($query_Recordset1, $ipnppd) or die(mysql_error());
   $row_Recordset1 = mysql_fetch_assoc($Recordset1);
   $curdate = $row_Recordset1[curdate];

    $query_Recordset1 = ' SELECT IF ( SUM( mc_gross - mc_fee ) , SUM( mc_gross - mc_fee ) , 0 ) AS ipn_total, COUNT( * ) AS numrecs'
        . ' FROM transactions'
        . ' WHERE ( payment_Date > \'' . $recdate . '\' AND payment_date <= \'' . $curdate . '\' ) AND payment_status = \'Completed\' AND ( transactions.txn_type = \'send_money\' OR transactions.txn_type = \'web_accept\' );';
   $Recordset1 = mysql_query($query_Recordset1, $ipnppd) or die(mysql_error());
   $row_Recordset1 = mysql_fetch_assoc($Recordset1);


    global $admin, $bgcolor2, $prefix, $dbi, $currentlang, $multilingual;
    include ("header.php");

    GraphicAdmin();
   echo '<a name="AdminTop"></a>';
    OpenTable();
    echo "<center><font class=\"title\"><b>Treasury Financial</b></font></center>";
    CloseTable();
    echo "<br>";
    OpenTable();
    echo "<center><font class=\"title\"><b>Update register with PayPal IPN</b></font></center><br><br>";

   if( $row_Recordset1['numrecs'] == 0 )
      echo "There are no new IPN records to import! ";
   else
   {
      $insert_set = "INSERT INTO `financial` (`date`,`num`,`name`,`descr`,`amount`) VALUES ('$curdate','','PayPal IPN','Auto-Reconcile','$row_Recordset1[ipn_total]')";
      $rval = mysql_query($insert_set, $ipnppd) or die(mysql_error());

      if($rval)
         echo "<b>$row_Recordset1[numrecs]</b> IPN records have been imported for a total of $" . sprintf("%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=\"admin.php?op=Treasury#AdminTop\" method=\"post\">";
   echo "<input type=\"hidden\" name=\"op\" value=\"Treasury\">"
      ."<input type=\"submit\" value=\"Return\"\">"
      ."</form>";

//    include("footer.php");


}

  Switch($op)
  {
   case "FinRegAdd":
      FinancialRegAdd();
      break;
      
   case "FinRegEdit":
      FinancialRegEdit();
      break;
      
   case "FinRegDel":
      FinancialRegDel();
      break;
      
    case "Treasury":
      Treasury();
       break;
   
   case "Config":
      Config();
      break;
      
   case "ConfigUpdate":
      ConfigUpdate();
      break;

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



?>
 
nuken
RavenNuke(tm) Development Team



Joined: Mar 11, 2007
Posts: 2024
Location: North Carolina

PostPosted: Wed Oct 07, 2009 1:17 pm Reply with quote

Try this....
Code:
<?php

/************************************************************************/
/* NukeTreasury - Financial management for PHP-Nuke */
/* Copyright (c) 2004 by Dave Lawrence AKA Thrash */
/* [ Only registered users can see links on this board! Get registered or login! ] */
/* [ Only registered users can see links on this board! Get registered or login! ] */
/* */
/* 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 */
/* Upgraded and cleaned up by Telli http://codezwiz.com */
/************************************************************************/

if (!defined('ADMIN_FILE')) die ('Access Denied');

global $prefix, $db, $admin_file;
$result = $db->sql_query("select radminsuper from ".$prefix."_authors where aid='$aid'");
list($radminsuper) = $db->sql_fetchrow($result);

if ( !$radminsuper == 1 )
{
echo "Access Denied";
}


function Treasury()
{
global $admin, $bgcolor2, $prefix, $db, $currentlang, $multilingual;
include ("header.php");
include("http://www.iforclan.net/Donation-stats/html/modules/Donations/config.inc.php");

if( !$ipnppd )
{
echo "<br /><br />NukeTreasury FATAL ERROR: Unable to connect to SQL database. Please check your settings in modules/Donations/config.inc.php<br /><br />";
return;
}

$currentPage = $HTTP_SERVER_VARS["PHP_SELF"];

// Register paging
$maxRows_Recordset1 = 10;
$pageNum_Recordset1 = 0;
if (isset($_POST['pageNum_Recordset1'])) {
$pageNum_Recordset1 = $_POST['pageNum_Recordset1'];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;

mysql_select_db($database_ipnppd, $ipnppd);
$query_Recordset1 = "SELECT id, date, DATE_FORMAT(date, '%d-%b-%Y') as fdate, num, name, descr, amount FROM financial order by date DESC";
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $ipnppd) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);

if (isset($_POST['totalRows_Recordset1'])) {
$totalRows_Recordset1 = $_POST['totalRows_Recordset1'];
} else {
$all_Recordset1 = mysql_query($query_Recordset1);
$totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
$queryString_Recordset1 = sprintf("&totalRows_Recordset1=%d#AdminTop", $totalRows_Recordset1);

// Collect IPN reconcile data
// First, get the date of the last time we reconciled
$query_Recordset2 = 'SELECT `date` as recdate'
. ' FROM financial'
. ' WHERE name = \'PayPal IPN\''
. ' ORDER BY date DESC '
. ' LIMIT 1 ';
$Recordset2 = mysql_query($query_Recordset2, $ipnppd) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
$recdate = $row_Recordset2[recdate];

// Get the date of the last donation
$query_Recordset2 = 'SELECT `payment_date` as curdate'
. ' FROM transactions'
. ' WHERE payment_status = \'Completed\' AND ( transactions.txn_type = \'send_money\' OR transactions.txn_type = \'web_accept\' )'
. ' ORDER BY payment_date DESC '
. ' LIMIT 1 ';
$Recordset2 = mysql_query($query_Recordset2, $ipnppd) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($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 transactions '
. ' WHERE ( payment_Date > \'' . $recdate . '\' AND payment_date <= \'' . $curdate . '\' ) '
. ' GROUP BY txn_id ';
$Recordset2 = mysql_query($query_Recordset2, $ipnppd) or die(mysql_error());

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

// Get the register balance
$query_Recordset4 = "SELECT SUM(amount) as total FROM financial";
$Recordset4 = mysql_query($query_Recordset4, $ipnppd) or die(mysql_error());
$row_Recordset4 = mysql_fetch_assoc($Recordset4);
$total = $row_Recordset4[total];

// Output the page
GraphicAdmin();
echo "<a name=\"AdminTop\"></a>";
OpenTable();
echo "<center><font class=\"title\"><b>Treasury Administration</b></font></center>";
CloseTable();
echo "<br />";
OpenTable();
echo "<center><font class=\"option\"><b>Treasury Financial Register</b></font></center><br />";

echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
echo "<tr><td width=\"100%\">";
echo "<form action=\"admin.php?op=Config#AdminTop\" method=\"post\">";
echo "<input type=\"hidden\" name=\"op\" value=\"Config\"><input type=\"submit\" value=\"Config\"></form>";
echo "</td></tr>";

echo "<tr><td width=\"100%\">";
echo "Number of new IPN records: $num_ipn - Totaling \$$ipn_tot";
echo "</td></tr>";
echo "<tr><td width=\"100%\">";
echo "<form action=\"admin.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." . '\n\n' . "Are you sure you want to do this now?')\">"
."</form>";
echo "</td></tr></table>";

$currentPage = "admin.php?op=Treasury";
echo "<center><table border=\"0\"><tr>";
if( $pageNum_Recordset1 > 0 )
{
echo '<td><form action="admin.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="|&lt;" title="Current"></form></td>';
echo '<td><form action="admin.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="&lt;" title="Next newest"></form></td>';
}
if( $pageNum_Recordset1 < $totalPages_Recordset1 )
{
echo '<td><form action="admin.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="&gt;" title="Next Oldest"></form></td>';
echo '<td><form action="admin.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="&gt;|" title="Oldest"></form></td>';
}
echo "</tr></table></center>";

echo "<table border=\"1\" width=\"100%\" align=\"center\"><tr>"
."<td bgcolor=\"$bgcolor2\" align=\"center\" width=\"4\"><b>&nbsp;</b></td>"
."<td bgcolor=\"$bgcolor2\" align=\"center\"><b>Date</b></td>"
."<td bgcolor=\"$bgcolor2\" align=\"center\"><b>Num</b></td>"
."<td bgcolor=\"$bgcolor2\" align=\"center\"><b>Name</b></td>"
."<td bgcolor=\"$bgcolor2\" align=\"center\"><b>Decsription</b></td>"
."<td bgcolor=\"$bgcolor2\" align=\"center\"><b>Amount</b></td></tr><tr>";

$row=0;
do {
$row += 1;
echo "<tr>"
."<td align=\"center\">"
."<A HREF=\"javascript: void 0\" onclick=\""
."document.recedit.id.value = '$row_Recordset1[id]'; "
."document.recedit.Date.value = '$row_Recordset1[fdate]'; "
."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=\"admin.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?" . '\n\n' . "Are you sure you want to do this now?')\""
."></a></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 < 0 )
echo "color=\"#FF0000\"";
echo ">\$$amt</font></td></tr>";
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));

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

echo "<table><tr>"
."<td bgcolor=\"$bgcolor2\" align=\"center\"><b>Date</b></td>"
."<td bgcolor=\"$bgcolor2\" align=\"center\"><b>Num</b></td>"
."<td bgcolor=\"$bgcolor2\" align=\"center\"><b>Name</b></td>"
."<td bgcolor=\"$bgcolor2\" align=\"center\"><b>Description</b></td>"
."<td bgcolor=\"$bgcolor2\" align=\"center\"><b>Amount</b></td></tr><tr>"
."<form action=\"admin.php\" method=\"post\" name=\"recedit\">"
."<td align=\"left\" width=\"8\"><input name=\"id\" type=\"hidden\">"
."<input name=\"Date\" type=\"text\" size=\"11\"></td>"
."<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>";

CloseTable();
echo "<br />";

include("footer.php");
mysql_free_result($Recordset1);

}

function FinancialRegAdd()
{
global $admin, $bgcolor2, $prefix, $db, $currentlang, $multilingual;
include ("header.php");
include("http://www.iforclan.net/Donation-stats/html/modules/Donations/config.inc.php");

$ipnppd = mysql_pconnect($hostname_ipnppd, $username_ipnppd, $password_ipnppd) or die(mysql_error());

GraphicAdmin();
OpenTable();
echo "<center><font class=\"title\"><b>Treasury Record add</b></font></center>";
CloseTable();
echo "<br />";
OpenTable();

$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<br />";
else
{
echo "Field passed validation!<br />";

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

mysql_select_db($database_ipnppd, $ipnppd);
$insert_Recordset = "INSERT INTO `financial` VALUES "
."(NULL, '" . strftime("%Y-%m-%d", $nTime) . "','" . $_POST[Num] . "','" . $_POST[Name]
."','" . $_POST[Descr] . "','" . $_POST[Amount] . "')";

echo "$insert_Recordset";
$rvalue = mysql_query($insert_Recordset, $ipnppd) or die(mysql_error());

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

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

}
}


function FinancialRegDel()
{
global $admin, $bgcolor2, $prefix, $db, $currentlang, $multilingual;
include ("header.php");
include("http://www.iforclan.net/Donation-stats/html/modules/Donations/config.inc.php");

$ipnppd = mysql_pconnect($hostname_ipnppd, $username_ipnppd, $password_ipnppd) or die(mysql_error());

GraphicAdmin();
OpenTable();
echo "<center><font class=\"title\"><b>Treasury Record Delete</b></font></center>";
CloseTable();
echo "<br />";
OpenTable();

echo "Field passed validation!<br />";

mysql_select_db($database_ipnppd, $ipnppd);

if( !(is_numeric($_GET[id]) && $_GET[id]>0))
{
echo "<br />Invalid record id specified, operation aborted<br />";
} else
{
$del_Recordset = "DELETE FROM `financial` WHERE `id`='$_GET[id]' LIMIT 1";
$rvalue = mysql_query($del_Recordset, $ipnppd) or die(mysql_error());

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


function FinancialRegEdit()
{
global $admin, $bgcolor2, $prefix, $db, $currentlang, $multilingual;
include ("header.php");
include("http://www.iforclan.net/Donation-stats/html/modules/Donations/config.inc.php");

$ipnppd = mysql_pconnect($hostname_ipnppd, $username_ipnppd, $password_ipnppd) or die(mysql_error());

GraphicAdmin();
OpenTable();
echo "<center><font class=\"title\"><b>Treasury Record Edit</b></font></center>";
CloseTable();
echo "<br />";
OpenTable();

// echo "$_POST[Date] $_POST[Num] $_POST[Name] $_POST[Descr] $_POST[Amount]<br /><br />";
$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 />";

mysql_select_db($database_ipnppd, $ipnppd);
$insert_Recordset = "UPDATE `financial` SET date='". strftime("%Y-%m-%d", $nTime) . "', num='$_POST[Num]', Name='$_POST[Name]', "
."descr='$_POST[Descr]', amount='$_POST[Amount]' WHERE id='$_POST[id]' LIMIT 1";

echo "$insert_Recordset";
$rvalue = mysql_query($insert_Recordset, $ipnppd) or die(mysql_error());

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

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

}
}


function SelectYN($nm, $val)
{
echo '<select size="1" name="' . $nm . '">';
if( $val )
{
echo '<option selected value="1">Yes</option>'
. '<option value="0">No</option>';
} else {
echo '<option value="1">Yes</option>'
. '<option selected value="0">No</option>';
}
echo '</select>';
}


function ShowYNBox($name, $desc, $tdWidth, $inpSize, $inpJava)
{
global $ipnppd, $bgcolor2;

$query_cfg = "SELECT * FROM config WHERE name = '$name'";
$cfgset = mysql_query($query_cfg, $ipnppd);
if( !$cfgset )
return;

$cfg = mysql_fetch_assoc($cfgset);
$text = htmlentities($cfg[text]);
echo "<tr>"
."<td title=\"$text\" bgcolor=\"$bgcolor2\" align=\"right\">$desc</td>"
."<td title=\"$text\" align=\"left\">";
echo '<select size="1" name="var_' . $name . '">';
if( $cfg[value] )
{
echo '<option selected value="1">Yes</option>'
. '<option value="0">No</option>';
} else {
echo '<option value="1">Yes</option>'
. '<option selected value="0">No</option>';
}
echo '</select>';
// SelectYN("var_dm_show_date", $tr_config[dm_show_date]);
}


function ShowTextBox($name, $desc, $tdWidth, $inpSize, $inpJava)
{
global $ipnppd, $bgcolor2;

$query_cfg = "SELECT * FROM config WHERE name = '$name'";
$cfgset = mysql_query($query_cfg, $ipnppd);
if( !$cfgset )
return;
$cfg = mysql_fetch_assoc($cfgset);
$text = htmlentities($cfg[text]);
echo "<tr>"
."<td title=\"$text\" bgcolor=\"$bgcolor2\" align=\"right\" width=\"$tdWidth\">$desc</td>"
."<td title=\"$text\" align=\"left\">"
."<input size=\"$inpSize\" name=\"var_$name\" type=\"text\" value=\"$cfg[value]\" $inpJava></td></tr>";
}


function ShowImgXYBox($xnm, $ynm, $desc, $inpSize, $inpJava)
{
global $ipnppd, $bgcolor2;

$query_cfg = "SELECT * FROM config WHERE name = '$xnm'";
$cfgset = mysql_query($query_cfg, $ipnppd);

if( $cfgset)
{
$cfg = mysql_fetch_assoc($cfgset);

$text = htmlentities($cfg[text]);
echo "<tr>"
."<td title=\"$text\" bgcolor=\"$bgcolor2\" align=\"right\">$desc</td><td title=\"$text\" align=\"left\">";

echo "&nbsp;Width&nbsp;"
."<input size=\"$inpSize\" name=\"var_$cfg[name]\" type=\"text\" value=\"$cfg[value]\" $inpJava>";

$query_cfg = "SELECT * FROM config WHERE name = '$ynm'";
$cfgset = mysql_query($query_cfg, $ipnppd);
if( $cfgset)
{
$cfg = mysql_fetch_assoc($cfgset);
echo "&nbsp;&nbsp;Height&nbsp;"
."<input size=\"$inpSize\" name=\"var_$cfg[name]\" type=\"text\" value=\"$cfg[value]\" $inpJava>";
}
echo "</td></tr>";
}
}


function Config()
{
global $admin, $bgcolor2, $prefix, $db, $currentlang, $multilingual;
include ("header.php");
include("http://www.iforclan.net/Donation-stats/html/modules/Donations/config.inc.php");

?>
<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 reside on an HTTPS server.\nIf you use this URL, users will receive a warning\nabout viewing secure and non-secure data on the same page.\n\n 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 enter\na URL for cancelled payments PayPal will also use\nthis URL for cancelled payments.');
return true;
}
</script>
<?php

GraphicAdmin();
OpenTable();
echo "<center><font class=\"title\"><b>Treasury Configuration</b></font></center>";
CloseTable();
echo "<br />";
echo "<form name=\"tr_configs\" action=\"admin.php\" method=\"post\">"
. "<input type=\"hidden\" name=\"op\" value=\"ConfigUpdate\">";

OpenTable();
echo "<center><font class=\"title\"><b>Donat-o-Meter Config</b></font></center><br />";

mysql_select_db($database_ipnppd, $ipnppd);

echo "<table border=\"1\" >";

ShowTextBox("swing_day", "<b>Swing Day</b>", "175", "4", "onChange=\"return validInt(this,'Swing Day',1);\"");
ShowTextBox("dm_title", "<b>Donat-o-Meter Title</b>", "", "40", "");
ShowTextBox("dm_num_don", "<b>Number of donators to list</b>", "", "4", "");
ShowYNBox("dm_show_date", "<b>Reveal dates in DM</b>", "", "", "");
ShowYNBox("dm_show_amt", "<b>Reveal Amounts in DM</b>", "", "", "");
ShowTextBox("dm_button", "<b>URL for button image</b>", "", "70", "onChange=\"return validdateURL(this,this.value);\"");
ShowImgXYBox("dm_img_width", "dm_img_height", "<b>Image dimensions</b>", "4", "onChange=\"return validInt(this,'Image Dimension',0);\"");

echo "</table><br />";

$query_Recordset1 = "SELECT * FROM config WHERE config.name = 'goal' AND config.subtype<>'Default'";
$Recordset1 = mysql_query($query_Recordset1, $ipnppd) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
$desc = htmlentities($row_Recordset1[text]);

echo "Donation goals by month<br />";
echo "<table border=\"1\" width=\"100\">";
$row1 = '<tr><td bgcolor=\"$bgcolor2\" align=\"center\"><b>Month</b></td>';
$row2 = '<tr><td bgcolor=\"$bgcolor2\" 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_goal-$row_Recordset1[subtype]\" type=\"text\" value=\"$row_Recordset1[value]\" onChange=\"return validInt(this,'$row_Recordset1[subtype] Donation Goal',1);\"></td>";
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
$row1 .= '</tr>';
$row2 .= '</tr>';
echo "$row1 $row2";
echo "</table><br />";

echo "<input type=\"submit\" value=\"Submit\">";
CloseTable();

OpenTable();
echo "<center><font class=\"title\"><b>Donations Module Config</b></font></center><br />";
echo "<table border=\"1\" ><tr><form action=\"admin.php\" method=\"post\">";

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 &quot;submit&quot; 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: &quot;YES&quot; Response</b>", "", "50", "");
ShowTextBox("don_name_no", "<b>Username request: &quot;NO&quot; Response</b>", "", "50", "");
ShowYNBox("don_show_date", "<b>Reveal dates</b>", "", "", "");
ShowYNBox("don_show_amt", "<b>Reveal Amounts</b>", "", "", "");

$desc = "Your Donation will keep [IFOR] servers online and our community alive";

$sql = $sql = "SELECT * FROM config WHERE name = 'don_text'";
$Recordset = mysql_query($sql, $ipnppd) or die(mysql_error());
$row = mysql_fetch_assoc($Recordset);
$DON_TEXT = $row[text];
echo "<tr>"
."<td title=\"$desc\" bgcolor=\"$bgcolor2\" 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 />";

echo "Suggested Donation amounts<br />";
$query_Recordset1 = "SELECT * FROM config WHERE config.name = 'don_amount' ORDER BY config.subtype";
$Recordset1 = mysql_query($query_Recordset1, $ipnppd) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
$desc = htmlentities($row_Recordset1[text]);

echo "<table border=\"1\" width=\"100\">";
$row1 = '<tr><td title="' . $desc . '" bgcolor=\"$bgcolor2\" align=\"center\"><b></b></td>';
$row2 = '<tr><td title="' . $desc . '" bgcolor=\"$bgcolor2\" 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 = mysql_fetch_assoc($Recordset1));
$row1 .= '</tr>';
$row2 .= '</tr>';
echo "$row1 $row2";

echo "</table><br />";

echo "<input type=\"submit\" value=\"Submit\">";
CloseTable();

OpenTable();
echo "<center><font class=\"title\"><b>PayPal Configuration</b></font></center><br />";
echo "<table border=\"1\" ><tr><form action=\"admin.php\" method=\"post\">";

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>", "", "", "");

echo "</table><br />";

echo "<br /><font class=\"title\"><b>IPN Logging options</b></font>";

echo "<table border=\"1\" ><tr><form action=\"admin.php\" method=\"post\">";
echo "<tr>"
."<td bgcolor=\"$bgcolor2\" 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", "<b>Keep this many log entries</b>", "", "4", "");

global $nukeurl;
$desc = 'http://www.iforclan.net/Donation-stats/html/modules/Donations/ipn/ipnppd.php';
$desc = htmlentities($desc);
echo "<tr>"
."<td title =\"$desc\" bgcolor=\"$bgcolor2\" align=\"right\"><b>IPN link for PayPal</b></td>"
."<td title =\"$desc\" align=\"left\">&nbsp;




&nbsp;&nbsp;<a href=\"$nukeurl/modules/Donations/ipn/ipnppd.php?dbg=1\" target=\"_blank\"><b><i>Click here to test IPN</i></b></a></td>"
. "</td></tr>";
echo "</table><br />";

echo "<input type=\"submit\" value=\"Submit\">";
CloseTable();

echo "</form>";

mysql_free_result($Recordset1);
include("footer.php");
}

function UpdateDb($db,$nm, $sub, $val, $txt)
{
global $ilog;
$insert_Recordset = "UPDATE `config` SET `value`='$val', `text`='$txt' WHERE `name`='$nm' AND `subtype`='$sub'";

$ilog .= "$insert_Recordset<br /><br />";
echo "$insert_Recordset<br /><br /><font color=\"#FF0000\"><b>";
$rvalue = mysql_query($insert_Recordset, $db) or die(mysql_error());
echo "</b></font>";
}
function UpdateDbShort($db,$nm, $sub, $val, $txt)
{
global $ilog;
$insert_Recordset = "UPDATE `config` SET `value`='$val' WHERE `name`='$nm' AND `subtype`='$sub'";

$ilog .= "$insert_Recordset<br /><br />";
echo "$insert_Recordset<br /><br /><font color=\"#FF0000\"><b>";
$rvalue = mysql_query($insert_Recordset, $db) or die(mysql_error());
echo "</b></font>";
}


function ConfigUpdate()
{
global $admin, $bgcolor2, $prefix, $db, $currentlang, $multilingual;
include ("header.php");
include("http://www.iforclan.net/Donation-stats/html/modules/Donations/config.inc.php");

GraphicAdmin();
OpenTable();
echo "<center><font class=\"title\"><b>Treasury Configuration Error</b></font></center>";
echo "<br /><font color=\"#0000FF\"><b>If you see this screen then an SQL error was encountered</b></br>"
. "You shoud see a message in <font color=\"#FF0000\">RED</font> below indicating what the error is</font><br /><br />";
CloseTable();
// echo "<br />";
OpenTable();
$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($ipnppd, $varnm, $subtype2[1], "0", $textarea);
} else {
echo "$varnm $subtype[1] => $value<br />";
$ERR &= UpdateDbShort($ipnppd, $varnm, $subtype[1], $value, "");
}
} else
{
echo "$varnm => $value<br />";
$ERR &= UpdateDbShort($ipnppd,$varnm, "", $value, "");
}
}
}

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

function IpnRec()
{
include("http://www.iforclan.net/Donation-stats/html/modules/Donations/config.inc.php");
$ipnppd = mysql_pconnect($hostname_ipnppd, $username_ipnppd, $password_ipnppd) or die(mysql_error());
mysql_select_db($database_ipnppd, $ipnppd);

$query_Recordset1 = 'SELECT `date` as recdate'
. ' FROM financial'
. ' WHERE name = \'PayPal IPN\''
. ' ORDER BY date DESC '
. ' LIMIT 1 ';
$Recordset1 = mysql_query($query_Recordset1, $ipnppd) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$recdate = $row_Recordset1[recdate];

$query_Recordset1 = 'SELECT `payment_date` as curdate'
. ' FROM transactions'
. ' WHERE payment_status = \'Completed\' AND ( transactions.txn_type = \'send_money\' OR transactions.txn_type = \'web_accept\' )'
. ' ORDER BY payment_date DESC '
. ' LIMIT 1 ';
$Recordset1 = mysql_query($query_Recordset1, $ipnppd) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$curdate = $row_Recordset1[curdate];

$query_Recordset1 = ' SELECT IF ( SUM( mc_gross - mc_fee ) , SUM( mc_gross - mc_fee ) , 0 ) AS ipn_total, COUNT( * ) AS numrecs'
. ' FROM transactions'
. ' WHERE ( payment_Date > \'' . $recdate . '\' AND payment_date <= \'' . $curdate . '\' ) AND payment_status = \'Completed\' AND ( transactions.txn_type = \'send_money\' OR transactions.txn_type = \'web_accept\' );';
$Recordset1 = mysql_query($query_Recordset1, $ipnppd) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);


global $admin, $bgcolor2, $prefix, $db, $currentlang, $multilingual;
include ("header.php");

GraphicAdmin();
echo '<a name="AdminTop"></a>';
OpenTable();
echo "<center><font class=\"title\"><b>Treasury Financial</b></font></center>";
CloseTable();
echo "<br />";
OpenTable();
echo "<center><font class=\"title\"><b>Update register with PayPal IPN</b></font></center><br /><br />";

if( $row_Recordset1['numrecs'] == 0 )
echo "There are no new IPN records to import! ";
else
{
$insert_set = "INSERT INTO `financial` (`date`,`num`,`name`,`descr`,`amount`) VALUES ('$curdate','','PayPal IPN','Auto-Reconcile','$row_Recordset1[ipn_total]')";
$rval = mysql_query($insert_set, $ipnppd) or die(mysql_error());

if($rval)
echo "<b>$row_Recordset1[numrecs]</b> IPN records have been imported for a total of $" . sprintf("%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=\"admin.php?op=Treasury#AdminTop\" method=\"post\">";
echo "<input type=\"hidden\" name=\"op\" value=\"Treasury\">"
."<input type=\"submit\" value=\"Return\"\">"
."</form>";

// include("footer.php");


}

Switch($op)
{
case "FinRegAdd":
FinancialRegAdd();
break;

case "FinRegEdit":
FinancialRegEdit();
break;

case "FinRegDel":
FinancialRegDel();
break;

case "Treasury":
Treasury();
break;

case "Config":
Config();
break;

case "ConfigUpdate":
ConfigUpdate();
break;

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



?>

_________________
Tricked Out News 
View user's profile Send private message Send e-mail Visit poster's website
akrantz







PostPosted: Wed Oct 07, 2009 2:29 pm Reply with quote

Hi nuken!

I copy pasted that code but unfortunatley it didnt work...Sad

If you go here; [ Only registered users can see links on this board! Get registered or login! ]

and here; [ Only registered users can see links on this board! Get registered or login! ]

You see what im talking about (maybe you already know??)

Specially on the donatometer.html it should show the value from the db, right?

Is there anything else i can present in order for you guys to help me out on this?

I highly appriciate your efforts to help me!!!

Thanks
 
Dawg







PostPosted: Wed Oct 07, 2009 6:42 pm Reply with quote

Akrantz,
Looking at these URLs....Something is amiss....

Should it not be.... [ Only registered users can see links on this board! Get registered or login! ]

Something is FUBARed about your install....

The path to that file should be....
[ Only registered users can see links on this board! Get registered or login! ]


Dawg
 
Unit1
Worker
Worker



Joined: Oct 26, 2004
Posts: 134
Location: Boston

PostPosted: Wed Oct 07, 2009 8:56 pm Reply with quote

From looking at the site it does not appear to be a php nuke site akrantz are you trying to put in a php nuke modules on a html site? If so that is why you are having so much trouble with the Donations setup.

If you would like some help on setting up a nuke site for you and your clan I have done many of them for others. I will be more than willing to help do this for you I got work tomorrow but when I get home about 6 pm EST I will help you setup a nuke site with every thing you will need for you and your clan

_________________
* 5 Simple rules to be happy: * Free Your Heart from Hatred * Free Your Mind from Worries * Live Simply * Give More * Expect Less. 
View user's profile Send private message
akrantz







PostPosted: Wed Oct 07, 2009 11:57 pm Reply with quote

lol!

yeah thats right im trying to setup a php module on a html site....

But should that really be a problem? I mean i use php for all our "forms" example; [ Only registered users can see links on this board! Get registered or login! ] Where the php works on processing the form and sends the email. This works really good (and is html and php combined).

When i downloaded nuketreasury my thought was to integrate it with the site, since the donatometer and donations.html are both written in html.

Basically what I done is that i have:
1. Unzipped the file and uploaded it to my server (the provider supports php nuke).
2. Changed the file name from NukeTreasury -> Donation-stats (easier for me to find it in the main catalog.
3. Therefore the dir for the files -> [ Only registered users can see links on this board! Get registered or login! ] name)/etc/etc/
4. In the php documents i have changed the original ref. from: (//modules/Donations/Donatometer.html to [ Only registered users can see links on this board! Get registered or login! ] (since that is where its actually located).
5. I still wonder if it´s something in one of the php files that is not correct refered, since it does not seem to collect the information from the db and displays $DM_GOAL etc instead of the value in the database.

I can agree this is totally FUBAR... Smile

Yeah Unit1 everyone keeps telling me that we should switch completly and use php nuke! Two things is stopping me from do that right now:
1. Im so stubborn and as soon as i encounter a problem - i just simply wont to solve it (maybe sometimes i simply should know when to stop trying).
2. The real truth is that I dont know much at all about php scripting!!!Thats the real issue. I don´t understand the language. Ill give you a example! I downloaded php nuke 8.0 (I think it was 8.0) and uploaded it to the server (see; [ Only registered users can see links on this board! Get registered or login! ] Now i dont even know how to edit the darn thing....lol! you see my problem wiht getting a nuke site i wouldnt even know where to start....
 
Dawg







PostPosted: Thu Oct 08, 2009 5:06 am Reply with quote

Akrantz,
That is not going to work. The reason it is not working is becasue you are missing the database layer that comes with Nuke along with a bunch of other stuff.

My recommandation.
Delete 8.0 (Bad Idea)
Hire Unit1 to set you up with RN.

Once your site is up and running you can take it one step at a time. PHP and RN are really fun once you get the hang of it.

Dawg
 
akrantz







PostPosted: Thu Oct 08, 2009 5:17 am Reply with quote

Ok!

So really its not possible to combine the nuketreasury with a html page?
 
akrantz







PostPosted: Thu Oct 08, 2009 5:20 am Reply with quote

The reason im asking is because your saying "That is not going to work. The reason it is not working is becasue you are missing the database layer that comes with Nuke along with a bunch of other stuff." I just wanna be sure, cause then there is no idea for me to keep on trying...

If thats the case, well then i might consider switching to php instead.
 
Guardian2003
Site Admin



Joined: Aug 28, 2003
Posts: 6799
Location: Ha Noi, Viet Nam

PostPosted: Thu Oct 08, 2009 5:38 am Reply with quote

Nuke Treasury requires some specific functions to work and those functions would be missing if you are not using phpNuke or some derivative of phpNuke.
Think of it as putting an jet engine in a car. The mounting brackets won't line up, it's the wrong sort of fuel, the wires are too short..........
 
View user's profile Send private message Send e-mail
Dawg







PostPosted: Thu Oct 08, 2009 5:42 am Reply with quote

It will not work without Nuke of some flavor. If you are going to use Nuke....You really should use RN. (If you do not want to get hacked)

To give you another example....

You are sitting a Light Bulb in the middle of the floor and expecting it to work without it being hooked up to the wireing in the house.....That's not going to work.

Dawg
 
montego
Site Admin



Joined: Aug 29, 2004
Posts: 9457
Location: Arizona

PostPosted: Thu Oct 08, 2009 6:15 am Reply with quote

akrantz, hence the name NukeTreasury. Wink Since PayPal has been around for a very long time, there has got to be just a ton of free PHP scripts out there that are more standalone. Yes, you could re-write NukeTreasury if you have the proper skillsets but you might find something else much closer to what you are after I suspect.

_________________
Where Do YOU Stand?
HTML Newsletter::ShortLinks::Mailer::Downloads and more... 
View user's profile Send private message Visit poster's website
Susann
Moderator



Joined: Dec 19, 2004
Posts: 3191
Location: Germany:Moderator German NukeSentinel Support

PostPosted: Thu Oct 08, 2009 12:36 pm Reply with quote

I do have the same problem like you and I miss an image. However, I use RavenNuke and Nuke Treasury but I think it´s not really a problem if it doesn`t show all in donatometer.html because everything works like it should with this url: modules.php? name=Donations
 
View user's profile Send private message
akrantz







PostPosted: Thu Oct 08, 2009 12:48 pm Reply with quote

do you have a site in html?

My site is build totally in html! I only use php scripts to send forms!

As it seems now i wont be able to use Nuketreasury!

So I guess i have two options:
1. Change site to php (nuke)
2. Find another donato meter
 
Susann







PostPosted: Thu Oct 08, 2009 12:58 pm Reply with quote

I use it in RavenNuke but I have checked the urls you posted above at my site and found out that I have the same issue but it works.
There are different donation scripts available maybe you will find an other one.
If you change your site just use RavenNuke.
 
Unit1







PostPosted: Thu Oct 08, 2009 6:36 pm Reply with quote

akrantz my offer still stands I will setup the full nuke site for you and do any of the edits that will be needed

Sorry to all here but my sites are not a RN setup's. I have had my sites and the other ones that I am the webmaster at for a very long time with no problems at all with them because of a lot of time spent reading here and also on some of the other team members sites and implementing a lot of the security fixes to the site. I do understand that RN is one of the best nuke set up's out today but I am an old dog and tend to stay with what I know best in my old age

akrantz my time and support for the setup and code changes for the site would be free It will take a bit of time to do all the edits and some updating to the setup. But I would ask that if you want me to do this for you that when it is done and you are happy with the setup that if you can make a Donation to Ravens site as you can see they all here are great people and help so many others with their problems like they have done for me so many times in the past.

Or maybe if you want RN I am sure someone can help you or point you to someone with more experience with RN setup than I do. IMO if I was just starting out with a nuke setup I would go with the RN setup it is more up to date and you cannot beat the support that you will get here for a nuke setup RavensScripts
 
akrantz







PostPosted: Thu Oct 08, 2009 10:04 pm Reply with quote

I just want to thank everyone for your time reading and helping me out on this!

THANK YOU!

"Unit1" I´ve sent you a PM
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Nuke Treasury

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©