function GetCSVFile() { // имя файла для сохранения $from_date = get('from_date', '', 'g'); $to_date = get('to_date', '', 'g'); $filename = $this->name . '_' . $from_date . ' - ' . $to_date . '.csv'; $data = $this->GetCSVData(); $GLOBALS['gzip'] = false; ob_end_clean(); $zip = new ss_zip('', 6); $zip->add_data($filename, $data); $zip->save($filename . ".zip", 'd'); exit; }
$rCount = sql_fetch_array($rsCount); mysql_free_result($rsCount); if ($rCount['count'] == 1) { $rsName = sql_slave('SELECT `caches`.`wp_oc` `wp_oc` FROM `ov2content`, `caches` WHERE `ov2content`.`cache_id`=`caches`.`cache_id` LIMIT 1'); $rName = sql_fetch_array($rsName); mysql_free_result($rsName); $sFilebasename = $rName['wp_oc']; } else { $sFilebasename = 'ocde' . $options['queryid']; } $bUseZip = $rCount['count'] > 20; $bUseZip = $bUseZip || (isset($_REQUEST['zip']) ? $_REQUEST['zip'] == '1' : false); if ($bUseZip == true) { $content = ''; require_once $rootpath . 'lib/phpzip/ss_zip.class.php'; $phpzip = new ss_zip('', 6); } // ok, ausgabe starten if ($sqldebug == false) { if ($bUseZip == true) { header("content-type: application/zip"); header('Content-Disposition: attachment; filename=' . $sFilebasename . '.zip'); } else { header("Content-type: application/ov2"); header("Content-Disposition: attachment; filename=" . $sFilebasename . ".ov2"); } } // ok, ausgabe ... /* cacheid name
sql_drop_temp_table_slave('searchtmp'); // for the case something went wrong and it was not propery cleaned up sql_temp_table_slave('searchtmp'); sql_slave('CREATE TEMPORARY TABLE &searchtmp SELECT ' . $sql . $sqlLimit); $count = sql_value_slave('SELECT COUNT(*) FROM &searchtmp', 0); if ($count == 1) { $sFilebasename = sql_value_slave(' SELECT `caches`.`wp_oc` FROM &searchtmp, `caches` WHERE &searchtmp.`cache_id`=`caches`.`cache_id` LIMIT 1', '?'); } else { $sFilebasename = 'ocde' . $options['queryid']; } $bUseZip = $count > $zip_threshold || isset($_REQUEST['zip']) && $_REQUEST['zip'] == '1'; if ($bUseZip) { $phpzip = new ss_zip('', 6); } if (!$db['debug']) { if ($bUseZip) { header('Content-type: ' . $content_type_zipped); header('Content-disposition: attachment; filename="' . $sFilebasename . '.zip"'); } else { header('Content-type: ' . $content_type_plain); header('Content-disposition: attachment; filename="' . $sFilebasename . '.' . $output_module . '"'); } } // helper function for output modules function append_output($str) { global $db, $content, $bUseZip; if (!$db['debug']) {
$ecriture=fwrite($fichier_content_xml,'</office:spreadsheet>'); $ecriture=fwrite($fichier_content_xml,'</office:body>'); $ecriture=fwrite($fichier_content_xml,'</office:document-content>'); //========================================== $fermeture=fclose($fichier_content_xml); set_time_limit(3000); $fichier_liste="options_eleves_gepi_".suppr_accents(preg_replace("/'/","'",preg_replace('/[" ]/','',$projet)))."_".date("Ymd_Hi"); if(file_exists("../lib/ss_zip.class.php")){ //require_once("ss_zip.class.php"); require_once("../lib/ss_zip.class.php"); $zip= new ss_zip('',6); $zip->add_file("../temp/".$user_temp_directory."/content.xml",'content.xml'); $zip->add_file('liste_options_ods/meta.xml','meta.xml'); $zip->add_file('liste_options_ods/mimetype','mimetype'); $zip->add_file('liste_options_ods/settings.xml','settings.xml'); $zip->add_file('liste_options_ods/styles.xml','styles.xml'); $zip->add_file('liste_options_ods/META-INF/manifest.xml','META-INF/manifest.xml'); $zip->save("../temp/".$user_temp_directory."/$fichier_liste.zip"); rename("../temp/".$user_temp_directory."/$fichier_liste.zip","../temp/".$user_temp_directory."/".$fichier_liste.".ods"); } else { $path = path_niveau(); $chemin_temp = $path."temp/".get_user_temp_directory()."/";
$rCount = sql_fetch_array($rsCount); mysql_free_result($rsCount); if ($rCount['count'] == 1) { $rsName = sql_slave('SELECT `caches`.`wp_oc` `wp_oc` FROM `txtcontent`, `caches` WHERE `txtcontent`.`cache_id`=`caches`.`cache_id` LIMIT 1'); $rName = sql_fetch_array($rsName); mysql_free_result($rsName); $sFilebasename = $rName['wp_oc']; } else { $sFilebasename = 'ocde' . $options['queryid']; } $bUseZip = $rCount['count'] > 1; $bUseZip = $bUseZip || isset($_REQUEST['zip']) && $_REQUEST['zip'] == '1'; if ($bUseZip == true) { $content = ''; require_once $rootpath . 'lib/phpzip/ss_zip.class.php'; $phpzip = new ss_zip('', 6); } // ok, ausgabe starten if ($sqldebug == false) { if ($bUseZip == true) { header("content-type: application/zip"); header('Content-Disposition: attachment; filename=' . $sFilebasename . '.zip'); } else { header("Content-type: text/plain"); header("Content-Disposition: attachment; filename=" . $sFilebasename . ".txt"); } } // ok, ausgabe ... $rs = sql_slave('SELECT SQL_BUFFER_RESULT `txtcontent`.`cache_id` `cacheid`, `txtcontent`.`longitude` `longitude`, `txtcontent`.`latitude` `latitude`, `caches`.`wp_oc` `waypoint`, `caches`.`date_hidden` `date_hidden`, `caches`.`name` `name`, `caches`.`country` `country`, `caches`.`terrain` `terrain`, `caches`.`difficulty` `difficulty`, `caches`.`desc_languages` `desc_languages`, `cache_size`.`de` `size`, `cache_type`.`de` `type`, `cache_status`.`de` `status`, `user`.`username` `username`, `cache_desc`.`desc` `desc`, `cache_desc`.`short_desc` `short_desc`, `cache_desc`.`hint` `hint`, `cache_desc`.`desc_html` `html` FROM `txtcontent`, `caches`, `user`, `cache_desc`, `cache_type`, `cache_status`, `cache_size` WHERE `txtcontent`.`cache_id`=`caches`.`cache_id` AND `caches`.`cache_id`=`cache_desc`.`cache_id` AND `caches`.`default_desclang`=`cache_desc`.`language` AND `txtcontent`.`user_id`=`user`.`user_id` AND `caches`.`type`=`cache_type`.`id` AND `caches`.`status`=`cache_status`.`id` AND `caches`.`size`=`cache_size`.`id`'); while ($r = sql_fetch_array($rs)) { $thisline = $txtLine;
function EditCSV() { $period = get('period', 'all'); $date_state = ""; if ($period != 'all') { $from = get('from_date', ''); $to = get('to_date', ''); if ($from && $to) { $from = explode('-', $from); $to = explode('-', $to); if (count($to) > 2 && count($from) > 2) { $from_date = mktime(0, 0, 0, $from[1], $from[2], $from[0]); $to_date = mktime(23, 59, 59, $to[1], $to[2], $to[0]); } } $date_state = " AND (o.order_date BETWEEN '" . $from_date . "' AND '" . $to_date . "')"; } $filename = $this->name . '_' . date('Y-m-d') . '.csv'; $data = $this->str('art') . ';' . $this->str('art2') . ';' . $this->str('name') . ';' . $this->str('manufacturer') . ';' . $this->str('catalog') . ';' . $this->str('order_id') . ';' . $this->str('order_date') . ';' . $this->str('quantity') . ';' . $this->str('price') . ';' . $this->str('customer_price') . "\n"; $client_id = get('client_id', NULL); if (isset($client_id)) { $rows = $this->getRows("SELECT p.art, p.art2, p.name, m.name as manufacturer, t.name as catalog, o.id as order_id, DATE_FORMAT(FROM_UNIXTIME(o.order_date),'%Y-%m-%d') as order_date, c.quantity, c.price, c.customer_price\n FROM orders AS o, cart AS c, elem_product AS ep\n LEFT JOIN products AS p ON c.product_id = p.id\n LEFT JOIN manufacturers AS m ON m.id = p.manufacturer_id\n LEFT JOIN tree AS t ON ep.pid = t.id\n LEFT JOIN auth_users AS c1 ON o.client_id=c1.id\n WHERE c.order_id=o.id AND ep.id=p.id AND o.status IN ('Delivered', 'ReadyPaid') " . $date_state . " AND o.client_id=" . $client_id . " ORDER BY o.order_date"); } else { $sql = "SELECT p.art, p.art2, p.name, m.name as manufacturer, t.name as catalog, o.id as order_id, DATE_FORMAT(FROM_UNIXTIME(o.order_date),'%Y-%m-%d') as order_date, c.quantity, c.price, c.customer_price\n FROM orders AS o, cart AS c, elem_product AS ep\n LEFT JOIN products AS p ON c.product_id = p.id\n LEFT JOIN manufacturers AS m ON m.id = p.manufacturer_id\n LEFT JOIN tree AS t ON ep.pid = t.id\n WHERE c.order_id = o.id AND ep.id=p.id AND o.status IN ('Delivered', 'ReadyPaid') " . $date_state . " ORDER BY o.order_date"; $rows = $this->getRows($sql); } if ($rows) { foreach ($rows as $i => $row) { $data .= $row['art'] . ';' . $row['art2'] . ';' . $row['name'] . ';' . $row['manufacturer'] . ';' . $row['catalog'] . ';' . $row['order_id'] . ';' . $row['order_date'] . ';' . $row['quantity'] . ';' . $row['price'] . ';' . $row['customer_price'] . "\n"; } } $zip = new ss_zip('', 6); $zip->add_data($filename, $data); $zip->save($filename . ".zip", 'd'); }
function download() { $config = $this->get_config(); if (!$config) { return "<SCRIPT>alert('" . $this->str('err_no_config') . "')</SCRIPT>"; } $rows = sql_query('SELECT ' . implode(',', $config['fields_request']) . ' FROM ' . $config['table_base']); if (!$rows) { return "<SCRIPT>alert(\"Error: " . mysql_error() . "\")</SCRIPT>"; } require 'modules/csv_tools/Bs_CsvUtil.class.php'; $Bs_CsvUtil =& new Bs_CsvUtil(); // первой строкой выдаем заголовки таблицы $data = $Bs_CsvUtil->arrayToCsvString($config['fields_request'], ';', 'none', TRUE) . "\n"; // теперь собственно данные построчно: while ($row = mysql_fetch_assoc($rows)) { $csv_row = $Bs_CsvUtil->arrayToCsvString($row, ';', $trim = 'none', TRUE); /* $comma = '';$csv_row = ''; foreach($row AS $val){ $csv_row .= $comma.'"'.$val.'"'; $comma = '; '; }*/ //добавляем возможность скачивания zip архива //(strtr($csv_row, array("\r" => '\r', "\n" => '\n'))."\n"); $data .= strtr($csv_row, array("\r" => '\\r', "\n" => '\\n')) . "\n"; } // new empty archive with compression level 6 $zip = new ss_zip('', 6); $zip->add_data($config['table_base'] . '.csv', $data); $zip->save('modules/csv_tools/' . $config['table_base'] . ".zip", 'd'); }
$ecriture = fwrite($fichier_tmp_xml, '<table:table-row table:style-name="ro3"><table:table-cell/><table:table-cell/><table:table-cell table:number-columns-repeated="3"/>'); $ecriture = fwrite($fichier_tmp_xml, '<table:table-cell table:formula="oooc:=IF([.B' . $i . ']="";"";IF(ISERROR(ROUND(20*SUMPRODUCT([.G' . $i . ':.AZ' . $i . '];[.G$3:.AZ$3])/(SUMPRODUCT([.G$3:.AZ$3];[.G$4:.AZ$4])-SUMPRODUCT([.G' . $i . ':.AZ' . $i . ']="abs";[.G$3:.AZ$3];[.G$4:.AZ$4])-SUMPRODUCT([.G' . $i . ':.AZ' . $i . ']="disp";[.G$3:.AZ$3];[.G$4:.AZ$4])-SUMPRODUCT([.G' . $i . ':.AZ' . $i . ']="-";[.G$3:.AZ$3];[.G$4:.AZ$4])-SUMPRODUCT([.G' . $i . ':.AZ' . $i . ']="";[.G$3:.AZ$3];[.G$4:.AZ$4])-SUMPRODUCT([.G' . $i . ':.AZ' . $i . ']="v";[.G$3:.AZ$3];[.G$4:.AZ$4]));1));"-";ROUND(20*SUMPRODUCT([.G' . $i . ':.AZ' . $i . '];[.G$3:.AZ$3])/(SUMPRODUCT([.G$3:.AZ$3];[.G$4:.AZ$4])-SUMPRODUCT([.G' . $i . ':.AZ' . $i . ']="abs";[.G$3:.AZ$3];[.G$4:.AZ$4])-SUMPRODUCT([.G' . $i . ':.AZ' . $i . ']="disp";[.G$3:.AZ$3];[.G$4:.AZ$4])-SUMPRODUCT([.G' . $i . ':.AZ' . $i . ']="-";[.G$3:.AZ$3];[.G$4:.AZ$4])-SUMPRODUCT([.G' . $i . ':.AZ' . $i . ']="";[.G$3:.AZ$3];[.G$4:.AZ$4])-SUMPRODUCT([.G' . $i . ':.AZ' . $i . ']="v";[.G$3:.AZ$3];[.G$4:.AZ$4]));1)))"><text:p/></table:table-cell>'); $nb_max_dev = 46; $ecriture = fwrite($fichier_tmp_xml, '<table:table-cell table:number-columns-repeated="' . $nb_max_dev . '"/>'); $ecriture = fwrite($fichier_tmp_xml, '</table:table-row>'); } $ecriture = fwrite($fichier_tmp_xml, '</table:table>'); $ecriture = fwrite($fichier_tmp_xml, '<table:table table:name="Infos" table:style-name="ta1" table:print="false"><table:table-column table:style-name="co2" table:number-columns-repeated="6" table:default-cell-style-name="Default"/><table:table-row table:style-name="ro3"><table:table-cell table:number-columns-repeated="6"/></table:table-row><table:table-row table:style-name="ro3"><table:table-cell/><table:table-cell table:style-name="ce14" office:value-type="string"><text:p>Feuille de calcul destinée à:</text:p></table:table-cell><table:table-cell table:number-columns-repeated="4"/></table:table-row><table:table-row table:style-name="ro3"><table:table-cell/><table:table-cell office:value-type="string"><text:p>. une saisie hors ligne des notes</text:p></table:table-cell><table:table-cell table:number-columns-repeated="4"/></table:table-row><table:table-row table:style-name="ro3"><table:table-cell/><table:table-cell office:value-type="string"><text:p>. une conservation des résultats dans un tableur,...</text:p></table:table-cell><table:table-cell table:number-columns-repeated="4"/></table:table-row><table:table-row table:style-name="ro3"><table:table-cell table:number-columns-repeated="6"/></table:table-row><table:table-row table:style-name="ro4"><table:table-cell/><table:table-cell table:style-name="ce14" office:value-type="string"><text:p>L'import des notes dans GEPI se fait ainsi:</text:p></table:table-cell><table:table-cell table:number-columns-repeated="3"/><table:table-cell office:value-type="string"><text:p><text:s/></text:p></table:table-cell></table:table-row><table:table-row table:style-name="ro3"><table:table-cell/><table:table-cell office:value-type="string"><text:p>. dans le feuillet 'Notes', cliquer sur le menu 'Fichier/Enregistrer sous'</text:p></table:table-cell><table:table-cell table:number-columns-repeated="4"/></table:table-row><table:table-row table:style-name="ro3"><table:table-cell/><table:table-cell office:value-type="string"><text:p>. choisir 'Fichier CSV' dans 'Type de fichiers' et cocher 'Editer les paramètres du filtre'</text:p></table:table-cell><table:table-cell table:number-columns-repeated="4"/></table:table-row><table:table-row table:style-name="ro3"><table:table-cell/><table:table-cell office:value-type="string"><text:p>. cliquer sur 'Enregistrer'</text:p></table:table-cell><table:table-cell table:number-columns-repeated="4"/></table:table-row><table:table-row table:style-name="ro3"><table:table-cell/><table:table-cell office:value-type="string"><text:p>. valider 'Oui' l'avertissement comme quoi seul le feuillet actif va être enregistré</text:p></table:table-cell><table:table-cell table:number-columns-repeated="4"/></table:table-row><table:table-row table:style-name="ro3"><table:table-cell/><table:table-cell office:value-type="string"><text:p>. dans les paramètres CSV, choisir le point-virgule comme séparateur de champs et supprimer le séparateur de texte</text:p></table:table-cell><table:table-cell table:number-columns-repeated="4"/></table:table-row><table:table-row table:style-name="ro3"><table:table-cell table:number-columns-repeated="6"/></table:table-row><table:table-row table:style-name="ro4"><table:table-cell/><table:table-cell table:style-name="ce14" office:value-type="string"><text:p>Quelques conseils et remarques pour permettre un import des notes dans GEPI:</text:p></table:table-cell><table:table-cell table:number-columns-repeated="4"/></table:table-row><table:table-row table:style-name="ro3"><table:table-cell/><table:table-cell office:value-type="string"><text:p>. Les champs importés sont repérés par le contenu de la colonne A (masquée par défaut) et de la ligne 1 avec un préfixe GEPI_</text:p></table:table-cell><table:table-cell table:number-columns-repeated="4"/></table:table-row><table:table-row table:style-name="ro3"><table:table-cell/><table:table-cell office:value-type="string"><text:p>. Les colonnes moyennes ne sont pas prises en compte dans GEPI; elles sont recalculées d'après les notes importées.</text:p></table:table-cell><table:table-cell table:number-columns-repeated="4"/></table:table-row><table:table-row table:style-name="ro3"><table:table-cell/><table:table-cell office:value-type="string"><text:p>. Ne pas fusionner de cellules sans quoi le format CSV sera perturbé.</text:p></table:table-cell><table:table-cell table:number-columns-repeated="4"/></table:table-row><table:table-row table:style-name="ro3"><table:table-cell/><table:table-cell office:value-type="string"><text:p>. Les formules permettent des calculs jusqu'à la ligne 100 et jusqu'à la colonne AZ.</text:p></table:table-cell><table:table-cell table:number-columns-repeated="4"/></table:table-row><table:table-row table:style-name="ro3"><table:table-cell/><table:table-cell office:value-type="string"><text:p>. Ne pas insérer de ligne pour ajouter un élève (à moins de remplir correctement aussi la colonne A (masquée par défaut))</text:p></table:table-cell><table:table-cell table:number-columns-repeated="4"/></table:table-row><table:table-row table:style-name="ro3"><table:table-cell table:number-columns-repeated="6"/></table:table-row><table:table-row table:style-name="ro3"><table:table-cell/><table:table-cell table:style-name="ce14" office:value-type="string"><text:p>Astuce:</text:p></table:table-cell><table:table-cell table:number-columns-repeated="4"/></table:table-row><table:table-row table:style-name="ro3"><table:table-cell/><table:table-cell office:value-type="string"><text:p>Vous pouvez saisir plusieurs trimestres en insérant un nouveau feuillet (copie du premier) pour saisir tous les trimestres dans un même fichier tableur. </text:p></table:table-cell><table:table-cell table:number-columns-repeated="4"/></table:table-row><table:table-row table:style-name="ro3"><table:table-cell/><table:table-cell office:value-type="string"><text:p>Il est indispensable que les lignes et colonnes masquées soient copiées avec le reste de la page.</text:p></table:table-cell><table:table-cell table:number-columns-repeated="4"/></table:table-row><table:table-row table:style-name="ro4"><table:table-cell/><table:table-cell office:value-type="string"><text:p>Lors de l'export, la macro Export_CSV prend en compte le feuillet en courant.</text:p></table:table-cell><table:table-cell table:number-columns-repeated="4"/></table:table-row></table:table></office:spreadsheet></office:body></office:document-content>'); $fermeture = fclose($fichier_tmp_xml); //set_time_limit(3000); /** * Création d'un .odc */ if (file_exists("../lib/ss_zip.class.php")) { require_once "../lib/ss_zip.class.php"; $zip = new ss_zip('', 6); $zip->add_file("{$tmp_fich}", 'content.xml'); // On n'ajoute pas les dossiers, ni les fichiers vides... ss_zip ne le supporte pas... // ... et OpenOffice a l'air de supporter l'absence de ces dossiers/fichiers. $zip->add_file($chemin_modele_ods . '/Basic/script-lc.xml', 'Basic/script-lc.xml'); $zip->add_file($chemin_modele_ods . '/Basic/Standard/script-lb.xml', 'Basic/Standard/script-lb.xml'); $zip->add_file($chemin_modele_ods . '/Basic/Standard/Module1.xml', 'Basic/Standard/Module1.xml'); // On ne met pas ce fichier parce que sa longueur vide fait une blague pour ss_zip. $zip->add_file($chemin_modele_ods . '/META-INF/manifest.xml', 'META-INF/manifest.xml'); $zip->add_file($chemin_modele_ods . '/settings.xml', 'settings.xml'); $zip->add_file($chemin_modele_ods . '/meta.xml', 'meta.xml'); $zip->add_file($chemin_modele_ods . '/Thumbnails/thumbnail.png', 'Thumbnails/thumbnail.png'); $zip->add_file($chemin_modele_ods . '/mimetype', 'mimetype'); $zip->add_file($chemin_modele_ods . '/styles.xml', 'styles.xml'); $zip->save("{$tmp_fich}.zip"); if (file_exists("{$chemin_temp}/{$nom_fic}")) {
$rName = XDb::xFetchArray($rsName); XDb::xFreeResults($rsName); if (isset($rName['name']) && $rName['name'] != '') { $sFilebasename = trim($rName['name']); } else { $sFilebasename = "{$short_sitename}" . $options['queryid']; } } } $sFilebasename = str_replace(" ", "_", $sFilebasename); $bUseZip = $rCount['count'] > 50; $bUseZip = $bUseZip || isset($_REQUEST['zip']) && $_REQUEST['zip'] == '1'; // $bUseZip = false; if ($bUseZip == true) { require_once $rootpath . 'lib/phpzip/ss_zip.class.php'; $phpzip = new ss_zip('', 6); } // ok, ausgabe starten include $stylepath . '/search.result.caches.kml.head.tpl.php'; $s = $dbcSearch->simpleQuery('SELECT MIN(`longitude`) `minlon`, MAX(`longitude`) `maxlon`, MIN(`latitude`) `minlat`, MAX(`latitude`) `maxlat` FROM `kmlcontent`'); $rMinMax = $dbcSearch->dbResultFetchOneRowOnly($s); $kmlDetailHead = str_replace('{minlat}', $rMinMax['minlat'], $kmlDetailHead); $kmlDetailHead = str_replace('{minlon}', $rMinMax['minlon'], $kmlDetailHead); $kmlDetailHead = str_replace('{maxlat}', $rMinMax['maxlat'], $kmlDetailHead); $kmlDetailHead = str_replace('{maxlon}', $rMinMax['maxlon'], $kmlDetailHead); $kmlDetailHead = str_replace('{{time}}', date($kmlTimeFormat), $kmlDetailHead); echo $kmlDetailHead; // ok, ausgabe ... /*