I have just translated my delphi project to C#. I need a little help fixing some of the code I couldn't fix. One code I couldn't fix was xplode.
Here is my source:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Threading;
using System.IO;
using System.Text;
using System.Diagnostics;
using System.Data;
using System.Data.SqlClient;
using System.Xml;
namespace Project1.Unit1_NS
{
public partial class TForm1 : Form
{
internal static ArrayList alParams;
private tsUtils aUtils;
private dbConnection dbConn;
protected SqlDataReader dr;
protected StringBuilder sbSQL;
public TForm1()
{
// Required for Windows Form Designer support
InitializeComponent();
aUtils = new tsUtils();
dbConn = new dbConnection( aUtils );
alParams = new ArrayList();
}
public TIdHTTP IdHTTP1;
public TIdAntiFreeze IdAntiFreeze1;
public TLabeledEdit LabeledEdit1;
public TLabeledEdit LabeledEdit2; /* Private declarations */// Public declarations
public void Button1Click(object sender, EventArgs e)
{
TStringlist strs;
int i,j,k;
Label1.Text = "Status: Logging In";
strs = new RichTextBox();
strs.AppendText("next=1");
strs.AppendText("path=");
strs.AppendText("username="+LabeledEdit1.Text);
strs.AppendText("password="+LabeledEdit2.Text);
recieve = IdHTTP1.("http://extremegpt.com/members/login.php?next",strs);
if((recieve.IndexOf("Members - Home")!=0) )
{
Label1.Text = "Status: Doing Clicks!";
recieve = IdHTTP1.Get("http://extremegpt.com/members/signupPTS.php?cid=296");
while(((recieve.IndexOf("<a href=\"http://extremegpt.com/members/pts/click.php")!=0) && (Stop() == false)) )
{
try {
recieve = IdHTTP1.Get("http://extremegpt.com/members/signupPTS.php?cid=296");
i = recieve.IndexOf("<a href=\"http://extremegpt.com/members/pts/click.php");recieve=recieve.Remove(i-1,40);
explode(EX1,"<a href=\"http://extremegpt.com/members/pts/click.php",recieve);
explode(EX2, "\" target=\"_blank\" onclick=\"", EX1[1]);
Label1.Text = "Status: Visit "+EX2[0];
within = IdHTTP1.Get("http://extremegpt.com/members/pts/click.php"+EX2[0]);
explode(EX1,"0;url=",within);
explode(EX2, "\">",EX1[1]);
within = IdHTTP1.Get(EX2[0]);
explode= (EX1,"url=",within);
explode= (EX2, "\">",EX1[1]);
within = IdHTTP1.Get(EX2[0]);
Label1.Text = "Status: Visit 1 link";
for( j = 0;j <= 1;j++) {
i = within.IndexOf("href=\"");within=within.Remove(i-1,10);
}
explode(EX1,"href=\"",within);
explode(EX2, "\"",EX1[1]);
within = IdHTTP1.Get(IdHTTP1.Request.Host+"/"+EX2[0]);
Label1.Text = "Status: Cleaning Up";
explode(EX1,"<form method=\"POST\" action=\"signupPTS.php?",recieve);
explode(EX2,"\" style=\"margin:0px\">",EX1[1]);
strs.Clear();
IdHTTP1.("http://extremegpt.com/members/signupPTS.php?"+EX2[0],strs);
k = randomrange(5,10);
Label1.Text = "Status: Wait " + Convert.ToString( k ) +" Seconds";
Delay(k*1000);
}
catch(Exception)
{
ON E:EXCEPTION )
{
Label2.ForeColor = Color.Red;
Label2.Text = "Exception Caught: " + E.Message + ". Continue. ID: " + Convert.ToString( RandomRange(1000,9999) );
explode(EX1,"<form method=\"POST\" action=\"signupPTS.php?",recieve);
explode(EX2,"\" style=\"margin:0px\">",EX1[1]);
strs.Clear();
IdHTTP1.("http://extremegpt.com/members/signupPTS.php?"+EX2[0],strs);
continue;
}
}
}
Label1.Text = "Status: No Ads Found!";
IdHTTP1.CookieManager.CookieCollection.Clear();
} else
Label1.Text = "Status: Wrong Info!";
}
public void Button2Click(object sender, EventArgs e)
{
Stop() = true;
IdHTTP1.Destroy;
Application.Exit();
}
public void Button3Click(object sender, EventArgs e)
{
Process tsProcess = new Process();
tsProcess.StartInfo.FileName = "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=XUJSAHCBY58A4";
tsProcess.StartInfo.Arguments = "null";
tsProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal; tsProcess.Start();
while( !tsProcess.HasExited ) { Application.DoEvents(); } // wait until process finishes
if( tsProcess.ExitCode != 0 )
{
MessageBox.Show( "Error loading process: " + tsProcess.ExitCode );
Application.Exit();
}
tsProcess.Close();
;
}
}
public static class Unit1
{
public static TForm1 Form1;
private string recieve,within;
private TStrArray EX1,EX2;
private boolean stop = false;
internal int Explode( TStrArray a, string Border,string S)
{
string S2;
int Result;
Result = 0;
S2 = S + Border;
do
{
SetLength(a, a.Length + 1);
a[Result] = S2.Substring( S2.IndexOf(Border) - 1, 0);S2=S2.Remove( 1-1,a[Result] + Border.Length);
Result++;
}
while( S2 == "");
return Result;
}
internal void Delay( long dwMilliseconds)
{
double iStart, iStop;
iStart = GetTickCount;
do
{
iStop = GetTickCount;
Application.DoEvents();
Thread.Sleep(1); // addition from Christian Scheffler to avoid high CPU last
}
while( (iStop - iStart) >= dwMilliseconds);
}
}
}