<commit_before><?php

/**
 * Handle all medias model requests.
 *
 * @link http://github.com/marcoraddatz/candyCMS
 * @author <NAME>
 * @license MIT
 * @since 2.1
 *
 */

namespace candyCMS\Core\Models;

use candyCMS\Core\Helpers\AdvancedException;
use candyCMS\Core\Helpers\Helper;
use candyCMS\Core\Helpers\Image;

class Medias extends Main {

  /**
   * Get log overview data.
   *
   * @access public
   * @return array $this->_aData
   *
   */
  public function getOverview() {
    require_once PATH_STANDARD . '/vendor/candycms/core/helpers/Image.helper.php';

    $sOriginalPath = Helper::removeSlash(PATH_UPLOAD . '/' . $this->_sController);
    $oDir = opendir($sOriginalPath);

    $aFiles = array();
    while ($sFile = readdir($oDir)) {
      $sPath = $sOriginalPath . '/' . $sFile;

      if (substr($sFile, 0, 1) == '.' || is_dir($sPath))
        continue;

      $sFileType  = strtolower(substr(strrchr($sPath, '.'), 1));
      $iNameLen   = strlen($sFile) - 4;

      if ($sFileType == 'jpeg')
        $iNameLen--;

      $sFileName = substr($sFile, 0, $iNameLen);

      if ($sFileType == 'jpg' || $sFileType == 'jpeg' || $sFileType == 'png' || $sFileType == 'gif') {
        $aImgDim = getImageSize($sPath);

        if (!file_exists(Helper::removeSlash(PATH_UPLOAD . '/temp/' . $this->_sController . '/' . $sFile))) {
          $oImage = new Image($sFileName, 'temp', $sPath, $sFileType);
          $oImage->resizeAndCut('32', $this->_sController);
        }
      }

      else
        $aImgDim = '';

      $aFiles[] = array(
        'name'  => $sFile,
        'date'  => Array(
            'raw' => filectime($sPath),
            'w3c' => date('Y-m-d\TH:i:sP', filectime($sPath))),
        'size'  => Helper::fileSizeToString(Helper::getFileSize($sPath)),
        'type'  => $sFileType,
        'dim'   => $aImgDim,
        'url'   => Helper::addSlash(PATH_UPLOAD) . '/' . $this->_sController . '/' . $sFile,
        'url_destroy' => '/' . $this->_sController . '/' . $sFile . '/destroy'
      );
    }

    closedir($oDir);

    return $aFiles;
  }

  /**
   * Destroy a file and delete from HDD.
   *
   * @access public
   * @param mixed $sId the unique name of the file
   * @param string $sController controller to use, obsolete and only for not giving E_STRICT warnings
   * @return boolean status of query
   *
   */
  public function destroy($sId, $sController = '') {
    # We get the image information via GET
    $sPath = Helper::removeSlash(PATH_UPLOAD . '/' . $this->_sController . '/' . $sId);
<commit_msg>added url again so that rss feeds get correct path<commit_after><?php

/**
 * Handle all medias model requests.
 *
 * @link http://github.com/marcoraddatz/candyCMS
 * @author <NAME>
 * @license MIT
 * @since 2.1
 *
 */

namespace candyCMS\Core\Models;

use candyCMS\Core\Helpers\AdvancedException;
use candyCMS\Core\Helpers\Helper;
use candyCMS\Core\Helpers\Image;

class Medias extends Main {

  /**
   * Get log overview data.
   *
   * @access public
   * @return array $this->_aData
   *
   */
  public function getOverview() {
    require_once PATH_STANDARD . '/vendor/candycms/core/helpers/Image.helper.php';

    $sOriginalPath = Helper::removeSlash(PATH_UPLOAD . '/' . $this->_sController);
    $oDir = opendir($sOriginalPath);

    $aFiles = array();
    while ($sFile = readdir($oDir)) {
      $sPath = $sOriginalPath . '/' . $sFile;

      if (substr($sFile, 0, 1) == '.' || is_dir($sPath))
        continue;

      $sFileType  = strtolower(substr(strrchr($sPath, '.'), 1));
      $iNameLen   = strlen($sFile) - 4;

      if ($sFileType == 'jpeg')
        $iNameLen--;

      $sFileName = substr($sFile, 0, $iNameLen);

      if ($sFileType == 'jpg' || $sFileType == 'jpeg' || $sFileType == 'png' || $sFileType == 'gif') {
        $aImgDim = getImageSize($sPath);

        if (!file_exists(Helper::removeSlash(PATH_UPLOAD . '/temp/' . $this->_sController . '/' . $sFile))) {
          $oImage = new Image($sFileName, 'temp', $sPath, $sFileType);
          $oImage->resizeAndCut('32', $this->_sController);
        }
      }

      else
        $aImgDim = '';

      $aFiles[] = array(
        'name'  => $sFile,
        'date'  => Array(
            'raw' => filectime($sPath),
            'w3c' => date('Y-m-d\TH:i:sP', filectime($sPath))),
        'size'  => Helper::fileSizeToString(Helper::getFileSize($sPath)),
        'type'  => $sFileType,
        'dim'   => $aImgDim,
        'url'   => WEBSITE_URL . Helper::addSlash(PATH_UPLOAD) . '/' . $this->_sController . '/' . $sFile,
        'url_destroy' => '/' . $this->_sController . '/' . $sFile . '/destroy'
      );
    }

    closedir($oDir);

    return $aFiles;
  }

  /**
   * Destroy a file and delete from HDD.
   *
   * @access public
   * @param mixed $sId the unique name of the file
   * @param string $sController controller to use, obsolete and only for not giving E_STRICT warnings
   * @return boolean status of query
   *
   */
  public function destroy($sId, $sController = '') {
    # We get the image information via GET
    $sPath = Helper::removeSlash(PATH_UPLOAD . '/' . $this->_sController . '/' . $sId);

{'fraction_non_alphanumeric': 0.17429406037000975, 'fraction_numerical': 0.0038948393378773127, 'mean_word_length': 2.584089323098395, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5181445', 'n_tokens_mistral': 1832, 'n_tokens_neox': 1772, 'n_words': 370}