login_auth.php
来自「sabreipb 2.1.6 utf-8中文版本!」· PHP 代码 · 共 430 行
PHP
430 行
<?php/*+--------------------------------------------------------------------------| Invision Power Board v2.1.5| =============================================| by Matthew Mecham| (c) 2001 - 2005 Invision Power Services, Inc.| | =============================================| Web: | Time: Wed, 01 Mar 2006 19:11:27 GMT| Release: | Licence Info: +---------------------------------------------------------------------------| > $Date: 2005-10-28 15:18:16 +0100 (Fri, 28 Oct 2005) $| > $Revision: 67 $| > $Author: bfarber $+---------------------------------------------------------------------------|| > Components Functions| > Module written by Matt Mecham| > Date started: 12th April 2005 (13:09)+--------------------------------------------------------------------------*/if ( ! defined( 'IN_ACP' ) ){ print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded 'admin.php'."; exit();}class ad_login_auth{ # Globals var $ipsclass; var $perm_main = 'tools'; var $perm_child = 'loginauth'; /*-------------------------------------------------------------------------*/ // Main handler /*-------------------------------------------------------------------------*/ function auto_run() { $this->html = $this->ipsclass->acp_load_template('cp_skin_tools'); switch($this->ipsclass->input['code']) { case 'manage': $this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':' ); $this->login_list(); break; case 'login_add': $this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':add' ); $this->login_form('add'); break; case 'login_add_do': $this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':add' ); $this->login_save('add'); break; case 'login_edit_details': $this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':edit' ); $this->login_form('edit'); break; case 'login_edit_do': $this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':edit' ); $this->login_save('edit'); break; case 'login_diagnostics': $this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':diagnostics' ); $this->login_diagnostics(); break; case 'components_export': $this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':export' ); $this->components_export('single'); break; case 'component_import': $this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':import' ); $this->components_import(); break; case 'component_move': $this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':edit' ); $this->components_move(); break; default: $this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':' ); $this->login_list(); break; } } /*-------------------------------------------------------------------------*/ // Components Rebuild Cache /*-------------------------------------------------------------------------*/ function components_rebuildcache() { $this->ipsclass->cache['components'] = array(); $this->ipsclass->DB->simple_construct( array( 'select' => 'com_id,com_enabled,com_section,com_filename,com_url_uri,com_url_title,com_position', 'from' => 'components', 'order' => 'com_position ASC' ) ); $this->ipsclass->DB->simple_exec(); while ( $r = $this->ipsclass->DB->fetch_row() ) { $this->ipsclass->cache['components'][] = $r; } $this->ipsclass->update_cache( array( 'name' => 'components', 'array' => 1, 'deletefirst' => 1 ) ); } /*-------------------------------------------------------------------------*/ // Components Import /*-------------------------------------------------------------------------*/ function components_import() { //----------------------------------------- // INIT //----------------------------------------- $updated = 0; $inserted = 0; $cur_components = array(); if ( $_FILES['FILE_UPLOAD']['name'] == "" or ! $_FILES['FILE_UPLOAD']['name'] or ($_FILES['FILE_UPLOAD']['name'] == "none") ) { //----------------------------------------- // check and load from server //----------------------------------------- if ( ! $this->ipsclass->input['file_location'] ) { $this->ipsclass->main_msg = "No upload file was found and no filename was specified."; $this->components_list(); return; } if ( ! file_exists( ROOT_PATH . $this->ipsclass->input['file_location'] ) ) { $this->ipsclass->main_msg = "Could not find the file to open at: " . ROOT_PATH . $this->ipsclass->input['file_location']; $this->components_list(); return; } if ( preg_match( "#\.gz$#", $this->ipsclass->input['file_location'] ) ) { if ( $FH = @gzopen( ROOT_PATH.$this->ipsclass->input['file_location'], 'rb' ) ) { while ( ! @gzeof( $FH ) ) { $content .= @gzread( $FH, 1024 ); } @gzclose( $FH ); } } else { if ( $FH = @fopen( ROOT_PATH.$this->ipsclass->input['file_location'], 'rb' ) ) { $content = @fread( $FH, filesize(ROOT_PATH.$this->ipsclass->input['lang_location']) ); @fclose( $FH ); } } } else { //----------------------------------------- // Get uploaded schtuff //----------------------------------------- $tmp_name = $_FILES['FILE_UPLOAD']['name']; $tmp_name = preg_replace( "#\.gz$#", "", $tmp_name ); $content = $this->ipsclass->admin->import_xml( $tmp_name ); } //----------------------------------------- // Get current components. //----------------------------------------- $this->ipsclass->DB->simple_construct( array( 'select' => 'com_id, com_section', 'from' => 'components', 'order' => 'com_id' ) ); $this->ipsclass->DB->simple_exec(); while ( $r = $this->ipsclass->DB->fetch_row() ) { $cur_components[ $r['com_section'] ] = $r['com_id']; } //----------------------------------------- // Get xml mah-do-dah //----------------------------------------- require( KERNEL_PATH.'class_xml.php' ); $xml = new class_xml(); //----------------------------------------- // Unpack the datafile //----------------------------------------- $xml->xml_parse_document( $content ); //----------------------------------------- // pArse //----------------------------------------- $fields = array( 'com_title' , 'com_description', 'com_author' , 'com_url', 'com_version', 'com_menu_data', 'com_enabled' , 'com_safemode' , 'com_section', 'com_filename' ); if ( ! is_array( $xml->xml_array['componentexport']['componentgroup']['component'][0] ) ) { //----------------------------------------- // Ensure [0] is populated //----------------------------------------- $tmp = $xml->xml_array['componentexport']['componentgroup']['component']; unset($xml->xml_array['componentexport']['componentgroup']['component']); $xml->xml_array['componentexport']['componentgroup']['component'][0] = $tmp; } foreach( $xml->xml_array['componentexport']['componentgroup']['component'] as $id => $entry ) { $newrow = array(); foreach( $fields as $f ) { $newrow[$f] = $entry[ $f ]['VALUE']; } $this->ipsclass->DB->force_data_type = array( 'com_version' => 'string' ); if ( $cur_components[ $entry['com_section']['VALUE'] ] ) { //----------------------------------------- // Update //----------------------------------------- $this->ipsclass->DB->do_update( 'components', $newrow, 'com_id='.$cur_components[ $entry['com_section']['VALUE'] ] ); $updated++; } else { //----------------------------------------- // INSERT //----------------------------------------- $newrow['com_date_added'] = time(); $this->ipsclass->DB->do_insert( 'components', $newrow ); $inserted++; } } //----------------------------------------- // Done... //----------------------------------------- $this->components_rebuildcache(); $this->ipsclass->main_msg = "$updated components updated $inserted components inserted"; $this->components_list(); } /*-------------------------------------------------------------------------*/ // Components Export /*-------------------------------------------------------------------------*/ function components_export($type='single') { //-------------------------------------------- // INIT //-------------------------------------------- $com_id = intval($this->ipsclass->input['com_id']); $rows = array(); //-------------------------------------------- // Checks... //-------------------------------------------- if ( $type == 'single' ) { if ( ! $com_id ) { $this->ipsclass->main_msg = "No ID was passed, please try again"; $this->components_list(); return; } //-------------------------------------------- // Get DB row(s) //-------------------------------------------- $this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'components', 'where' => 'com_id='.$com_id ) ); $this->ipsclass->DB->simple_exec(); while ( $r = $this->ipsclass->DB->fetch_row() ) { $rows[] = $r; } } else { //-------------------------------------------- // Get DB row(s) //-------------------------------------------- $this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'components' ) ); $this->ipsclass->DB->simple_exec(); while ( $r = $this->ipsclass->DB->fetch_row() ) { $rows[] = $r; } } //------------------------------- // Get XML class //------------------------------- require_once( KERNEL_PATH.'class_xml.php' ); $xml = new class_xml(); $xml->xml_set_root( 'componentexport', array( 'exported' => time() ) ); //------------------------------- // Add component //------------------------------- $xml->xml_add_group( 'componentgroup' ); $entry = array(); foreach( $rows as $idx => $r ) { $content = array(); foreach( $r as $k => $v ) { $content[] = $xml->xml_build_simple_tag( $k, $v ); } $entry[] = $xml->xml_build_entry( 'component', $content ); } $xml->xml_add_entry_to_group( 'componentgroup', $entry ); $xml->xml_format_document(); $doc = $xml->xml_document; //------------------------------- // Print to browser //------------------------------- $this->ipsclass->admin->show_download( $doc, 'ipd_components.xml', '', 0 ); } /*-------------------------------------------------------------------------*/ // Log in: Diagnostics /*-------------------------------------------------------------------------*/ function login_diagnostics() { //----------------------------------------- // Init Vars //----------------------------------------- $login_id = intval($this->ipsclass->input['login_id']); //----------------------------------------- // Check (please?) //----------------------------------------- $login = $this->ipsclass->DB->simple_exec_query( array( 'select' => '*', 'from' => 'login_methods', 'where' => 'login_id='.$login_id ) ); if ( ! $login['login_id'] ) { $this->ipsclass->main_msg = "No ID was passed, please try again."; $this->login_list(); return; } //----------------------------------------- // Generate file //----------------------------------------- $mypath = ROOT_PATH.'sources/loginauth/'.$login['login_folder_name']; //----------------------------------------- // Generate General Info //----------------------------------------- $login['_enabled_img'] = $login['login_enabled'] ? 'aff_tick.png' : 'aff_cross.png'; $login['_installed_img'] = $login['login_installed'] ? 'aff_tick.png' : 'aff_cross.png'; $login['_has_settings'] = $login['login_settings'] ? 'aff_tick.png' : 'aff_cross.png'; //----------------------------------------- // File based info //----------------------------------------- $login['_file_auth_exists'] = @file_exists( $mypath.'/auth.php' ) ? 'aff_tick.png' : 'aff_cross.png'; $login['_file_conf_exists'] = @file_exists( $mypath.'/conf.php' ) ? 'aff_tick.png' : 'aff_cross.png'; $login['_file_acp_exists'] = @file_exists( $mypath.'/acp.php' ) ? 'aff_tick.png' : 'aff_cross.png'; $login['_file_conf_write'] = @file_exists( $mypath.'/conf.php' ) ? 'aff_tick.png' : 'aff_cross.png'; $this->ipsclass->html .= $this->html->login_diagnostics( $login ); $this->ipsclass->html_help_title = "鐧诲綍鏂瑰紡绠$悊鍣
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?