Solved

PHP {Action}

Posted on 2012-03-12
8
485 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
Comment Utility
You mean it literally has "{Action}" in the form code?

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

Accepted Solution

by:
Dave Baldwin earned 500 total points
Comment Utility
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 108

Expert Comment

by:Ray Paseur
Comment Utility
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
 

Author Comment

by:nachtmsk
Comment Utility
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:nachtmsk
Comment Utility
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
Comment Utility
the code might be in smarty
0
 
LVL 32

Expert Comment

by:DrDamnit
Comment Utility
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 108

Expert Comment

by:Ray Paseur
Comment Utility
@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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…

763 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now