本文整理汇总了PHP中G::encryptCrc32方法的典型用法代码示例。如果您正苦于以下问题:PHP G::encryptCrc32方法的具体用法?PHP G::encryptCrc32怎么用?PHP G::encryptCrc32使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类G
的用法示例。
在下文中一共展示了G::encryptCrc32方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create_zip
/**
* This function is used to create archives .
* zip
*
* @return boolean
*/
public function create_zip()
{
$files = 0;
$offset = 0;
$central = "";
if (!empty($this->options['sfx'])) {
if ($fp = @fopen($this->options['sfx'], "rb")) {
$temp = fread($fp, filesize($this->options['sfx']));
fclose($fp);
$this->add_data($temp);
$offset += strlen($temp);
unset($temp);
} else {
$this->error[] = "Could not open sfx module from {$this->options['sfx']}.";
}
}
$pwd = getcwd();
chdir($this->options['basedir']);
foreach ($this->files as $current) {
if ($current['name'] == $this->options['name']) {
continue;
}
$timedate = explode(" ", date("Y n j G i s", $current['stat'][9]));
$timedate = $timedate[0] - 1980 << 25 | $timedate[1] << 21 | $timedate[2] << 16 | $timedate[3] << 11 | $timedate[4] << 5 | $timedate[5];
$block = pack("VvvvV", 0x4034b50, 0xa, 0x0, isset($current['method']) || $this->options['method'] == 0 ? 0x0 : 0x8, $timedate);
if ($current['stat'][7] == 0 && $current['type'] == 5) {
$block .= pack("VVVvv", 0x0, 0x0, 0x0, strlen($current['name2']) + 1, 0x0);
$block .= $current['name2'] . "/";
$this->add_data($block);
$central .= pack("VvvvvVVVVvvvvvVV", 0x2014b50, 0x14, $this->options['method'] == 0 ? 0x0 : 0xa, 0x0, isset($current['method']) || $this->options['method'] == 0 ? 0x0 : 0x8, $timedate, 0x0, 0x0, 0x0, strlen($current['name2']) + 1, 0x0, 0x0, 0x0, 0x0, $current['type'] == 5 ? 0x10 : 0x0, $offset);
$central .= $current['name2'] . "/";
$files++;
$offset += 31 + strlen($current['name2']);
} elseif ($current['stat'][7] == 0) {
$block .= pack("VVVvv", 0x0, 0x0, 0x0, strlen($current['name2']), 0x0);
$block .= $current['name2'];
$this->add_data($block);
$central .= pack("VvvvvVVVVvvvvvVV", 0x2014b50, 0x14, $this->options['method'] == 0 ? 0x0 : 0xa, 0x0, isset($current['method']) || $this->options['method'] == 0 ? 0x0 : 0x8, $timedate, 0x0, 0x0, 0x0, strlen($current['name2']), 0x0, 0x0, 0x0, 0x0, $current['type'] == 5 ? 0x10 : 0x0, $offset);
$central .= $current['name2'];
$files++;
$offset += 30 + strlen($current['name2']);
} elseif ($fp = @fopen($current['name'], "rb")) {
$temp = fread($fp, $current['stat'][7]);
fclose($fp);
$crc32 = G::encryptCrc32($temp);
if (!isset($current['method']) && $this->options['method'] == 1) {
$temp = gzcompress($temp, $this->options['level']);
$size = strlen($temp) - 6;
$temp = substr($temp, 2, $size);
} else {
$size = strlen($temp);
}
$block .= pack("VVVvv", $crc32, $size, $current['stat'][7], strlen($current['name2']), 0x0);
$block .= $current['name2'];
$this->add_data($block);
$this->add_data($temp);
unset($temp);
$central .= pack("VvvvvVVVVvvvvvVV", 0x2014b50, 0x14, $this->options['method'] == 0 ? 0x0 : 0xa, 0x0, isset($current['method']) || $this->options['method'] == 0 ? 0x0 : 0x8, $timedate, $crc32, $size, $current['stat'][7], strlen($current['name2']), 0x0, 0x0, 0x0, 0x0, 0x0, $offset);
$central .= $current['name2'];
$files++;
$offset += 30 + strlen($current['name2']) + $size;
} else {
$this->error[] = "Could not open file {$current['name']} for reading. It was not added.";
}
}
$this->add_data($central);
$this->add_data(pack("VvvvvVVv", 0x6054b50, 0x0, 0x0, $files, $files, strlen($central), $offset, !empty($this->options['comment']) ? strlen($this->options['comment']) : 0x0));
if (!empty($this->options['comment'])) {
$this->add_data($this->options['comment']);
}
chdir($pwd);
return 1;
}
示例2: encryptCrc32
public function encryptCrc32($string)
{
if (!class_exists('G')) {
$realdocuroot = str_replace('\\', '/', $_SERVER['DOCUMENT_ROOT']);
$docuroot = explode('/', $realdocuroot);
array_pop($docuroot);
$pathhome = implode('/', $docuroot) . '/';
array_pop($docuroot);
$pathTrunk = implode('/', $docuroot) . '/';
require_once $pathTrunk . 'gulliver/system/class.g.php';
}
return G::encryptCrc32($string);
}
示例3: hashCode
/**
* If the primary key is not <code>null</code>, return the hashcode of the
* primary key. Otherwise calls <code>Object.hashCode()</code>.
*
* @return int Hashcode
*/
public function hashCode()
{
if (!class_exists('G')) {
$realdocuroot = str_replace('\\', '/', $_SERVER['DOCUMENT_ROOT']);
$docuroot = explode('/', $realdocuroot);
array_pop($docuroot);
$pathhome = implode('/', $docuroot) . '/';
array_pop($docuroot);
$pathTrunk = implode('/', $docuroot) . '/';
require_once $pathTrunk . 'gulliver/system/class.g.php';
}
$ok = $this->getPrimaryKey();
if ($ok === null) {
return G::encryptCrc32(serialize($this));
}
return G::encryptCrc32(serialize($ok));
// serialize because it could be an array ("ComboKey")
}
示例4: upgrade
//.........这里部分代码省略.........
@chmod( $targetFileName, 0666 );
}
} else {
//delete unused files
if (file_exists( $targetFileName )) {
@unlink( $targetFileName );
}
}
} else {
if (! file_exists( PATH_TRUNK . $sFilePath )) {
mkdir( PATH_TRUNK . $sFilePath, 0777 );
}
}
} elseif (file_exists( PATH_TRUNK . $sFilePath ) && $sFilePath != 'workflow/engine/gulliver') {
@unlink( PATH_TRUNK . $sFilePath );
}
}
}
//end files copied.
$missedFiles = '';
$distinctFiles = '';
$missed = 0;
$distinct = 0;
//checking files of this installation server with the files in Repository Code.
if ($sCheckListFile != '') {
$fp = fopen( $sCheckListFile, 'r' );
while (! feof( $fp )) {
$line = explode( ' ', fgets( $fp ) );
if (count( $line ) == 3) {
$file = PATH_TRUNK . trim( $line[2] );
if (is_readable( $file )) {
$size = sprintf( "%07d", filesize( $file ) );
$checksum = sprintf( "%010u", G::encryptCrc32( file_get_contents( $file ) ) );
if (! ($line[0] == $size && $line[1] == $checksum) && substr( $file, - 4 ) != '.xml') {
$distinctFiles .= $file . "\n";
$distinct ++;
}
} else {
$missedFiles .= $file . "\n";
$missed ++;
}
}
}
fclose( $fp );
}
if ($missed > 0) {
$aErrors[] = "Warning: there are $missed missed files. ";
}
$aErrors[] = $missedFiles;
if ($distinct > 0) {
$aErrors[] = "Warning: there are $distinct files with differences. ";
$aErrors[] = $distinctFiles;
}
//now include the files and classes needed for upgrade databases, dont move this files, because we
//are getting the last files in this point. Even the files was in the patch we will take the new ones.
include PATH_METHODS . PATH_SEP . 'setup' . PATH_SEP . 'upgrade_RBAC.php';
G::LoadClass( 'languages' );
G::LoadSystem( 'database_mysql' );
$bForceXml = true;
$bParseSchema = true;
$bParseSchemaRBAC = true;
示例5: hashCode
/**
* Returns a hash code value for the object.
*/
public function hashCode()
{
if (!class_exists('G')) {
$realdocuroot = str_replace('\\', '/', $_SERVER['DOCUMENT_ROOT']);
$docuroot = explode('/', $realdocuroot);
array_pop($docuroot);
$pathhome = implode('/', $docuroot) . '/';
array_pop($docuroot);
$pathTrunk = implode('/', $docuroot) . '/';
require_once $pathTrunk . 'gulliver/system/class.g.php';
}
$h = G::encryptCrc32(serialize($this->value)) ^ G::encryptCrc32($this->comparison);
if ($this->table !== null) {
$h ^= G::encryptCrc32($this->table);
}
if ($this->column !== null) {
$h ^= G::encryptCrc32($this->column);
}
foreach ($this->clauses as $clause) {
// TODO: i KNOW there is a php incompatibility with the following line
// but i dont remember what it is, someone care to look it up and
// replace it if it doesnt bother us?
// $clause->appendPsTo($sb='',$params=array());
$sb = '';
$params = array();
$clause->appendPsTo($sb, $params);
$h ^= G::encryptCrc32(serialize(array($sb, $params)));
unset($sb, $params);
}
return $h;
}
示例6: getConnection
/**
* Create a new DB connection object and connect to the specified
* database
*
* @param mixed $dsn "data source name", see the self::parseDSN
* method for a description of the dsn format. Can also be
* specified as an array of the format returned by DB::parseDSN().
* @param int $flags Connection flags (e.g. PERSISTENT).
*
* @return Connection Newly created DB connection object
* @throws SQLException
* @see self::parseDSN()
*/
public static function getConnection($dsn, $flags = 0)
{
if (is_array($dsn)) {
$dsninfo = $dsn;
} else {
$dsninfo = self::parseDSN($dsn);
}
// gather any flags from the DSN
if (isset($dsninfo['persistent']) && !empty($dsninfo['persistent'])) {
$flags |= Creole::PERSISTENT;
}
if (isset($dsninfo['compat_assoc_lower']) && !empty($dsninfo['compat_assoc_lower'])) {
$flags |= Creole::COMPAT_ASSOC_LOWER;
}
if (isset($dsninfo['compat_rtrim_string']) && !empty($dsninfo['compat_rtrim_string'])) {
$flags |= Creole::COMPAT_RTRIM_STRING;
}
if (isset($dsninfo['compat_all']) && !empty($dsninfo['compat_all'])) {
$flags |= Creole::COMPAT_ALL;
}
if ($flags & Creole::NO_ASSOC_LOWER) {
trigger_error("The Creole::NO_ASSOC_LOWER flag has been deprecated, and is now the default behavior. Use Creole::COMPAT_ASSOC_LOWER to lowercase resulset keys.", E_USER_WARNING);
}
if (!class_exists('G')) {
$realdocuroot = str_replace('\\', '/', $_SERVER['DOCUMENT_ROOT']);
$docuroot = explode('/', $realdocuroot);
array_pop($docuroot);
$pathhome = implode('/', $docuroot) . '/';
array_pop($docuroot);
$pathTrunk = implode('/', $docuroot) . '/';
require_once $pathTrunk . 'gulliver/system/class.g.php';
}
// sort $dsninfo by keys so the serialized result is always the same
// for identical connection parameters, no matter what their order is
ksort($dsninfo);
$connectionMapKey = G::encryptCrc32(serialize($dsninfo + array('compat_flags' => $flags & Creole::COMPAT_ALL)));
// see if we already have a connection with these parameters cached
if (isset(self::$connectionMap[$connectionMapKey]) && $dsninfo['phptype'] !== 'dbarray') {
// persistent connections will be used if a non-persistent one was requested and is available
// but a persistent connection will be created if a non-persistent one is present
// TODO: impliment auto close of non persistent and replacing the
// non persistent with the persistent object so as we dont have
// both links open for no reason
if (isset(self::$connectionMap[$connectionMapKey][1])) {
// is persistent
// a persistent connection with these parameters is already there,
// so we return it, no matter what was specified as persistent flag
$con = self::$connectionMap[$connectionMapKey][1];
} else {
// we don't have a persistent connection, and since the persistent
// flag wasn't set either, we just return the non-persistent connection
$con = self::$connectionMap[$connectionMapKey][0];
}
// if we're here, a non-persistent connection was already there, but
// the user wants a persistent one, so it will be created
if ($con->isConnected()) {
return $con;
}
}
// support "catchall" drivers which will themselves handle the details of connecting
// using the proper RDBMS driver.
if (isset(self::$driverMap['*'])) {
$type = '*';
} else {
$type = $dsninfo['phptype'];
if (!isset(self::$driverMap[$type])) {
throw new SQLException("No driver has been registered to handle connection type: {$type}");
}
}
// may need to make this more complex if we add support
// for 'dbsyntax'
$clazz = self::import(self::$driverMap[$type]);
$obj = new $clazz();
if (!$obj instanceof Connection) {
throw new SQLException("Class does not implement creole.Connection interface: {$clazz}");
}
try {
$obj->connect($dsninfo, $flags);
} catch (SQLException $sqle) {
$sqle->setUserInfo(isset($dsninfo["username"]) ? $dsninfo["username"] : "");
throw $sqle;
}
$persistent = ($flags & Creole::PERSISTENT) === Creole::PERSISTENT;
return self::$connectionMap[$connectionMapKey][(int) $persistent] = $obj;
}