CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 CCS very helpful- select DB, table in DB and then a grid page to show data from selected table.

Print topic Send  topic

Author Message
man_linux

Posts: 13
Posted: 08/11/2006, 11:21 AM

Hi,
I am using this software to make a small front end of PHP and database MySQL.
Its just two pages portal, but CCS is making it very complicated. So many common files, classes, variables, properties and not easy to make custom changes in code, feature of inserting ‘custom code’ isn’t useful because to put custom code you need to understand all classes and variables from all files and then make your own code, which is very hard.
The grid boulder is hopeless, it binds grid to particular table, I have MySQL with frequently changing databases and tables in them. I need one page to select database and table and then a grid to show data from any selected tables.
I didn’t find any way to make a form to show list of databases, then select one database. Again I need to have one more list box showing tables from selected database, and then a grid to show data from that table. All tables in all database are with same columns and names. So I need just 1 grid to show all tables. Also search output to the same grid from selected DB and table. I want to put all this in two pages but CCS is not capable of doing it.
Is there any one who managed to do this, please let me know the way.
View profile  Send private message
peterr


Posts: 5971
Posted: 08/11/2006, 12:16 PM

I suspect that you don't have experience with software development tools, like Visual Studio, Oracle Forms, Borland Delphi, or MS Access? They are not that much different from CCS framework, features and capabilities. CCS only provides more wizards, visual development, and the open code framework you saw but didn't need to look at :-)

Basic explanation is that all professional tools and frameworks must have substantial amount of code to cover functionality they support. You can find many tools that generate simple code but have 10% of CCS capabilities.
You also don't need to understand any classes or variables to use events and custom code, just like you don't need to debug .NET Framework or disassemble MS Access to be able to use them. Many people create their applications in first week and without having much PHP experience. I also don't know those common classes or variables, just use my own form fields and variables and can create any application I want. The little PHP I know I learned by using CCS, and those are just basic PHP commands. The common code framework is quite transparent and you don't even have to be aware of it. While events are used in the same way as in many other professional 4GL/RAD tools, where sometimes you don't even see common code/framework and all you have are those events.
I'd recommend that you start with the tutorial at http://docs.codecharge.com/studio3/html/QuickStart/Crea...AppBuilder.html and see what you can do with events, without understanding any of the common code. You'll also see how powerful CCS is :-)

Quote :
The grid boulder is hopeless, it binds grid to particular table
Sorry to disappoint you but this is how RAD tools work and should work. You do need to assign data source to your components, preview your grid, design layout around it, specify column captions, etc. If you need an ad-hoc grid then you don't need a RAD/visual development tool. Just write your own code or find a PHP application that does this, rather than a tool.
Though I just noticed that in your specific case you should be able to replace the table name dynamically at run time, as long as all replacement tables have the same columns. Maybe just ask if or how? :-)
Anyway, 'll try to get back to this question when I have a chance to check how to do this. I suspect that many others did this as well, or have ideas - so expect an answer.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
peterr


Posts: 5971
Posted: 08/11/2006, 12:40 PM

Ah, this is documented right here:
http://docs.codecharge.com/studio3/html/ProgrammingTech.../ModifySQL.html

I guess you should be able to replace a table in the existing SQL with another table name. Somewhat related topic is here: http://forums.codecharge.com/posts.php?post_id=77443
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
man_linux

Posts: 13
Posted: 08/11/2006, 1:01 PM

Thanks for help; last 1 week I am trying to make it, I am really frustrated.
I made my code and attached it to grid.
As I want to switch do different databases and select different tables, I made both as variables so it will change from previous selection and reflect in grid but didn’t work, especially on search and grid combination. Search parameters don’t flow properly when I include grid again after first show.

View profile  Send private message
tonyk

Posts: 163
Posted: 08/11/2006, 1:09 PM

You would obtain the names of your databases and then the tables using pretty basic mysql statements, these you could use to populate a temporary table for a grid form in the before show event. Then further custom sql statements to obtain column names if necessary or if you have built a generic grid you should be able to modify the datasource to point to the correct database.
You make very sweeping statements about the inadequacy of CCS as you perceive it. Might I suggest that your comments would be better phrased as "With my present state of knowledge I do not see how this can be done. Any help gratefully received." Its amazing what simple politeness and good manners can achieve.
It would help to know more about your project as there may in fact be a more efficient way of approaching the problem. One would be that if you have a common data structure in many identical tables then you could include a group identifier field to identify the groups of data and put it all in one table. Then if you want to change structure you need only do it once. If you want to dump data you can do so by selecting all records in a particular group.
As far as the common code is concerned I have set up many successful interfaces without ever having had to go near the common files. If you know only the most basic php (like me) and you actually read the manual and do the tutorials you may come to realize just what a powerful tool this is; and the support you will get here, if you are a reasonable person, will be fantatstic.
Anyway lets know more about what you are trying to achieve.
Tony :-)
View profile  Send private message
man_linux

Posts: 13
Posted: 08/11/2006, 1:44 PM

I am running out of time. I tried various event options, nothing worked. sorry for those harsh words.

I am giving my project details....
I got 100s of firewalls, then I get rules of those and put in to MySQL using a script.
Each Firewall makes 1 database of its name, and tables as per access-lists(interfaces) on that firewall. Each table has same kind of columns.

$fw is firewall name/DB name
$acl is access-list/interface name/table

In CCS when I prepare DB connection it only 1 database. Which is in Common.php and db_mysql.php.
To solve this I get all DB names in 1 listbox. (show databases)
second list box it get all tables in DB selected in first listbox (show tables from $fw)

Here are files.
Please ignore print lines in these.

Index.php
//-------------------------------------------
<?php

