コード例 #1
0
 function template_update_upload()
 {
     require_once JPATH_COMPONENT . DS . 'assets' . DS . 'export_helper.php';
     jimport('joomla.filesystem.file');
     $file = "";
     $msg = '';
     foreach ($_FILES as $k => $v) {
         // $msg .= 'key: '.$k.'<br />';
         // $msg .= 'val: '.$v.'<br />';
         if (strpos($k, 'uploadedupdatefile_') !== false && !empty($_FILES[$k]['name'])) {
             $file = $k;
         }
     }
     $arr = explode('_', $file);
     if (count($arr) > 1) {
         $tid = $arr[1];
         if (!is_numeric($tid)) {
             return "Error!";
         }
         // get previous file
         $ehelper = new OnepageTemplateHelper();
         $tt = $ehelper->getTemplate($tid);
         $target_path = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_onepage' . DS . 'export' . DS . 'templates' . DS;
         $newname = JFile::makesafe(basename($_FILES['uploadedupdatefile_' . $tid]['name']));
         if (file_exists($target_path . $newname) && $tt['file'] != $newname) {
             $msg = 'Another theme is using the same filename';
         } else {
             if (file_exists($target_path . $tt['file'])) {
                 if (!JFile::delete($target_path . $tt['file'])) {
                     $msg .= 'Could not remove old template file: ' . $tt['file'] . '<br />';
                 }
             }
             $msg .= $ehelper->updateFileName($tid, $newname);
             if (!empty($msg)) {
                 //$userfile = JRequest::getVar('uploadedupdatefile_'.$tid, null, 'files');
                 //var_dump($userfile); die();
                 $target_path = $target_path . $newname;
                 //echo $target_path.'<br />'; var_dump($_FILES); die();
                 if (JFile::upload($_FILES[$file]['tmp_name'], $target_path)) {
                     $msg .= "The template file " . $newname . " has been uploaded";
                 } else {
                     $msg .= "There was an error uploading the file, please try again! file: " . $newname;
                 }
             }
         }
     }
     if (empty($msg)) {
         $msg = 'O.K.';
     }
     //JFile::delete($_FILES[$file]['tmp_name']);
     $link = 'index.php?option=com_onepage&view=order_export';
     $this->setRedirect($link, $msg);
     return $msg;
     //die('som tu');
 }
コード例 #2
0
ファイル: config.php プロジェクト: aldegtyarev/stelsvelo
 function template_update_upload()
 {
     return false;
     jimport('joomla.filesystem.file');
     $file = "";
     $msg = '';
     foreach ($_FILES as $k => $v) {
         // $msg .= 'key: '.$k.'<br />';
         // $msg .= 'val: '.$v.'<br />';
         if (strpos($k, 'uploadedupdatefile_') !== false && !empty($_FILES[$k]['name'])) {
             $file = $k;
         }
     }
     $arr = explode('_', $file);
     if (count($arr) > 1) {
         $tid = $arr[1];
         if (!is_numeric($tid)) {
             return "Error!";
         }
         // get previous file
         $ehelper = new OnepageTemplateHelper();
         $tt = $ehelper->getTemplate($tid);
         $target_path = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_onepage' . DS . 'export' . DS;
         if (file_exists($target_path . $tt['file'])) {
             if (!JFile::delete($target_path . $tt['file'])) {
                 $msg .= 'Could not remove old template file: ' . $tt['file'];
             }
         }
         $newname = JFile::makesafe(basename($_FILES['uploadedupdatefile_' . $tid]['name']));
         $msg .= $ehelper->updateFileName($tid, $newname);
         //$userfile = JRequest::getVar('uploadedupdatefile_'.$tid, null, 'files');
         //var_dump($userfile); die();
         $target_path = $target_path . $newname;
         if (JFile::upload($_FILES[$file]['tmp_name'], $target_path)) {
             $msg .= "The template file " . $newname . " has been uploaded";
         } else {
             $msg .= "There was an error uploading the file, please try again! file: " . $newname;
         }
     } else {
         $msg .= "There was an error uploading the file, please try again! ";
     }
     return $msg;
 }