APO-Epsilon/apo-website

View on GitHub
status_change.php

Summary

Maintainability
C
1 day
Test Coverage

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

  $query_orgs = $db->query($select_orgs) or die("There was a problem querying the organizations. Contact the webmaster.");
Severity: Minor
Found in status_change.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 list_orgs() contains an exit expression.
Open

  $query_orgs = $db->query($select_orgs) or die("There was a problem querying the organizations. Contact the webmaster.");
Severity: Minor
Found in status_change.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

  $query_orgs = $db->query($select_orgs) or die("There was a problem querying the organizations. Contact the webmaster.");
Severity: Minor
Found in status_change.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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  if (isset($_POST['update'])) {
    // Update Information
    $_POST = array_map('mysql_real_escape_string', $_POST);
    $user_id = $_SESSION['sessionID'];
$sql = <<<SQL
Severity: Major
Found in status_change.php and 1 other location - About 1 day to fix
updateinfo.php on lines 40..352

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 297.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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 101 and the first side effect is on line 75.
Open

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

Avoid variables with short names like $i. Configured minimum length is 3.
Open

  $i = 1;
Severity: Minor
Found in status_change.php by phpmd

ShortVariable

Since: 0.2

Detects when a field, local, or parameter has a very short name.

Example

class Something {
    private $q = 15; // VIOLATION - Field
    public static function main( array $as ) { // VIOLATION - Formal
        $r = 20 + $this->q; // VIOLATION - Local
        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
            $r += $this->q;
        }
    }
}

Source https://phpmd.org/rules/naming.html#shortvariable

Line exceeds 120 characters; contains 421 characters
Open

    $force = "<div style='margin: 50px; padding: 10px; background: #F08080; '><h1 style='color:red;'>Please update your information for this semester.</h1> Do you have any new <b>Littles</b>, different <b>status</b>, have a new <b>local address</b>, or change your <b>major</b> recently?  You will not be able to access the site until you have clicked 'Update' below.  If you have problems, contact the webmaster!</div>";
Severity: Minor
Found in status_change.php by phpcodesniffer

Line exceeds 120 characters; contains 398 characters
Open

            <input type="text" name="phone" value="$row[phone]" placeholder="+1-555-555-1234" required="" pattern="^(?:(?:\+?1\s*(?:[.-]\s*)?)?(?:\(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*\)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(?:[.-]\s*)?)?([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)?([0-9]{4})(?:\s*(?:#|x\.?|ext\.?|extension)\s*(\d+))?$" autocomplete="tel"/>
Severity: Minor
Found in status_change.php by phpcodesniffer

Line exceeds 120 characters; contains 179 characters
Open

            <input type="text" name="local_address" value="$row[localaddress]" pattern="[a-zA-Z\d\s\-\,\#\.\+]+" placeholder="123 Any Street" autocomplete="Local street-address"/>
Severity: Minor
Found in status_change.php by phpcodesniffer

Line exceeds 120 characters; contains 131 characters
Open

            <input type="text" name="first_name" value="$row[firstname]" placeholder="First name" required="" autocomplete="name"/>
Severity: Minor
Found in status_change.php by phpcodesniffer

Line exceeds 120 characters; contains 122 characters
Open

  $query_orgs = $db->query($select_orgs) or die("There was a problem querying the organizations. Contact the webmaster.");
Severity: Minor
Found in status_change.php by phpcodesniffer

Line exceeds 120 characters; contains 129 characters
Open

            <input type="text" name="email" value="$row[email]" placeholder="name@example.com" required="" autocomplete="email"/>
Severity: Minor
Found in status_change.php by phpcodesniffer

Line exceeds 120 characters; contains 128 characters
Open

            <input type="text" name="last_name" value="$row[lastname]" placeholder="Last name" required="" autocomplete="name"/>
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected at least 8 spaces, found 4
Open

    $_POST = array_map('mysql_real_escape_string', $_POST);
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected 8 spaces, found 4
Open

    }else{
Severity: Minor
Found in status_change.php by phpcodesniffer

Space before opening parenthesis of function call prohibited
Open

  include ('mysql_access.php');
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected 8 spaces, found 2
Open

  }
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected 4 spaces, found 2
Open

  }
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected 8 spaces, found 4
Open

    }
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected at least 8 spaces, found 4
Open

    $result2 = $db->query($sql2);
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected at least 12 spaces, found 6
Open

      echo $_SESSION['active_sem'];
