當前位置: 首頁>>代碼示例>>PHP>>正文


PHP System::log方法代碼示例

本文整理匯總了PHP中Contao\System::log方法的典型用法代碼示例。如果您正苦於以下問題:PHP System::log方法的具體用法?PHP System::log怎麽用?PHP System::log使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Contao\System的用法示例。


在下文中一共展示了System::log方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: processPostUpload

 /**
  * Compress images
  *
  * @param boolean $arrFiles File array
  */
 public function processPostUpload($arrFiles)
 {
     if (is_array($arrFiles) && $GLOBALS['TL_CONFIG']['tinypng_api_key'] != '') {
         $strUrl = 'https://api.tinypng.com/shrink';
         $strKey = $GLOBALS['TL_CONFIG']['tinypng_api_key'];
         $strAuthorization = 'Basic ' . base64_encode("api:{$strKey}");
         foreach ($arrFiles as $file) {
             $objFile = FilesModel::findByPath($file);
             if (in_array($objFile->extension, array('png', 'jpg', 'jpeg'))) {
                 $strFile = TL_ROOT . '/' . $file;
                 $objRequest = new Request();
                 $objRequest->method = 'post';
                 $objRequest->data = file_get_contents($strFile);
                 $objRequest->setHeader('Content-type', 'image/png');
                 $objRequest->setHeader('Authorization', $strAuthorization);
                 $objRequest->send($strUrl);
                 $arrResponse = json_decode($objRequest->response);
                 if ($objRequest->code == 201) {
                     file_put_contents($strFile, fopen($arrResponse->output->url, "rb", false));
                     $objFile->tstamp = time();
                     $objFile->path = $file;
                     $objFile->hash = md5_file(TL_ROOT . '/' . $file);
                     $objFile->save();
                     System::log('Compression was successful. (File: ' . $file . ')', __METHOD__, TL_FILES);
                 } else {
                     System::log('Compression failed. (' . $arrResponse->message . ') (File: ' . $file . ')', __METHOD__, TL_FILES);
                 }
             }
         }
     }
 }
開發者ID:christianbarkowsky,項目名稱:contao-tiny-compress-images,代碼行數:36,代碼來源:TinyCompressImages.php

示例2: purge

 /**
  * Purge the data
  */
 public function purge()
 {
     // Purge the data
     Database::getInstance()->query("TRUNCATE TABLE tl_vimeo_cache");
     // Purge the images
     $folder = new \Folder(static::$imagesFolder);
     $folder->purge();
     // Log the action
     System::log('Purged the Vimeo cache', __METHOD__, TL_CRON);
 }
開發者ID:derhaeuptling,項目名稱:contao-vimeo-api,代碼行數:13,代碼來源:Cache.php

示例3: rebuildVimeoCache

 /**
  * Rebuild Vimeo cache
  *
  * @param DataContainer $dc
  */
 public function rebuildVimeoCache(DataContainer $dc)
 {
     $rebuilder = new Rebuilder();
     try {
         $result = $rebuilder->rebuildElementCache(ContentModel::findByPk($dc->id));
     } catch (\InvalidArgumentException $e) {
         return;
     } catch (\RuntimeException $e) {
         System::log(sprintf('Unable to rebuild Vimeo cache of element ID %s: %s', $dc->id, $e->getMessage()), __METHOD__, TL_ERROR);
         $result = false;
     }
     if ($result === true) {
         Message::addConfirmation($GLOBALS['TL_LANG']['tl_content']['vimeo_cacheConfirm']);
     } elseif ($result === false) {
         Message::addError($GLOBALS['TL_LANG']['tl_content']['vimeo_cacheError']);
     }
 }
開發者ID:derhaeuptling,項目名稱:contao-vimeo-api,代碼行數:22,代碼來源:ContentContainer.php

