function setText($text = '')
 {
     if ($this->charset != "utf-8") {
         parent::setText(encodeString($this->encodeNonInCharset($text, false), $this->charset));
     } else {
         parent::setText($text);
     }
 }
Esempio n. 2
0
function fetchPage($r, $f, $m, $mode)
{
    $c = access_url($r);
    //$output will be written in a file.
    //$out will be printed.
    $encoded = '';
    if ($mode == "enc") {
        $output = base64_encode($c[0]);
        $encoded .= encodeString($output);
        $out = "[" . $encoded . "]";
    } else {
        if ($mode == "raw") {
            $out = $c[0];
            $output = base64_encode($c[0]);
        } else {
            if ($mode == "script") {
                $output = base64_encode($c[0]);
                $out = 'eval(Base64.decode("' . $output . '"));';
            }
        }
    }
    $hrh = $c[1];
    if (strlen($encoded) == 0) {
        $encoded = encodeString($output);
    }
    $ContentType = getheader($hrh, "Content-type");
    $Filename = getheader($hrh, "Filename");
    //Generate json data
    $arrayData = array();
    $arrayData["Content-type"] = $ContentType;
    $arrayData["Request-url"] = $r;
    $arrayData["md5sum"] = md5($encoded);
    $arrayData["Filename"] = $Filename;
    $jsonData = json_encode($arrayData);
    if (!$mode == "enc") {
        print "(" . base64_encode($jsonData) . ")\n";
    } else {
        header("Content-type: " . $ContentType, true);
        header("Filename: " . $Filename, true);
    }
    if (ENABLE_CACHE) {
        $o = gzopen($f, GZ_WRITE_MODE);
        @gzwrite($o, "[");
        @gzwrite($o, $output);
        @gzwrite($o, "]");
        @gzwrite($o, "(");
        @gzwrite($o, $jsonData);
        @gzwrite($o, ")");
        @gzclose($o);
    }
    echo $out;
}
Esempio n. 3
0
 private function checkPassword($username, $password, $hash)
 {
     $hashtype = substr($hash, 0, strpos($hash, '}') + 1);
     $hashclean = strpos($hash, '}') ? substr($hash, strpos($hash, '}') + 1) : $hash;
     switch ($hashtype) {
         case '{SSHA}':
             $salt = substr(base64_decode($hashclean), -10);
             return $hashclean == base64_encode(pack("H*", sha1($password . $salt)) . $salt);
             break;
         case '{SHA}':
             return $hashclean == base64_encode(pack("H*", sha1($password)));
             break;
         case '{HTS}':
         default:
             return $hashclean == encodeString($username, $password);
             break;
     }
 }
