Commit 126da44c authored by liyuanhong's avatar liyuanhong

Initial commit

parents
Pipeline #321 canceled with stages

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

#-------------------------
# Operating Specific Junk Files
#-------------------------
# OS X
.DS_Store
.AppleDouble
.LSOverride
# OS X Thumbnails
._*
# Windows image file caches
Thumbs.db
ehthumbs.db
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msm
*.msp
# Windows shortcuts
*.lnk
# Linux
*~
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
#-------------------------
# Environment Files
#-------------------------
# These should never be under version control,
# as it poses a security risk.
.env
.vagrant
Vagrantfile
#-------------------------
# Temporary Files
#-------------------------
writable/cache/*
!writable/cache/index.html
writable/logs/*
!writable/logs/index.html
writable/session/*
!writable/session/index.html
writable/uploads/*
!writable/uploads/index.html
writable/debugbar/*
php_errors.log
#-------------------------
# User Guide Temp Files
#-------------------------
user_guide_src/build/*
user_guide_src/cilexer/build/*
user_guide_src/cilexer/dist/*
user_guide_src/cilexer/pycilexer.egg-info/*
#-------------------------
# Test Files
#-------------------------
tests/coverage*
# Don't save phpunit under version control.
phpunit
#-------------------------
# Composer
#-------------------------
vendor/
composer.lock
#-------------------------
# IDE / Development Files
#-------------------------
# Modules Testing
_modules/*
# phpenv local config
.php-version
# Jetbrains editors (PHPStorm, etc)
.idea/
*.iml
# Netbeans
nbproject/
build/
nbbuild/
dist/
nbdist/
nbactions.xml
nb-configuration.xml
.nb-gradle/
# Sublime Text
*.tmlanguage.cache
*.tmPreferences.cache
*.stTheme.cache
*.sublime-workspace
*.sublime-project
.phpintel
/api/
# Visual Studio Code
.vscode/
/results/
/phpunit*.xml
/.phpunit.*.cache
/public/pics/
# CodeIgniter 4 Framework
## What is CodeIgniter?
CodeIgniter is a PHP full-stack web framework that is light, fast, flexible, and secure.
More information can be found at the [official site](http://codeigniter.com).
This repository holds the distributable version of the framework,
including the user guide. It has been built from the
[development repository](https://github.com/codeigniter4/CodeIgniter4).
More information about the plans for version 4 can be found in [the announcement](http://forum.codeigniter.com/thread-62615.html) on the forums.
The user guide corresponding to this version of the framework can be found
[here](https://codeigniter4.github.io/userguide/).
## Important Change with index.php
`index.php` is no longer in the root of the project! It has been moved inside the *public* folder,
for better security and separation of components.
This means that you should configure your web server to "point" to your project's *public* folder, and
not to the project root. A better practice would be to configure a virtual host to point there. A poor practice would be to point your web server to the project root and expect to enter *public/...*, as the rest of your logic and the
framework are exposed.
**Please** read the user guide for a better explanation of how CI4 works!
The user guide updating and deployment is a bit awkward at the moment, but we are working on it!
## Repository Management
We use Github issues, in our main repository, to track **BUGS** and to track approved **DEVELOPMENT** work packages.
We use our [forum](http://forum.codeigniter.com) to provide SUPPORT and to discuss
FEATURE REQUESTS.
This repository is a "distribution" one, built by our release preparation script.
Problems with it can be raised on our forum, or as issues in the main repository.
## Contributing
We welcome contributions from the community.
Please read the [*Contributing to CodeIgniter*](https://github.com/codeigniter4/CodeIgniter4/blob/develop/contributing.md) section in the development repository.
## Server Requirements
PHP version 7.2 or higher is required, with the following extensions installed:
- [intl](http://php.net/manual/en/intl.requirements.php)
- [libcurl](http://php.net/manual/en/curl.requirements.php) if you plan to use the HTTP\CURLRequest library
Additionally, make sure that the following extensions are enabled in your PHP:
- json (enabled by default - don't turn it off)
- [mbstring](http://php.net/manual/en/mbstring.installation.php)
- [mysqlnd](http://php.net/manual/en/mysqlnd.install.php)
- xml (enabled by default - don't turn it off)
<IfModule authz_core_module>
Require all denied
</IfModule>
<IfModule !authz_core_module>
Deny from all
</IfModule>
<?php
/**
* The goal of this file is to allow developers a location
* where they can overwrite core procedural functions and
* replace them with their own. This file is loaded during
* the bootstrap process and is called during the frameworks
* execution.
*
* This can be looked at as a `master helper` file that is
* loaded early on, and may also contain additional functions
* that you'd like to use throughout your entire application
*
* @link: https://codeigniter4.github.io/CodeIgniter4/
*/
<?php namespace Config;
use CodeIgniter\Config\BaseConfig;
class App extends BaseConfig
{
/*
|--------------------------------------------------------------------------
| Base Site URL
|--------------------------------------------------------------------------
|
| URL to your CodeIgniter root. Typically this will be your base URL,
| WITH a trailing slash:
|
| http://example.com/
|
| If this is not set then CodeIgniter will try guess the protocol, domain
| and path to your installation. However, you should always configure this
| explicitly and never rely on auto-guessing, especially in production
| environments.
|
*/
// public $baseURL = 'http://localhost:8080/';
public $baseURL = 'http://10.16.4.205:8080/';
// public $baseURL = 'http://localhost/ci4/public/';
/*
|--------------------------------------------------------------------------
| Index File
|--------------------------------------------------------------------------
|
| Typically this will be your index.php file, unless you've renamed it to
| something else. If you are using mod_rewrite to remove the page set this
| variable so that it is blank.
|
*/
public $indexPage = 'index.php';
/*
|--------------------------------------------------------------------------
| URI PROTOCOL
|--------------------------------------------------------------------------
|
| This item determines which getServer global should be used to retrieve the
| URI string. The default setting of 'REQUEST_URI' works for most servers.
| If your links do not seem to work, try one of the other delicious flavors:
|
| 'REQUEST_URI' Uses $_SERVER['REQUEST_URI']
| 'QUERY_STRING' Uses $_SERVER['QUERY_STRING']
| 'PATH_INFO' Uses $_SERVER['PATH_INFO']
|
| WARNING: If you set this to 'PATH_INFO', URIs will always be URL-decoded!
*/
public $uriProtocol = 'REQUEST_URI';
/*
|--------------------------------------------------------------------------
| Default Locale
|--------------------------------------------------------------------------
|
| The Locale roughly represents the language and location that your visitor
| is viewing the site from. It affects the language strings and other
| strings (like currency markers, numbers, etc), that your program
| should run under for this request.
|
*/
public $defaultLocale = 'en';
/*
|--------------------------------------------------------------------------
| Negotiate Locale
|--------------------------------------------------------------------------
|
| If true, the current Request object will automatically determine the
| language to use based on the value of the Accept-Language header.
|
| If false, no automatic detection will be performed.
|
*/
public $negotiateLocale = false;
/*
|--------------------------------------------------------------------------
| Supported Locales
|--------------------------------------------------------------------------
|
| If $negotiateLocale is true, this array lists the locales supported
| by the application in descending order of priority. If no match is
| found, the first locale will be used.
|
*/
public $supportedLocales = ['en'];
/*
|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| The default timezone that will be used in your application to display
| dates with the date helper, and can be retrieved through app_timezone()
|
*/
// public $appTimezone = 'America/Chicago';
public $appTimezone = 'Asia/Shanghai';
/*
|--------------------------------------------------------------------------
| Default Character Set
|--------------------------------------------------------------------------
|
| This determines which character set is used by default in various methods
| that require a character set to be provided.
|
| See http://php.net/htmlspecialchars for a list of supported charsets.
|
*/
public $charset = 'UTF-8';
/*
|--------------------------------------------------------------------------
| URI PROTOCOL
|--------------------------------------------------------------------------
|
| If true, this will force every request made to this application to be
| made via a secure connection (HTTPS). If the incoming request is not
| secure, the user will be redirected to a secure version of the page
| and the HTTP Strict Transport Security header will be set.
*/
public $forceGlobalSecureRequests = false;
/*
|--------------------------------------------------------------------------
| Session Variables
|--------------------------------------------------------------------------
|
| 'sessionDriver'
|
| The storage driver to use: files, database, redis, memcached
| - CodeIgniter\Session\Handlers\FileHandler
| - CodeIgniter\Session\Handlers\DatabaseHandler
| - CodeIgniter\Session\Handlers\MemcachedHandler
| - CodeIgniter\Session\Handlers\RedisHandler
|
| 'sessionCookieName'
|
| The session cookie name, must contain only [0-9a-z_-] characters
|
| 'sessionExpiration'
|
| The number of SECONDS you want the session to last.
| Setting to 0 (zero) means expire when the browser is closed.
|
| 'sessionSavePath'
|
| The location to save sessions to, driver dependent.
|
| For the 'files' driver, it's a path to a writable directory.
| WARNING: Only absolute paths are supported!
|
| For the 'database' driver, it's a table name.
| Please read up the manual for the format with other session drivers.
|
| IMPORTANT: You are REQUIRED to set a valid save path!
|
| 'sessionMatchIP'
|
| Whether to match the user's IP address when reading the session data.
|
| WARNING: If you're using the database driver, don't forget to update
| your session table's PRIMARY KEY when changing this setting.
|
| 'sessionTimeToUpdate'
|
| How many seconds between CI regenerating the session ID.
|
| 'sessionRegenerateDestroy'
|
| Whether to destroy session data associated with the old session ID
| when auto-regenerating the session ID. When set to FALSE, the data
| will be later deleted by the garbage collector.
|
| Other session cookie settings are shared with the rest of the application,
| except for 'cookie_prefix' and 'cookie_httponly', which are ignored here.
|
*/
public $sessionDriver = 'CodeIgniter\Session\Handlers\FileHandler';
public $sessionCookieName = 'ci_session';
public $sessionExpiration = 7200;
public $sessionSavePath = WRITEPATH . 'session';
public $sessionMatchIP = false;
public $sessionTimeToUpdate = 300;
public $sessionRegenerateDestroy = false;
/*
|--------------------------------------------------------------------------
| Cookie Related Variables
|--------------------------------------------------------------------------
|
| 'cookiePrefix' = Set a cookie name prefix if you need to avoid collisions
| 'cookieDomain' = Set to .your-domain.com for site-wide cookies
| 'cookiePath' = Typically will be a forward slash
| 'cookieSecure' = Cookie will only be set if a secure HTTPS connection exists.
| 'cookieHTTPOnly' = Cookie will only be accessible via HTTP(S) (no javascript)
|
| Note: These settings (with the exception of 'cookie_prefix' and
| 'cookie_httponly') will also affect sessions.
|
*/
public $cookiePrefix = '';
public $cookieDomain = '';
public $cookiePath = '/';
public $cookieSecure = false;
public $cookieHTTPOnly = false;
/*
|--------------------------------------------------------------------------
| Reverse Proxy IPs
|--------------------------------------------------------------------------
|
| If your server is behind a reverse proxy, you must whitelist the proxy
| IP addresses from which CodeIgniter should trust headers such as
| HTTP_X_FORWARDED_FOR and HTTP_CLIENT_IP in order to properly identify
| the visitor's IP address.
|
| You can use both an array or a comma-separated list of proxy addresses,
| as well as specifying whole subnets. Here are a few examples:
|
| Comma-separated: '10.0.1.200,192.168.5.0/24'
| Array: array('10.0.1.200', '192.168.5.0/24')
*/
public $proxyIPs = '';
/*
|--------------------------------------------------------------------------
| Cross Site Request Forgery
|--------------------------------------------------------------------------
| Enables a CSRF cookie token to be set. When set to TRUE, token will be
| checked on a submitted form. If you are accepting user data, it is strongly
| recommended CSRF protection be enabled.
|
| CSRFTokenName = The token name
| CSRFHeaderName = The header name
| CSRFCookieName = The cookie name
| CSRFExpire = The number in seconds the token should expire.
| CSRFRegenerate = Regenerate token on every submission
| CSRFRedirect = Redirect to previous page with error on failure
*/
public $CSRFTokenName = 'csrf_test_name';
public $CSRFHeaderName = 'X-CSRF-TOKEN';
public $CSRFCookieName = 'csrf_cookie_name';
public $CSRFExpire = 7200;
public $CSRFRegenerate = true;
public $CSRFRedirect = true;
/*
|--------------------------------------------------------------------------
| Content Security Policy
|--------------------------------------------------------------------------
| Enables the Response's Content Secure Policy to restrict the sources that
| can be used for images, scripts, CSS files, audio, video, etc. If enabled,
| the Response object will populate default values for the policy from the
| ContentSecurityPolicy.php file. Controllers can always add to those
| restrictions at run time.
|
| For a better understanding of CSP, see these documents:
| - http://www.html5rocks.com/en/tutorials/security/content-security-policy/
| - http://www.w3.org/TR/CSP/
*/
public $CSPEnabled = false;
}
<?php namespace Config;
require_once SYSTEMPATH . 'Config/AutoloadConfig.php';
/**
* -------------------------------------------------------------------
* AUTO-LOADER
* -------------------------------------------------------------------
* This file defines the namespaces and class maps so the Autoloader
* can find the files as needed.
*/
class Autoload extends \CodeIgniter\Config\AutoloadConfig
{
public $psr4 = [];
public $classmap = [];
//--------------------------------------------------------------------
/**
* Collects the application-specific autoload settings and merges
* them with the framework's required settings.
*
* NOTE: If you use an identical key in $psr4 or $classmap, then
* the values in this file will overwrite the framework's values.
*/
public function __construct()
{
parent::__construct();
/**
* -------------------------------------------------------------------
* Namespaces
* -------------------------------------------------------------------
* This maps the locations of any namespaces in your application
* to their location on the file system. These are used by the
* Autoloader to locate files the first time they have been instantiated.
*
* The '/app' and '/system' directories are already mapped for
* you. You may change the name of the 'App' namespace if you wish,
* but this should be done prior to creating any namespaced classes,
* else you will need to modify all of those classes for this to work.
*
* DO NOT change the name of the CodeIgniter namespace or your application
* WILL break. *
* Prototype:
*
* $Config['psr4'] = [
* 'CodeIgniter' => SYSPATH
* `];
*/
$psr4 = [
'App' => APPPATH, // To ensure filters, etc still found,
APP_NAMESPACE => APPPATH, // For custom namespace
'Config' => APPPATH . 'Config',
];
/**
* -------------------------------------------------------------------
* Class Map
* -------------------------------------------------------------------
* The class map provides a map of class names and their exact
* location on the drive. Classes loaded in this manner will have
* slightly faster performance because they will not have to be
* searched for within one or more directories as they would if they
* were being autoloaded through a namespace.
*
* Prototype:
*
* $Config['classmap'] = [
* 'MyClass' => '/path/to/class/file.php'
* ];
*/
$classmap = [];
//--------------------------------------------------------------------
// Do Not Edit Below This Line
//--------------------------------------------------------------------
$this->psr4 = array_merge($this->psr4, $psr4);
$this->classmap = array_merge($this->classmap, $classmap);
unset($psr4, $classmap);
}
//--------------------------------------------------------------------
}
<?php
/*
|--------------------------------------------------------------------------
| ERROR DISPLAY
|--------------------------------------------------------------------------
| In development, we want to show as many errors as possible to help
| make sure they don't make it to production. And save us hours of
| painful debugging.
*/
error_reporting(-1);
ini_set('display_errors', '1');
/*
|--------------------------------------------------------------------------
| DEBUG BACKTRACES
|--------------------------------------------------------------------------
| If true, this constant will tell the error screens to display debug
| backtraces along with the other error information. If you would
| prefer to not see this, set this value to false.
*/
defined('SHOW_DEBUG_BACKTRACE') || define('SHOW_DEBUG_BACKTRACE', true);
/*
|--------------------------------------------------------------------------
| DEBUG MODE
|--------------------------------------------------------------------------
| Debug mode is an experimental flag that can allow changes throughout
| the system. This will control whether Kint is loaded, and a few other
| items. It can always be used within your own application too.
*/
defined('CI_DEBUG') || define('CI_DEBUG', 1);
<?php
/*
|--------------------------------------------------------------------------
| ERROR DISPLAY
|--------------------------------------------------------------------------
| Don't show ANY in production environments. Instead, let the system catch
| it and display a generic error message.
*/
ini_set('display_errors', '0');
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
/*
|--------------------------------------------------------------------------
| DEBUG MODE
|--------------------------------------------------------------------------
| Debug mode is an experimental flag that can allow changes throughout
| the system. It's not widely used currently, and may not survive
| release of the framework.
*/
defined('CI_DEBUG') || define('CI_DEBUG', 0);
<?php
/*
|--------------------------------------------------------------------------
| ERROR DISPLAY
|--------------------------------------------------------------------------
| In development, we want to show as many errors as possible to help
| make sure they don't make it to production. And save us hours of
| painful debugging.
*/
error_reporting(-1);
ini_set('display_errors', '1');
/*
|--------------------------------------------------------------------------
| DEBUG BACKTRACES
|--------------------------------------------------------------------------
| If true, this constant will tell the error screens to display debug
| backtraces along with the other error information. If you would
| prefer to not see this, set this value to false.
*/
defined('SHOW_DEBUG_BACKTRACE') || define('SHOW_DEBUG_BACKTRACE', true);
/*
|--------------------------------------------------------------------------
| DEBUG MODE
|--------------------------------------------------------------------------
| Debug mode is an experimental flag that can allow changes throughout
| the system. It's not widely used currently, and may not survive
| release of the framework.
*/
defined('CI_DEBUG') || define('CI_DEBUG', 1);
<?php namespace Config;
use CodeIgniter\Config\BaseConfig;
class Cache extends BaseConfig
{
/*
|--------------------------------------------------------------------------
| Primary Handler
|--------------------------------------------------------------------------
|
| The name of the preferred handler that should be used. If for some reason
| it is not available, the $backupHandler will be used in its place.
|
*/
public $handler = 'file';
/*
|--------------------------------------------------------------------------
| Backup Handler
|--------------------------------------------------------------------------
|
| The name of the handler that will be used in case the first one is
| unreachable. Often, 'file' is used here since the filesystem is
| always available, though that's not always practical for the app.
|
*/
public $backupHandler = 'dummy';
/*
|--------------------------------------------------------------------------
| Cache Directory Path
|--------------------------------------------------------------------------
|
| The path to where cache files should be stored, if using a file-based
| system.
|
*/
public $storePath = WRITEPATH . 'cache/';
/*
|--------------------------------------------------------------------------
| Cache Include Query String
|--------------------------------------------------------------------------
|
| Whether to take the URL query string into consideration when generating
| output cache files. Valid options are:
|
| false = Disabled
| true = Enabled, take all query parameters into account.
| Please be aware that this may result in numerous cache
| files generated for the same page over and over again.
| array('q') = Enabled, but only take into account the specified list
| of query parameters.
|
*/
public $cacheQueryString = false;
/*
|--------------------------------------------------------------------------
| Key Prefix
|--------------------------------------------------------------------------
|
| This string is added to all cache item names to help avoid collisions
| if you run multiple applications with the same cache engine.
|
*/
public $prefix = '';
/*
| -------------------------------------------------------------------------
| Memcached settings
| -------------------------------------------------------------------------
| Your Memcached servers can be specified below, if you are using
| the Memcached drivers.
|
| See: https://codeigniter.com/user_guide/libraries/caching.html#memcached
|
*/
public $memcached = [
'host' => '127.0.0.1',
'port' => 11211,
'weight' => 1,
'raw' => false,
];
/*
| -------------------------------------------------------------------------
| Redis settings
| -------------------------------------------------------------------------
| Your Redis server can be specified below, if you are using
| the Redis or Predis drivers.
|
*/
public $redis = [
'host' => '127.0.0.1',
'password' => null,
'port' => 6379,
'timeout' => 0,
'database' => 0,
];
/*
|--------------------------------------------------------------------------
| Available Cache Handlers
|--------------------------------------------------------------------------
|
| This is an array of cache engine alias' and class names. Only engines
| that are listed here are allowed to be used.
|
*/
public $validHandlers = [
'dummy' => \CodeIgniter\Cache\Handlers\DummyHandler::class,
'file' => \CodeIgniter\Cache\Handlers\FileHandler::class,
'memcached' => \CodeIgniter\Cache\Handlers\MemcachedHandler::class,
'predis' => \CodeIgniter\Cache\Handlers\PredisHandler::class,
'redis' => \CodeIgniter\Cache\Handlers\RedisHandler::class,
'wincache' => \CodeIgniter\Cache\Handlers\WincacheHandler::class,
];
}
<?php
//--------------------------------------------------------------------
// App Namespace
//--------------------------------------------------------------------
// This defines the default Namespace that is used throughout
// CodeIgniter to refer to the Application directory. Change
// this constant to change the namespace that all application
// classes should use.
//
// NOTE: changing this will require manually modifying the
// existing namespaces of App\* namespaced-classes.
//
defined('APP_NAMESPACE') || define('APP_NAMESPACE', 'App');
/*
|--------------------------------------------------------------------------
| Composer Path
|--------------------------------------------------------------------------
|
| The path that Composer's autoload file is expected to live. By default,
| the vendor folder is in the Root directory, but you can customize that here.
*/
defined('COMPOSER_PATH') || define('COMPOSER_PATH', ROOTPATH . 'vendor/autoload.php');
/*
|--------------------------------------------------------------------------
| Timing Constants
|--------------------------------------------------------------------------
|
| Provide simple ways to work with the myriad of PHP functions that
| require information to be in seconds.
*/
defined('SECOND') || define('SECOND', 1);
defined('MINUTE') || define('MINUTE', 60);
defined('HOUR') || define('HOUR', 3600);
defined('DAY') || define('DAY', 86400);
defined('WEEK') || define('WEEK', 604800);
defined('MONTH') || define('MONTH', 2592000);
defined('YEAR') || define('YEAR', 31536000);
defined('DECADE') || define('DECADE', 315360000);
/*
|--------------------------------------------------------------------------
| Exit Status Codes
|--------------------------------------------------------------------------
|
| Used to indicate the conditions under which the script is exit()ing.
| While there is no universal standard for error codes, there are some
| broad conventions. Three such conventions are mentioned below, for
| those who wish to make use of them. The CodeIgniter defaults were
| chosen for the least overlap with these conventions, while still
| leaving room for others to be defined in future versions and user
| applications.
|
| The three main conventions used for determining exit status codes
| are as follows:
|
| Standard C/C++ Library (stdlibc):
| http://www.gnu.org/software/libc/manual/html_node/Exit-Status.html
| (This link also contains other GNU-specific conventions)
| BSD sysexits.h:
| http://www.gsp.com/cgi-bin/man.cgi?section=3&topic=sysexits
| Bash scripting:
| http://tldp.org/LDP/abs/html/exitcodes.html
|
*/
defined('EXIT_SUCCESS') || define('EXIT_SUCCESS', 0); // no errors
defined('EXIT_ERROR') || define('EXIT_ERROR', 1); // generic error
defined('EXIT_CONFIG') || define('EXIT_CONFIG', 3); // configuration error
defined('EXIT_UNKNOWN_FILE') || define('EXIT_UNKNOWN_FILE', 4); // file not found
defined('EXIT_UNKNOWN_CLASS') || define('EXIT_UNKNOWN_CLASS', 5); // unknown class
defined('EXIT_UNKNOWN_METHOD') || define('EXIT_UNKNOWN_METHOD', 6); // unknown class member
defined('EXIT_USER_INPUT') || define('EXIT_USER_INPUT', 7); // invalid user input
defined('EXIT_DATABASE') || define('EXIT_DATABASE', 8); // database error
defined('EXIT__AUTO_MIN') || define('EXIT__AUTO_MIN', 9); // lowest automatically-assigned error code
defined('EXIT__AUTO_MAX') || define('EXIT__AUTO_MAX', 125); // highest automatically-assigned error code
<?php namespace Config;
use CodeIgniter\Config\BaseConfig;
/**
* Class ContentSecurityPolicyConfig
*
* Stores the default settings for the ContentSecurityPolicy, if you
* choose to use it. The values here will be read in and set as defaults
* for the site. If needed, they can be overridden on a page-by-page basis.
*
* Suggested reference for explanations:
* https://www.html5rocks.com/en/tutorials/security/content-security-policy/
*
* @package Config
*/
class ContentSecurityPolicy extends BaseConfig
{
// broadbrush CSP management
public $reportOnly = false; // default CSP report context
public $reportURI = null; // URL to send violation reports to
public $upgradeInsecureRequests = false; // toggle for forcing https
// sources allowed; string or array of strings
// Note: once you set a policy to 'none', it cannot be further restricted
public $defaultSrc = null; // will default to self if not over-ridden
public $scriptSrc = 'self';
public $styleSrc = 'self';
public $imageSrc = 'self';
public $baseURI = null; // will default to self if not over-ridden
public $childSrc = 'self';
public $connectSrc = 'self';
public $fontSrc = null;
public $formAction = 'self';
public $frameAncestors = null;
public $mediaSrc = null;
public $objectSrc = 'self';
public $manifestSrc = null;
// mime types allowed; string or array of strings
public $pluginTypes = null;
// list of actions allowed; string or array of strings
public $sandbox = null;
}
<?php namespace Config;
/**
* Database Configuration
*
* @package Config
*/
class Database extends \CodeIgniter\Database\Config
{
/**
* The directory that holds the Migrations
* and Seeds directories.
*
* @var string
*/
public $filesPath = APPPATH . 'Database/';
/**
* Lets you choose which connection group to
* use if no other is specified.
*
* @var string
*/
public $defaultGroup = 'default';
/**
* The default database connection.
*
* @var array
*/
public $default = [
'DSN' => '',
'hostname' => 'localhost',
'username' => 'lyh',
'password' => 'pass',
'database' => 'sys_man',
'DBDriver' => 'MySQLi',
'DBPrefix' => '',
'pConnect' => false,
'DBDebug' => (ENVIRONMENT !== 'production'),
'cacheOn' => false,
'cacheDir' => '',
'charset' => 'utf8',
'DBCollat' => 'utf8_general_ci',
'swapPre' => '',
'encrypt' => false,
'compress' => false,
'strictOn' => false,
'failover' => [],
'port' => 3306,
];
/**
* This database connection is used when
* running PHPUnit database tests.
*
* @var array
*/
public $tests = [
'DSN' => '',
'hostname' => '127.0.0.1',
'username' => '',
'password' => '',
'database' => ':memory:',
'DBDriver' => 'SQLite3',
'DBPrefix' => 'db_', // Needed to ensure we're working correctly with prefixes live. DO NOT REMOVE FOR CI DEVS
'pConnect' => false,
'DBDebug' => (ENVIRONMENT !== 'production'),
'cacheOn' => false,
'cacheDir' => '',
'charset' => 'utf8',
'DBCollat' => 'utf8_general_ci',
'swapPre' => '',
'encrypt' => false,
'compress' => false,
'strictOn' => false,
'failover' => [],
'port' => 3306,
];
//--------------------------------------------------------------------
public function __construct()
{
parent::__construct();
// Ensure that we always set the database group to 'tests' if
// we are currently running an automated test suite, so that
// we don't overwrite live data on accident.
if (ENVIRONMENT === 'testing')
{
$this->defaultGroup = 'tests';
// Under Travis-CI, we can set an ENV var named 'DB_GROUP'
// so that we can test against multiple databases.
if ($group = getenv('DB'))
{
if (is_file(TESTPATH . 'travis/Database.php'))
{
require TESTPATH . 'travis/Database.php';
if (! empty($dbconfig) && array_key_exists($group, $dbconfig))
{
$this->tests = $dbconfig[$group];
}
}
}
}
}
//--------------------------------------------------------------------
}
<?php namespace Config;
/**
* DocTypes
*
* @package Config
*/
class DocTypes
{
public $list =
[
'xhtml11' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">',
'xhtml1-strict' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">',
'xhtml1-trans' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">',
'xhtml1-frame' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">',
'xhtml-basic11' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd">',
'html5' => '<!DOCTYPE html>',
'html4-strict' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">',
'html4-trans' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">',
'html4-frame' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">',
'mathml1' => '<!DOCTYPE math SYSTEM "http://www.w3.org/Math/DTD/mathml1/mathml.dtd">',
'mathml2' => '<!DOCTYPE math PUBLIC "-//W3C//DTD MathML 2.0//EN" "http://www.w3.org/Math/DTD/mathml2/mathml2.dtd">',
'svg10' => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">',
'svg11' => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">',
'svg11-basic' => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Basic//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-basic.dtd">',
'svg11-tiny' => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">',
'xhtml-math-svg-xh' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">',
'xhtml-math-svg-sh' => '<!DOCTYPE svg:svg PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">',
'xhtml-rdfa-1' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">',
'xhtml-rdfa-2' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.1//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-2.dtd">',
];
}
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
class Email extends BaseConfig
{
/**
* @var string
*/
public $fromEmail;
/**
* @var string
*/
public $fromName;
/**
* @var string
*/
public $recipients;
/**
* The "user agent"
*
* @var string
*/
public $userAgent = 'CodeIgniter';
/**
* The mail sending protocol: mail, sendmail, smtp
*
* @var string
*/
public $protocol = 'mail';
/**
* The server path to Sendmail.
*
* @var string
*/
public $mailPath = '/usr/sbin/sendmail';
/**
* SMTP Server Address
*
* @var string
*/
public $SMTPHost;
/**
* SMTP Username
*
* @var string
*/
public $SMTPUser;
/**
* SMTP Password
*
* @var string
*/
public $SMTPPass;
/**
* SMTP Port
*
* @var integer
*/
public $SMTPPort = 25;
/**
* SMTP Timeout (in seconds)
*
* @var integer
*/
public $SMTPTimeout = 5;
/**
* Enable persistent SMTP connections
*
* @var boolean
*/
public $SMTPKeepAlive = false;
/**
* SMTP Encryption. Either tls or ssl
*
* @var string
*/
public $SMTPCrypto = 'tls';
/**
* Enable word-wrap
*
* @var boolean
*/
public $wordWrap = true;
/**
* Character count to wrap at
*
* @var integer
*/
public $wrapChars = 76;
/**
* Type of mail, either 'text' or 'html'
*
* @var string
*/
public $mailType = 'text';
/**
* Character set (utf-8, iso-8859-1, etc.)
*
* @var string
*/
public $charset = 'UTF-8';
/**
* Whether to validate the email address
*
* @var boolean
*/
public $validate = false;
/**
* Email Priority. 1 = highest. 5 = lowest. 3 = normal
*
* @var integer
*/
public $priority = 3;
/**
* Newline character. (Use “\r\n” to comply with RFC 822)
*
* @var string
*/
public $CRLF = "\r\n";
/**
* Newline character. (Use “\r\n” to comply with RFC 822)
*
* @var string
*/
public $newline = "\r\n";
/**
* Enable BCC Batch Mode.
*
* @var boolean
*/
public $BCCBatchMode = false;
/**
* Number of emails in each BCC batch
*
* @var integer
*/
public $BCCBatchSize = 200;
/**
* Enable notify message from server
*
* @var boolean
*/
public $DSN = false;
}
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
/**
* Encryption configuration.
*
* These are the settings used for encryption, if you don't pass a parameter
* array to the encrypter for creation/initialization.
*/
class Encryption extends BaseConfig
{
/*
|--------------------------------------------------------------------------
| Encryption Key Starter
|--------------------------------------------------------------------------
|
| If you use the Encryption class you must set an encryption key (seed).
| You need to ensure it is long enough for the cipher and mode you plan to use.
| See the user guide for more info.
*/
public $key = '';
/*
|--------------------------------------------------------------------------
| Encryption driver to use
|--------------------------------------------------------------------------
|
| One of the supported drivers, eg 'OpenSSL' or 'Sodium'.
| The default driver, if you don't specify one, is 'OpenSSL'.
*/
public $driver = 'OpenSSL';
}
<?php namespace Config;
use CodeIgniter\Events\Events;
/*
* --------------------------------------------------------------------
* Application Events
* --------------------------------------------------------------------
* Events allow you to tap into the execution of the program without
* modifying or extending core files. This file provides a central
* location to define your events, though they can always be added
* at run-time, also, if needed.
*
* You create code that can execute by subscribing to events with
* the 'on()' method. This accepts any form of callable, including
* Closures, that will be executed when the event is triggered.
*
* Example:
* Events::on('create', [$myInstance, 'myMethod']);
*/
Events::on('pre_system', function () {
if (ENVIRONMENT !== 'testing')
{
while (\ob_get_level() > 0)
{
\ob_end_flush();
}
\ob_start(function ($buffer) {
return $buffer;
});
}
/*
* --------------------------------------------------------------------
* Debug Toolbar Listeners.
* --------------------------------------------------------------------
* If you delete, they will no longer be collected.
*/
if (ENVIRONMENT !== 'production')
{
Events::on('DBQuery', 'CodeIgniter\Debug\Toolbar\Collectors\Database::collect');
Services::toolbar()->respond();
}
});
<?php namespace Config;
/**
* Setup how the exception handler works.
*
* @package Config
*/
class Exceptions
{
/*
|--------------------------------------------------------------------------
| LOG EXCEPTIONS?
|--------------------------------------------------------------------------
| If true, then exceptions will be logged
| through Services::Log.
|
| Default: true
*/
public $log = true;
/*
|--------------------------------------------------------------------------
| DO NOT LOG STATUS CODES
|--------------------------------------------------------------------------
| Any status codes here will NOT be logged if logging is turned on.
| By default, only 404 (Page Not Found) exceptions are ignored.
*/
public $ignoreCodes = [ 404 ];
/*
|--------------------------------------------------------------------------
| Error Views Path
|--------------------------------------------------------------------------
| This is the path to the directory that contains the 'cli' and 'html'
| directories that hold the views used to generate errors.
|
| Default: APPPATH.'Views/errors'
*/
public $errorViewPath = APPPATH . 'Views/errors';
}
<?php namespace Config;
use CodeIgniter\Config\BaseConfig;
class Filters extends BaseConfig
{
// Makes reading things below nicer,
// and simpler to change out script that's used.
public $aliases = [
'csrf' => \CodeIgniter\Filters\CSRF::class,
'toolbar' => \CodeIgniter\Filters\DebugToolbar::class,
'honeypot' => \CodeIgniter\Filters\Honeypot::class,
'login_filter' => \App\Filters\LoginFilter::class,
'login_page_filter' => \App\Filters\LoginPageFilter::class
];
// Always applied before every request
public $globals = [
'before' => [
//'honeypot'
// 'csrf',
],
'after' => [
'toolbar',
//'honeypot'
],
];
// Works on all of a particular HTTP method
// (GET, POST, etc) as BEFORE filters only
// like: 'post' => ['CSRF', 'throttle'],
public $methods = [
// 'get' => ['login_page_filter']
];
// List filter aliases and any before/after uri patterns
// that they should run on, like:
// 'isLoggedIn' => ['before' => ['account/*', 'profiles/*']],
public $filters = [
'login_page_filter' => ['before' => ['devManage','devManage/*','orgManage','orgManage/*','userManage','userManage/*']],
'login_filter' => ['before' => ['devManageCtr','devManageCtr/*']]
];
}
<?php namespace Config;
class ForeignCharacters extends \CodeIgniter\Config\ForeignCharacters
{
}
<?php namespace Config;
use CodeIgniter\Config\BaseConfig;
class Format extends BaseConfig
{
/*
|--------------------------------------------------------------------------
| Available Response Formats
|--------------------------------------------------------------------------
|
| When you perform content negotiation with the request, these are the
| available formats that your application supports. This is currently
| only used with the API\ResponseTrait. A valid Formatter must exist
| for the specified format.
|
| These formats are only checked when the data passed to the respond()
| method is an array.
|
*/
public $supportedResponseFormats = [
'application/json',
'application/xml', // machine-readable XML
'text/xml', // human-readable XML
];
/*
|--------------------------------------------------------------------------
| Formatters
|--------------------------------------------------------------------------
|
| Lists the class to use to format responses with of a particular type.
| For each mime type, list the class that should be used. Formatters
| can be retrieved through the getFormatter() method.
|
*/
public $formatters = [
'application/json' => \CodeIgniter\Format\JSONFormatter::class,
'application/xml' => \CodeIgniter\Format\XMLFormatter::class,
'text/xml' => \CodeIgniter\Format\XMLFormatter::class,
];
//--------------------------------------------------------------------
/**
* A Factory method to return the appropriate formatter for the given mime type.
*
* @param string $mime
*
* @return \CodeIgniter\Format\FormatterInterface
*/
public function getFormatter(string $mime)
{
if (! array_key_exists($mime, $this->formatters))
{
throw new \InvalidArgumentException('No Formatter defined for mime type: ' . $mime);
}
$class = $this->formatters[$mime];
if (! class_exists($class))
{
throw new \BadMethodCallException($class . ' is not a valid Formatter.');
}
return new $class();
}
//--------------------------------------------------------------------
}
<?php namespace Config;
use CodeIgniter\Config\BaseConfig;
class Honeypot extends BaseConfig
{
/**
* Makes Honeypot visible or not to human
*
* @var boolean
*/
public $hidden = true;
/**
* Honeypot Label Content
*
* @var string
*/
public $label = 'Fill This Field';
/**
* Honeypot Field Name
*
* @var string
*/
public $name = 'honeypot';
/**
* Honeypot HTML Template
*
* @var string
*/
public $template = '<label>{label}</label><input type="text" name="{name}" value=""/>';
}
<?php namespace Config;
use CodeIgniter\Config\BaseConfig;
class Images extends BaseConfig
{
/**
* Default handler used if no other handler is specified.
*
* @var string
*/
public $defaultHandler = 'gd';
/**
* The path to the image library.
* Required for ImageMagick, GraphicsMagick, or NetPBM.
*
* @var string
*/
public $libraryPath = '/usr/local/bin/convert';
/**
* The available handler classes.
*
* @var array
*/
public $handlers = [
'gd' => \CodeIgniter\Images\Handlers\GDHandler::class,
'imagick' => \CodeIgniter\Images\Handlers\ImageMagickHandler::class,
];
}
<?php namespace Config;
use CodeIgniter\Config\BaseConfig;
use Kint\Renderer\Renderer;
class Kint extends BaseConfig
{
/*
|--------------------------------------------------------------------------
| Kint
|--------------------------------------------------------------------------
|
| We use Kint's RichRenderer and CLIRenderer. This area contains options
| that you can set to customize how Kint works for you.
|
| For details on these settings, see Kint's docs:
| https://kint-php.github.io/kint/
|
*/
/*
|--------------------------------------------------------------------------
| Global Settings
|--------------------------------------------------------------------------
*/
public $plugins = null;
public $maxDepth = 6;
public $displayCalledFrom = true;
public $expanded = false;
/*
|--------------------------------------------------------------------------
| RichRenderer Settings
|--------------------------------------------------------------------------
*/
public $richTheme = 'aante-light.css';
public $richFolder = false;
public $richSort = Renderer::SORT_FULL;
public $richObjectPlugins = null;
public $richTabPlugins = null;
/*
|--------------------------------------------------------------------------
| CLI Settings
|--------------------------------------------------------------------------
*/
public $cliColors = true;
public $cliForceUTF8 = false;
public $cliDetectWidth = true;
public $cliMinWidth = 40;
}
<?php namespace Config;
use CodeIgniter\Config\BaseConfig;
class Logger extends BaseConfig
{
/*
|--------------------------------------------------------------------------
| Error Logging Threshold
|--------------------------------------------------------------------------
|
| You can enable error logging by setting a threshold over zero. The
| threshold determines what gets logged. Any values below or equal to the
| threshold will be logged. Threshold options are:
|
| 0 = Disables logging, Error logging TURNED OFF
| 1 = Emergency Messages - System is unusable
| 2 = Alert Messages - Action Must Be Taken Immediately
| 3 = Critical Messages - Application component unavailable, unexpected exception.
| 4 = Runtime Errors - Don't need immediate action, but should be monitored.
| 5 = Warnings - Exceptional occurrences that are not errors.
| 6 = Notices - Normal but significant events.
| 7 = Info - Interesting events, like user logging in, etc.
| 8 = Debug - Detailed debug information.
| 9 = All Messages
|
| You can also pass an array with threshold levels to show individual error types
|
| array(1, 2, 3, 8) = Emergency, Alert, Critical, and Debug messages
|
| For a live site you'll usually enable Critical or higher (3) to be logged otherwise
| your log files will fill up very fast.
|
*/
public $threshold = 3;
/*
|--------------------------------------------------------------------------
| Date Format for Logs
|--------------------------------------------------------------------------
|
| Each item that is logged has an associated date. You can use PHP date
| codes to set your own date formatting
|
*/
public $dateFormat = 'Y-m-d H:i:s';
/*
|--------------------------------------------------------------------------
| Log Handlers
|--------------------------------------------------------------------------
|
| The logging system supports multiple actions to be taken when something
| is logged. This is done by allowing for multiple Handlers, special classes
| designed to write the log to their chosen destinations, whether that is
| a file on the getServer, a cloud-based service, or even taking actions such
| as emailing the dev team.
|
| Each handler is defined by the class name used for that handler, and it
| MUST implement the CodeIgniter\Log\Handlers\HandlerInterface interface.
|
| The value of each key is an array of configuration items that are sent
| to the constructor of each handler. The only required configuration item
| is the 'handles' element, which must be an array of integer log levels.
| This is most easily handled by using the constants defined in the
| Psr\Log\LogLevel class.
|
| Handlers are executed in the order defined in this array, starting with
| the handler on top and continuing down.
|
*/
public $handlers = [
//--------------------------------------------------------------------
// File Handler
//--------------------------------------------------------------------
'CodeIgniter\Log\Handlers\FileHandler' => [
/*
* The log levels that this handler will handle.
*/
'handles' => [
'critical',
'alert',
'emergency',
'debug',
'error',
'info',
'notice',
'warning',
],
/*
* The default filename extension for log files.
* An extension of 'php' allows for protecting the log files via basic
* scripting, when they are to be stored under a publicly accessible directory.
*
* Note: Leaving it blank will default to 'log'.
*/
'fileExtension' => '',
/*
* The file system permissions to be applied on newly created log files.
*
* IMPORTANT: This MUST be an integer (no quotes) and you MUST use octal
* integer notation (i.e. 0700, 0644, etc.)
*/
'filePermissions' => 0644,
/*
* Logging Directory Path
*
* By default, logs are written to WRITEPATH . 'logs/'
* Specify a different destination here, if desired.
*/
'path' => '',
],
/**
* The ChromeLoggerHandler requires the use of the Chrome web browser
* and the ChromeLogger extension. Uncomment this block to use it.
*/
// 'CodeIgniter\Log\Handlers\ChromeLoggerHandler' => [
// /*
// * The log levels that this handler will handle.
// */
// 'handles' => ['critical', 'alert', 'emergency', 'debug',
// 'error', 'info', 'notice', 'warning'],
// ]
];
}
<?php namespace Config;
use CodeIgniter\Config\BaseConfig;
class Migrations extends BaseConfig
{
/*
|--------------------------------------------------------------------------
| Enable/Disable Migrations
|--------------------------------------------------------------------------
|
| Migrations are enabled by default for security reasons.
| You should enable migrations whenever you intend to do a schema migration
| and disable it back when you're done.
|
*/
public $enabled = true;
/*
|--------------------------------------------------------------------------
| Migrations table
|--------------------------------------------------------------------------
|
| This is the name of the table that will store the current migrations state.
| When migrations runs it will store in a database table which migration
| level the system is at. It then compares the migration level in this
| table to the $config['migration_version'] if they are not the same it
| will migrate up. This must be set.
|
*/
public $table = 'migrations';
/*
|--------------------------------------------------------------------------
| Timestamp Format
|--------------------------------------------------------------------------
|
| This is the format that will be used when creating new migrations
| using the cli command:
| > php spark migrate:create
|
| Typical formats:
| YmdHis_
| Y-m-d-His_
| Y_m_d_His_
|
*/
public $timestampFormat = 'Y-m-d-His_';
}
This diff is collapsed.
<?php namespace Config;
// Cannot extend BaseConfig or looping resources occurs.
class Modules
{
/*
|--------------------------------------------------------------------------
| Auto-Discovery Enabled?
|--------------------------------------------------------------------------
|
| If true, then auto-discovery will happen across all elements listed in
| $activeExplorers below. If false, no auto-discovery will happen at all,
| giving a slight performance boost.
*/
public $enabled = true;
/*
|--------------------------------------------------------------------------
| Auto-Discovery Within Composer Packages Enabled?
|--------------------------------------------------------------------------
|
| If true, then auto-discovery will happen across all namespaces loaded
| by Composer, as well as the namespaces configured locally.
*/
public $discoverInComposer = true;
/*
|--------------------------------------------------------------------------
| Auto-discover Rules
|--------------------------------------------------------------------------
|
| Lists the aliases of all discovery classes that will be active
| and used during the current application request. If it is not
| listed here, only the base application elements will be used.
*/
public $activeExplorers = [
'events',
'registrars',
'routes',
'services',
];
/**
* Should the application auto-discover the requested resources.
*
* Valid values are:
* - events
* - registrars
* - routes
* - services
*
* @param string $alias
*
* @return boolean
*/
public function shouldDiscover(string $alias)
{
if (! $this->enabled)
{
return false;
}
$alias = strtolower($alias);
return in_array($alias, $this->activeExplorers);
}
}
<?php namespace Config;
use CodeIgniter\Config\BaseConfig;
class Pager extends BaseConfig
{
/*
|--------------------------------------------------------------------------
| Templates
|--------------------------------------------------------------------------
|
| Pagination links are rendered out using views to configure their
| appearance. This array contains aliases and the view names to
| use when rendering the links.
|
| Within each view, the Pager object will be available as $pager,
| and the desired group as $pagerGroup;
|
*/
public $templates = [
'default_full' => 'CodeIgniter\Pager\Views\default_full',
'default_simple' => 'CodeIgniter\Pager\Views\default_simple',
'default_head' => 'CodeIgniter\Pager\Views\default_head',
];
/*
|--------------------------------------------------------------------------
| Items Per Page
|--------------------------------------------------------------------------
|
| The default number of results shown in a single page.
|
*/
public $perPage = 20;
}
<?php namespace Config;
/**
* Holds the paths that are used by the system to
* locate the main directories, app, system, etc.
* Modifying these allows you to re-structure your application,
* share a system folder between multiple applications, and more.
*
* All paths are relative to the project's root folder.
*/
class Paths
{
/*
*---------------------------------------------------------------
* SYSTEM FOLDER NAME
*---------------------------------------------------------------
*
* This variable must contain the name of your "system" folder.
* Include the path if the folder is not in the same directory
* as this file.
*/
public $systemDirectory = __DIR__ . '/../../system';
/*
*---------------------------------------------------------------
* APPLICATION FOLDER NAME
*---------------------------------------------------------------
*
* If you want this front controller to use a different "app"
* folder than the default one you can set its name here. The folder
* can also be renamed or relocated anywhere on your getServer. If
* you do, use a full getServer path. For more info please see the user guide:
* http://codeigniter.com/user_guide/general/managing_apps.html
*
* NO TRAILING SLASH!
*/
public $appDirectory = __DIR__ . '/..';
/*
* ---------------------------------------------------------------
* WRITABLE DIRECTORY NAME
* ---------------------------------------------------------------
*
* This variable must contain the name of your "writable" directory.
* The writable directory allows you to group all directories that
* need write permission to a single place that can be tucked away
* for maximum security, keeping it out of the app and/or
* system directories.
*/
public $writableDirectory = __DIR__ . '/../../writable';
/*
* ---------------------------------------------------------------
* TESTS DIRECTORY NAME
* ---------------------------------------------------------------
*
* This variable must contain the name of your "tests" directory.
*/
public $testsDirectory = __DIR__ . '/../../tests';
/*
* ---------------------------------------------------------------
* VIEW DIRECTORY NAME
* ---------------------------------------------------------------
*
* This variable must contain the name of the directory that
* contains the view files used by your application. By
* default this is in `app/Views`. This value
* is used when no value is provided to `Services::renderer()`.
*/
public $viewDirectory = __DIR__ . '/../Views';
}
<?php namespace Config;
// Create a new instance of our RouteCollection class.
$routes = Services::routes();
// Load the system's routing file first, so that the app and ENVIRONMENT
// can override as needed.
if (file_exists(SYSTEMPATH . 'Config/Routes.php'))
{
require SYSTEMPATH . 'Config/Routes.php';
}
/**
* --------------------------------------------------------------------
* Router Setup
* --------------------------------------------------------------------
*/
$routes->setDefaultNamespace('App\Controllers');
$routes->setDefaultController('Home');
$routes->setDefaultMethod('index');
$routes->setTranslateURIDashes(false);
$routes->set404Override();
$routes->setAutoRoute(true);
/**
* --------------------------------------------------------------------
* Route Definitions
* --------------------------------------------------------------------
*/
// We get a performance increase by specifying the default
// route since we don't have to scan directories.
$routes->get('/', 'Home::index');
$routes->get('/devManage', 'DevManage::devManagePage');
$routes->get('/sign', 'Sign::loginPage');
$routes->get('/orgManage', 'OrgManage::orgManagePage');
$routes->get('/userManage', 'UserManage::userManagePage');
$routes->get('/sysManage', 'SysManage::logManagePage');
/**
* --------------------------------------------------------------------
* Additional Routing
* --------------------------------------------------------------------
*
* There will often be times that you need additional routing and you
* need to it be able to override any defaults in this file. Environment
* based routes is one such time. require() additional route files here
* to make that happen.
*
* You will have access to the $routes object within that file without
* needing to reload it.
*/
if (file_exists(APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php'))
{
require APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php';
}
<?php namespace Config;
use CodeIgniter\Config\Services as CoreServices;
require_once SYSTEMPATH . 'Config/Services.php';
/**
* Services Configuration file.
*
* Services are simply other classes/libraries that the system uses
* to do its job. This is used by CodeIgniter to allow the core of the
* framework to be swapped out easily without affecting the usage within
* the rest of your application.
*
* This file holds any application-specific services, or service overrides
* that you might need. An example has been included with the general
* method format you should use for your service methods. For more examples,
* see the core Services file at system/Config/Services.php.
*/
class Services extends CoreServices
{
// public static function example($getShared = true)
// {
// if ($getShared)
// {
// return static::getSharedInstance('example');
// }
//
// return new \CodeIgniter\Example();
// }
}
<?php namespace Config;
use CodeIgniter\Config\BaseConfig;
class Toolbar extends BaseConfig
{
/*
|--------------------------------------------------------------------------
| Debug Toolbar
|--------------------------------------------------------------------------
| The Debug Toolbar provides a way to see information about the performance
| and state of your application during that page display. By default it will
| NOT be displayed under production environments, and will only display if
| CI_DEBUG is true, since if it's not, there's not much to display anyway.
|
| toolbarMaxHistory = Number of history files, 0 for none or -1 for unlimited
|
*/
public $collectors = [
\CodeIgniter\Debug\Toolbar\Collectors\Timers::class,
\CodeIgniter\Debug\Toolbar\Collectors\Database::class,
\CodeIgniter\Debug\Toolbar\Collectors\Logs::class,
\CodeIgniter\Debug\Toolbar\Collectors\Views::class,
// \CodeIgniter\Debug\Toolbar\Collectors\Cache::class,
\CodeIgniter\Debug\Toolbar\Collectors\Files::class,
\CodeIgniter\Debug\Toolbar\Collectors\Routes::class,
\CodeIgniter\Debug\Toolbar\Collectors\Events::class,
];
/*
|--------------------------------------------------------------------------
| Max History
|--------------------------------------------------------------------------
| The Toolbar allows you to view recent requests that have been made to
| the application while the toolbar is active. This allows you to quickly
| view and compare multiple requests.
|
| $maxHistory sets a limit on the number of past requests that are stored,
| helping to conserve file space used to store them. You can set it to
| 0 (zero) to not have any history stored, or -1 for unlimited history.
|
*/
public $maxHistory = 20;
/*
|--------------------------------------------------------------------------
| Toolbar Views Path
|--------------------------------------------------------------------------
| The full path to the the views that are used by the toolbar.
| MUST have a trailing slash.
|
*/
public $viewsPath = SYSTEMPATH . 'Debug/Toolbar/Views/';
/*
|--------------------------------------------------------------------------
| Max Queries
|--------------------------------------------------------------------------
| If the Database Collector is enabled, it will log every query that the
| the system generates so they can be displayed on the toolbar's timeline
| and in the query log. This can lead to memory issues in some instances
| with hundreds of queries.
|
| $maxQueries defines the maximum amount of queries that will be stored.
|
*/
public $maxQueries = 100;
}
<?php namespace Config;
use CodeIgniter\Config\BaseConfig;
class UserAgents extends BaseConfig
{
/*
| -------------------------------------------------------------------
| USER AGENT TYPES
| -------------------------------------------------------------------
| This file contains four arrays of user agent data. It is used by the
| User Agent Class to help identify browser, platform, robot, and
| mobile device data. The array keys are used to identify the device
| and the array values are used to set the actual name of the item.
*/
public $platforms = [
'windows nt 10.0' => 'Windows 10',
'windows nt 6.3' => 'Windows 8.1',
'windows nt 6.2' => 'Windows 8',
'windows nt 6.1' => 'Windows 7',
'windows nt 6.0' => 'Windows Vista',
'windows nt 5.2' => 'Windows 2003',
'windows nt 5.1' => 'Windows XP',
'windows nt 5.0' => 'Windows 2000',
'windows nt 4.0' => 'Windows NT 4.0',
'winnt4.0' => 'Windows NT 4.0',
'winnt 4.0' => 'Windows NT',
'winnt' => 'Windows NT',
'windows 98' => 'Windows 98',
'win98' => 'Windows 98',
'windows 95' => 'Windows 95',
'win95' => 'Windows 95',
'windows phone' => 'Windows Phone',
'windows' => 'Unknown Windows OS',
'android' => 'Android',
'blackberry' => 'BlackBerry',
'iphone' => 'iOS',
'ipad' => 'iOS',
'ipod' => 'iOS',
'os x' => 'Mac OS X',
'ppc mac' => 'Power PC Mac',
'freebsd' => 'FreeBSD',
'ppc' => 'Macintosh',
'linux' => 'Linux',
'debian' => 'Debian',
'sunos' => 'Sun Solaris',
'beos' => 'BeOS',
'apachebench' => 'ApacheBench',
'aix' => 'AIX',
'irix' => 'Irix',
'osf' => 'DEC OSF',
'hp-ux' => 'HP-UX',
'netbsd' => 'NetBSD',
'bsdi' => 'BSDi',
'openbsd' => 'OpenBSD',
'gnu' => 'GNU/Linux',
'unix' => 'Unknown Unix OS',
'symbian' => 'Symbian OS',
];
// The order of this array should NOT be changed. Many browsers return
// multiple browser types so we want to identify the sub-type first.
public $browsers = [
'OPR' => 'Opera',
'Flock' => 'Flock',
'Edge' => 'Spartan',
'Chrome' => 'Chrome',
// Opera 10+ always reports Opera/9.80 and appends Version/<real version> to the user agent string
'Opera.*?Version' => 'Opera',
'Opera' => 'Opera',
'MSIE' => 'Internet Explorer',
'Internet Explorer' => 'Internet Explorer',
'Trident.* rv' => 'Internet Explorer',
'Shiira' => 'Shiira',
'Firefox' => 'Firefox',
'Chimera' => 'Chimera',
'Phoenix' => 'Phoenix',
'Firebird' => 'Firebird',
'Camino' => 'Camino',
'Netscape' => 'Netscape',
'OmniWeb' => 'OmniWeb',
'Safari' => 'Safari',
'Mozilla' => 'Mozilla',
'Konqueror' => 'Konqueror',
'icab' => 'iCab',
'Lynx' => 'Lynx',
'Links' => 'Links',
'hotjava' => 'HotJava',
'amaya' => 'Amaya',
'IBrowse' => 'IBrowse',
'Maxthon' => 'Maxthon',
'Ubuntu' => 'Ubuntu Web Browser',
'Vivaldi' => 'Vivaldi',
];
public $mobiles = [
// legacy array, old values commented out
'mobileexplorer' => 'Mobile Explorer',
// 'openwave' => 'Open Wave',
// 'opera mini' => 'Opera Mini',
// 'operamini' => 'Opera Mini',
// 'elaine' => 'Palm',
'palmsource' => 'Palm',
// 'digital paths' => 'Palm',
// 'avantgo' => 'Avantgo',
// 'xiino' => 'Xiino',
'palmscape' => 'Palmscape',
// 'nokia' => 'Nokia',
// 'ericsson' => 'Ericsson',
// 'blackberry' => 'BlackBerry',
// 'motorola' => 'Motorola'
// Phones and Manufacturers
'motorola' => 'Motorola',
'nokia' => 'Nokia',
'palm' => 'Palm',
'iphone' => 'Apple iPhone',
'ipad' => 'iPad',
'ipod' => 'Apple iPod Touch',
'sony' => 'Sony Ericsson',
'ericsson' => 'Sony Ericsson',
'blackberry' => 'BlackBerry',
'cocoon' => 'O2 Cocoon',
'blazer' => 'Treo',
'lg' => 'LG',
'amoi' => 'Amoi',
'xda' => 'XDA',
'mda' => 'MDA',
'vario' => 'Vario',
'htc' => 'HTC',
'samsung' => 'Samsung',
'sharp' => 'Sharp',
'sie-' => 'Siemens',
'alcatel' => 'Alcatel',
'benq' => 'BenQ',
'ipaq' => 'HP iPaq',
'mot-' => 'Motorola',
'playstation portable' => 'PlayStation Portable',
'playstation 3' => 'PlayStation 3',
'playstation vita' => 'PlayStation Vita',
'hiptop' => 'Danger Hiptop',
'nec-' => 'NEC',
'panasonic' => 'Panasonic',
'philips' => 'Philips',
'sagem' => 'Sagem',
'sanyo' => 'Sanyo',
'spv' => 'SPV',
'zte' => 'ZTE',
'sendo' => 'Sendo',
'nintendo dsi' => 'Nintendo DSi',
'nintendo ds' => 'Nintendo DS',
'nintendo 3ds' => 'Nintendo 3DS',
'wii' => 'Nintendo Wii',
'open web' => 'Open Web',
'openweb' => 'OpenWeb',
// Operating Systems
'android' => 'Android',
'symbian' => 'Symbian',
'SymbianOS' => 'SymbianOS',
'elaine' => 'Palm',
'series60' => 'Symbian S60',
'windows ce' => 'Windows CE',
// Browsers
'obigo' => 'Obigo',
'netfront' => 'Netfront Browser',
'openwave' => 'Openwave Browser',
'mobilexplorer' => 'Mobile Explorer',
'operamini' => 'Opera Mini',
'opera mini' => 'Opera Mini',
'opera mobi' => 'Opera Mobile',
'fennec' => 'Firefox Mobile',
// Other
'digital paths' => 'Digital Paths',
'avantgo' => 'AvantGo',
'xiino' => 'Xiino',
'novarra' => 'Novarra Transcoder',
'vodafone' => 'Vodafone',
'docomo' => 'NTT DoCoMo',
'o2' => 'O2',
// Fallback
'mobile' => 'Generic Mobile',
'wireless' => 'Generic Mobile',
'j2me' => 'Generic Mobile',
'midp' => 'Generic Mobile',
'cldc' => 'Generic Mobile',
'up.link' => 'Generic Mobile',
'up.browser' => 'Generic Mobile',
'smartphone' => 'Generic Mobile',
'cellphone' => 'Generic Mobile',
];
// There are hundreds of bots but these are the most common.
public $robots = [
'googlebot' => 'Googlebot',
'msnbot' => 'MSNBot',
'baiduspider' => 'Baiduspider',
'bingbot' => 'Bing',
'slurp' => 'Inktomi Slurp',
'yahoo' => 'Yahoo',
'ask jeeves' => 'Ask Jeeves',
'fastcrawler' => 'FastCrawler',
'infoseek' => 'InfoSeek Robot 1.0',
'lycos' => 'Lycos',
'yandex' => 'YandexBot',
'mediapartners-google' => 'MediaPartners Google',
'CRAZYWEBCRAWLER' => 'Crazy Webcrawler',
'adsbot-google' => 'AdsBot Google',
'feedfetcher-google' => 'Feedfetcher Google',
'curious george' => 'Curious George',
'ia_archiver' => 'Alexa Crawler',
'MJ12bot' => 'Majestic-12',
'Uptimebot' => 'Uptimebot',
];
}
<?php namespace Config;
class Validation
{
//--------------------------------------------------------------------
// Setup
//--------------------------------------------------------------------
/**
* Stores the classes that contain the
* rules that are available.
*
* @var array
*/
public $ruleSets = [
\CodeIgniter\Validation\Rules::class,
\CodeIgniter\Validation\FormatRules::class,
\CodeIgniter\Validation\FileRules::class,
\CodeIgniter\Validation\CreditCardRules::class,
];
/**
* Specifies the views that are used to display the
* errors.
*
* @var array
*/
public $templates = [
'list' => 'CodeIgniter\Validation\Views\list',
'single' => 'CodeIgniter\Validation\Views\single',
];
//--------------------------------------------------------------------
// Rules
//--------------------------------------------------------------------
}
<?php namespace Config;
class View extends \CodeIgniter\Config\View
{
/**
* When false, the view method will clear the data between each
* call. This keeps your data safe and ensures there is no accidental
* leaking between calls, so you would need to explicitly pass the data
* to each view. You might prefer to have the data stick around between
* calls so that it is available to all views. If that is the case,
* set $saveData to true.
*/
public $saveData = true;
/**
* Parser Filters map a filter name with any PHP callable. When the
* Parser prepares a variable for display, it will chain it
* through the filters in the order defined, inserting any parameters.
* To prevent potential abuse, all filters MUST be defined here
* in order for them to be available for use within the Parser.
*
* Examples:
* { title|esc(js) }
* { created_on|date(Y-m-d)|esc(attr) }
*/
public $filters = [];
/**
* Parser Plugins provide a way to extend the functionality provided
* by the core Parser by creating aliases that will be replaced with
* any callable. Can be single or tag pair.
*/
public $plugins = [];
}
<?php
namespace App\Controllers;
/**
* Class BaseController
*
* BaseController provides a convenient place for loading components
* and performing functions that are needed by all your controllers.
* Extend this class in any new controllers:
* class Home extends BaseController
*
* For security be sure to declare any new methods as protected or private.
*
* @package CodeIgniter
*/
use CodeIgniter\Controller;
class BaseController extends Controller
{
/**
* An array of helpers to be loaded automatically upon
* class instantiation. These helpers will be available
* to all other controllers that extend BaseController.
*
* @var array
*/
protected $helpers = [];
/**
* Constructor.
*/
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
{
// Do Not Edit This Line
parent::initController($request, $response, $logger);
//--------------------------------------------------------------------
// Preload any models, libraries, etc, here.
//--------------------------------------------------------------------
// E.g.:
// $this->session = \Config\Services::session();
}
}
<?php namespace App\Controllers;
helper('util');
helper('const');
class DevManage extends BaseController
{
/****************************************************
* 设备管理页面
/****************************************************/
public function devManagePage()
{
$data = array();
$username = $this->request->getGet("username");
$token = $this->request->getGet("token");
$page = (int)$this->request->getGet("page");
if($page == 0){
$page = 1;
}
$perPage = (int)$this->request->getGet("perPage");
if($perPage == 0){
$perPage = 20;
}
$item = array();
$item["page"] = $page;
$item["perPage"] = $perPage;
if($username == "" || $token == ""){
$data["userInfo"] = [];
}else{
$signModel = new \App\Models\SignModel();
$userInfo = $signModel->getItemByUsername($username);
$devManageModel = new \App\Models\DevManageModel();
$firstCategory = $devManageModel->getAllFirstCategory();
$secondCategory = $devManageModel->getSecondCategoryByFirstCategoryId();
$devices = $devManageModel->getDevicesAllInfoByPage($item);
$totalNums = $devManageModel->getTatalDeviceNum()[0]["total"];
$orgManageModel = new \App\Models\OrgManageModel();
$orgSections = $orgManageModel->getAllOrgSection();
if($userInfo[0]["token"] == $token){
$data["userInfo"] = $userInfo[0];
$data["notification"] = [];
$data["category"] = array();
$data["category"]["firstCategory"] = $firstCategory;
$data["category"]["secondCategory"] = $secondCategory;
$data["orgSections"] = $orgSections;
$data["devices"] = $devices;
$data["pageInfo"] = array();
$data["pageInfo"]["page"] = $page;
$data["pageInfo"]["perPage"] = $perPage;
$data["pageInfo"]["total"] = $totalNums;
//TODO 小红点的逻辑需要加上
}else{
$data["userInfo"] = [];
}
}
$data["uri"] = getUriInfo($this->request);
return view('devManage/dev_manage',$data);
}
/****************************************************
* 设备详情页面
/****************************************************/
public function devDetail(){
$data = array();
$username = $this->request->getGet("username");
$token = $this->request->getGet("token");
$devId = (int)$this->request->getGet("devId");
if($username == "" || $token == ""){
$data["userInfo"] = [];
}else{
$signModel = new \App\Models\SignModel();
$userInfo = $signModel->getItemByUsername($username);
$devManageModel = new \App\Models\DevManageModel();
$devInfo = $devManageModel->getDeviceInfoById($devId);
$devImg = $devManageModel->getDevImgsById($devId);
if(count($devInfo) == 0){
$devInfo[0] = array();
}
if($userInfo[0]["token"] == $token){
$data["userInfo"] = $userInfo[0];
$data["devInfo"] = $devInfo[0];
$data["devImg"] = $devImg;
$data["notification"] = [];
//TODO 小红点的逻辑需要加上
}else{
$data["userInfo"] = [];
}
}
$data["uri"] = getUriInfo($this->request);
return view('devManage/dev_detail',$data);
}
/****************************************************
* 分类管理页面
/****************************************************/
public function categoryManagePage(){
$data = array();
$username = $this->request->getGet("username");
$token = $this->request->getGet("token");
if($username == "" || $token == ""){
$data["userInfo"] = [];
}else{
$signModel = new \App\Models\SignModel();
$userInfo = $signModel->getItemByUsername($username);
if($userInfo[0]["token"] == $token){
$data["userInfo"] = $userInfo[0];
$data["notification"] = [];
//TODO 小红点的逻辑需要加上
}else{
$data["userInfo"] = [];
}
}
$data["uri"] = getUriInfo($this->request);
$data["category"] = array();
$devManageModel = new \App\Models\DevManageModel();
$data["category"]["firstCategory"] = $devManageModel->getAllFirstCategory();
$data["category"]["secondCategory"] = $devManageModel->getSecondCategoryByFirstCategoryId();
return view('devManage/category_manage',$data);
}
}
This diff is collapsed.
<?php namespace App\Controllers;
helper('util');
helper('const');
class Home extends BaseController
{
/*********************************************
* 进入设备管理系统首页
*********************************************/
public function index()
{
$data = array();
$username = $this->request->getGet("username");
$token = $this->request->getGet("token");
if($username == "" || $token == ""){
$data["userInfo"] = [];
}else{
$signModel = new \App\Models\SignModel();
$userInfo = $signModel->getItemByUsername($username);
if($userInfo[0]["token"] == $token){
$data["userInfo"] = $userInfo[0];
$data["notification"] = [];
//TODO 小红点的逻辑需要加上
}else{
$data["userInfo"] = [];
}
}
$data["uri"] = getUriInfo($this->request);
return view('home/home',$data);
}
/*********************************************
* 展示设备页面
*********************************************/
public function showDevs()
{
$data = array();
$username = $this->request->getGet("username");
$token = $this->request->getGet("token");
$page = (int)$this->request->getGet("page");
if($page == 0){
$page = 1;
}
$perPage = (int)$this->request->getGet("perPage");
if($perPage == 0){
$perPage = 20;
}
$item = array();
$item["page"] = $page;
$item["perPage"] = $perPage;
if($username == "" || $token == ""){
$data["userInfo"] = [];
}else{
$signModel = new \App\Models\SignModel();
$userInfo = $signModel->getItemByUsername($username);
$devManageModel = new \App\Models\DevManageModel();
$devices = $devManageModel->getDevicesAllInfoByPage($item);
$totalNums = $devManageModel->getTatalDeviceNum()[0]["total"];
if($userInfo[0]["token"] == $token){
$data["userInfo"] = $userInfo[0];
$data["devices"] = $devices;
$data["pageInfo"] = array();
$data["pageInfo"]["page"] = $page;
$data["pageInfo"]["perPage"] = $perPage;
$data["pageInfo"]["total"] = $totalNums;
$data["notification"] = [];
//TODO 小红点的逻辑需要加上
}else{
$data["userInfo"] = [];
}
}
$data["uri"] = getUriInfo($this->request);
return view('home/show_devs',$data);
}
/*********************************************
* 设备详情页面
*********************************************/
public function showDevDetail()
{
$data = array();
$username = $this->request->getGet("username");
$token = $this->request->getGet("token");
$devId = (int)$this->request->getGet("devId");
if($username == "" || $token == ""){
$data["userInfo"] = [];
}else{
$signModel = new \App\Models\SignModel();
$userInfo = $signModel->getItemByUsername($username);
$devManageModel = new \App\Models\DevManageModel();
$devInfo = $devManageModel->getDeviceInfoById($devId);
$devImg = $devManageModel->getDevImgsById($devId);
if(count($devInfo) == 0){
$devInfo[0] = array();
}
if($userInfo[0]["token"] == $token){
$data["userInfo"] = $userInfo[0];
$data["devInfo"] = $devInfo[0];
$data["devImg"] = $devImg;
$data["notification"] = [];
//TODO 小红点的逻辑需要加上
}else{
$data["userInfo"] = [];
}
}
$data["uri"] = getUriInfo($this->request);
return view('home/show_dev_detail',$data);
}
}
<?php namespace App\Controllers;
class HomeCtr extends BaseController
{
}
<?php namespace App\Controllers;
helper('util');
class OrgManage extends BaseController
{
/****************************************************
* 组织部门管理页面
/****************************************************/
public function orgManagePage()
{
$data = array();
$username = $this->request->getGet("username");
$token = $this->request->getGet("token");
if($username == "" || $token == ""){
$data["userInfo"] = [];
}else{
$signModel = new \App\Models\SignModel();
$userInfo = $signModel->getItemByUsername($username);
$orgManageModel = new \App\Models\OrgManageModel();
$orgSections = $orgManageModel->getAllOrgSection();
if($userInfo[0]["token"] == $token){
$data["userInfo"] = $userInfo[0];
$data["notification"] = [];
$data["orgSections"] = $orgSections;
//TODO 小红点的逻辑需要加上
}else{
$data["userInfo"] = [];
}
}
$data["uri"] = getUriInfo($this->request);
return view('orgManage/org_manage',$data);
}
}
\ No newline at end of file
<?php namespace App\Controllers;
helper('statusCode');
class OrgManageCtr extends BaseController
{
/****************************************************
* 添加部门
/****************************************************/
public function addOrgSection(){
$result = array();
$param = $this->request->getJSON();
$timest = time();
$curTime = date("Y-m-d H:i:s", $timest);
$item = array();
$item["org_section_name"] = $param->org_section_name;
$item["org_section_detail"] = $param->org_section_detail;
$item["create_time"] = $curTime;
try{
$orgManageModel = new \App\Models\OrgManageModel();
$orgManageModel->insertOrgSection($item);
$result["status"] = SUCESS;
$result["message"] = "添加部门成功!";
}catch (Exception $e){
$result["status"] = COMMON_FAIL;
$message = $e->getMessage();
$result["message"] = $message;
}
$this->response->setHeader('Content-Type', 'application/json')
->setHeader('charset', 'utf-8');
$result = json_encode($result);
echo $result;
}
/****************************************************
* 删除部门
/****************************************************/
public function delOrgSection(){
$result = array();
$param = $this->request->getJSON();
$orgSectionId = $param->org_section_id;
try{
$orgManageModel = new \App\Models\OrgManageModel();
$orgManageModel->delOrgSection($orgSectionId);
$result["status"] = SUCESS;
$result["message"] = "删除部门成功!";
}catch (Exception $e){
$result["status"] = COMMON_FAIL;
$message = $e->getMessage();
$result["message"] = $message;
}
$this->response->setHeader('Content-Type', 'application/json')
->setHeader('charset', 'utf-8');
$result = json_encode($result);
echo $result;
}
/****************************************************
* 更新部门
/****************************************************/
public function updateOrgSection(){
$result = array();
$param = $this->request->getJSON();
$item = array();
$item["org_section_name"] = $param->org_section_name;
$item["org_section_detail"] = $param->org_section_detail;
$item["id"] = $param->org_section_id;
try{
$orgManageModel = new \App\Models\OrgManageModel();
$orgManageModel->updateOrgSection($item);
$result["status"] = SUCESS;
$result["message"] = "修改部门成功!";
}catch (Exception $e){
$result["status"] = COMMON_FAIL;
$message = $e->getMessage();
$result["message"] = $message;
}
$this->response->setHeader('Content-Type', 'application/json')
->setHeader('charset', 'utf-8');
$result = json_encode($result);
echo $result;
}
/****************************************************
* 获取所有部门
/****************************************************/
public function getAllOrgSections(){
$result = array();
$param = $this->request->getJSON();
try{
$orgManageModel = new \App\Models\OrgManageModel();
$data = $orgManageModel->getAllOrgSection();
$result["status"] = SUCESS;
$result["data"] = $data;
}catch (Exception $e){
$result["status"] = COMMON_FAIL;
$message = $e->getMessage();
$result["message"] = $message;
}
$this->response->setHeader('Content-Type', 'application/json')
->setHeader('charset', 'utf-8');
$result = json_encode($result);
echo $result;
}
}
\ No newline at end of file
<?php namespace App\Controllers;
class Sign extends BaseController
{
/****************************************************
* 登录页面
/****************************************************/
public function loginPage(){
$data = array();
return view('sign/login',$data);
}
/****************************************************
* 注册页面
/****************************************************/
public function registerPage(){
$data = array();
return view('sign/register',$data);
}
}
\ No newline at end of file
<?php namespace App\Controllers;
helper('statusCode');
class SignCtr extends BaseController
{
/****************************************************
* 用户登录
/****************************************************/
public function login(){
$result = array();
$param = $this->request->getJSON();
$timest = time();
$curTime = date("Y-m-d H:i:s", $timest);
$item = array();
$item["username"] = $param->username;
$item["password"] = $param->password;
try{
$signModel = new \App\Models\SignModel();
$userInfo = $signModel->getItemByUsername($param->username);
if(count($userInfo) == 0){
$result["status"] = COMMON_FAIL;
$result["message"] = "该用户不存在!";
}else{
if($userInfo[0]["password"] == $param->password){
$tokenInfo = array();
$exInfo = $param->username.$param->password.$curTime; //用于生成token的字符串
$tokenStr = md5($exInfo);
$tokenInfo["token"] = $tokenStr;
$tokenInfo["login_time"] = $curTime;
$tokenInfo["username"] = $param->username;
$signModel->writeIntoToken($tokenInfo);
$result["status"] = SUCESS;
$result["message"] = "登录成功!";
$userInfo[0]["token"] = $tokenStr;
$result["user"] = $userInfo[0];
}else{
$result["status"] = COMMON_FAIL;
$result["message"] = "用户名或密码不对!";
}
}
}catch (Exception $e){
$result["status"] = COMMON_FAIL;
$message = $e->getMessage();
$result["message"] = $message;
}
$this->response->setHeader('Content-Type', 'application/json')
->setHeader('charset', 'utf-8');
$result = json_encode($result);
echo $result;
}
/****************************************************
* 用户登出
/****************************************************/
public function logout(){
$result = array();
$param = $this->request->getJSON();
$item = array();
$item["username"] = $param->username;
try{
$signModel = new \App\Models\SignModel();
$userInfo = $signModel->getItemByUsername($param->username);
$signModel->clearToken($item);
$result["status"] = SUCESS;
$result["message"] = "退出登录成功!";
}catch (Exception $e){
$result["status"] = COMMON_FAIL;
$message = $e->getMessage();
$result["message"] = $message;
}
$this->response->setHeader('Content-Type', 'application/json')
->setHeader('charset', 'utf-8');
$result = json_encode($result);
echo $result;
}
/****************************************************
* 注册用户
/****************************************************/
public function register(){
$result = array();
$param = $this->request->getJSON();
$timest = time();
$curTime = date("Y-m-d H:i:s", $timest);
$item = array();
$item["username"] = $param->username;
$item["nick"] = $param->nick;
$item["password"] = $param->password;
$item["status"] = 0; //正常用户
$item["role"] = 2; //普通用户
$item["register_time"] = $curTime;
try{
$signModel = new \App\Models\SignModel();
$userInfo = $signModel->getItemByUsername($param->username);
if(count($userInfo) > 0){
$result["status"] = COMMON_FAIL;
$result["message"] = "该用户已存在!";
}else{
$signModel->register($item);
$result["status"] = SUCESS;
$result["message"] = "注册成功!";
}
}catch (Exception $e){
$result["status"] = COMMON_FAIL;
$message = $e->getMessage();
$result["message"] = $message;
}
$this->response->setHeader('Content-Type', 'application/json')
->setHeader('charset', 'utf-8');
$result = json_encode($result);
echo $result;
}
}
\ No newline at end of file
<?php namespace App\Controllers;
helper('util');
class SysManage extends BaseController
{
/****************************************************
* 日志管理页面
/****************************************************/
public function logManagePage(){
$data = array();
$username = $this->request->getGet("username");
$token = $this->request->getGet("token");
$page = (int)$this->request->getGet("page");
// if($page == 0){
// $page = 1;
// }
// $perPage = (int)$this->request->getGet("perPage");
// if($perPage == 0){
// $perPage = 20;
// }
// $item = array();
// $item["page"] = $page;
// $item["perPage"] = $perPage;
if($username == "" || $token == ""){
$data["userInfo"] = [];
}else{
$signModel = new \App\Models\SignModel();
$userInfo = $signModel->getItemByUsername($username);
if($userInfo[0]["token"] == $token){
$data["userInfo"] = $userInfo[0];
$data["notification"] = [];
//TODO 小红点的逻辑需要加上
}else{
$data["userInfo"] = [];
}
}
$data["uri"] = getUriInfo($this->request);
return view('sysManage/log_manage',$data);
}
}
\ No newline at end of file
<?php namespace App\Controllers;
helper('util');
class UserManage extends BaseController
{
/****************************************************
* 用户管理页面
/****************************************************/
public function userManagePage(){
$data = array();
$username = $this->request->getGet("username");
$token = $this->request->getGet("token");
$page = (int)$this->request->getGet("page");
if($page == 0){
$page = 1;
}
$perPage = (int)$this->request->getGet("perPage");
if($perPage == 0){
$perPage = 20;
}
$item = array();
$item["page"] = $page;
$item["perPage"] = $perPage;
if($username == "" || $token == ""){
$data["userInfo"] = [];
}else{
$signModel = new \App\Models\SignModel();
$userInfo = $signModel->getItemByUsername($username);
$userManageModel = new \App\Models\UserManageModel();
$users = $userManageModel->getUsersByPage($item);
$totalNums = $userManageModel->getTatalUserNum()[0]["total"];
$orgManageModel = new \App\Models\OrgManageModel();
$orgSections = $orgManageModel->getAllOrgSection();
if($userInfo[0]["token"] == $token){
$data["userInfo"] = $userInfo[0];
$data["users"] = $users;
$data["orgSections"] = $orgSections;
$data["notification"] = [];
$data["pageInfo"] = array();
$data["pageInfo"]["page"] = $page;
$data["pageInfo"]["perPage"] = $perPage;
$data["pageInfo"]["total"] = $totalNums;
//TODO 小红点的逻辑需要加上
}else{
$data["userInfo"] = [];
}
}
$data["uri"] = getUriInfo($this->request);
return view('userManage/user_manage',$data);
}
/////////////////////////////////////////////////// 权限管理区域 ////////////////////////////////////////////////////////////////
/****************************************************
* 展示权限页面
/****************************************************/
public function showRightsPage(){
$data = array();
$username = $this->request->getGet("username");
$token = $this->request->getGet("token");
if($username == "" || $token == ""){
$data["userInfo"] = [];
}else{
$signModel = new \App\Models\SignModel();
$userInfo = $signModel->getItemByUsername($username);
$userManageModel = new \App\Models\UserManageModel();
if($userInfo[0]["token"] == $token){
$data["userInfo"] = $userInfo[0];
$data["notification"] = [];
//TODO 小红点的逻辑需要加上
}else{
$data["userInfo"] = [];
}
}
$data["uri"] = getUriInfo($this->request);
return view('userManage/show_rights',$data);
}
}
\ No newline at end of file
<?php namespace App\Controllers;
helper('statusCode');
class UserManageCtr extends BaseController
{
/****************************************************
* 添加用户
/****************************************************/
public function addUser(){
$result = array();
$param = $this->request->getJSON();
$timest = time();
$curTime = date("Y-m-d H:i:s", $timest);
$item = array();
$item["username"] = $param->username;
$item["nick"] = $param->nick;
$item["password"] = $param->password;
$item["status"] = 0;
$item["role"] = $param->role;
$item["org_section_id"] = $param->org_section_id;
$item["create_time"] = $curTime;
try{
$userManageModel = new \App\Models\UserManageModel();
$userManageModel->addUser($item);
$result["status"] = SUCESS;
$result["message"] = "添加用户成功!";
}catch (Exception $e){
$result["status"] = COMMON_FAIL;
$message = $e->getMessage();
$result["message"] = $message;
}
$this->response->setHeader('Content-Type', 'application/json')
->setHeader('charset', 'utf-8');
$result = json_encode($result);
echo $result;
}
/****************************************************
* 编辑用户
/****************************************************/
public function editUser(){
$result = array();
$param = $this->request->getJSON();
$timest = time();
$curTime = date("Y-m-d H:i:s", $timest);
$item = array();
$item["id"] = $param->userId;
$item["username"] = $param->username;
$item["nick"] = $param->nick;
$item["password"] = $param->password;
$item["status"] = 0;
$item["role"] = $param->role;
$item["org_section_id"] = $param->org_section_id;
$item["update_time"] = $curTime;
try{
$userManageModel = new \App\Models\UserManageModel();
$userManageModel->updateUserInfo($item);
$result["status"] = SUCESS;
$result["message"] = "更新用户成功!";
}catch (Exception $e){
$result["status"] = COMMON_FAIL;
$message = $e->getMessage();
$result["message"] = $message;
}
$this->response->setHeader('Content-Type', 'application/json')
->setHeader('charset', 'utf-8');
$result = json_encode($result);
echo $result;
}
/****************************************************
* 删除用户用户
/****************************************************/
public function delUser(){
$result = array();
$param = $this->request->getJSON();
$id = $param->userId;
try{
$userManageModel = new \App\Models\UserManageModel();
$userManageModel->delUserById($id);
$result["status"] = SUCESS;
$result["message"] = "删除用户成功!";
}catch (Exception $e){
$result["status"] = COMMON_FAIL;
$message = $e->getMessage();
$result["message"] = $message;
}
$this->response->setHeader('Content-Type', 'application/json')
->setHeader('charset', 'utf-8');
$result = json_encode($result);
echo $result;
}
}
\ No newline at end of file
<?php namespace App\Filters;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use CodeIgniter\Filters\FilterInterface;
/*********************************************
* 针对接口访问的过滤器
*********************************************/
class LoginFilter implements FilterInterface
{
public function before(RequestInterface $request)
{
$param = $request->getJSON();
}
//--------------------------------------------------------------------
public function after(RequestInterface $request, ResponseInterface $response)
{
// Do something here
}
}
\ No newline at end of file
<?php namespace App\Filters;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use CodeIgniter\Filters\FilterInterface;
/*********************************************
* 针对页面访问的过滤器
*********************************************/
class LoginPageFilter implements FilterInterface
{
public function before(RequestInterface $request)
{
$username = $request->getGet("username");
$token = $request->getGet("token");
if($username == "" || $token == ""){
return redirect("sign");
}else{
$signModel = new \App\Models\SignModel();
$userInfo = $signModel->getItemByUsername($username);
if($userInfo[0]["token"] != $token){
return redirect("sign");
}
}
}
//--------------------------------------------------------------------
public function after(RequestInterface $request, ResponseInterface $response)
{
// Do something here
}
}
\ No newline at end of file
<?php namespace App\Filters;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use CodeIgniter\Filters\FilterInterface;
/*********************************************
* 针对权限接口访问的过滤器
*********************************************/
class RightsFilter implements FilterInterface
{
public function before(RequestInterface $request)
{
$param = $request->getJSON();
}
//--------------------------------------------------------------------
public function after(RequestInterface $request, ResponseInterface $response)
{
// Do something here
}
}
\ No newline at end of file
<?php
define('IMG_ORI', "pics/"); //保存压缩后的大图片常量
define('IMG_SMALL', "pics/small/"); //保存压缩后的小图片常量
define('IMG_SCALE', 800); //图片按照高压缩的比例,算法为: 图片高/(图片高/IMG_SCALE),压缩有的高为:IMG_SCALE
define('IMG_SCALE_SMALL', 80);
\ No newline at end of file
<?php
define('SUCESS', "200"); //返回成功状态码
define('NO_LOGIN', "4001"); //用户未登录
define('COMMON_FAIL', "4003"); //通用失败信息
\ No newline at end of file
<?php
/****************************************************
* 获取请求url信息
/****************************************************/
function getUriInfo($request){
$data = array();
$data["url"] = (string)$request->uri;
$data["seg"] = $request->uri->getSegments();
if(count($data["seg"]) == 0){
array_push($data["seg"],"/");
}else{
array_push($data["seg"],"/");
}
array_push($data["seg"],"/");
return $data;
}
function test(){
echo "test";
}
\ No newline at end of file
<?php namespace App\Models;
use CodeIgniter\Model;
class DevManageModel extends Model
{
protected $DBGroup = 'default'; //默认连接的数据库
protected $table = 'first_category'; //指定模型要使用的数据库表
protected $returnType = 'array';
protected $allowedFields = [ //允许更改,写入数据库的字段
"category_name",
"detail",
"create_time",
"first_category_id",
];
/////////////////////////////////////////////////// 分类管理区域 ////////////////////////////////////////////////////////////////
/****************************************************
* 向第一分类表插入数据
/****************************************************/
public function insertFirstCategoryData($data){
$maxIdObj = $this->db->query('select Max(id) AS id from first_category');
$maxIdResult = $maxIdObj->getResultArray();
$id = $maxIdResult[0]["id"] + 1;
$sql = 'insert into first_category (id,category_name,detail,create_time) values ("'.$id.'","'
.$data["category_name"].'","'
.$data["detail"].'","'
.$data["create_time"].'")';
$insertObj = $this->db->query($sql);
}
/****************************************************
* 删除一条第一分类数据
/****************************************************/
public function delFirstCategoryById($id){
$sql = "delete from second_category where first_category_id=".$id;
$this->db->query($sql);
$sql = "delete from first_category where id=".$id;
$this->db->query($sql);
}
/****************************************************
* 删除一条第二级分类数据
/****************************************************/
public function delSecondCategoryById($id){
$sql = "delete from second_category where id=".$id;
$this->db->query($sql);
}
/****************************************************
* 向第二分类表插入数据
/****************************************************/
public function insertSecondCategoryData($data){
$sql = 'insert into second_category (category_name,detail,first_category_id,create_time) values ("'
.$data["category_name"].'","'
.$data["detail"].'","'
.$data["first_category_id"].'","'
.$data["create_time"].'")';
$insertObj = $this->db->query($sql);
}
/****************************************************
* 获取第一级分类表的所有数据
/****************************************************/
public function getAllFirstCategory(){
$sql = "select * from first_category";
$allFirstCategoryObj = $this->db->query($sql);
$result = $allFirstCategoryObj->getResultArray();
return $result;
}
/****************************************************
* 获取第二级分类表的数据通过一级分类id
/****************************************************/
public function getSecondCategoryByFirstCategoryId($firstCategoryId=1){
$sql = "select * from second_category where first_category_id='".$firstCategoryId."'";
$allFirstCategoryObj = $this->db->query($sql);
$result = $allFirstCategoryObj->getResultArray();
return $result;
}
/////////////////////////////////////////////////// 设备管理区域 ////////////////////////////////////////////////////////////////
/****************************************************
* 插入一条设备
/****************************************************/
public function insertDevice($data){
$sql = 'insert into devices (dev_name, dev_code, dev_brand, dev_model, dev_system,
dev_version, dev_color, add_time, dev_status, dev_delete, first_category_id, second_category_id,
org_section_id, dev_detail, dev_feature) values ("'
.$data["dev_name"].'","'
.$data["dev_code"].'","'
.$data["dev_brand"].'","'
.$data["dev_model"].'","'
.$data["dev_system"].'","'
.$data["dev_version"].'","'
.$data["dev_color"].'","'
.$data["add_time"].'",'
.$data["dev_status"].','
.$data["dev_delete"].','
.$data["first_category_id"].','
.$data["second_category_id"].','
.$data["org_section_id"].',"'
.$data["dev_detail"].'","'
.$data["dev_feature"].'")';
$insertObj = $this->db->query($sql);
}
/****************************************************
* 更新设备信息
/****************************************************/
public function updateDevice($data){
$sql = 'update devices set dev_name="'
.$data["dev_name"].'",dev_code="'
.$data["dev_code"].'",dev_brand="'
.$data["dev_brand"].'",dev_model="'
.$data["dev_model"].'",dev_system="'
.$data["dev_system"].'",dev_version="'
.$data["dev_version"].'",dev_color="'
.$data["dev_color"].'",update_time="'
.$data["update_time"].'",dev_status='
.$data["dev_status"].',dev_delete='
.$data["dev_delete"].',first_category_id='
.$data["first_category_id"].',second_category_id='
.$data["second_category_id"].',org_section_id='
.$data["org_section_id"].',dev_detail="'
.$data["dev_detail"].'",dev_feature="'
.$data["dev_feature"].'"'
.' where id="'.$data["id"].'"';
$obj = $this->db->query($sql);
}
/****************************************************
* 分页获取设备信息
/****************************************************/
public function getDevicesAllInfoByPage($data){
$sql = 'select t1.*,
t2.category_name,
t3.org_section_name
from devices t1
left join first_category t2 on t1.first_category_id = t2.id
left join org_section t3 on t1.org_section_id = t3.id limit '.(($data["page"] - 1) * $data["perPage"]).','.$data["perPage"];
$allFirstCategoryObj = $this->db->query($sql);
$result = $allFirstCategoryObj->getResultArray();
return $result;
}
/****************************************************
* 获取单条设备信息
/****************************************************/
public function getDeviceInfoById($id){
$sql = 'select t1.*,
t2.category_name,
t3.org_section_name
from devices t1
left join first_category t2 on t1.first_category_id = t2.id
left join org_section t3 on t1.org_section_id = t3.id where t1.id='.$id;
$allFirstCategoryObj = $this->db->query($sql);
$result = $allFirstCategoryObj->getResultArray();
return $result;
}
/****************************************************
* 获取所有的设备数
/****************************************************/
public function getTatalDeviceNum(){
$sql = 'select count(*) as total from devices';
$obj = $this->db->query($sql);
$result = $obj->getResultArray();
return $result;
}
/****************************************************
* 获取单条设备信息
/****************************************************/
public function getDevInfoById($id){
$sql = "select * from devices where id=".$id;
$obj = $this->db->query($sql);
$result = $obj->getResultArray();
return $result;
}
/****************************************************
* 删除设备
/****************************************************/
public function delDevById($id){
$sql = "delete from devices where id=".$id;
$this->db->query($sql);
}
/////////////////////////////////////////////////// 图片操作区域 ////////////////////////////////////////////////////////////////
/****************************************************
* 添加设备图片
/****************************************************/
public function insertDevImg($data){
$sql = 'insert into dev_img (dev_id,create_time,img_ori,img_small) values ('
.$data["devId"].',"'
.$data["create_time"].'","'
.$data["img_ori"].'","'
.$data["img_small"].'")';
$this->db->query($sql);
}
/****************************************************
* 根据设备id获取设备图片
/****************************************************/
public function getDevImgsById($id){
$sql = "select * from dev_img where dev_id=".$id;
$obj = $this->db->query($sql);
$result = $obj->getResultArray();
return $result;
}
/****************************************************
* 根据图片id获取设备图片信息
/****************************************************/
public function getImgInfoById($id){
$sql = "select * from dev_img where id=".$id;
$obj = $this->db->query($sql);
$result = $obj->getResultArray();
return $result;
}
/****************************************************
* 根据设备id删除指定设备图片
/****************************************************/
public function delImgByIds($data){
$sql = "delete from dev_img where dev_id=".$data["dev_id"]." and id=".$data["img_id"];
$this->db->query($sql);
}
}
\ No newline at end of file
<?php namespace App\Models;
use CodeIgniter\Model;
class OrgManageModel extends Model
{
protected $DBGroup = 'default'; //默认连接的数据库
protected $table = 'org_section'; //指定模型要使用的数据库表
protected $returnType = 'array';
protected $allowedFields = [ //允许更改,写入数据库的字段
"org_section_name",
"org_section_detail",
"org_company_id",
"org_company_name",
"create_time"
];
/****************************************************
* 获取所有部门数据
/****************************************************/
public function getAllOrgSection(){
$sql = 'select * from org_section';
$obj = $this->db->query($sql);
$result = $obj->getResultArray();
return $result;
}
/****************************************************
* 添加一条部门数据
/****************************************************/
public function insertOrgSection($data){
$sql = 'insert into org_section (org_section_name,org_section_detail,create_time) value ("'
.$data["org_section_name"].'","'
.$data["org_section_detail"].'","'
.$data["create_time"].'")';
$insertObj = $this->db->query($sql);
}
/****************************************************
* 删除一条部门数据
/****************************************************/
public function delOrgSection($id){
$sql = "delete from org_section where id=".$id;
$obj = $this->db->query($sql);
}
/****************************************************
* 修改一条部门数据
/****************************************************/
public function updateOrgSection($data){
$sql = 'update org_section set ';
if($data["org_section_name"] != ""){
$sql = $sql.'org_section_name="'.$data["org_section_name"].'"';
}
if($data["org_section_detail"] != ""){
if($data["org_section_name"] != ""){
$sql = $sql.',';
}
$sql = $sql.'org_section_detail="'.$data["org_section_name"].'"';
}
$sql = $sql.' where id="'.$data["id"].'"';
$obj = $this->db->query($sql);
}
}
\ No newline at end of file
<?php namespace App\Models;
use CodeIgniter\Model;
class SignModel extends Model
{
protected $DBGroup = 'default'; //默认连接的数据库
protected $table = 'users'; //指定模型要使用的数据库表
protected $returnType = 'array';
protected $allowedFields = [ //允许更改,写入数据库的字段
"username",
"password",
"nick",
"status",
"role",
"create_time",
"upate_time",
"login_time",
"register_time",
"token"
];
/****************************************************
* 注册一个新用户
/****************************************************/
public function register($data){
$sql = 'insert into users (username,nick,password,status,role,register_time) values ("'.$data["username"].'","'
.$data["nick"].'","'
.$data["password"].'","'
.$data["status"].'","'
.$data["role"].'","'
.$data["register_time"].'")';
$insertObj = $this->db->query($sql);
}
/****************************************************
* 根据用户名,获取数据库记录
/****************************************************/
public function getItemByUsername($username){
$sql = 'select * from users where username="'.$username.'"';
$obj = $this->db->query($sql);
$result = $obj->getResultArray();
return $result;
}
/****************************************************
* 写入用户token
/****************************************************/
public function writeIntoToken($data){
$sql = 'update users set token="'.$data["token"].'",login_time="'.$data["login_time"].'" where username="'.$data["username"].'"';
$obj = $this->db->query($sql);
}
/****************************************************
* 清除token
/****************************************************/
public function clearToken($data){
$sql = 'update users set token="" where username="'.$data["username"].'"';
$obj = $this->db->query($sql);
}
}
\ No newline at end of file
<?php namespace App\Models;
use CodeIgniter\Model;
class UserManageModel extends Model
{
protected $DBGroup = 'default'; //默认连接的数据库
protected $table = 'users'; //指定模型要使用的数据库表
protected $returnType = 'array';
protected $allowedFields = [ //允许更改,写入数据库的字段
"username",
"nick",
"password",
"token",
"status",
"role",
"create_time",
"update_time",
"login_time",
"register_time",
"org_section_id",
"token",
"token",
];
/****************************************************
* 获取所有用户
/****************************************************/
public function getAllUsers(){
$sql = 'select t1.*,t2.org_section_name from users t1 left join org_section t2 on t1.org_section_id = t2.id';
$obj = $this->db->query($sql);
$result = $obj->getResultArray();
return $result;
}
/****************************************************
* 分页获取用户数据
/****************************************************/
public function getUsersByPage($data){
$sql = 'select t1.*,t2.org_section_name from users t1 left join org_section t2 on t1.org_section_id = t2.id'
.' limit '.(($data["page"] - 1) * $data["perPage"]).','.$data["perPage"];
$obj = $this->db->query($sql);
$result = $obj->getResultArray();
return $result;
}
/****************************************************
* 获取所有的用户数
/****************************************************/
public function getTatalUserNum(){
$sql = 'select count(*) as total from users';
$obj = $this->db->query($sql);
$result = $obj->getResultArray();
return $result;
}
/****************************************************
* 添加用户
/****************************************************/
public function addUser($data){
$sql = 'insert into users (username,nick,password,status,role,create_time,org_section_id) values ("'
.$data["username"].'","'
.$data["nick"].'","'
.$data["password"].'",'
.$data["status"].','
.$data["role"].',"'
.$data["create_time"].'",'
.$data["org_section_id"].')';
$this->db->query($sql);
}
/****************************************************
* 更新用户信息
/****************************************************/
public function updateUserInfo($data){
$sql = 'update users set username="'
.$data["username"].'",nick="'
.$data["nick"].'",password="'
.$data["password"].'",status='
.$data["status"].',role='
.$data["role"].',update_time="'
.$data["update_time"].'",org_section_id='
.$data["org_section_id"]
.' where id='.$data["id"];
$this->db->query($sql);
}
/****************************************************
* 删除用户
/****************************************************/
public function delUserById($id){
$sql = "delete from users where id=".$id;
$this->db->query($sql);
}
/////////////////////////////////////////////////// 权限管理区域(目前没有权限表) ////////////////////////////////////////////////////////////////
/****************************************************
* 获取所有权限类型
/****************************************************/
public function getAllRights(){
}
}
\ No newline at end of file
<?php $data = $this->data; ?>
<div class="container-fluid">
<div class="row-fluid">
<div class="span3" id="sidebar" style="width:250px;position:fixed;">
<ul class="nav nav-list bs-docs-sidenav nav-collapse collapse">
<li>
<a href="index.html"><i class="icon-chevron-right"></i> 首页</a>
</li>
<li class="active">
<a href="calendar.html"><i class="icon-chevron-right"></i> 查看设备</a>
</li>
<li>
<a href="stats.html"><i class="icon-chevron-right"></i> 设备管理 </a>
</li>
<li>
<a href="form.html"><i class="icon-chevron-right"></i> 添加设备</a>
</li>
<li>
<a href="form.html"><i class="icon-chevron-right"></i> 日志查看</a>
</li>
</ul>
</div>
</div>
</div>
\ No newline at end of file
<?php $data = $this->data; ?>
<?= view("header.php",$data); ?>
<?= view("home/aside.php",$data); ?>
<div class="span9" id="content" style="width:100%;">
<div style="width:100%;min-height:700px;">
</div>
</div>
<?= view("footer.php",$data); ?>
<?php $data = $this->data; ?>
<div class="container-fluid">
<div class="row-fluid">
<div class="span3" id="sidebar" style="width:250px;position:fixed;z-index:100;display:none;">
<ul class="nav nav-list bs-docs-sidenav nav-collapse collapse">
<li <?php if($data["uri"]["seg"][1] == "/" || $data["uri"]["seg"][1] == "devManagePage"){echo "class='active'";} ?> onclick="leftSwich(this)" id="left_dev_man">
<a><i class="icon-chevron-right"></i> 设备管理</a>
</li>
<li <?php if($data["uri"]["seg"][1] == "devDetail"){echo "class='active'";} ?> onclick="leftSwich(this)" id="left_dev_detail">
<a><i class="icon-chevron-right"></i> 设备详情</a>
</li>
<li <?php if($data["uri"]["seg"][1] == "categoryManagePage"){echo "class='active'";} ?> onclick="leftSwich(this)" id="left_category_man">
<a><i class="icon-chevron-right"></i> 分类管理</a>
</li>
</ul>
</div>
</div>
</div>
<script>
/*******************************************
* 左侧菜单切换
/******************************************/
function leftSwich(e){
var id = $(e).attr("id");
var host = window.location.host;
var username = $.cookie('username');
var token = $.cookie('token');
if(username == undefined){
username = "";
}
if(token == undefined){
token = "";
}
if(id == "left_dev_man"){
window.location.href = "http://" + host + "/devManage" + "?username=" + username + "&token=" + token ;
}else if(id == "left_dev_detail"){
window.location.href = "http://" + host + "/devManage/devDetail" + "?username=" + username + "&token=" + token ;;
}else if(id == "left_category_man"){
window.location.href = "http://" + host + "/devManage/categoryManagePage" + "?username=" + username + "&token=" + token ;;
}
}
</script>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<?php
use CodeIgniter\CLI\CLI;
CLI::error('ERROR: ' . $code);
CLI::write($message);
CLI::newLine();
An uncaught Exception was encountered
Type: <?= get_class($exception), "\n"; ?>
Message: <?= $message, "\n"; ?>
Filename: <?= $exception->getFile(), "\n"; ?>
Line Number: <?= $exception->getLine(); ?>
<?php if (defined('SHOW_DEBUG_BACKTRACE') && SHOW_DEBUG_BACKTRACE === true): ?>
Backtrace:
<?php foreach ($exception->getTrace() as $error): ?>
<?php if (isset($error['file'])): ?>
<?= trim('-' . $error['line'] . ' - ' . $error['file'] . '::' . $error['function']) . "\n" ?>
<?php endif ?>
<?php endforeach ?>
<?php endif ?>
<?php
// On the CLI, we still want errors in productions
// so just use the exception template.
include __DIR__ . '/error_exception.php';
This diff is collapsed.
//--------------------------------------------------------------------
// Tabs
//--------------------------------------------------------------------
var tabLinks = new Array();
var contentDivs = new Array();
function init ()
{
// Grab the tab links and content divs from the page
var tabListItems = document.getElementById('tabs').childNodes;
console.log(tabListItems);
for (var i = 0; i < tabListItems.length; i ++)
{
if (tabListItems[i].nodeName == "LI")
{
var tabLink = getFirstChildWithTagName(tabListItems[i], 'A');
var id = getHash(tabLink.getAttribute('href'));
tabLinks[id] = tabLink;
contentDivs[id] = document.getElementById(id);
}
}
// Assign onclick events to the tab links, and
// highlight the first tab
var i = 0;
for (var id in tabLinks)
{
tabLinks[id].onclick = showTab;
tabLinks[id].onfocus = function () { this.blur() };
if (i == 0)
{
tabLinks[id].className = 'active';
}
i ++;
}
// Hide all content divs except the first
var i = 0;
for (var id in contentDivs)
{
if (i != 0)
{
console.log(contentDivs[id]);
contentDivs[id].className = 'content hide';
}
i ++;
}
}
//--------------------------------------------------------------------
function showTab ()
{
var selectedId = getHash(this.getAttribute('href'));
// Highlight the selected tab, and dim all others.
// Also show the selected content div, and hide all others.
for (var id in contentDivs)
{
if (id == selectedId)
{
tabLinks[id].className = 'active';
contentDivs[id].className = 'content';
}
else
{
tabLinks[id].className = '';
contentDivs[id].className = 'content hide';
}
}
// Stop the browser following the link
return false;
}
//--------------------------------------------------------------------
function getFirstChildWithTagName (element, tagName)
{
for (var i = 0; i < element.childNodes.length; i ++)
{
if (element.childNodes[i].nodeName == tagName)
{
return element.childNodes[i];
}
}
}
//--------------------------------------------------------------------
function getHash (url)
{
var hashPos = url.lastIndexOf('#');
return url.substring(hashPos + 1);
}
//--------------------------------------------------------------------
function toggle (elem)
{
elem = document.getElementById(elem);
if (elem.style && elem.style['display'])
{
// Only works with the "style" attr
var disp = elem.style['display'];
}
else if (elem.currentStyle)
{
// For MSIE, naturally
var disp = elem.currentStyle['display'];
}
else if (window.getComputedStyle)
{
// For most other browsers
var disp = document.defaultView.getComputedStyle(elem, null).getPropertyValue('display');
}
// Toggle the state of the "display" style
elem.style.display = disp == 'block' ? 'none' : 'block';
return false;
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="robots" content="noindex">
<title>Whoops!</title>
<style type="text/css">
<?= preg_replace('#[\r\n\t ]+#', ' ', file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'debug.css')) ?>
</style>
</head>
<body>
<div class="container text-center">
<h1 class="headline">Whoops!</h1>
<p class="lead">We seem to have hit a snag. Please try again later...</p>
</div>
</body>
</html>
<?php $data = $this->data; ?>
<footer style="_background:pink;height:50px;float:left;width:100%;margin-top:10px;">
<p></p>
</footer>
</div>
<script src="<?= base_url().'/'; ?>theme/assets/scripts.js"></script>
</body>
</html>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<?php $data = $this->data; ?>
<?= view("header.php",$data); ?>
<?= view("sysManage/aside.php",$data); ?>
<div class="span9" id="content" style="width:100%;">
<div style="width:100%;min-height:700px;">
<h1>日志管理</h1>
</div>
</div>
<?= view("footer.php",$data); ?>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
php spark serve --port 8081
php spark serve --host 0.0.0.0
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment