Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 60 additions & 18 deletions .phpcs.xml
Original file line number Diff line number Diff line change
@@ -1,45 +1,87 @@
<?xml version="1.0"?>
<ruleset name="Emoncms">
<rule ref="Generic">
<!-- Please note some of these rules contradict each other, and as such, shouldn't both be enabled -->
<exclude name="Generic.Arrays.ArrayIndent.CloseBraceIncorrect"/>
<exclude name="Generic.Arrays.ArrayIndent.CloseBraceNotNewLine"/>
<exclude name="Generic.Arrays.ArrayIndent.KeyIncorrect"/>
<exclude name="Generic.Arrays.ArrayIndent.OpenBraceIncorrect"/>
<exclude name="Generic.Arrays.DisallowLongArraySyntax.Found"/>
<exclude name="Generic.Arrays.DisallowShortArraySyntax.Found"/>
<exclude name="Generic.Classes.OpeningBraceSameLine.BraceOnNewLine"/>
<exclude name="Generic.CodeAnalysis.AssignmentInCondition.Found"/>
<exclude name="Generic.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition"/>"/>
<exclude name="Generic.CodeAnalysis.EmptyStatement.DetectedCatch"/>
<exclude name="Generic.CodeAnalysis.EmptyStatement.DetectedElse"/>
<exclude name="Generic.CodeAnalysis.EmptyStatement.DetectedElseif"/>
<exclude name="Generic.CodeAnalysis.EmptyStatement.DetectedForeach"/>
<exclude name="Generic.CodeAnalysis.EmptyStatement.DetectedIf"/>
<exclude name="Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed"/>
<exclude name="Generic.CodeAnalysis.UnusedFunctionParameter.Found"/>
<exclude name="Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed"/>
<exclude name="Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed"/>
<exclude name="Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassAfterLastUsed"/>
<exclude name="Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterface"/>
<exclude name="Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceAfterLastUsed"/>
<exclude name="Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed"/>
<exclude name="Generic.Commenting.DocComment.LongNotCapital"/>
<exclude name="Generic.Commenting.DocComment.MissingShort"/>
<exclude name="Generic.Commenting.DocComment.NonParamGroup"/>
<exclude name="Generic.Commenting.DocComment.ShortNotCapital"/>
<exclude name="Generic.Commenting.DocComment.SpacingAfter"/>
<exclude name="Generic.Commenting.DocComment.SpacingBeforeTags"/>
<exclude name="Generic.Commenting.DocComment.TagValueIndent"/>
<exclude name="Generic.Commenting.Todo.CommentFound"/>
<exclude name="Generic.Commenting.Todo.TaskFound"/>
<exclude name="Generic.ControlStructures.DisallowYodaConditions.Found"/>
<exclude name="Generic.ControlStructures.InlineControlStructure.NotAllowed"/>
<exclude name="Generic.Files.EndFileNewline.NotFound"/>
<exclude name="Generic.Files.EndFileNoNewline.Found"/>
<exclude name="Generic.Files.ExecutableFile.Executable"/>
<exclude name="Generic.Files.InlineHTML.Found"/>
<exclude name="Generic.Files.LineLength.MaxExceeded"/>
<exclude name="Generic.Files.LineLength.TooLong"/>
<exclude name="Generic.Files.LowercasedFilename.NotFound"/>
<exclude name="Generic.Files.OneClassPerFile.MultipleFound"/>
<exclude name="Generic.Files.OneObjectStructurePerFile.MultipleFound"/>
<exclude name="Generic.Formatting.DisallowMultipleStatements.SameLine"/>
<exclude name="Generic.Formatting.MultipleStatementAlignment.IncorrectWarning"/>
<exclude name="Generic.Formatting.MultipleStatementAlignment.NotSameWarning"/>
<exclude name="Generic.Formatting.NoSpaceAfterCast.SpaceFound"/>
<exclude name="Generic.Formatting.SpaceAfterCast.NoSpace"/>
<exclude name="Generic.Formatting.SpaceAfterNot.Incorrect"/>
<exclude name="Generic.Formatting.SpaceBeforeCast.NoSpace"/>
<exclude name="Generic.Functions.FunctionCallArgumentSpacing.NoSpaceAfterComma"/>
<exclude name="Generic.Functions.FunctionCallArgumentSpacing.TooMuchSpaceAfterComma"/>
<exclude name="Generic.Functions.OpeningFunctionBraceBsdAllman.BraceOnSameLine"/>
<exclude name="Generic.Functions.OpeningFunctionBraceKernighanRitchie.BraceOnNewLine"/>
<exclude name="Generic.Functions.OpeningFunctionBraceKernighanRitchie.SpaceBeforeBrace"/>
<exclude name="Generic.Metrics.CyclomaticComplexity.MaxExceeded"/>
<exclude name="Generic.Metrics.CyclomaticComplexity.TooHigh"/>
<exclude name="Generic.Metrics.NestingLevel.TooHigh"/>
<exclude name="Generic.NamingConventions.CamelCapsFunctionName.NotCamelCaps"/>
<exclude name="Generic.NamingConventions.CamelCapsFunctionName.ScopeNotCamelCaps"/>
<exclude name="Generic.NamingConventions.InterfaceNameSuffix.Missing"/>
<exclude name="Generic.PHP.CharacterBeforePHPOpeningTag.Found"/>
<exclude name="Generic.PHP.ClosingPHPTag.NotFound"/>
<exclude name="Generic.PHP.LowerCaseConstant.Found"/>
<exclude name="Generic.PHP.NoSilencedErrors.Discouraged"/>
<exclude name="Generic.PHP.RequireStrictTypes.MissingDeclaration"/>
<exclude name="Generic.PHP.SAPIUsage.FunctionFound"/>
<exclude name="Generic.PHP.UpperCaseConstant.Found"/>
<exclude name="Generic.Strings.UnnecessaryHeredoc.Found"/>
<exclude name="Generic.Strings.UnnecessaryStringConcat.Found"/>
<exclude name="Generic.WhiteSpace.ArbitraryParenthesesSpacing.SpaceAfterOpen"/>
<exclude name="Generic.WhiteSpace.ArbitraryParenthesesSpacing.SpaceBeforeClose"/>
<exclude name="Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed"/>
<exclude name="Generic.WhiteSpace.DisallowTabIndent.TabsUsed"/>
<exclude name="Generic.WhiteSpace.IncrementDecrementSpacing.SpaceAfterIncrement"/>
<exclude name="Generic.WhiteSpace.LanguageConstructSpacing.IncorrectSingle"/>
<exclude name="Generic.WhiteSpace.ScopeIndent.Incorrect"/>
<exclude name="Generic.WhiteSpace.ScopeIndent.IncorrectExact"/>
<exclude name="Generic.Formatting.NoSpaceAfterCast.SpaceFound"/>
<exclude name="Generic.Arrays.ArrayIndent.CloseBraceNotNewLine"/>
<exclude name="Generic.Arrays.ArrayIndent.CloseBraceIncorrect"/>
<exclude name="Generic.NamingConventions.CamelCapsFunctionName.ScopeNotCamelCaps"/>
<exclude name="Generic.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition"/>"/>
<exclude name="Generic.Formatting.SpaceAfterNot.Incorrect"/>
<exclude name="Generic.CodeAnalysis.AssignmentInCondition.Found"/>
<exclude name="Generic.Functions.OpeningFunctionBraceBsdAllman.BraceOnSameLine"/>
<exclude name="Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed"/>
<exclude name="Generic.PHP.NoSilencedErrors.Discouraged"/>
<exclude name="Generic.PHP.SAPIUsage.FunctionFound"/>
<exclude name="Generic.Files.LowercasedFilename.NotFound"/>
<exclude name="Generic.Commenting.Todo.TaskFound"/>
<exclude name="Generic.Commenting.DocComment.ShortNotCapital"/>
<exclude name="Generic.Files.OneClassPerFile.MultipleFound"/>
<exclude name="Generic.Metrics.CyclomaticComplexity.MaxExceeded"/>
<exclude name="Generic.Functions.OpeningFunctionBraceKernighanRitchie.SpaceBeforeBrace"/>
<exclude name="Generic.ControlStructures.InlineControlStructure.NotAllowed"/>
</rule>
<file>.</file>
<arg name="extensions" value="php"/>
<arg name="encoding" value="UTF-8"/>
<exclude-pattern type="relative">^(vendor|Lib)/*</exclude-pattern>
</ruleset>
3 changes: 2 additions & 1 deletion Lib/menu/menu_langjs.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ function _Tr_Menu(key)
<?php // will return the default value if LANG_JS[key] is not defined. ?>
return LANG_JS_MENU[key] || key;
}
</script>
</script>

6 changes: 3 additions & 3 deletions Modules/admin/admin_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function admin_controller()
$log->error(sprintf('%s|%s',_('Not Admin'), implode('/',array_filter(array($route->controller,$route->action,$route->subaction)))));
$message = urlencode(_('Admin Authentication Required'));

$referrer = urlencode(base64_encode(filter_var($_SERVER['REQUEST_URI'] , FILTER_SANITIZE_URL)));
$referrer = urlencode(base64_encode(filter_var($_SERVER['REQUEST_URI'], FILTER_SANITIZE_URL)));
return sprintf(
'<div class="alert alert-warn mt-3"><h4 class="mb-1">%s</h4>%s. <a href="%s" class="alert-link">%s</a></div>',
_('Admin Authentication Required'),
Expand Down Expand Up @@ -467,9 +467,9 @@ function read_file($file, $lines)
break;
}
if(!empty($handle)) $t = fgetc($handle);
$pos --;
$pos--;
}
$linecounter --;
$linecounter--;
if ($beginning) {
rewind($handle);
}
Expand Down
114 changes: 57 additions & 57 deletions Modules/admin/admin_menu.php
Original file line number Diff line number Diff line change
@@ -1,57 +1,57 @@
<?php
global $session;
if ($session["write"] && $session["admin"]) {
$menu['setup']['l2']['admin'] = array(
'name' => _("Admin"),
'href' => 'admin',
'default' => 'admin/info',
'icon' => 'tasks',
'order' => 13,
"l3"=>array(
"info"=>array(
"name"=>_("System Info"),
"href"=>"admin/info",
"order"=>1,
"icon"=>"input"
),
"update"=>array(
"name"=>_("Update"),
"href"=>"admin/update",
"order"=>1,
"icon"=>"input"
),
"components"=>array(
"name"=>_("Components"),
"href"=>"admin/components",
"order"=>1,
"icon"=>"input"
),
"firmware"=>array(
"name"=>_("Serial Monitor"),
"href"=>"admin/serial",
"order"=>1,
"icon"=>"input"
),
"serialconfig"=>array(
"name"=>_("Serial Config"),
"href"=>"admin/serconfig",
"order"=>1,
"icon"=>"input"
),
"log"=>array(
"name"=>_("Emoncms Log"),
"href"=>"admin/log",
"order"=>1,
"icon"=>"input"
),
"users"=>array(
"name"=>_("Users"),
"href"=>"admin/users",
"order"=>1,
"icon"=>"input"
)
)
);
}
<?php
global $session;
if ($session["write"] && $session["admin"]) {
$menu['setup']['l2']['admin'] = array(
'name' => _("Admin"),
'href' => 'admin',
'default' => 'admin/info',
'icon' => 'tasks',
'order' => 13,

"l3"=>array(
"info"=>array(
"name"=>_("System Info"),
"href"=>"admin/info",
"order"=>1,
"icon"=>"input"
),
"update"=>array(
"name"=>_("Update"),
"href"=>"admin/update",
"order"=>1,
"icon"=>"input"
),
"components"=>array(
"name"=>_("Components"),
"href"=>"admin/components",
"order"=>1,
"icon"=>"input"
),
"firmware"=>array(
"name"=>_("Serial Monitor"),
"href"=>"admin/serial",
"order"=>1,
"icon"=>"input"
),
"serialconfig"=>array(
"name"=>_("Serial Config"),
"href"=>"admin/serconfig",
"order"=>1,
"icon"=>"input"
),
"log"=>array(
"name"=>_("Emoncms Log"),
"href"=>"admin/log",
"order"=>1,
"icon"=>"input"
),
"users"=>array(
"name"=>_("Users"),
"href"=>"admin/users",
"order"=>1,
"icon"=>"input"
)
)

);
}
2 changes: 1 addition & 1 deletion Modules/feed/engine/MysqlMemory.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public function create($feedid, $options)
$table = $this->get_table(intval($feedid));
$name = $table['name'];
$type = $table['type'];

$this->log->info("create() Mysql Memory $name");
$this->mysqli->query("CREATE TABLE $name (time INT UNSIGNED NOT NULL, data $type, UNIQUE (time)) ENGINE=MEMORY");
return true;
Expand Down
2 changes: 1 addition & 1 deletion Modules/feed/engine/MysqlTimeSeries.php
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ public function get_data_DMY_time_of_day($feedid, $start, $end, $mode, $timezone
}
elseif($time >= $range[1]['time']) {
// return latest feed value
$value = (float) $range[1]['data'];
$value = (float) $range[1]['data'];
break;
}
else {
Expand Down
2 changes: 1 addition & 1 deletion Modules/feed/engine/shared_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public function getTimeZoneFormated($time_in,$timezone) {
* custom engine methods can be added by extending a new interface with this one.
* use the newly extended interface to implement the custom engine class
*/
interface engine_methods{
interface engine_methods {

/**
* Create feed
Expand Down
2 changes: 1 addition & 1 deletion Modules/schedule/schedule_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function schedule_controller()
// if public
if (isset($session['write']) && $session['write'] && $session['userid']>0 && $scheduleget['userid']==$session['userid']) {
if ($route->action == "delete") $result = $schedule->delete($scheduleid );
if ($route->action == 'set') $result = $schedule->set_fields($scheduleid ,get('fields'));
if ($route->action == 'set') $result = $schedule->set_fields($scheduleid,get('fields'));
}
}
else
Expand Down
6 changes: 3 additions & 3 deletions Modules/schedule/schedule_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,10 @@ private function match_engine($expression, $exp_timezone, $time, $debug) {
list($start, $end) = explode('-', $day, 2);
list($m, $d) = explode('/', $start, 2);
$start = clone $timeDay;
$start->setDate($start->format('Y') , $m , $d); // set the wanted day and month for 00:00 of input year
$start->setDate($start->format('Y'), $m, $d); // set the wanted day and month for 00:00 of input year
list($m, $d) = explode('/', $end, 2);
$end = clone $timeDay;
$end->setDate($end->format('Y') , $m , $d); // set the wanted day and month for 00:00 of input year
$end->setDate($end->format('Y'), $m, $d); // set the wanted day and month for 00:00 of input year
if ($debug) {
$debugval.=(" ---->" . $start->format('D Y-m-d H:i:s e') . " - " . $end->format('D Y-m-d H:i:s e') . " ? ". $timeDay->format('D Y-m-d H:i:s e'));
}
Expand All @@ -267,7 +267,7 @@ private function match_engine($expression, $exp_timezone, $time, $debug) {
} else { // Is just one day
list($m, $d) = explode('/', $day, 2);
$start = clone $timeDay;
$start->setDate($start->format('Y') , $m , $d); // set the wanted day and month for 00:00 of input year
$start->setDate($start->format('Y'), $m, $d); // set the wanted day and month for 00:00 of input year
if ($debug) {
$debugval.=(" ---->" . $start->format('D Y-m-d H:i:s e') . " ? ". $timeDay->format('D Y-m-d H:i:s e'));
}
Expand Down
70 changes: 35 additions & 35 deletions Modules/user/user_menu.php
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
<?php
global $session;
if ($session["write"]) {
$menu["setup"]["l2"]['user'] = array("name"=>_('My Account'),"href"=>"user/view", "order"=>12, "icon"=>"user");
}
/*
global $session;
$menu['user'][] = array(
'text' => _("My Account"),
'icon' => 'user',
'path' => 'user/view',
'order' => 1
);
$menu['user'][] = array(
'li_class' => 'divider',
'href' => '#',
'order' => 3
);
$menu['user'][] = array(
'text' => _("Logout"),
'icon' => 'logout',
'path' => 'user/logout',
'order' => 4,
'id' => 'logout-link'
);
$menu['user'][] = array(
'title' => _("Login"),
// 'text' => _("Login"),
'icon' => 'enter',
'path' => '/',
'public' => true,
'public_only' => true
);*/
<?php
global $session;
if ($session["write"]) {
$menu["setup"]["l2"]['user'] = array("name"=>_('My Account'),"href"=>"user/view", "order"=>12, "icon"=>"user");
}
/*
global $session;

$menu['user'][] = array(
'text' => _("My Account"),
'icon' => 'user',
'path' => 'user/view',
'order' => 1
);
$menu['user'][] = array(
'li_class' => 'divider',
'href' => '#',
'order' => 3
);
$menu['user'][] = array(
'text' => _("Logout"),
'icon' => 'logout',
'path' => 'user/logout',
'order' => 4,
'id' => 'logout-link'
);

$menu['user'][] = array(
'title' => _("Login"),
// 'text' => _("Login"),
'icon' => 'enter',
'path' => '/',
'public' => true,
'public_only' => true
);*/
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"squizlabs/php_codesniffer": "3.13.2"
},
"scripts": {
"fix": "phpcbf -p --ignore=*/vendor/* --ignore=*/Lib/* --extensions=php .",
"fix": "phpcbf -p .",
"lint": "parallel-lint . --exclude vendor",
"phpcs": "phpcs -p -s --ignore=*/vendor/* --ignore=*/Lib/* .",
"test": [
Expand Down
Loading