示例4: checkLoginStatus

 public function checkLoginStatus($objPage, $objLayout, \PageRegular $objPageRegular)
 {
     global $objPage;
     $loggedIn = FE_USER_LOGGED_IN;
     if (\Input::get('logout')) {
         if (@$this->User->logout()) {
             $loggedIn = false;
         }
     }
     if (!$loggedIn && $objPage->type != "login" && (Config::get("globalLogin") == 1 || $objPage->type == "error_403")) {
         $loginPage = PageModel::findOneBy("type", "login");
         if (isset($loginPage) && $loginPage->published == 1) {
             $loginPage->loadDetails();
             $objPage = $loginPage;
             $handler = new LoginPage(\Environment::get("request"));
             $handler->generate($loginPage);
             exit;
         } else {
             System::log("Please create a Login-Page urgently!!", "LoginPage\\checkLoginStatus", TL_ERROR);
             if ($objPage->type == "error_403") {
                 return;
             }
             $page403_model = \PageModel::find403ByPid($objPage->rootId);
             if (isset($page403_model) && $page403_model->published == 1) {
                 $page403_model->loadDetails();
                 $objPage = $page403_model;
                 $handler = new PageError403();
                 $handler->generate($page403_model->id, $page403_model->rootId);
                 exit;
             } else {
                 System::log("Please create a 403-Error-Page urgently!!", "LoginPage\\checkLoginStatus", TL_ERROR);
                 $objPage->template = 'fe_login';
                 $objPage->templateGroup = $objLayout->templates;
                 $objPageRegular->createTemplate($objPage, $objLayout);
             }
         }
     }
 }
開發者ID:postyou,項目名稱:contao-deep-login,代碼行數:38,代碼來源:LoginPage.php

示例5: onImportUser

 /**
  * Contao ImportUser Hook Implementation
  *
  * Imports a user from phpbb if login credentials match
  *
  * @param $username
  * @param $password
  * @param $scope
  * @return bool
  */
 public function onImportUser($username, $password, $scope)
 {
     if ($scope == 'tl_member') {
         // Before we try to import a user, we must check is username is maybe = username_clean
         // We already now that the user could not be found by username column
         if (($real_username = $this->findByCleanUsername($username)) != '') {
             // So we found the user by it's clean username, then we overwrite the POST Value
             // because contao will recheck it.
             Input::setPost('username', $real_username);
             return true;
         }
         $loginResult = System::getContainer()->get('phpbb_bridge.connector')->validateLogin($username, $password);
         // Only import user if login to forum succeeded
         if ($loginResult === true) {
             System::log("Trying to import User: " . $username, __METHOD__, TL_ACCESS);
             // Try to import the user to contao (tl_member / frontend)
             $importResult = System::getContainer()->get('phpbb_bridge.connector')->importUser($username, $password);
             return $importResult;
             // Should usually be true
         }
     }
     return false;
 }
開發者ID:ctsmedia,項目名稱:contao-phpbb-bridge-bundle,代碼行數:33,代碼來源:ContaoFrontendListener.php

示例6: request

 /**
  * Make an API request to Vimeo.
  *
  * @param string $url    A Vimeo API Endpoint. Should not include the host
  * @param array  $params An array of parameters to send to the endpoint. If the HTTP method is GET, they will be added to the url, otherwise they will be written to the body
  * @param string $method The HTTP Method of the request
  * @param bool   $json_body
  *
  * @return array|null
  */
 public function request($url, $params = array(), $method = 'GET', $json_body = true)
 {
     if (Config::get('debugMode')) {
         static $requestCount = 0;
         if (++$requestCount > $this->requestLimit) {
             System::log(sprintf('The request limit of %s has been reached. Please check your script for possible optimizations.', $this->requestLimit), __METHOD__, 'VIMEO');
             return null;
         }
         System::log('Vimeo request to: ' . $url, __METHOD__, 'VIMEO');
     }
     try {
         $response = parent::request($url, $params, $method, $json_body);
     } catch (\Exception $e) {
         System::log(sprintf('Vimeo request (%s) failed with exception: %s', $url, $e->getMessage()), __METHOD__, TL_ERROR);
         return null;
     }
     $this->updateStats($response['headers']);
     if ($response['status'] !== 200) {
         System::log(sprintf('Vimeo request (%s) failed (code %s): %s', $url, $response['status'], print_r($response, true)), __METHOD__, TL_ERROR);
         return null;
     }
     return $response;
 }
開發者ID:derhaeuptling,項目名稱:contao-vimeo-api,代碼行數:33,代碼來源:Client.php