define("RelativePath", ".");

session_start ();
global $fw;
global $acl;

print "<link href=Styles/Basic/Style_Components.css type=text/css rel=stylesheet>";
print "<link href=Styles/Basic/Style.css type=text/css rel=stylesheet>";


$dbhost="10.10.9.xxx";
$user="root";
$password="mysql";
mysql_connect($dbhost,$user,$password) or die( "Unable to select database");
//@mysql_select_db($database) or die( "Unable to select database");
$query="show databases";
$result = mysql_query($query);

print "<table cellspacing=0 cellpadding=0 border=0>";
print "<tr>";
print "<td valign=top>";
print "<table class=HeaderBasic cellspacing=0 cellpadding=0 border=0>";
print "<tr>";
print "<td class=HeaderLeftBasic><img src=Styles/Basic/Images/Spacer.gif border=0></td>";
print "<th style=WIDTH:975px><center>Firewall Access List Viewer</th>";
print "<td class=HeaderRightBasic><img src=Styles/Basic/Images/Spacer.gif border=0></td>";
print "</tr>";
print "</table>";
print "<table class=RecordBasic cellspacing=0 cellpadding=0>";
print "<tr class=ControlsBasic>";
print "</td>";
print "</tr>";
print "<tr class=BottomBasic>";
print "<td align=right colspan=2>";
print "<p></p>";
print "</tr>";
print "</table>";
print "</td>";
print "</tr>";
print "</table>";

print "<br>";
print "<br>";

print "<form name=firewall action=acl.php method=post>";
print "<table cellspacing=0 cellpadding=0 border=0>";
print "<tr>";
print "<td valign=top>";
print "<table class=HeaderBasic cellspacing=0 cellpadding=0 border=0>";
print "<tr>";
print "<td class=HeaderLeftBasic><img src=Styles/Basic/Images/Spacer.gif border=0></td>";
print "<th>Firewall</th>";
print "<td class=HeaderRightBasic><img src=Styles/Basic/Images/Spacer.gif border=0></td>";
print "</tr>";
print "</table>";
print "<table class=RecordBasic cellspacing=0 cellpadding=0>";
print "<tr class=ControlsBasic>";
print "<td colspan=2>Please select Firewall</td>";
print "</tr>";
print "<tr class=ControlsBasic>";
print "<th style=WIDTH:100px>Name </th>";
print "<td>";
print "<SELECT name=firewall style=WIDTH:200px >";
while ($line = mysql_fetch_array($result))
{
foreach ($line as $value)
{
print "<OPTION value='$value'";
}
print ">$value</OPTION>";

$GLOBALS['fw'] = $_POST['firewall'];
$_SESSION['fwname'] = $fw;
}
mysql_free_result($result);

print "</td>";
print "</tr>";
print "<tr class=BottomBasic>";
print "<td align=right colspan=2>";
print "<p></p>";
print "<p> <br> <input style=WIDTH:120px; HEIGHT:24px size=42 type=submit value=Select name=Submit>";
print "</tr>";
print "</table>";
print "</td>";
print "</tr>";
print "</table>";

@$GLOBALS['fw'] = $_POST['firewall'];

//echo "Firewall: " . $_POST['firewall']."";
$_SESSION['fwname'] = $fw;
print "</form>";
global $fw;

print "<br>";
$query1="show tables from $fw";
$result1 = mysql_query($query1);
print "</form>";
global $fw;
?>
//---------------------------------------------------

acl.php
//---------------------------------------------------
<?php
@define("RelativePath", ".");
@include(RelativePath . "/index.php");
//@include(RelativePath . "/acl.php");

@session_start ();

@$fw=$_SESSION['fwname'];
@$acl=$_SESSION['aclname'];

print "<html>";
print "<head>";
print "<title>Index</title>";
print "<link href=Styles/Simple/Style_Components.css type=text/css rel=stylesheet>";
print "<link href=Styles/Simple/Style.css type=text/css rel=stylesheet>";
print "</head>";
print "<body>";

$dbhost="10.10.9.xxx";
$user="root";
$password="mysql";
$database="SB_SerBurPix";
mysql_connect($dbhost,$user,$password) or die( "Unable to select database");
$query1="show tables from `$fw`";
$result1 = mysql_query($query1);
print "<table cellspacing=0 cellpadding=0 border=0>";
print "<tr>";
print "<td valign=top>";
print "<table class=HeaderBasic cellspacing=0 cellpadding=0 border=0>";
print "<tr>";
print "<td class=HeaderLeftBasic><img src=Styles/Basic/Images/Spacer.gif border=0></td>";
print "<th>Access List</th>";
print "<td class=HeaderRightBasic><img src=Styles/Basic/Images/Spacer.gif border=0></td>";
print "</tr>";
print "</table>";
print "<table class=RecordBasic cellspacing=0 cellpadding=0>";
print "<tr class=ControlsBasic>";
print "<td colspan=2>Please select Access Lists</td>";
print "</tr>";
print "<tr class=ControlsBasic>";
print "<th style=WIDTH:100px>Name </th>";
print "<td>";
print "<form name=acl_name action=show.php method=post>";
print "<SELECT name=acl_name style=WIDTH:200px>";
while ($line = mysql_fetch_array($result1))
{
foreach ($line as $value)
{
print "<OPTION value='$value'";
}
print ">$value</OPTION>";

$GLOBALS['acl'] = $_POST['acl_name'];
$GLOBALS['fwname'] = $fw;
$_SESSION['aclname'] = $acl;
$_SESSION['fwname'] = $fw;

echo $_SERVER['fwname'];
echo $_SESSION['fwname'];
$fwname['fwname'] = $_POST['fwname'];
}

