Filter:   InfoImg
download addpay.php
Language: PHP
LOC: 243
Project Info
Total ISP(total-isp)
Server: SourceForge
Type: cvs
...orge\t\total‑isp\total‑isp\
   abn.php
   addnew.php
   addnote.php
   addpay.php
   addsub.php
   addtime.php
   aliasadd.php
   answer.php
   approvelink.php
   ask.php
   autobill.php
   autobillpost.php
   backuplink.php
   batchtax.php
   Blocks-check.php
   Blocks-oldmail.php
   buildmenu.php
   business-check.php
   buytime.php
   cachemgr.php
   callanalysis.php
   calls.php
   callweekall.php
   ccemail.php
   changes.php
   checkmail.php
   cli.php
   clicheck.php
   config.php
   createwebdir.php
   credit.php
   creditpost.php
   cvimage.php
   dbspec.sql
   dealer.php
   dealeredit.php
   dealereditsave.php
   dealermenu.php
   dealerspecial-check.php
   dealerspecial.php
   dealersummary.php
   dig.php
   dnstest.php
   domainadd.php
   dschurn.php
   dsused.php
   edit.php
   editadd.php
   emailip.php
   expire.php
   extraadd.php
   faq.php
   firstpayments.php
   fixedip.dat
   fixedip.ph
   fixedip.php
   frames.php
   frconten.php
   frmain.php
   getcall.php
   gstinc.inc.php
   gsttest.php
   hms.inc.php
   index.php
   invoicepost.php
   invoices.php
   IPAD-check.php
   ipadmail.dat
   jump.php
   kick.php
   kickall.php
   killed.php
   lastaccess.php
   lastcall.php
   lastpasswords.php
   list.php
   listpay.php
   listpurchase-cash.php
   listpurchase-cheque.php
   listpurchase-code.php
   listpurchase-dupes.php
   listpurchase-exact.php
   listpurchase-group.php
   listpurchase-summary.php
   listpurchase-supplier.php
   ...purchase-unapproved.php
   listpurchase.php
   lm.inc.php
   loginfail.php
   mail.php
   mailadd.php
   mailusr.php
   monthpurch.php
   mysql.inc.php
   names.php
   newcustomer.php
   nextcall.php
   nosubs.php
   orphans.php
   password.php
   payimage.php
   payment.php
   payreport.php
   payview.php
   pdf-daily-sum.php
   pdfprint.inc.php
   permanent-check.php
   phpinfo.php
   phptest.php
   ping.php
   purchase-delete.php
   purchaseedit.php
   purchaseindex.php
   purchasing.php
   qchar.php
   radiususers.php
   radtest.php
   reallysure.php
   recall.php
   redir.php
   report.php
   reseller-check.php
   resellview.php
   sampledata.sql
   searchfaq.php
   searchfaqres.php
   sendmail.php
   staff.php
   subedit.php
   subeditadd.php
   submituser.php
   subnames.php
   taxpdf.php
   testbatch.php
   testpdf-day.php
   testpost.php
   testtaxpdf.php
   testuser.php
   testwho.php
   thundermail.php
   tigris.php
   time1.inc.php
   timetest.php
   top.php
   unanswered.php
   unlimited-3mth-check.php
   unlimited-check.php
   unlimited-stats.php
   unlimitedpartition.php
   uploadmailhdr.php
   user.php
   viewnotes.php
   visp.inc.php
   webadd.php
   weblinks.php
   WebSite-check.php
   weeknotes.php
   weekuser.php
   who.php
   whoip.php
   whoverify.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
<?
include "./auth.inc.php";
#commission
#should probably be changed to a .inc.php.php.php of sorts
#or dynamic system to allow different rates..

#$resellercommissionrate=0.05;
#$agentcommissionrate=0.05;




function CC_checksum($ccard){
   if(strlen($ccard) < 1)
     return 0;
   $ccard = ereg_replace("[^[:digit:]]+", "", $ccard);
   $checksum = 0;
   $factor = (strlen($ccard) % 2) ? 1 : 2;
   for($i = 0; $i < strlen($ccard); $i++){
     $digit = substr($ccard, $i, 1);
     $checksum += ($digit * $factor > 9) ? $digit * $factor - 9 : $digit * $factor;
     $factor = ($factor == 1) ? 2 : 1;
   }
   return !($checksum % 10);
 }


if ($ccnum){
	if (!CC_checksum($ccnum)){
		print "The Credit Card Number appears to be invalid";
		exit;
	}

	#check credit card date
	


	#add the credit card to the database
	$ccexpire = "$ExpiryDateYear-$ExpiryDateMonth-01";
	$msql="UPDATE MasterAccounts SET CreditCardNumbor='$ccnum', CreditCardExp='$ccexpire' WHERE CustomerID=$CustomerID";
	mysql_query($msql);
	if (mysql_error())
		print "Credit Card Update Error: ".mysql_error();
}



