Beispiel #1
0
 function Execute($Params)
 {
     $pki = new JpkiCorePlugin($this->App);
     $Params['id'] = array(19, 20);
     if (isset($Params['id']) && is_array($Params['id'])) {
         $ID = $Params['id'];
     } else {
         $out['Error'][] = "Supply 'id' array please.";
     }
     if (isset($Params['content'])) {
         $Data = $Params['content'];
     } else {
         $out['Error'][] = "Supply 'content' please.";
     }
     if (is_array($ID)) {
         foreach ($ID as $i) {
             $Res = j::SQL("SELECT X509 FROM jpki_certificates WHERE ID=?", $i);
             if ($Res) {
                 $PKs[] = $pki->X509_ExtractPublicKey($Res[0]['X509']);
             }
         }
         $Res = $pki->SealData($Data, $PKs);
         $out['SealedResult'] = $Res;
     }
     return $out;
 }
Beispiel #2
0
 function Execute($Params)
 {
     $pki = new JpkiCorePlugin($this->App);
     if (isset($Params['id'])) {
         $ID = $Params['id'];
     } else {
         $out['Error'][] = "Supply 'id' please.";
     }
     if (isset($Params['content'])) {
         $Data = $Params['content'];
     } else {
         $out['Error'][] = "Supply 'content' please.";
     }
     if (isset($Params['signature'])) {
         $Signature = $Params['signature'];
     } else {
         $out['Error'][] = "Supply 'signature' please.";
     }
     $Res = j::SQL("SELECT X509 FROM jpki_certificates WHERE ID=?", $ID);
     if ($Res) {
         $PublicKey = $pki->X509_ExtractPublicKey($Res[0]['X509']);
         $Res = $pki->VerifyDataSignature($Data, $Signature, $PublicKey);
     } else {
         $Res['Error'] = 'X509 Not Found with spplied id.';
     }
     $out['Verification'] = $Res;
     return $out;
 }
Beispiel #3
0
 function Execute($Params)
 {
     $pki = new JpkiCorePlugin($this->App);
     if (isset($Params['id'])) {
         $ID = $Params['id'];
     } else {
         $out['Error'][] = "Supply 'id' please.";
     }
     if (isset($Params['content'])) {
         $Data = $Params['content'];
     } else {
         $out['Error'][] = "Supply 'content' please.";
     }
     if (isset($Params['envelopekey'])) {
         $EnvelopeKey = $Params['envelopekey'];
     } else {
         $out['Error'][] = "Supply 'envelopekey' please.";
     }
     $Res = j::SQL("SELECT PrivateKey FROM jpki_certificates WHERE ID=?", $ID);
     if ($Res) {
         $Res = $pki->UnsealData($Data, $EnvelopeKey, $Res[0]['PrivateKey']);
     } else {
         $Res['Error'] = "X509 not found with spplied id.";
     }
     $out['UnsealedResult'] = $Res;
     return $out;
 }
Beispiel #4
0
 function Execute($Params)
 {
     $pki = new JpkiCorePlugin($this->App);
     if (isset($Params['id'])) {
         $ID = $Params['id'];
     } else {
         $out['Error'][] = "Supply 'id' please.";
     }
     $Res = j::SQL("SELECT X509 FROM jpki_certificates WHERE ID=?", $ID);
     if ($Res) {
         $Res = $pki->X509_Details($Res[0]['X509'], false);
     } else {
         $Res['Error'] = 'X509 Not Found.';
     }
     $out['Result'] = $Res;
     return $out;
 }
Beispiel #5
0
 function Execute($Params)
 {
     $pki = new JpkiCorePlugin($this->App);
     if (isset($Params['id'])) {
         $ID = $Params['id'];
     } else {
         $out['Error'][] = "Supply 'id' please.";
     }
     if (isset($Params['content'])) {
         $Data = $Params['content'];
     } else {
         $out['Error'][] = "Supply 'content' please.";
     }
     $Res = j::SQL("SELECT PrivateKey FROM jpki_certificates WHERE ID=?", $ID);
     if ($Res) {
         $Res = $pki->Encrypt_Private($Data, $Res[0]['PrivateKey']);
     } else {
         $Res['Error'] = 'PrivateKey Not Found with spplied id.';
     }
     $out['EncryptedData'] = $Res;
     return $out;
 }
