upload_photo.php
show_active accesses the super-global variable $_SESSION. Open
Open
function show_active(){
//Start loading external resources
?>
<script src='/js/foundation/foundation.js'></script>
<script src='/js/foundation/foundation.reveal.js'></script>
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
show_active accesses the super-global variable $_SESSION. Open
Open
function show_active(){
//Start loading external resources
?>
<script src='/js/foundation/foundation.js'></script>
<script src='/js/foundation/foundation.reveal.js'></script>
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
Method show_active
has 255 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function show_active(){
//Start loading external resources
?>
<script src='/js/foundation/foundation.js'></script>
<script src='/js/foundation/foundation.reveal.js'></script>
File upload_photo.php
has 287 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
<?php
require_once ('session.php');
require_once ('mysql_access.php');
require_once ('get_photo.php');
//Code based on example at https://vikasmahajan.wordpress.com/2010/07/07/inserting-and-displaying-images-in-mysql-using-php/
The function show_active() has 300 lines of code. Current threshold is set to 100. Avoid really long methods. Open
Open
function show_active(){
//Start loading external resources
?>
<script src='/js/foundation/foundation.js'></script>
<script src='/js/foundation/foundation.reveal.js'></script>
- Exclude checks
Avoid using undefined variables such as '$db' which will lead to PHP notices. Open
Open
$result = $db->query($sql) or die("Error in query: " . mysqli_error());
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
The function show_active() contains an exit expression. Open
Open
$result = $db->query($sql) or die("Error in query: " . mysqli_error());
- Read upRead up
- Exclude checks
ExitExpression
Since: 0.2
An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.
Example
class Foo {
public function bar($param) {
if ($param === 42) {
exit(23);
}
}
}
Source https://phpmd.org/rules/design.html#exitexpression
Avoid unused local variables such as '$db'. Open
Open
$result = $db->query($sql) or die("Error in query: " . mysqli_error());
- Read upRead up
- Exclude checks
UnusedLocalVariable
Since: 0.2
Detects when a local variable is declared and/or assigned, but not used.
Example
class Foo {
public function doSomething()
{
$i = 5; // Unused
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable
A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 25 and the first side effect is on line 2. Open
Open
<?php
- Exclude checks
Line exceeds 120 characters; contains 136 characters Open
Open
<div id="crop_modal" class="reveal-modal" data-reveal role="dialog" data-options="close_on_background_click:false; close_on_esc:false;">
- Exclude checks
Line exceeds 120 characters; contains 129 characters Open
Open
$("#crop_info").html('Oops, something is wrong with connection. Error message: Requested JSON parse failed');
- Exclude checks
Line exceeds 120 characters; contains 122 characters Open
Open
$("#crop_info").html('Oops, something is wrong with connection. Error message: Ajax request aborted');
- Exclude checks
Line exceeds 120 characters; contains 124 characters Open
Open
<input id="userfile" name="userfile" type="file" accept="image/*" onchange="readImageFile(this)" /> <br><br>
- Exclude checks
Line exceeds 120 characters; contains 125 characters Open
Open
document.getElementById('crop_info').innerHTML = 'Step 4: Add Blur to Enlarged Photo with StackBlur';
- Exclude checks
Line exceeds 120 characters; contains 124 characters Open
Open
//Code based on example at https://vikasmahajan.wordpress.com/2010/07/07/inserting-and-displaying-images-in-mysql-using-php/
- Exclude checks
Line exceeds 120 characters; contains 132 characters Open
Open
$("#crop_info").html('Oops, something is wrong with connection. Error message: Requested page not found [404]');
- Exclude checks
Line exceeds 120 characters; contains 129 characters Open
Open
$("#crop_info").html('Oops, something is wrong with connection. Error message: Internal Server Error [500]');
- Exclude checks
End of line character is invalid; expected "\n" but found "\r\n" Open
Open
<?php
- Exclude checks
Line exceeds 120 characters; contains 212 characters Open
Open
document.getElementById("file_div").innerHTML("<p>Sorry, this browser does not support the HTML5 canvas and as such cannot be used to upload a user photo. Please try again using a newer web browser</p>");
- Exclude checks
Line exceeds 120 characters; contains 134 characters Open
Open
$("#crop_info").html('Oops, something is wrong with connection. Error message: Unable to connect to the network');
- Exclude checks
Line exceeds 120 characters; contains 138 characters Open
Open
$("#crop_info").html("Oops, something went wrong. Please refresh the page and try again. Error message: " + response);
- Exclude checks
Expected 1 space after closing parenthesis; found 0 Open
Open
if(mysqli_num_rows($result) != 0){
- Exclude checks
Space before opening parenthesis of function call prohibited Open
Open
require_once ('mysql_access.php');
- Exclude checks
Space before opening parenthesis of function call prohibited Open
Open
require_once ('session.php');
- Exclude checks
Space before opening parenthesis of function call prohibited Open
Open
require_once ('get_photo.php');
- Exclude checks
Opening brace should be on a new line Open
Open
function show_active(){
- Exclude checks
Expected 1 space after IF keyword; 0 found Open
Open
if(mysqli_num_rows($result) != 0){
- Exclude checks