Severity: Minor
Found in status_change.php by phpcodesniffer

Expected 1 space after ELSE keyword; 0 found
Open

    }else{
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected at least 8 spaces, found 4
Open

    $gender = $row['gender'];
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected 8 spaces, found 4
Open

    } else {
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected at least 12 spaces, found 6
Open

      echo "There may have been an error.  Click <a href='./updateinfo.php'>here</a> to try again.";
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected 4 spaces, found 2
Open

  } else {
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected at least 8 spaces, found 4
Open

    $row = mysqli_fetch_array($result);
Severity: Minor
Found in status_change.php by phpcodesniffer

Expected 1 space after closing brace; 0 found
Open

    }else{
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected at least 12 spaces, found 6
Open

      $genderF = "";
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected 8 spaces, found 4
Open

    }
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected at least 12 spaces, found 2
Open

  $i = 1;
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected at least 8 spaces, found 0
Open

$sql = <<<SQL
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected 8 spaces, found 4
Open

    if($gender == 2){
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected at least 4 spaces, found 2
Open

  echo '<div class="entry">You need to <a href="./login.php">login</a> before you can use this page.</div>';
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected at least 16 spaces, found 4
Open

    $i = $i + 1;
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected at least 8 spaces, found 2
Open

  $force = "";
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected 8 spaces, found 2
Open

  if (isset($_GET['forced']) == "true") {
Severity: Minor
Found in status_change.php by phpcodesniffer

Expected 1 space after IF keyword; 0 found
Open

    if($result && $_POST['race'] != "" && $_POST['gender'] != 0){
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected at least 12 spaces, found 6
Open

      echo $_SESSION['active_sem'];
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected at least 8 spaces, found 4
Open

    $sql = "SELECT * FROM `contact_information` WHERE `id` = '$user_id' LIMIT 1";
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected at least 12 spaces, found 6
Open

      $selectedF = "";
Severity: Minor
Found in status_change.php by phpcodesniffer

Expected 1 space after ELSE keyword; 0 found
Open

    }else{
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected at least 12 spaces, found 2
Open

  $query_orgs = $db->query($select_orgs) or die("There was a problem querying the organizations. Contact the webmaster.");
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected 4 spaces, found 2
Open

  if (isset($_POST['update'])) {
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected at least 12 spaces, found 6
Open

      echo "Your information has been updated.  Click <a href='./updateinfo.php'>here</a> to make more changes. ";
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected 8 spaces, found 4
Open

    if($result && $_POST['race'] != "" && $_POST['gender'] != 0){
Severity: Minor
Found in status_change.php by phpcodesniffer

Expected 1 space after IF keyword; 0 found
Open

    if($selected == 'F'){
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected at least 8 spaces, found 4
Open

    $month = date('F', $b_day);
Severity: Minor
Found in status_change.php by phpcodesniffer

Expected 1 space after IF keyword; 0 found
Open

    if($gender == 2){
Severity: Minor
Found in status_change.php by phpcodesniffer

Usage of ELSE IF is discouraged; use ELSEIF instead
Open

    }else if($gender == 1){
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected at least 12 spaces, found 6
Open

      $selectedT = "";
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected at least 12 spaces, found 6
Open

      $genderF = "checked=\"yes\"";
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected 8 spaces, found 4
Open

    }else{
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected at least 12 spaces, found 2
Open

  include ('mysql_access.php');
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected at least 8 spaces, found 4
Open

    $user_id = $_SESSION['sessionID'];
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected at least 8 spaces, found 4
Open

    $result = $db->query($sql);
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected 8 spaces, found 4
Open

    }
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected at least 8 spaces, found 4
Open

    $user_id = $_SESSION['sessionID'];
Severity: Minor
Found in status_change.php by phpcodesniffer

Expected 1 space after closing brace; 0 found
Open

    }else{
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected at least 12 spaces, found 6
Open

      $genderF = "";
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected 8 spaces, found 0
Open

function list_orgs(){
Severity: Minor
Found in status_change.php by phpcodesniffer

Space before opening parenthesis of function call prohibited
Open

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

Line indented incorrectly; expected at least 12 spaces, found 6
Open

      $_SESSION['active_sem'] = $current_semester;
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected at least 12 spaces, found 6
Open

      $selectedF = "checked=\"yes\"";
Severity: Minor
Found in status_change.php by phpcodesniffer

Expected 1 space after closing parenthesis; found 0
Open

    if($gender == 2){
Severity: Minor
Found in status_change.php by phpcodesniffer

Opening brace should be on a new line
Open

function list_orgs(){
Severity: Minor
Found in status_change.php by phpcodesniffer

Expected 1 space after closing parenthesis; found 0
Open

    if($result && $_POST['race'] != "" && $_POST['gender'] != 0){
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected at least 8 spaces, found 4
Open

    $result = $db->query($sql);
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected 8 spaces, found 4
Open

    if($selected == 'F'){
Severity: Minor
Found in status_change.php by phpcodesniffer

Expected 1 space after closing parenthesis; found 0
Open

    }else if($gender == 1){
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected 8 spaces, found 0
Open

}
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected at least 8 spaces, found 4
Open

    $selected = $row['hide_info'];
Severity: Minor
Found in status_change.php by phpcodesniffer

Expected 1 space after closing parenthesis; found 0
Open

    if($selected == 'F'){
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected at least 12 spaces, found 6
Open

      $selectedT = "checked=\"yes\"";
Severity: Minor
Found in status_change.php by phpcodesniffer

Expected 1 space after closing brace; 0 found
Open

    }else if($gender == 1){
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected at least 16 spaces, found 4
Open

    echo "<option id='$orgs[id]''>$orgs[name]</option>";
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected 12 spaces, found 2
Open

  }
Severity: Minor
Found in status_change.php by phpcodesniffer

Space before opening parenthesis of function call prohibited
Open

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

Line indented incorrectly; expected at least 8 spaces, found 4
Open

    $b_day = mktime(0, 0, 0, $row['bmonth'], 1, 2000);
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected at least 12 spaces, found 0
Open

$select_orgs = <<<SQL
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected 12 spaces, found 2
Open

  while ($orgs = mysqli_fetch_array($query_orgs)) {
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected at least 12 spaces, found 4
Open

    $force = "<div style='margin: 50px; padding: 10px; background: #F08080; '><h1 style='color:red;'>Please update your information for this semester.</h1> Do you have any new <b>Littles</b>, different <b>status</b>, have a new <b>local address</b>, or change your <b>major</b> recently?  You will not be able to access the site until you have clicked 'Update' below.  If you have problems, contact the webmaster!</div>";
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected at least 8 spaces, found 4
Open

    $sql2 = "UPDATE `contact_information` SET visited = '1' WHERE id = '$user_id' LIMIT 1";
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected at least 12 spaces, found 6
Open

      $_SESSION['active_sem'] = $current_semester;
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected at least 12 spaces, found 6
Open

      $genderM = "";
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected at least 8 spaces, found 0
Open

echo<<<END
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected at least 12 spaces, found 6
Open

      $genderM = "checked=\"yes\"";
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected 8 spaces, found 4
Open

    }else if($gender == 1){
Severity: Minor
Found in status_change.php by phpcodesniffer

Expected 1 space after IF keyword; 0 found
Open

    }else if($gender == 1){
Severity: Minor
Found in status_change.php by phpcodesniffer

Line indented incorrectly; expected at least 12 spaces, found 6
Open

      $genderM = "";
Severity: Minor
Found in status_change.php by phpcodesniffer

The variable $select_orgs is not named in camelCase.
Open

function list_orgs(){
  include ('mysql_access.php');
$select_orgs = <<<SQL
  SELECT `name`, `id`
  FROM `organizations`
Severity: Minor
Found in status_change.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $select_orgs is not named in camelCase.
Open

function list_orgs(){
  include ('mysql_access.php');
$select_orgs = <<<SQL
  SELECT `name`, `id`
  FROM `organizations`
Severity: Minor
Found in status_change.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $query_orgs is not named in camelCase.
Open

function list_orgs(){
  include ('mysql_access.php');
$select_orgs = <<<SQL
  SELECT `name`, `id`
  FROM `organizations`
Severity: Minor
Found in status_change.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $query_orgs is not named in camelCase.
Open

function list_orgs(){
  include ('mysql_access.php');
$select_orgs = <<<SQL
  SELECT `name`, `id`
  FROM `organizations`
Severity: Minor
Found in status_change.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

There are no issues that match your filters.

Category
Status