'Set_plugins', 'URL' => get_admin_plugin_menu_link(dirname(__FILE__)).'/admin.php' ) ); return $menu; } //============================================================================ function begin_admin() { global $erreur_message,$liste_des_plugins_actifs,$liste_active_plugins,$page; //========= Liste des plugins actifs ================= if (!isset($page['body_id'])) return; if($page['body_id']!='theAdminPage' ) return ; if($page['page']=='plugins_list' || $page['page']=='plugins'){ $plugins = new plugins(); $plugins->sort_fs_plugins('name'); $liste_des_plugins_actifs = array(); foreach ($plugins->fs_plugins as $plugin_id => $fs_plugin){ if(isset( $plugins->db_plugins_by_id[$plugin_id])){ $State_id=$plugins->db_plugins_by_id[$plugin_id]['state'] ; if($State_id=="active" && $plugin_id!="set_plugins") array_push($liste_des_plugins_actifs,$plugin_id); } } //foreach if (isset($_GET['set'])){ $ret['config']=$_GET; $ret['liste_plugins']=$liste_des_plugins_actifs; // array_push($ret,$liste_des_plugins_actifs); if($_GET['config']['liste_visible']) set_plugins::save_config(); echo json_encode($ret); exit; } $liste_active_plugins=$liste_des_plugins_actifs; } } //============================================================================ function set_plugins_add() { global $user, $template, $val,$page,$conf,$erreur_message,$infos_message; global $liste_des_plugins_actifs,$liste_active_plugins; if (!isset($page['body_id'])) return; switch($page['body_id']){ case 'theAdminPage': switch($page['page']){ case 'plugins_list': if(!isset($template)) return ; set_plugins::Affiche_set_plugins(); break; case 'plugins': if (!isset($page['tab'])) return; if ($page['tab']!="installed") return ; set_plugins::Affiche_set_plugins(); break; } } } //============================================================================ function messages_admin(){ global $template,$page, $template, $pwg_loaded_plugins,$infos_message,$erreur_message,$infos_warning; if ( (isset($_GET['page']) AND ($_GET['page'] == 'plugins' || $_GET['page'] == 'plugins_list' )) ) { if (!isset($page['infos'])) $page['infos']=array(); if ($infos_message != "") { array_push($page['infos'], $infos_message); $infos_message=""; } if (count($page['infos']) != 0){ $template->assign('infos', $page['infos']); } if (!isset($page['errors'])) $page['errors']=array(); if ($erreur_message != "") { array_push($page['errors'], $erreur_message); $erreur_message=""; } if (count($page['errors']) != 0){ $template->assign('errors', $page['errors']); } if (!isset($page['warnings'])) $page['warnings']=array(); if ($infos_warning!= "") { array_push($page['warnings'], $infos_warning); $infos_warning= ""; } if (count($page['warnings']) != 0){ $template->assign('warnings', $page['warnings']); } } } //========================================================================================== function set_var($key,$defaut){ global $set_plugins_parametres; global $infos_message; if(isset($set_plugins_parametres) && isset($set_plugins_parametres[$key])) $ret=$set_plugins_parametres[$key]; $ret= (isset($ret))?$ret:$defaut; $ret=isset($_POST[$key])?$_POST[$key]:$ret; return $ret ; } //================================================================ function save_config(){ global $list_visible, $state,$liste,$nb,$page,$conf ; global $infos_message,$infos_warning,$erreur_message ; $config=array(); $config = array( 'list_visible' => $list_visible, 'state' => $state, 'liste'=>$liste, 'nb' =>$nb ); // $infos_warning .="save_config" . set_plugins::memo_var($conf['set_plugins'] ); $conf['set_plugins']= (serialize($config)); conf_update_param('set_plugins', $conf['set_plugins']); } //================================================================= function memo_var($variables){ ob_start(); echo '
';
    print_r($variables);
    echo '