mysql_free_result($result1);
print "</td>";
print "</tr>";
print "<tr class=BottomBasic>";
print "<td align=right colspan=2>";
print "<p></p>";
print "<p> <br> <input style=WIDTH:120px; HEIGHT:24px size=42 type=submit value=Show name=Submit>";
print "<input type=hidden name=fwname value=$fw >";
print "</tr>";
print "</table>";
print "</td>";
print "</tr>";
print "</table>";
$query2="connect $fw";
mysql_query($query2);
//echo "acl_name: " . $_POST['acl_name']."";
@$GLOBALS['acl'] = $_POST['acl_name'];

$_SESSION['aclname'] = $acl;
$_SESSION['fwname'] = $fw;

print "</form>";
?>
//-------------------------------------------------------------

View profile  Send private message
man_linux

Posts: 13
Posted: 08/11/2006, 1:48 PM

show.php
//-------------------------------------------------------------
<?php
//Include Common Files @1-D8345F67
define("RelativePath", ".");
define("PathToCurrentPage", "/");
define("FileName", "show.php");
include(RelativePath . "/Common.php");
include(RelativePath . "/Template.php");
include(RelativePath . "/Sorter.php");
include(RelativePath . "/Navigator.php");
include(RelativePath . "/acl.php");
//End Include Common Files

@session_start ();

@$fw=$_POST['fwname'];
@$acl=$_SESSION['aclname'];
@include acl.php;

class clsRecordsb_dmz1_access_inSearch { //sb_dmz1_access_inSearch Class @3-45051A08

//Variables @3-0DF9B1C2

// 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;

// Class variables
//End Variables

//Class_Initialize Event @3-FA5DD705
function clsRecordsb_dmz1_access_inSearch($RelativePath, & $Parent)
{

global $FileName;
global $CCSLocales;
global $DefaultDateFormat;
$this->Visible = true;
$this->Parent = & $Parent;
$this->RelativePath = $RelativePath;
$this->Errors = new clsErrors();
$this->ErrorBlock = "Record sb_dmz1_access_inSearch/Error";
$this->ReadAllowed = true;
if($this->Visible)
{
$this->ComponentName = "sb_dmz1_access_inSearch";
$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->s_Action = & new clsControl(ccsTextBox, "s_Action", "s_Action", ccsMemo, "", CCGetRequestParam("s_Action", $Method, NULL), $this);
$this->s_Protocol = & new clsControl(ccsTextBox, "s_Protocol", "s_Protocol", ccsMemo, "", CCGetRequestParam("s_Protocol", $Method, NULL), $this);
$this->s_Source = & new clsControl(ccsTextBox, "s_Source", "s_Source", ccsMemo, "", CCGetRequestParam("s_Source", $Method, NULL), $this);
$this->s_SrcPort = & new clsControl(ccsTextBox, "s_SrcPort", "s_SrcPort", ccsMemo, "", CCGetRequestParam("s_SrcPort", $Method, NULL), $this);
$this->s_Destination = & new clsControl(ccsTextBox, "s_Destination", "s_Destination", ccsMemo, "", CCGetRequestParam("s_Destination", $Method, NULL), $this);
$this->s_DstPort = & new clsControl(ccsTextBox, "s_DstPort", "s_DstPort", ccsMemo, "", CCGetRequestParam("s_DstPort", $Method, NULL), $this);
$this->s_Hitcount = & new clsControl(ccsTextBox, "s_Hitcount", "s_Hitcount", ccsMemo, "", CCGetRequestParam("s_Hitcount", $Method, NULL), $this);
$this->s_ChangeControl = & new clsControl(ccsTextBox, "s_ChangeControl", "s_ChangeControl", ccsMemo, "", CCGetRequestParam("s_ChangeControl", $Method, NULL), $this);
$this->Button_DoSearch = & new clsButton("Button_DoSearch", $Method, $this);
}
}
//End Class_Initialize Event

//Validate Method @3-F2BB0A77
function Validate()
{
global $CCSLocales;
$Validation = true;
$Where = "";
$Validation = ($this->s_Action->Validate() && $Validation);
$Validation = ($this->s_Protocol->Validate() && $Validation);
$Validation = ($this->s_Source->Validate() && $Validation);
$Validation = ($this->s_SrcPort->Validate() && $Validation);
$Validation = ($this->s_Destination->Validate() && $Validation);
$Validation = ($this->s_DstPort->Validate() && $Validation);
$Validation = ($this->s_Hitcount->Validate() && $Validation);
$Validation = ($this->s_ChangeControl->Validate() && $Validation);
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "OnValidate", $this);
$Validation = $Validation && ($this->s_Action->Errors->Count() == 0);
$Validation = $Validation && ($this->s_Protocol->Errors->Count() == 0);
$Validation = $Validation && ($this->s_Source->Errors->Count() == 0);
$Validation = $Validation && ($this->s_SrcPort->Errors->Count() == 0);
$Validation = $Validation && ($this->s_Destination->Errors->Count() == 0);
$Validation = $Validation && ($this->s_DstPort->Errors->Count() == 0);
$Validation = $Validation && ($this->s_Hitcount->Errors->Count() == 0);
$Validation = $Validation && ($this->s_ChangeControl->Errors->Count() == 0);
return (($this->Errors->Count() == 0) && $Validation);
}
//End Validate Method