示例7: fetchVideoImage

 /**
  * Fetch the video image
  *
  * @param int $videoId
  * @param int $index
  *
  * @return null|string
  *
  * @throws \InvalidArgumentException
  */
 protected function fetchVideoImage($videoId, $index)
 {
     if ($index < 1) {
         throw new \InvalidArgumentException('The image index cannot be smaller than 1');
     }
     $videoId = (int) $videoId;
     // Return if the video could not be found
     if (($videoData = $this->getVideo($videoId)) === null) {
         return null;
     }
     $index = (int) $index - 1;
     // If the first image was requested then it should already be there
     if ($index === 0 && isset($videoData['pictures']['sizes'])) {
         $sizes = $videoData['pictures']['sizes'];
     } else {
         // Return if there are no video images
         if (($images = $this->getVideoImages($videoId)) === null) {
             return null;
         }
         $sizes = isset($images['data'][$index]['sizes']) ? $images['data'][$index]['sizes'] : $images['data'][0]['sizes'];
     }
     $picture = array_pop($sizes);
     $request = new Request();
     $request->send($picture['link']);
     if ($request->hasError()) {
         System::log(sprintf('Unable to download Vimeo video image "%s"', $picture['link']), __METHOD__, TL_ERROR);
         return null;
     }
     return $request->response;
 }
開發者ID:derhaeuptling,項目名稱:contao-vimeo-api,代碼行數:40,代碼來源:StandardProvider.php

示例8: getRootPageFromUrl

 /**
  * Try to find a root page based on language and URL
  *
  * @return PageModel
  */
 public static function getRootPageFromUrl()
 {
     // HOOK: add custom logic
     if (isset($GLOBALS['TL_HOOKS']['getRootPageFromUrl']) && is_array($GLOBALS['TL_HOOKS']['getRootPageFromUrl'])) {
         foreach ($GLOBALS['TL_HOOKS']['getRootPageFromUrl'] as $callback) {
             /** @var PageModel $objRootPage */
             if (is_object($objRootPage = static::importStatic($callback[0])->{$callback[1]}())) {
                 return $objRootPage;
             }
         }
     }
     $host = \Environment::get('host');
     // The language is set in the URL
     if (\Config::get('addLanguageToUrl') && !empty($_GET['language'])) {
         $objRootPage = \PageModel::findFirstPublishedRootByHostAndLanguage($host, \Input::get('language'));
         // No matching root page found
         if ($objRootPage === null) {
             \System::log('No root page found (host "' . $host . '", language "' . \Input::get('language') . '")', __METHOD__, TL_ERROR);
             throw new NoRootPageFoundException('No root page found');
         }
     } else {
         $accept_language = \Environment::get('httpAcceptLanguage');
         // Find the matching root pages (thanks to Andreas Schempp)
         $objRootPage = \PageModel::findFirstPublishedRootByHostAndLanguage($host, $accept_language);
         // No matching root page found
         if ($objRootPage === null) {
             \System::log('No root page found (host "' . \Environment::get('host') . '", languages "' . implode(', ', \Environment::get('httpAcceptLanguage')) . '")', __METHOD__, TL_ERROR);
             throw new NoRootPageFoundException('No root page found');
         }
         // Redirect to the language root (e.g. en/)
         if (\Config::get('addLanguageToUrl') && !\Config::get('doNotRedirectEmpty') && \Environment::get('relativeRequest') == '') {
             $arrParams = array('_locale' => $objRootPage->language);
             $strUrl = \System::getContainer()->get('router')->generate('contao_index', $arrParams);
             $strUrl = substr($strUrl, strlen(\Environment::get('path')) + 1);
             static::redirect($strUrl, 301);
         }
     }
     return $objRootPage;
 }
開發者ID:bytehead,項目名稱:core-bundle,代碼行數:44,代碼來源:Frontend.php

示例9: initForumRequest

 /**
  * @return Browser
  */
 protected function initForumRequest($force = false)
 {
     // Init Request
     $client = new Curl();
     $client->setMaxRedirects(0);
     $browser = new Browser();
     $browser->setClient($client);
     $cookieListener = new CookieListener();
     $browser->addListener($cookieListener);
     // We need to make sure that the if the original Request is already coming from the forum, we then are not
     // allowed to send a request to the forum so we create a login loop for example.
     if ($force === false && System::getContainer()->get('request_stack')->getCurrentRequest() && System::getContainer()->get('request_stack')->getCurrentRequest()->headers->get('x-requested-with') == 'ContaoPhpbbBridge') {
         System::log('Bridge Request Recursion detected', __METHOD__, TL_ERROR);
         throw new TooManyRequestsHttpException(null, 'Internal recursion Bridge requests detected');
     }
     return $browser;
 }
