Link to home
Create AccountLog in
Avatar of nachtmsk
nachtmskFlag for United States of America

asked on

PHP {Action}

Hi,
I'm slogging through someone elses code (I'm not a PHP dev).

The form call looks like this:
  <form method="post" action="{Action}" name="{HTMLFormName}">


When I view source on that page I see an actual action (ie action="myscript.php?t=Login")
But I have no clue where that value for {Action} is coming from. I've been grepping like crazy but see nothing.
Could someone shed some light on this and tell me where it could be coming from?
Also, in general, why is the developer using {Action} instead of just putting in the script name?

Thanks
Nacht
Avatar of DrDamnit
DrDamnit
Flag of United States of America image

You mean it literally has "{Action}" in the form code?

It would probably help if you posted the code. Sanitized, of course...
ASKER CERTIFIED SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
My guess, and it is only a guess, is that you're looking at some "pseudo-code" from a framework of some sort.  The authors of frameworks often think they are simplifying the lives of those who are ignorant of programming by putting the framework between the user and the programming language.  In my opinion, this simply interjects another layer of abstraction and complexity.  Frameworks are not like calculators that do math for the math-ignorant.  They are more like lawyers who represent you in court.  If you do not understand every word of what they are saying you are risking an unfortunate outcome at best, or a catastrophe at worst.

So I agree with DrDamnit: Let's see enough of the code to figure out what you are looking at there!  Best, ~Ray
Avatar of nachtmsk

ASKER

Thanks Everyone. here is the code for Login.html. There is also a file called Login.php.

-------------
<html>
<head>
<meta name="GENERATOR" content="CodeCharge Studio 2.3.2.24">
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<title>Registration</title>
<link rel="stylesheet" type="text/css" href="Themes/BlueNote/Style.css">
</head>
<body bgcolor="#ffffff" text="#000000" link="#000000" vlink="#000000" alink="#000000" class="BlueNotePageBODY">
&nbsp;
<!-- BEGIN Record Login -->
<div align="center">
  <form method="post" action="{Action}" name="{HTMLFormName}">
    <p><font class="BlueNoteFormHeaderFont">Registration</font></p>

    <p><font class="">Please login with your User/ID password <br>
   <br>
    <br>



    </font>
    <table cellpadding="4" class="BlueNoteFormTABLE">
      <!-- BEGIN Error -->
      <tr>
        <td colspan="2" class="BlueNoteErrorDataTD">{Error}</td>
      </tr>
      <!-- END Error -->
      <tr>
        <td class="BlueNoteFieldCaptionTD">Login&nbsp;</td>
        <td class="BlueNoteDataTD"><input name="{login_Name}" value="{login}" maxlength="100" class="BlueNoteInput">&nbsp;</td>
      </tr>

      <tr>
        <td class="BlueNoteFieldCaptionTD">Password&nbsp;</td>
        <td class="BlueNoteDataTD"><input type="password" name="{password_Name}" value="{password}" maxlength="100" class="BlueNoteInput">&nbsp;</td>
      </tr>

      <tr>
        <td colspan="2" align="right" nowrap class="BlueNoteFooterTD">
          <!-- BEGIN Button Button_DoLogin --><input name="{Button_Name}" type="submit" value="Login" class="BlueNoteButton"><!-- END Button Button_DoLogin -->&nbsp; </td>
      </tr>

    </table>

 

    <p>&nbsp;</p>

    <p><br>
    <!-- END Record Login -->{Footer} </p>

  </form>
</div>
</body>
</html>
Here is the code for Login.php

<?php
//Include Common Files @1-5471E0F2
define("RelativePath", ".");
include(RelativePath . "/Common.php");
include(RelativePath . "/Template.php");
include(RelativePath . "/Sorter.php");
include(RelativePath . "/Navigator.php");

//End Include Common Files

class clsRecordLogin { //Login Class @2-58926B8F

//Variables @2-B2F7A83E

    // Public variables
    var $ComponentName;
    var $HTMLFormAction;
    var $PressedButton;
    var $Errors;
    var $ErrorBlock;
    var $FormSubmitted;
    var $FormEnctype;
    var $Visible;
    var $Recordset;

    var $CCSEvents = "";
    var $CCSEventResult;

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