//CheckErrors Method @3-97740D59
function CheckErrors()
{
$errors = false;
$errors = ($errors || $this->s_Action->Errors->Count());
$errors = ($errors || $this->s_Protocol->Errors->Count());
$errors = ($errors || $this->s_Source->Errors->Count());
$errors = ($errors || $this->s_SrcPort->Errors->Count());
$errors = ($errors || $this->s_Destination->Errors->Count());
$errors = ($errors || $this->s_DstPort->Errors->Count());
$errors = ($errors || $this->s_Hitcount->Errors->Count());
$errors = ($errors || $this->s_ChangeControl->Errors->Count());
$errors = ($errors || $this->Errors->Count());
return $errors;
}
//End CheckErrors Method

//Operation Method @3-14E2AA8C
function Operation()
{
if(!$this->Visible)
return;

global $Redirect;
global $FileName;

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

if($this->FormSubmitted) {
$this->PressedButton = "Button_DoSearch";
if($this->Button_DoSearch->Pressed) {
$this->PressedButton = "Button_DoSearch";
}
}
$Redirect = "show.php";
if($this->Validate()) {
if($this->PressedButton == "Button_DoSearch") {
$Redirect = "show.php" . "?" . CCMergeQueryStrings(CCGetQueryString("Form", array("Button_DoSearch", "Button_DoSearch_x", "Button_DoSearch_y")));
if(!CCGetEvent($this->Button_DoSearch->CCSEvents, "OnClick", $this->Button_DoSearch)) {
$Redirect = "show.php";
}
}
} else {
$Redirect = "show.php";
}
}
//End Operation Method

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

if(!$this->Visible)
return;

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


$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 = "";
$Error = ComposeStrings($Error, $this->s_Action->Errors->ToString());
$Error = ComposeStrings($Error, $this->s_Protocol->Errors->ToString());
$Error = ComposeStrings($Error, $this->s_Source->Errors->ToString());
$Error = ComposeStrings($Error, $this->s_SrcPort->Errors->ToString());
$Error = ComposeStrings($Error, $this->s_Destination->Errors->ToString());
$Error = ComposeStrings($Error, $this->s_DstPort->Errors->ToString());
$Error = ComposeStrings($Error, $this->s_Hitcount->Errors->ToString());
$Error = ComposeStrings($Error, $this->s_ChangeControl->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->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeShow", $this);
if(!$this->Visible) {
$Tpl->block_path = $ParentPath;
return;
}

$this->s_Action->Show();
$this->s_Protocol->Show();
$this->s_Source->Show();
$this->s_SrcPort->Show();
$this->s_Destination->Show();
$this->s_DstPort->Show();
$this->s_Hitcount->Show();
$this->s_ChangeControl->Show();
$this->Button_DoSearch->Show();
$Tpl->parse();
$Tpl->block_path = $ParentPath;
}
//End Show Method

} //End sb_dmz1_access_inSearch Class @3-FCB6E20C
View profile  Send private message
man_linux

Posts: 13
Posted: 08/11/2006, 1:50 PM

