Example #1
0
 /** 
  * dechunk an http 'transfer-encoding: chunked' message 
  * 
  * @param string $chunk the encoded message 
  * @return string the decoded message.  If $chunk wasn't encoded properly it will be returned unmodified. 
  */
 function http_chunked_decode($chunk)
 {
     $pos = 0;
     $len = strlen($chunk);
     $dechunk = null;
     while ($pos < $len && ($chunkLenHex = substr($chunk, $pos, ($newlineAt = strpos($chunk, "\n", $pos + 1)) - $pos))) {
         if (!is_hex($chunkLenHex)) {
             trigger_error('Value is not properly chunk encoded', E_USER_WARNING);
             return $chunk;
         }
         $pos = $newlineAt + 1;
         $chunkLen = hexdec(rtrim($chunkLenHex, "\r\n"));
         $dechunk .= substr($chunk, $pos, $chunkLen);
         $pos = strpos($chunk, "\n", $pos + $chunkLen) + 1;
     }
     return $dechunk;
 }
Example #2
0
/**
 * Fix any invalid entities in the text.
 *
 * @param  string			Text to fix in
 * @return string			Fixed result
 */
function fix_entities($in)
{
    global $ENTITIES;
    $out = '';
    $len = strlen($in);
    for ($i = 0; $i < $len; $i++) {
        $out .= $in[$i];
        if ($in[$i] == '&') {
            $lump = substr($in, $i + 1, 8);
            $pos = strpos($lump, ';');
            if ($pos === false) {
                $out .= 'amp;';
            } else {
                $lump = substr($lump, 0, $pos);
                if (!($lump[0] == '#' && (is_numeric(substr($lump, 1)) || $lump[1] == 'x' && is_hex(substr($lump, 2))))) {
                    if (!isset($ENTITIES[$lump])) {
                        $out .= 'amp;';
                    }
                }
            }
        }
    }
    return $out;
}
Example #3
0
$mafiasql = mysqli_query($con, "SELECT * FROM Mafias");
$mafiadata = mysqli_fetch_array($mafiasql);
if ($mymoney < 1000000) {
    header("Location: createmafiaresult.php?result=fail&reason=money");
} else {
    $allsetmon = "+";
}
if ($afterbuyproperties > $mymaxproperties) {
    header("Location: createmafiaresult.php?result=fail&reason=properties");
} else {
    $allsetpro = "+";
}
if (empty($color)) {
    header("Location: createmafiaresult.php?result=fail&reason=color");
} else {
    if (is_hex($color) && strlen($color) == 6) {
        $allsetcol = "+";
        $color = "#" . $color;
    } else {
        header("Location: createmafiaresult.php?result=fail&reason=color");
    }
}
function is_hex($hex)
{
    $hex = strtolower(trim(ltrim($hex, "0")));
    if (empty($hex)) {
        $hex = 0;
    }
    $dec = hexdec($hex);
    return $hex == dechex($dec);
}
Example #4
0
 protected function is_hex($hex)
 {
     if (defined('STRICT_TYPES') && CAMEL_CASE == '1') {
         return (bool) self::parameters(['hex' => DT::STRING])->call(__FUNCTION__)->with($hex)->returning(DT::BOOL);
     } else {
         return (bool) is_hex($hex);
     }
 }
                $newpass = md5($newpass);
                if ($pass == $currentpass) {
                    mysqli_query($con, "UPDATE Users SET Password='******' WHERE Cookie='{$cookie}'");
                    header("Location: usersettings.php?result=success&reason=passupdated");
                } else {
                    header("Location: usersettings.php?result=fail&reason=wrongcurrentpass-passchange");
                }
            }
        } else {
            header("Location: usersettings.php?result=fail&reason=newpassmismatch");
        }
    }
} elseif ($edit == "color") {
    if ($pass == $currentpass) {
        $color = $_POST['color'];
        if (is_hex($color)) {
            if ($mymembership >= $time) {
                $color = '#' . $color;
                mysqli_query($con, "UPDATE Users SET Color='{$color}' WHERE Cookie='{$cookie}'");
                header("Location: usersettings.php?result=success&reason=colorupdated");
            } else {
                header("Location: index.php");
            }
        } else {
            header("Location: usersettings.php?result=fail&reason=nothex");
        }
    } else {
        header("Location: usersettings.php?result=fail&reason=wrongcurrentpass-color");
    }
} else {
    header("Location: index.php");
Example #6
0
  public function get($str)
  {

    /*
      Identify ID Format and Process
    */

    $pid = false;

    // EID
    if (ctype_digit($str) === true && strlen($str) <= 2) {
      $q = $this->db->select('acctnum')->where('eid',$str);
      $r = $q->get('entities')->row_array();
      $pid = element('acctnum',$r);
    }
    // Account Number as Integer
    elseif (ctype_digit($str) === true  && strlen($str) >= 7)
    {
      $pid = $str;
    }
    // Account Number as Hexadecimal
    elseif (is_hex($str) === true)
    {
      $pid = hexdec($str);
    }
    // Account Number as Fromatted String
    elseif (is_account_number($str))
    {
      $pid = preg_replace('/\D/','', $str);
    }
    // Email Address
    elseif (is_email($str))
    {
      $q = $this->api->request('get', 'profile/pid', array('email'=>$str));

      if (isset($q->pid))
      {
        $pid = $q->pid;
      }
      else
      {
        $pid = false;
      }
    }
    // Telephone Number
    elseif (is_tel($str))
    {
      $q = $this->api->request('get', 'profile/pid',array('tel'=>$str));

      if (isset($q->pid))
      {
        $pid = $q->pid;
      }
      else
      {
        $pid = false;
      }
    }

    // Create Profile in Class If Needed
    if (isset($this->profiles[$pid]) !== true)
    {
      $this->profiles[$pid] = new Profile_Base($pid);
    }

    // Store Reference
    $profile = $this->profiles[$pid];

    // Return Reference to Profile in Class
    return $profile;

  }