...

View Full Version : How does this code generate a page?



rock_14
06-09-2007, 09:53 PM
I have a project I have taken over from another developer. I am trying to understand what he has done. It looks like he is using some templating engine, but I don't know which one.

In particular, after a user registers at register.php they are taken to register2.php. On register2.php they enter their credit card information that is then passed to authorize.net.

I think I can do the authorize.net part, but I don't know how to change the form action= correctly.

On register2.html, I have the following code from the previous developer:



<form name="{HTMLFormName}" action="{Action}" method="post">


On register2.php, I have the following code as it relates to form action.



<?php

//Include Common Files @1-D05D8DF9
define("RelativePath", ".");
define("PathToCurrentPage", "/");
define("FileName", "register2.php");
include(RelativePath . "/Common.php");
include(RelativePath . "/Template.php");
include(RelativePath . "/Sorter.php");
include(RelativePath . "/Navigator.php");
//End Include Common Files

class clsRecordusers { //users Class @36-9BE1AF6F

//Variables @36-D6FF3E86

// Public variables
var $ComponentType = "Record";
var $ComponentName;
var $Parent;
var $HTMLFormAction;
var $PressedButton;
var $Errors;
var $ErrorBlock;
var $FormSubmitted;
var $FormEnctype;
var $Visible;
var $IsEmpty;

var $CCSEvents = "";
var $CCSEventResult;

var $RelativePath = "";

var $InsertAllowed = false;
var $UpdateAllowed = false;
var $DeleteAllowed = false;
var $ReadAllowed = false;
var $EditMode = false;
var $ds;
var $DataSource;
var $ValidatingControls;
var $Controls;
var $Attributes;

// Class variables
//End Variables

//Class_Initialize Event @36-F9A91C9F
function clsRecordusers($RelativePath, & $Parent)
{

global $FileName;
global $CCSLocales;
global $DefaultDateFormat;
$this->Visible = true;
$this->Parent = & $Parent;
$this->RelativePath = $RelativePath;
$this->Errors = new clsErrors();
$this->ErrorBlock = "Record users/Error";
$this->ReadAllowed = true;
if($this->Visible)
{
$this->ComponentName = "users";
$this->Attributes = new clsAttributes($this->ComponentName . ":");
$CCSForm = split(":", CCGetFromGet("ccsForm", ""), 2);
if(sizeof($CCSForm) == 1)
$CCSForm[1] = "";
list($FormName, $FormMethod) = $CCSForm;
$this->FormEnctype = "application/x-www-form-urlencoded";
$this->FormSubmitted = ($FormName == $this->ComponentName);
$Method = $this->FormSubmitted ? ccsPost : ccsGet;
$this->first_name = & new clsControl(ccsTextBox, "first_name", "First Name", ccsText, "", CCGetRequestParam("first_name", $Method, NULL), $this);
$this->first_name->Required = true;
$this->last_name = & new clsControl(ccsTextBox, "last_name", "Last Name", ccsText, "", CCGetRequestParam("last_name", $Method, NULL), $this);
$this->last_name->Required = true;
$this->street = & new clsControl(ccsTextBox, "street", "Street", ccsText, "", CCGetRequestParam("street", $Method, NULL), $this);
$this->street->Required = true;
$this->city = & new clsControl(ccsTextBox, "city", "City", ccsText, "", CCGetRequestParam("city", $Method, NULL), $this);
$this->city->Required = true;
$this->state = & new clsControl(ccsListBox, "state", "State", ccsText, "", CCGetRequestParam("state", $Method, NULL), $this);
$this->state->DSType = dsTable;
list($this->state->BoundColumn, $this->state->TextColumn, $this->state->DBFormat) = array("id_state", "state", "");
$this->state->DataSource = new clsDBConnection1();
$this->state->ds = & $this->state->DataSource;
$this->state->DataSource->SQL = "SELECT * \n" .
"FROM state {SQL_Where} {SQL_OrderBy}";
$this->state->Required = true;
$this->zip_code = & new clsControl(ccsTextBox, "zip_code", "Zip Code", ccsInteger, "", CCGetRequestParam("zip_code", $Method, NULL), $this);
$this->zip_code->Required = true;
$this->cc_num = & new clsControl(ccsTextBox, "cc_num", "Credit Card Number:", ccsText, "", CCGetRequestParam("cc_num", $Method, NULL), $this);
$this->cc_num->Required = true;
$this->expiration_date = & new clsControl(ccsTextBox, "expiration_date", "Expiration Date", ccsDate, array("mm", "/", "yy"), CCGetRequestParam("expiration_date", $Method, NULL), $this);
$this->expiration_date->Required = true;
$this->DatePicker_expiration_date = & new clsDatePicker("DatePicker_expiration_date", "users", "expiration_date", $this);
$this->Button_Insert = & new clsButton("Button_Insert", $Method, $this);
$this->Button_Update = & new clsButton("Button_Update", $Method, $this);
$this->Button_Delete = & new clsButton("Button_Delete", $Method, $this);
if(!$this->FormSubmitted) {
if(!is_array($this->state->Value) && !strlen($this->state->Value) && $this->state->Value !== false)
$this->state->SetText(44);
if(!is_array($this->expiration_date->Value) && !strlen($this->expiration_date->Value) && $this->expiration_date->Value !== false)
$this->expiration_date->SetValue(time());
}
}
}
//End Class_Initialize Event

//Validate Method @36-401DC157
function Validate()
{
global $CCSLocales;
$Validation = true;
$Where = "";
$Validation = ($this->first_name->Validate() && $Validation);
$Validation = ($this->last_name->Validate() && $Validation);
$Validation = ($this->street->Validate() && $Validation);
$Validation = ($this->city->Validate() && $Validation);
$Validation = ($this->state->Validate() && $Validation);
$Validation = ($this->zip_code->Validate() && $Validation);
$Validation = ($this->cc_num->Validate() && $Validation);
$Validation = ($this->expiration_date->Validate() && $Validation);
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "OnValidate", $this);
$Validation = $Validation && ($this->first_name->Errors->Count() == 0);
$Validation = $Validation && ($this->last_name->Errors->Count() == 0);
$Validation = $Validation && ($this->street->Errors->Count() == 0);
$Validation = $Validation && ($this->city->Errors->Count() == 0);
$Validation = $Validation && ($this->state->Errors->Count() == 0);
$Validation = $Validation && ($this->zip_code->Errors->Count() == 0);
$Validation = $Validation && ($this->cc_num->Errors->Count() == 0);
$Validation = $Validation && ($this->expiration_date->Errors->Count() == 0);
return (($this->Errors->Count() == 0) && $Validation);
}
//End Validate Method

