/* Rob's Easy Budget Tool * http://www.edgerob.net/budget * * This code is freely distributable for educational and non-commercial use. */ "; $headers = "From: Rob's Easy Budget Tool \r\n"; $subject = "Password Reset Request"; $body = "Hello, here is your new password for Rob's Easy Budget Tool. Use this to login to your account.\n\n"; $body .= $pass."\n\n"; $body .= "http://edgerob.net/budget"; mail ($to, $subject, $body, $headers); $q = "update users set password='".md5($pass)."' where email='$email'"; $result = mysql_query($q) or die(mysql_error()); echo "0"; return; } $logged_in = checkLogin(); if ($logged_in) $user = $_SESSION['username']; if ($action == "changepw") { $pass = $_GET['pass']; $q = "update users set password='$pass' where email='$user'"; $result = mysql_query($q) or die(mysql_error()); echo "0"; return; } $cat = $_GET['cat']; if ($action == "updatetotal") { $total = $_GET['total']; $rel = $_GET['rel']; $q = "update totals set total='$total' where user='$user'"; $result = mysql_query($q) or die(mysql_error()); return; } if ($action == "filltotal") { filltotal(); return; } if ($action == "addtrans") { $type = $_GET['type']; $amount = $_GET['amount']; $date = $_GET['date']; $description = $_GET['description']; if ($type == "debit") $q = "update categories set balance=balance-$amount where id=$cat"; else $q = "update categories set balance=balance+$amount where id=$cat"; $result = mysql_query($q) or die(mysql_error()); if ($type == "debit") $q = "update totals set total=total-$amount where user='$user'"; else $q = "update totals set total=total+$amount where user='$user'"; $result = mysql_query($q) or die(mysql_error()); $q = "insert into transactions (user, cat, type, amount, date, description) values ('$user', $cat, '$type', '$amount', '$date', '$description')"; $result = mysql_query($q) or die(mysql_error()); fillcat($cat); return; } if ($action == "addcat") { $name = $_GET['name']; $q = "select name from categories where user='$user' and name='$name'"; $result = mysql_query($q) or die(mysql_error()); if (!mysql_num_rows($result)) { $q = "insert into categories (user, name, balance) values ('$user', '$name', 0)"; $result = mysql_query($q) or die(mysql_error()); } fillcats($user); return; } if ($action == "deltrans") { $cat = $_GET['cat']; $id = $_GET['id']; $q = "select user from categories where id='$cat'"; $result = mysql_query($q) or die(mysql_error()); $temp = mysql_fetch_array($result); if ($user != $temp['user']) return; $q = "select amount, type, cat from transactions where id='$id'"; $result = mysql_query($q) or die(mysql_error()); $temp=mysql_fetch_array($result); $type = $temp['type']; $amount = $temp['amount']; $cat = $temp['cat']; if ($type == "debit") $q = "update categories set balance=balance+$amount where id='$cat'"; else $q = "update categories set balance=balance-$amount where id='$cat'"; $result = mysql_query($q) or die(mysql_error()); if ($type == "debit") $q = "update totals set total=total+$amount where user='$user'"; else $q = "update totals set total=total-$amount where user='$user'"; $result = mysql_query($q) or die(mysql_error()); $q = "delete from transactions where id='$id'"; $result = mysql_query($q) or die(mysql_error()); fillcat($cat); return; } if ($action == "delcat") { $id = $_GET['id']; $q = "select user from categories where id='$id'"; $result = mysql_query($q) or die(mysql_error()); $temp = mysql_fetch_array($result); if ($user != $temp['user']) return; $q = "delete from transactions where cat='$id'"; $result = mysql_query($q) or die(mysql_error()); $q = "delete from categories where id='$id'"; $result = mysql_query($q) or die(mysql_error()); fillcats($user); return; } if ($action == "post") { if (!$logged_in) { echo "1"; die(); } $name = $_GET['name']; $subject = $_GET['subject']; $message = nl2br($_GET['message']); $date = time(); $q = "insert into posts (user, name, subject, message, date) values ('$user', '$name', '$subject', '$message', '$date')"; $result = mysql_query($q) or die(mysql_error()); fillforum("latest"); return; } if ($action == "delpost") { $id = $_GET['id']; $q = "select user from posts where id='$id'"; $result = mysql_query($q) or die(mysql_error()); $temp = mysql_fetch_array($result); if ($user != $temp['user']) return; $q = "delete from posts where id='$id'"; $result = mysql_query($q) or die(mysql_error()); fillforum("latest"); return; } if ($action == "fillforum") { fillforum($_GET['page']); return; } function filltotal() { global $user; $q = "select total from totals where user='$user'"; $result = mysql_query($q) or die(mysql_error()); $temp = mysql_fetch_array($result); $total = $temp['total']; ?>
Total Money (click to change):
$
'.$cat['name'].'
$'.$cat['balance'].'
'; $total = $total - $cat['balance']; } ?>
Leftover Money:
; " >$
No transactions. Add a new transaction below.'; return; } while ($t = mysql_fetch_array($result)) { $a = explode ('-', $t['date']); $date = date("M d, Y", mktime(0,0,0,$a[1],$a[2],$a[0])); echo '
'; if ($t['type'] == 'debit') echo '$'.$t['amount']; else echo ' '; echo '
'; if ($t['type'] == 'credit') echo '$'.$t['amount']; else echo ' '; echo '
'.$date.'
 '.$t['description'].'
'; echo '
 
'; } echo '
Balance: $'.$bal.'
'; return; } function fillcats($u) { $q = "select * from categories where user='$u' order by name asc"; $result = mysql_query($q) or die(mysql_error()); if (mysql_num_rows($result) == 0) { echo 'You currently have no categories. Please add a new category below.'; return; } while ($cat = mysql_fetch_array($result)) { ?>
Page:'; for ($i = 1; $i <= $pages; $i++) { if ($i != $page) $pagebox .= ' '.$i.''; else $pagebox .= ' '.$i; } $pagebox .= ' '; echo $pagebox; while ($post = mysql_fetch_array($result)) { $date = date("M d, Y H:i", $post['date']); ?>

Posted by on
Delete'; ?>