Skip to content
Extraits de code Groupes Projets
Valider a0949a99 rédigé par Fil's avatar Fil
Parcourir les fichiers

plein de corrections: upload des documents, vignette automatique,...

plein de corrections: upload des documents, vignette automatique, spip_action.php qui trainaient, etc
parent 95305a87
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -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' />",
......
......@@ -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='",
......
......@@ -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";
}
}
......
......@@ -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)
......
......@@ -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' />") .
......
......@@ -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" .
......
......@@ -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
//
......
......@@ -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);
}
}
}
......
......@@ -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'))
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter