Changeset 5206 in spip-zone
- Timestamp:
- Sep 9, 2006, 7:04:30 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
_plugins_/_amelioration_admin_/icones_admin/exec/config_habillage_prive.php
r5202 r5206 60 60 $plugin_directory = _DIR_PLUGIN_HABILLAGE_PRIVE; 61 61 62 ## ATTENTION : LE CAS DE FIGURE DANS LEQUEL L'UTILISATEUR OUVRE CETTE PAGE SANS 63 ## CHOISIR UNE CASE A COCHER N'A PAS ETE PROGRAMME, CE QUI CAUSE UNE ERREUR DANS 64 ## LE FICHIER MES_OPTIONS.PHP SI L'ON VISITE JUSTE CETTE PAGE SANS RIEN FAIRE. 65 66 // Si le fichier inc/mes_options.php existe deja 67 if (file_exists($options_file)) { 68 $backup_file = "$options_file.backup"; 69 rename($options_file, $backup_file); 70 $open_backup_file = fopen($backup_file, 'r'); 71 $backup_file_size = filesize ($backup_file); 72 $read_backup_file = fread ($open_backup_file, $backup_file_size); 73 $search_comment = eregi("//start_define_img_pack(.*)//end_define_img_pack", $read_backup_file, $comment); 74 $search_original_content = eregi("define\(\'_DIR_IMG_PACK\', \(\'(.*)\'\)\)\;", $read_backup_file, $original_content); 75 $search_content = eregi("define\(\'_DIR_IMG_PACK\', \(\'(.*)\'\)\)\;(.*)//end_define_img_pack", $read_backup_file, $content); 76 $search_all_content = eregi("<\?(.*)define\(\'_DIR_IMG_PACK\', \(\'(.*)\'\)\)\;(.*)\?>", $read_backup_file, $all_content); 77 78 # Si l'utilisateur ou l'utilisatrice ne demande pas a revenir a la situation 79 # initiale (= a son chemin vers img_pack d'origine). 80 if ($theme != "initial") { 81 82 # Si le fichier ecrire/mes_options.php contient le commentaire ajoute par 83 # le plugin, cela signifie que le plugin a deja ete active pour un habillage. 84 # Il faut donc modifier la ligne existante personnalisee du chemin vers 85 # img_pack. : 86 if ($search_comment) { 87 $open_options_file = fopen($options_file, 'w+'); 88 $new_content = $plugin_directory."/themes/".$theme."/img_pack/"; 89 $insert_new_content = ereg_replace($content[1], $new_content, $read_backup_file); 90 $write = fwrite($open_options_file, $insert_new_content); 91 fclose($open_options_file); 92 } 93 94 # Si le fichier mes_options sauvegarde redefinissait le chemin d'img_pack 95 # par la ligne define('_DIR_IMG_PACK', [...]) avant le choix d'un autre 96 # habillage : 97 else if ($search_original_content) { 98 $search_comment_backup = eregi("//backup(.*)", $read_backup_file); 62 # N'agir que si le theme n'est pas vide. Ceci permet, en cas de non-choix, de ne pas 63 # ecrire un fichier mes_options.php errone. 64 if ($theme != "") { 65 // Si le fichier inc/mes_options.php existe deja 66 if (file_exists($options_file)) { 67 $backup_file = "$options_file.backup"; 68 rename($options_file, $backup_file); 69 $open_backup_file = fopen($backup_file, 'r'); 70 $backup_file_size = filesize ($backup_file); 71 $read_backup_file = fread ($open_backup_file, $backup_file_size); 72 $search_comment = eregi("//start_define_img_pack(.*)//end_define_img_pack", $read_backup_file, $comment); 73 $search_original_content = eregi("define\(\'_DIR_IMG_PACK\', \(\'(.*)\'\)\)\;", $read_backup_file, $original_content); 74 $search_content = eregi("define\(\'_DIR_IMG_PACK\', \(\'(.*)\'\)\)\;(.*)//end_define_img_pack", $read_backup_file, $content); 75 $search_all_content = eregi("<\?(.*)define\(\'_DIR_IMG_PACK\', \(\'(.*)\'\)\)\;(.*)\?>", $read_backup_file, $all_content); 76 77 # Si l'utilisateur ou l'utilisatrice ne demande pas a revenir a la situation 78 # initiale (= a son chemin vers img_pack d'origine). 79 if ($theme != "initial") { 80 81 # Si le fichier ecrire/mes_options.php contient le commentaire ajoute par 82 # le plugin, cela signifie que le plugin a deja ete active pour un habillage. 83 # Il faut donc modifier la ligne existante personnalisee du chemin vers 84 # img_pack. : 85 if ($search_comment) { 86 $open_options_file = fopen($options_file, 'w+'); 87 $new_content = $plugin_directory."/themes/".$theme."/img_pack/"; 88 $insert_new_content = ereg_replace($content[1], $new_content, $read_backup_file); 89 $write = fwrite($open_options_file, $insert_new_content); 90 fclose($open_options_file); 91 } 99 92 100 if ($search_comment_backup) { 93 # Si le fichier mes_options sauvegarde redefinissait le chemin d'img_pack 94 # par la ligne define('_DIR_IMG_PACK', [...]) avant le choix d'un autre 95 # habillage : 96 else if ($search_original_content) { 97 $search_comment_backup = eregi("//backup(.*)", $read_backup_file); 98 99 if ($search_comment_backup) { 100 $open_options_file = fopen($options_file, 'w+'); 101 $new_content = "//start_define_img_pack\ndefine('_DIR_IMG_PACK', ('".$plugin_directory."/themes/".$theme."/img_pack/'));\n//end_define_img_pack\n?>"; 102 $insert_new_content = ereg_replace( '\?>', $new_content, $read_backup_file); 103 $write = fwrite($open_options_file, $insert_new_content); 104 fclose($open_options_file); 105 } 106 else { 107 $open_options_file = fopen($options_file, 'w+'); 108 $replaced_content = "define\(\'_DIR_IMG_PACK\', \(\'"; 109 $new_content = "//start_define_img_pack\ndefine('_DIR_IMG_PACK', ('".$plugin_directory."/themes/".$theme."/img_pack/'));\n//end_define_img_pack\n//backup_define('_DIR_IMG_PACK', ('"; 110 $insert_new_content = ereg_replace( $replaced_content, $new_content, $read_backup_file); 111 $write = fwrite($open_options_file, $insert_new_content); 112 fclose($open_options_file); 113 } 114 } 115 116 # Si le fichier ecrire/mes_options.php existe deja mais qu'il ne redefinie 117 # pas le chemin vers img_pack. 118 else { 101 119 $open_options_file = fopen($options_file, 'w+'); 102 120 $new_content = "//start_define_img_pack\ndefine('_DIR_IMG_PACK', ('".$plugin_directory."/themes/".$theme."/img_pack/'));\n//end_define_img_pack\n?>"; … … 105 123 fclose($open_options_file); 106 124 } 107 else { 125 126 } 127 128 # Si l'utilisateur ou l'utilisatrice veut revenir a la situation initiale. 129 else if ($theme == "initial") { 130 $search_comment_backup = eregi("//backup_define\(\'_DIR_IMG_PACK\', \(\'(.*)\'\)\)\;", $read_backup_file); 131 132 if ($search_comment) { 108 133 $open_options_file = fopen($options_file, 'w+'); 109 $replaced_content = "define\(\'_DIR_IMG_PACK\', \(\'"; 110 $new_content = "//start_define_img_pack\ndefine('_DIR_IMG_PACK', ('".$plugin_directory."/themes/".$theme."/img_pack/'));\n//end_define_img_pack\n//backup_define('_DIR_IMG_PACK', ('"; 111 $insert_new_content = ereg_replace( $replaced_content, $new_content, $read_backup_file); 134 $erased_content = "//start_define_img_pack(.*)//end_define_img_pack"; 135 $insert_new_content = ereg_replace($erased_content, '', $read_backup_file); 112 136 $write = fwrite($open_options_file, $insert_new_content); 113 137 fclose($open_options_file); 114 } 138 } 139 140 else if ($search_comment_backup){ 141 $open_options_file = fopen($options_file, 'w+'); 142 $insert_new_content = ereg_replace( '//backup_define', 'define', $read_backup_file); 143 $write = fwrite($open_options_file, $insert_new_content); 144 fclose($open_options_file); 145 } 146 147 else { 148 rename($backup_file, $options_file); 149 } 115 150 } 116 117 # Si le fichier ecrire/mes_options.php existe deja mais qu'il ne redefinie 118 # pas le chemin vers img_pack. 119 else { 120 $open_options_file = fopen($options_file, 'w+'); 121 $new_content = "//start_define_img_pack\ndefine('_DIR_IMG_PACK', ('".$plugin_directory."/themes/".$theme."/img_pack/'));\n//end_define_img_pack\n?>"; 122 $insert_new_content = ereg_replace( '\?>', $new_content, $read_backup_file); 123 $write = fwrite($open_options_file, $insert_new_content); 124 fclose($open_options_file); 125 } 126 127 } 128 129 # Si l'utilisateur ou l'utilisatrice veut revenir a la situation initiale. 130 else if ($theme == "initial") { 131 $search_comment_backup = eregi("//backup_define\(\'_DIR_IMG_PACK\', \(\'(.*)\'\)\)\;", $read_backup_file); 132 133 if ($search_comment) { 134 $open_options_file = fopen($options_file, 'w+'); 135 $erased_content = "//start_define_img_pack(.*)//end_define_img_pack"; 136 $insert_new_content = ereg_replace($erased_content, '', $read_backup_file); 137 $write = fwrite($open_options_file, $insert_new_content); 138 fclose($open_options_file); 139 } 140 141 else if ($search_comment_backup){ 142 $open_options_file = fopen($options_file, 'w+'); 143 $insert_new_content = ereg_replace( '//backup_define', 'define', $read_backup_file); 144 $write = fwrite($open_options_file, $insert_new_content); 145 fclose($open_options_file); 146 } 147 148 else { 149 rename($backup_file, $options_file); 150 } 151 } 152 } 153 154 else { 155 $open_options_file = fopen($options_file, 'w+'); 156 $new_content = "<?\n//start_define_img_pack\ndefine('_DIR_IMG_PACK', ('".$plugin_directory."/themes/".$theme."/img_pack/'));\n//end_define_img_pack\n?>"; 157 $write = fwrite($open_options_file, $new_content); 158 fclose($open_options_file); 159 } 151 } 152 153 else { 154 $open_options_file = fopen($options_file, 'w+'); 155 $new_content = "<?\n//start_define_img_pack\ndefine('_DIR_IMG_PACK', ('".$plugin_directory."/themes/".$theme."/img_pack/'));\n//end_define_img_pack\n?>"; 156 $write = fwrite($open_options_file, $new_content); 157 fclose($open_options_file); 158 } 159 } 160 160 161 161 echo '<INPUT type=radio name="theme" value="initial"';
Note: See TracChangeset
for help on using the changeset viewer.