//CheckErrors Method @36-2FC55FE7
function CheckErrors()
{
$errors = false;
$errors = ($errors || $this->first_name->Errors->Count());
$errors = ($errors || $this->last_name->Errors->Count());
$errors = ($errors || $this->street->Errors->Count());
$errors = ($errors || $this->city->Errors->Count());
$errors = ($errors || $this->state->Errors->Count());
$errors = ($errors || $this->zip_code->Errors->Count());
$errors = ($errors || $this->cc_num->Errors->Count());
$errors = ($errors || $this->expiration_date->Errors->Count());
$errors = ($errors || $this->DatePicker_expiration_date->Errors->Count());
$errors = ($errors || $this->Errors->Count());
return $errors;
}
//End CheckErrors Method

//Operation Method @36-AF15C64E
function Operation()
{
if(!$this->Visible)
return;

global $Redirect;
global $FileName;

if(!$this->FormSubmitted) {
return;
}

if($this->FormSubmitted) {
$this->PressedButton = "Button_Insert";
if($this->Button_Insert->Pressed) {
$this->PressedButton = "Button_Insert";
} else if($this->Button_Update->Pressed) {
$this->PressedButton = "Button_Update";
} else if($this->Button_Delete->Pressed) {
$this->PressedButton = "Button_Delete";
}
}
$Redirect = $FileName . "?" . CCGetQueryString("QueryString", array("ccsForm"));
if($this->PressedButton == "Button_Delete") {
if(!CCGetEvent($this->Button_Delete->CCSEvents, "OnClick", $this->Button_Delete)) {
$Redirect = "";
}
} else if($this->Validate()) {
if($this->PressedButton == "Button_Insert") {
if(!CCGetEvent($this->Button_Insert->CCSEvents, "OnClick", $this->Button_Insert)) {
$Redirect = "";
}
} else if($this->PressedButton == "Button_Update") {
if(!CCGetEvent($this->Button_Update->CCSEvents, "OnClick", $this->Button_Update)) {
$Redirect = "";
}
}
} else {
$Redirect = "";
}
}
//End Operation Method

