neo_fileshare

  • bipi bipi
    T3PO
    0 x
    16 Beiträge
    0 Hilfreiche Beiträge
    08. 03. 2012, 10:49

    Hallo
    ich verwende die EXT neo_fileshare und nach einem Serverumzug werden die Dateirechte der upgeloadeten Dateien immer mit 0600 gesetzt statt mit 0644, Ich glaub da muss in der EXT irgendwo ein chmod($new_file, 0644); hin, nur wo weiß ich nicht?? könntet Ihr mir da bitte helfen!

    anbei die class.tx_neofileshare_pi2.php

    1. <?php
    2. /***************************************************************
    3. * Copyright notice
    4. *
    5. * (c) 2007 Neonaut <info@neonaut.de>
    6. * All rights reserved
    7. *
    8. * This script is part of the TYPO3 project. The TYPO3 project is
    9. * free software; you can redistribute it and/or modify
    10. * it under the terms of the GNU General Public License as published by
    11. * the Free Software Foundation; either version 2 of the License, or
    12. * (at your option) any later version.
    13. *
    14. * The GNU General Public License can be found at
    15. * http://www.gnu.org/copyleft/gpl.html.
    16. *
    17. * This script is distributed in the hope that it will be useful,
    18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
    19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    20. * GNU General Public License for more details.
    21. *
    22. * This copyright notice MUST APPEAR in all copies of the script!
    23. ***************************************************************/
    24.  
    25. require_once(PATH_tslib.'class.tslib_pibase.php');
    26.  
    27.  
    28. /**
    29.  * Plugin 'Download' for the 'neo_fileshare' extension.
    30.  *
    31.  * @author Neonaut <info@neonaut.de>
    32.  * @package TYPO3
    33.  * @subpackage tx_neofileshare
    34.  */
    35. class tx_neofileshare_pi2 extends tslib_pibase {
    36. var $prefixId = 'tx-neofileshare-pi2'; // Same as class name
    37. var $scriptRelPath = 'pi2/class.tx_neofileshare_pi2.php'; // Path to this script relative to the extension dir.
    38. var $extKey = 'neo_fileshare'; // The extension key.
    39.  
    40. var $table = 'tx_neofileshare_files'; // The extension Table
    41. var $uploadFolder = 'uploads/tx_neofileshare'; // The extension UploadFolder (reset by TCA Conf)
    42.  
    43. var $cObj;
    44. var $conf;
    45. var $ffAr;
    46.  
    47. /**
    48. * Main method of your PlugIn
    49. *
    50. * @param string $content: The content of the PlugIn
    51. * @param array $conf: The PlugIn Configuration
    52. * @return The content that should be displayed on the website
    53. */
    54. function main($content,$conf) {
    55. $this->conf = $conf;
    56. // Set the UploadFolder Path
    57. t3lib_div::loadTCA($this->table);
    58. $this->uploadFolder = $GLOBALS['TCA']['tx_neofileshare_files']['columns']['file']['config']['uploadfolder'];
    59.  
    60. // Default orderBy Value
    61. if ( !$this->piVars['sort'] ) {
    62. $this->piVars['sort'] = ( !$conf['defaultOrder'] ) ? 'crdate:1' : $conf['defaultOrder'];
    63. }
    64.  
    65. // Flexforms
    66. $this->pi_initPIflexForm();
    67.  
    68. $this->ffAr['results_at_a_time'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'results_at_a_time');
    69. $this->ffAr['maxPages'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'maxPages');
    70. $this->ffAr['maxFileTitle'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'maxFileTitle');
    71. $this->ffAr['orderBy'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'selectOrderBy');
    72. $this->ffAr['order'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'selectOrder');
    73.  
    74. switch((string)$conf['CMD']) {
    75. case 'rm':
    76. list($t) = explode(':',$this->cObj->currentRecord);
    77. $this->internal['currentTable']= $t;
    78. $this->internal['currentRow'] = $this->cObj->data;
    79.  
    80. $this->neo_rmFile();
    81. default:
    82. if (strstr($this->cObj->currentRecord,'tt_content')) {
    83. $conf['pidList'] = $this->cObj->data['pages'];
    84. $conf['recursive'] = $this->cObj->data['recursive'];
    85. }
    86.  
    87. require_once(PATH_site.'typo3/sysext/cms/tslib/class.tslib_content.php');
    88. $this->cObj = t3lib_div::makeInstance('tslib_cObj');
    89.  
    90. return $this->pi_wrapInBaseClass($this->listView($content,$conf));
    91. break;
    92. }
    93. }
    94.  
    95. /**
    96. * Shows a list of database entries
    97. *
    98. * @param string $content: content of the PlugIn
    99. * @param array $conf: PlugIn Configuration
    100. * @return HTML list of table entries
    101. */
    102. function listView($content,$conf) {
    103. if ($this->piVars['showUid']) { // If a single element should be displayed:
    104. $this->internal['currentTable'] = 'tx_neofileshare_files';
    105. $this->internal['currentRow'] = $this->pi_getRecord('tx_neofileshare_files',$this->piVars['showUid']);
    106.  
    107. $this->neo_rmFile();
    108. }
    109.  
    110. $this->conf = $conf; // Setting the TypoScript passed to this function in $this->conf
    111. $this->pi_setPiVarDefaults();
    112. $this->pi_loadLL(); // Loading the LOCAL_LANG values
    113. $this->pi_USER_INT_obj=1; // Configuring so caching is not expected. This value means that no cHash params are ever set. We do this, because it's a USER_INT object!
    114. $lConf = $this->conf['listView.']; // Local settings for the listView function
    115.  
    116. $items = array();
    117. if (!isset($this->piVars['pointer'])) $this->piVars['pointer']=0;
    118. if (!isset($this->piVars['mode'])) $this->piVars['mode']=1;
    119.  
    120. // Initializing the query parameters:
    121. list($this->internal['orderBy'],$this->internal['descFlag']) = explode(':',$this->piVars['sort']);
    122. $this->internal['results_at_a_time'] = t3lib_div::intInRange($lConf['results_at_a_time'],0,1000,3); // Number of results to show in a listing.
    123. $this->internal['maxPages'] = t3lib_div::intInRange($lConf['maxPages'],0,1000,2);; // The maximum number of "pages" in the browse-box: "Page 1", "Page 2", etc.
    124. $this->internal['searchFieldList'] = 'title,description,file,crdate,fe_group,fe_owner,tstamp,crdate,pid,uid';
    125. $this->internal['orderByList'] ='title,description,crdate,fe_owner';
    126. #$this->internal['searchFieldList'] = 'title,description,file';
    127.  
    128. // Flexform override
    129. $this->internal['orderBy'] = ( strlen($this->ffAr['orderBy']) > 0 ) ? $this->ffAr['orderBy'] : $this->internal['orderBy'];
    130. $this->internal['results_at_a_time'] = ( strlen($this->ffAr['results_at_a_time']) > 0 ) ? $this->ffAr['results_at_a_time'] : $this->internal['results_at_a_time'];
    131. $this->internal['maxPages'] = ( strlen($this->ffAr['maxPages']) > 0 ) ? $this->ffAr['maxPages'] : $this->internal['maxPages'];
    132. $this->internal['descFlag'] = ( strlen($this->ffAr['order']) > 0 ) ? $this->ffAr['order'] : $this->internal['descFlag'];
    133. $this->internal['descFlag'] = ( $this->internal['descFlag'] < 0 ) ? 1 : $this->internal['descFlag'];
    134.  
    135. // Get number of records:
    136. $res = $this->pi_exec_query('tx_neofileshare_files',1);
    137. list($this->internal['res_count']) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
    138.  
    139. // Make listing query, pass query to SQL database:
    140. $res = $this->pi_exec_query('tx_neofileshare_files');
    141. $this->internal['currentTable'] = 'tx_neofileshare_files';
    142.  
    143. // Put the whole list together:
    144. $fullTable=''; // Clear var;
    145.  
    146. // Adds the search box:
    147. $fullTable.=$this->pi_list_searchBox();
    148.  
    149. // Adds the result browser:
    150. $browseWrap = array(
    151. 'browseBoxWrap' => '<div class="browseBoxWrap">|</div>',
    152. 'showResultsWrap' => '<div class="showResultsWrap">|</div>',
    153. 'browseLinksWrap' => '<div class="browseLinksWrap">|</div>',
    154. //'showResultsNumbersWrap' => '<span class="showResultsNumbersWrap">|</span>',
    155. 'disabledLinkWrap' => '<span class="disabledLinkWrap">|</span>',
    156. 'inactiveLinkWrap' => '<span class="inactiveLinkWrap">|</span>',
    157. 'activeLinkWrap' => '<span class="activeLinkWrap">|</span>'
    158. );
    159.  
    160. $fullTable.=$this->pi_list_browseresults(1,'',$browseWrap);
    161.  
    162. // Adds the whole list table
    163. if ( $GLOBALS['TYPO3_DB']->sql_num_rows($res) > 0 ) {
    164. $fullTable.=$this->pi_list_makelist($res);
    165. } else {
    166. $fullTable .= '<div class="'.$this->prefixId.'-status">'.$this->getFieldHeader('nomatches').'</div>';
    167. }
    168.  
    169. // Returns the content from the plugin.
    170. return $fullTable;
    171. }
    172.  
    173. /**
    174. * Returns a single table row for list view
    175. *
    176. * @param integer $c: Counter for odd / even behavior
    177. * @return A HTML table row
    178. */
    179. function pi_list_row($c) {
    180. $editPanel = $this->pi_getEditPanel();
    181. if ($editPanel) $editPanel='<TD>'.$editPanel.'</TD>';
    182.  
    183. return '<tr'.($c%2 ? $this->pi_classParam('listrow-odd') : '').'>
    184. <td><p>'.$this->getFieldContent('title').'</p></td>
    185. <td><p>'.$this->getFieldContent('description').'</p></td>
    186. <td><p>'.date("d.m.Y",$this->getFieldContent('crdate')).'</p></td>
    187. <td><p>'.$this->neo_getUserName($this->getFieldContent('fe_owner')).'</p></td>'.
    188. (($GLOBALS['TSFE']->fe_user->user['uid']) ? '<td><p>'.$this->neo_getDeleteLink($this->getFieldContent('fe_owner')).'</p></td>' : '').
    189. '</tr>';
    190. }
    191.  
    192. /**
    193. * Returns a table row with column names of the table
    194. *
    195. * @return A HTML table row
    196. */
    197. function pi_list_header() {
    198. return '<tr'.$this->pi_classParam('listrow-header').'>
    199. <td><p>'.$this->getFieldHeader_sortLink('title').'</p></td>
    200. <td><p>'.$this->getFieldHeader_sortLink('description').'</p></td>
    201. <td><p>'.$this->getFieldHeader_sortLink('crdate').'</p></td>
    202. <td><p>'.$this->getFieldHeader_sortLink('fe_owner').'</p></td>'.
    203. (($GLOBALS['TSFE']->fe_user->user['uid']) ? '<td><p>'.$this->getFieldHeader('delete').'</p></td>' : '').
    204. '</tr>';
    205. }
    206.  
    207. /**
    208. * Returns the content of a given field
    209. *
    210. * @param string $fN: name of table field
    211. * @return Value of the field
    212. */
    213. function getFieldContent($fN) {
    214. switch($fN) {
    215. case "title":
    216. // This will wrap the title in a link.
    217. $conf = array(
    218. "parameter" => $this->uploadFolder."/".rawurlencode($this->internal['currentRow']['file']),
    219. "ATagParams" => 'onclick="window.open(this.href); return false;"',
    220. "title" => $this->internal['currentRow']['file']
    221. );
    222.  
    223. $title = ( strlen($this->internal['currentRow']['title']) > 0 ) ? $this->internal['currentRow']['title'] : $this->internal['currentRow']['file'];
    224.  
    225. // If no Title exists, use the Filename
    226. if ( strlen($this->internal['currentRow']['title']) <= 0 ) {
    227. $maxFileTitle = ( $this->conf['maxFileTitle'] > 0 ) ? $this->conf['maxFileTitle'] : 15;
    228. $title = preg_replace('/^([0-9]{4}-[0-9]{2}-[0-9]{2}_[0-9]{2}-[0-9]{2}-[0-9]{2}_)(.*)\.(.*[^.])$/i','$2',$title);
    229.  
    230. // If the Filename is to long, reduce it!
    231. if ( strlen($title) > $maxFileTitle ) {
    232. $title = substr($title,0,$maxFileTitle).'...';
    233. }
    234. }
    235.  
    236. if ( strlen($this->piVars['sword']) > 0 ) {
    237. $title = preg_replace("/(".$this->piVars['sword'].")/i",'<span class="'.$this->prefixId.'-sword">\\1</span>',$title);
    238. }
    239.  
    240. return $this->cObj->typoLink($title, $conf);
    241. break;
    242.  
    243. case "description":
    244. $title = $this->internal['currentRow']['description'];
    245.  
    246. if ( strlen($this->piVars['sword']) > 0 ) {
    247. $title = preg_replace("/(".$this->piVars['sword'].")/i",'<span class="'.$this->prefixId.'-sword">\\1</span>',$title);
    248. }
    249.  
    250. return $title;
    251. break;
    252.  
    253. default:
    254. return $this->internal['currentRow'][$fN];
    255. break;
    256. }
    257. }
    258.  
    259. /**
    260. * Returns the label for a fieldname from local language array
    261. *
    262. * @param [type] $fN: ...
    263. * @return [type] ...
    264. */
    265. function getFieldHeader($fN) {
    266. switch($fN) {
    267. case "title":
    268. return $this->pi_getLL('listFieldHeader_title','<em>title</em>');
    269. break;
    270. default:
    271. return $this->pi_getLL('listFieldHeader_'.$fN,'['.$fN.']');
    272. break;
    273. }
    274. }
    275.  
    276. /**
    277. * Returns a sorting link for a column header
    278. *
    279. * @param string $fN: Fieldname
    280. * @return The fieldlabel wrapped in link that contains sorting vars
    281. */
    282. function getFieldHeader_sortLink($fN) {
    283. $str = $this->pi_linkTP_keepPIvars($this->getFieldHeader($fN),array('sort'=>$fN.':'.($this->internal['descFlag']?0:1)));
    284. return preg_replace('=^(<a)(.*[^>])>(.*)</a>$=i','$1$2 title="Order by $3">$3</a>',$str);
    285. }
    286.  
    287.  
    288. /**
    289. * Returns the FrontEnd Username of a given UID
    290. *
    291. * @param integer $uid: UID of FE_User
    292. * @return string Returns the Username Field of the table fe_user
    293. */
    294. function neo_getUserName($uid) {
    295. $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('username','fe_users',"uid = '".(int)$uid."'",'','username','1');
    296. $retVal = $GLOBALS['TYPO3_DB']->sql_fetch_row($result);
    297.  
    298. $GLOBALS['TYPO3_DB']->sql_free_result($result);
    299.  
    300. return $retVal[0];
    301. }
    302.  
    303. /**
    304. * Checks whether the current User is able to delete the current File and returns the Link for deleting Option
    305. *
    306. * @param integer $fuid: UID of the File Owner
    307. * @return string Returns the Delete Link if available for this file
    308. */
    309. function neo_getDeleteLink($fowner_uid) {
    310. if ( ($GLOBALS['TSFE']->fe_user->user['uid'] > 0) && ($GLOBALS['TSFE']->fe_user->user['uid'] === $fowner_uid) ) {
    311. $conf = array(
    312. "parameter" => $this->pi_list_linkSingle($this->getFieldHeader('deleteButton'),$this->internal['currentRow']['uid'],false,array(),true),
    313. "ATagParams" => 'onclick="return confirm(\''.$this->getFieldHeader('confirmQuestion').'\')"'
    314. );
    315. return $link = $this->cObj->typoLink($this->getFieldHeader('deleteButton'), $conf);
    316. } else return false;
    317. }
    318.  
    319. function neo_rmFile() {
    320. if ( ($GLOBALS['TSFE']->fe_user->user['uid'] > 0) && ($GLOBALS['TSFE']->fe_user->user['uid'] === $this->internal['currentRow']['fe_owner']) ) {
    321. if ( $this->conf['feHiddenDelete'] == 0 ) {
    322. $path = t3lib_div::getFileAbsFileName($GLOBALS['TCA']['tx_neofileshare_files']['columns']['file']['config']['uploadfolder']);
    323. $file = &$this->internal['currentRow']['file'];
    324.  
    325. if ( @unlink($path."/".$file) ) {
    326. $GLOBALS['TYPO3_DB']->exec_DELETEquery((string)$this->internal['currentTable'],"uid = '".(int)$this->internal['currentRow']['uid']."'");
    327. }
    328. } else {
    329. $query = 'UPDATE '.(string)$this->internal['currentTable'].' SET hidden = 1 WHERE uid = '.(int)$this->internal['currentRow']['uid'];
    330. $GLOBALS['TYPO3_DB']->sql_query($query);
    331. }
    332. }
    333. }
    334. }
    335.  
    336.  
    337.  
    338. if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/neo_fileshare/pi2/class.tx_neofileshare_pi2.php']) {
    339. include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/neo_fileshare/pi2/class.tx_neofileshare_pi2.php']);
    340. }
    341.  
    342. ?>


  • 1
  • bipi bipi
    T3PO
    0 x
    16 Beiträge
    0 Hilfreiche Beiträge
    09. 03. 2012, 08:04

    Hier die Lösung für alle die es mal brauchen, einfach in der function neo_saveUpload

    chmod ($path."/".$filename,644);

    ergänzen

    1. function neo_saveUpload($POST) {
    2. $storagePid = ( strlen($this->ffAr['storagePid']) > 0 ) ? $this->ffAr['storagePid'] : $this->conf['storage_pid'];
    3.  
    4. $filename = $this->neo_checkFilename(date("Y-m-d_H-i-s")."_".$_FILES[$this->prefixId]['name']['file']);
    5. $user_id = (int)$GLOBALS['TSFE']->fe_user->user['uid'];
    6. $group_id = ( $POST['publicAccess'] == 0 ) ? (int)$GLOBALS['TSFE']->fe_user->user['usergroup'] : 0;
    7. $path = t3lib_div::getFileAbsFileName($GLOBALS['TCA']['tx_neofileshare_files']['columns']['file']['config']['uploadfolder']);
    8. $pid = (($storagePid > 0) ? $storagePid : $GLOBALS['TSFE']->id);
    9.  
    10. if ( @move_uploaded_file($_FILES[$this->prefixId]['tmp_name']['file'],$path."/".$filename) ) {
    11. chmod ($path."/".$filename,644);
    12. $insertArr = array(
    13. "pid" => $pid,
    14. "tstamp" => time(),
    15. "crdate" => time(),
    16. "cruser_id" => $user_id,
    17. "fe_group" => $group_id,
    18. "title" => htmlentities(strip_tags($POST['title'])),
    19. "description" => str_replace("\r","",str_replace("\n","",htmlentities(strip_tags($POST['description'])))),
    20. "file" => $filename,
    ....

  • 1