function signIn($username, $password)
{
    if (hasNotSensitiveCharacters($username)) {
        if (hasNotSensitiveCharacters($password)) {
            $password = encodeString($password);
            $query = "select * from user_login WHERE username='******' AND password='******'";
            $result_set = mysql_query($query);
            if (isQuerySuccess($result_set)) {
                if (mysql_num_rows($result_set) == 1) {
                    $userLogin = mysql_fetch_array($result_set);
                    $_SESSION['username'] = $userLogin['username'];
                    redirect_to("userHome");
                    return "";
                } else {
                    return "Invalid Login details";
                }
            }
        } else {
            return "Password has invalid characters";
        }
    } else {
        return "Username has invalid characters";
    }
}
Esempio n. 5
0
function encodeString($string, $length)
{
    $string = str_pad($string, $length);
    $string = substr($string, 0, $length);
    $encoded = '';
    for ($n = 0; $n < strlen($string); ++$n) {
        $encoded .= dechex(ord($string[$n]));
    }
    return $encoded;
}
$dbh = Database::connect();
$sql = 'SELECT * FROM devices LEFT JOIN aircrafts ON dev_actype = ac_id WHERE dev_noident = 0 AND dev_notrack = 0 ORDER BY dev_id ASC';
echo "002c38\n";
// Version
foreach ($dbh->query($sql) as $row) {
    echo encodeString($row['dev_id'], 6);
    // Id
    echo encodeString('', 21);
    // Owner
    echo encodeString('', 21);
    // Airport
    echo encodeString($row['ac_type'], 21);
    // Aircraft
    echo encodeString($row['dev_acreg'], 7);
    // Raignum
    echo encodeString($row['dev_accn'], 3);
    // CN
    echo encodeString('', 7) . "\n";
    // Freq
}
Database::disconnect();
function addUser($username, $email, $firstname, $lastname, $gender, $address1, $address2, $country, $contactnumber, $password)
{
    if (hasNotSensitiveCharacters($username)) {
        if (hasNotSensitiveCharacters($email)) {
            if (hasNotSensitiveCharacters($firstname)) {
                if (hasNotSensitiveCharacters($lastname)) {
                    if (hasNotSensitiveCharacters($gender)) {
                        if (hasNotSensitiveCharacters($address1)) {
                            if (hasNotSensitiveCharacters($address2)) {
                                if (hasNotSensitiveCharacters($country)) {
                                    if (hasNotSensitiveCharacters($contactnumber)) {
                                        if (hasNotSensitiveCharacters($password)) {
                                            if ($gender != "Select a gender" && $country != "Select a country") {
                                                if (!(isUserExistsByUsername($username) || isUserExistsByEmail($email))) {
                                                    if (isNonFetchQuerySuccess("INSERT INTO user_profile_details (username, first_name, last_name,gender,address_line1,country,email,address_line2,picture_file_path,contact_number) VALUES ('{$username}', '{$firstname}','{$lastname}' , '{$gender}' , '{$address1}', '{$country}', '{$email}', '{$address2}', '', '{$contactnumber}')")) {
                                                        $password = encodeString($password);
                                                        if (isAdminAlreadyExists($username)) {
                                                            isNonFetchQuerySuccess("INSERT INTO user_login (username, password , status) VALUES ('{$username}', '{$password}', 'NORMAL USER')");
                                                        } else {
                                                            isNonFetchQuerySuccess("INSERT INTO user_login (username, password , status) VALUES ('{$username}', '{$password}', 'ADMIN USER')");
                                                        }
                                                        $_SESSION['firstSignIn'] = "Successfully signed up! <br> Now you can login here";
                                                        redirect_to("home");
                                                    } else {
                                                        return "Registration Failed";
                                                    }
                                                } else {
                                                    if (isUserExistsByUsername($username)) {
                                                        return "Username is not available";
                                                    } else {
                                                        if (isUserExistsByEmail($email)) {
                                                            return "Email already exists";
                                                        }
                                                    }
                                                }
                                            }
                                        } else {
                                            return "Password has Invalid characters";
                                        }
                                    } else {
                                        return "Contact number has Invalid characters";
                                    }
                                } else {
                                    return "Country has Invalid characters";
                                }
                            } else {
                                return "Address Line 2 has Invalid characters";
                            }
                        } else {
                            return "Address Line 1 has Invalid characters";
                        }
                    } else {
                        return "Gender has Invalid characters";
                    }
                } else {
                    return "Last name has Invalid characters";
                }
            } else {
                return "First name has Invalid characters";
            }
        } else {
            return "Email has Invalid characters";
        }
    } else {
        return "Username has Invalid characters";
    }
}
Esempio n. 7
0
 /**
  * change the internal links
  */
 protected function setLinks(DOMDocument $dom)
 {
     $list = $dom->getElementsByTagName('a');
     foreach ($list as $node) {
         $href = $node->getAttribute('href');
         $title = encodeString($node->getAttribute('title')) . '.xhtml';
         if ($href[0] == '#') {
             continue;
         } elseif (in_array($title, $this->linksList)) {
             $pos = strpos($href, '#');
             if ($pos !== false) {
                 $anchor = substr($href, $pos + 1);
                 if (is_numeric($anchor)) {
                     $title .= '#_' . $anchor;
                 } else {
                     $title .= '#' . $anchor;
                 }
             }
             $node->setAttribute('href', $title);
         } elseif (substr($href, 0, 2) === '//') {
             $node->setAttribute('href', 'http:' . $href);
         } elseif ($href[0] === '/') {
             $node->setAttribute('href', $this->baseUrl . $href);
         }
     }
 }
                                                            <tr height="30">
                                                                <td>
                                                                    <div style="font-size:11px; font-weight:bold; color:#c1c1c1;">
                                                                    	<a href="#"><i class="fa fa-map-marker"></i> ' . $countryName . '</a> <i class="fa fa-angle-right"></i> 
                                                                        <a href="#">' . $cityName . '</a> <i class="fa fa-angle-right"></i> 
                                                                        <a href="#">' . $areaName . '</a>
                                                                    </div>
                                                                </td>
                                                            </tr>
                                                        </tbody>
                                                     </table>
                                                </td>
												
                                                <td class="tableCellCenter action_td_verticle">
													 <div><a href="/reservation/' . encodeString($camping_row['id'], "camping") . '" target="_new"><button type="submit" class="btn btn-primary btn-xs" ><i class="fa fa-calendar fa-fw"></i> 가용성</button></a></div>
                                                	 <div><a href="/camp/' . encodeString($camping_row['id'], "camping") . '" target="_new"><button type="submit" class="btn btn-primary btn-xs" ><i class="fa fa-eye fa-fw"></i>View</button></a></div>
                                                     <div><a href="/admin/editcamping?id=' . $camping_row['id'] . '"><button type="submit" class="btn btn-primary btn-xs" ><i class="fa fa-pencil-square-o fa-fw"></i> 편집</button></a></div>
                                                     <div><button type="submit" class="btn btn-primary btn-xs" style="' . ($active == 0 ? 'background:#ec6513;' : '') . '" onclick="comfirmCampDeactivate(' . $camping_row['id'] . ',' . $active . ')" >' . ($active == 1 ? '<i class="fa fa-lock"></i> Deactive ' : '<i class="fa fa-unlock-alt"></i>  Active ') . '</button></div>
                                                     ' . ($pending == 1 ? '<div><button type="submit" class="btn btn-primary btn-xs" onclick="comfirmCampApproval(' . $camping_row['id'] . ',' . $pending . ')" ><i class="fa fa-check-square-o fa-fw"></i> Approve</button></div>' : '') . '
                                                </td>
                                            </tr>';
        $i++;
    }
    if ($campingListString == '') {
        $campingListString = '<tr><td colspan="3" style="text-align:center; color:#c0434d;"><i class="fa fa-frown-o"></i> No Camping Found</td></tr>';
    }
    $data = array('list' => $campingListString, 'targetPage' => $targetPage, 'totalRow' => $totalRow, 'totalPages' => $totalPages, 'gotoSelectNum' => $gotoSelectNum, 'nav_btn_disable' => $nav_btn_disable);
    echo json_encode($data);
} elseif ($cmd == 'deactivateCamp_block') {
    $id = post('id');
    $camp_qry = exec_query_utf8("UPDATE tblcamping SET active = NOT active WHERE id={$id} LIMIT 1");
Esempio n. 9
0
 public function testEncodeString()
 {
     $this->assertEquals('c0_test_dou', encodeString('test_Δôü'));
 }
Esempio n. 10
0
	function setText($text = '')
	{
		global $prefs;
		if (!empty($prefs['email_footer'])) {
			$text .= CRLF . $prefs['email_footer'];
		}
		if ($this->charset != "utf-8")
			parent::setText(encodeString($this->encodeNonInCharset($text, false), $this->charset));
		else
			parent::setText($text);
	}
function updateUserPassWord($username, $currentPassword, $newPassword)
{
    if (hasNotSensitiveCharacters($currentPassword)) {
        if (hasNotSensitiveCharacters($newPassword)) {
            $currentPassword = encodeString($currentPassword);
            $query = "select * from user_login WHERE username='******' AND password='******'";
            $result_set = mysql_query($query);
            if (isQuerySuccess($result_set)) {
                if (mysql_num_rows($result_set) == 1) {
                    $newPassword = encodeString($newPassword);
                    isNonFetchQuerySuccess("UPDATE user_login SET password = '******' WHERE username = '******' ");
                    return "<font color=green>Password is changed successfully</font>";
                } else {
                    return "<font color=red>Invalid current password</font>";
                }
            }
        } else {
            return "<font color=red>Invalid new password</font>";
        }
    } else {
        return "<font color=red>Invalid current password</font>";
    }
}
Esempio n. 12
0
 /**
  * Function to add new user in db.
  * currently not using these function as we add user directly once we login by google account
  * @param type $input_data 
  * @return type
  */
 function add_new_user($input_data)
 {
     $user_name = $input_data['username'];
     $password = $input_data['password'];
     $email = $input_data['email'];
     $first = $input_data['first'];
     $last = $input_data['last'];
     $encrypted_password = encodeString($password);
     $role = 'user';
     //create user array to insert ibnto users table
     $user_array = array('username' => $user_name, 'password' => $encrypted_password, 'role' => $role);
     $query = $this->db->insert_string('users', $user_array);
     $result = $this->db->query($query);
     $id = $this->db->insert_id();
     //create profile array to insert into profile table
     $profile_array = array('first' => $first, 'last' => $last, 'email' => $email);
     $query = $this->db->insert_string('google_account', $profile_array);
     $result = $this->db->query($query);
     if ($result) {
         return true;
     } else {
         return false;
     }
 }
Esempio n. 13
0
/**
 * Builds a unique temporary file name for a given title and extension
 *
 * @param string $title
 * @param string $extension
 * @return string
 */
function buildTemporaryFileName($title, $extension)
{
    global $wsexportConfig;
    return $wsexportConfig['tempPath'] . '/' . encodeString($title) . '-' . mt_rand() . '.' . $extension;
}