function setaCookieSessao() { global $SESSID, $expired_date, $chave_cookie_sessao; //setcookie("CookieTeste", $value); //setcookie("CookieTeste", $value, time()+3600); /* expira em 1 hora */ //setcookie("CookieTeste", $value, time()+3600, "/~rasmus/", ".example.com", 1); setcookie($chave_cookie_sessao, encryptString($SESSID), time() + $expired_date * 3600, "/"); }
function local_encryptQueryReplace($matches) { $parsedUrl = parse_url($matches[0]); //Convert only internal links if (stristr($parsedUrl['path'], 'http') === false || stristr('http://' . $parsedUrl['path'], G_SERVERNAME) !== false || stristr('https://' . $parsedUrl['path'], G_SERVERNAME) !== false) { $matches[2] = 'cru=' . encryptString($matches[2]); } return $matches[1] . $matches[2] . $matches[3]; }
public function update($fields = array()) { if (!count($fields)) { show_error('Invalid update parameters.'); } if (!empty($fields['permission_group']) && $fields['permission_group'] == 'administrator' && $this->authentication->get('permission_group') != 'administrator') { show_error('You are not allowed to edit or create Administrator users. If you feel you have reached this page in error please contact the website administrator.'); } if (!empty($fields['password_new']) && !empty($fields['password_confirm'])) { // Passwords Match? if ($fields['password_new'] != $fields['password_confirm']) { show_error('New password does not match confirmation.'); } // New Password Length if (strlen($fields['password_new']) < $this->ADMIN_CONF['login']['req_password_len']) { show_error('Password must be ' . $this->ADMIN_CONF['login']['req_password_len'] . ' characters or longer.'); } $fields['password'] = encryptString($fields['password_new']); $fields['password_options'] = $this->_setPasswordOptions($fields); } return parent::update($fields); }
function _login($username, $password) { if (is_null($username) || is_null($password)) { return FALSE; } if ($this->isInitial()) { // Encrypt password if this is a login request, it will already be encrypted if session val $password = encryptString($password); $this->_checkLoginFails(); } if ($login = CI()->user_model->authenticate($username, $password)) { // Found user row, but make sure everything is ok now... // Check if the user is enabled. Need to do it here for a nicer error message $this->_checkInactiveLogin($login); if ($this->isInitial()) { // Has user been active in past 90 days $this->_checkExpiredLogin($login); // Has password expired ? } // User login successful, sweet! CI()->session->set_userdata('username', $username); CI()->session->set_userdata('password', $password); $this->_user = $login; // Set user options if (!empty($this->_user['options']['display_profiler']) && $this->_user['options']['display_profiler'] > 0) { CI()->output->enable_profiler(TRUE); } // Everything's good, let's get out of here return TRUE; } else { // Failed login attempt // Update tracking table with information $this->_addLoginFail($username); } return FALSE; }
//----------------------------------------------------------------------------------- //------------------------------------------------------------------------------------ function encryptString($strString, $strPassword) { // $strString is the content of the entire file with serials echo "strString: " . $strString . "<br/>"; echo "strPassword: "******"<br/>"; //$strPasswordMD5 = md5($strPassword); $strPasswordMD5 = '00000000000000000000000000000000'; echo "strPasswordMD5: " . $strPasswordMD5 . "<br/>"; $intMD5Total = evalCrossTotal($strPasswordMD5); echo "intMD5Total: " . $intMD5Total . "<br/>"; $arrEncryptedValues = array(); $intStrlen = strlen($strString); echo "intStrlen: " . $intStrlen . "<br/>"; for ($i = 0; $i < $intStrlen; $i++) { echo "i: " . $i . "<br/>"; $arrEncryptedValues[] = ord(substr($strString, $i, 1)) + ('0x0' . substr($strPasswordMD5, $i % 32, 1)) - $intMD5Total; echo "ord: " . ord(substr($strString, $i, 1)) . "<br/>"; echo "substr(strPasswordMD5: " . ('0x0' . substr($strPasswordMD5, $i % 32, 1)) . "<br/>"; echo "intMD5Total: " . $intMD5Total . "<br/>"; $temp = ord(substr($strString, $i, 1)) + ('0x0' . substr($strPasswordMD5, $i % 32, 1)) - $intMD5Total; echo "temp: " . $temp . "<br/>"; $intMD5Total = evalCrossTotal(substr(md5(substr($strString, 0, $i + 1)), 0, 16) . substr(md5($intMD5Total), 0, 16)); echo "newintMD5Total: " . $intMD5Total . "<br/><br/>"; } return implode(' ', $arrEncryptedValues); } //----------------------------------------------------------------------------------- echo "working :" . encryptString("", ""); echo "<br/>Bye <br/>";
$intMD5Total = evalCrossTotal($strPasswordMD5); //echo $intMD5Total."\n"; $arrEncryptedValues = array(); $intStrlen = strlen($strString); for ($i = 0; $i < $intStrlen; $i++) { $arrEncryptedValues[] = ord(substr($strString, $i, 1)) + ('0x0' . substr($strPasswordMD5, $i % 32, 1)) - $intMD5Total; $intMD5Total = evalCrossTotal(substr(md5(substr($strString, 0, $i + 1)), 0, 16) . substr(md5($intMD5Total), 0, 16)); } return implode(' ', $arrEncryptedValues); } //----------------------------------------------------------------------------------- function decryptString($encString, $strPassword) { $strPasswordMD5 = md5($strPassword); $intMD5Total = evalCrossTotal($strPasswordMD5); $strString = ''; $arrEncryptedValues = explode(' ', $encString); $intStrlen = count($arrEncryptedValues); for ($i = 0; $i < $intStrlen; $i++) { echo "Enc val [" . $i . "]:" . $arrEncryptedValues[$i] . "\n"; $strString .= chr(intval($arrEncryptedValues[$i]) - ('0x0' . substr($strPasswordMD5, $i % 32, 1)) + $intMD5Total); //$strString .= chr('0x0'. substr($strPasswordMD5, $i%32, 1)) // ord <=> chr (ord gets decimal for ascii, chr returns ascii for decimal) // implode explode (convert to integer with intval) $intMD5Total = evalCrossTotal(substr(md5(substr($strString, 0, $i + 1)), 0, 16) . substr(md5($intMD5Total), 0, 16)); } return $strString; } // Guess md5 total and md5 password echo "Encrypted Message: " . encryptString('hello', 'password') . "\n"; echo "Decrypted Message: " . decryptString('-163 -73 -167 -112 -31', 'password') . "\n";
var g_player_count = 3; var g_playerset_name = "PlaySet2"; var g_conference_name = "MM会议"; var channels = new Array(); channels[1] = '<?php echo encryptString("dbc0f004854457f59fb16ab863a3a1722cef553f", $macid); ?> '; channels[2] = '<?php echo encryptString("c8306ae139ac98f432932286151dc0ec55580eca", $macid); ?> '; channels[3] = '<?php echo encryptString("934385f53d1bd0c1b8493e44d0dfd4c8e88a04bb", $macid); ?> '; var m_Gobals=new Array(); var m_pause=new Array(); for (var i = 1; i <= g_player_count; i++) { m_pause[i] = false; } function onLoadLayout() { try {
public function resetPassword($fields = null, $user = null) { if (is_null($fields)) { show_error('Invalid change password request.'); } if (!empty($fields['user'])) { $user_fields = array('user' => $fields['user']); } else { if (!empty($fields['email'])) { $user_fields = array('email' => $fields['email']); } else { return FALSE; } } // Get user $user = $this->selectSet('password')->get($user_fields); // Make sure a valid user with email address if (empty($user[0][$this->id_field])) { return FALSE; } if (empty($user[0]['email'])) { $this->layout->setMessage('Can not reset your password, you do not have an email address supplied. Please contact your system administrator to perform this action.', 'page', 'error'); return FALSE; } CI()->activity->log($this->table, $user[0][$this->id_field], 'Password reset'); $new_pass = random_string(); $update_fields = array('user_id' => $user[0][$this->id_field], 'password' => encryptString($new_pass, $user[0][$this->id_field]), 'password_options' => $user[0]['password_options']); $this->update($update_fields); // Send notification email CI()->load->library('email'); CI()->email->from(CI()->ADMIN_CONF['forgot_pw_email']['from_email'], CI()->ADMIN_CONF['forgot_pw_email']['from_name']); CI()->email->to($user[0]['email']); CI()->email->subject(CI()->ADMIN_CONF['forgot_pw_email']['subject']); CI()->email->message(CI()->ADMIN_CONF['forgot_pw_email']['message'] . $new_pass); CI()->email->send(); return true; }
/** * Redirect to another page * * This function implements either server-side (php) or client side (javascript) redirection * <br/>Example: * <code> * </code> * * @param string $url The url to redirect to. If 'self' is used, it is equivalent to a reload (only it isn't) * @param boolean $js Whether to use js-based redirection * @param string $target which frame to reload (only applicable when $js is true). Can be 'top', 'window' or any frame name * @param boolean $retainUrl Whether to retain the url as it is * @since 3.6.0 */ function eF_redirect($url, $js = false, $target = 'top', $retainUrl = false) { if (!$retainUrl) { $parts = parse_url($url); if (isset($parts['query']) && $parts['query']) { if ($GLOBALS['configuration']['encrypt_url']) { $parts['query'] = 'cru=' . encryptString($parts['query']); } elseif (isset($_SESSION['s_login'])) { $query = explode("&", $parts['query']); foreach ($query as $key => $value) { $queryParts = explode("=", $value); if ($queryParts[0] == 'message') { $_SESSION['s_message'] = $queryParts[1]; unset($query[$key]); } elseif ($queryParts[0] == 'message_type') { $_SESSION['s_message_type'] = $queryParts[1]; unset($query[$key]); } } $parts['query'] = implode("&", $query); } $parts['query'] = '?' . $parts['query']; } else { $parts['query'] = ''; } if ($parts['fragment'] == "") { $url = G_SERVERNAME . basename($parts['path']) . $parts['query']; } else { $url = G_SERVERNAME . basename($parts['path']) . $parts['query'] . '#' . $parts['fragment']; } } session_write_close(); if ($js) { echo "<script language='JavaScript'>{$target}.location='{$url}'</script>"; } else { header("location:{$url}"); } exit; }
<?php /** * Encrypts a string using $shift Caesar Cipher * @param string $string The string that will be encrypted * @param string $shift the amount of characters shifted * @return The encrypted string */ function encryptString($string, $shift) { for ($i = 0; $i < strlen($string); $i++) { $string[$i] = chr(ord($string[$i]) + $shift); } return $string . PHP_EOL; } $plates = file('php://stdin'); print_r($plates); for ($i = 0; $i < count($plates); $i++) { echo encryptString($plates[$i], 3); }
/** * Redirect to another page * * This function implements either server-side (php) or client side (javascript) redirection * <br/>Example: * <code> * </code> * * @param string $url The url to redirect to. If 'self' is used, it is equivalent to a reload (only it isn't) * @param boolean $js Whether to use js-based redirection * @param string $target which frame to reload (only applicable when $js is true). Can be 'top', 'window' or any frame name * @param boolean $retainUrl Whether to retain the url as it is * @since 3.6.0 */ function eF_redirect($url, $js = false, $target = 'top', $retainUrl = false, $message_by_get = false) { if (!$retainUrl) { $parts = parse_url($url); if (isset($parts['query']) && $parts['query']) { if ($GLOBALS['configuration']['encrypt_url']) { $parts['query'] = 'cru=' . encryptString($parts['query']); } elseif (isset($_SESSION['s_login'])) { $query = explode("&", $parts['query']); foreach ($query as $key => $value) { $queryParts = explode("=", $value); if ($queryParts[0] == 'message') { $_SESSION['s_message'] = $queryParts[1]; unset($query[$key]); } elseif ($queryParts[0] == 'message_type') { $_SESSION['s_message_type'] = $queryParts[1]; unset($query[$key]); } } $parts['query'] = implode("&", $query); } $parts['query'] = '?' . $parts['query']; } else { $parts['query'] = ''; } // Added $message_by_get because IE seems to lose $_SESSION['s_message'] after redirect from popup iframe (module_documents_exchange $message = _MODULE_DOCUMENTS_EXCHANGE_FILELOCKED) if ($_SESSION['s_message'] && $message_by_get) { if ($parts['query'] == '') { $parts['query'] = '?message=' . $_SESSION['s_message']; unset($_SESSION['s_message']); } else { $parts['query'] = $parts['query'] . '&message=' . $_SESSION['s_message']; unset($_SESSION['s_message']); } } if ($parts['fragment'] == "") { $url = G_SERVERNAME . basename($parts['path']) . $parts['query']; } else { $url = G_SERVERNAME . basename($parts['path']) . $parts['query'] . '#' . $parts['fragment']; } } session_write_close(); if ($js) { echo "<script language='JavaScript'>{$target}.location='{$url}'</script>"; } else { header("location:{$url}"); } exit; }