本文整理汇总了PHP中io::strlen方法的典型用法代码示例。如果您正苦于以下问题:PHP io::strlen方法的具体用法?PHP io::strlen怎么用?PHP io::strlen使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io
的用法示例。
在下文中一共展示了io::strlen方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setValue
/**
* Sets the string value.
*
* @param string $value the string value to set
* @return boolean true on success, false on failure
* @access public
*/
function setValue($value)
{
//add some complementary checks on values
if ($value && io::strlen($value) > 255) {
$this->raiseError("Setting a too long string for string value : max 255 cars, set : " . io::strlen($value));
return false;
}
$this->_value = $value;
return true;
}
示例2: create_tar
/**
* Creates compressed file by compressing raw data contained into $this->CMS_archive
*
* @return true on success, false on failure
*/
function create_tar()
{
$pwd = getcwd();
chdir($this->options['basedir']);
foreach ($this->files as $current) {
if ($current['name'] == $this->options['name']) {
continue;
}
if (io::strlen($current['name2']) > 99) {
$path = io::substr($current['name2'], 0, io::strpos($current['name2'], "/", io::strlen($current['name2']) - 100) + 1);
$current['name2'] = io::substr($current['name2'], io::strlen($path));
if (io::strlen($path) > 154 || io::strlen($current['name2']) > 99) {
$this->raiseError("Could not add {$path}{$current['name2']} to archive because the filename is too long.");
continue;
}
}
$block = pack("a100a8a8a8a12a12a8a1a100a6a2a32a32a8a8a155a12", $current['name2'], decoct($current['stat'][2]), sprintf("%6s ", decoct($current['stat'][4])), sprintf("%6s ", decoct($current['stat'][5])), sprintf("%11s ", decoct($current['stat'][7])), sprintf("%11s ", decoct($current['stat'][9])), " ", $current['type'], "", "ustar", "00", "Unknown", "Unknown", "", "", !empty($path) ? $path : "", "");
$checksum = 0;
for ($i = 0; $i < 512; $i++) {
$checksum += ord(io::substr($block, $i, 1));
}
$checksum = pack("a8", sprintf("%6s ", decoct($checksum)));
$block = substr_replace($block, $checksum, 148, 8);
if ($current['stat'][7] == 0) {
$this->add_data($block);
} else {
if ($fp = @fopen($current['name'], "rb")) {
$this->add_data($block);
while ($temp = fread($fp, 1048576)) {
$this->add_data($temp);
}
if ($current['stat'][7] % 512 > 0) {
$temp = "";
for ($i = 0; $i < 512 - $current['stat'][7] % 512; $i++) {
$temp .= "";
}
$this->add_data($temp);
}
fclose($fp);
} else {
$this->raiseError("Could not open file {$current['name']} for reading. It was not added.");
}
}
}
$this->add_data(pack("a512", ""));
chdir($pwd);
return true;
}
示例3: search
/**
* Search groups
* Static function.
*
* @param string search : search group by lastname, firstname or login
* @param string letter : search group by first lastname letter
* @param integer userId : search group which user belongs to
* @param string order : order by fieldname (without suffix). default : label
* @param integer start : search start offset
* @param integer limit : search limit (default : 0 : unlimited)
* @param boolean returnObjects : return CMS_profile_usersGroup objects (default) or array of groupId
* @return array(CMS_profile_usersGroup)
* @access public
*/
static function search($search = '', $letter = '', $userId = false, $groupsIds = array(), $order = '', $direction = 'asc', $start = 0, $limit = 0, $returnObjects = true, &$score = array())
{
$start = (int) $start;
$limit = (int) $limit;
$direction = in_array(io::strtolower($direction), array('asc', 'desc')) ? io::strtolower($direction) : 'asc';
$keywordsWhere = $letterWhere = $groupWhere = $orderClause = $orderBy = '';
$select = 'id_prg';
if ($search) {
//clean user keywords (never trust user input, user is evil)
$keyword = strtr($search, ",;", " ");
$words = array();
$words = array_map("trim", array_unique(explode(" ", io::strtolower($keyword))));
$cleanedWords = array();
foreach ($words as $aWord) {
if ($aWord && $aWord != '' && io::strlen($aWord) >= 3) {
$aWord = str_replace(array('%', '_'), array('\\%', '\\_'), $aWord);
$cleanedWords[] = $aWord;
}
}
if (!$cleanedWords) {
//if no words after cleaning, return
return array();
}
foreach ($cleanedWords as $cleanedWord) {
$keywordsWhere .= $keywordsWhere ? ' and ' : '';
$keywordsWhere .= " label_prg like '%" . sensitiveIO::sanitizeSQLString($cleanedWord) . "%'";
}
//$keywordsWhere = ' (';
$select .= " , MATCH (label_prg, description_prg) AGAINST ('" . sensitiveIO::sanitizeSQLString($search) . "') as m ";
$keywordsWhere = " (MATCH (label_prg, description_prg) AGAINST ('" . sensitiveIO::sanitizeSQLString($search) . "') or (" . $keywordsWhere . "))";
}
if ($letter && io::strlen($letter) === 1) {
$letterWhere .= $keywordsWhere ? ' and ' : '';
$letterWhere .= " label_prg like '" . sensitiveIO::sanitizeSQLString($letter) . "%'";
}
if ($userId && sensitiveIO::isPositiveInteger($userId)) {
$userGroups = CMS_profile_usersGroupsCatalog::getGroupsOfUser($userId, true);
if (!$userGroups) {
return array();
}
$groupWhere .= $keywordsWhere || $letterWhere ? ' and ' : '';
$groupWhere .= " id_prg in (" . implode(',', $userGroups) . ")";
}
if ($groupsIds) {
$groupWhere .= $keywordsWhere || $letterWhere || $groupWhere ? ' and ' : '';
$groupWhere .= " id_prg in (" . sensitiveIO::sanitizeSQLString(implode(',', $groupsIds)) . ")";
}
if ($order != 'score') {
if ($order) {
$found = false;
$sql = "DESCRIBE profilesUsersGroups";
$q = new CMS_query($sql);
while ($field = $q->getValue('Field')) {
if ($field == $order . '_prg') {
$found = true;
}
}
if ($found) {
$orderBy = $order . '_prg';
} else {
$orderBy = 'label_prg';
}
} else {
$orderBy = 'label_prg';
}
if ($orderBy) {
$orderClause = "order by\n\t\t\t\t\t" . $orderBy . "\n\t\t\t\t\t" . $direction;
}
} else {
$orderClause = " order by m " . $direction;
}
$sql = "\n\t\t\tselect\n\t\t\t\t" . $select . "\n\t\t\tfrom\n\t\t\t\tprofilesUsersGroups\n\t\t\t" . ($keywordsWhere || $letterWhere || $groupWhere ? 'where' : '') . "\n\t\t\t" . $keywordsWhere . "\n\t\t\t" . $letterWhere . "\n\t\t\t" . $groupWhere . "\n\t\t\t" . $orderClause . "\n\t\t";
if ($limit) {
$sql .= "limit \n\t\t\t\t" . $start . ", " . $limit;
}
$q = new CMS_query($sql);
//pr($sql);
//pr($q->getNumRows());
$groups = array();
while ($r = $q->getArray()) {
$id = $r['id_prg'];
//set match score if exists
if (isset($r['m'])) {
$score[$id] = $r['m'];
}
if ($returnObjects) {
//.........这里部分代码省略.........
示例4: _checkRightFormat
/**
* Check validity format of a given right
*
* @param string the right to check
* format :
* r read (and execute if it's a folder)
* w read and write (and execute if it's a folder)
* x read+write+execute
* XXX unix chmod octal value (ex : 664, 775, etc.)
* @return boolean true on success, false on failure
* @access private
*/
protected function _checkRightFormat($right)
{
if (is_numeric($right)) {
if (io::strlen($right) != 3) {
return false;
} else {
$rights = preg_split('//', $right, -1, PREG_SPLIT_NO_EMPTY);
foreach ($rights as $aRight) {
if ($aRight > 7) {
return false;
}
}
}
} else {
if ($right != 'r' && $right != 'w' && $right != 'x') {
return false;
}
}
return true;
}
示例5: getFieldSearchSQL
/**
* Get field search SQL request (used by class CMS_object_search)
*
* @param integer $fieldID : this field id in object (aka $this->_field->getID())
* @param mixed $value : the value to search
* @param string $operator : additionnal search operator
* @param string $where : where clauses to add to SQL
* @param boolean $public : values are public or edited ? (default is edited)
* @return string : the SQL request
* @access public
*/
function getFieldSearchSQL($fieldID, $value, $operator, $where, $public = false)
{
$supportedOperator = array('like', '!=', '=', 'any', 'all', 'phrase', 'beginswith');
$supportedOperatorForArray = array('in', 'not in', 'any', 'all');
// No operator : use default search
if (!$operator) {
return parent::getFieldSearchSQL($fieldID, $value, $operator, $where, $public);
}
// Check supported operators
if ($operator && !in_array($operator, array_merge($supportedOperator, $supportedOperatorForArray))) {
$this->raiseError("Unknown search operator : " . $operator . ", use default search instead");
$operator = false;
}
// Check operators for array value
if (is_array($value) && $operator && !in_array($operator, $supportedOperatorForArray)) {
$this->raiseError("Can't use this operator : " . $operator . " with an array value, return empty sql");
return '';
}
$statusSuffix = $public ? "_public" : "_edited";
$cleanedWords = array();
if (is_array($value)) {
if ($operator == 'any' || $operator == 'all') {
// in this case, we do a specific cleanup
foreach ($value as $i => $val) {
$cleanedWords[] = str_replace(array('%', '_'), array('\\%', '\\_'), $val);
}
} else {
foreach ($value as $i => $val) {
$value[$i] = "'" . SensitiveIO::sanitizeSQLString($val) . "'";
}
$value = '(' . implode(',', $value) . ')';
}
} elseif (strtolower($value) == 'null') {
$value = "''";
} else {
if ($operator == 'any' || $operator == 'all') {
$words = array();
$words = array_map("trim", array_unique(explode(" ", $value)));
foreach ($words as $aWord) {
if ($aWord && $aWord != '' && io::strlen($aWord) >= 3) {
$aWord = str_replace(array('%', '_'), array('\\%', '\\_'), $aWord);
$cleanedWords[] = $aWord;
}
}
} elseif ($operator != 'phrase' && $operator != 'beginswith') {
// we keep this for backward compatibility, where the user can specify his search with % at the beginning / end
$value = "'" . SensitiveIO::sanitizeSQLString($value) . "'";
}
}
$whereClause = '';
switch ($operator) {
case 'any':
$whereClause .= '(';
//then add keywords
$count = '0';
foreach ($cleanedWords as $aWord) {
$whereClause .= $count ? ' or ' : '';
$count++;
$whereClause .= "value like '%" . $aWord . "%'";
if (htmlentities($aWord) != $aWord) {
$whereClause .= " or value like '%" . htmlentities($aWord) . "%'";
}
}
$whereClause .= ')';
break;
case 'all':
$whereClause .= '(';
//then add keywords
$count = '0';
foreach ($cleanedWords as $aWord) {
$whereClause .= $count ? ' and ' : '';
$count++;
if (htmlentities($aWord) != $aWord) {
$whereClause .= "(value like '%" . $aWord . "%' or value like '%" . htmlentities($aWord) . "%')";
} else {
$whereClause .= "value like '%" . $aWord . "%'";
}
}
$whereClause .= ')';
break;
case 'phrase':
$value = str_replace(array('%', '_'), array('\\%', '\\_'), trim($value));
if (htmlentities($value) != $value) {
$whereClause .= "(value like '%" . $value . "%' or value like '%" . htmlentities($value) . "%')";
} else {
$whereClause .= "value like '%" . $value . "%'";
}
break;
case 'beginswith':
//.........这里部分代码省略.........
示例6: duplicate
/**
* Duplicate this block
* Used to duplicate a CMS_page.
*
* @param CMS_page $destinationPage, the page receiving a copy of this block
* @param boolean $public The precision needed for USERSPACE location
* @return CMS_block object
*/
function duplicate(&$destinationPage, $public = false)
{
if (SensitiveIO::isPositiveInteger($this->_dbID) && $this->_file) {
$table = $this->_getDataTableName(RESOURCE_LOCATION_USERSPACE, $public);
//Copy linked file
//In new file name, delete reference to old page and add refernce to new one
$_newFilename = "p" . $destinationPage->getID() . io::substr($this->_file, io::strpos($this->_file, "_"), io::strlen($this->_file));
if (@is_file(PATH_MODULES_FILES_STANDARD_FS . "/edited/" . $this->_file) && @copy(PATH_MODULES_FILES_STANDARD_FS . "/edited/" . $this->_file, PATH_MODULES_FILES_STANDARD_FS . "/edited/" . $_newFilename) && @chmod(PATH_MODULES_FILES_STANDARD_FS . "/edited/" . $_newFilename, octdec(FILES_CHMOD))) {
//Public
if ($public) {
if (!@copy(PATH_MODULES_FILES_STANDARD_FS . "/public/" . $this->_file, PATH_MODULES_FILES_STANDARD_FS . "/public/" . $_newFilename) || !@chmod(PATH_MODULES_FILES_STANDARD_FS . "/public/" . $_newFilename, octdec(FILES_CHMOD))) {
$this->raiseError("Duplicate, copy of new file failed : " . PATH_MODULES_FILES_STANDARD_FS . "/public/" . $_newFilename);
}
}
$_newEnlargedFilename = '';
//With enlarged file
if ($this->_enlargedFile != '') {
$_newEnlargedFilename = "p" . $destinationPage->getID() . io::substr($this->_enlargedFile, io::strpos($this->_enlargedFile, "_"), io::strlen($this->_enlargedFile));
//Edited
if (!@copy(PATH_MODULES_FILES_STANDARD_FS . "/edited/" . $this->_enlargedFile, PATH_MODULES_FILES_STANDARD_FS . "/edited/" . $_newEnlargedFilename) || !@chmod(PATH_MODULES_FILES_STANDARD_FS . "/edited/" . $_newEnlargedFilename, octdec(FILES_CHMOD))) {
$this->raiseError("Duplicate, copy of new enlarged file failed : " . PATH_MODULES_FILES_STANDARD_FS . "/edited/" . $_newEnlargedFilename);
}
//Public
if ($public) {
if (!@copy(PATH_MODULES_FILES_STANDARD_FS . "/public/" . $this->_enlargedFile, PATH_MODULES_FILES_STANDARD_FS . "/public/" . $_newEnlargedFilename) || !@chmod(PATH_MODULES_FILES_STANDARD_FS . "/public/" . $_newEnlargedFilename, octdec(FILES_CHMOD))) {
$this->raiseError("Duplicate, copy of new enlarged file failed : " . PATH_MODULES_FILES_STANDARD_FS . "/public/" . $_newEnlargedFilename);
}
}
}
//Save new datas
$str_set = "\n\t\t\t\t\t\tpage='" . $destinationPage->getID() . "',\n\t\t\t\t\t\tclientSpaceID='" . $this->_clientSpaceID . "',\n\t\t\t\t\t\trowID='" . $this->_rowID . "',\n\t\t\t\t\t\tblockID='" . $this->_tagID . "',\n\t\t\t\t\t\tlabel='" . SensitiveIO::sanitizeSQLString(SensitiveIO::stripPHPTags($this->_label)) . "',\n\t\t\t\t\t\tfile='" . SensitiveIO::sanitizeSQLString(SensitiveIO::stripPHPTags($_newFilename)) . "',\n\t\t\t\t\t\texternalLink='" . SensitiveIO::sanitizeSQLString(SensitiveIO::stripPHPTags($this->_externalLink)) . "',\n\t\t\t\t\t\tenlargedFile='" . SensitiveIO::sanitizeSQLString(SensitiveIO::stripPHPTags($_newEnlargedFilename)) . "'\n\t\t\t\t";
$sql = "\n\t\t\t\t\tinsert into\n\t\t\t\t\t\t" . $table . "\n\t\t\t\t\tset\n\t\t\t\t\t\t" . $str_set . "\n\t\t\t\t";
$q = new CMS_query($sql);
if (!$q->hasError()) {
//Table Edition
$sql = "\n\t\t\t\t\t\tinsert into\n\t\t\t\t\t\t\t" . $this->_getDataTableName(RESOURCE_LOCATION_EDITION, false) . "\n\t\t\t\t\t\tset\n\t\t\t\t\t\t\tid='" . $q->getLastInsertedID() . "',\n\t\t\t\t\t\t\t" . $str_set . "\n\t\t\t\t\t";
$q = new CMS_query($sql);
return !$q->hasError();
} else {
$this->raiseError("Duplicate, SQL insertion of new filename failed : " . $sql);
}
} else {
$this->raiseError("Duplicate, copy of file failed :" . PATH_MODULES_FILES_STANDARD_FS . "/edited/" . $this->_file);
}
}
return false;
}
示例7: dirname
*
* @package Automne
* @subpackage admin
* @author Sébastien Pauchet <sebastien.pauchet@ws-interactive.fr>
*/
require_once dirname(__FILE__) . '/../../cms_rc_admin.php';
//load interface instance
$view = CMS_view::getInstance();
//set default display mode for this page
$view->setDisplayMode(CMS_view::SHOW_JSON);
//This file is an admin file. Interface must be secure
$view->setSecure();
$query = sensitiveIO::request('query', '', '');
$start = sensitiveIO::request('start', 'sensitiveIO::isPositiveInteger', 0);
$limit = sensitiveIO::request('limit', 'sensitiveIO::isPositiveInteger', 10);
if (!$query || io::strlen($query) < 3) {
CMS_grandFather::raiseError('Missing query or query is too short : ' . $query);
$view->show();
}
//lauch search
$results = CMS_search::getSearch($query, $cms_user, false, false);
//pr($results);
$pages = array();
$count = 0;
if (isset($results['results']) && is_array($results['results'])) {
foreach ($results['results'] as $result) {
if ($count >= $start && sizeof($pages) < $limit) {
$page = CMS_tree::getPageById($result);
if ($page && !$page->hasError()) {
$pages[] = array('pageId' => $page->getID(), 'title' => $page->getTitle() . ' (' . $page->getID() . ')', 'status' => $page->getStatus()->getHTML(true, $cms_user, MOD_STANDARD_CODENAME, $page->getID()), 'lineage' => CMS_tree::getLineage(APPLICATION_ROOT_PAGE_ID, $page->getID(), false));
} else {
示例8: getAll
/**
* Return all the rows available
*
* @param CMS_profile_user $cms_user : restrict to user rights on modules (default : false)
* @param integer $tplId : restrict to rows usable in given template (default : false)
* @param string $csId : restrict to rows usable in given clientspace (default : false)
* @param integer $start : start position
* @param integer $limit : limit position
* @param integer $count : number of rows found (passed by reference)
* @access public
*/
static function getAll($includeInactive = false, $keyword = '', $groups = array(), $rowIds = array(), $user = false, $tplId = false, $csId = false, $start = 0, $limit = 0, $returnObjects = true, &$score = array())
{
$select = 'id_row';
$where = '';
//keywords
if ($keyword) {
//clean user keywords (never trust user input, user is evil)
$keyword = strtr($keyword, ",;", " ");
$words = array();
$words = array_map("trim", array_unique(explode(" ", io::strtolower($keyword))));
$cleanedWords = array();
foreach ($words as $aWord) {
if ($aWord && $aWord != '' && io::strlen($aWord) >= 3) {
$aWord = str_replace(array('%', '_'), array('\\%', '\\_'), $aWord);
$cleanedWords[] = $aWord;
}
}
if (!$cleanedWords) {
//if no words after cleaning, return
return array();
}
$keywordWhere = '';
foreach ($cleanedWords as $cleanedWord) {
$keywordWhere .= $keywordWhere ? ' and ' : '';
$keywordWhere .= " (\n\t\t\t\t\tdescription_row like '%" . sensitiveIO::sanitizeSQLString($cleanedWord) . "%'\n\t\t\t\t\tor label_row like '%" . sensitiveIO::sanitizeSQLString($cleanedWord) . "%'\n\t\t\t\t)";
}
$where .= $where ? ' and ' : '';
$where .= " ((" . $keywordWhere . ") or MATCH (label_row, description_row) AGAINST ('" . sensitiveIO::sanitizeSQLString($keyword) . "') )";
$select .= " , MATCH (label_row, description_row) AGAINST ('" . sensitiveIO::sanitizeSQLString($keyword) . "') as m ";
}
$sql = "\n\t\t\tselect\n\t\t\t\t" . $select . "\n\t\t\tfrom\n\t\t\t\tmod_standard_rows\n\t\t";
//groups
if ($groups) {
foreach ($groups as $group) {
$where .= $where ? ' and ' : '';
$where .= " (\n\t\t\t\t\tgroupsStack_row='" . sensitiveIO::sanitizeSQLString($group) . "'\n\t\t\t\t\tor groupsStack_row like '%;" . sensitiveIO::sanitizeSQLString($group) . ";%'\n\t\t\t\t\tor groupsStack_row like '" . sensitiveIO::sanitizeSQLString($group) . ";%'\n\t\t\t\t\tor groupsStack_row like '%;" . sensitiveIO::sanitizeSQLString($group) . "'\n\t\t\t\t)";
}
}
//useable
if (!$includeInactive) {
$where .= $where ? ' and ' : '';
$where .= " useable_row=1 ";
}
//rowIds
if ($rowIds) {
$where .= $where ? ' and ' : '';
$where .= " id_row in (" . implode(',', $rowIds) . ") ";
}
if ($tplId) {
$where .= $where ? ' and ' : '';
$where .= " (\n\t\t\t\ttplfilter_row=''\n\t\t\t\tor tplfilter_row='" . sensitiveIO::sanitizeSQLString($tplId) . "'\n\t\t\t\tor tplfilter_row like '%;" . sensitiveIO::sanitizeSQLString($tplId) . ";%'\n\t\t\t\tor tplfilter_row like '" . sensitiveIO::sanitizeSQLString($tplId) . ";%'\n\t\t\t\tor tplfilter_row like '%;" . sensitiveIO::sanitizeSQLString($tplId) . "'\n\t\t\t) ";
}
//user
if (is_object($user) && !$user->hasAdminClearance(CLEARANCE_ADMINISTRATION_EDITVALIDATEALL)) {
$groupsDenied = $user->getRowGroupsDenied();
$groupsDenied = $groupsDenied->getElements();
if ($groupsDenied) {
$where .= $where ? ' and (' : '(';
foreach ($groupsDenied as $group) {
$where .= " (\n\t\t\t\t\t\tgroupsStack_row != '" . sensitiveIO::sanitizeSQLString($group[0]) . "'\n\t\t\t\t\t\tand groupsStack_row not like '%;" . sensitiveIO::sanitizeSQLString($group[0]) . ";%'\n\t\t\t\t\t\tand groupsStack_row not like '" . sensitiveIO::sanitizeSQLString($group[0]) . ";%'\n\t\t\t\t\t\tand groupsStack_row not like '%;" . sensitiveIO::sanitizeSQLString($group[0]) . "'\n\t\t\t\t\t) and";
}
//remove last "or" and append )
$where = io::substr($where, 0, -3) . ')';
}
}
$sql = $sql . ($where ? ' where ' . $where : '');
//order
if (io::strpos($sql, 'MATCH') === false) {
$sql .= " order by label_row ";
} else {
$sql .= " order by m desc ";
}
//limit
if ($start || $limit) {
$sql .= " limit " . sensitiveIO::sanitizeSQLString($start) . "," . sensitiveIO::sanitizeSQLString($limit);
}
//pr($sql);
$q = new CMS_query($sql);
$rows = array();
while ($r = $q->getArray()) {
$id = $r['id_row'];
//set match score if exists
if (isset($r['m'])) {
$score[$id] = $r['m'];
}
if ($returnObjects) {
$row = new CMS_row($id);
if (!$row->hasError()) {
$rows[$row->getID()] = $row;
//.........这里部分代码省略.........
示例9: create_zip
/**
* Creates compressed file by compressing raw data contained into $this->CMS_archive
*
* @return true on success, false on failure
*/
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 += io::strlen($temp);
unset($temp);
} else {
$this->raiseError("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;
}
// Special chars management
$translate = array('Ç' => pack("C", 128), 'ü' => pack("C", 129), 'é' => pack("C", 130), 'â' => pack("C", 131), 'ä' => pack("C", 132), 'à' => pack("C", 133), 'å' => pack("C", 134), 'ç' => pack("C", 135), 'ê' => pack("C", 136), 'ë' => pack("C", 137), 'è' => pack("C", 138), 'ï' => pack("C", 139), 'î' => pack("C", 140), 'ì' => pack("C", 141), 'Ä' => pack("C", 142), 'Å' => pack("C", 143), 'É' => pack("C", 144), 'æ' => pack("C", 145), 'Æ' => pack("C", 146), 'ô' => pack("C", 147), 'ö' => pack("C", 148), 'ò' => pack("C", 149), 'û' => pack("C", 150), 'ù' => pack("C", 151), 'Ö' => pack("C", 153), 'Ü' => pack("C", 154), '£' => pack("C", 156), '¥' => pack("C", 157), 'ƒ' => pack("C", 159), 'á' => pack("C", 160), 'í' => pack("C", 161), 'ó' => pack("C", 162), 'ú' => pack("C", 163), 'ñ' => pack("C", 164), 'Ñ' => pack("C", 165));
$current['name2'] = strtr($current['name2'], $translate);
$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, io::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, io::strlen($current['name2']) + 1, 0x0, 0x0, 0x0, 0x0, $current['type'] == 5 ? 0x10 : 0x0, $offset);
$central .= $current['name2'] . "/";
$files++;
$offset += 31 + io::strlen($current['name2']);
} else {
if ($current['stat'][7] == 0) {
$block .= pack("VVVvv", 0x0, 0x0, 0x0, io::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, io::strlen($current['name2']), 0x0, 0x0, 0x0, 0x0, $current['type'] == 5 ? 0x10 : 0x0, $offset);
$central .= $current['name2'];
$files++;
$offset += 30 + io::strlen($current['name2']);
} else {
if ($fp = @fopen($current['name'], "rb")) {
$temp = fread($fp, $current['stat'][7]);
fclose($fp);
$crc32 = crc32($temp);
if (!isset($current['method']) && $this->options['method'] == 1) {
$temp = gzcompress($temp, $this->options['level']);
$size = io::strlen($temp) - 6;
$temp = io::substr($temp, 2, $size);
} else {
$size = io::strlen($temp);
}
$block .= pack("VVVvv", $crc32, $size, $current['stat'][7], io::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], io::strlen($current['name2']), 0x0, 0x0, 0x0, 0x0, 0x0, $offset);
$central .= $current['name2'];
$files++;
$offset += 30 + io::strlen($current['name2']) + $size;
} else {
$this->raiseError("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, io::strlen($central), $offset, !empty($this->options['comment']) ? io::strlen($this->options['comment']) : 0x0));
if (!empty($this->options['comment'])) {
$this->add_data($this->options['comment']);
}
chdir($pwd);
return true;
}
示例10: setAltDomains
/**
* Sets the alternatives domains url. Can be empty. Will be riden of http://.
*
* @param string $url The url to set
* @return boolean true on success, false on failure.
* @access public
*/
function setAltDomains($domains)
{
if (!$domains) {
$this->_altdomains = '';
return true;
}
$this->_altdomains = '';
$domains = explode(';', $domains);
foreach ($domains as $domain) {
if (io::substr($domain, 0, 7) == "http://") {
$domain = io::substr($domain, 7);
}
if ($domain) {
$this->_altdomains .= $this->_altdomains ? ';' : '';
if (io::substr($domain, io::strlen($domain) - 1) == "/") {
$domain = io::substr($domain, 0, -1);
}
$this->_altdomains .= $domain;
}
}
return true;
}
示例11: startScript
/**
* Start the scripts process queue.
* Remove the lock file then relaunch the script if force is true
*
* @param boolean $force Set to true if you wish to remove the lock file before launch
* @return void
* @access public
* @static
*/
static function startScript($force = false)
{
if (USE_BACKGROUND_REGENERATOR) {
$forceRestart = '';
if ($force) {
$forceRestart = ' -F';
} elseif (processManager::hasRunningScript()) {
return false;
}
//test if we're on windows or linux, for the output redirection
if (APPLICATION_IS_WINDOWS) {
if (realpath(PATH_PHP_CLI_WINDOWS) === false) {
CMS_grandFather::raiseError("Unknown CLI location : " . PATH_PHP_CLI_WINDOWS . ", please check your configuration.");
return false;
}
// Create the BAT file
$command = '@echo off' . "\r\n" . 'start /B /LOW ' . realpath(PATH_PHP_CLI_WINDOWS) . ' ' . realpath(PATH_PACKAGES_FS . '\\scripts\\script.php') . ' -m ' . REGENERATION_THREADS . $forceRestart;
$replace = array('program files (x86)' => 'progra~2', 'program files' => 'progra~1', 'documents and settings' => 'docume~1');
$command = str_ireplace(array_keys($replace), $replace, $command);
if (!@touch(PATH_WINDOWS_BIN_FS . "/script.bat")) {
CMS_grandFather::_raiseError("CMS_scriptsManager : startScript : Create file error : " . PATH_WINDOWS_BIN_FS . "/script.bat");
return false;
}
$fh = @fopen(PATH_WINDOWS_BIN_FS . "/script.bat", "wb");
if (is_resource($fh)) {
if (!@fwrite($fh, $command, io::strlen($command))) {
CMS_grandFather::raiseError("Save file error : script.bat");
}
@fclose($fh);
}
$WshShell = new COM("WScript.Shell");
$oExec = $WshShell->Run(str_ireplace(array_keys($replace), $replace, realpath(PATH_WINDOWS_BIN_FS . '\\script.bat')), 0, false);
} else {
$error = '';
if (!defined('PATH_PHP_CLI_UNIX') || !PATH_PHP_CLI_UNIX) {
$return = CMS_patch::executeCommand('which php 2>&1', $error);
if ($error) {
CMS_grandFather::raiseError('Error when finding php CLI with command "which php", please check your configuration : ' . $error);
return false;
}
if (io::substr($return, 0, 1) != '/') {
CMS_grandFather::raiseError('Can\'t find php CLI with command "which php", please check your configuration.');
return false;
}
$return = CMS_patch::executeCommand("cd " . PATH_REALROOT_FS . "; php " . PATH_PACKAGES_FS . "/scripts/script.php -m " . REGENERATION_THREADS . $forceRestart . " > /dev/null 2>&1 &", $error);
if ($error) {
CMS_grandFather::raiseError('Error during execution of script command (cd ' . PATH_REALROOT_FS . '; php ' . PATH_PACKAGES_FS . '/scripts/script.php -m ' . REGENERATION_THREADS . $forceRestart . '), please check your configuration : ' . $error);
return false;
}
} else {
$return = CMS_patch::executeCommand(PATH_PHP_CLI_UNIX . ' -v 2>&1', $error);
if ($error) {
CMS_grandFather::raiseError('Error when testing php CLI with command "' . PATH_PHP_CLI_UNIX . ' -v", please check your configuration : ' . $error);
return false;
}
if (io::strpos(io::strtolower($return), '(cli)') === false) {
CMS_grandFather::raiseError(PATH_PHP_CLI_UNIX . ' is not the CLI version');
return false;
}
$return = CMS_patch::executeCommand("cd " . PATH_REALROOT_FS . "; " . PATH_PHP_CLI_UNIX . " " . PATH_PACKAGES_FS . "/scripts/script.php -m " . REGENERATION_THREADS . $forceRestart . " > /dev/null 2>&1 &", $error);
if ($error) {
CMS_grandFather::raiseError('Error during execution of script command (cd ' . PATH_REALROOT_FS . '; ' . PATH_PHP_CLI_UNIX . ' ' . PATH_PACKAGES_FS . '/scripts/script.php -m ' . REGENERATION_THREADS . $forceRestart . '), please check your configuration : ' . $error);
return false;
}
}
//CMS_grandFather::log($return);
//CMS_grandFather::log("cd ".PATH_REALROOT_FS."; php ".PATH_PACKAGES_FS."/scripts/script.php -m ".REGENERATION_THREADS.$forceRestart." > /dev/null 2>&1 &");
//@system("cd ".PATH_REALROOT_FS."; php ".PATH_PACKAGES_FS."/scripts/script.php -m ".REGENERATION_THREADS.$forceRestart." > /dev/null 2>&1 &");
}
} else {
CMS_session::setSessionVar('start_script', true);
}
}
示例12: duplicate
/**
* Duplicate this block
* Used to duplicate a CMS_page.
*
* @param CMS_page $destinationPage, the page receiving a copy of this block
* @param boolean $public The precision needed for USERSPACE location
* @return CMS_block object
*/
function duplicate(&$destinationPage, $public = false)
{
if (SensitiveIO::isPositiveInteger($this->_dbID) && $this->_file) {
$table = $this->_getDataTableName(RESOURCE_LOCATION_USERSPACE, $public);
//Copy linked file
//In new file name, delete reference to old page and add refernce to new one
$_newFilename = "p" . $destinationPage->getID() . io::substr($this->_file, io::strpos($this->_file, "_"), io::strlen($this->_file));
if (@is_file(PATH_MODULES_FILES_STANDARD_FS . "/edited/" . $this->_file) && @copy(PATH_MODULES_FILES_STANDARD_FS . "/edited/" . $this->_file, PATH_MODULES_FILES_STANDARD_FS . "/edited/" . $_newFilename) && @chmod(PATH_MODULES_FILES_STANDARD_FS . "/edited/" . $_newFilename, octdec(FILES_CHMOD))) {
//Public
if ($public) {
if (!@copy(PATH_MODULES_FILES_STANDARD_FS . "/public/" . $this->_file, PATH_MODULES_FILES_STANDARD_FS . "/public/" . $_newFilename) || !@chmod(PATH_MODULES_FILES_STANDARD_FS . "/public/" . $_newFilename, octdec(FILES_CHMOD))) {
$this->raiseError("Duplicate, flash file copy failed : " . PATH_MODULES_FILES_STANDARD_FS . "/public/" . $_newFilename);
}
}
//Save new datas
$str_set = "\n\t\t\t\t\t\tpage='" . $destinationPage->getID() . "',\n\t\t\t\t\t\tclientSpaceID='" . $this->_clientSpaceID . "',\n\t\t\t\t\t\trowID='" . $this->_rowID . "',\n\t\t\t\t\t\tblockID='" . $this->_tagID . "',\n\t\t\t\t\t\tfile='" . SensitiveIO::sanitizeSQLString($_newFilename) . "',\n\t\t\t\t\t\twidth='" . SensitiveIO::sanitizeSQLString($this->_width) . "',\n\t\t\t\t\t\theight='" . SensitiveIO::sanitizeSQLString($this->_height) . "',\n\t\t\t\t\t\tname='" . SensitiveIO::sanitizeSQLString($this->_name) . "',\n\t\t\t\t\t\tversion='" . SensitiveIO::sanitizeSQLString($this->_version) . "',\n\t\t\t\t\t\tparams='" . SensitiveIO::sanitizeSQLString($this->_params) . "',\n\t\t\t\t\t\tflashvars='" . SensitiveIO::sanitizeSQLString($this->_flashvars) . "',\n\t\t\t\t\t\tattributes='" . SensitiveIO::sanitizeSQLString($this->_flashattributes) . "'\n\t\t\t\t";
$sql = "\n\t\t\t\t\tinsert into\n\t\t\t\t\t\t" . $table . "\n\t\t\t\t\tset\n\t\t\t\t\t\t" . $str_set . "\n\t\t\t\t";
$q = new CMS_query($sql);
if (!$q->hasError()) {
//Table Edition
$sql = "\n\t\t\t\t\t\tinsert into\n\t\t\t\t\t\t\t" . $this->_getDataTableName(RESOURCE_LOCATION_EDITION, false) . "\n\t\t\t\t\t\tset\n\t\t\t\t\t\t\tid='" . $q->getLastInsertedID() . "',\n\t\t\t\t\t\t\t" . $str_set . "\n\t\t\t\t\t";
$q = new CMS_query($sql);
return !$q->hasError();
} else {
$this->raiseError("Duplicate, SQL insertion of new flash failed: " . $sql);
}
} else {
$this->raiseError("Duplicate, copy of file failed :" . PATH_MODULES_FILES_STANDARD_FS . "/edited/" . $this->_file);
}
}
return false;
}
示例13: setValue
/**
* Sets a value for a given language code.
*
* @param string $languageCode the language code of the value to set
* @param mixed $value the value to set
* @return boolean true on success, false on failure
* @access public
*/
function setValue($languageCode, $value)
{
if (io::strlen($languageCode) > 5) {
$this->raiseError("Can't use a language code longuer than 5 caracters : " . $languageCode);
return false;
}
$this->_values[$languageCode] = $value;
return true;
}
示例14: search
/**
* Search users
* Static function.
*
* @param string search : search user by lastname, firstname or login
* @param string letter : search user by first lastname letter
* @param integer group : search user by group ID
* @param string order : order by fieldname (without suffix). default : lastname, firstname
* @param integer start : search start offset
* @param integer limit : search limit (default : 0 : unlimited)
* @param boolean activeOnly : return only active users (default : false)
* @param boolean returnObjects : return CMS_profile_user objects (default) or array of userId
* @return array(CMS_profile_user)
* @access public
*/
static function search($search = '', $letter = '', $group = '', $order = '', $direction = 'asc', $start = 0, $limit = 0, $activeOnly = false, $returnObjects = true, &$score = array())
{
$start = (int) $start;
$limit = (int) $limit;
$group = (int) $group;
$direction = in_array(io::strtolower($direction), array('asc', 'desc')) ? io::strtolower($direction) : 'asc';
$keywordsWhere = $letterWhere = $groupWhere = $orderBy = $orderClause = $idWhere = '';
$select = 'id_pru';
if (io::strpos($search, ':noroot:') !== false) {
$idWhere = " and id_pru != '" . ROOT_PROFILEUSER_ID . "'";
$search = trim(str_replace(':noroot:', '', $search));
}
if (io::substr($search, 0, 5) == 'user:' && sensitiveIO::isPositiveInteger(io::substr($search, 5))) {
$idWhere = " and id_pru = '" . sensitiveIO::sanitizeSQLString(io::substr($search, 5)) . "'";
$search = '';
}
if (io::substr($search, 0, 6) == 'group:' && sensitiveIO::isPositiveInteger(io::substr($search, 6))) {
$group = io::substr($search, 6);
$search = '';
}
if ($search) {
//clean user keywords (never trust user input, user is evil)
$keyword = strtr($search, ",;", " ");
$words = array();
$words = array_map("trim", array_unique(explode(" ", io::strtolower($keyword))));
$cleanedWords = array();
foreach ($words as $aWord) {
if ($aWord && $aWord != '' && io::strlen($aWord) >= 3) {
$aWord = str_replace(array('%', '_'), array('\\%', '\\_'), $aWord);
if (htmlentities($aWord) != $aWord) {
$cleanedWords[] = htmlentities($aWord);
}
$cleanedWords[] = $aWord;
}
}
if (!$cleanedWords) {
//if no words after cleaning, return
return array();
}
foreach ($cleanedWords as $cleanedWord) {
$keywordsWhere .= $keywordsWhere ? " and " : '';
$keywordsWhere .= " (\n\t\t\t\t\tlastName_pru like '%" . sensitiveIO::sanitizeSQLString($cleanedWord) . "%'\n\t\t\t\t\tor firstName_pru like '%" . sensitiveIO::sanitizeSQLString($cleanedWord) . "%'\n\t\t\t\t\tor login_pru like '%" . sensitiveIO::sanitizeSQLString($cleanedWord) . "%'\n\t\t\t\t)";
}
$keywordsWhere = ' and ((' . $keywordsWhere . ')';
$select .= " , MATCH (lastName_pru, firstName_pru, login_pru) AGAINST ('" . sensitiveIO::sanitizeSQLString($search) . "') as m ";
$keywordsWhere .= " or MATCH (lastName_pru, firstName_pru, login_pru) AGAINST ('" . sensitiveIO::sanitizeSQLString($search) . "') )";
}
if ($letter && io::strlen($letter) === 1) {
$letterWhere = " and lastName_pru like '" . sensitiveIO::sanitizeSQLString($letter) . "%'";
}
if ($group) {
$groupUsers = CMS_profile_usersGroupsCatalog::getGroupUsers($group, false);
if (!$groupUsers) {
return array();
}
$groupWhere = " and id_pru in (" . implode(',', $groupUsers) . ")";
}
if ($order != 'score') {
if ($order) {
$found = false;
$sql = "DESCRIBE profilesUsers";
$q = new CMS_query($sql);
while ($field = $q->getValue('Field')) {
if ($field == $order . '_pru') {
$found = true;
}
}
if ($found) {
$orderBy = $order . '_pru';
} else {
$orderBy = 'lastName_pru,firstName_pru';
}
} else {
$orderBy = 'lastName_pru,firstName_pru';
}
if ($orderBy) {
$orderClause = "order by\n\t\t\t\t\t" . $orderBy . "\n\t\t\t\t\t" . $direction;
}
} elseif ($search) {
$orderClause = " order by m " . $direction;
}
$sql = "\n\t\t\tselect\n\t\t\t\t" . $select . "\n\t\t\tfrom\n\t\t\t\tprofilesUsers\n\t\t\twhere \n\t\t\t deleted_pru='0'\n\t\t\t" . ($activeOnly ? " and active_pru='1' " : '') . "\n\t\t\t" . $keywordsWhere . "\n\t\t\t" . $letterWhere . "\n\t\t\t" . $groupWhere . "\n\t\t\t" . $idWhere . "\n\t\t\t" . $orderClause . "\n\t\t";
if ($limit) {
$sql .= "limit \n\t\t\t\t" . $start . ", " . $limit;
}
//.........这里部分代码省略.........
示例15: EncodeQP
/** Encode string to quoted-printable.
* @access private
* @return string
*/
function EncodeQP($str)
{
$encoded = $this->FixEOL($str);
if (io::substr($encoded, -io::strlen($this->LE)) != $this->LE) {
$encoded .= $this->LE;
}
/* Replace every high ascii, control and = characters */
$encoded = preg_replace('/([\\000-\\010\\013\\014\\016-\\037\\075\\177-\\377])/e', "'='.sprintf('%02X', ord('\\1'))", $encoded);
/* Replace every spaces and tabs when it's the last character on a line */
$encoded = preg_replace("/([\t ])" . $this->LE . "/e", "'='.sprintf('%02X', ord('\\1')).'" . $this->LE . "'", $encoded);
/* Maximum line length of 76 characters before CRLF (74 + space + '=') */
//$encoded = $this->WrapText($encoded, 74, true);
return $encoded;
}