本文整理汇总了PHP中XenForo_Helper_File::makeWritableByFtpUser方法的典型用法代码示例。如果您正苦于以下问题:PHP XenForo_Helper_File::makeWritableByFtpUser方法的具体用法?PHP XenForo_Helper_File::makeWritableByFtpUser怎么用?PHP XenForo_Helper_File::makeWritableByFtpUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XenForo_Helper_File
的用法示例。
在下文中一共展示了XenForo_Helper_File::makeWritableByFtpUser方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionConfig
public function actionConfig()
{
$config = $this->_input->filterSingle('config', XenForo_Input::JSON_ARRAY);
if ($this->_request->isPost()) {
$db = $this->_testConfig($config, $error);
if ($error) {
return $this->responseError($error);
}
$configFile = XenForo_Application::getInstance()->getConfigDir() . '/config.php';
if (!file_exists($configFile) && is_writable(dirname($configFile))) {
try {
file_put_contents($configFile, $this->_getInstallModel()->generateConfig($config));
XenForo_Helper_File::makeWritableByFtpUser($configFile);
$written = true;
} catch (Exception $e) {
$written = false;
}
} else {
$written = false;
}
$viewParams = array('written' => $written, 'configFile' => $configFile, 'config' => $config);
return $this->_getInstallWrapper(1, $this->responseView('XenForo_Install_View_Install_ConfigGenerated', 'install_config_generated', $viewParams));
} else {
return $this->_getInstallWrapper(1, $this->responseView('XenForo_Install_View_Install_Config', 'install_config'));
}
}
示例2: _createFiles
protected function _createFiles(sonnb_XenGallery_Model_ContentData $model, $filePath, $contentData, $useTemp = true, $isVideo = false)
{
$smallThumbFile = $model->getContentDataSmallThumbnailFile($contentData);
$mediumThumbFile = $model->getContentDataMediumThumbnailFile($contentData);
$largeThumbFile = $model->getContentDataLargeThumbnailFile($contentData);
$originalFile = $model->getContentDataFile($contentData);
if ($useTemp) {
$filename = tempnam(XenForo_Helper_File::getTempDir(), 'xf');
@copy($filePath, $filename);
} else {
$filename = $filePath;
}
if ($isVideo === false && $originalFile) {
$directory = dirname($originalFile);
if (XenForo_Helper_File::createDirectory($directory, true)) {
@copy($filename, $originalFile);
XenForo_Helper_File::makeWritableByFtpUser($originalFile);
} else {
return false;
}
}
if ($isVideo === false) {
$ext = sonnb_XenGallery_Model_ContentData::$typeMap[$contentData['extension']];
} else {
$ext = sonnb_XenGallery_Model_ContentData::$typeMap[sonnb_XenGallery_Model_VideoData::$videoEmbedExtension];
}
$model->createContentDataThumbnailFile($filename, $largeThumbFile, $ext, sonnb_XenGallery_Model_ContentData::CONTENT_FILE_TYPE_LARGE);
$model->createContentDataThumbnailFile($largeThumbFile, $mediumThumbFile, $ext, sonnb_XenGallery_Model_ContentData::CONTENT_FILE_TYPE_MEDIUM);
$model->createContentDataThumbnailFile($largeThumbFile, $smallThumbFile, $ext, sonnb_XenGallery_Model_ContentData::CONTENT_FILE_TYPE_SMALL);
@unlink($filename);
return true;
}
示例3: _copyFile
/**
* Copies the specified file.
*
* @param string $source
* @param string $destination
*
* @return boolean
*/
protected function _copyFile($source, $destination)
{
$success = copy($source, $destination);
if ($success) {
XenForo_Helper_File::makeWritableByFtpUser($destination);
}
return $success;
}
示例4: _install_1
protected function _install_1()
{
$targetLoc = XenForo_Helper_File::getExternalDataPath() . "/sitemaps";
if (!is_dir($targetLoc)) {
XenForo_Helper_File::createDirectory($targetLoc);
XenForo_Helper_File::makeWritableByFtpUser($targetLoc);
}
}
示例5: _saveTemplate
/**
* @see XenForo_Template_FileHandler::save
*/
protected function _saveTemplate($title, $styleId, $languageId, $template)
{
$this->_createTemplateDirectory();
$fileName = $this->_getFileName($title, $styleId, $languageId);
file_put_contents($fileName, $template);
XenForo_Helper_File::makeWritableByFtpUser($fileName);
$this->_postTemplateChange($fileName, 'write');
return $fileName;
}
示例6: createDirectory
/**
* Recursively creates directories until the full path is created.
*
* @param string $path Directory path to create
* @param boolean $createIndexHtml If true, creates an index.html file in the created directory
*
* @return boolean True on success
*/
public static function createDirectory($path, $createIndexHtml = false)
{
$path = preg_replace('#/+$#', '', $path);
if (file_exists($path) && is_dir($path)) {
return true;
}
$path = str_replace('\\', '/', $path);
$parts = explode('/', $path);
$pathPartCount = count($parts);
$partialPath = '';
$rootDir = XenForo_Application::getInstance()->getRootDir();
// find the "lowest" part that exists (and is a dir)...
for ($i = $pathPartCount - 1; $i >= 0; $i--) {
$partialPath = implode('/', array_slice($parts, 0, $i + 1));
if ($partialPath == $rootDir) {
return false;
// can't go above the root dir
}
if (file_exists($partialPath)) {
if (!is_dir($partialPath)) {
return false;
} else {
break;
}
}
}
if ($i < 0) {
return false;
}
$i++;
// skip over the last entry (as it exists)
// ... now create directories for anything below it
for (; $i < $pathPartCount; $i++) {
$partialPath .= '/' . $parts[$i];
if (!mkdir($partialPath)) {
return false;
} else {
if ($createIndexHtml) {
XenForo_Helper_File::makeWritableByFtpUser($partialPath);
$fp = @fopen($partialPath . '/index.html', 'w');
if ($fp) {
fwrite($fp, ' ');
fclose($fp);
XenForo_Helper_File::makeWritableByFtpUser($partialPath . '/index.html');
}
}
}
}
return true;
}
示例7: filePutContents
public static function filePutContents($path, $contents)
{
$dir = dirname($path);
XenForo_Helper_File::createDirectory($dir, true);
$lines = explode("\n", $contents);
$linesTrimmed = array();
foreach ($lines as $line) {
if (trim($line) == '') {
$linesTrimmed[] = '';
} else {
$linesTrimmed[] = $line;
}
}
file_put_contents($path, implode("\n", $linesTrimmed));
XenForo_Helper_File::makeWritableByFtpUser($path);
}
示例8: regeneratePublicHtml
/**
* @param mixed $overrideMotd set motd pre-cache-update
* @param mixed $unsync if not due to new message set true
*/
public function regeneratePublicHtml($overrideMotd = false, $unsync = false)
{
$viewParams = array();
$options = XenForo_Application::get('options');
$visitor = XenForo_Visitor::getInstance();
if ($options->dark_taigachat_speedmode == 'Disabled') {
return;
}
if ($unsync) {
/** @var XenForo_Model_DataRegistry */
$registryModel = $this->getModelFromCache('XenForo_Model_DataRegistry');
$lastUnsync = $registryModel->get('dark_taigachat_unsync');
if (!empty($lastUnsync) && $lastUnsync > time() - 30) {
return;
}
$registryModel->set('dark_taigachat_unsync', time());
}
// swap timezone to default temporarily
$oldTimeZone = XenForo_Locale::getDefaultTimeZone()->getName();
XenForo_Locale::setDefaultTimeZone($options->guestTimeZone);
$messages = $this->getMessages(1, array("page" => 1, "perPage" => $options->dark_taigachat_fullperpage, "lastRefresh" => 0));
$messagesMini = $this->getMessages(1, array("page" => 1, "perPage" => $options->dark_taigachat_sidebarperpage, "lastRefresh" => 0));
$messageIds = $this->getMessageIds(1, array("page" => 1, "perPage" => $options->dark_taigachat_fullperpage, "lastRefresh" => 0));
$bbCodeParser = new XenForo_BbCode_Parser(XenForo_BbCode_Formatter_Base::create('Base'));
$motd = new XenForo_BbCode_TextWrapper($overrideMotd !== false ? $overrideMotd : $options->dark_taigachat_motd, $bbCodeParser);
$onlineUsersTaiga = null;
if ($options->dark_taigachat_sidebar) {
$onlineUsersTaiga = $this->getActivityUserList($visitor->toArray());
}
$viewParams = array('taigachat' => array("messages" => $messages, "sidebar" => false, "messageIds" => $messageIds, "editside" => $options->dark_taigachat_editside, "timedisplay" => $options->dark_taigachat_timedisplay, "miniavatar" => $options->dark_taigachat_miniavatar, "lastrefresh" => 0, "numInChat" => $this->getActivityUserCount(), "motd" => $motd, "online" => $onlineUsersTaiga, "route" => $options->dark_taigachat_route, "publichtml" => true, 'canView' => true, 'enabled' => true));
$dep = new Dark_TaigaChat_Dependencies();
$dep->preLoadData();
$dep->preloadTemplate('dark_taigachat_list');
$viewRenderer = new Dark_TaigaChat_ViewRenderer_JsonInternal($dep, new Zend_Controller_Response_Http(), new Zend_Controller_Request_Http());
if (!file_exists($this->getDataPath() . '/taigachat')) {
XenForo_Helper_File::createDirectory($this->getDataPath() . '/taigachat', true);
}
$innerContent = $viewRenderer->renderView('Dark_TaigaChat_ViewPublic_TaigaChat_List', $viewParams, 'dark_taigachat_list');
$filename = $this->getDataPath() . '/taigachat/messages.html';
$yayForNoLocking = mt_rand(0, 10000000);
if (file_put_contents($filename . ".{$yayForNoLocking}.tmp", $innerContent, LOCK_EX) === false) {
throw new XenForo_Exception("Failed writing TaigaChat messages to {$filename}.{$yayForNoLocking}.tmp");
}
if (!@rename($filename . ".{$yayForNoLocking}.tmp", $filename)) {
@unlink($filename . ".{$yayForNoLocking}.tmp");
}
XenForo_Helper_File::makeWritableByFtpUser($filename);
$viewParams['taigachat']['messages'] = $messagesMini;
$viewParams['taigachat']['sidebar'] = true;
$innerContent = $viewRenderer->renderView('Dark_TaigaChat_ViewPublic_TaigaChat_List', $viewParams, 'dark_taigachat_list');
$filename = $this->getDataPath() . '/taigachat/messagesmini.html';
if (file_put_contents($filename . ".{$yayForNoLocking}.tmp", $innerContent, LOCK_EX) === false) {
throw new XenForo_Exception("Failed writing TaigaChat messages to {$filename}.{$yayForNoLocking}.tmp");
}
// The only reason this could fail is if the file is being hammered, hence no worries ignoring failure
if (!@rename($filename . ".{$yayForNoLocking}.tmp", $filename)) {
@unlink($filename . ".{$yayForNoLocking}.tmp");
}
XenForo_Helper_File::makeWritableByFtpUser($filename);
// put things back to how they was
XenForo_Locale::setDefaultTimeZone($oldTimeZone);
}
示例9: makeWritableByFtpUser
public static function makeWritableByFtpUser($file)
{
return XenForo_Helper_File::makeWritableByFtpUser($file);
}
示例10: _moveFile
/**
* Moves the specified file. If it's an uploaded file, it will be moved with
* move_uploaded_file().
*
* @param string $source
* @param string $destination
*
* @return boolean
*/
protected function _moveFile($source, $destination)
{
if (is_uploaded_file($source)) {
$success = move_uploaded_file($source, $destination);
} else {
$success = rename($source, $destination);
}
if ($success) {
XenForo_Helper_File::makeWritableByFtpUser($destination);
}
return $success;
}
示例11: save
public function save($filename)
{
XenForo_Helper_File::makeWritableByFtpUser(dirname($filename));
file_put_contents($filename, $this->_dom->saveXml());
}
示例12: _writeImage
/**
* Writes out an image.
*
* @param integer $contentId
* @param string $size Size code
* @param string $tempFile Temporary image file. Will be moved.
*
* @return boolean
*/
protected function _writeImage($contentId, $size, $tempFile)
{
if (!in_array($size, array_keys(self::$_sizes))) {
throw new XenForo_Exception('Invalid image size.');
}
$filePath = $this->getImageFilePath($contentId, $size);
$directory = dirname($filePath);
if (XenForo_Helper_File::createDirectory($directory, true) && is_writable($directory)) {
if (file_exists($filePath)) {
unlink($filePath);
}
$success = rename($tempFile, $filePath);
if ($success) {
XenForo_Helper_File::makeWritableByFtpUser($filePath);
}
return $success;
} else {
return false;
}
}
示例13: writeInstallLock
public function writeInstallLock()
{
$fileName = XenForo_Helper_File::getInternalDataPath() . '/install-lock.php';
$fp = fopen($fileName, 'w');
fwrite($fp, '<?php header(\'Location: ../index.php\'); /* Installed: ' . date(DATE_RFC822) . ' */');
fclose($fp);
XenForo_Helper_File::makeWritableByFtpUser($fileName);
}
示例14: _updateAddOnFiles
private static function _updateAddOnFiles($addOnId, $tempFile)
{
$tempDir = $tempFile . '_extracted';
XenForo_Helper_File::createDirectory($tempDir, false);
XenForo_Helper_File::makeWritableByFtpUser($tempDir);
$decompress = new Zend_Filter_Decompress(array('adapter' => 'Zip', 'options' => array('target' => $tempDir)));
if (!$decompress->filter($tempFile)) {
throw new XenForo_Exception('Unable to extract add-on package.', true);
}
$uploadDir = sprintf('%s/upload', $tempDir);
if (!is_dir($uploadDir)) {
throw new XenForo_Exception('Unsupported add-on package (no "upload" directory found).', true);
}
$xfDir = dirname(XenForo_Autoloader::getInstance()->getRootDir());
$files = self::_verifyAddOnFiles($uploadDir, $xfDir);
$xmlPath = self::_findXmlPath($addOnId, $tempDir, $xfDir, $files);
self::_moveAddOnFiles($uploadDir, $xfDir, $files);
return $xmlPath;
}
示例15: safeRename
/**
* Performs a cross-stream/device safe rename by falling back
* to a copy+delete if needed.
*
* @param string $source
* @param string $destination
*
* @return bool
*/
public static function safeRename($source, $destination)
{
try {
if (is_uploaded_file($source)) {
$success = move_uploaded_file($source, $destination);
} else {
$success = rename($source, $destination);
}
} catch (Exception $e) {
// possibly a perm problem, but may be an issue moving across streams, so copy+delete instead
$success = false;
}
if (!$success) {
$success = copy($source, $destination);
if ($success) {
@unlink($source);
}
}
if ($success) {
XenForo_Helper_File::makeWritableByFtpUser($destination);
}
return $success;
}