public function setData($data) { if (!$data instanceof \Maslosoft\Mangan\DataProvider) { throw new InvalidArgumentException(spritnf('Parameter `$data` must be of type %s, but %s given', \Maslosoft\Mangan\DataProvider::$CLS, @get_class($data))); } foreach ($data->data as $group) { $this->_groups[] = $group; } }
* file that was distributed with this source code. * * * @author Gassan Idriss <*****@*****.**> */ require_once dirname(__FILE__) . '/functions.php'; if (!isset($argv[1]) || !isset($argv[2])) { print_line(PHP_EOL . 'Usage:'); print_line("\t" . 'php ' . $_SERVER['SCRIPT_NAME'] . ' /path/to/fragment.xml ClassName [/out/dir]'); print_line("\t" . 'php ' . $_SERVER['SCRIPT_NAME'] . ' "<XML></XML>" ClassName [/out/dir]', true); } $sourceXml = $argv[1]; $targetClass = $argv[2]; $targetDir = isset($argv[3]) && is_dir($argv[3]) ? $argv[3] : dirname(__FILE__); if (!is_dir($targetDir)) { print_line(spritnf('Dir %s Not Found', $targetDir), true); } if (file_exists($sourceXml)) { $xml = new \SimpleXMLElement(file_get_contents($sourceXml)); } else { $xml = new \SimpleXMLElement($sourceXml); } $setters = ''; $assertions = ''; foreach ($xml->children() as $child) { print_line($child->getName()); $name = $child->getName(); $camelName = $name; $camelName[0] = strtolower($camelName[0]); $setters .= generate_setter($name, $camelName); $assertions .= generate_assertion($name, $camelName);
/** * Internal function don't use. */ function core_get_jq_alert_message($message) { return spritnf("alert('%s');", $message); }
/** * Hashes a password and returns the hash based on the specified enc_type. * * @param string The password to hash in clear text. * @param string Standard LDAP encryption type which must be one of * crypt, ext_des, md5crypt, blowfish, md5, sha, smd5, ssha, or clear. * @return string The hashed password. */ function password_hash($password_clear, $enc_type) { if (DEBUG_ENABLED && (($fargs = func_get_args()) || ($fargs = 'NOARGS'))) { debug_log('Entered (%%)', 1, 0, __FILE__, __LINE__, __METHOD__, $fargs); } $enc_type = strtolower($enc_type); switch ($enc_type) { case 'crypt': if ($_SESSION[APPCONFIG]->getValue('password', 'no_random_crypt_salt')) { $new_value = sprintf('{CRYPT}%s', crypt($password_clear, substr($password_clear, 0, 2))); } else { $new_value = sprintf('{CRYPT}%s', crypt($password_clear, random_salt(2))); } break; case 'ext_des': # Extended des crypt. see OpenBSD crypt man page. if (!defined('CRYPT_EXT_DES') || CRYPT_EXT_DES == 0) { error(_('Your system crypt library does not support extended DES encryption.'), 'error', 'index.php'); } $new_value = sprintf('{CRYPT}%s', crypt($password_clear, '_' . random_salt(8))); break; case 'md5crypt': if (!defined('CRYPT_MD5') || CRYPT_MD5 == 0) { error(_('Your system crypt library does not support md5crypt encryption.'), 'error', 'index.php'); } $new_value = sprintf('{CRYPT}%s', crypt($password_clear, '$1$' . random_salt(9))); break; case 'blowfish': if (!defined('CRYPT_BLOWFISH') || CRYPT_BLOWFISH == 0) { error(_('Your system crypt library does not support blowfish encryption.'), 'error', 'index.php'); } # Hardcoded to second blowfish version and set number of rounds $new_value = sprintf('{CRYPT}%s', crypt($password_clear, '$2a$12$' . random_salt(13))); break; case 'md5': $new_value = sprintf('{MD5}%s', base64_encode(pack('H*', md5($password_clear)))); break; case 'sha': # Use php 4.3.0+ sha1 function, if it is available. if (function_exists('sha1')) { $new_value = sprintf('{SHA}%s', base64_encode(pack('H*', sha1($password_clear)))); } elseif (function_exists('mhash')) { $new_value = sprintf('{SHA}%s', base64_encode(mhash(MHASH_SHA1, $password_clear))); } else { error(_('Your PHP install does not have the mhash() function. Cannot do SHA hashes.'), 'error', 'index.php'); } break; case 'ssha': if (function_exists('mhash') && function_exists('mhash_keygen_s2k')) { mt_srand((double) microtime() * 1000000); $salt = mhash_keygen_s2k(MHASH_SHA1, $password_clear, substr(pack('h*', md5(mt_rand())), 0, 8), 4); $new_value = sprintf('{SSHA}%s', base64_encode(mhash(MHASH_SHA1, $password_clear . $salt) . $salt)); } else { error(_('Your PHP install does not have the mhash() or mhash_keygen_s2k() function. Cannot do S2K hashes.'), 'error', 'index.php'); } break; case 'smd5': if (function_exists('mhash') && function_exists('mhash_keygen_s2k')) { mt_srand((double) microtime() * 1000000); $salt = mhash_keygen_s2k(MHASH_MD5, $password_clear, substr(pack('h*', md5(mt_rand())), 0, 8), 4); $new_value = spritnf('{SMD5}%s', base64_encode(mhash(MHASH_MD5, $password_clear . $salt) . $salt)); } else { error(_('Your PHP install does not have the mhash() or mhash_keygen_s2k() function. Cannot do S2K hashes.'), 'error', 'index.php'); } break; case 'clear': default: $new_value = $password_clear; } return $new_value; }