APO-Epsilon/apo-website

View on GitHub
upload_photo.php

Summary

Maintainability
D
1 day
Test Coverage

show_active accesses the super-global variable $_SESSION.
Open

function show_active(){
    //Start loading external resources
    ?>
    <script src='/js/foundation/foundation.js'></script>
    <script src='/js/foundation/foundation.reveal.js'></script>
Severity: Minor
Found in upload_photo.php by phpmd

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

function show_active(){
    //Start loading external resources
    ?>
    <script src='/js/foundation/foundation.js'></script>
    <script src='/js/foundation/foundation.reveal.js'></script>
Severity: Minor
Found in upload_photo.php by phpmd

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

function show_active(){
    //Start loading external resources
    ?>
    <script src='/js/foundation/foundation.js'></script>
    <script src='/js/foundation/foundation.reveal.js'></script>
Severity: Major
Found in upload_photo.php - About 1 day to fix

    File upload_photo.php has 287 lines of code (exceeds 250 allowed). Consider refactoring.
    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/
    Severity: Minor
    Found in upload_photo.php - About 2 hrs to fix

      The function show_active() has 300 lines of code. Current threshold is set to 100. Avoid really long methods.
      Open

      function show_active(){
          //Start loading external resources
          ?>
          <script src='/js/foundation/foundation.js'></script>
          <script src='/js/foundation/foundation.reveal.js'></script>
      Severity: Minor
      Found in upload_photo.php by phpmd

      Avoid using undefined variables such as '$db' which will lead to PHP notices.
      Open

      $result = $db->query($sql) or die("Error in query: " . mysqli_error());
      Severity: Minor
      Found in upload_photo.php by phpmd

      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

      $result = $db->query($sql) or die("Error in query: " . mysqli_error());
      Severity: Minor
      Found in upload_photo.php by phpmd

      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

      $result = $db->query($sql) or die("Error in query: " . mysqli_error());
      Severity: Minor
      Found in upload_photo.php by phpmd

      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

      <?php
      Severity: Minor
      Found in upload_photo.php by phpcodesniffer

      Line exceeds 120 characters; contains 136 characters
      Open

      <div id="crop_modal" class="reveal-modal" data-reveal role="dialog" data-options="close_on_background_click:false; close_on_esc:false;">
      Severity: Minor
      Found in upload_photo.php by phpcodesniffer

      Line exceeds 120 characters; contains 129 characters
      Open

                          $("#crop_info").html('Oops, something is wrong with connection. Error message: Requested JSON parse failed');
      Severity: Minor
      Found in upload_photo.php by phpcodesniffer

      Line exceeds 120 characters; contains 122 characters
      Open

                          $("#crop_info").html('Oops, something is wrong with connection. Error message: Ajax request aborted');
      Severity: Minor
      Found in upload_photo.php by phpcodesniffer

      Line exceeds 120 characters; contains 124 characters
      Open

                      <input id="userfile" name="userfile" type="file" accept="image/*" onchange="readImageFile(this)" /> <br><br>
      Severity: Minor
      Found in upload_photo.php by phpcodesniffer

      Line exceeds 120 characters; contains 125 characters
      Open

                              document.getElementById('crop_info').innerHTML = 'Step 4: Add Blur to Enlarged Photo with StackBlur';
      Severity: Minor
      Found in upload_photo.php by phpcodesniffer

      Line exceeds 120 characters; contains 124 characters
      Open

      //Code based on example at https://vikasmahajan.wordpress.com/2010/07/07/inserting-and-displaying-images-in-mysql-using-php/
      Severity: Minor
      Found in upload_photo.php by phpcodesniffer

      Line exceeds 120 characters; contains 132 characters
      Open

                          $("#crop_info").html('Oops, something is wrong with connection. Error message: Requested page not found [404]');
      Severity: Minor
      Found in upload_photo.php by phpcodesniffer

      Line exceeds 120 characters; contains 129 characters
      Open

                          $("#crop_info").html('Oops, something is wrong with connection. Error message: Internal Server Error [500]');
      Severity: Minor
      Found in upload_photo.php by phpcodesniffer

      End of line character is invalid; expected "\n" but found "\r\n"
      Open

      <?php
      Severity: Minor
      Found in upload_photo.php by phpcodesniffer

      Line exceeds 120 characters; contains 212 characters
      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>");
      Severity: Minor
      Found in upload_photo.php by phpcodesniffer

      Line exceeds 120 characters; contains 134 characters
      Open

                          $("#crop_info").html('Oops, something is wrong with connection. Error message: Unable to connect to the network');
      Severity: Minor
      Found in upload_photo.php by phpcodesniffer

      Line exceeds 120 characters; contains 138 characters
      Open

                          $("#crop_info").html("Oops, something went wrong. Please refresh the page and try again. Error message: " + response);
      Severity: Minor
      Found in upload_photo.php by phpcodesniffer

      Expected 1 space after closing parenthesis; found 0
      Open

      if(mysqli_num_rows($result) != 0){
      Severity: Minor
      Found in upload_photo.php by phpcodesniffer

      Space before opening parenthesis of function call prohibited
      Open

      require_once ('mysql_access.php');
      Severity: Minor
      Found in upload_photo.php by phpcodesniffer

      Space before opening parenthesis of function call prohibited
      Open

      require_once ('session.php');
      Severity: Minor
      Found in upload_photo.php by phpcodesniffer

      Space before opening parenthesis of function call prohibited
      Open

      require_once ('get_photo.php');
      Severity: Minor
      Found in upload_photo.php by phpcodesniffer

      Opening brace should be on a new line
      Open

      function show_active(){
      Severity: Minor
      Found in upload_photo.php by phpcodesniffer

      Expected 1 space after IF keyword; 0 found
      Open

      if(mysqli_num_rows($result) != 0){
      Severity: Minor
      Found in upload_photo.php by phpcodesniffer

      There are no issues that match your filters.

      Category
      Status