開發者ID:ctsmedia,項目名稱:contao-phpbb-bridge-bundle,代碼行數:20,代碼來源:Connector.php

示例10: handleLog

 /**
  * Handle a log event.
  *
  * @param LogEvent $event The event.
  *
  * @return void
  */
 public function handleLog(LogEvent $event)
 {
     System::log($event->getText(), $event->getFunction(), $event->getCategory());
 }
開發者ID:contao-community-alliance,項目名稱:events-contao-bindings,代碼行數:11,代碼來源:SystemSubscriber.php

示例11: get

 /**
  * Resize an image and store the resized version in the image target folder
  *
  * @param string  $image        The image path
  * @param integer $width        The target width
  * @param integer $height       The target height
  * @param string  $mode         The resize mode
  * @param string  $target       An optional target path
  * @param boolean $force        Override existing target images
  *
  * @return string|null The path of the resized image or null
  *
  * @deprecated Deprecated since Contao 4.3, to be removed in Contao 5.0.
  *             Use the contao.image.image_factory service instead.
  */
 public static function get($image, $width, $height, $mode = '', $target = null, $force = false)
 {
     @trigger_error('Using Image::get() has been deprecated and will no longer work in Contao 5.0. Use the contao.image.image_factory service instead.', E_USER_DEPRECATED);
     if ($image == '') {
         return null;
     }
     try {
         $imageObj = static::create($image, array($width, $height, $mode));
         $imageObj->setTargetPath($target);
         $imageObj->setForceOverride($force);
         if (($path = $imageObj->executeResize()->getResizedPath()) != '') {
             return $path;
         }
     } catch (\Exception $e) {
         \System::log('Image "' . $image . '" could not be processed: ' . $e->getMessage(), __METHOD__, TL_ERROR);
     }
     return null;
 }
開發者ID:contao,項目名稱:core-bundle,代碼行數:33,代碼來源:Image.php

示例12: autologinAction

 /**
  * @Route("/autologin")
  * @return Response
  */
 public function autologinAction()
 {
     $this->validateRequest();
     $isLoggedIn = false;
     $userId = 0;
     if (FE_USER_LOGGED_IN === true) {
         $username = $this->container->get('security.token_storage')->getToken()->getUsername();
         $phpBBuser = $this->container->get('phpbb_bridge.connector')->getUser($username);
         if ($phpBBuser !== null) {
             $isLoggedIn = true;
             $userId = $phpBBuser->user_id;
         } else {
             System::log('Request from phpbb to autologin a user which was found in Contao but not in phpbb: ' . $username, __METHOD__, TL_ERROR);
         }
     }
     $response = new JsonResponse();
     $response->setData(array('is_logged_in' => $isLoggedIn, 'user_id' => (int) $userId));
     return $response;
 }
開發者ID:ctsmedia,項目名稱:contao-phpbb-bridge-bundle,代碼行數:23,代碼來源:ConnectController.php

