@@ -13,16 +13,16 @@ |
||
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) return; |
| 14 | 14 | |
| 15 | 15 | function action_ajouter_lien_dist($arg=null){ |
| 16 | - if (is_null($arg)){ |
|
| 17 | - $securiser_action = charger_fonction('securiser_action','inc'); |
|
| 18 | - $arg = $securiser_action(); |
|
| 19 | - } |
|
| 16 | + if (is_null($arg)){ |
|
| 17 | + $securiser_action = charger_fonction('securiser_action','inc'); |
|
| 18 | + $arg = $securiser_action(); |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - $arg = explode("-",$arg); |
|
| 22 | - list($objet_source,$ids,$objet_lie,$idl) = $arg; |
|
| 21 | + $arg = explode("-",$arg); |
|
| 22 | + list($objet_source,$ids,$objet_lie,$idl) = $arg; |
|
| 23 | 23 | |
| 24 | - include_spip('action/editer_liens'); |
|
| 25 | - objet_associer(array($objet_source=>$ids), array($objet_lie=>$idl)); |
|
| 24 | + include_spip('action/editer_liens'); |
|
| 25 | + objet_associer(array($objet_source=>$ids), array($objet_lie=>$idl)); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | |
@@ -28,16 +28,16 @@ discard block |
||
| 28 | 28 | // http://doc.spip.org/@_generer_url_page |
| 29 | 29 | function _generer_url_page($type,$id, $args='', $ancre='') { |
| 30 | 30 | |
| 31 | - if ($generer_url_externe = charger_fonction("generer_url_$type",'urls',true)) { |
|
| 32 | - $url = $generer_url_externe($id, $args, $ancre); |
|
| 33 | - if (NULL != $url) return $url; |
|
| 34 | - } |
|
| 31 | + if ($generer_url_externe = charger_fonction("generer_url_$type",'urls',true)) { |
|
| 32 | + $url = $generer_url_externe($id, $args, $ancre); |
|
| 33 | + if (NULL != $url) return $url; |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - $url = _debut_urls_page . $type . _separateur_urls_page |
|
| 37 | - . $id . _terminaison_urls_page; |
|
| 36 | + $url = _debut_urls_page . $type . _separateur_urls_page |
|
| 37 | + . $id . _terminaison_urls_page; |
|
| 38 | 38 | |
| 39 | - if ($args) $args = strpos($url,'?') ? "&$args" : "?$args"; |
|
| 40 | - return _DIR_RACINE . $url . $args . ($ancre ? "#$ancre" : ''); |
|
| 39 | + if ($args) $args = strpos($url,'?') ? "&$args" : "?$args"; |
|
| 40 | + return _DIR_RACINE . $url . $args . ($ancre ? "#$ancre" : ''); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | // retrouve le fond et les parametres d'une URL abregee |
@@ -45,51 +45,51 @@ discard block |
||
| 45 | 45 | // http://doc.spip.org/@urls_page_dist |
| 46 | 46 | function urls_page_dist($i, &$entite, $args='', $ancre='') |
| 47 | 47 | { |
| 48 | - if (is_numeric($i)) |
|
| 49 | - return _generer_url_page($entite, $i, $args, $ancre); |
|
| 48 | + if (is_numeric($i)) |
|
| 49 | + return _generer_url_page($entite, $i, $args, $ancre); |
|
| 50 | 50 | |
| 51 | - // traiter les injections du type domaine.org/spip.php/cestnimportequoi/ou/encore/plus/rubrique23 |
|
| 52 | - if ($GLOBALS['profondeur_url']>0 AND $entite=='sommaire'){ |
|
| 53 | - return array(array(),'404'); |
|
| 54 | - } |
|
| 51 | + // traiter les injections du type domaine.org/spip.php/cestnimportequoi/ou/encore/plus/rubrique23 |
|
| 52 | + if ($GLOBALS['profondeur_url']>0 AND $entite=='sommaire'){ |
|
| 53 | + return array(array(),'404'); |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - // voir s'il faut recuperer le id_* implicite et les &debut_xx; |
|
| 57 | - if (is_array($args)) |
|
| 58 | - $contexte = $args; |
|
| 59 | - else |
|
| 60 | - parse_str($args,$contexte); |
|
| 61 | - include_spip('inc/urls'); |
|
| 62 | - $r = nettoyer_url_page($i, $contexte); |
|
| 63 | - if ($r) { |
|
| 64 | - array_pop($r); // nettoyer_url_page renvoie un argument de plus inutile ici |
|
| 65 | - return $r; |
|
| 66 | - } |
|
| 56 | + // voir s'il faut recuperer le id_* implicite et les &debut_xx; |
|
| 57 | + if (is_array($args)) |
|
| 58 | + $contexte = $args; |
|
| 59 | + else |
|
| 60 | + parse_str($args,$contexte); |
|
| 61 | + include_spip('inc/urls'); |
|
| 62 | + $r = nettoyer_url_page($i, $contexte); |
|
| 63 | + if ($r) { |
|
| 64 | + array_pop($r); // nettoyer_url_page renvoie un argument de plus inutile ici |
|
| 65 | + return $r; |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - /* |
|
| 68 | + /* |
|
| 69 | 69 | * Le bloc qui suit sert a faciliter les transitions depuis |
| 70 | 70 | * le mode 'urls-propres' vers les modes 'urls-standard' et 'url-html' |
| 71 | 71 | * Il est inutile de le recopier si vous personnalisez vos URLs |
| 72 | 72 | * et votre .htaccess |
| 73 | 73 | */ |
| 74 | - // Si on est revenu en mode html, mais c'est une ancienne url_propre |
|
| 75 | - // on ne redirige pas, on assume le nouveau contexte (si possible) |
|
| 76 | - $url = $i; |
|
| 77 | - $url_propre = isset($url) |
|
| 78 | - ? $url |
|
| 79 | - : (isset($_SERVER['REDIRECT_url_propre']) |
|
| 80 | - ? $_SERVER['REDIRECT_url_propre'] |
|
| 81 | - : (isset($_ENV['url_propre']) |
|
| 82 | - ? $_ENV['url_propre'] |
|
| 83 | - : '' |
|
| 84 | - )); |
|
| 85 | - if ($url_propre) { |
|
| 86 | - if ($GLOBALS['profondeur_url']<=0) |
|
| 87 | - $urls_anciennes = charger_fonction('propres','urls',true); |
|
| 88 | - else |
|
| 89 | - $urls_anciennes = charger_fonction('arbo','urls',true); |
|
| 90 | - return $urls_anciennes?$urls_anciennes($url_propre, $entite, $contexte):''; |
|
| 91 | - } |
|
| 92 | - /* Fin du bloc compatibilite url-propres */ |
|
| 74 | + // Si on est revenu en mode html, mais c'est une ancienne url_propre |
|
| 75 | + // on ne redirige pas, on assume le nouveau contexte (si possible) |
|
| 76 | + $url = $i; |
|
| 77 | + $url_propre = isset($url) |
|
| 78 | + ? $url |
|
| 79 | + : (isset($_SERVER['REDIRECT_url_propre']) |
|
| 80 | + ? $_SERVER['REDIRECT_url_propre'] |
|
| 81 | + : (isset($_ENV['url_propre']) |
|
| 82 | + ? $_ENV['url_propre'] |
|
| 83 | + : '' |
|
| 84 | + )); |
|
| 85 | + if ($url_propre) { |
|
| 86 | + if ($GLOBALS['profondeur_url']<=0) |
|
| 87 | + $urls_anciennes = charger_fonction('propres','urls',true); |
|
| 88 | + else |
|
| 89 | + $urls_anciennes = charger_fonction('arbo','urls',true); |
|
| 90 | + return $urls_anciennes?$urls_anciennes($url_propre, $entite, $contexte):''; |
|
| 91 | + } |
|
| 92 | + /* Fin du bloc compatibilite url-propres */ |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | ?> |
@@ -18,174 +18,174 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | class IterateurSQL implements Iterator { |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * ressource sql |
|
| 23 | - * @var resource|bool |
|
| 24 | - */ |
|
| 25 | - protected $sqlresult = false; |
|
| 26 | - |
|
| 27 | - /** |
|
| 28 | - * row sql courante |
|
| 29 | - * @var array|null |
|
| 30 | - */ |
|
| 31 | - protected $row = null; |
|
| 32 | - |
|
| 33 | - protected $firstseek = false; |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * Erreur presente ? |
|
| 37 | - * |
|
| 38 | - * @var bool |
|
| 39 | - **/ |
|
| 40 | - public $err = false; |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * Calcul du total des elements |
|
| 44 | - * |
|
| 45 | - * @var int|null |
|
| 46 | - **/ |
|
| 47 | - public $total = null; |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * selectionner les donnees, ie faire la requete SQL |
|
| 51 | - * @return void |
|
| 52 | - */ |
|
| 53 | - protected function select() { |
|
| 54 | - $this->row = null; |
|
| 55 | - $v = &$this->command; |
|
| 56 | - $this->sqlresult = calculer_select($v['select'], $v['from'], $v['type'], $v['where'], $v['join'], $v['groupby'], $v['orderby'], $v['limit'], $v['having'], $v['table'], $v['id'], $v['connect'], $this->info); |
|
| 57 | - $this->err = !$this->sqlresult; |
|
| 58 | - $this->firstseek = false; |
|
| 59 | - $this->pos = -1; |
|
| 60 | - |
|
| 61 | - // pas d'init a priori, le calcul ne sera fait qu'en cas de besoin (provoque une double requete souvent inutile en sqlite) |
|
| 62 | - //$this->total = $this->count(); |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - /* |
|
| 21 | + /** |
|
| 22 | + * ressource sql |
|
| 23 | + * @var resource|bool |
|
| 24 | + */ |
|
| 25 | + protected $sqlresult = false; |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * row sql courante |
|
| 29 | + * @var array|null |
|
| 30 | + */ |
|
| 31 | + protected $row = null; |
|
| 32 | + |
|
| 33 | + protected $firstseek = false; |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * Erreur presente ? |
|
| 37 | + * |
|
| 38 | + * @var bool |
|
| 39 | + **/ |
|
| 40 | + public $err = false; |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * Calcul du total des elements |
|
| 44 | + * |
|
| 45 | + * @var int|null |
|
| 46 | + **/ |
|
| 47 | + public $total = null; |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * selectionner les donnees, ie faire la requete SQL |
|
| 51 | + * @return void |
|
| 52 | + */ |
|
| 53 | + protected function select() { |
|
| 54 | + $this->row = null; |
|
| 55 | + $v = &$this->command; |
|
| 56 | + $this->sqlresult = calculer_select($v['select'], $v['from'], $v['type'], $v['where'], $v['join'], $v['groupby'], $v['orderby'], $v['limit'], $v['having'], $v['table'], $v['id'], $v['connect'], $this->info); |
|
| 57 | + $this->err = !$this->sqlresult; |
|
| 58 | + $this->firstseek = false; |
|
| 59 | + $this->pos = -1; |
|
| 60 | + |
|
| 61 | + // pas d'init a priori, le calcul ne sera fait qu'en cas de besoin (provoque une double requete souvent inutile en sqlite) |
|
| 62 | + //$this->total = $this->count(); |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + /* |
|
| 66 | 66 | * array command: les commandes d'initialisation |
| 67 | 67 | * array info: les infos sur le squelette |
| 68 | 68 | */ |
| 69 | - public function __construct($command, $info=array()) { |
|
| 70 | - $this->type='SQL'; |
|
| 71 | - $this->command = $command; |
|
| 72 | - $this->info = $info; |
|
| 73 | - $this->select(); |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * Rembobiner |
|
| 78 | - * @return bool |
|
| 79 | - */ |
|
| 80 | - public function rewind() { |
|
| 81 | - return ($this->pos > 0) |
|
| 82 | - ? $this->seek(0) |
|
| 83 | - : true; |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - /** |
|
| 87 | - * Verifier l'etat de l'iterateur |
|
| 88 | - * @return bool |
|
| 89 | - */ |
|
| 90 | - public function valid() { |
|
| 91 | - if ($this->err) |
|
| 92 | - return false; |
|
| 93 | - if (!$this->firstseek) |
|
| 94 | - $this->next(); |
|
| 95 | - return is_array($this->row); |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - /** |
|
| 99 | - * Valeurs sur la position courante |
|
| 100 | - * @return array |
|
| 101 | - */ |
|
| 102 | - public function current() { |
|
| 103 | - return $this->row; |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - public function key() { |
|
| 107 | - return $this->pos; |
|
| 108 | - } |
|
| 69 | + public function __construct($command, $info=array()) { |
|
| 70 | + $this->type='SQL'; |
|
| 71 | + $this->command = $command; |
|
| 72 | + $this->info = $info; |
|
| 73 | + $this->select(); |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * Rembobiner |
|
| 78 | + * @return bool |
|
| 79 | + */ |
|
| 80 | + public function rewind() { |
|
| 81 | + return ($this->pos > 0) |
|
| 82 | + ? $this->seek(0) |
|
| 83 | + : true; |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + /** |
|
| 87 | + * Verifier l'etat de l'iterateur |
|
| 88 | + * @return bool |
|
| 89 | + */ |
|
| 90 | + public function valid() { |
|
| 91 | + if ($this->err) |
|
| 92 | + return false; |
|
| 93 | + if (!$this->firstseek) |
|
| 94 | + $this->next(); |
|
| 95 | + return is_array($this->row); |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + /** |
|
| 99 | + * Valeurs sur la position courante |
|
| 100 | + * @return array |
|
| 101 | + */ |
|
| 102 | + public function current() { |
|
| 103 | + return $this->row; |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + public function key() { |
|
| 107 | + return $this->pos; |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | - /** |
|
| 111 | - * Sauter a une position absolue |
|
| 112 | - * @param int $n |
|
| 113 | - * @param null|string $continue |
|
| 114 | - * @return bool |
|
| 115 | - */ |
|
| 116 | - public function seek($n=0, $continue=null) { |
|
| 117 | - if (!sql_seek($this->sqlresult, $n, $this->command['connect'], $continue)) { |
|
| 118 | - // SQLite ne sait pas seek(), il faut relancer la query |
|
| 119 | - // si la position courante est apres la position visee |
|
| 120 | - // il faut relancer la requete |
|
| 121 | - if ($this->pos>$n){ |
|
| 122 | - $this->free(); |
|
| 123 | - $this->select(); |
|
| 124 | - $this->valid(); |
|
| 125 | - } |
|
| 126 | - // et utiliser la methode par defaut pour se deplacer au bon endroit |
|
| 127 | - // (sera fait en cas d'echec de cette fonction) |
|
| 128 | - return false; |
|
| 129 | - } |
|
| 130 | - $this->row = sql_fetch($this->sqlresult, $this->command['connect']); |
|
| 131 | - $this->pos = min($n,$this->count()); |
|
| 132 | - return true; |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - /** |
|
| 136 | - * Avancer d'un cran |
|
| 137 | - * @return void |
|
| 138 | - */ |
|
| 139 | - public function next(){ |
|
| 140 | - $this->row = sql_fetch($this->sqlresult, $this->command['connect']); |
|
| 141 | - $this->pos ++; |
|
| 142 | - $this->firstseek |= true; |
|
| 143 | - } |
|
| 144 | - |
|
| 145 | - /** |
|
| 146 | - * Avancer et retourner les donnees pour le nouvel element |
|
| 147 | - * @return array|bool|null |
|
| 148 | - */ |
|
| 149 | - public function fetch(){ |
|
| 150 | - if ($this->valid()) { |
|
| 151 | - $r = $this->current(); |
|
| 152 | - $this->next(); |
|
| 153 | - } else |
|
| 154 | - $r = false; |
|
| 155 | - return $r; |
|
| 156 | - } |
|
| 157 | - |
|
| 158 | - /** |
|
| 159 | - * liberer les ressources |
|
| 160 | - * @return bool |
|
| 161 | - */ |
|
| 162 | - public function free(){ |
|
| 163 | - if (!$this->sqlresult) return true; |
|
| 164 | - $a = sql_free($this->sqlresult, $this->command['connect']); |
|
| 165 | - $this->sqlresult = null; |
|
| 166 | - return $a; |
|
| 167 | - } |
|
| 110 | + /** |
|
| 111 | + * Sauter a une position absolue |
|
| 112 | + * @param int $n |
|
| 113 | + * @param null|string $continue |
|
| 114 | + * @return bool |
|
| 115 | + */ |
|
| 116 | + public function seek($n=0, $continue=null) { |
|
| 117 | + if (!sql_seek($this->sqlresult, $n, $this->command['connect'], $continue)) { |
|
| 118 | + // SQLite ne sait pas seek(), il faut relancer la query |
|
| 119 | + // si la position courante est apres la position visee |
|
| 120 | + // il faut relancer la requete |
|
| 121 | + if ($this->pos>$n){ |
|
| 122 | + $this->free(); |
|
| 123 | + $this->select(); |
|
| 124 | + $this->valid(); |
|
| 125 | + } |
|
| 126 | + // et utiliser la methode par defaut pour se deplacer au bon endroit |
|
| 127 | + // (sera fait en cas d'echec de cette fonction) |
|
| 128 | + return false; |
|
| 129 | + } |
|
| 130 | + $this->row = sql_fetch($this->sqlresult, $this->command['connect']); |
|
| 131 | + $this->pos = min($n,$this->count()); |
|
| 132 | + return true; |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + /** |
|
| 136 | + * Avancer d'un cran |
|
| 137 | + * @return void |
|
| 138 | + */ |
|
| 139 | + public function next(){ |
|
| 140 | + $this->row = sql_fetch($this->sqlresult, $this->command['connect']); |
|
| 141 | + $this->pos ++; |
|
| 142 | + $this->firstseek |= true; |
|
| 143 | + } |
|
| 144 | + |
|
| 145 | + /** |
|
| 146 | + * Avancer et retourner les donnees pour le nouvel element |
|
| 147 | + * @return array|bool|null |
|
| 148 | + */ |
|
| 149 | + public function fetch(){ |
|
| 150 | + if ($this->valid()) { |
|
| 151 | + $r = $this->current(); |
|
| 152 | + $this->next(); |
|
| 153 | + } else |
|
| 154 | + $r = false; |
|
| 155 | + return $r; |
|
| 156 | + } |
|
| 157 | + |
|
| 158 | + /** |
|
| 159 | + * liberer les ressources |
|
| 160 | + * @return bool |
|
| 161 | + */ |
|
| 162 | + public function free(){ |
|
| 163 | + if (!$this->sqlresult) return true; |
|
| 164 | + $a = sql_free($this->sqlresult, $this->command['connect']); |
|
| 165 | + $this->sqlresult = null; |
|
| 166 | + return $a; |
|
| 167 | + } |
|
| 168 | 168 | |
| 169 | - /** |
|
| 170 | - * Compter le nombre de resultats |
|
| 171 | - * @return int |
|
| 172 | - */ |
|
| 173 | - public function count() { |
|
| 174 | - if (is_null($this->total)) { |
|
| 175 | - if (!$this->sqlresult) { |
|
| 176 | - $this->total = 0; |
|
| 177 | - } else { |
|
| 178 | - # cas count(*) |
|
| 179 | - if (in_array('count(*)', $this->command['select'])) { |
|
| 180 | - $this->valid(); |
|
| 181 | - $s = $this->current(); |
|
| 182 | - $this->total = $s['count(*)']; |
|
| 183 | - } else |
|
| 184 | - $this->total = sql_count($this->sqlresult, $this->command['connect']); |
|
| 185 | - } |
|
| 186 | - } |
|
| 187 | - return $this->total; |
|
| 188 | - } |
|
| 169 | + /** |
|
| 170 | + * Compter le nombre de resultats |
|
| 171 | + * @return int |
|
| 172 | + */ |
|
| 173 | + public function count() { |
|
| 174 | + if (is_null($this->total)) { |
|
| 175 | + if (!$this->sqlresult) { |
|
| 176 | + $this->total = 0; |
|
| 177 | + } else { |
|
| 178 | + # cas count(*) |
|
| 179 | + if (in_array('count(*)', $this->command['select'])) { |
|
| 180 | + $this->valid(); |
|
| 181 | + $s = $this->current(); |
|
| 182 | + $this->total = $s['count(*)']; |
|
| 183 | + } else |
|
| 184 | + $this->total = sql_count($this->sqlresult, $this->command['connect']); |
|
| 185 | + } |
|
| 186 | + } |
|
| 187 | + return $this->total; |
|
| 188 | + } |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | ?> |
@@ -18,22 +18,22 @@ |
||
| 18 | 18 | // annonce au compilo les "champs" disponibles |
| 19 | 19 | // |
| 20 | 20 | function iterateur_php_dist($b, $iteratorName) { |
| 21 | - $b->iterateur = $iteratorName; # designe la classe d'iterateur |
|
| 22 | - $b->show = array( |
|
| 23 | - 'field' => array( |
|
| 24 | - 'cle' => 'STRING', |
|
| 25 | - 'valeur' => 'STRING', |
|
| 26 | - ) |
|
| 27 | - ); |
|
| 28 | - foreach (get_class_methods($iteratorName) as $method) { |
|
| 29 | - $b->show['field'][ strtolower($method) ] = 'METHOD'; |
|
| 30 | - } |
|
| 31 | - /* |
|
| 21 | + $b->iterateur = $iteratorName; # designe la classe d'iterateur |
|
| 22 | + $b->show = array( |
|
| 23 | + 'field' => array( |
|
| 24 | + 'cle' => 'STRING', |
|
| 25 | + 'valeur' => 'STRING', |
|
| 26 | + ) |
|
| 27 | + ); |
|
| 28 | + foreach (get_class_methods($iteratorName) as $method) { |
|
| 29 | + $b->show['field'][ strtolower($method) ] = 'METHOD'; |
|
| 30 | + } |
|
| 31 | + /* |
|
| 32 | 32 | foreach (get_class_vars($iteratorName) as $property) { |
| 33 | 33 | $b->show['field'][ strtolower($property) ] = 'PROPERTY'; |
| 34 | 34 | } |
| 35 | 35 | */ |
| 36 | - return $b; |
|
| 36 | + return $b; |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | |
@@ -21,13 +21,13 @@ |
||
| 21 | 21 | // annonce au compilo les "champs" disponibles |
| 22 | 22 | // |
| 23 | 23 | function iterateur_POUR_dist($b) { |
| 24 | - $b->iterateur = 'DATA'; # designe la classe d'iterateur |
|
| 25 | - $b->show = array( |
|
| 26 | - 'field' => array( |
|
| 27 | - 'cle' => 'STRING', |
|
| 28 | - 'valeur' => 'STRING', |
|
| 29 | - ) |
|
| 30 | - ); |
|
| 31 | - return $b; |
|
| 24 | + $b->iterateur = 'DATA'; # designe la classe d'iterateur |
|
| 25 | + $b->show = array( |
|
| 26 | + 'field' => array( |
|
| 27 | + 'cle' => 'STRING', |
|
| 28 | + 'valeur' => 'STRING', |
|
| 29 | + ) |
|
| 30 | + ); |
|
| 31 | + return $b; |
|
| 32 | 32 | } |
| 33 | 33 | |
@@ -20,16 +20,16 @@ |
||
| 20 | 20 | // annonce au compilo les "champs" disponibles |
| 21 | 21 | // |
| 22 | 22 | function iterateur_CONDITION_dist($b) { |
| 23 | - $b->iterateur = 'CONDITION'; # designe la classe d'iterateur |
|
| 24 | - $b->show = array( |
|
| 25 | - 'field' => array() |
|
| 26 | - ); |
|
| 27 | - return $b; |
|
| 23 | + $b->iterateur = 'CONDITION'; # designe la classe d'iterateur |
|
| 24 | + $b->show = array( |
|
| 25 | + 'field' => array() |
|
| 26 | + ); |
|
| 27 | + return $b; |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | |
| 31 | 31 | class IterateurCONDITION extends IterateurData { |
| 32 | - protected function select($command) { |
|
| 33 | - $this->tableau = array(0=>1); |
|
| 34 | - } |
|
| 32 | + protected function select($command) { |
|
| 33 | + $this->tableau = array(0=>1); |
|
| 34 | + } |
|
| 35 | 35 | } |
@@ -16,59 +16,59 @@ |
||
| 16 | 16 | // http://doc.spip.org/@genie_maintenance_dist |
| 17 | 17 | function genie_maintenance_dist ($t) { |
| 18 | 18 | |
| 19 | - // (re)mettre .htaccess avec deny from all |
|
| 20 | - // dans les deux repertoires dits inaccessibles par http |
|
| 21 | - include_spip('inc/acces'); |
|
| 22 | - verifier_htaccess(_DIR_ETC); |
|
| 23 | - verifier_htaccess(_DIR_TMP); |
|
| 19 | + // (re)mettre .htaccess avec deny from all |
|
| 20 | + // dans les deux repertoires dits inaccessibles par http |
|
| 21 | + include_spip('inc/acces'); |
|
| 22 | + verifier_htaccess(_DIR_ETC); |
|
| 23 | + verifier_htaccess(_DIR_TMP); |
|
| 24 | 24 | |
| 25 | - // Verifier qu'aucune table n'est crashee |
|
| 26 | - if (!_request('reinstall')) |
|
| 27 | - verifier_crash_tables(); |
|
| 25 | + // Verifier qu'aucune table n'est crashee |
|
| 26 | + if (!_request('reinstall')) |
|
| 27 | + verifier_crash_tables(); |
|
| 28 | 28 | |
| 29 | - return 1; |
|
| 29 | + return 1; |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | |
| 33 | 33 | // http://doc.spip.org/@verifier_crash_tables |
| 34 | 34 | function verifier_crash_tables() { |
| 35 | - if (spip_connect()) { |
|
| 36 | - include_spip('base/serial'); |
|
| 37 | - include_spip('base/auxiliaires'); |
|
| 38 | - $crash = array(); |
|
| 39 | - foreach (array('tables_principales', 'tables_auxiliaires') as $com) { |
|
| 40 | - foreach ($GLOBALS[$com] as $table => $desc) { |
|
| 41 | - if (!sql_select('*', $table,'','','', 1) |
|
| 42 | - AND !defined('spip_interdire_cache')) # cas "LOST CONNECTION" |
|
| 43 | - $crash[] = $table; |
|
| 44 | - } |
|
| 45 | - } |
|
| 46 | - #$crash[] = 'test'; |
|
| 47 | - if ($crash) { |
|
| 48 | - ecrire_meta('message_crash_tables', serialize($crash)); |
|
| 49 | - spip_log('crash des tables', 'err'); |
|
| 50 | - spip_log($crash, 'err'); |
|
| 51 | - } else { |
|
| 52 | - effacer_meta('message_crash_tables'); |
|
| 53 | - } |
|
| 35 | + if (spip_connect()) { |
|
| 36 | + include_spip('base/serial'); |
|
| 37 | + include_spip('base/auxiliaires'); |
|
| 38 | + $crash = array(); |
|
| 39 | + foreach (array('tables_principales', 'tables_auxiliaires') as $com) { |
|
| 40 | + foreach ($GLOBALS[$com] as $table => $desc) { |
|
| 41 | + if (!sql_select('*', $table,'','','', 1) |
|
| 42 | + AND !defined('spip_interdire_cache')) # cas "LOST CONNECTION" |
|
| 43 | + $crash[] = $table; |
|
| 44 | + } |
|
| 45 | + } |
|
| 46 | + #$crash[] = 'test'; |
|
| 47 | + if ($crash) { |
|
| 48 | + ecrire_meta('message_crash_tables', serialize($crash)); |
|
| 49 | + spip_log('crash des tables', 'err'); |
|
| 50 | + spip_log($crash, 'err'); |
|
| 51 | + } else { |
|
| 52 | + effacer_meta('message_crash_tables'); |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - return $crash; |
|
| 56 | - } |
|
| 55 | + return $crash; |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - return false; |
|
| 58 | + return false; |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | // http://doc.spip.org/@message_crash_tables |
| 62 | 62 | function message_crash_tables() { |
| 63 | - if ($crash = verifier_crash_tables()) { |
|
| 64 | - return |
|
| 65 | - '<strong>' . _T('texte_recuperer_base') . '</strong><br />' |
|
| 66 | - . ' <tt>'.join(', ', $crash).'</tt><br />' |
|
| 67 | - . generer_form_ecrire('base_repair', |
|
| 68 | - _T('texte_crash_base'), '', |
|
| 69 | - _T('bouton_tenter_recuperation')) |
|
| 70 | - ; |
|
| 71 | - } |
|
| 63 | + if ($crash = verifier_crash_tables()) { |
|
| 64 | + return |
|
| 65 | + '<strong>' . _T('texte_recuperer_base') . '</strong><br />' |
|
| 66 | + . ' <tt>'.join(', ', $crash).'</tt><br />' |
|
| 67 | + . generer_form_ecrire('base_repair', |
|
| 68 | + _T('texte_crash_base'), '', |
|
| 69 | + _T('bouton_tenter_recuperation')) |
|
| 70 | + ; |
|
| 71 | + } |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | ?> |
@@ -19,12 +19,12 @@ discard block |
||
| 19 | 19 | * @return int |
| 20 | 20 | */ |
| 21 | 21 | function genie_mise_a_jour_dist($t) { |
| 22 | - include_spip('inc/meta'); |
|
| 23 | - $maj = info_maj ('spip', 'SPIP', $GLOBALS['spip_version_branche']); |
|
| 24 | - ecrire_meta('info_maj_spip',$maj?($GLOBALS['spip_version_branche']."|$maj"):"",'non'); |
|
| 22 | + include_spip('inc/meta'); |
|
| 23 | + $maj = info_maj ('spip', 'SPIP', $GLOBALS['spip_version_branche']); |
|
| 24 | + ecrire_meta('info_maj_spip',$maj?($GLOBALS['spip_version_branche']."|$maj"):"",'non'); |
|
| 25 | 25 | |
| 26 | - spip_log("Verification version SPIP : ".($maj?$maj:"version a jour"),"verifie_maj"); |
|
| 27 | - return 1; |
|
| 26 | + spip_log("Verification version SPIP : ".($maj?$maj:"version a jour"),"verifie_maj"); |
|
| 27 | + return 1; |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | |
@@ -35,32 +35,32 @@ discard block |
||
| 35 | 35 | define('_VERSIONS_LISTE', 'archives.xml'); |
| 36 | 36 | |
| 37 | 37 | function info_maj ($dir, $file, $version){ |
| 38 | - include_spip('inc/plugin'); |
|
| 38 | + include_spip('inc/plugin'); |
|
| 39 | 39 | |
| 40 | - list($maj,$min,$rev) = preg_split('/\D+/', $version); |
|
| 40 | + list($maj,$min,$rev) = preg_split('/\D+/', $version); |
|
| 41 | 41 | |
| 42 | - $nom = _DIR_CACHE_XML . _VERSIONS_LISTE; |
|
| 43 | - $page = !file_exists($nom) ? '' : file_get_contents($nom); |
|
| 44 | - $page = info_maj_cache($nom, $dir, $page); |
|
| 42 | + $nom = _DIR_CACHE_XML . _VERSIONS_LISTE; |
|
| 43 | + $page = !file_exists($nom) ? '' : file_get_contents($nom); |
|
| 44 | + $page = info_maj_cache($nom, $dir, $page); |
|
| 45 | 45 | |
| 46 | - // reperer toutes les versions de numero majeur superieur ou egal |
|
| 47 | - // (a revoir quand on arrivera a SPIP V10 ...) |
|
| 48 | - $p = substr("0123456789", intval($maj)); |
|
| 49 | - $p = ',/' . $file . '\D+([' . $p . ']+)\D+(\d+)(\D+(\d+))?.*?[.]zip",i'; |
|
| 50 | - preg_match_all($p, $page, $m, PREG_SET_ORDER); |
|
| 51 | - $page = ''; |
|
| 52 | - foreach ($m as $v) { |
|
| 53 | - list(, $maj2, $min2,, $rev2) = $v; |
|
| 54 | - $version_maj = $maj2 . '.' . $min2 . '.' . $rev2; |
|
| 55 | - if ((spip_version_compare($version, $version_maj, '<')) |
|
| 56 | - AND (spip_version_compare($page, $version_maj, '<'))) |
|
| 57 | - $page = $version_maj; |
|
| 58 | - } |
|
| 46 | + // reperer toutes les versions de numero majeur superieur ou egal |
|
| 47 | + // (a revoir quand on arrivera a SPIP V10 ...) |
|
| 48 | + $p = substr("0123456789", intval($maj)); |
|
| 49 | + $p = ',/' . $file . '\D+([' . $p . ']+)\D+(\d+)(\D+(\d+))?.*?[.]zip",i'; |
|
| 50 | + preg_match_all($p, $page, $m, PREG_SET_ORDER); |
|
| 51 | + $page = ''; |
|
| 52 | + foreach ($m as $v) { |
|
| 53 | + list(, $maj2, $min2,, $rev2) = $v; |
|
| 54 | + $version_maj = $maj2 . '.' . $min2 . '.' . $rev2; |
|
| 55 | + if ((spip_version_compare($version, $version_maj, '<')) |
|
| 56 | + AND (spip_version_compare($page, $version_maj, '<'))) |
|
| 57 | + $page = $version_maj; |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - if (!$page) return ""; |
|
| 61 | - return "<a class='info_maj_spip' href='"._VERSIONS_SERVEUR."$dir' title='$page'>" . |
|
| 62 | - _T('nouvelle_version_spip',array('version'=>$page)) . |
|
| 63 | - '</a>'; |
|
| 60 | + if (!$page) return ""; |
|
| 61 | + return "<a class='info_maj_spip' href='"._VERSIONS_SERVEUR."$dir' title='$page'>" . |
|
| 62 | + _T('nouvelle_version_spip',array('version'=>$page)) . |
|
| 63 | + '</a>'; |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | // Verifie que la liste $page des versions dans le fichier $nom est a jour |
@@ -70,20 +70,20 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | function info_maj_cache($nom, $dir, $page='') |
| 72 | 72 | { |
| 73 | - $re = '<archives id="a' . $GLOBALS['meta']["alea_ephemere"] . '">'; |
|
| 74 | - if (preg_match("/$re/", $page)) return $page; |
|
| 73 | + $re = '<archives id="a' . $GLOBALS['meta']["alea_ephemere"] . '">'; |
|
| 74 | + if (preg_match("/$re/", $page)) return $page; |
|
| 75 | 75 | |
| 76 | - $url = _VERSIONS_SERVEUR . $dir . '/' . _VERSIONS_LISTE; |
|
| 77 | - $a = file_exists($nom) ? filemtime($nom) : ''; |
|
| 78 | - include_spip('inc/distant'); |
|
| 79 | - $res = recuperer_lapage($url, false, 'GET', _COPIE_LOCALE_MAX_SIZE, '',false, $a); |
|
| 80 | - // Si rien de neuf (ou inaccessible), garder l'ancienne |
|
| 81 | - if ($res) list(, $page) = $res; |
|
| 82 | - // Placer l'indicateur de fraicheur |
|
| 83 | - $page = preg_replace('/^<archives.*?>/', $re, $page); |
|
| 84 | - sous_repertoire(_DIR_CACHE_XML); |
|
| 85 | - ecrire_fichier($nom, $page); |
|
| 86 | - return $page; |
|
| 76 | + $url = _VERSIONS_SERVEUR . $dir . '/' . _VERSIONS_LISTE; |
|
| 77 | + $a = file_exists($nom) ? filemtime($nom) : ''; |
|
| 78 | + include_spip('inc/distant'); |
|
| 79 | + $res = recuperer_lapage($url, false, 'GET', _COPIE_LOCALE_MAX_SIZE, '',false, $a); |
|
| 80 | + // Si rien de neuf (ou inaccessible), garder l'ancienne |
|
| 81 | + if ($res) list(, $page) = $res; |
|
| 82 | + // Placer l'indicateur de fraicheur |
|
| 83 | + $page = preg_replace('/^<archives.*?>/', $re, $page); |
|
| 84 | + sous_repertoire(_DIR_CACHE_XML); |
|
| 85 | + ecrire_fichier($nom, $page); |
|
| 86 | + return $page; |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | ?> |
@@ -25,31 +25,31 @@ |
||
| 25 | 25 | * @return int |
| 26 | 26 | */ |
| 27 | 27 | function genie_mail_dist($t) { |
| 28 | - $adresse_neuf = $GLOBALS['meta']['adresse_neuf']; |
|
| 29 | - $jours_neuf = $GLOBALS['meta']['jours_neuf']; |
|
| 30 | - |
|
| 31 | - $now = time(); |
|
| 32 | - if (!isset($GLOBALS['meta']['dernier_envoi_neuf'])) |
|
| 33 | - ecrire_meta('dernier_envoi_neuf',date('Y-m-d H:i:s',$now - (3600 * 24 * $jours_neuf))); |
|
| 34 | - |
|
| 35 | - $page = recuperer_fond('nouveautes',array('date'=>$GLOBALS['meta']['dernier_envoi_neuf'],'jours_neuf'=>$jours_neuf),array('raw'=>true)); |
|
| 36 | - |
|
| 37 | - if (strlen(trim($page['texte']))){ |
|
| 38 | - // recuperer les entetes envoyes par #HTTP_HEADER |
|
| 39 | - $headers = ""; |
|
| 40 | - if (isset($page['entetes']) AND count($page['entetes'])){ |
|
| 41 | - foreach ($page['entetes'] as $k => $v) |
|
| 42 | - $headers .= (strlen($v)?"$k: $v":$k)."\n"; |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - include_spip("inc/notifications"); |
|
| 46 | - notifications_envoyer_mails($adresse_neuf,$page['texte'],"","",$headers); |
|
| 47 | - ecrire_meta('dernier_envoi_neuf',date('Y-m-d H:i:s',$now)); |
|
| 48 | - } |
|
| 49 | - else |
|
| 50 | - spip_log("mail nouveautes : rien de neuf depuis $jours_neuf jours"); |
|
| 51 | - |
|
| 52 | - return 1; |
|
| 28 | + $adresse_neuf = $GLOBALS['meta']['adresse_neuf']; |
|
| 29 | + $jours_neuf = $GLOBALS['meta']['jours_neuf']; |
|
| 30 | + |
|
| 31 | + $now = time(); |
|
| 32 | + if (!isset($GLOBALS['meta']['dernier_envoi_neuf'])) |
|
| 33 | + ecrire_meta('dernier_envoi_neuf',date('Y-m-d H:i:s',$now - (3600 * 24 * $jours_neuf))); |
|
| 34 | + |
|
| 35 | + $page = recuperer_fond('nouveautes',array('date'=>$GLOBALS['meta']['dernier_envoi_neuf'],'jours_neuf'=>$jours_neuf),array('raw'=>true)); |
|
| 36 | + |
|
| 37 | + if (strlen(trim($page['texte']))){ |
|
| 38 | + // recuperer les entetes envoyes par #HTTP_HEADER |
|
| 39 | + $headers = ""; |
|
| 40 | + if (isset($page['entetes']) AND count($page['entetes'])){ |
|
| 41 | + foreach ($page['entetes'] as $k => $v) |
|
| 42 | + $headers .= (strlen($v)?"$k: $v":$k)."\n"; |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + include_spip("inc/notifications"); |
|
| 46 | + notifications_envoyer_mails($adresse_neuf,$page['texte'],"","",$headers); |
|
| 47 | + ecrire_meta('dernier_envoi_neuf',date('Y-m-d H:i:s',$now)); |
|
| 48 | + } |
|
| 49 | + else |
|
| 50 | + spip_log("mail nouveautes : rien de neuf depuis $jours_neuf jours"); |
|
| 51 | + |
|
| 52 | + return 1; |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | ?> |