public static function SetVisitorEntropyIDCookie() { //-- if (!defined('SMART_FRAMEWORK_VERSION')) { die('Smart Runtime // Set Visitor Entropy ID Cookie :: Requires SmartFramework to be loaded ...'); } //end if //-- if (defined('SMART_APP_VISITOR_COOKIE')) { die('SetVisitorEntropyIDCookie :: SMART_APP_VISITOR_COOKIE must not be re-defined ...'); } //end if //-- $cookie = ''; //-- {{{SYNC-SMART-UNIQUE-COOKIE}}} if (defined('SMART_FRAMEWORK_UNIQUE_ID_COOKIE_NAME') and !defined('SMART_FRAMEWORK_UNIQUE_ID_COOKIE_SKIP')) { if ((string) SMART_FRAMEWORK_UNIQUE_ID_COOKIE_NAME != '') { if (SmartFrameworkSecurity::ValidateVariableName(strtolower((string) SMART_FRAMEWORK_UNIQUE_ID_COOKIE_NAME))) { //-- $cookie = (string) trim(strtolower(SmartFrameworkSecurity::FilterUnsafeString((string) $_COOKIE[(string) SMART_FRAMEWORK_UNIQUE_ID_COOKIE_NAME]))); if ((string) $cookie == '' or strlen((string) $cookie) != 40 or !preg_match('/^[a-f0-9]+$/', (string) $cookie)) { $entropy = (string) sha1((string) Smart::unique_entropy('uuid-cookie')); // generate a random unique key ; cookie was not yet set or is invalid if (defined('SMART_FRAMEWORK_UNIQUE_ID_COOKIE_DOMAIN') and (string) SMART_FRAMEWORK_UNIQUE_ID_COOKIE_DOMAIN != '') { @setcookie((string) SMART_FRAMEWORK_UNIQUE_ID_COOKIE_NAME, (string) $entropy, 0, '/', (string) SMART_FRAMEWORK_UNIQUE_ID_COOKIE_DOMAIN); // set it using domain } else { @setcookie((string) SMART_FRAMEWORK_UNIQUE_ID_COOKIE_NAME, (string) $entropy, 0, '/'); // set it } //end if else $cookie = (string) $entropy; } //end if //-- } //end if } //end if } //end if //-- #end# sync define('SMART_APP_VISITOR_COOKIE', (string) $cookie); // empty or cookie ID //-- }
private function build_multipart() { //-- $timeduid = Smart::uuid_10_seq(); // 10 chars, timed based, can repeat only once in 1000 years for the same millisecond $timedrid = strrev($timeduid); $entropy = Smart::unique_entropy('mail/send'); // this generate a very random value $boundary = '_===-Mime.Part____.' . $timeduid . '_' . md5('@MimePart---#Boundary@' . $entropy) . '_P_.-=_'; // 69 chars of 70 max $relatedboundary = '_-==-Mime.Related_.' . $timedrid . '_' . md5('@MimeRelated#Boundary@' . $entropy) . '_R_.=-_'; // 69 chars of 70 max //-- $multipart = ''; $multipart .= 'Content-Type: multipart/mixed; boundary="' . $boundary . '"' . "\r\n" . "\r\n"; $multipart .= 'This is a multi-part message in MIME format.' . "\r\n" . "\r\n"; $multipart .= '--' . $boundary . "\r\n"; $multipart .= 'Content-Type: multipart/related; boundary="' . $relatedboundary . '"' . "\r\n"; //-- cid parts $multipart .= "\r\n"; for ($i = Smart::array_size($this->parts) - 1; $i >= 0; $i--) { $multipart .= '--' . $relatedboundary . "\r\n"; $multipart .= $this->build_message($this->parts[$i]); } //end for $multipart .= "\r\n"; $multipart .= '--' . $relatedboundary . '--' . "\r\n"; //-- attachments $multipart .= "\r\n"; for ($i = Smart::array_size($this->atts) - 1; $i >= 0; $i--) { $multipart .= '--' . $boundary . "\r\n"; $multipart .= $this->build_message($this->atts[$i]); } //end for //-- $multipart .= "\r\n"; $multipart .= '--' . $boundary . '--' . "\r\n"; //-- return $multipart; //-- }
public function login($username, $pass, $mode = '') { // IMAP4 //-- $this->tag = 'smart' . strtoupper(md5(Smart::unique_entropy('imapv4'))) . 'framework'; $this->username = (string) $username; //-- if ($this->debug) { $this->log .= '[INF] Login to Mail Server (USER = '******')' . "\n"; } //end if //-- if (strlen($this->error) > 0) { return 0; } //end if //-- normal login if ($this->debug) { $this->log .= '[INF] Login Method: Normal' . "\n"; } //end if //-- $reply = $this->send_cmd('LOGIN ' . $username . ' ' . $pass); if (strlen($this->error) > 0) { return 0; } //end if //-- $test = $this->is_ok($reply); if ((string) $test != 'ok') { $this->error = '[ERR] IMAP4 User or Password Failed [' . $reply . ']'; return 0; } //end if //-- return 1; //-- }
private function _generate_iv() { // Initialize pseudo random generator // seed rand: (double)microtime()*1000000 // no more needed // Collect very random data. // Add as many "pseudo" random sources as you can find. // Possible sources: Memory usage, diskusage, file and directory content... $iv = Smart::random_number(); $iv .= Smart::unique_entropy(); $iv .= SmartUtils::get_visitor_tracking_uid(); $iv .= implode("\r", (array) $_SERVER); $iv .= implode("\r", (array) $_COOKIES); return $this->_hash($iv); }