From a0949a9903144120b922959c1f97d94f3fa259f0 Mon Sep 17 00:00:00 2001 From: Fil <fil@rezo.net> Date: Wed, 22 Feb 2006 11:20:43 +0000 Subject: [PATCH] plein de corrections: upload des documents, vignette automatique, spip_action.php qui trainaient, etc --- ecrire/exec_admin_vider.php | 4 +- ecrire/exec_install.php | 2 +- ecrire/exec_spip_action_cookie.php | 4 +- ecrire/exec_spip_action_joindre.php | 17 +--- ecrire/exec_spip_action_test_dirs.php | 2 +- ecrire/inc_documents.php | 2 +- ecrire/inc_getdocument.php | 114 -------------------------- ecrire/inc_logos.php | 4 +- ecrire/inc_version.php | 5 +- 9 files changed, 15 insertions(+), 139 deletions(-) diff --git a/ecrire/exec_admin_vider.php b/ecrire/exec_admin_vider.php index 6857c26c11..1dfbd5371d 100644 --- a/ecrire/exec_admin_vider.php +++ b/ecrire/exec_admin_vider.php @@ -105,7 +105,7 @@ if ($quota_cache) { $hash = calculer_action_auteur("$action $arg"); echo ' (', _T('cache_modifiable_webmestre'),')</p>', - "\n<form action='", generer_url_public("spip_action.php"), "' method='POST'>", + "\n<form action='", generer_url_action($action), "' method='POST'>", "\n<input type='hidden' name='action' value='$action' />", "\n<input type='hidden' name='arg' value='$arg' />", "\n<input type='hidden' name='id_auteur' value='$connect_id_auteur' />", @@ -131,7 +131,7 @@ if ($quota_cache) { $arg = 'vignettes'; $hash = calculer_action_auteur("$action $arg"); - echo "\n<form action='", generer_url_public("spip_action.php"), "' method='POST'>", + echo "\n<form action='", generer_url_action($action), "' method='POST'>", "\n<input type='hidden' name='action' value='$action' />", "\n<input type='hidden' name='arg' value='$arg' />", "\n<input type='hidden' name='id_auteur' value='$connect_id_auteur' />", diff --git a/ecrire/exec_install.php b/ecrire/exec_install.php index a455e337ba..0ffae155dd 100644 --- a/ecrire/exec_install.php +++ b/ecrire/exec_install.php @@ -529,7 +529,7 @@ function install_() "<p><div align='center'>", $menu_langues, "</div>", - "<p><form action='", generer_url_public('spip_action.php'), + "<p><form action='", generer_url_action('test_dirs'), "'>", '<input type="hidden" name="action" value="test_dirs" />', "<div align='$spip_lang_right'><input type='submit' class='fondl' VALUE='", diff --git a/ecrire/exec_spip_action_cookie.php b/ecrire/exec_spip_action_cookie.php index 4776553f2e..31b096b706 100644 --- a/ecrire/exec_spip_action_cookie.php +++ b/ecrire/exec_spip_action_cookie.php @@ -233,7 +233,7 @@ if ($var_lang) { if (changer_langue($var_lang)) { spip_setcookie('spip_lang', $var_lang, time() + 365 * 24 * 3600); $redirect = ereg_replace("[?&]lang=[^&]*", '', $redirect); - $redirect .= (strpos($redirect, "?") ? "&" : "?") . "lang=$var_lang"; + $redirect .= (strpos($redirect, "?")!==false ? "&" : "?") . "lang=$var_lang"; } } @@ -256,7 +256,7 @@ if ($var_lang_ecrire) { } $redirect = ereg_replace("[?&]lang=[^&]*", '', $redirect); - $redirect .= (strpos($redirect, "?") ? "&" : "?") . "lang=$var_lang_ecrire"; + $redirect .= (strpos($redirect, "?")!==false ? "&" : "?") . "lang=$var_lang_ecrire"; } } diff --git a/ecrire/exec_spip_action_joindre.php b/ecrire/exec_spip_action_joindre.php index 194c4ed95b..67dd6c6c08 100644 --- a/ecrire/exec_spip_action_joindre.php +++ b/ecrire/exec_spip_action_joindre.php @@ -27,7 +27,6 @@ function spip_action_joindre_dist() $url, $chemin, $ancre, $type, $id, $id_document, $_FILES, $HTTP_POST_FILES; - include_ecrire("inc_session"); if (!verifier_action_auteur("$action $arg", $hash, $id_auteur)) { include_ecrire('inc_minipres'); @@ -84,9 +83,11 @@ function spip_action_joindre1($arg, $mode, $type, $id, $id_document,$hash, $id_a $files = array(); if (is_array($arg)) foreach ($arg as $file) { - if (!$file['error'] == 4 /* UPLOAD_ERR_NO_FILE */) + var_dump($file); + if (!($file['error'] == 4) /* UPLOAD_ERR_NO_FILE */) $files[]=$file; } + examiner_les_fichiers($files, $mode, $type, $id, $id_document, $hash, $id_auteur, $redirect, $actifs); } @@ -119,18 +120,6 @@ function spip_action_joindre3($arg, $mode, $type, $id, $id_document,$hash, $id_a $hash, $id_auteur, $redirect, $actifs); } -/* code mort cf. sousaction4 -// identifie les repertoires de upload aux rubriques Spip - -function spip_action_joindre4($arg, $mode, $type, $id, $id_document, $hash, $id_auteur, $redirect, &$documents_actifs) -{ - if (!$arg || strstr($arg, '..')) return; - $upload = (_DIR_TRANSFERT .$arg); - identifie_repertoire_et_rubrique($upload, $id, $id_auteur); - include_ecrire("inc_rubriques"); - calculer_rubriques(); -} */ - // Zip avec confirmation "tel quel" function spip_action_joindre5($arg, $mode, $type, $id, $id_document,$hash, $id_auteur, $redirect, &$actifs) diff --git a/ecrire/exec_spip_action_test_dirs.php b/ecrire/exec_spip_action_test_dirs.php index 455ae1b8a2..de3fcac393 100644 --- a/ecrire/exec_spip_action_test_dirs.php +++ b/ecrire/exec_spip_action_test_dirs.php @@ -94,7 +94,7 @@ if ($bad_dirs OR $absent_dirs) { } $res = "<p>" . $continuer . $res . aide ("install0") . "</p>" . - "<form action='" . generer_url_public('spip_action.php') . "'>" . + "<form action='" . generer_url_action('test_dirs') . "'>" . "<input type='hidden' name='action' value='test_dirs' />" . (!$test_dir ? "" : "<input type='hidden' name='test_dir' value='$test_dir' />") . diff --git a/ecrire/inc_documents.php b/ecrire/inc_documents.php index 9f46dd162f..b17c18959f 100644 --- a/ecrire/inc_documents.php +++ b/ecrire/inc_documents.php @@ -594,7 +594,7 @@ function construire_upload($corps, $args, $enctype='') $res .= "\n<input type='hidden' name='$k' value='$v' />"; # ici enlever $action pour uploader directemet dans l'espace prive (UPLOAD_DIRECT) - return "\n<form method='post' action='" . generer_url_public('spip_action.php') . + return "\n<form method='post' action='" . generer_url_action('joindre') . "'" . (!$enctype ? '' : " enctype='$enctype'") . " style='border: 0px; margin: 0px;'>\n" . diff --git a/ecrire/inc_getdocument.php b/ecrire/inc_getdocument.php index cc0f99dc2e..635b01e6ee 100644 --- a/ecrire/inc_getdocument.php +++ b/ecrire/inc_getdocument.php @@ -452,120 +452,6 @@ function examiner_les_fichiers($files, $mode, $type, $id, $id_document, $hash, $ } } -/* code mort cf sousaction4 -function identifie_repertoire_et_rubrique($DIR, $id_rubrique, $id_auteur, $art=0) -{ - static $exts = array(); - - $handle = @opendir($DIR); - if (!$handle) {spip_log("$DIR pas lisible") ; return 0;} - - $textes = array(); - $docs = array(); - $rubriques = array(); - - // collecte des 3 sortes d'entrees - while (($entree = readdir($handle)) !== false) { - $chemin = "$DIR/$entree"; - if ($entree[0] !='.') { - if (is_dir($chemin)) { - $rubriques[$chemin] = $entree; - } else { - if (is_readable($chemin) && - (preg_match("/^([a-zA-Z0-9_].*)\.([a-zA-Z0-9]+)$/", $entree, $match))) { - $ext = strtolower($match[2]); - - if (($ext == 'html') || ($ext == 'htm') || ($ext == 'txt')) - $textes[$match[1]] = $match[2]; - else { - if ($ext == 'jpeg') $ext = 'jpg'; - if (!isset($exts[$ext])) { - $req = "SELECT extension FROM spip_types_documents WHERE extension='$ext'"; - $exts[$ext] = spip_fetch_array(spip_query($req)) ? 'oui' : 'non'; - } - if ($exts[$ext] == 'non') continue; - $docs[] = $entree; - } - } - } - } - } - closedir($handle); - $collecte = count($textes); - if (isset($textes['index'])) { - - $texte = spip_file_get_contents($DIR . "/index." .$textes['index']); - if (preg_match(',<body[^>]*>(.*)</body>,is', $texte, $match)) - $texte = $match[1]; - $texte = '<html>'. $texte . '</html>'; - $texte = addslashes($texte); - spip_query("UPDATE spip_rubriques SET texte='" .$texte . "' -WHERE id_rubrique=$id_rubrique"); - unset($textes['index']); - } - - // integration a la base SQL en commencant par les textes, - // afin de savoir combien ont ete crees, a chaque niveau. - - if ($textes) { - ksort($textes); - foreach($textes as $k=>$v) { - $titre= addslashes(trim(preg_replace('/[-_]/', ' ', $k))); - $chemin = "$DIR/$k." . $v; - $texte = spip_file_get_contents($chemin); - if ($v[0] == 'h') { - // cas du html - if (preg_match(',<body[^>]*>(.*)</body>,is', $texte, $match)) - $texte = $match[1]; - $texte = '<html>'. $texte . '</html>'; - } else {$texte = '<pre>'. $texte . '</pre>';} - $texte = addslashes($texte); - $date = date("Y-m-d H:i:s", filemtime($chemin)); - $art=spip_abstract_insert($GLOBALS['table_prefix']. "_articles", - "(id_rubrique,titre,texte,date,statut)", - "($id_rubrique, '$titre', '$texte', '$date', 'prop')"); - spip_abstract_insert($GLOBALS['table_prefix']. "_auteurs_articles", - "(id_auteur,id_article)", - "($id_auteur,$art)"); - } - } - - - // si la rubrique a 0 ou 1 article, les documents sont - // joints l'article present ou de niveau superieur, sinon a la rubrique. - - - if (($collecte <= 1) AND $art) - {$type = 'article'; $id = $art;} - else - {$type = 'rubrique'; $id = $id_rubrique; $collecte += count($docs);} - - if ($docs) { - foreach($docs as $v) - ajouter_un_document ("$DIR/$v",$v,$type,$id,'document',0,$actifs); - } - - if ($rubriques) { - foreach ($rubriques as $k => $v) - { - - $rub=spip_abstract_insert($GLOBALS['table_prefix'] . "_rubriques", - "(titre,id_parent,statut)", - "('" . addslashes($v) . "', $id_rubrique, 'prepa')"); - $m = identifie_repertoire_et_rubrique($k, $rub, $id_auteur, $art); - if ($m) - $collecte+=$m; - else { - // faudrait essayer de prevenir plutot que de guerir - spip_query("DELETE FROM spip_rubriques WHERE id_rubrique=$rub"); - } - } - } - return $collecte; - -} -*/ - // // Convertit le type numerique retourne par getimagesize() en extension fichier // diff --git a/ecrire/inc_logos.php b/ecrire/inc_logos.php index e9bbc48b78..da84c9afaf 100644 --- a/ecrire/inc_logos.php +++ b/ecrire/inc_logos.php @@ -122,7 +122,7 @@ function afficher_logo($racine, $titre, $type, $mode, $id, $redirect) { $hash = calculer_action_auteur("iconifier $racine"); echo debut_block_invisible(md5($titre)); - echo "\n\n<form action='" . generer_url_public('spip_action.php') . "' method='POST' + echo "\n\n<form action='" . generer_url_action('iconifier') . "' method='POST' ENCTYPE='multipart/form-data'> <div>"; echo "\n<input name='redirect' type='hidden' value='$redirect' />"; @@ -497,7 +497,7 @@ function reduire_image_logo($img, $taille = -1, $taille_y = -1) { if (eregi("(.*)\.(jpg|gif|png)$", $logo, $regs)) { if ($i = cherche_image_nommee($regs[1], array($regs[2]))) { list(,$nom,$format) = $i; - ratio_image($logo, $nom, $format, $taille, $taille_y, $attributs); + return ratio_image($logo, $nom, $format, $taille, $taille_y, $attributs); } } } diff --git a/ecrire/inc_version.php b/ecrire/inc_version.php index c45cf9864f..ebd215ae09 100644 --- a/ecrire/inc_version.php +++ b/ecrire/inc_version.php @@ -411,8 +411,9 @@ else // Installer Spip si pas installe... sauf si justement on est en train // if (!(_FILE_CONNECT -OR autoriser_sans_cookie($_REQUEST["exec"]) OR (substr(basename($SCRIPT_NAME),0,11) == "spip_cookie") -OR (basename($REQUEST_URI) == 'spip_action.php?action=test_dirs'))) { +OR autoriser_sans_cookie(_request('exec')) +OR _request('action') == 'cookie' +OR _request('action') == 'test_dirs')) { // Si on peut installer, on lance illico if (@file_exists('inc_version.php')) -- GitLab