script47 / easyphp Goto Github PK
View Code? Open in Web Editor NEWA class containing various PHP functions to make a developers life easier.
License: Other
A class containing various PHP functions to make a developers life easier.
License: Other
The notify method is pretty ineffective, as you'd be sending n
e-mails every time it's called, rather than just 1.
For the to
field (the first parameter), you can comma separate the addresses.
This will be more effective.
mail( implode(",", self::$mailTo), "New Major Error Logged" . $message . PHP_EOL . PHP_EOL . "This log was generated on " . $logGeneratedOn . PHP_EOL . PHP_EOL . "The time above is set using the server time.", "From: Logs@EasyPHPClass\n");
There's a possible insecurity here, allowing users to spoof their IP address.
X-Forwarded-For is an HTTP header field considered as a de facto standard for identifying the originating IP address of a client connecting to a web server through an HTTP proxy or load balancer.
Because this method sends a Header
, it can be called during mid-code. If you have HTML output already, you'll get a headers already sent
error.
You can achieve sending a header()
after output by using output control/buffering
The current redirect method has a pretty redundant parameter; $type
. If you want an instant redirect, you need to supply the word instant
, which really isn't needed, because the only thing that separates an instant redirect and a timed redirect is the $time
parameter.
I think an approach like this would be much better;
public static function redirect($page, $time = 0) {
header("Refresh: $time; URL=$page");
}
That way, you only have 1 parameter for an instant redirect, and 2 for a timed redirect; not three (one being useless).
The logger() method
should write to a log too (if a parameter is given) depending on the type of $message
. For example;
public static function logger($message, $type = "") {
$timeStamp = date("h:i:s d/m/Y");
mail($this->loggerSendTo, "PHP Logger", $message . PHP_EOL . PHP_EOL . "Sent On - " . $timeStamp, "From: $sendTo");
if($type != "") {
if(file_exists('/path/to/logs'. strtolower($type) .'.log') AND is_writable('/path/to/logs'. strtolower($type) .'.log') {
file_put_contents('/path/to/logs'. strtolower($type) .'.log', PHP_EOL . $timeStamp .' -'. $message . PHP_EOL, FILE_APPEND);
}
}
}
Your method encode()
should be changed to;
=
) with another character?Ideally, modify the message() function to;
div
with a suitable class name to allow easier modification/styling.I think your logic is flawed on isEmpty
method.
isEmpty
suggests if the variable is empty return TRUE
, otherwise FALSE
.
Your logic suggests if the variable is empty return FALSE
, otherwise NOT FALSE
.
Because, really, you're asking if it's empty. If it is, return TRUE
.
Also, methods prefixed with is
should return boolean.
public static function isEmpty($variable) {
//Do we need to check the variable is set?
return empty($variable);
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.