class clsGridsb_dmz1_access_in { //sb_dmz1_access_in class @2-97BBD5A7

//Variables @2-663D5B8C

// Public variables
var $ComponentType = "Grid";
var $ComponentName;
var $Visible;
var $Errors;
var $ErrorBlock;
var $ds;
var $DataSource;
var $PageSize;
var $IsEmpty;
var $SorterName = "";
var $SorterDirection = "";
var $PageNumber;
var $RowNumber;
var $ControlsVisible = array();

var $CCSEvents = "";
var $CCSEventResult;

var $RelativePath = "";

// Grid Controls
var $StaticControls;
var $RowControls;
//End Variables

//Class_Initialize Event @2-D100CF4C
function clsGridsb_dmz1_access_in($RelativePath, & $Parent)
{
global $FileName;
global $CCSLocales;
global $DefaultDateFormat;
$this->ComponentName = "sb_dmz1_access_in";
$this->Visible = True;
$this->Parent = & $Parent;
$this->RelativePath = $RelativePath;
$this->Errors = new clsErrors();
$this->ErrorBlock = "Grid sb_dmz1_access_in";
$this->DataSource = new clssb_dmz1_access_inDataSource($this);
$this->ds = & $this->DataSource;
$this->PageSize = CCGetParam($this->ComponentName . "PageSize", "");
if(!is_numeric($this->PageSize) || !strlen($this->PageSize))
$this->PageSize = 100;
else
$this->PageSize = intval($this->PageSize);
if ($this->PageSize > 100)
$this->PageSize = 100;
if($this->PageSize == 0)
$this->Errors->addError("<p>Form: Grid " . $this->ComponentName . "<br>Error: (CCS06) Invalid page size.</p>");
$this->PageNumber = intval(CCGetParam($this->ComponentName . "Page", 1));
if ($this->PageNumber <= 0) $this->PageNumber = 1;

$this->Line = & new clsControl(ccsLabel, "Line", "Line", ccsMemo, "", CCGetRequestParam("Line", ccsGet, NULL), $this);
$this->Action = & new clsControl(ccsLabel, "Action", "Action", ccsMemo, "", CCGetRequestParam("Action", ccsGet, NULL), $this);
$this->Protocol = & new clsControl(ccsLabel, "Protocol", "Protocol", ccsMemo, "", CCGetRequestParam("Protocol", ccsGet, NULL), $this);
$this->Source = & new clsControl(ccsLabel, "Source", "Source", ccsMemo, "", CCGetRequestParam("Source", ccsGet, NULL), $this);
$this->SrcPort = & new clsControl(ccsLabel, "SrcPort", "SrcPort", ccsMemo, "", CCGetRequestParam("SrcPort", ccsGet, NULL), $this);
$this->Destination = & new clsControl(ccsLabel, "Destination", "Destination", ccsMemo, "", CCGetRequestParam("Destination", ccsGet, NULL), $this);
$this->DstPort = & new clsControl(ccsLabel, "DstPort", "DstPort", ccsMemo, "", CCGetRequestParam("DstPort", ccsGet, NULL), $this);
$this->Hitcount = & new clsControl(ccsLabel, "Hitcount", "Hitcount", ccsMemo, "", CCGetRequestParam("Hitcount", ccsGet, NULL), $this);
$this->ChangeControl = & new clsControl(ccsLabel, "ChangeControl", "ChangeControl", ccsMemo, "", CCGetRequestParam("ChangeControl", ccsGet, NULL), $this);
$this->Navigator = & new clsNavigator($this->ComponentName, "Navigator", $FileName, 10, tpCentered, $this);
}
//End Class_Initialize Event

//Initialize Method @2-90E704C5
function Initialize()
{
if(!$this->Visible) return;

$this->DataSource->PageSize = & $this->PageSize;
$this->DataSource->AbsolutePage = & $this->PageNumber;
$this->DataSource->SetOrder($this->SorterName, $this->SorterDirection);
}
//End Initialize Method

//Show Method @2-CB8BBFAB
function Show()
{
global $Tpl;
global $CCSLocales;
if(!$this->Visible) return;

$this->RowNumber = 0;

$this->DataSource->Parameters["urls_Action"] = CCGetFromGet("s_Action", NULL);
$this->DataSource->Parameters["urls_Protocol"] = CCGetFromGet("s_Protocol", NULL);
$this->DataSource->Parameters["urls_Source"] = CCGetFromGet("s_Source", NULL);
$this->DataSource->Parameters["urls_SrcPort"] = CCGetFromGet("s_SrcPort", NULL);
$this->DataSource->Parameters["urls_Destination"] = CCGetFromGet("s_Destination", NULL);
$this->DataSource->Parameters["urls_DstPort"] = CCGetFromGet("s_DstPort", NULL);
$this->DataSource->Parameters["urls_Hitcount"] = CCGetFromGet("s_Hitcount", NULL);
$this->DataSource->Parameters["urls_ChangeControl"] = CCGetFromGet("s_ChangeControl", NULL);

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


$this->DataSource->Prepare();
$this->DataSource->Open();
$this->IsEmpty = ! $this->DataSource->next_record();

$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeShow", $this);
if(!$this->Visible) return;

$GridBlock = "Grid " . $this->ComponentName;
$ParentPath = $Tpl->block_path;
$Tpl->block_path = $ParentPath . "/" . $GridBlock;


if (!$this->IsEmpty) {
$this->IsEmpty = false;
$this->ControlsVisible["Line"] = $this->Line->Visible;
$this->ControlsVisible["Action"] = $this->Action->Visible;
$this->ControlsVisible["Protocol"] = $this->Protocol->Visible;
$this->ControlsVisible["Source"] = $this->Source->Visible;
$this->ControlsVisible["SrcPort"] = $this->SrcPort->Visible;
$this->ControlsVisible["Destination"] = $this->Destination->Visible;
$this->ControlsVisible["DstPort"] = $this->DstPort->Visible;
$this->ControlsVisible["Hitcount"] = $this->Hitcount->Visible;
$this->ControlsVisible["ChangeControl"] = $this->ChangeControl->Visible;
do {
$this->RowNumber++;
$this->DataSource->SetValues();
$Tpl->block_path = $ParentPath . "/" . $GridBlock . "/Row";
$this->Line->SetValue($this->DataSource->Line->GetValue());
$this->Action->SetValue($this->DataSource->Action->GetValue());
$this->Protocol->SetValue($this->DataSource->Protocol->GetValue());
$this->Source->SetValue($this->DataSource->Source->GetValue());
$this->SrcPort->SetValue($this->DataSource->SrcPort->GetValue());
$this->Destination->SetValue($this->DataSource->Destination->GetValue());
$this->DstPort->SetValue($this->DataSource->DstPort->GetValue());
$this->Hitcount->SetValue($this->DataSource->Hitcount->GetValue());
$this->ChangeControl->SetValue($this->DataSource->ChangeControl->GetValue());
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeShowRow", $this);
$this->Line->Show();
$this->Action->Show();
$this->Protocol->Show();
$this->Source->Show();
$this->SrcPort->Show();
$this->Destination->Show();
$this->DstPort->Show();
$this->Hitcount->Show();
$this->ChangeControl->Show();
$Tpl->block_path = $ParentPath . "/" . $GridBlock;
$Tpl->parse("Row", true);
} while (($this->RowNumber < $this->PageSize) && $this->DataSource->next_record());
}
else // Show NoRecords block if no records are found
{
$this->IsEmpty = true;
$Tpl->parse("NoRecords", false);
}

$errors = $this->GetErrors();
if(strlen($errors))
{
$Tpl->replaceblock("", $errors);
$Tpl->block_path = $ParentPath;
return;
}
$this->Navigator->PageNumber = $this->DataSource->AbsolutePage;
if ($this->DataSource->RecordsCount == "CCS not counted")
$this->Navigator->TotalPages = $this->DataSource->AbsolutePage + ($this->DataSource->next_record() ? 1 : 0);
else
$this->Navigator->TotalPages = $this->DataSource->PageCount();
$this->Navigator->Show();
$Tpl->parse();
$Tpl->block_path = $ParentPath;
$this->DataSource->close();
}
//End Show Method

//GetErrors Method @2-63B53DEB
function GetErrors()
{
$errors = "";
$errors = ComposeStrings($errors, $this->Line->Errors->ToString());
$errors = ComposeStrings($errors, $this->Action->Errors->ToString());
$errors = ComposeStrings($errors, $this->Protocol->Errors->ToString());
$errors = ComposeStrings($errors, $this->Source->Errors->ToString());
$errors = ComposeStrings($errors, $this->SrcPort->Errors->ToString());
$errors = ComposeStrings($errors, $this->Destination->Errors->ToString());
$errors = ComposeStrings($errors, $this->DstPort->Errors->ToString());
$errors = ComposeStrings($errors, $this->Hitcount->Errors->ToString());
$errors = ComposeStrings($errors, $this->ChangeControl->Errors->ToString());
$errors = ComposeStrings($errors, $this->Errors->ToString());
$errors = ComposeStrings($errors, $this->DataSource->Errors->ToString());
return $errors;
}
//End GetErrors Method

} //End sb_dmz1_access_in Class @2-FCB6E20C