//Show Method @36-DB44E9C2
function Show()
{
global $Tpl;
global $FileName;
global $CCSLocales;
$Error = "";

if(!$this->Visible)
return;

$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeSelect", $this);

$this->state->Prepare();

$RecordBlock = "Record " . $this->ComponentName;
$ParentPath = $Tpl->block_path;
$Tpl->block_path = $ParentPath . "/" . $RecordBlock;
$this->EditMode = $this->EditMode && $this->ReadAllowed;

if($this->FormSubmitted || $this->CheckErrors()) {
$Error = "";
$Error = ComposeStrings($Error, $this->first_name->Errors->ToString());
$Error = ComposeStrings($Error, $this->last_name->Errors->ToString());
$Error = ComposeStrings($Error, $this->street->Errors->ToString());
$Error = ComposeStrings($Error, $this->city->Errors->ToString());
$Error = ComposeStrings($Error, $this->state->Errors->ToString());
$Error = ComposeStrings($Error, $this->zip_code->Errors->ToString());
$Error = ComposeStrings($Error, $this->cc_num->Errors->ToString());
$Error = ComposeStrings($Error, $this->expiration_date->Errors->ToString());
$Error = ComposeStrings($Error, $this->DatePicker_expiration_date->Errors->ToString());
$Error = ComposeStrings($Error, $this->Errors->ToString());
$Tpl->SetVar("Error", $Error);
$Tpl->Parse("Error", false);
}
$CCSForm = $this->EditMode ? $this->ComponentName . ":" . "Edit" : $this->ComponentName;
$this->HTMLFormAction = $FileName . "?" . CCAddParam(CCGetQueryString("QueryString", ""), "ccsForm", $CCSForm);
$Tpl->SetVar("Action", $this->HTMLFormAction);
$Tpl->SetVar("HTMLFormName", $this->ComponentName);
$Tpl->SetVar("HTMLFormEnctype", $this->FormEnctype);
$this->Button_Update->Visible = $this->EditMode && $this->UpdateAllowed;
$this->Button_Delete->Visible = $this->EditMode && $this->DeleteAllowed;

$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeShow", $this);
$this->Attributes->Show();
if(!$this->Visible) {
$Tpl->block_path = $ParentPath;
return;
}

$this->first_name->Show();
$this->last_name->Show();
$this->street->Show();
$this->city->Show();
$this->state->Show();
$this->zip_code->Show();
$this->cc_num->Show();
$this->expiration_date->Show();
$this->DatePicker_expiration_date->Show();
$this->Button_Insert->Show();
$this->Button_Update->Show();
$this->Button_Delete->Show();
$Tpl->parse();
$Tpl->block_path = $ParentPath;
}
//End Show Method

} //End users Class @36-FCB6E20C

//Initialize Page @1-0AC484AA
// Variables
$FileName = "";
$Redirect = "";
$Tpl = "";
$TemplateFileName = "";
$BlockToParse = "";
$ComponentName = "";
$Attributes = "";

// Events;
$CCSEvents = "";
$CCSEventResult = "";

$FileName = FileName;
$Redirect = "";
$TemplateFileName = "register2.html";
$BlockToParse = "main";
$TemplateEncoding = "ISO-8859-1";
$PathToRoot = "./";
//End Initialize Page

//Include events file @1-CA384476
include("./register2_events.php");
//End Include events file

//Before Initialize @1-E870CEBC
$CCSEventResult = CCGetEvent($CCSEvents, "BeforeInitialize", $MainPage);
//End Before Initialize

//Initialize Objects @1-C55CC3AA
$DBConnection1 = new clsDBConnection1();
$MainPage->Connections["Connection1"] = & $DBConnection1;
$Attributes = new clsAttributes("page:");
$MainPage->Attributes = & $Attributes;

// Controls
$users = & new clsRecordusers("", $MainPage);
$MainPage->users = & $users;

BindEvents();

$CCSEventResult = CCGetEvent($CCSEvents, "AfterInitialize", $MainPage);

$Charset = $Charset ? $Charset : "iso-8859-1";
if ($Charset)
header("Content-Type: text/html; charset=" . $Charset);
//End Initialize Objects

//Initialize HTML Template @1-A8C4B9DA
$CCSEventResult = CCGetEvent($CCSEvents, "OnInitializeView", $MainPage);
$Tpl = new clsTemplate($FileEncoding, $TemplateEncoding);
$Tpl->LoadTemplate(PathToCurrentPage . $TemplateFileName, $BlockToParse, "ISO-8859-1");
$Tpl->block_path = "/$BlockToParse";
$CCSEventResult = CCGetEvent($CCSEvents, "BeforeShow", $MainPage);
$Attributes->Show();
//End Initialize HTML Template

//Execute Components @1-0C9864E9
$users->Operation();
//End Execute Components

//Go to destination page @1-9AF71AD7
if($Redirect)
{
$CCSEventResult = CCGetEvent($CCSEvents, "BeforeUnload", $MainPage);
$DBConnection1->close();
header("Location: " . $Redirect);
unset($users);
unset($Tpl);
exit;
}
//End Go to destination page

//Show Page @1-AA55A8F2
$users->Show();
$Tpl->block_path = "";
$Tpl->Parse($BlockToParse, false);
$main_block = $Tpl->GetVar($BlockToParse);
$CCSEventResult = CCGetEvent($CCSEvents, "BeforeOutput", $MainPage);
if ($CCSEventResult) echo $main_block;
//End Show Page

//Unload Page @1-D3A38D06
$CCSEventResult = CCGetEvent($CCSEvents, "BeforeUnload", $MainPage);
$DBConnection1->close();
unset($users);
unset($Tpl);
//End Unload Page


?>


Can anyone guess at what templating engine he used? Can anyone tell me a how to approach this? I need the action= {Action} to go to authorize.net, but I think simply changing it will cause a lot of problems.

Any ideas? Any help/advice would be greatly appreciated.:)

_Aerospace_Eng_
06-10-2007, 03:13 AM
Usually things like this are in the language files. Have you tried doing a search for this term? HTMLFormName If using DW this would be quite easy.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum