Example #1
0
 $table = array('label', 'login', 'pw', 'description');
 foreach ($rows as $record) {
     $printed_ids[] = $record['id'];
     if ($prev_path != $record['path']) {
         $pdf->SetFont('DejaVu', '', 10);
         $pdf->SetFillColor(192, 192, 192);
         error_log('key: ' . $key . ' - paths: ' . $record['path']);
         $pdf->cell(0, 6, $record['path'], 1, 1, "L", 1);
         $pdf->SetFillColor(222, 222, 222);
         $pdf->cell($table_col_width[0], 6, $LANG['label'], 1, 0, "C", 1);
         $pdf->cell($table_col_width[1], 6, $LANG['login'], 1, 0, "C", 1);
         $pdf->cell($table_col_width[2], 6, $LANG['pw'], 1, 0, "C", 1);
         $pdf->cell($table_col_width[3], 6, $LANG['description'], 1, 1, "C", 1);
     }
     $prev_path = $record['path'];
     if (!isutf8($record['pw'])) {
         $record['pw'] = "";
     }
     $record['description'] = html_entity_decode(htmlspecialchars_decode(str_replace("<br />", "\n", $record['description']), ENT_QUOTES));
     //row height calculation
     $nb = 0;
     $nb = max($nb, nbLines($table_col_width[0], $record['label']));
     $nb = max($nb, nbLines($table_col_width[3], $record['description']));
     $nb = max($nb, nbLines($table_col_width[2], $record['pw']));
     $h = 5 * $nb;
     //Page break needed?
     checkPageBreak($h);
     //Draw cells
     $pdf->SetFont('DejaVu', '', 9);
     for ($i = 0; $i < count($table); $i++) {
         $w = $table_col_width[$i];
Example #2
0
 // check if key exists for this item
 DB::query("SELECT * FROM " . prefix_table("keys") . " WHERE `id` = %i AND `sql_table` = %s", $record['id'], "items");
 $counter = DB::count();
 if ($counter == 0) {
     $storePrefix = false;
     // decrypt pw
     $pw = cryption($record['pw'], SALT, $record['pw_iv'], "decrypt");
     if (!empty($pw) && strlen($pw) > 15 && isutf8($pw)) {
         // Pw seems to have a prefix
         // get old prefix
         $randomKey = substr($pw, 0, 15);
         // check if prefix contains only lowercase and numerics
         //TODO
         // should we store?
         $storePrefix = true;
     } elseif (!empty($pw) && isutf8($pw)) {
         // Pw doesn't seem to have a prefix
         // re-encrypt with key prefix
         $randomKey = generateKey();
         $pw = $randomKey . $pw;
         $pw = encrypt($pw);
         // store pw
         DB::update(prefix_table("items"), array('pw' => $pw), "id=%s", $record['id']);
         // should we store?
         $storePrefix = true;
     }
     if ($storePrefix == true) {
         // store key prefix
         DB::insert(prefix_table("keys"), array('table' => 'items', 'id' => $record['id'], 'rand_key' => $randomKey));
     }
     $numOfItemsChanged++;
Example #3
0
<ul>
<?php 
include "../inc/function.php";
include "../inc/config.php";
session_start();
setcookie(session_name(), session_id(), time() + $sessionTime, "/");
if (isset($_SESSION["role"]) && ($_SESSION["role"] == ADMIN || $_SESSION["role"] == TEACHER)) {
    $father = @isutf8($_GET["dir"]) ? iconv("UTF-8", "gb2312", $_GET["dir"]) : $_GET["dir"];
    $fileArr = dir_list($father);
    foreach ($fileArr as $file) {
        $filename = str_replace($father . "/", "", $file);
        if (is_dir($file)) {
            $file = iconv("gb2312", "UTF-8", $file);
            $filename = iconv("gb2312", "UTF-8", $filename);
            echo "<li><img src='../img/no-expanded.gif' dir='{$file}' onclick='showChildrenDir(\"{$file}\",this)'>" . $filename . "</li>";
        } else {
            $file = iconv("gb2312", "UTF-8", $file);
            $filename = iconv("gb2312", "UTF-8", $filename);
            echo "<li><label><input type='radio' name='indexfile' value='{$file}'>" . $filename . "</label></li>";
        }
    }
} else {
    die("What are you doing?");
}
?>
</ul>
Example #4
0
$aes = new SplClassLoader('Encryption\\Crypt', '../includes/libraries');
$aes->register();
switch ($_POST['type']) {
    /*
     * CASE
     * creating a new ITEM
     */
    case "tool_1":
        if (!isset($_POST['action'])) {
            $rowColor = false;
            $ret = "";
            $rows = DB::query("SELECT i.id as id, i.pw as pw, k.rand_key as rand_key\n                FROM " . $pre . "items as i\n                LEFT JOIN " . $pre . "keys as k ON (k.id = i.id)\n                GROUP BY i.id\n                LIMIT " . $_POST['index'] . ", 10");
            foreach ($rows as $record) {
                $pw = decrypt($record['pw']);
                if (strlen($pw) >= 1) {
                    if (isutf8($pw)) {
                        if (substr($pw, 0, strlen($record['rand_key'])) == $record['rand_key']) {
                            // case
                        }
                        $pw = substr($pw, strlen($record['rand_key']));
                        if ($_SESSION['prefix_length'] >= strlen($pw)) {
                            $reduced_pw = "";
                        } else {
                            $reduced_pw = substr($pw, $_SESSION['prefix_length']);
                        }
                        $pw = str_replace(array('"', "\\'"), array("&quot;", "&escapesq;"), $pw);
                        $reduced_pw = str_replace(array('"', "\\'"), array("&quot;", "&escapesq;"), $reduced_pw);
                        if ($rowColor == true) {
                            $ret .= "<tr class='alt'><td><input class='pw_cb' type='checkbox' id='" . $record['id'] . "'></td><td id='old_" . $record['id'] . "'>" . $pw . "</td><td> -> </td><td id='new_" . $record['id'] . "'>" . $reduced_pw . "</td><td id='res_" . $record['id'] . "'></td></tr>";
                            $rowColor = false;
                        } else {
function _utf8_decode($string)
{
  	$string= html_entity_decode($string);
  	$tmp = $string;
	$count = 0;
	while (isutf8($tmp))
  	{
  		$tmp = utf8_decode($tmp);
		$count++;
	}

  	for ($i = 0; $i < $count-1 ; $i++)
  	{
    		$string = utf8_decode($string);
  	}
  	return $string;
}