本文整理汇总了PHP中IPSLib::isWritable方法的典型用法代码示例。如果您正苦于以下问题:PHP IPSLib::isWritable方法的具体用法?PHP IPSLib::isWritable怎么用?PHP IPSLib::isWritable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPSLib
的用法示例。
在下文中一共展示了IPSLib::isWritable方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: emoticonsPackImport
/**
* Import an emoticon pack
*
* @return @e void
*/
public function emoticonsPackImport()
{
/* Make sure all emoticon directories are writable */
$this->DB->build(array('select' => $this->DB->buildDistinct('emo_set') . ' as folder', 'from' => 'emoticons'));
$this->DB->execute();
while ($r = $this->DB->fetch()) {
$_folders[] = $r['folder'];
}
if (count($_folders)) {
foreach ($_folders as $folder) {
if (!IPSLib::isWritable(DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $folder)) {
$this->registry->output->global_error = sprintf($this->lang->words['emodir_not_write'], PUBLIC_DIRECTORY . '/style_emoticons/' . $folder);
return $this->emoticonsPackSplash();
}
}
}
/* Get the xml file */
try {
$content = $this->registry->adminFunctions->importXml('ipb_emoticons.xml');
} catch (Exception $e) {
$this->registry->output->showError($e->getMessage());
}
/* Check for content */
if (!$content) {
$this->registry->output->global_error = $this->lang->words['emo_fail'];
return $this->emoticonsPackSplash();
}
/* Setup XML */
require_once IPS_KERNEL_PATH . 'classXML.php';
/*noLibHook*/
$xml = new classXML(IPS_DOC_CHAR_SET);
require_once IPS_KERNEL_PATH . 'classXMLArchive.php';
/*noLibHook*/
$xmlarchive = new classXMLArchive();
/* Read the archive */
$xmlarchive->readXML($content);
/* Get the data file */
$emoticons = array();
$emoticon_data = array();
foreach ($xmlarchive->asArray() as $k => $f) {
if ($k == 'emoticon_data.xml') {
$emoticon_data = $f;
} else {
$emoticons[$f['filename']] = $f['content'];
}
}
/* Parse the XML Document */
$xml->loadXML($emoticon_data['content']);
/* Make sure we have a destination for these emoicons */
if (!$this->request['emo_set'] and !$this->request['new_emo_set']) {
$this->registry->output->global_error = $this->lang->words['emo_specify'];
}
/* Current emoticon set directory */
$emo_set_dir = trim($this->request['emo_set']);
/* New emoticon set directory */
$this->request['new_emo_set'] = preg_replace('/[^a-zA-Z0-9\\-_]/', "", $this->request['new_emo_set']);
/* Create the new set */
if ($this->request['new_emo_set']) {
$emo_set_dir = trim($this->request['new_emo_set']);
/* Check to see if the directory already exists */
if (file_exists(DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $emo_set_dir)) {
$this->registry->output->global_error = sprintf($this->lang->words['emo_already'], $emo_set_dir);
return $this->emoticonsPackSplash();
}
/* Create the directory */
if (@mkdir(DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $emo_set_dir, IPS_FOLDER_PERMISSION)) {
@chmod(DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $emo_set_dir, IPS_FOLDER_PERMISSION);
@file_put_contents(DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $emo_set_dir . '/index.html', '');
} else {
$this->registry->output->global_error = $this->lang->words['emo_ftp'];
return $this->emoticonsPackSplash();
}
}
/* Get a list of current emoticons, if we are not overwriting */
$emo_image = array();
$emo_typed = array();
if ($this->request['overwrite'] != 1) {
$this->DB->build(array('select' => '*', 'from' => 'emoticons', 'where' => "emo_set='" . $emo_set_dir . "'"));
$this->DB->execute();
while ($r = $this->DB->fetch()) {
$emo_image[$r['image']] = 1;
$emo_typed[$r['typed']] = 1;
}
}
/* Loop through the emoticons in the xml document */
foreach ($xml->fetchElements('emoticon') as $emoticon) {
$entry = $xml->fetchElementsFromRecord($emoticon);
/* Emoticon Data */
$image = $entry['image'];
$typed = $entry['typed'];
$click = $entry['clickable'];
/* Skip if we're not overwriting */
if ($emo_image[$image] or $emo_typed[$typed]) {
continue;
}
//.........这里部分代码省略.........
示例2: exportAllApps
/**
* Export all apps: Wrapper function really. Yes. It is.
*
* @access public
* @return array Array of messages or errors
*/
public function exportAllApps()
{
$messages = array();
$errors = array();
foreach (ipsRegistry::$applications as $app_dir => $app_data) {
@unlink(IPSLib::getAppDir($app_dir) . '/xml/' . $app_dir . '_settings.xml');
if (!file_exists(IPSLib::getAppDir($app_dir) . '/xml')) {
$errors[] = "Error: " . IPSLib::getAppDir($app_dir) . "/xml/ does not exist";
continue;
} else {
if (!IPSLib::isWritable(IPSLib::getAppDir($app_dir) . '/xml')) {
if (!@chmod(IPSLib::isWritable(IPSLib::getAppDir($app_dir) . '/xml', 0755))) {
$errors[] = "Error: " . IPSLib::getAppDir($app_dir) . "/xml/ is not writeable";
continue;
}
} else {
if (file_exists(IPSLib::getAppDir($app_dir) . '/xml/' . $app_dir . '_settings.xml') and !IPSLib::isWritable(IPSLib::getAppDir($app_dir) . '/xml/' . $app_dir . '_settings.xml')) {
$errors[] = "Error: " . IPSLib::getAppDir($app_dir) . '/xml/' . $app_dir . "_settings.xml is not writeable";
continue;
}
}
}
$this->_exportXML($app_dir);
$messages[] = $app_data['app_title'] . " Settings written into the application's XML directory";
/* In dev time stamp? */
if (IN_DEV) {
$cache = $this->caches['indev'];
$cache['import']['settings'][$app_dir] = time();
$this->cache->setCache('indev', $cache, array('donow' => 1, 'array' => 1));
}
}
return $errors ? $errors : $messages;
}
示例3: _writePHPTemplate
/**
* Write a PHP template cache file
*
* @access protected
* @param int Skin set ID
* @param string Group Name
* @param string Template content
* @return array Array of messages
*/
protected function _writePHPTemplate($setID, $groupName, $content)
{
//-----------------------------------------
// INIT
//-----------------------------------------
$return = 0;
$good_to_go = 0;
if (!SAFE_MODE_ON) {
$good_to_go = 1;
if (IPSLib::isWritable(IPS_CACHE_PATH . 'cache/skin_cache/') === TRUE) {
$good_to_go = 1;
if (!is_dir(IPS_CACHE_PATH . 'cache/skin_cache/cacheid_' . $setID)) {
if (!@mkdir(IPS_CACHE_PATH . 'cache/skin_cache/cacheid_' . $setID, IPS_FOLDER_PERMISSION)) {
$this->_addErrorMessage(sprintf($this->lang->words['fatalnotemplatew'], $setID));
return;
} else {
@file_put_contents(IPS_CACHE_PATH . 'cache/skin_cache/cacheid_' . $setID . '/index.html', '');
@chmod(IPS_CACHE_PATH . 'cache/skin_cache/cacheid_' . $setID, IPS_FOLDER_PERMISSION);
$good_to_go = 1;
}
} else {
if (is_file(IPS_CACHE_PATH . 'cache/skin_cache/cacheid_' . $setID . '/' . $groupName . '.php')) {
if (IPSLib::isWritable(IPS_CACHE_PATH . 'cache/skin_cache/cacheid_' . $setID . '/' . $groupName . '.php') !== TRUE) {
$this->_addErrorMessage(sprintf($this->lang->words['templatefilenowrite'], $setID, $groupName));
$good_to_go = 0;
} else {
$good_to_go = 1;
}
} else {
$good_to_go = 1;
}
}
} else {
$this->_addErrorMessage(sprintf($this->lang->words['fatalnotemplsafe'], IPS_CACHE_PATH));
}
}
//-----------------------------------------
// Write...
//-----------------------------------------
if ($good_to_go) {
if ($FH = @fopen(IPS_CACHE_PATH . 'cache/skin_cache/cacheid_' . $setID . '/' . $groupName . '.php', 'w')) {
fwrite($FH, $content, strlen($content));
fclose($FH);
@chmod(IPS_CACHE_PATH . 'cache/skin_cache/cacheid_' . $setID . '/' . $groupName . '.php', IPS_FILE_PERMISSION);
$this->_addMessage($this->lang->words['basicwrittenpre'] . "skin_cache/cacheid_{$setID}/{$groupName}.php");
} else {
$this->_addErrorMessage(sprintf($this->lang->words['templatefilenowrite'], $setID, $groupName));
}
}
}
示例4: exportTemplateAppXML
/**
* Export template XML into app dirs
*
* @access public
* @param string App to export into
* @param int [Set ID (0/root if omitted)]
* @param bool Include root bits in any XML export. Default is true
* @return void
*/
public function exportTemplateAppXML($app_dir, $setID = 0, $setOnly = TRUE)
{
//-----------------------------------------
// Get it
//-----------------------------------------
$setData = $this->fetchSkinData($setID);
$xml = $this->generateTemplateXML($app_dir, $setID, $setOnly);
//-----------------------------------------
// Attempt to write...
//-----------------------------------------
/* Set file name */
$file = IPSLib::getAppDir($app_dir) . '/xml/' . $app_dir . '_' . $setData['set_key'] . '_templates.xml';
/* Attempt to unlink first */
@unlink($file);
if ($xml) {
if (file_exists($file) and !IPSLib::isWritable($file)) {
$this->_addErrorMessage($file . ' is not writeable');
return FALSE;
}
file_put_contents($file, $xml);
$this->_addMessage("Templates for " . $app_dir . ' - ' . $setData['set_key'] . " created");
} else {
//$this->_addMessage( "XML for " . $app_dir . ' - ' . $setData['set_key'] . " could not be generated" );
}
}
示例5: _writePHPTemplate
/**
* Write a PHP template cache file
*
* @access protected
* @param int Skin set ID
* @param string Group Name
* @param string Template content
* @return array Array of messages
*/
protected function _writePHPTemplate($setID, $groupName, $content)
{
//-----------------------------------------
// INIT
//-----------------------------------------
$return = 0;
$good_to_go = 0;
if (!SAFE_MODE_ON) {
$good_to_go = 1;
if (IPSLib::isWritable(IPS_CACHE_PATH . 'cache/skin_cache/') === TRUE) {
$good_to_go = 1;
if (!is_dir(IPS_CACHE_PATH . 'cache/skin_cache/cacheid_' . $setID)) {
if (!@mkdir(IPS_CACHE_PATH . 'cache/skin_cache/cacheid_' . $setID, 0777)) {
$this->_addErrorMessage("Fatal! cannot create: cache/skin_cache/cacheid_{$setID}/");
return;
} else {
@file_put_contents(IPS_CACHE_PATH . 'cache/skin_cache/cacheid_' . $setID . '/index.html', '');
@chmod(IPS_CACHE_PATH . 'cache/skin_cache/cacheid_' . $setID, 0777);
$good_to_go = 1;
}
} else {
if (file_exists(IPS_CACHE_PATH . 'cache/skin_cache/cacheid_' . $setID . '/' . $groupName . '.php')) {
if (IPSLib::isWritable(IPS_CACHE_PATH . 'cache/skin_cache/cacheid_' . $setID . '/' . $groupName . '.php') !== TRUE) {
$this->_addErrorMessage("cache/skin_cache/cacheid_{$setID}/{$groupName}.php not writeable - cannot cache to PHP file");
$good_to_go = 0;
} else {
$good_to_go = 1;
}
} else {
$good_to_go = 1;
}
}
} else {
$this->_addErrorMessage("Fatal! " . IPS_CACHE_PATH . "cache/skin_cache not writeable - please change permissions via FTP or turn on Safe Mode");
}
}
//-----------------------------------------
// Write...
//-----------------------------------------
if ($good_to_go) {
if ($FH = @fopen(IPS_CACHE_PATH . 'cache/skin_cache/cacheid_' . $setID . '/' . $groupName . '.php', 'w')) {
fwrite($FH, $content, strlen($content));
fclose($FH);
@chmod(IPS_CACHE_PATH . 'cache/skin_cache/cacheid_' . $setID . '/' . $groupName . '.php', 0777);
$this->_addMessage("Wrote skin_cache/cacheid_{$setID}/{$groupName}.php");
} else {
$this->_addErrorMessage("cache/skin_cache/cacheid_{$setID}/{$groupName}.php not writeable - cannot cache to PHP file");
}
}
}
示例6: exportTemplateAppXML
/**
* Export template XML into app dirs
*
* @access public
* @param string App to export into
* @param int [Set ID (0/root if omitted)]
* @param bool Include root bits in any XML export. Default is true
* @return @e void
*/
public function exportTemplateAppXML($app_dir, $setID = 0, $setOnly = TRUE)
{
//-----------------------------------------
// Get it
//-----------------------------------------
$setData = $this->fetchSkinData($setID);
$xml = $this->generateTemplateXML($app_dir, $setID, $setOnly);
//-----------------------------------------
// Attempt to write...
//-----------------------------------------
/* Set file name */
$file = IPSLib::getAppDir($app_dir) . '/xml/' . $app_dir . '_' . $setData['set_key'] . '_templates.xml';
/* Attempt to unlink first */
@unlink($file);
if ($xml) {
if (is_file($file) and !IPSLib::isWritable($file)) {
$this->_addErrorMessage($file . ' ' . $this->lang->words['css_isnotwritable']);
return FALSE;
}
file_put_contents($file, $xml);
$this->_addMessage(sprintf($this->lang->words['templatescreatedmsg'], $app_dir, $setData['set_key']));
}
}