Solved

PHP {Action}

Posted on 2012-03-12
8
491 Views
Last Modified: 2012-03-16
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
0
Comment
Question by:nachtmsk
  • 2
  • 2
  • 2
  • +2
8 Comments
 
LVL 32

Expert Comment

by:DrDamnit
ID: 37712621
You mean it literally has "{Action}" in the form code?

It would probably help if you posted the code. Sanitized, of course...
0
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 37712664
If that's in a PHP string, the curly braces force execution and that could mean in this case that Action is a defined string constant somewhere in the code.  Otherwise, it often means that those are variables the some program is supposed to substitute values for.  Keep an eye out for some program or PHP that reads that file and parses it.
0
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 37712689
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
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

Author Comment

by:nachtmsk
ID: 37712875
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>
0
 

Author Comment

by:nachtmsk
ID: 37712884
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


?>
0
 
LVL 1

Expert Comment

by:rakjosh
ID: 37713114
the code might be in smarty
0
 
LVL 32

Expert Comment

by:DrDamnit
ID: 37716505
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 ??
0
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 37716824
@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
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
paypal ipn url 5 55
PHP AJAX JSON 2 58
How can I implement a "Select All" with this configuration...? 6 39
What does != "" mean in programming 8 26
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
This article discusses how to create an extensible mechanism for linked drop downs.
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question