plugins/SpecialAdmin.php
changeset 915 91f4da84966f
parent 898 c75754f5b1da
child 939 32a43ae3649b
equal deleted inserted replaced
914:f808e55fb92a 915:91f4da84966f
    71   // Admin pages that were too enormous to be in this file were split off into the plugins/admin/ directory in 1.0.1.
    71   // Admin pages that were too enormous to be in this file were split off into the plugins/admin/ directory in 1.0.1.
    72   // Only load these files if we're looking to load the admin panel
    72   // Only load these files if we're looking to load the admin panel
    73   list($pid, $ns) = RenderMan::strToPageID($paths->get_pageid_from_url());
    73   list($pid, $ns) = RenderMan::strToPageID($paths->get_pageid_from_url());
    74   if ( $ns == 'Admin' || ( $pid == 'Administration' && $ns == 'Special' ) )
    74   if ( $ns == 'Admin' || ( $pid == 'Administration' && $ns == 'Special' ) )
    75   {
    75   {
       
    76     require(ENANO_ROOT . '/plugins/admin/Home.php');
    76     require(ENANO_ROOT . '/plugins/admin/PageManager.php');
    77     require(ENANO_ROOT . '/plugins/admin/PageManager.php');
    77     require(ENANO_ROOT . '/plugins/admin/PageEditor.php');
    78     require(ENANO_ROOT . '/plugins/admin/PageEditor.php');
    78     require(ENANO_ROOT . '/plugins/admin/PageGroups.php');
    79     require(ENANO_ROOT . '/plugins/admin/PageGroups.php');
    79     require(ENANO_ROOT . '/plugins/admin/GroupManager.php');
    80     require(ENANO_ROOT . '/plugins/admin/GroupManager.php');
    80     require(ENANO_ROOT . '/plugins/admin/SecurityLog.php');
    81     require(ENANO_ROOT . '/plugins/admin/SecurityLog.php');
    93   global $db, $session, $paths, $template, $plugins; // Common objects
    94   global $db, $session, $paths, $template, $plugins; // Common objects
    94   echo '<form action="'.makeUrl($paths->nslist['Special'].'Administration', ( isset($_GET['sqldbg']) ? 'sqldbg&' : '' ) . ( isset($_GET['nocompress']) ? 'nocompress&' : '' ) . 'module='.$paths->cpage['module']).'" method="post" enctype="multipart/form-data">';
    95   echo '<form action="'.makeUrl($paths->nslist['Special'].'Administration', ( isset($_GET['sqldbg']) ? 'sqldbg&' : '' ) . ( isset($_GET['nocompress']) ? 'nocompress&' : '' ) . 'module='.$paths->cpage['module']).'" method="post" enctype="multipart/form-data">';
    95 }
    96 }
    96 
    97 
    97 // function names are IMPORTANT!!! The name pattern is: page_<namespace ID>_<page URLname, without namespace>
    98 // function names are IMPORTANT!!! The name pattern is: page_<namespace ID>_<page URLname, without namespace>
    98 
       
    99 function page_Admin_Home() {
       
   100   global $db, $session, $paths, $template, $plugins; // Common objects
       
   101   global $lang;
       
   102   if ( $session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN )
       
   103   {
       
   104     $login_link = makeUrlNS('Special', 'Login/' . $paths->nslist['Special'] . 'Administration', 'level=' . USER_LEVEL_ADMIN, true);
       
   105     echo '<h3>' . $lang->get('adm_err_not_auth_title') . '</h3>';
       
   106     echo '<p>' . $lang->get('adm_err_not_auth_body', array( 'login_link' => $login_link )) . '</p>';
       
   107     return;
       
   108   }
       
   109   
       
   110   if ( $paths->getParam(0) == 'updates.xml' )
       
   111   {
       
   112     require_once(ENANO_ROOT . '/includes/http.php');
       
   113     $req = new Request_HTTP('ktulu.enanocms.org', '/meta/updates.xml');
       
   114     $response = $req->get_response_body();
       
   115     header('Content-type: application/xml');
       
   116     if ( $req->response_code != HTTP_OK )
       
   117     {
       
   118       // Error in response
       
   119       echo '<enano><latest><error><![CDATA[
       
   120 Did not properly receive response from server. Response code: ' . $req->response_code . ' ' . $req->response_string . '
       
   121 ]]></error></latest></enano>';
       
   122     }
       
   123     else
       
   124     {
       
   125       // Retrieve first update
       
   126       $first_update = preg_match('/<release tag="([^"]+)" version="([^"]+)" (codename="([^"]+)" )?relnotes="([^"]+)" ?\/>/', $response, $match);
       
   127       if ( !$first_update )
       
   128       {
       
   129         echo '<enano><latest><error><![CDATA[
       
   130 Received invalid XML response.
       
   131 ]]></error></latest></enano>';
       
   132       }
       
   133       else
       
   134       {
       
   135         if ( version_compare(enano_version(true), $match[2], '<') )
       
   136         {
       
   137           $response = str_replace_once('</latest>', "  <haveupdates />\n  </latest>", $response);
       
   138         }
       
   139         echo $response;
       
   140       }
       
   141     }
       
   142     return;
       
   143   }
       
   144   
       
   145   // Basic information
       
   146   echo '<h2>' . $lang->get('acphome_heading_main') . '</h2>';
       
   147   echo '<p>' . $lang->get('acphome_welcome_line1') . '</p>';
       
   148   echo '<p>' . $lang->get('acphome_welcome_line2') . '</p>';
       
   149   
       
   150   // Demo mode
       
   151   if ( defined('ENANO_DEMO_MODE') )
       
   152   {
       
   153     echo '<h3>' . $lang->get('acphome_msg_demo_title') . '</h3>
       
   154           <p>' . $lang->get('acphome_msg_demo_body', array('reset_url' => makeUrlNS('Special', 'DemoReset', false, true))) . '</p>';
       
   155   }
       
   156   
       
   157   // Check for the installer scripts
       
   158   if( file_exists(ENANO_ROOT.'/install/install.php') && !defined('ENANO_DEMO_MODE') )
       
   159   {
       
   160     echo '<div class="error-box">
       
   161             ' . $lang->get('acphome_msg_install_files') . '
       
   162           </div>';
       
   163   }
       
   164   
       
   165   echo '<h3>' . $lang->get('acphome_heading_updates') . '</h3>';
       
   166   echo '<p>' . $lang->get('acphome_msg_updates_info', array('updates_url' => 'http://ktulu.enanocms.org/meta/updates.xml')) . '</p>';
       
   167   echo '<div id="update_check_container"><input type="button" onclick="ajaxUpdateCheck(this.parentNode.id);" value="' . $lang->get('acphome_btn_check_updates') . '" /></div>';
       
   168   
       
   169   // Inactive users
       
   170   $q = $db->sql_query('SELECT time_id FROM '.table_prefix.'logs WHERE log_type=\'admin\' AND action=\'activ_req\';');
       
   171   if ( $q )
       
   172   {
       
   173     if ( $db->numrows() > 0 )
       
   174     {
       
   175       $n = $db->numrows();
       
   176       $um_flags = 'href="#" onclick="ajaxPage(\''.$paths->nslist['Admin'].'UserManager\'); return false;"';
       
   177       if ( $n == 1 )
       
   178         $s = $lang->get('acphome_msg_inactive_users_one', array('um_flags' => $um_flags));
       
   179       else
       
   180         $s = $lang->get('acphome_msg_inactive_users_plural', array('um_flags' => $um_flags));
       
   181       echo '<div class="warning-box">
       
   182               ' . $s . '
       
   183             </div>';
       
   184     }
       
   185   }
       
   186   $db->free_result();
       
   187   // Stats
       
   188   if(getConfig('log_hits') == '1')
       
   189   {
       
   190     require_once(ENANO_ROOT . '/includes/stats.php');
       
   191     $stats = stats_top_pages(10);
       
   192     //die('<pre>'.print_r($stats,true).'</pre>');
       
   193     $c = 0;
       
   194     $cls = 'row2';
       
   195     echo '<h3>' . $lang->get('acphome_heading_top_pages') . '</h3>
       
   196           <div class="tblholder">
       
   197             <table style="width: 100%;" border="0" cellspacing="1" cellpadding="4">
       
   198               <tr>
       
   199                 <th>' . $lang->get('acphome_th_toppages_page') . '</th>
       
   200                 <th>' . $lang->get('acphome_th_toppages_hits') . '</th>
       
   201               </tr>';
       
   202     foreach($stats as $data)
       
   203     {
       
   204       echo   '<tr>';
       
   205       $cls = ( $cls == 'row1' ) ? 'row2' : 'row1';
       
   206       echo     '<td class="'.$cls.'">
       
   207                   <a href="'.makeUrl($data['page_urlname']).'">'.$data['page_title'].'</a></td><td style="text-align: center;" class="'.$cls.'">'.$data['num_hits']
       
   208              . '</td>';
       
   209       echo   '</tr>';
       
   210     }
       
   211     echo '  </table>
       
   212           </div>';
       
   213   }
       
   214   
       
   215   // Any hooks?
       
   216   $code = $plugins->setHook('acp_home');
       
   217   foreach ( $code as $cmd )
       
   218   {
       
   219     eval($cmd);
       
   220   }
       
   221   
       
   222   // Security log
       
   223   echo '<h3>' . $lang->get('acphome_heading_seclog') . '</h3>';
       
   224   echo '<p>' . $lang->get('acphome_msg_seclog_info') . '</p>';
       
   225   $seclog = get_security_log(5);
       
   226   echo $seclog;
       
   227   
       
   228   echo '<p><a href="#" onclick="ajaxPage(\''.$paths->nslist['Admin'].'SecurityLog\'); return false;">' . $lang->get('acphome_btn_seclog_full') . '</a></p>';
       
   229   
       
   230 }
       
   231 
    99 
   232 function page_Admin_GeneralConfig() {
   100 function page_Admin_GeneralConfig() {
   233   global $db, $session, $paths, $template, $plugins; // Common objects
   101   global $db, $session, $paths, $template, $plugins; // Common objects
   234   global $lang;
   102   global $lang;
   235   if ( $session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN )
   103   if ( $session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN )
   388     if ( in_array($_POST['gravatar_rating'], array('g', 'pg', 'r', 'x')) )
   256     if ( in_array($_POST['gravatar_rating'], array('g', 'pg', 'r', 'x')) )
   389     {
   257     {
   390       setConfig('gravatar_rating', $_POST['gravatar_rating']);
   258       setConfig('gravatar_rating', $_POST['gravatar_rating']);
   391     }
   259     }
   392     
   260     
   393     if ( is_dir(ENANO_ROOT . '/' . $_POST['avatar_directory']) )
   261     setConfig('avatar_directory', 'files/avatars');
   394     {
       
   395       if ( preg_match('/^[A-z0-9_-]+(?:\/(?:[A-z0-9_-]+))*\/?$/', $_POST['avatar_directory']) )
       
   396       {
       
   397         setConfig('avatar_directory', $_POST['avatar_directory']);
       
   398       }
       
   399       else
       
   400       {
       
   401         echo '<div class="error-box">' . $lang->get('acpgc_err_avatar_dir_invalid') . '</div>';
       
   402       }
       
   403     }
       
   404     else
       
   405     {
       
   406       echo '<div class="error-box">' . $lang->get('acpgc_err_avatar_dir_not_exist') . '</div>';
       
   407     }
       
   408     
   262     
   409     setConfig('userpage_grant_acl', ( isset($_POST['userpage_grant_acl']) ? '1' : '0' ));
   263     setConfig('userpage_grant_acl', ( isset($_POST['userpage_grant_acl']) ? '1' : '0' ));
   410     
   264     
   411     // Allow plugins to save their changes
   265     // Allow plugins to save their changes
   412     $code = $plugins->setHook('acp_general_save');
   266     $code = $plugins->setHook('acp_general_save');
  1023             
   877             
  1024             <br />
   878             <br />
  1025             
   879             
  1026             <?php endforeach; ?>
   880             <?php endforeach; ?>
  1027           </fieldset>
   881           </fieldset>
  1028         </td>
       
  1029       </tr>
       
  1030       
       
  1031       <tr>
       
  1032         <td class="row2">
       
  1033           <?php echo $lang->get('acpgc_field_avatar_directory'); ?><br />
       
  1034           <small><?php echo $lang->get('acpgc_field_avatar_directory_hint'); ?></small>
       
  1035         </td>
       
  1036         <td class="row2">
       
  1037           <input type="text" name="avatar_directory" size="30" <?php if ( $x = getConfig('avatar_directory') ) echo "value=\"$x\" "; else echo "value=\"files/avatars\" "; ?>/>
       
  1038         </td>
   882         </td>
  1039       </tr>
   883       </tr>
  1040       
   884       
  1041     <!-- Misc. options -->
   885     <!-- Misc. options -->
  1042     
   886