1 | <?php |
---|
2 | //================================================================================================= |
---|
3 | global $conf,$template,$page ; |
---|
4 | global $infos_message,$erreur_message,$infos_warning; |
---|
5 | |
---|
6 | global $user, $val; |
---|
7 | global $list_visible, $state,$liste_plugins; |
---|
8 | global $set_plugins_parametres; |
---|
9 | global $nb,$liste,$state,$list_visible,$add_plugins; |
---|
10 | if (isset($conf['set_plugins'])) $set_plugins_parametres = unserialize($conf['set_plugins']); |
---|
11 | $nb=set_plugins::set_var('nb','10'); |
---|
12 | |
---|
13 | $liste = set_plugins::set_var('list',array()); |
---|
14 | if (isset($liste[0]) && is_array($liste[0])) |
---|
15 | $liste = array(); |
---|
16 | $liste= array_unique($liste); |
---|
17 | |
---|
18 | $state=set_plugins::set_var('state',"active"); |
---|
19 | $list_visible=set_plugins::set_var('list_visible',"on,on,on,on"); |
---|
20 | $add_plugins=set_plugins::set_var('add_plugins',""); |
---|
21 | |
---|
22 | global $set; |
---|
23 | |
---|
24 | if ( isset($_POST)) { |
---|
25 | $set="true"; |
---|
26 | }else{ |
---|
27 | $set="false"; |
---|
28 | } |
---|
29 | |
---|
30 | $dir=realpath('./local/plugins/set_plugins'); |
---|
31 | if (!is_dir($dir)){ |
---|
32 | $dir= realpath('./local/plugins'). "\\set_plugins"; |
---|
33 | $umask = umask(0); |
---|
34 | $mkd = @mkdir($dir, 0755, true ); |
---|
35 | umask($umask); |
---|
36 | if ($mkd==false){ |
---|
37 | fatal_error( "$dir ".l10n('no write access')); |
---|
38 | } |
---|
39 | $file = $dir.'\\.htaccess'; |
---|
40 | @file_put_contents( $file, 'allow from all' ); |
---|
41 | } |
---|
42 | $dir=realpath('./local/plugins/set_plugins'); |
---|
43 | if(!isset($edited_file) || $edited_file=="") |
---|
44 | $edited_file=$dir."/config.txt"; |
---|
45 | $edited_file=str_replace("\\","/", $edited_file); |
---|
46 | |
---|
47 | if (isset($_POST['submit']) && $_POST['submit']==l10n('save_file')){ |
---|
48 | if (file_exists($edited_file)){ |
---|
49 | copy($edited_file, substr_replace($edited_file, '.bak', strrpos($edited_file , '.'), 0) ); |
---|
50 | |
---|
51 | |
---|
52 | } |
---|
53 | if ($file = @fopen($edited_file , "w")) { |
---|
54 | $liste= array_unique($liste); |
---|
55 | @fwrite($file , serialize($liste)); |
---|
56 | @fclose($file); |
---|
57 | $infos_message.=l10n("save config").set_plugins::memo_var($liste); |
---|
58 | $infos_message.=set_plugins::memo_var($liste); |
---|
59 | $infos_message.=set_plugins::memo_var($_POST); |
---|
60 | unset($_POST['submit']); |
---|
61 | } |
---|
62 | |
---|
63 | } |
---|
64 | |
---|
65 | ///================================================================ |
---|
66 | if (isset($_POST['restore'])){ |
---|
67 | $content_file = file_get_contents(substr_replace($edited_file, '.bak', strrpos($edited_file , '.'), 0)); |
---|
68 | $file =array(); |
---|
69 | $liste= array_unique(unserialize($content_file)); |
---|
70 | unset($_POST['restore']); |
---|
71 | } |
---|
72 | |
---|
73 | |
---|
74 | if(isset($_POST['add_plugins']) && $add_plugins!="" ){ |
---|
75 | $liste= array_unique($liste); |
---|
76 | if(!array_search($add_plugins, $liste)){ |
---|
77 | array_push($liste, $add_plugins ); |
---|
78 | } |
---|
79 | $add_plugins=""; |
---|
80 | unset( $_POST['add_plugins']); |
---|
81 | } |
---|
82 | |
---|
83 | if(count($liste )>0) |
---|
84 | $liste_plugins=isset($_POST['liste_plugins'])?$_POST['liste_plugins']:$liste; |
---|
85 | |
---|
86 | if ( $set=="true"){ |
---|
87 | set_plugins::save_config(); |
---|
88 | unset($_POST['list_visible']); |
---|
89 | unset($_POST['nb']); |
---|
90 | } |
---|
91 | |
---|
92 | |
---|
93 | |
---|
94 | $plugins = new plugins(); |
---|
95 | $plugins->sort_fs_plugins('name'); |
---|
96 | //$plugins->get_incompatible_plugins(); |
---|
97 | $redirect_url = get_root_url().'admin.php?page='.$_GET['page']; |
---|
98 | $base_url = get_root_url().'admin.php?page='.$page['page']; |
---|
99 | $action_url = $base_url.'&plugin='.'%s'.'&pwg_token='.get_pwg_token(); |
---|
100 | //======================================================= |
---|
101 | |
---|
102 | if($liste) $liste_plugins = array_combine($liste,$liste); |
---|
103 | else $liste_plugins =array(); |
---|
104 | //========================================================== |
---|
105 | $plugin_ids = array_intersect(array_keys($plugins->db_plugins_by_id), |
---|
106 | array_keys($liste_plugins) |
---|
107 | ); |
---|
108 | $liste_tpl=array(); |
---|
109 | foreach($plugins->fs_plugins as $plugin_id => $fs_plugin) { |
---|
110 | //==== test si $plugin_id fait partie de $liste_plugins ============== |
---|
111 | $key = array_search($plugin_id, $liste_plugins,false); |
---|
112 | if ($key!== false){ |
---|
113 | if(isset( $plugins->db_plugins_by_id[$plugin_id])){ |
---|
114 | $tpl_plugin = array( |
---|
115 | 'NAME' => $fs_plugin['name'], |
---|
116 | 'U_ACTION' => sprintf($action_url, $plugin_id), |
---|
117 | 'STATE' => $plugins->db_plugins_by_id[$plugin_id]['state'] |
---|
118 | ); |
---|
119 | $liste_tpl[$plugin_id]= $tpl_plugin ; |
---|
120 | } |
---|
121 | |
---|
122 | } |
---|
123 | |
---|
124 | } |
---|
125 | $template->assign( array( 'liste_plugins' => $liste_tpl)); |
---|
126 | |
---|
127 | $template->assign( array( 'PHPWG_VERSION' => PHPWG_VERSION , |
---|
128 | 'cl_plugins' => $cl_set_plugins_plugin , |
---|
129 | 'cl_version' => $cl_set_plugins_plugin['version'] , |
---|
130 | 'name' => $cl_set_plugins_plugin['name'] , |
---|
131 | 'Version_pwg' => PHPWG_VERSION, |
---|
132 | 'SET_PLUGINS_PATH' => SET_PLUGINS_PATH, |
---|
133 | 'SET_PLUGINS_PATH_ABS' => SET_PLUGINS_PATH_ABS, |
---|
134 | 'set' => $set , |
---|
135 | 'nb' => ($nb>0)?$nb:1, |
---|
136 | 'state' => $state , |
---|
137 | 'list_visible' => $list_visible, |
---|
138 | 'add_plugins' => $add_plugins, |
---|
139 | 'nb_list' => count($liste), |
---|
140 | 'nb_plugins' => count($plugins->db_plugins_by_id) , |
---|
141 | 'restore' => false , |
---|
142 | 'edited_file' => $edited_file |
---|
143 | ) |
---|
144 | ); |
---|
145 | |
---|
146 | |
---|
147 | ?> |
---|