class clssb_dmz1_access_inDataSource extends clsDBConnection1 { //sb_dmz1_access_inDataSource Class @2-BC02D867

//DataSource Variables @2-975170D3
var $Parent = "";
var $CCSEvents = "";
var $CCSEventResult;
var $ErrorBlock;
var $CmdExecution;

var $CountSQL;
var $wp;


// Datasource fields
var $Line;
var $Action;
var $Protocol;
var $Source;
var $SrcPort;
var $Destination;
var $DstPort;
var $Hitcount;
var $ChangeControl;
//End DataSource Variables
View profile  Send private message
man_linux

Posts: 13
Posted: 08/11/2006, 1:50 PM



//DataSourceClass_Initialize Event @2-787AD603
function clssb_dmz1_access_inDataSource(& $Parent)
{
$this->Parent = & $Parent;
$this->ErrorBlock = "Grid sb_dmz1_access_in";
$this->Initialize();
$this->Line = new clsField("Line", ccsMemo, "");
$this->Action = new clsField("Action", ccsMemo, "");
$this->Protocol = new clsField("Protocol", ccsMemo, "");
$this->Source = new clsField("Source", ccsMemo, "");
$this->SrcPort = new clsField("SrcPort", ccsMemo, "");
$this->Destination = new clsField("Destination", ccsMemo, "");
$this->DstPort = new clsField("DstPort", ccsMemo, "");
$this->Hitcount = new clsField("Hitcount", ccsMemo, "");
$this->ChangeControl = new clsField("ChangeControl", ccsMemo, "");

}
//End DataSourceClass_Initialize Event

//SetOrder Method @2-9E1383D1
function SetOrder($SorterName, $SorterDirection)
{
$this->Order = "";
$this->Order = CCGetOrder($this->Order, $SorterName, $SorterDirection,
"");
}
//End SetOrder Method

//Prepare Method @2-AB5B9621
function Prepare()
{
global $CCSLocales;
global $DefaultDateFormat;
$this->wp = new clsSQLParameters($this->ErrorBlock);
$this->wp->AddParameter("1", "urls_Action", ccsMemo, "", "", $this->Parameters["urls_Action"], "", false);
$this->wp->AddParameter("2", "urls_Protocol", ccsMemo, "", "", $this->Parameters["urls_Protocol"], "", false);
$this->wp->AddParameter("3", "urls_Source", ccsMemo, "", "", $this->Parameters["urls_Source"], "", false);
$this->wp->AddParameter("4", "urls_SrcPort", ccsMemo, "", "", $this->Parameters["urls_SrcPort"], "", false);
$this->wp->AddParameter("5", "urls_Destination", ccsMemo, "", "", $this->Parameters["urls_Destination"], "", false);
$this->wp->AddParameter("6", "urls_DstPort", ccsMemo, "", "", $this->Parameters["urls_DstPort"], "", false);
$this->wp->AddParameter("7", "urls_Hitcount", ccsMemo, "", "", $this->Parameters["urls_Hitcount"], "", false);
$this->wp->AddParameter("8", "urls_ChangeControl", ccsMemo, "", "", $this->Parameters["urls_ChangeControl"], "", false);
$this->wp->Criterion[1] = $this->wp->Operation(opContains, "Action", $this->wp->GetDBValue("1"), $this->ToSQL($this->wp->GetDBValue("1"), ccsMemo),false);
$this->wp->Criterion[2] = $this->wp->Operation(opContains, "Protocol", $this->wp->GetDBValue("2"), $this->ToSQL($this->wp->GetDBValue("2"), ccsMemo),false);
$this->wp->Criterion[3] = $this->wp->Operation(opContains, "Source", $this->wp->GetDBValue("3"), $this->ToSQL($this->wp->GetDBValue("3"), ccsMemo),false);
$this->wp->Criterion[4] = $this->wp->Operation(opContains, "SrcPort", $this->wp->GetDBValue("4"), $this->ToSQL($this->wp->GetDBValue("4"), ccsMemo),false);
$this->wp->Criterion[5] = $this->wp->Operation(opContains, "Destination", $this->wp->GetDBValue("5"), $this->ToSQL($this->wp->GetDBValue("5"), ccsMemo),false);
$this->wp->Criterion[6] = $this->wp->Operation(opContains, "DstPort", $this->wp->GetDBValue("6"), $this->ToSQL($this->wp->GetDBValue("6"), ccsMemo),false);
$this->wp->Criterion[7] = $this->wp->Operation(opContains, "Hitcount", $this->wp->GetDBValue("7"), $this->ToSQL($this->wp->GetDBValue("7"), ccsMemo),false);
$this->wp->Criterion[8] = $this->wp->Operation(opContains, "ChangeControl", $this->wp->GetDBValue("8"), $this->ToSQL($this->wp->GetDBValue("8"), ccsMemo),false);
$this->Where = $this->wp->opAND(
false, $this->wp->opAND(
false, $this->wp->opAND(
false, $this->wp->opAND(
false, $this->wp->opAND(
false, $this->wp->opAND(
false, $this->wp->opAND(
false,
$this->wp->Criterion[1],
$this->wp->Criterion[2]),
$this->wp->Criterion[3]),
$this->wp->Criterion[4]),
$this->wp->Criterion[5]),
$this->wp->Criterion[6]),
$this->wp->Criterion[7]),
$this->wp->Criterion[8]);
}
//End Prepare Method

//Open Method @2-512A747B
function Open()
{

$fw=$_POST['fwname'];
$acl=$_SESSION['aclname'];

$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeBuildSelect", $this->Parent);
$this->CountSQL = "use `$fw`";
$this->SQL = "SELECT * FROM `$acl`{SQL_Where} {SQL_OrderBy} ";


$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeExecuteSelect", $this->Parent);
if ($this->CountSQL)
$this->RecordsCount = CCGetDBValue(CCBuildSQL($this->CountSQL, $this->Where, ""), $this);
else
$this->RecordsCount = "CCS not counted";
$this->query($this->OptimizeSQL(CCBuildSQL($this->SQL, $this->Where, $this->Order)));


$this->CCSEventResult = CCGetEvent($this->CCSEvents, "AfterExecuteSelect", $this->Parent);
}


//SetValues Method @2-B799C951
function SetValues()
{
$this->Line->SetDBValue($this->f("Line"));
$this->Action->SetDBValue($this->f("Action"));
$this->Protocol->SetDBValue($this->f("Protocol"));
$this->Source->SetDBValue($this->f("Source"));
$this->SrcPort->SetDBValue($this->f("SrcPort"));
$this->Destination->SetDBValue($this->f("Destination"));
$this->DstPort->SetDBValue($this->f("DstPort"));
$this->Hitcount->SetDBValue($this->f("Hitcount"));
$this->ChangeControl->SetDBValue($this->f("ChangeControl"));
}
//End SetValues Method

} //End sb_dmz1_access_inDataSource Class @2-FCB6E20C

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

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

