Skip to content
This repository has been archived by the owner on Nov 15, 2022. It is now read-only.

Commit

Permalink
fix(lang): review language usage and controller access
Browse files Browse the repository at this point in the history
  • Loading branch information
KaiSchwarz-cnic committed Oct 8, 2019
1 parent 464d876 commit 5bd93d8
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 104 deletions.
4 changes: 2 additions & 2 deletions controller/_language.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
if (!isset($language)) {
$language = "english";
}
$file_backorder = dirname(__FILE__)."/../lang/".$language.".php";
$file_backorder = dirname(__FILE__). DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "lang" . DIRECTORY_SEPARATOR . $language . ".php";
if (file_exists($file_backorder)) {
include($file_backorder);
} else {
include(dirname(__FILE__)."/../lang/english.php");
include(dirname(__FILE__). DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "lang" . DIRECTORY_SEPARATOR . "english.php");
}
18 changes: 9 additions & 9 deletions controller/dropdomains.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?php
//inlude this _language file in all controllers
include(dirname(__FILE__)."/_language.php");
include(dirname(__FILE__). DIRECTORY_SEPARATOR . "_language.php");

$statusheader = $_LANG['setallbackorder'];
$statusheader = $_ADDONLANG['setallbackorder'];

$fields = array(); //fieldname, apifieldname
$fields[]=array ("fieldname" => "", "apifieldname" => "BACKORDERTYPE");
$fields[]=array ("fieldname" => $_LANG['domainname'], "apifieldname" => "DOMAIN");
$fields[]=array ("fieldname" => $_LANG['dropdate'], "apifieldname" => "DROPDATE");
$fields[]=array ("fieldname" => $_LANG['chars'], "apifieldname" => "NUMBEROFCHARACTERS");
$fields[]=array ("fieldname" => $_LANG['digits'], "apifieldname" => "NUMBEROFDIGITS");
$fields[]=array ("fieldname" => $_LANG['hyphens'], "apifieldname" => "NUMBEROFHYPHENS");
$fields[]=array ("fieldname" => $_ADDONLANG['domainname'], "apifieldname" => "DOMAIN");
$fields[]=array ("fieldname" => $_ADDONLANG['dropdate'], "apifieldname" => "DROPDATE");
$fields[]=array ("fieldname" => $_ADDONLANG['chars'], "apifieldname" => "NUMBEROFCHARACTERS");
$fields[]=array ("fieldname" => $_ADDONLANG['digits'], "apifieldname" => "NUMBEROFDIGITS");
$fields[]=array ("fieldname" => $_ADDONLANG['hyphens'], "apifieldname" => "NUMBEROFHYPHENS");

$vars["fields"] = $fields;

Expand Down Expand Up @@ -75,5 +75,5 @@
}

$vars["breadcrumb"][] = array("last" => false, "link" => "", "label" => "Backorder" );
$vars["breadcrumb"][] = array("last" => true, "link" => "", "label" => $_LANG["domainheader"]);
$vars["displayTitle"] = $_LANG["domainheader"];
$vars["breadcrumb"][] = array("last" => true, "link" => "", "label" => $_ADDONLANG["domainheader"]);
$vars["displayTitle"] = $_ADDONLANG["domainheader"];
14 changes: 7 additions & 7 deletions controller/manage.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
include dirname(__FILE__) . DIRECTORY_SEPARATOR . "_language.php";

$vars["breadcrumb"][] = array("last" => false, "link" => "", "label" => "Backorder" );
$vars["breadcrumb"][] = array("last" => true, "link" => "", "label" => $_LANG["managebackorders"]);
$vars["displayTitle"] = $_LANG["managebackorders"];
$vars["breadcrumb"][] = array("last" => true, "link" => "", "label" => $_ADDONLANG["managebackorders"]);
$vars["displayTitle"] = $_ADDONLANG["managebackorders"];

$statusheader = $_LANG['setallbackorder'];
$statusheader = $_ADDONLANG['setallbackorder'];

