public function getIconFilePath($nodeId, $number, $externalDataPath = null) { if ($externalDataPath === null) { $externalDataPath = XenForo_Helper_File::getExternalDataPath(); } return sprintf('%s/nodeIcons/' . $nodeId . '_' . $number . '.jpg', $externalDataPath); }
public function deleteThumb($mediaID) { $targetLoc = XenForo_Helper_File::getExternalDataPath() . '/media/' . $mediaID . '.jpg'; if (file_exists($targetLoc)) { unlink($targetLoc); } }
/** * @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(array("page" => 1, "perPage" => $options->dark_taigachat_fullperpage, "lastRefresh" => 0)); $messagesMini = $this->getMessages(array("page" => 1, "perPage" => $options->dark_taigachat_sidebarperpage, "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 = $this->getActivityUserList($visitor->toArray()); $viewParams = array('taigachat' => array("messages" => $messages, "sidebar" => false, "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(); $viewRenderer = new Dark_TaigaChat_ViewRenderer_JsonInternal($dep, new Zend_Controller_Response_Http(), new Zend_Controller_Request_Http()); if (!file_exists(XenForo_Helper_File::getExternalDataPath() . '/taigachat')) { XenForo_Helper_File::createDirectory(XenForo_Helper_File::getExternalDataPath() . '/taigachat', true); } $innerContent = $viewRenderer->renderView('Dark_TaigaChat_ViewPublic_TaigaChat_List', $viewParams, 'dark_taigachat_list'); $filename = XenForo_Helper_File::getExternalDataPath() . '/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}.tmp.{$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; //$viewParams['taigachat']['online'] = null; $innerContent = $viewRenderer->renderView('Dark_TaigaChat_ViewPublic_TaigaChat_List', $viewParams, 'dark_taigachat_list'); $filename = XenForo_Helper_File::getExternalDataPath() . '/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 timezone back to how it was XenForo_Locale::setDefaultTimeZone($oldTimeZone); }
public function actionIndex() { $file = XenForo_Helper_File::getExternalDataPath() . '/sitemaps/index.xml'; if (!file_exists($file)) { $this->getModelFromCache('EWRutiles_Sitemap_Model_Sitemap')->buildIndex(); } echo file_get_contents($file); exit; }
public function getDataPath() { $options = XenForo_Application::get('options'); if (!$options->dark_taigachat_externaldata) { return XenForo_Helper_File::getExternalDataPath(); } else { return 'data'; } }
protected function _uninstall_0() { $targetLoc = glob(XenForo_Helper_File::getExternalDataPath() . "/sitemaps/*.xml*"); foreach ($targetLoc as $file) { unlink($file); } $targetLoc = XenForo_Helper_File::getExternalDataPath() . "/sitemaps"; if (is_dir($targetLoc)) { rmdir($targetLoc); } }
public function buildRSSbyMedia($document, $media, $local = false) { $itm_node = $document->createElement('item'); $itm_node->appendChild($document->createElement('pubDate', date("r", $media['media_date']))); $itm_node->appendChild($document->createElement('title', substr(htmlspecialchars($media['media_title']), 0, 100))); $itm_node->appendChild($document->createElement('description', substr(htmlspecialchars(XenForo_Helper_String::bbCodeStrip(str_replace("\n", " ", $media['media_description']))), 0, 2048))); $itm_node->appendChild($document->createElement('link', XenForo_Link::buildPublicLink('full:media', $media))); $itm_node->appendChild($document->createElement('guid', XenForo_Link::buildPublicLink('full:media', $media))); $itm_node->appendChild($document->createElement('comments', XenForo_Link::buildPublicLink('full:media/comments', $media))); $itm_node->appendChild($cat_node = $document->createElement('category', htmlspecialchars('+' . $media['category_name']))); $cat_node->appendChild($dom_node = $document->createAttribute('domain')); $dom_node->appendChild($document->createTextNode(XenForo_Link::buildPublicLink('full:media/category', $media))); $itm_node->appendChild($usr_node = $document->createElement('category', htmlspecialchars('+' . $media['username']))); $usr_node->appendChild($dom_node = $document->createAttribute('domain')); $dom_node->appendChild($document->createTextNode(XenForo_Link::buildPublicLink('full:media/user', $media))); if (trim($media['media_keywords'])) { foreach (explode(',', $media['media_keywords']) as $tag) { $itm_node->appendChild($tag_node = $document->createElement('category', htmlspecialchars(trim($tag)))); $tag_node->appendChild($dom_node = $document->createAttribute('domain')); $dom_node->appendChild($document->createTextNode(XenForo_Link::buildPublicLink('full:media/keyword', array('keyword_text' => trim($tag))))); } } if ($local && $media['service_feed'] == 'null') { $itm_node->appendChild($thu_node = $document->createElement('enclosure')); $thu_node->appendChild($url_node = $document->createAttribute('url')); $url_node->appendChild($document->createTextNode($media['content_loc'])); $thu_node->appendChild($len_node = $document->createAttribute('length')); $len_node->appendChild($document->createTextNode(intval(@filesize(XenForo_Helper_File::getExternalDataPath() . '/local/' . $media['service_value'])))); } else { $itm_node->appendChild($thu_node = $document->createElement('enclosure')); $thu_node->appendChild($url_node = $document->createAttribute('url')); $url_node->appendChild($document->createTextNode(XenForo_Application::get('options')->boardUrl . '/data/media/' . $media['media_id'] . '.jpg')); $thu_node->appendChild($len_node = $document->createAttribute('length')); $len_node->appendChild($document->createTextNode(intval(@filesize(XenForo_Helper_File::getExternalDataPath() . '/media/' . $media['thumbnail'])))); $thu_node->appendChild($typ_node = $document->createAttribute('type')); $typ_node->appendChild($document->createTextNode('image/jpeg')); } $itm_node->appendChild($document->createElement('dc:creator', htmlspecialchars($media['username']))); return $itm_node; }
public function getRequirementErrors(Zend_Db_Adapter_Abstract $db = null) { $errors = array(); $phpVersion = phpversion(); if (version_compare($phpVersion, '5.2.11', '<')) { $errors['phpVersion'] = new XenForo_Phrase('php_version_x_does_not_meet_requirements', array('version' => $phpVersion)); } $safeModeIni = @ini_get('safe_mode'); if (is_bool($safeModeIni) || intval($safeModeIni)) { $isSafeMode = (bool) $safeModeIni; } else { $isSafeMode = in_array(strtolower($safeModeIni), array('on', 'yes', 'true')); } if ($isSafeMode) { $errors['safe_mode'] = new XenForo_Phrase('php_must_not_be_in_safe_mode'); } if (!function_exists('mysqli_connect')) { $errors['mysqlPhp'] = new XenForo_Phrase('required_php_extension_x_not_found', array('extension' => 'MySQLi')); } if (!function_exists('gd_info')) { $errors['gd'] = new XenForo_Phrase('required_php_extension_x_not_found', array('extension' => 'GD')); } else { if (!function_exists('imagecreatefromjpeg')) { $errors['gdJpeg'] = new XenForo_Phrase('gd_jpeg_support_missing'); } } if (!function_exists('iconv')) { $errors['iconv'] = new XenForo_Phrase('required_php_extension_x_not_found', array('extension' => 'Iconv')); } if (!function_exists('ctype_alnum')) { $errors['ctype'] = new XenForo_Phrase('required_php_extension_x_not_found', array('extension' => 'Ctype')); } if (!function_exists('preg_replace')) { $errors['pcre'] = new XenForo_Phrase('required_php_extension_x_not_found', array('extension' => 'PCRE')); } else { try { preg_match('/./u', 'x'); } catch (Exception $e) { $errors['pcre'] = new XenForo_Phrase('pcre_unicode_support_missing'); } } if (!function_exists('spl_autoload_register')) { $errors['spl'] = new XenForo_Phrase('required_php_extension_x_not_found', array('extension' => 'SPL')); } if (!function_exists('json_encode')) { $errors['json'] = new XenForo_Phrase('required_php_extension_x_not_found', array('extension' => 'JSON')); } if (!class_exists('DOMDocument') || !class_exists('SimpleXMLElement')) { $errors['xml'] = new XenForo_Phrase('required_php_xml_extensions_not_found'); } if ($db) { $mySqlVersion = $db->getServerVersion(); if ($mySqlVersion && intval($mySqlVersion) < 5) { $errors['mysqlVersion'] = new XenForo_Phrase('mysql_version_x_does_not_meet_requirements', array('version' => $mySqlVersion)); } } $dataDir = XenForo_Helper_File::getExternalDataPath(); if (!is_dir($dataDir) || !is_writable($dataDir)) { $errors['dataDir'] = new XenForo_Phrase('directory_x_must_be_writable', array('directory' => $dataDir)); } else { foreach (scandir($dataDir) as $file) { if ($file[0] == '.') { continue; } $fullPath = "{$dataDir}/{$file}"; if (is_dir($fullPath) && !is_writable($fullPath)) { $errors['dataDir'] = new XenForo_Phrase('all_directories_under_x_must_be_writable', array('directory' => $dataDir)); } } } $internalDataDir = XenForo_Helper_File::getInternalDataPath(); if (!is_dir($internalDataDir) || !is_writable($internalDataDir)) { $errors['internalDataDir'] = new XenForo_Phrase('directory_x_must_be_writable', array('directory' => $internalDataDir)); } else { foreach (scandir($internalDataDir) as $file) { if ($file[0] == '.') { continue; } $fullPath = "{$internalDataDir}/{$file}"; if (is_dir($fullPath) && !is_writable($fullPath)) { $errors['internalDataDir'] = new XenForo_Phrase('all_directories_under_x_must_be_writable', array('directory' => $internalDataDir)); } } } return $errors; }
/** * Get the file path to an image. * * @param integer $contentId * @param string $size Size code * * @return string */ public function getImageFilePath($contentId, $size) { return sprintf('%s/threads/%s/%d/%s.jpg', XenForo_Helper_File::getExternalDataPath(), $size, floor($contentId / 100), $contentId); }
public function actionUpdate() { //######################################## // Update each attachment because // the pixel width is over maxWidth // setting in options. //######################################## // get user group permissions if (!XenForo_Visitor::getInstance()->hasPermission('imageResizerGroupID', 'imageResizerID')) { throw $this->getNoPermissionResponseException(); } // get options from Admin CP -> Options -> Image Resizer -> Default Image Processor $imPecl = XenForo_Application::get('options')->imageLibrary['class']; // check option if ($imPecl != 'imPecl') { return $this->responseError(new XenForo_Phrase('imageresizer_imagemagick_with_pecl_required')); } // get options from Admin CP -> Options -> Image Resizer -> Maximum Width $maximumWidth = XenForo_Application::get('options')->imageResizerMaximumWidth; // check option if ($maximumWidth == 0) { return $this->responseError(new XenForo_Phrase('imageresizer_maximum_width_in_options_not_set')); } // get options from Admin CP -> Options -> Image Resizer -> Maximum Height $maximumHeight = XenForo_Application::get('options')->imageResizerMaximumHeight; // check option if ($maximumHeight == 0) { return $this->responseError(new XenForo_Phrase('imageresizer_maximum_height_in_options_not_set')); } // get limit $limit = $this->_input->filterSingle('limit', XenForo_Input::UINT); // verify limit set if ($limit == '') { return $this->responseError(new XenForo_Phrase('imageresizer_limit_switch_missing_in_url')); } //######################################## // start update process //######################################## // get internalDataPath $internalDataPath = XenForo_Helper_File::getInternalDataPath(); // get data path $externalDataPath = XenForo_Helper_File::getExternalDataPath(); // get database $db = XenForo_Application::get('db'); // run query $attachments = $db->fetchAll("\n\t\tSELECT xf_attachment_data.*, xf_attachment.*, xf_user.username\n\t\tFROM xf_attachment_data\n\t\tINNER JOIN xf_attachment ON xf_attachment.data_id = xf_attachment_data.data_id\n\t\tINNER JOIN xf_user ON xf_user.user_id = xf_attachment_data.user_id\n\t\tWHERE xf_attachment.unassociated = 0\n\t\tAND xf_attachment.content_type = 'post'\n\t\tAND\t(xf_attachment_data.width > " . $maximumWidth . "\n\t\tOR xf_attachment_data.height > " . $maximumHeight . ")\n\t\tORDER BY xf_attachment_data.width DESC, xf_attachment_data.data_id DESC\n\t\tLIMIT " . $limit . "\n\t\t"); foreach ($attachments as $k => $v) { // clear variable $skip = ''; //##################################### // define last folder name // 0-999 are stored in the 0 directory // 1000-1999 stored in the 1 directory etc //##################################### $dataId = $v['data_id']; $fileHash = $v['file_hash']; $lastFolder = floor($dataId / 1000); //##################################### // define attachment full path //##################################### // attachment path $attachmentFullPath = $internalDataPath . '/attachments/' . $lastFolder . '/' . $dataId . '-' . $fileHash . '.data'; // throw error if file missing if (!file_exists($attachmentFullPath)) { throw new XenForo_Exception(new XenForo_Phrase('imageresizer_attachment_missing_from_file_directory') . ' ' . $attachmentFullPath, true); } //##################################### // get file information //##################################### // get size $filesize = filesize($attachmentFullPath); // get dimensions list($width, $height) = getimagesize($attachmentFullPath); //##################################### // If file information is different // than information in database, update // database first. //##################################### // verify database information is correct if ($filesize != $v['file_size'] or $width != $v['width'] or $height != $v['height']) { // run query $db->query(' UPDATE xf_attachment_data SET file_size = "' . $filesize . '", width = "' . $width . '", height = "' . $height . '" WHERE data_id = ? ', $dataId); // skip resize $skip = 'yes'; } // resize if required if ($skip != 'yes') { //##################################### // Database information is correct, // resize image. //##################################### // get options from Admin CP -> Options -> Image Resizer -> Maximum Width $maximumWidth = XenForo_Application::get('options')->imageResizerMaximumWidth; // get options from Admin CP -> Options -> Image Resizer -> Maximum Height $maximumHeight = XenForo_Application::get('options')->imageResizerMaximumHeight; // resize based on width if ($width > $maximumWidth) { // resize image - (use the '\>' flag) exec("/usr/bin/convert {$attachmentFullPath} -resize {$maximumWidth} x {$maximumHeight}\\> {$attachmentFullPath}"); } // resize based on height if ($width <= $maximumWidth and $height > $maximumHeight) { // resize based on height only exec("/usr/bin/convert {$attachmentFullPath} -resize x{$maximumHeight} {$attachmentFullPath}"); } //##################################### // Rename attachment with new file hash // in the filename. //##################################### // get new hash $filehashNew = hash_file('md5', $attachmentFullPath); // prepare new filename (with new file hash) $newFilenameDataPath = $internalDataPath . '/attachments/' . $lastFolder . '/' . $dataId . '-' . $filehashNew . '.data'; // rename original filename to new filename exec("mv {$attachmentFullPath} {$newFilenameDataPath}"); //##################################### // update xf_attachment_data //##################################### // get size $filesize = filesize($newFilenameDataPath); // get dimensions list($width, $height) = getimagesize($newFilenameDataPath); // run query $db->query(' UPDATE xf_attachment_data SET file_size = "' . $filesize . '", file_hash = "' . $filehashNew . '", width = "' . $width . '", height = "' . $height . '" WHERE data_id = ? ', $dataId); //##################################### // Update thumbnail with new file hash // in the filename. //##################################### // thumbpath original name $thumbpath = $externalDataPath . '/attachments/' . $lastFolder . '/' . $dataId . '-' . $fileHash . '.jpg'; // throw error if file missing if (!file_exists($thumbpath)) { throw new XenForo_Exception(new XenForo_Phrase('imageresizer_attachment_missing_from_file_directory') . ' ' . $thumbpath, true); } // thumbpath new name $thumbpathNew = $externalDataPath . '/attachments/' . $lastFolder . '/' . $dataId . '-' . $filehashNew . '.jpg'; // rename thumbnail exec("mv {$thumbpath} {$thumbpathNew}"); } } // response redirect return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildPublicLink('imageresizer/updateconfirm')); }
public function getContentDataLargeThumbnailFile(array $data, $forceLocal = false, $externalDataPath = null) { if (empty($data['content_type'])) { return null; } if (!empty($data['bdattachmentstore_engine']) && $forceLocal === false) { $fileModel = $this->_bdAttachmentStore_getFileModel(); $engine = $data['bdattachmentstore_engine']; $engineOptions = @unserialize($data['bdattachmentstore_options']); $filePath = $this->getStoreContentDataLargeThumbnailFile($data); $file = $fileModel->getAccessibleFilePath($engine, $engineOptions, $filePath, true); if (is_file($file)) { return $file; } } if ($externalDataPath === null) { $externalDataPath = XenForo_Helper_File::getExternalDataPath(); } if (!empty($data['content_type']) && $data['content_type'] === sonnb_XenGallery_Model_Video::$contentType) { $data['extension'] = self::$videoEmbedExtension; } return sprintf('%s/' . $data['content_type'] . 's/l/%d/%d-%d-%s.%s', $externalDataPath, floor($data['content_data_id'] / 1000), $data['content_data_id'], $data['upload_date'], md5('l' . $data['file_hash']), $data['extension']); }
protected function _importMedia(array $item, array $options, $video = false) { $sDb = $this->_sourceDb; $user = $sDb->fetchRow(' SELECT user_id, username FROM xf_user WHERE user_id = ? ', $item['user_id']); if (!$user) { return false; } if (!$video) { $originalFilePath = sprintf('%s/photos/o/%d/%d-%d-%s.%s', XenForo_Helper_File::getExternalDataPath(), floor($item['content_data_id'] / 1000), $item['content_data_id'], $item['upload_date'], md5('o' . $item['file_hash']), $item['extension']); if (!file_exists($originalFilePath)) { return false; } $tempFile = tempnam(XenForo_Helper_File::getTempDir(), 'xfmg'); copy($originalFilePath, $tempFile); } else { $tempFile = false; } $model = $this->_getMediaGalleryImportersModel(); $albumId = $model->mapAlbumId($item['album_id']); list($viewPrivacy, $shareUsers) = $model->getAlbumPrivacyAndShareUsersFromAlbumPrivacyXenGallery($item); $lastCommentId = @explode(',', $item['latest_comment_ids']); if (is_array($lastCommentId)) { $lastCommentId = end($lastCommentId); } elseif (is_int($item['latest_comment_ids'])) { $lastCommentId = $item['latest_comment_ids']; } if ($lastCommentId) { $lastCommentDate = $model->getLastCommentDateFromContentXenGallery($item['content_id'], $item['content_type']); } else { $lastCommentDate = 0; } $noTitle = new XenForo_Phrase('xengallery_imported_item'); $xengalleryMedia = array('media_title' => $item['title'] ? $item['title'] : $noTitle->render(), 'media_description' => $item['description'], 'media_date' => $item['upload_date'], 'last_edit_date' => XenForo_Application::$time, 'last_comment_date' => $lastCommentDate, 'media_type' => $item['content_type'] == 'photo' ? 'image_upload' : 'video_embed', 'media_state' => $item['content_state'], 'album_id' => $albumId, 'category_id' => 0, 'media_privacy' => $viewPrivacy, 'attachment_id' => 0, 'user_id' => $item['user_id'], 'username' => $item['username'], 'ip_id' => $model->getLatestIpIdFromUserId($item['user_id']), 'likes' => $item['likes'], 'like_users' => unserialize($item['like_users']), 'comment_count' => $item['comment_count'], 'rating_count' => 0, 'media_view_count' => $item['view_count']); if ($video) { $xengalleryMedia['media_tag'] = '[media=' . $item['video_type'] . ']' . $item['video_key'] . '[/media]'; $xengalleryMedia['media_embed_url'] = 'n/a'; $xfAttachment = array(); $xfAttachmentData = array(); } else { $xfAttachment = array('data_id' => 0, 'content_type' => 'xengallery_media', 'content_id' => 0, 'attach_date' => $item['upload_date'], 'temp_hash' => '', 'unassociated' => 0, 'view_count' => $item['view_count']); $xfAttachmentData = array('user_id' => $item['user_id'], 'upload_date' => $item['upload_date'], 'filename' => sprintf('%d-%d-%s.%s', $item['content_data_id'], $item['upload_date'], md5('o' . $item['file_hash']), $item['extension']), 'attach_count' => 1); } $importedMediaId = $model->importMedia($item['content_id'], $tempFile, 'sonnb_xengallery_' . $item['content_type'], $xengalleryMedia, $xfAttachment, $xfAttachmentData); @unlink($tempFile); return $importedMediaId; }
public function getAuthorCoverFile(array $user, $forceLocal = false, $externalDataPath = null) { $coverData = $user['sonnb_xengallery_cover']; if (!is_array($coverData)) { $coverData = @unserialize($coverData); } if (empty($coverData)) { return ''; } if (!empty($coverData['bdattachmentstore_engine']) && $forceLocal === false) { $fileModel = $this->_bdAttachmentStore_getFileModel(); $engine = $coverData['bdattachmentstore_engine']; $engineOptions = $coverData['bdattachmentstore_options']; $filePath = $this->getAuthorCoverStoreFile($user); $file = $fileModel->getAccessibleFilePath($engine, $engineOptions, $filePath, true); if ($file) { return $file; } } if ($externalDataPath === null) { $externalDataPath = XenForo_Helper_File::getExternalDataPath(); } return sprintf('%s/xengallery-covers/%d/%d-%d.%s', $externalDataPath, floor($user['user_id'] / 1000), $user['user_id'], $coverData['upload_date'], $coverData['extension']); }
public function saveFile($document, $type, $loops) { if (XenForo_Application::get('options')->EWRutiles_Sitemap_gzip) { $path = XenForo_Helper_File::getExternalDataPath() . '/sitemaps/' . $type . '_' . $loops . '.xml.gz'; $file = gzopen($path, 'w'); gzwrite($file, $document->saveXML()); fclose($file); return XenForo_Application::get('options')->boardUrl . '/data/sitemaps/' . $type . '_' . $loops . '.xml.gz'; } else { $path = XenForo_Helper_File::getExternalDataPath() . '/sitemaps/' . $type . '_' . $loops . '.xml'; $file = fopen($path, 'w'); fwrite($file, $document->saveXML()); fclose($file); return XenForo_Application::get('options')->boardUrl . '/data/sitemaps/' . $type . '_' . $loops . '.xml'; } }
public function getAvatarFilePath($teamId, $externalDataPath = null) { if ($externalDataPath === null) { $externalDataPath = XenForo_Helper_File::getExternalDataPath(); } return sprintf('%s/nobita/teams/avatars/%d/%d.jpg', $externalDataPath, floor($teamId / 1000), $teamId); }
/** * Gets the full path to this attachment's thumbnail. * * @param array $data Attachment data info * * @return string */ public function getAttachmentThumbnailFilePath(array $data) { return XenForo_Helper_File::getExternalDataPath() . '/attachments/' . floor($data['data_id'] / 1000) . "/{$data['data_id']}-{$data['file_hash']}.jpg"; }
/** * Get the file path to a resource icon. * * @param integer $resourceId * @param string $externalDataPath External data directory path (optional) * * @return string */ public function getResourceIconFilePath($resourceId, $externalDataPath = null) { if ($externalDataPath === null) { $externalDataPath = XenForo_Helper_File::getExternalDataPath(); } return sprintf('%s/resource_icons/%d/%d.jpg', $externalDataPath, floor($resourceId / 1000), $resourceId); }
public function getVideoThumbnailFromParts(array $parts) { if (!isset($parts[0]) || !isset($parts[1])) { return false; } $serviceId = preg_replace('#[^a-zA-Z0-9_]#', '', $parts[0]); $videoId = $parts[1]; $cleanVideoId = XenGallery_Helper_String::cleanVideoId($videoId); if (!strlen($serviceId) || !strlen($cleanVideoId)) { return false; } $videoThumbnail = sprintf('%s/xengallery/%s/%s_%s_thumb.jpg', XenForo_Helper_File::getExternalDataPath(), $serviceId, $serviceId, $cleanVideoId); if (!file_exists($videoThumbnail) || !is_readable($videoThumbnail)) { $mediaSiteOptions = XenForo_Application::getOptions()->xengalleryMediaThumbs; if (empty($mediaSiteOptions[$serviceId])) { return false; } $mediaSite = $mediaSiteOptions[$serviceId]; if (strpos($mediaSite, '_')) { if (class_exists($mediaSite)) { /** @var $thumbnailObj XenGallery_Thumbnail_Abstract */ $thumbnailObj = XenGallery_Thumbnail_Abstract::create($mediaSite); $thumbnailPath = $thumbnailObj->getThumbnailUrl($videoId); } else { $thumbnailPath = $mediaSite; } } else { $thumbnailPath = $mediaSite; } if (strpos($thumbnailPath, '{$id}')) { $this->_thumbnailPath = XenForo_Application::$externalDataPath . '/xengallery/' . $serviceId; XenForo_Helper_File::createDirectory($this->_thumbnailPath, true); $thumbnailUrl = str_replace('{$id}', rawurldecode($videoId), $thumbnailPath); XenGallery_Thumbnail_Abstract::saveThumbnailFromUrl($serviceId, $cleanVideoId, $thumbnailUrl); } } return $videoThumbnail; }
public static function getThumbnailPath($fullPath, $width, $height = 0, $dir = null) { $thumbnailPath = XenForo_Helper_File::getExternalDataPath() . self::_getThumbnailRelativePath($fullPath, $width, $height, $dir); return $thumbnailPath; }
public function getCategoryIconFilePath($categoryId, $externalDataPath = null) { if ($externalDataPath === null) { $externalDataPath = XenForo_Helper_File::getExternalDataPath(); } return sprintf('%s/nobita/teams/category_icons/%d/%d.jpg', $externalDataPath, floor($categoryId / 1000), $categoryId); }
protected function _uninstall_0() { $this->_getDb()->query("\n\t\t\tDROP TABLE IF EXISTS\n\t\t\t\t`EWRmedio_categories`,\n\t\t\t\t`EWRmedio_comments`,\n\t\t\t\t`EWRmedio_keylinks`,\n\t\t\t\t`EWRmedio_keywords`,\n\t\t\t\t`EWRmedio_media`,\n\t\t\t\t`EWRmedio_playlists`,\n\t\t\t\t`EWRmedio_read`,\n\t\t\t\t`EWRmedio_services`,\n\t\t\t\t`EWRmedio_users`,\n\t\t\t\t`EWRmedio_watch`\n\t\t"); $this->_getDb()->query("DELETE IGNORE FROM `xf_content_type` WHERE content_type = 'media'"); $this->_getDb()->query("DELETE IGNORE FROM `xf_content_type` WHERE content_type = 'media_comment'"); $this->_getDb()->query("DELETE IGNORE FROM `xf_content_type_field` WHERE content_type = 'media'"); $this->_getDb()->query("DELETE IGNORE FROM `xf_content_type_field` WHERE content_type = 'media_comment'"); XenForo_Model::create('XenForo_Model_ContentType')->rebuildContentTypeCache(); $targetLoc = glob(XenForo_Helper_File::getExternalDataPath() . "/media/*.jpg"); foreach ($targetLoc as $file) { unlink($file); } $targetLoc = XenForo_Helper_File::getExternalDataPath() . "/media"; if (is_dir($targetLoc)) { rmdir($targetLoc); } }
protected function _createPhotoData($options, &$attachment, $data) { $file = XenForo_Helper_File::getExternalDataPath() . "/media/{$attachment['media_id']}.jpg"; if (!is_file($file) || !file_exists($file)) { $file = sonnb_XenGallery_Model_ContentData::$videoNoThumbnail; } return $this->_createVideoFiles($file, $data); }
/** * Get the file path to an avatar. * * @param integer $userId * @param string $size Size code * * @return string */ public function getAvatarFilePath($userId, $size) { $group = floor($userId / 1000); return XenForo_Helper_File::getExternalDataPath() . "/avatars/{$size}/{$group}/{$userId}.jpg"; }
/** * Gets the full path to this attachment's thumbnail. * * @param array $data Attachment data info * @param string External data path * * @return string */ public function getAttachmentThumbnailFilePath(array $data, $externalDataPath = null) { if ($externalDataPath === null) { $externalDataPath = XenForo_Helper_File::getExternalDataPath(); } return sprintf('%s/attachments/%d/%d-%s.jpg', $externalDataPath, floor($data['data_id'] / 1000), $data['data_id'], $data['file_hash']); }
public function getAlbumThumbnailFilePath($albumId, $original = false) { if ($original) { return sprintf('%s/xengallery/originals/album/%d/%d.jpg', XenForo_Helper_File::getInternalDataPath(), floor($albumId / 1000), $albumId); } else { return sprintf('%s/xengallery/album/%d/%d.jpg', XenForo_Helper_File::getExternalDataPath(), floor($albumId / 1000), $albumId); } }