示例13: addFilesBreadcrumb

    /**
     * Add a breadcrumb menu to the file tree
     *
     * @param string $strKey
     *
     * @throws \RuntimeException
     */
    public static function addFilesBreadcrumb($strKey = 'tl_files_node')
    {
        /** @var AttributeBagInterface $objSession */
        $objSession = \System::getContainer()->get('session')->getBag('contao_backend');
        // Set a new node
        if (isset($_GET['node'])) {
            // Check the path (thanks to Arnaud Buchoux)
            if (\Validator::isInsecurePath(\Input::get('node', true))) {
                throw new \RuntimeException('Insecure path ' . \Input::get('node', true));
            }
            $objSession->set($strKey, \Input::get('node', true));
            \Controller::redirect(preg_replace('/(&|\\?)node=[^&]*/', '', \Environment::get('request')));
        }
        $strNode = $objSession->get($strKey);
        if ($strNode == '') {
            return;
        }
        // Check the path (thanks to Arnaud Buchoux)
        if (\Validator::isInsecurePath($strNode)) {
            throw new \RuntimeException('Insecure path ' . $strNode);
        }
        // Currently selected folder does not exist
        if (!is_dir(TL_ROOT . '/' . $strNode)) {
            $objSession->set($strKey, '');
            return;
        }
        $objUser = \BackendUser::getInstance();
        $strPath = \Config::get('uploadPath');
        $arrNodes = explode('/', preg_replace('/^' . preg_quote(\Config::get('uploadPath'), '/') . '\\//', '', $strNode));
        $arrLinks = array();
        // Add root link
        $arrLinks[] = '<img src="' . TL_FILES_URL . 'system/themes/' . \Backend::getTheme() . '/images/filemounts.gif" width="18" height="18" alt=""> <a href="' . \Controller::addToUrl('node=') . '" title="' . specialchars($GLOBALS['TL_LANG']['MSC']['selectAllNodes']) . '">' . $GLOBALS['TL_LANG']['MSC']['filterAll'] . '</a>';
        // Generate breadcrumb trail
        foreach ($arrNodes as $strFolder) {
            $strPath .= '/' . $strFolder;
            // Do not show pages which are not mounted
            if (!$objUser->hasAccess($strPath, 'filemounts')) {
                continue;
            }
            // No link for the active folder
            if ($strFolder == basename($strNode)) {
                $arrLinks[] = '<img src="' . TL_FILES_URL . 'system/themes/' . \Backend::getTheme() . '/images/folderC.gif" width="18" height="18" alt=""> ' . $strFolder;
            } else {
                $arrLinks[] = '<img src="' . TL_FILES_URL . 'system/themes/' . \Backend::getTheme() . '/images/folderC.gif" width="18" height="18" alt=""> <a href="' . \Controller::addToUrl('node=' . $strPath) . '" title="' . specialchars($GLOBALS['TL_LANG']['MSC']['selectNode']) . '">' . $strFolder . '</a>';
            }
        }
        // Check whether the node is mounted
        if (!$objUser->hasAccess($strNode, 'filemounts')) {
            $objSession->set($strKey, '');
            \System::log('Folder ID ' . $strNode . ' was not mounted', __METHOD__, TL_ERROR);
            \Controller::redirect('contao/main.php?act=error');
        }
        // Limit tree
        $GLOBALS['TL_DCA']['tl_files']['list']['sorting']['root'] = array($strNode);
        // Insert breadcrumb menu
        $GLOBALS['TL_DCA']['tl_files']['list']['sorting']['breadcrumb'] .= '

<ul id="tl_breadcrumb">
  <li>' . implode(' &gt; </li><li>', $arrLinks) . '</li>
</ul>';
    }
開發者ID:jamesdevine,項目名稱:core-bundle,代碼行數:68,代碼來源:Backend.php

示例14: handleElementAction

 /**
  * Handle the element AJAX action
  *
  * @throws \InvalidArgumentException
  * @throws \RuntimeException
  */
 protected function handleElementAction()
 {
     // Throw an error if content element could not be found
     if (($contentElement = ContentModel::findByPk(Input::post('id'))) === null) {
         System::log(sprintf('Unable to find the content element ID %s', Input::post('id')), __METHOD__, TL_ERROR);
         header('HTTP/1.1 400 Bad Request');
         die('Bad Request');
     }
     $dataProvider = $this->getBatchProvider();
     $callback = static::getCallbackInstance($contentElement->type);
     if (!$callback->rebuild($dataProvider, $contentElement)) {
         header('HTTP/1.1 400 Bad Request');
         die('Bad Request');
     }
     header('HTTP/1.1 200 OK');
     die('OK');
 }
開發者ID:derhaeuptling,項目名稱:contao-vimeo-api,代碼行數:23,代碼來源:Rebuilder.php

示例15: handleRunOnce

 /**
  * Handle "runonce" files
  *
  * @throws \Exception
  */
 public static function handleRunOnce()
 {
     try {
         $files = \System::getContainer()->get('contao.resource_locator')->locate('config/runonce.php', null, false);
     } catch (\InvalidArgumentException $e) {
         return;
     }
     foreach ($files as $file) {
         try {
             include $file;
         } catch (\Exception $e) {
         }
         $strRelpath = str_replace(TL_ROOT . DIRECTORY_SEPARATOR, '', $file);
         if (!unlink($file)) {
             throw new \Exception("The file {$strRelpath} cannot be deleted. Please remove the file manually and correct the file permission settings on your server.");
         }
         \System::log("File {$strRelpath} ran once and has then been removed successfully", __METHOD__, TL_GENERAL);
     }
 }
開發者ID:contao,項目名稱:core-bundle,代碼行數:24,代碼來源:Backend.php


注:本文中的Contao\System::log方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。