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; }
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; }
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; }
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; }
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; }
/** * This is registered as a PHP shutdown function. It checks if a fatal error is occured, and if so * logs and outputs it. */ function ShutdownFunction() { //check to see if shutdown function runned because of error or naturally $isError = false; $error = error_get_last(); if ($error) { switch ($error['type']) { case E_ERROR: case E_CORE_ERROR: case E_PARSE: case E_COMPILE_ERROR: case E_USER_ERROR: // case E_NOTICE: // default: $isError = true; break; } } if ($isError) { $this->Shutdown = true; $this->PresentError($error['type'], $error['message'], $error['file'], $error['line']); echo "<h1>Fatal Error</h1>\n<p>Some fatal error caused the application to quit unexpectedly. The error details have been successfully \nlogged for the system administrator to review them later.\nWe're sorry for the inconvenience.</p>\n"; if (j::$Log) { j::Log("ShutdownError", "Error type " . $error['type'] . " : " . $error['message'] . " (" . $error['file'] . " at " . $error['line'] . ")", 5); } exit(1); } }
/** * * 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; }
<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(" ", " ", htmlspecialchars(print_r($Op, true)))); ?> </td> </tr> </table>
/** * Calls a web service on any URL * Uses constant("SERVICES_INTERMEDIATE_ENCODING") for wrapping, which is SOAP by default * * @param String $Endpoint WSDL * @param string $Method name * @param Array $Params * @return Mixed */ function CallSoap($Endpoint, $Method, $Params, $isWSDL = false, $Session = false) { j::$App->LoadSystemModule("plugin.nusoap.nusoap"); $soap = new nusoap_client($Endpoint, $isWSDL); $CookiePath = $this->Hostname($Endpoint) . "_cookies"; if ($Session) { $soap->UpdateCookies(j::LoadSession($CookiePath)); } $Result = $soap->call($Method, $Params); if ($Session) { j::SaveSession($CookiePath, $soap->getCookies()); } return $Result; }
/** * 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(); }
public function getAllUsersBelow100() { $r = j::DQL("SELECT COUNT(U) AS Result FROM MyUser AS U"); return $r[0]['Result']; }
static function CheckInput($Value, $Title = "temp") { $X = j::LoadSession("CAPTCHA_{$Title}"); j::DeleteSession("CAPTCHA_{$Title}"); return $X === $Value; }
/** 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; }
<?php if (\jf\HttpRequest::File() == "sys/login" or \jf\HttpRequest::File() == "sys/logout") { return; } if (!j::UserID()) { header("location: " . SiteRoot . "/sys/login?return=/{\\jf\\HttpRequest::File()}"); } else { if (!j::$RBAC->Check("panel")) { j::$RBAC->Enforce("root"); } }
static function Delete($Object) { j::ORM()->remove($Object); }
<!-- 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>