if (!$PaymentType){
	print "Please specify a payment type!";
	exit;

}

if (!$PaymentObject){
	print "Nothing to do!";
	exit;

}

if (!$NumHours)
	$NumHours=$hours;


if ($PaymentObject=="Casual"){
	if ($NumHours){
		$Rate=intval($dollars*100/$NumHours)/100;
		$amount=$dollars;
		$purchase="$NumHours Casual Hrs @ $Rate/hour";
	}else{
		print "<H1>No Hours Entered!</H1>";
		exit;
	}	
}elseif($PaymentObject=="Plan"){
	#do plans
	if (!$PlanType){
		print "Error in Plan Type";
		exit;
	}
	$psql="SELECT * FROM PlanTypes WHERE PlanID=$PlanType";
	$pres=mysql_query($psql);
	$prow=mysql_fetch_array($pres);
	$purchase=$prow[PlanName];
	$amount=$prow[Cost];

	$kbytequota = $prow[WeeklyDownloadLimit];
	$excesscharge = $prow[ExcessCharge];
	$maxcon = $prow[MaxCon];
	$mailboxsize = $prow[MailBoxSize];
	$maxlogins = $prow[MaxLogins];
	
	$startminutes = $prow[StartMinutes];
	$endminutes = $prow[EndMinutes];	

}elseif($PaymentObject=="Misc"){
	#miscellaneous payment
	if (!$Misc&& $Misc<>'0'){
		print "You selected Miscellaneous Payment But didn't specify an amount!";
		exit;
	}

	if (!$MiscDesc){
		print "Please provide a description for any Miscellaneous Payment.";
		exit;
	}
	$amount=$Misc;
	$purchase=$MiscDesc;
}

$rsql="SELECT Reseller, RecurDealer, TimeRemaining, ExpireDate FROM
MasterAccounts WHERE CustomerID=$ID";
$result=mysql_query($rsql);

if (mysql_num_rows($result)){

 	$marow=mysql_fetch_array($result);

 	if ($marow[RecurDealer])
 	{
		$ResellerOriginal=$marow[Reseller];
		##$resellercommissionamt=$amount*$resellercommissionrate;
 	}else{
		print "No Reseller!";
		$resellercommissionamt=0;
 	}
}else{

	die("MasterAccounts Query Error");
}

########################
# dealer commissions   #
########################

if ($ResellerOriginal){
	$dcsql = "SELECT ResellerCommission FROM Dealer WHERE DealerID=$ResellerOriginal";
	$dcres = mysql_query($dcsql);
	if (mysql_num_rows($dcres)){
		
		$resellercommissionrate=mysql_result($dcres,0);
		print "Reseller Commission assigned: $resellercommissionrate\n";

		#don't bother calculating unless we're in here.
		$resellercommissionamt=$amount * $resellercommissionrate;
		print "R$ $resellercommissionamt. A$ $amount R% $resellercommissionrate.";
	}else{
		$perr.="Reseller Error with ResellerCommission for Reseller $ResellerOriginal::";
	}
}


if($ResellerPay){
	#agent took this payment
	$agentcommissionamt=$amount*$agentcommissionrate;
}

if ($PaymentType=='Credit Card Pend'||$PaymentType=='Cheque in Mail'||$PaymentType=='Invoice'){
	$credit=1;
}

$ptsql="SELECT CreditCheck 
	FROM PaymentTypes 
	WHERE PaymentTypeName='$PaymentType'";

$ptres=mysql_query($ptsql);
$ptrow=mysql_fetch_row($ptres);
	if ($ptrow[0]>0)
		$credit=1;

print "Original Reseller: $ResellerOriginal\n";
$identity="$REMOTE_ADDR-$PHP_AUTH_USER";

$isql="INSERT INTO Payments(
PaymentID,CustomerID,PaymentType,PaymentAmount,PaymentDate,Purchase,
RecallName,RecallPhone,ResellerOriginal,ResellerPayment,Identifier,
ResellerCommission,AgentCommission,Credit)
VALUES('',$ID,'$PaymentType','$amount',Now(),'$purchase',
'$RecallName','$RecallPhone','$ResellerOriginal','$ResellerPay','$identity',
'$resellercommissionamt', '$agentcommissionamt','$credit')"; 

print $isql;

mysql_query($isql);
if (mysql_errno())
        print "<H1>Payment Error: ".mysql_error()."</H1>";