$fields = array(); //fieldname, apifieldname
$fields[]=array ("fieldname" => "", "apifieldname" => "BACKORDERTYPE");
$fields[]=array ("fieldname" => "ID", "apifieldname" => "ID");
$fields[]=array ("fieldname" => $_LANG["domainname"], "apifieldname" => "DOMAIN");
$fields[]=array ("fieldname" => $_LANG["dropdate"], "apifieldname" => "DROPDATE");
$fields[]=array ("fieldname" => $_LANG["status"], "apifieldname" => "STATUS");
$fields[]=array ("fieldname" => $_ADDONLANG["domainname"], "apifieldname" => "DOMAIN");
$fields[]=array ("fieldname" => $_ADDONLANG["dropdate"], "apifieldname" => "DROPDATE");
$fields[]=array ("fieldname" => $_ADDONLANG["status"], "apifieldname" => "STATUS");

$vars["fields"] = $fields;

Expand Down Expand Up @@ -57,7 +57,7 @@
$tmpfield = '<div class="btn-group btn-group">';
//DISPLAY DELETE BUTTON ONLY FOR: "PENDING-PAYMENT", "AUCTION-PENDING", "PROCESSING"
if (!in_array($item['STATUS'], array("PENDING-PAYMENT", "AUCTION-PENDING", "PROCESSING"))) {
$tmpfield .= '<button placeholder2="'.$item['DROPDATE'].'" placeholder="'.$cnt.'" value="'.$item['DOMAIN'].'" class="line'.$cnt.' setbackorder btn btn-default btn-sm active">'.$_LANG['deletebutton'].'</button>';
$tmpfield .= '<button placeholder2="'.$item['DROPDATE'].'" placeholder="'.$cnt.'" value="'.$item['DOMAIN'].'" class="line'.$cnt.' setbackorder btn btn-default btn-sm active">'.$_ADDONLANG['deletebutton'].'</button>';
}
$tmpfield .= '</div>';
$newitem[] = $tmpfield;
Expand Down
42 changes: 17 additions & 25 deletions ispapibackorder.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ function ispapibackorder_clientarea($vars)
$key = "ispapibackorder";
$language = (isset($_SESSION["language"]) ? $_SESSION["language"] : "english");
$file = getcwd() . DIRECTORY_SEPARATOR . "modules" . DIRECTORY_SEPARATOR . "addons" . DIRECTORY_SEPARATOR . $key . DIRECTORY_SEPARATOR . "lang" . DIRECTORY_SEPARATOR . $language . ".php";
if (file_exists($file)){
if (file_exists($file)) {
include($file);
}

Expand All @@ -191,35 +191,27 @@ function ispapibackorder_clientarea($vars)
});

$modulename = "ispapibackorder";
$modulepath = "modules/addons/".$modulename;
$modulepath = "modules" . DIRECTORY_SEPARATOR . "addons" . DIRECTORY_SEPARATOR . $modulename;

//include language files
$language = $_SESSION["Language"];
if (!isset($language)) {
$language = "english";
if (!preg_match("/^(manage|dropdomains)$/", $_GET["p"])) {
//just to ensure %00 attacks are not working - WHMCS filters it out, but still white-listing is more secure
die("not allowed");
}
$file = getcwd()."/lang/".$language.".php";
$file_backorder = getcwd()."/modules/addons/ispapibackorder/lang/".$language.".php";
include($file);
if (file_exists($file_backorder)) {
include($file_backorder);
}

//include controller file
$vars = array();
$controller = getcwd()."/modules/addons/".$modulename."/controller/".$_GET["p"].".php";
$controller = getcwd() . DIRECTORY_SEPARATOR . $modulepath . DIRECTORY_SEPARATOR . "controller" . DIRECTORY_SEPARATOR . $_GET["p"] . ".php";
if (file_exists($controller)) {
include $controller;
include $controller;
} else {
die("controller not found");
}

$vars["moduletemplatepath"] = $modulepath . DIRECTORY_SEPARATOR . "templates";
$vars["modulepath"] = $modulepath . DIRECTORY_SEPARATOR;

return array(
'pagetitle' => "Backorder",
'breadcrumb' => array('index.php?m=ispapibackorder'=>'Backorder'),
'templatefile' => "templates/".$_GET["p"],
'requirelogin' => true,
'vars' => array_merge($vars, array(
'moduletemplatepath' => $modulepath."/templates",
'modulepath' => $modulepath."/"
)),
'pagetitle' => "Backorder",
'breadcrumb' => array('index.php?m=ispapibackorder'=>'Backorder'),
'templatefile' => "templates/" . $_GET["p"],
'requirelogin' => true,
'vars' => $vars
);
}
Loading

0 comments on commit 5bd93d8

Please sign in to comment.