neo_fileshare
| Autor | Nachricht |
|---|---|
|
Verfasst am: 08. 03. 2012 [10:49]
|
|
|
bipi
Themenersteller
Dabei seit: 04.05.2010
Beiträge: 14
|
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 PHP <?php /*************************************************************** * Copyright notice * * (c) 2007 Neonaut <info@neonaut.de> * All rights reserved * * This script is part of the TYPO3 project. The TYPO3 project is * free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * The GNU General Public License can be found at * http://www.gnu.org/copyleft/gpl.html. * * This script is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ require_once(PATH_tslib.'class.tslib_pibase.php'); /** * Plugin 'Download' for the 'neo_fileshare' extension. * * @author Neonaut <info@neonaut.de> * @package TYPO3 * @subpackage tx_neofileshare */ class tx_neofileshare_pi2 extends tslib_pibase { var $prefixId = 'tx-neofileshare-pi2'; // Same as class name var $scriptRelPath = 'pi2/class.tx_neofileshare_pi2.php'; // Path to this script relative to the extension dir. var $extKey = 'neo_fileshare'; // The extension key. var $table = 'tx_neofileshare_files'; // The extension Table var $uploadFolder = 'uploads/tx_neofileshare'; // The extension UploadFolder (reset by TCA Conf) var $cObj; var $conf; var $ffAr; /** * Main method of your PlugIn * * @param string $content: The content of the PlugIn * @param array $conf: The PlugIn Configuration * @return The content that should be displayed on the website */ function main($content,$conf) { $this->conf = $conf; // Set the UploadFolder Path t3lib_div::loadTCA($this->table); $this->uploadFolder = $GLOBALS['TCA']['tx_neofileshare_files']['columns']['file']['config']['uploadfolder']; // Default orderBy Value if ( !$this->piVars['sort'] ) { $this->piVars['sort'] = ( !$conf['defaultOrder'] ) ? 'crdate:1' : $conf['defaultOrder']; } // Flexforms $this->pi_initPIflexForm(); $this->ffAr['results_at_a_time'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'results_at_a_time'); $this->ffAr['maxPages'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'maxPages'); $this->ffAr['maxFileTitle'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'maxFileTitle'); $this->ffAr['orderBy'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'selectOrderBy'); $this->ffAr['order'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'selectOrder'); switch((string)$conf['CMD']) { case 'rm': list($t) = explode(':',$this->cObj->currentRecord); $this->internal['currentTable']= $t; $this->internal['currentRow'] = $this->cObj->data; $this->neo_rmFile(); default: if (strstr($this->cObj->currentRecord,'tt_content')) { $conf['pidList'] = $this->cObj->data['pages']; $conf['recursive'] = $this->cObj->data['recursive']; } require_once(PATH_site.'typo3/sysext/cms/tslib/class.tslib_content.php'); $this->cObj = t3lib_div::makeInstance('tslib_cObj'); return $this->pi_wrapInBaseClass($this->listView($content,$conf)); break; } } /** * Shows a list of database entries * * @param string $content: content of the PlugIn * @param array $conf: PlugIn Configuration * @return HTML list of table entries */ function listView($content,$conf) { if ($this->piVars['showUid']) { // If a single element should be displayed: $this->internal['currentTable'] = 'tx_neofileshare_files'; $this->internal['currentRow'] = $this->pi_getRecord('tx_neofileshare_files',$this->piVars['showUid']); $this->neo_rmFile(); } $this->conf = $conf; // Setting the TypoScript passed to this function in $this->conf $this->pi_setPiVarDefaults(); $this->pi_loadLL(); // Loading the LOCAL_LANG values $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! $lConf = $this->conf['listView.']; // Local settings for the listView function $items = array(); if (!isset($this->piVars['pointer'])) $this->piVars['pointer']=0; if (!isset($this->piVars['mode'])) $this->piVars['mode']=1; // Initializing the query parameters: list($this->internal['orderBy'],$this->internal['descFlag']) = explode(':',$this->piVars['sort']); $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. $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. $this->internal['searchFieldList'] = 'title,description,file,crdate,fe_group,fe_owner,tstamp,crdate,pid,uid'; $this->internal['orderByList'] ='title,description,crdate,fe_owner'; #$this->internal['searchFieldList'] = 'title,description,file'; // Flexform override $this->internal['orderBy'] = ( strlen($this->ffAr['orderBy']) > 0 ) ? $this->ffAr['orderBy'] : $this->internal['orderBy']; $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']; $this->internal['maxPages'] = ( strlen($this->ffAr['maxPages']) > 0 ) ? $this->ffAr['maxPages'] : $this->internal['maxPages']; $this->internal['descFlag'] = ( strlen($this->ffAr['order']) > 0 ) ? $this->ffAr['order'] : $this->internal['descFlag']; $this->internal['descFlag'] = ( $this->internal['descFlag'] < 0 ) ? 1 : $this->internal['descFlag']; // Get number of records: $res = $this->pi_exec_query('tx_neofileshare_files',1); list($this->internal['res_count']) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res); // Make listing query, pass query to SQL database: $res = $this->pi_exec_query('tx_neofileshare_files'); $this->internal['currentTable'] = 'tx_neofileshare_files'; // Put the whole list together: $fullTable=''; // Clear var; // Adds the search box: $fullTable.=$this->pi_list_searchBox(); // Adds the result browser: $browseWrap = array( 'browseBoxWrap' => '<div class="browseBoxWrap">|</div>', 'showResultsWrap' => '<div class="showResultsWrap">|</div>', 'browseLinksWrap' => '<div class="browseLinksWrap">|</div>', //'showResultsNumbersWrap' => '<span class="showResultsNumbersWrap">|</span>', 'disabledLinkWrap' => '<span class="disabledLinkWrap">|</span>', 'inactiveLinkWrap' => '<span class="inactiveLinkWrap">|</span>', 'activeLinkWrap' => '<span class="activeLinkWrap">|</span>' ); $fullTable.=$this->pi_list_browseresults(1,'',$browseWrap); // Adds the whole list table if ( $GLOBALS['TYPO3_DB']->sql_num_rows($res) > 0 ) { $fullTable.=$this->pi_list_makelist($res); } else { $fullTable .= '<div class="'.$this->prefixId.'-status">'.$this->getFieldHeader('nomatches').'</div>'; } // Returns the content from the plugin. return $fullTable; } /** * Returns a single table row for list view * * @param integer $c: Counter for odd / even behavior * @return A HTML table row */ function pi_list_row($c) { $editPanel = $this->pi_getEditPanel(); if ($editPanel) $editPanel='<TD>'.$editPanel.'</TD>'; return '<tr'.($c%2 ? $this->pi_classParam('listrow-odd') : '').'> <td><p>'.$this->getFieldContent('title').'</p></td> <td><p>'.$this->getFieldContent('description').'</p></td> <td><p>'.date("d.m.Y",$this->getFieldContent('crdate')).'</p></td> <td><p>'.$this->neo_getUserName($this->getFieldContent('fe_owner')).'</p></td>'. (($GLOBALS['TSFE']->fe_user->user['uid']) ? '<td><p>'.$this->neo_getDeleteLink($this->getFieldContent('fe_owner')).'</p></td>' : ''). '</tr>'; } /** * Returns a table row with column names of the table * * @return A HTML table row */ function pi_list_header() { return '<tr'.$this->pi_classParam('listrow-header').'> <td><p>'.$this->getFieldHeader_sortLink('title').'</p></td> <td><p>'.$this->getFieldHeader_sortLink('description').'</p></td> <td><p>'.$this->getFieldHeader_sortLink('crdate').'</p></td> <td><p>'.$this->getFieldHeader_sortLink('fe_owner').'</p></td>'. (($GLOBALS['TSFE']->fe_user->user['uid']) ? '<td><p>'.$this->getFieldHeader('delete').'</p></td>' : ''). '</tr>'; } /** * Returns the content of a given field * * @param string $fN: name of table field * @return Value of the field */ function getFieldContent($fN) { switch($fN) { case "title": // This will wrap the title in a link. $conf = array( "parameter" => $this->uploadFolder."/".rawurlencode($this->internal['currentRow']['file']), "ATagParams" => 'onclick="window.open(this.href); return false;"', "title" => $this->internal['currentRow']['file'] ); $title = ( strlen($this->internal['currentRow']['title']) > 0 ) ? $this->internal['currentRow']['title'] : $this->internal['currentRow']['file']; // If no Title exists, use the Filename if ( strlen($this->internal['currentRow']['title']) <= 0 ) { $maxFileTitle = ( $this->conf['maxFileTitle'] > 0 ) ? $this->conf['maxFileTitle'] : 15; $title = preg_replace('/^([0-9]{4}-[0-9]{2}-[0-9]{2}_[0-9]{2}-[0-9]{2}-[0-9]{2}_)(.*)\.(.*[^.])$/i','',$title); // If the Filename is to long, reduce it! if ( strlen($title) > $maxFileTitle ) { $title = substr($title,0,$maxFileTitle).'...'; } } if ( strlen($this->piVars['sword']) > 0 ) { $title = preg_replace("/(".$this->piVars['sword']."<img src="typo3conf/ext/mm_forum//res/smilies/icon_wink.gif" alt="icon_wink.gif" />/i",'<span class="'.$this->prefixId.'-sword">\1</span>',$title); } return $this->cObj->typoLink($title, $conf); break; case "description": $title = $this->internal['currentRow']['description']; if ( strlen($this->piVars['sword']) > 0 ) { $title = preg_replace("/(".$this->piVars['sword']."<img src="typo3conf/ext/mm_forum//res/smilies/icon_wink.gif" alt="icon_wink.gif" />/i",'<span class="'.$this->prefixId.'-sword">\1</span>',$title); } return $title; break; default: return $this->internal['currentRow'][$fN]; break; } } /** * Returns the label for a fieldname from local language array * * @param [type] $fN: ... * @return [type] ... */ function getFieldHeader($fN) { switch($fN) { case "title": return $this->pi_getLL('listFieldHeader_title','<em>title</em>'); break; default: return $this->pi_getLL('listFieldHeader_'.$fN,'['.$fN.']'); break; } } /** * Returns a sorting link for a column header * * @param string $fN: Fieldname * @return The fieldlabel wrapped in link that contains sorting vars */ function getFieldHeader_sortLink($fN) { $str = $this->pi_linkTP_keepPIvars($this->getFieldHeader($fN),array('sort'=>$fN.':'.($this->internal['descFlag']?0:1))); return preg_replace('=^(<a)(.*[^>])>(.*)</a>$=i',' title="Order by "></a>',$str); } /** * Returns the FrontEnd Username of a given UID * * @param integer $uid: UID of FE_User * @return string Returns the Username Field of the table fe_user */ function neo_getUserName($uid) { $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('username','fe_users',"uid = '".(int)$uid."'",'','username','1'); $retVal = $GLOBALS['TYPO3_DB']->sql_fetch_row($result); $GLOBALS['TYPO3_DB']->sql_free_result($result); return $retVal[0]; } /** * Checks whether the current User is able to delete the current File and returns the Link for deleting Option * * @param integer $fuid: UID of the File Owner * @return string Returns the Delete Link if available for this file */ function neo_getDeleteLink($fowner_uid) { if ( ($GLOBALS['TSFE']->fe_user->user['uid'] > 0) && ($GLOBALS['TSFE']->fe_user->user['uid'] === $fowner_uid) ) { $conf = array( "parameter" => $this->pi_list_linkSingle($this->getFieldHeader('deleteButton'),$this->internal['currentRow']['uid'],false,array(),true), "ATagParams" => 'onclick="return confirm(\''.$this->getFieldHeader('confirmQuestion').'\')"' ); return $link = $this->cObj->typoLink($this->getFieldHeader('deleteButton'), $conf); } else return false; } function neo_rmFile() { if ( ($GLOBALS['TSFE']->fe_user->user['uid'] > 0) && ($GLOBALS['TSFE']->fe_user->user['uid'] === $this->internal['currentRow']['fe_owner']) ) { if ( $this->conf['feHiddenDelete'] == 0 ) { $path = t3lib_div::getFileAbsFileName($GLOBALS['TCA']['tx_neofileshare_files']['columns']['file']['config']['uploadfolder']); $file = &$this->internal['currentRow']['file']; if ( @unlink($path."/".$file) ) { $GLOBALS['TYPO3_DB']->exec_DELETEquery((string)$this->internal['currentTable'],"uid = '".(int)$this->internal['currentRow']['uid']."'"<img src="typo3conf/ext/mm_forum//res/smilies/icon_wink.gif" alt="icon_wink.gif" />; } } else { $query = 'UPDATE '.(string)$this->internal['currentTable'].' SET hidden = 1 WHERE uid = '.(int)$this->internal['currentRow']['uid']; $GLOBALS['TYPO3_DB']->sql_query($query); } } } } if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/neo_fileshare/pi2/class.tx_neofileshare_pi2.php']) { include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/neo_fileshare/pi2/class.tx_neofileshare_pi2.php']); } ?> |
|
Verfasst am: 09. 03. 2012 [08:04]
|
|
|
bipi
Themenersteller
Dabei seit: 04.05.2010
Beiträge: 14
|
Hier die Lösung für alle die es mal brauchen, einfach in der function neo_saveUpload chmod ($path."/".$filename,644); ergänzen PHP function neo_saveUpload($POST) {
$storagePid = ( strlen($this->ffAr['storagePid']) > 0 ) ? $this->ffAr['storagePid'] : $this->conf['storage_pid'];
$filename = $this->neo_checkFilename(date("Y-m-d_H-i-s"<img src="typo3conf/ext/mm_forum//res/smilies/icon_wink.gif" alt="icon_wink.gif" />."_".$_FILES[$this->prefixId]['name']['file']);
$user_id = (int)$GLOBALS['TSFE']->fe_user->user['uid'];
$group_id = ( $POST['publicAccess'] == 0 ) ? (int)$GLOBALS['TSFE']->fe_user->user['usergroup'] : 0;
$path = t3lib_div::getFileAbsFileName($GLOBALS['TCA']['tx_neofileshare_files']['columns']['file']['config']['uploadfolder']);
$pid = (($storagePid > 0) ? $storagePid : $GLOBALS['TSFE']->id);
if ( @move_uploaded_file($_FILES[$this->prefixId]['tmp_name']['file'],$path."/".$filename) ) {
chmod ($path."/".$filename,644);
$insertArr = array(
"pid" => $pid,
"tstamp" => time(),
"crdate" => time(),
"cruser_id" => $user_id,
"fe_group" => $group_id,
"title" => htmlentities(strip_tags($POST['title'])),
"description" => str_replace("\r","",str_replace("\n","",htmlentities(strip_tags($POST['description'])))),
"file" => $filename, |