Beispiel #6
0
 /**
  * 
  * Automatically retrieves the data from the table and sets data
  * @param string $Table
  */
 function SetTable($Table)
 {
     $Query = "SELECT ";
     $fields = array();
     foreach ($this->HeaderArray as $k => $h) {
         $fields[] = $k;
     }
     $Query .= implode(",", $fields);
     $Query .= " FROM {$Table} ";
     if ($this->Sort) {
         $Query .= " ORDER BY {$this->Sort} {$this->Order} ";
     }
     if ($this->Offset) {
         $Query .= " LIMIT {$this->Offset},{$this->Limit}";
     } elseif ($this->Limit) {
         $Query .= " LIMIT {$this->Limit}";
     }
     $r = j::SQL($Query);
     $this->SetData($r);
     $this->Table = $Table;
 }
Beispiel #7
0
<style>
* {
font-size:small;
}
</style>
<table border='1' width='100%' cellpadding='2' cellspacing='0' >
<tr>
<td colspan='4'>
<?php 
$Op = j::SQL("SELECT * FROM jf_options");
if ($Op) {
    foreach ($Op as &$o) {
        $o['Value'] = unserialize($o['Value']);
    }
}
echo nl2br(str_replace(" ", "&nbsp;", htmlspecialchars(print_r($Op, true))));
?>

</td>
</tr>
</table>
Beispiel #8
0
 /**
  * Disconnects a phrase from its pivot. 
  * One of them should be in Pivot
  * @param $Phrase1 or ID1
  * @param $Language1 or ID2
  * @param $Phrase2
  * @param $Language2
  */
 function Unlink($Phrase1, $Language1, $Phrase2 = null, $Language2 = null)
 {
     if ($Phrase2 !== null) {
         $Phrase1 = $this->PhraseID($Phrase1, $Language1);
         $Language1 = $this->PhraseID($Phrase2, $Language2);
     }
     $ID1 = $Phrase1;
     $ID2 = $Language1;
     j::SQL("DELETE FROM jfp_i18n_graph WHERE ID1=? AND ID2=? LIMIT 1", $ID1, $ID2);
     return j::$DB->AffectedRows();
 }
Beispiel #9
0
 /**
     Edits a user credentials
     @param String $OldUsername
     @param String $NewUsername
     @param String $NewPassword leave null to not change
     @return null on old user doesn't exist, false on new user already exists,  true on success.
 */
 function EditUser($OldUsername, $NewUsername, $NewPassword = null)
 {
     if (!$this->UserExists($OldUsername)) {
         return null;
     }
     if ($OldUsername != $NewUsername and $this->UserExists($NewUsername)) {
         return false;
     }
     if ($NewPassword) {
         $HashedPass = new Password($NewUsername, $NewPassword);
         j::SQL("UPDATE {$this->TablePrefix()}users SET Username=?, Password=?, Salt=?, Protocol=? WHERE LOWER(Username)=LOWER(?)", $NewUsername, $HashedPass->Password(), $HashedPass->Salt(), $HashedPass->Protocol(), $OldUsername);
     } else {
         j::SQL("UPDATE {$this->TablePrefix()}users SET Username=? WHERE LOWER(Username)=LOWER(?)", $NewUsername, $OldUsername);
     }
     return true;
 }
Beispiel #10
0
<!-- Critical Logs -->
<tr>
<td colspan='4'><h2><?php 
tr("Critical Logs");
?>
</h2></td>
<td colspan='4'>


</td>
</tr>
<tr>
<td colspan='8'>
<?php 
$Logs = j::SQL("SELECT * FROM `" . reg("jf/log/table/name") . "` WHERE `" . reg("jf/log/table/Severity") . "`>=5 ORDER BY `" . reg("jf/log/table/Timestamp") . "` DESC LIMIT 50");
if (is_array($Logs)) {
    $n = 0;
    foreach ($Logs as $L) {
        echo "<strong>" . ++$n . ". " . $L['Subject'] . " (" . $L['Severity'] . ")</strong> " . $L['Data'] . " <i>(" . date("Y-m-d H:i:s", $L['Timestamp']) . ")</i>" . BR;
    }
    ?>
<form action='../logs/view' onsubmit='return confirm("Are you sure?");' method='post'>
<input type='hidden' name='DelSeverity' value='7' />
<input type='submit' value='Clear All Logs' />
</form>
<?php 
}
?>
</td>
</tr>