if ($PaymentObject=="Casual"){
	$numminutes=$NumHours*60;

	$usql="UPDATE MasterAccounts SET
TimeRemaining=TimeRemaining+$numminutes,LastModifyDate=now(),LastModifyUser='$PHP_AUTH_USER' 
WHERE CustomerID=$ID";
	mysql_query($usql);
	if (mysql_errno())
        print "<H1>Add Time Error: ".mysql_error()."</H1>";
	print $usql;

}elseif($PaymentObject=="Plan"){
	#Audit Customer? - check for existing expire etc.

  if ($prow[AccountType]=='casual'||$prow[AccountType] == 'Blocks'){
	
	$usql="UPDATE MasterAccounts
	SET KbyteQuota='$kbytequota',
	ExcessCharge='$excesscharge',";

	if ($accounttype <> $prow[AccountType]){
		#overwrite existing account stuff
	
		#make a note first..
		$note = "Account Changed. TimeRemaining was $marow[TimeRemaining], Expire was $marow[ExpireDate], 
		Account Type was $accounttype";
		
		$susql = "UPDATE SubAccounts 
			SET AccountType = '$prow[AccountType]',
			MaxConnectTime = '$maxcon',
			MailBoxSize = '$mailboxsize',
			LoginLimit = '$maxlogins',
			StartMinutes = '$startminutes',
			EndMinutes = '$endminutes', 
			WHERE CustomerID=$CustomerID
			AND AccountType='$accounttype'";		

		$usql.=" TimeRemaining='$prow[TimeRemaining]', ExpireDate='0000-00-00' ";
		
	}else{
		$usql.=" TimeRemaining=TimeRemaining+'$prow[TimeRemaining]'";

		$susql = "UPDATE SubAccounts
                        SET MaxConnectTime = '$maxcon',
                        MailBoxSize = '$mailboxsize',
                        LoginLimit = '$maxlogins'
                        WHERE CustomerID=$CustomerID
                        AND AccountType='$accounttype'";
	}

	$usql.=" WHERE CustomerID=$CustomerID";


  }else{

	#check for  existing expire date
	$esql = "SELECT ExpireDate FROM MasterAccounts WHERE CustomerID = $CustomerID";
	$eres = mysql_query($esql);
	$expire = mysql_result($eres,0);
	
	if (!$expire || substr($expire,0,4)=="0000" || $accounttype <> $prow[AccountType]){
		$exstr = 'now()';
		#make a note
		$note = "Account Changed. TimeRemaining was $marow[TimeRemaining], Expire was $marow[ExpireDate],
                Account Type was $accounttype";

		 $susql = "UPDATE SubAccounts
                        SET AccountType = '$prow[AccountType]',
                        MaxConnectTime = '$maxcon',
                        MailBoxSize = '$mailboxsize',
                        LoginLimit = '$maxlogins'
                        WHERE CustomerID=$CustomerID
                        AND AccountType='$accounttype'";

	}else{
		$exstr = 'ExpireDate';
		
		$susql = "UPDATE SubAccounts
                        SET MaxConnectTime = '$maxcon',
                        MailBoxSize = '$mailboxsize',
                        LoginLimit = '$maxlogins'
                        WHERE CustomerID=$CustomerID
                        AND AccountType='$accounttype'";
	}

	if ($prow[Months]){
		$interval = "$prow[Months] month";
	}elseif($prow[Days]){
		$interval = "$prow[Days] day";
	}else{
		print "<H2>Error. No Expire Amount in Days or months!!</H2>";
	}

	$usql="UPDATE MasterAccounts 
	SET ExpireDate=DATE_ADD($exstr, Interval $interval),
	KbyteQuota='$kbytequota',
        ExcessCharge='$excesscharge'";

	if ($prow[AccountType] <> $accounttype)
		$usql.=", TimeRemaining='$prow[TimeRemaining]' ";
	else
		$usql.=", TimeRemaining=Timeremaining + '$prow[TimeRemaining]' ";

	$usql.=" WHERE CustomerID=$CustomerID";

  }

	if ($note){
		$nsql = "INSERT INTO Notes(NoteDate, NoteAuthor, CustomerID, NoteText)
			VALUES(now(),'$PHP_AUTH_USER',$CustomerID,'$note')";
		mysql_query($nsql);
		if (mysql_error())
			print "<H2>Notes: ".mysql_error()."</H2>";
	}

	mysql_query($usql);
        if (mysql_errno())
        	print "<H1>Add Time Error: ".mysql_error()."</H1>";
        print $usql;
	
	if ($susql){
		mysql_query($susql);
		if (mysql_error())
			 print "<H1>Add Time Error (SubAccount): ".mysql_error()."</H1>";
	}

}
?>