    // Class variables
//End Variables

//Class_Initialize Event @2-8773475B
    function clsRecordLogin()
    {

        global $FileName;
        $this->Visible = true;
        $this->Errors = new clsErrors();
        $this->ErrorBlock = "Record Login/Error";
        $this->ReadAllowed = true;
        if($this->Visible)
        {
            $this->ComponentName = "Login";
            $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->login = new clsControl(ccsTextBox, "login", "login", ccsText, "", CCGetRequestParam("login", $Method));
            $this->login->Required = true;
            $this->password = new clsControl(ccsTextBox, "password", "password", ccsText, "", CCGetRequestParam("password", $Method));
            $this->password->Required = true;
            $this->Button_DoLogin = new clsButton("Button_DoLogin");
        }
    }
//End Class_Initialize Event

//Validate Method @2-DC81CDE9
    function Validate()
    {
        $Validation = true;
        $Where = "";
        $Validation = ($this->login->Validate() && $Validation);
        $Validation = ($this->password->Validate() && $Validation);
        $this->CCSEventResult = CCGetEvent($this->CCSEvents, "OnValidate");
        $Validation =  $Validation && ($this->login->Errors->Count() == 0);
        $Validation =  $Validation && ($this->password->Errors->Count() == 0);
        return (($this->Errors->Count() == 0) && $Validation);
    }
//End Validate Method

//CheckErrors Method @2-CE95D583
    function CheckErrors()
    {
        $errors = false;
        $errors = ($errors || $this->login->Errors->Count());
        $errors = ($errors || $this->password->Errors->Count());
        $errors = ($errors || $this->Errors->Count());
        return $errors;
    }
//End CheckErrors Method

//Operation Method @2-3942470C
    function Operation()
    {
        if(!$this->Visible)
            return;

        global $Redirect;
        global $FileName;

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

        if($this->FormSubmitted) {
            $this->PressedButton = "Button_DoLogin";
            if(strlen(CCGetParam("Button_DoLogin", ""))) {
                $this->PressedButton = "Button_DoLogin";
            }
        }
        $Redirect = $FileName;
        if($this->Validate()) {
            if($this->PressedButton == "Button_DoLogin") {
                if(!CCGetEvent($this->Button_DoLogin->CCSEvents, "OnClick")) {
                    $Redirect = "";
                }
            }
        } else {
            $Redirect = "";
        }
    }
//End Operation Method

//Show Method @2-F64E47DF
    function Show()
    {
        global $Tpl;
        global $FileName;
        $Error = "";

        if(!$this->Visible)
            return;

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


        $RecordBlock = "Record " . $this->ComponentName;
        $ParentPath = $Tpl->block_path;
        $Tpl->block_path = $ParentPath . "/" . $RecordBlock;
        $this->EditMode = $this->EditMode && $this->ReadAllowed;
        if(!$this->FormSubmitted)
        {
        }

        if($this->FormSubmitted || $this->CheckErrors()) {
            $Error .= $this->login->Errors->ToString();
            $Error .= $this->password->Errors->ToString();
            $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->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeShow");
        if(!$this->Visible) {
            $Tpl->block_path = $ParentPath;
            return;
        }

        $this->login->Show();
        $this->password->Show();
        $this->Button_DoLogin->Show();
        $Tpl->parse();
        $Tpl->block_path = $ParentPath;
    }
//End Show Method

} //End Login Class @2-FCB6E20C

//Include Page implementation @8-58DBA1E3
include_once(RelativePath . "/Footer.php");
//End Include Page implementation

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

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

$FileName = "Login.php";
$Redirect = "";
$TemplateFileName = "Login.html";
$BlockToParse = "main";
$TemplateEncoding = "";
$FileEncoding = "";
$PathToRoot = "./";
//End Initialize Page

//Initialize Objects @1-CB3D8D21

// Controls
$Login = new clsRecordLogin();
$Footer = new clsFooter("");
$Footer->BindEvents();
$Footer->Initialize();

// Events
include("./Login_events.php");
BindEvents();

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

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

//Initialize HTML Template @1-BA4209C8
$CCSEventResult = CCGetEvent($CCSEvents, "OnInitializeView");
$Tpl = new clsTemplate($FileEncoding, $TemplateEncoding);
$Tpl->LoadTemplate(TemplatePath . $TemplateFileName, "main", $TemplateEncoding);
$CCSEventResult = CCGetEvent($CCSEvents, "BeforeShow");
//End Initialize HTML Template

//Execute Components @1-ABCE2C31
$Login->Operation();
$Footer->Operations();
//End Execute Components

//Go to destination page @1-B929EE1C
if($Redirect)
{
    $CCSEventResult = CCGetEvent($CCSEvents, "BeforeUnload");
    header("Location: " . $Redirect);
    unset($Login);
    $Footer->Class_Terminate();
    unset($Footer);
    unset($Tpl);
    exit;
}
//End Go to destination page

//Show Page @1-3E61D024
$Login->Show();
$Footer->Show("Footer");
$Tpl->PParse("main", false);
//End Show Page

//Unload Page @1-4DB48991
$CCSEventResult = CCGetEvent($CCSEvents, "BeforeUnload");
unset($Login);
$Footer->Class_Terminate();
unset($Footer);
unset($Tpl);
//End Unload Page


?>
the code might be in smarty
I agree with rakjosh. It looks like smarty or some other template based system that is psuedo-cms.

http://www.smarty.net/

?? Any smarty experts ??
@DrDamnit: I wish EE would stand up zones for these topics which get lumped together in a rather thoughtless manner under the PHP Zone.

Wordpress, Drupal, Joomla.

And for these which wind up in the JavaScript Zone

Ajax, jQuery

Maybe Smarty would merit its own Zone, too.  The point here is not that Wordpress is written in PHP; the point is that 99% of the questions about Wordpress are not about PHP.  My guess is the same would be true of Smarty.

So if you have the ear of anyone at EE, let's try to inject some sanity into the Zone system.

Best to all, ~Ray