Example #1
0
 $record_ids = explode('|', $ids);
 $table_fields = explode('|', $_REQUEST['table_fields']);
 if (is_array($record_ids)) {
     foreach ($record_ids as $id) {
         $record = DB::getRecord($_REQUEST['current_url'], $id);
         $files = DB::getFiles($_REQUEST['current_url'] . '_files', $id);
         if ($files) {
             $i = 1;
             foreach ($files as $row) {
                 $i = $name_in_zip != $old_name ? 1 : $i;
                 $f_name = $row['field_name'];
                 $suffix = '_' . $suffixes[$f_name];
                 $row['name'] = $row['name'] ? $row['name'] : $row['f_id'] . '_' . $row['id'];
                 $url = File::fileExists($row['name'] . $suffix . '.' . $row['ext'], $CFG->default_upload_location, $_REQUEST['current_url']);
                 if (!$url) {
                     $url = File::fileExists($row['f_id'] . '_' . $row['id'] . '.' . $row['ext'], $CFG->default_upload_location, $_REQUEST['current_url']);
                 }
                 if ($url) {
                     $name_parts = array();
                     if ($table_fields) {
                         foreach ($table_fields as $field_name) {
                             $name_parts[] = str_replace(' ', '_', $record[$field_name]);
                         }
                     }
                     $name_in_zip = count($name_parts) > 0 ? implode('_', $name_parts) . '_' . $i . '.' . $row['ext'] : $url;
                     $str = file_get_contents($url);
                     $decrypted = Encryption::decrypt($str);
                     $zip->addFromString($name_in_zip, $decrypted);
                 }
                 $old_name = $name_in_zip;
                 $i++;
Example #2
0
 function deleteLike($search, $dir)
 {
     if (!$search || !$dir) {
         return false;
     }
     $files = scandir($CFG->dirroot . $dir);
     $matches = preg_grep("/{$search}(.)+/", $files);
     if ($matches) {
         foreach ($matches as $file) {
             $url = File::fileExists($file, $dir);
             if ($url) {
                 unlink($url);
             }
         }
     }
 }
Example #3
0
 /** ConvertPricelist
  *
  * Функция конвертации / без учета настроек
  * xls, xml, xlsx, ods, html, htm файлов в csv
  * 
  * @param  [string] $infile        [входной файл]
  * @param  [string] $pathToConvert [путь для экспорта]
  * @param  [number] $limit         [количество экспортируемых строк]
  **/
 public function convertXLStoCSVWithoutSettings($infile, $pathToConvert, $limit = false)
 {
     //проверить существование входящего файла
     if (!File::fileExists($infile)) {
         throw new Exception("Входящий файл " . $infile . " не существует");
     }
     $phpExcelPath = Yii::getPathOfAlias('core.extensions.PHPExcel.Classes');
     //выключаем autoloader yii
     // spl_autoload_unregister(array('YiiBase', 'autoload'));
     include_once $phpExcelPath . DS . 'PHPExcel.php';
     $this->objReader = PHPExcel_IOFactory::createReaderForFile($infile);
     $this->objReader->setReadDataOnly(false);
     //из за того что файл может загружаться долго то соединение может зависнуть
     Yii::app()->db->setActive(false);
     $this->objPHPExcel = $this->objReader->load($infile);
     //снова открываем соединение
     Yii::app()->db->setActive(true);
     $ext = File::getFileExtension($infile);
     $fileName = File::getFileName($infile);
     $result = [];
     //результирующий массив файлов
     $path = Yii::getPathOfAlias('core.extensions.SimpleExcel');
     require_once $path . DS . "SimpleExcel.php";
     $idSupplier = basename(dirname(dirname($infile)));
     foreach ($this->objPHPExcel->getWorksheetIterator() as $worksheet) {
         Yii::app()->db->setActive(true);
         $sheetName = $worksheet->getTitle();
         //slug sheetname
         Yii::import('core.behaviors.SlugBehavior');
         $slugger = new SlugBehavior();
         $sheetName = $slugger->makeSlug($sheetName);
         $outFileName = $fileName . "-" . $sheetName . ".csv";
         $outfile = $pathToConvert . DS . $outFileName;
         $highestRow = $worksheet->getHighestRow();
         // e.g. 10
         if ($limit && $highestRow > $limit) {
             $highestRow = $limit;
         }
         //получить слитые строки
         $fillMerged = false;
         $mergedRanges = [];
         $emptyRowsCount = 0;
         //если лист не пустой
         if ($highestRow > 1) {
             $csv = new SimpleExcel('CSV');
             $highestColumn = $worksheet->getHighestColumn();
             // e.g 'F'
             $highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn);
             if ($highestColumnIndex > 100) {
                 $highestColumnIndex = 100;
             }
             //для подстраховки от уродских прайсов
             foreach ($worksheet->getRowIterator() as $row) {
                 if ($emptyRowsCount > 100) {
                     break;
                 }
                 //для подстраховки от уродских прайсов
                 $data = [];
                 $empty = true;
                 for ($col = 0; $col < $highestColumnIndex; ++$col) {
                     $val = $this->getCellValue($worksheet, $col, $row->getRowIndex(), $fillMerged, $mergedRanges);
                     //получаем обработанное значение
                     $data[] = $val;
                     if ($empty) {
                         $empty = empty($val);
                     }
                 }
                 //заполняем строку, если массив не пустой
                 if (!$empty) {
                     $csv->writer->addRow($data);
                 } else {
                     $emptyRowsCount++;
                 }
             }
             File::checkPermissions($pathToConvert);
             $csv->writer->saveFile($outFileName, $outfile);
             $result[] = ['filename' => $outfile, 'cols' => $col, 'sheetname' => $outFileName];
             unset($csv);
         }
         Yii::app()->db->setActive(false);
     }
     Yii::app()->db->setActive(true);
     unset($this->objPHPExcel);
     unset($this->objReader);
     //включаем autoloader yii обратно
     // spl_autoload_register(array('YiiBase','autoload'));
     return $result;
 }
<form method="post">
	<input type="submit" name="submit" value="XML Genereren"/>
</form>
<br />
Beschikbare xml-bestanden:
<br /><br />
<?php 
$file = new File();
$fileList = $file->listFilesInDir(APP_XML_PATH);
foreach ($fileList as $file) {
    echo '<a href="data/xml/' . $file . '">' . $file . '</a><br />';
}
if (isset($_POST['submit'])) {
    $file = new File();
    $file->setFilePath(APP_XML_PATH . date("FY", strtotime("-1 month")) . '.xml');
    if (!$file->fileExists() || $file->fileIsEmpty()) {
        $file->appendFile('<file>');
    } else {
        if ($file->fileExists() || !$file->fileIsEmpty()) {
            $fileLines = $file->getFileLines();
            $file->emptyFile();
            foreach ($fileLines as $line) {
                if ($line != '</file>') {
                    $file->appendFile($line);
                }
            }
        }
    }
    $file->appendFile("\t" . '<bestellingen genereerdatum="' . date("d-m-Y H:i:s") . '">');
    $queryA = mysql_query("SELECT * FROM bestelling WHERE Datum >= '" . date("Y-m-01", strtotime("-1 month")) . "'");
    while ($fetch = mysql_fetch_assoc($queryA)) {
Example #5
0
    function flash($row, $size = false, $dimensions = false, $field_name = false, $img_size_persist = false, $table = false)
    {
        global $CFG;
        if (!is_array(self::$image_sizes) || !$img_size_persist) {
            self::$image_sizes = DB::getImageSizes($field_name);
        }
        if ($size && array_key_exists($size, self::$image_sizes)) {
            $dimensions = $dimensions ? $dimensions : self::$image_sizes[$size];
        }
        $row['name'] = $row['name'] ? $row['name'] : $row['f_id'] . '_' . $row['id'];
        $dir = !$row['dir'] ? $CFG->default_upload_location : $row['dir'];
        $url = File::fileExists($row['name'] . '.swf', $dir, $table);
        if ($url) {
            $HTML = '			
			<embed width="' . $dimensions['width'] . '" height="' . $dimensions['height'] . '" align="middle" type="application/x-shockwave-flash" salign="" allowscriptaccess="sameDomain" allowfullscreen="false" menu="true" name="' . $row['name'] . '" devicefont="false" wmode="transparent" scale="showall" loop="true" play="true" pluginspage="http://www.adobe.com/go/getflashplayer" quality="high" src="' . $url . '"/>
			<noscript>
				<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' . $dimensions['width'] . '" height="' . $dimensions['height'] . '" id="' . $row['name'] . '" align="middle">
					<param name="allowScriptAccess" value="sameDomain" />
					<param name="allowFullScreen" value="false" />
					<param name="movie" value="' . $url . '" />
					<param name="quality" value="high" />
					<param name="wmode" value="transparent" />
					<embed src="' . $url . '" quality="high" wmode="transparent" width="' . $dimensions['width'] . '" height="' . $dimensions['height'] . '" name="' . $row['name'] . '" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" />
				</object>
			</noscript>';
        } else {
            return "<img src=\"{$CFG->placeholder_image}\" title=\"Flash File Not Found\" height=\"{$dimensions['height']}\" width=\"{$dimensions['width']}\" />";
        }
        return $HTML . '<div class="clear"></div>';
    }