'; $m= ob_get_contents(); ob_end_clean(); return $m; } //=================================================================== function Affiche_set_plugins(){ global $infos_message,$liste_des_plugins_actifs,$erreur_message ; include_once(SET_PLUGINS_PATH."include/constants.php"); include(SET_PLUGINS_PATH.'include/affiche.php'); $all_tpl_vars = $template->get_template_vars('ADMIN_CONTENT'); if( isset($_POST['submit'])){ $state=""; if($_POST['submit']==l10n("Deactivate") ) $state='inactive'; elseif($_POST['submit']==l10n("Activate") ) $state='active'; if($state!=""){ if($state=="inactive") $sens ="DESC"; else $sens="ASC"; //============================ $query = 'SELECT * FROM ' . PLUGINS_TABLE . ' WHERE `state` NOT LIKE "'.$state. '" AND id!="' . "set_plugins" . '" ORDER BY `id` '.$sens.' LIMIT '.$nb.' '; $result = pwg_query($query); //======= mise a  jour ========= if($result){ $query = ' UPDATE '.PLUGINS_TABLE.' SET state="'.$state.'" WHERE `state` NOT LIKE "'.$state. '" AND id!="' . "set_plugins" . '" ORDER BY `id` '.$sens.' LIMIT '.$nb.';'; pwg_query($query); } //===================================== if(isset($result) && $result==true){ $liste= array_unique($liste); if(!array_search($add_plugins, $liste)){ array_push($liste, $add_plugins ); } while ($row = pwg_db_fetch_assoc($result)) { $url = $row['id'] ; array_push($liste, $url); } } }else if ($_POST['submit']==l10n('store') ){ $liste = array(); $state="active"; $query = 'SELECT * FROM ' . PLUGINS_TABLE . ' WHERE `state` LIKE "active" AND id!="' . "set_plugins" . '" '; $result = pwg_query($query); if(isset($result) && $result==true){ $liste_plugins = array(); while ($row = pwg_db_fetch_assoc($result)) { $url = $row['id'] ; //array_push($liste_plugins, array('plugin' => $url ) ); array_push($liste, $url ); } } $nb=count($liste_plugins); } if(isset($result) && $result==true){ $redirect_url = get_root_url().'admin.php?page='.$_GET['page']; set_plugins::save_config(); $_POST['set']=""; $set=""; include(SET_PLUGINS_PATH.'include/affiche.php'); // redirect($redirect_url); } } $template->set_filenames( array( 'cl_plugin' => SET_PLUGINS_PATH_ABS.'template/admin.tpl' ) ); //=========================================================== $header_1='

'.l10n("set_plugins").l10n("Version").": ".$cl_set_plugins_plugin['version'] .'

'; $bpplus=$header_1."
".$template->parse('cl_plugin', true)."
"; $template-> assign('ADMIN_CONTENT',$bpplus); $template-> concat('ADMIN_CONTENT',$all_tpl_vars); } //======================================== function save_to_file($liste){ global $infos_message; $edited_file=set_plugins::get_file_name(); if (file_exists($edited_file)){ copy($edited_file, substr_replace($edited_file, '.bak', strrpos($edited_file , '.'), 0) ); } if ($file = @fopen($edited_file , "w")) { $liste= array_unique($liste); @fwrite($file , serialize($liste)); @fclose($file); $infos_message.=l10n("save config").set_plugins::memo_var($edited_file); unset($_POST['submit']); } } //============================================== function restore_from_file(){ global $infos_message,$edited_file; $content_file = file_get_contents($edited_file); return unserialize($content_file) ; } //=============================================== function get_file_name(){ global $edited_file,$infos_message; $dir=realpath('./local/plugins/set_plugins'); if (!is_dir($dir)){ $dir=realpath('./local/plugins'); if (!is_dir($dir)){ $dir=str_replace("\\","/",realpath('./local').'/plugins'); $umask = umask(0); $mkd = @mkdir($dir, 0755, true ); umask($umask); if ($mkd==false){ fatal_error( "1°) $dir ".l10n('no write access')); } } //===================================================== $dir=realpath('./local/plugins/set_plugins'); if (!is_dir($dir)){ $dir=str_replace("\\","/",realpath('./local/plugins').'/set_plugins'); $umask = umask(0); $mkd = @mkdir($dir, 0755, true ); umask($umask); if ($mkd==false){ fatal_error( "2°) $dir ".l10n('no write access')); } //$file = $dir.'\\.htaccess'; //@file_put_contents( $file, 'allow from all' ); } $dir=realpath('./local/plugins/set_plugins'); } if(!isset($edited_file) || $edited_file=="") $edited_file=$dir."/config.txt"; $edited_file=str_replace("\\","/", $edited_file); return $edited_file ; } }// fin classe ?>