$FileName = FileName;
$Redirect = "";
$TemplateFileName = "show.html";
$BlockToParse = "main";
$TemplateEncoding = "CP1252";
$PathToRoot = "./";
//End Initialize Page

//Initialize Objects @1-0F760954
$DBConnection1 = new clsDBConnection1();
$MainPage->Connections["Connection1"] = & $DBConnection1;

// Controls
$sb_dmz1_access_inSearch = & new clsRecordsb_dmz1_access_inSearch("", $MainPage);
$sb_dmz1_access_in = & new clsGridsb_dmz1_access_in("", $MainPage);
$MainPage->sb_dmz1_access_inSearch = & $sb_dmz1_access_inSearch;
$MainPage->sb_dmz1_access_in = & $sb_dmz1_access_in;
$sb_dmz1_access_in->Initialize();

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

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

//Initialize HTML Template @1-DEDF43A5
$CCSEventResult = CCGetEvent($CCSEvents, "OnInitializeView", $MainPage);
$Tpl = new clsTemplate();
$Tpl->LoadTemplate(PathToCurrentPage . $TemplateFileName, $BlockToParse, "CP1252");
$Tpl->block_path = "/$BlockToParse";
$CCSEventResult = CCGetEvent($CCSEvents, "BeforeShow", $MainPage);
//End Initialize HTML Template

//Execute Components @1-6FFE3D7B
$sb_dmz1_access_inSearch->Operation();
//End Execute Components

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

//Show Page @1-15153002
$sb_dmz1_access_inSearch->Show();
$sb_dmz1_access_in->Show();
$Tpl->block_path = "";
$Tpl->Parse($BlockToParse, false);
$main_block = $Tpl->GetVar($BlockToParse);
$QQBBIED3T1H8O8T1M = array("<center><font fa","ce=\"Arial\"><smal","l>Gener","ated <","!-- SCC -->w&","#105;t&#","104; <!-- SCC --",">CodeChar ","3;e <!-- CCS ","-->Stud","io.</small","></font></center>","");
if(preg_match("/<\/body>/i", $main_block)) {
$main_block = preg_replace("/<\/body>/i", join($QQBBIED3T1H8O8T1M,"") . "</body>", $main_block);
} else if(preg_match("/<\/html>/i", $main_block) && !preg_match("/<\/frameset>/i", $main_block)) {
$main_block = preg_replace("/<\/html>/i", join($QQBBIED3T1H8O8T1M,"") . "</html>", $main_block);
} else if(!preg_match("/<\/frameset>/i", $main_block)) {
$main_block .= join($QQBBIED3T1H8O8T1M,"");
}
$CCSEventResult = CCGetEvent($CCSEvents, "BeforeOutput", $MainPage);
if ($CCSEventResult) echo $main_block;
//End Show Page

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

?>
//-------------------------------------------------------

View profile  Send private message
man_linux

Posts: 13
Posted: 08/11/2006, 1:51 PM

Let me know any better way to do this.
View profile  Send private message
tonyk

Posts: 163
Posted: 08/11/2006, 2:58 PM

Hi man_linux,
I am probably missing the point but I do not understand why you need hundreds of tables for hundreds of firewalls.
Why can't you place the definitions all in the same database?
You could have an auto_incrementing file containing
auto_inc_id INT
firewall_name VARCHAR 30 --- indexed and unique

In your definitions table
firewall_record_id INT (autoincrement key)
firewall_id (same as auto_inc_id)
field1...field2...and so on.

This would be much simpler to set up and maintain I would have thought.
If you still needed separate databases you could create these using sql commands and build the databases from the data stored in your main table, you could also make changes to one or all databases through a single unfiied table and drop any of the tables if necessary.
If you wanted users to have access to only their own firewall you could tie the user to the firewall description and rule descriptions by including a user_id field and instructing your user interface to show only those records containing the correct value for user_id.
Am I totally off course or is this a reasonable interpretation of what you are trying to achieve?
Tony
View profile  Send private message
man_linux

Posts: 13
Posted: 08/11/2006, 4:49 PM

I need to keep different databases for different devices since many has same kind of configuration but has to be kept separate from others.
I could solve this problem if I get an efficient way of putting serach parameters in in MySQL query and then changing grid's datasource.
How to do this in CCS?

Thanks
View profile  Send private message
peterr


Posts: 5971
Posted: 08/11/2006, 7:35 PM

See my above post. The SQL can be modified with just one line of code:
http://docs.codecharge.com/studio3/html/ProgrammingTech.../ModifySQL.html

I guess you should be able to replace a table in the existing SQL with another table name. Somewhat related topic is here: http://forums.codecharge.com/posts.php?post_id=77443
It's that simple! :-)
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
peterr


Posts: 5971
Posted: 08/11/2006, 7:40 PM

Actually are you trying to change just the table for a grid, or the database also?
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
man_linux

Posts: 13
Posted: 08/11/2006, 8:58 PM

I want to change database also.
In one 1 database I have 4 -10 tables, my current CCS code works fine for 1 DB and grid shows data from different tables. Search doesn’t work at all to use same grid even for different table in same database. When I change database then nothing works.
The method you have suggested is defining particular table name, when I change DB then table names are changing and will be accessed in any order so not possible to cover every table name.

I want 1 grid that will show any table from any DB, also will show search result redirect for any table and any DB. Because everywhere table structure is same, and so many DBs and tables and frequent adding and deleting of them so not possible to create and maintain PHPs for each DB and table.
View profile  Send private message
peterr


Posts: 5971
Posted: 08/11/2006, 9:23 PM

I just tested the above solution and it works without a hitch for switching tables on the fly.
Switching the database is indeed something more tricky and out of scope of CCS. But looking at what such guys as Feha are doing at http://forums.codecharge.com/posts.php?post_id=71096 , I think that you could modify the connection function in Common.php - by specifying different database name when you detect appropriate search parameter in the URL.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
Damian Hupfeld
Posted: 08/12/2006, 6:04 AM

The way I read your statement it is giving even more reason to use Tony's
method. Same kind of configuration really lends itself to one table that
supports all the possible variations. Keeping it seperate is easy - use CCS
Security and add a CompanyId or similar to the Firewalls table so that you
can restrict users from one company to only their own devices and you can
sort/group devices based on companies also.

It does seem exceessive to have 100's of databases containing very limited
data. A complicated firewall script might contain 10,000 characters? 20,000?


"man_linux" <man_linux@forum.codecharge> wrote in message
news:544dd17a22689d@news.codecharge.com...
>I need to keep different databases for different devices since many has
>same
> kind of configuration but has to be kept separate from others.
> I could solve this problem if I get an efficient way of putting serach
> parameters in in MySQL query and then changing grid's datasource.
> How to do this in CCS?
>
> Thanks
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

man_linux

Posts: 13
Posted: 08/13/2006, 5:37 AM

One thought I have is to make firewall and access-list name as variables, save those values to a cookie at the start of each session. Call those values for common files from the cookie.
When I make a grid and search form in CCS, which is the common location they refer to get DB and table name?
In grid there is a SQL query with specific table name, I couldn’t find any such thing for the search form. One complication I see is the class defined to the particular table name, which I want to be defined for variable name and to be generic.

Database doesn’t contain large amount of data. And no need to have access restriction since all firewalls belongs to my company.
I can club every thing to 1 DB by adding two columns, one for firewall name and second for access-list name.
To view data, I want first list box option which will show all firewalls, then second list box to show all access-lists in the selected firewall, then a search and grid form to show data.
View profile  Send private message
tonyk

Posts: 163
Posted: 08/14/2006, 6:27 AM

Look up dependent list boxes on this forum, there is tons of stuff about it :-)
Tony
View profile  Send private message
wkempees


Posts: 1679
Posted: 08/14/2006, 7:43 AM

How would DeKemp tackle this?
First, use one database in stead of 100s.
Second, use the same table names, with the same design for all 4 tables per firewall, but use a naming scheme, so nnnnn_tablename.
so we end up with one database containing 400+ tables identifyed by nnnn being the firewal number.
(author stated that each firewall outputs to it's own database, so it would be possible to change that).
Now we have one database to worry about, next we build search/grid for each of the 4 base tables, in the before build select we would now only need to string_replace the table name with the appropriate nnnn_tablename, which at runtime comes from the select firewall listbox in the search form.

Another approach, without changing any of the CCS base files, could be to define a connection for each of the databases, and at runtime open a connection based on the firewall Listbox.

The best normalized method would of course be to have 1 DB with the 4 base tables, and add a firewall identifying field to it.
(with a fifth table to contain firewall details and id).

Just my 2ct

Walter
(I think this whole thing would take (less than) 2 days to be operable).



_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
man_linux

Posts: 13
Posted: 08/14/2006, 6:18 PM

I made it.
Keeping my MySQL same with many databases and tables, I can read any database any table from 1 common search form and grid.
Just had to add few new things out of track, Thanks to CCS...:-)

Thanks for help.
View profile  Send private message
WKempees
Posted: 08/15/2006, 1:34 AM


Good Job.

Another Topic that needs it's Header Text changed.

Suggestion:
"CCS not very helpful, but Forum showed me otherwise."

Walter


Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.