--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | #-------------------------
2 | # Operating Specific Junk Files
3 | #-------------------------
4 |
5 | # OS X
6 | .DS_Store
7 | .AppleDouble
8 | .LSOverride
9 |
10 | # OS X Thumbnails
11 | ._*
12 |
13 | # Windows image file caches
14 | Thumbs.db
15 | ehthumbs.db
16 | Desktop.ini
17 |
18 | # Recycle Bin used on file shares
19 | $RECYCLE.BIN/
20 |
21 | # Windows Installer files
22 | *.cab
23 | *.msi
24 | *.msm
25 | *.msp
26 |
27 | # Windows shortcuts
28 | *.lnk
29 |
30 | # Linux
31 | *~
32 |
33 | # KDE directory preferences
34 | .directory
35 |
36 | # Linux trash folder which might appear on any partition or disk
37 | .Trash-*
38 |
39 | #-------------------------
40 | # Environment Files
41 | #-------------------------
42 | # These should never be under version control,
43 | # as it poses a security risk.
44 | .env
45 | .vagrant
46 | Vagrantfile
47 |
48 | #-------------------------
49 | # Temporary Files
50 | #-------------------------
51 | writable/cache/*
52 | !writable/cache/index.html
53 |
54 | writable/logs/*
55 | !writable/logs/index.html
56 |
57 | writable/session/*
58 | !writable/session/index.html
59 |
60 | writable/uploads/*
61 | !writable/uploads/index.html
62 |
63 | writable/debugbar/*
64 |
65 | php_errors.log
66 |
67 | #-------------------------
68 | # User Guide Temp Files
69 | #-------------------------
70 | user_guide_src/build/*
71 | user_guide_src/cilexer/build/*
72 | user_guide_src/cilexer/dist/*
73 | user_guide_src/cilexer/pycilexer.egg-info/*
74 |
75 | #-------------------------
76 | # Test Files
77 | #-------------------------
78 | tests/coverage*
79 |
80 | # Don't save phpunit under version control.
81 | phpunit
82 |
83 | #-------------------------
84 | # Composer
85 | #-------------------------
86 | vendor/
87 |
88 | #-------------------------
89 | # IDE / Development Files
90 | #-------------------------
91 |
92 | # Modules Testing
93 | _modules/*
94 |
95 | # phpenv local config
96 | .php-version
97 |
98 | # Jetbrains editors (PHPStorm, etc)
99 | .idea/
100 | *.iml
101 |
102 | # Netbeans
103 | nbproject/
104 | build/
105 | nbbuild/
106 | dist/
107 | nbdist/
108 | nbactions.xml
109 | nb-configuration.xml
110 | .nb-gradle/
111 |
112 | # Sublime Text
113 | *.tmlanguage.cache
114 | *.tmPreferences.cache
115 | *.stTheme.cache
116 | *.sublime-workspace
117 | *.sublime-project
118 | .phpintel
119 | /api/
120 |
121 | # Visual Studio Code
122 | .vscode/
123 |
124 | /results/
125 | /phpunit*.xml
126 | /.phpunit.*.cache
127 |
128 |
--------------------------------------------------------------------------------
/app/Config/DocTypes.php:
--------------------------------------------------------------------------------
1 | '',
14 | 'xhtml1-strict' => '',
15 | 'xhtml1-trans' => '',
16 | 'xhtml1-frame' => '',
17 | 'xhtml-basic11' => '',
18 | 'html5' => '',
19 | 'html4-strict' => '',
20 | 'html4-trans' => '',
21 | 'html4-frame' => '',
22 | 'mathml1' => '',
23 | 'mathml2' => '',
24 | 'svg10' => '',
25 | 'svg11' => '',
26 | 'svg11-basic' => '',
27 | 'svg11-tiny' => '',
28 | 'xhtml-math-svg-xh' => '',
29 | 'xhtml-math-svg-sh' => '',
30 | 'xhtml-rdfa-1' => '',
31 | 'xhtml-rdfa-2' => '',
32 | ];
33 | }
34 |
--------------------------------------------------------------------------------
/app/Views/ajax/index.php:
--------------------------------------------------------------------------------
1 | = $this->extend('layout/templates'); ?>
2 |
3 | = $this->Section('content'); ?>
4 |
5 |
6 |
7 |
CRUD Ajax jQuery
8 |
9 | Dashboard
10 | = $title; ?>
11 |
12 |
13 |
17 |
18 |
Add data
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
68 |
69 | = $this->endSection(); ?>
--------------------------------------------------------------------------------
/app/Controllers/Builder.php:
--------------------------------------------------------------------------------
1 | builderModel = new BuilderModel();
14 | helper('form');
15 | }
16 |
17 | public function index()
18 | {
19 | $data = [
20 | 'title' => 'Crud Query Builder',
21 | 'all_data' => $this->builderModel->select_data() // selecting all data
22 | ];
23 |
24 | return view('builder/index', $data);
25 | }
26 |
27 | public function add_data()
28 | {
29 | // validation
30 | $rules = $this->validate([
31 | 'name' => 'required',
32 | 'department' => 'required',
33 | 'position' => 'required',
34 | 'age' => 'required|numeric'
35 | ]);
36 |
37 | if (!$rules) {
38 | session()->setFlashData('failed', \Config\Services::validation()->getErrors());
39 | return redirect()->back();
40 | }
41 |
42 | $data = [
43 | 'name' => $this->request->getPost('name'),
44 | 'department' => $this->request->getPost('department'),
45 | 'position' => $this->request->getPost('position'),
46 | 'age' => $this->request->getPost('age')
47 | ];
48 |
49 | $this->builderModel->add_data($data);
50 | session()->setFlashData('success', 'data has been added to database.');
51 | return redirect()->back();
52 | }
53 |
54 | public function delete_data($id)
55 | {
56 | $this->builderModel->delete_data($id);
57 | session()->setFlashData('success', 'data has been deleted from database.');
58 | return redirect()->back();
59 | }
60 |
61 | public function update_data($id)
62 | {
63 | // validation
64 | $rules = $this->validate([
65 | 'name' => 'required',
66 | 'department' => 'required',
67 | 'position' => 'required',
68 | 'age' => 'required|numeric'
69 | ]);
70 |
71 | if (!$rules) {
72 | session()->setFlashData('failed', \Config\Services::validation()->getErrors());
73 | return redirect()->back();
74 | }
75 |
76 | $data = [
77 | 'name' => $this->request->getPost('name'),
78 | 'department' => $this->request->getPost('department'),
79 | 'position' => $this->request->getPost('position'),
80 | 'age' => $this->request->getPost('age')
81 | ];
82 |
83 | $this->builderModel->update_data($id, $data);
84 | session()->setFlashData('success', 'data has been updated from database.');
85 | return redirect()->back();
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/app/Config/Toolbar.php:
--------------------------------------------------------------------------------
1 | \CodeIgniter\Format\JSONFormatter::class,
39 | 'application/xml' => \CodeIgniter\Format\XMLFormatter::class,
40 | 'text/xml' => \CodeIgniter\Format\XMLFormatter::class,
41 | ];
42 |
43 | /*
44 | |--------------------------------------------------------------------------
45 | | Formatters Options
46 | |--------------------------------------------------------------------------
47 | |
48 | | Additional Options to adjust default formatters behaviour.
49 | | For each mime type, list the additional options that should be used.
50 | |
51 | */
52 | public $formatterOptions = [
53 | 'application/json' => JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES,
54 | 'application/xml' => 0,
55 | 'text/xml' => 0,
56 | ];
57 | //--------------------------------------------------------------------
58 |
59 | /**
60 | * A Factory method to return the appropriate formatter for the given mime type.
61 | *
62 | * @param string $mime
63 | *
64 | * @return \CodeIgniter\Format\FormatterInterface
65 | */
66 | public function getFormatter(string $mime)
67 | {
68 | if (! array_key_exists($mime, $this->formatters))
69 | {
70 | throw new \InvalidArgumentException('No Formatter defined for mime type: ' . $mime);
71 | }
72 |
73 | $class = $this->formatters[$mime];
74 |
75 | if (! class_exists($class))
76 | {
77 | throw new \BadMethodCallException($class . ' is not a valid Formatter.');
78 | }
79 |
80 | return new $class();
81 | }
82 |
83 | //--------------------------------------------------------------------
84 |
85 | }
86 |
--------------------------------------------------------------------------------
/app/Controllers/Export.php:
--------------------------------------------------------------------------------
1 | db = \Config\Database::connect();
16 | $this->builder = $this->db->table('peoples');
17 | }
18 |
19 | public function export_pdf()
20 | {
21 | $data = [
22 | 'pdf_peoples' => $this->builder->get()->getResultArray()
23 | ];
24 |
25 | $html = view('export/pdf', $data);
26 |
27 | // create new PDF document
28 | $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
29 |
30 |
31 | // set margins
32 | $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_RIGHT);
33 | $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
34 |
35 | // Add a page
36 | // This method has several options, check the source code documentation for more information.
37 | $pdf->AddPage();
38 |
39 | // Print text using writeHTMLCell()
40 | $pdf->writeHTML($html);
41 | $this->response->setContentType('application/pdf');
42 | // Close and output PDF document
43 | // This method has several options, check the source code documentation for more information.
44 | $pdf->Output('peoples.pdf', 'I');
45 | }
46 |
47 | public function export_excel()
48 | {
49 | $peoples = $this->builder->get()->getResultArray();
50 |
51 | $spreadsheet = new Spreadsheet();
52 | // tulis header/nama kolom
53 | $spreadsheet->setActiveSheetIndex(0)
54 | ->setCellValue('A1', 'No')
55 | ->setCellValue('B1', 'Name')
56 | ->setCellValue('C1', 'Address')
57 | ->setCellValue('D1', 'Email')
58 | ->setCellValue('E1', 'Birthdate');
59 |
60 | $column = 2;
61 | // tulis data mobil ke cell
62 | $no = 1;
63 | foreach ($peoples as $data) {
64 | $spreadsheet->setActiveSheetIndex(0)
65 | ->setCellValue('A' . $column, $no++)
66 | ->setCellValue('B' . $column, $data['name'])
67 | ->setCellValue('C' . $column, $data['address'])
68 | ->setCellValue('D' . $column, $data['email'])
69 | ->setCellValue('E' . $column, $data['birthdate']);
70 | $column++;
71 | }
72 | // tulis dalam format .xlsx
73 | $writer = new Xlsx($spreadsheet);
74 | $fileName = 'Peoples Data';
75 |
76 | // Redirect hasil generate xlsx ke web client
77 | header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
78 | header('Content-Disposition: attachment;filename=' . $fileName . '.xlsx');
79 | header('Cache-Control: max-age=0');
80 |
81 | $writer->save('php://output');
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/app/Config/Paths.php:
--------------------------------------------------------------------------------
1 | '',
34 | 'hostname' => 'localhost',
35 | 'username' => '',
36 | 'password' => '',
37 | 'database' => '',
38 | 'DBDriver' => 'MySQLi',
39 | 'DBPrefix' => '',
40 | 'pConnect' => false,
41 | 'DBDebug' => (ENVIRONMENT !== 'production'),
42 | 'cacheOn' => false,
43 | 'cacheDir' => '',
44 | 'charset' => 'utf8',
45 | 'DBCollat' => 'utf8_general_ci',
46 | 'swapPre' => '',
47 | 'encrypt' => false,
48 | 'compress' => false,
49 | 'strictOn' => false,
50 | 'failover' => [],
51 | 'port' => 3306,
52 | ];
53 |
54 | /**
55 | * This database connection is used when
56 | * running PHPUnit database tests.
57 | *
58 | * @var array
59 | */
60 | public $tests = [
61 | 'DSN' => '',
62 | 'hostname' => '127.0.0.1',
63 | 'username' => '',
64 | 'password' => '',
65 | 'database' => ':memory:',
66 | 'DBDriver' => 'SQLite3',
67 | 'DBPrefix' => 'db_', // Needed to ensure we're working correctly with prefixes live. DO NOT REMOVE FOR CI DEVS
68 | 'pConnect' => false,
69 | 'DBDebug' => (ENVIRONMENT !== 'production'),
70 | 'cacheOn' => false,
71 | 'cacheDir' => '',
72 | 'charset' => 'utf8',
73 | 'DBCollat' => 'utf8_general_ci',
74 | 'swapPre' => '',
75 | 'encrypt' => false,
76 | 'compress' => false,
77 | 'strictOn' => false,
78 | 'failover' => [],
79 | 'port' => 3306,
80 | ];
81 |
82 | //--------------------------------------------------------------------
83 |
84 | public function __construct()
85 | {
86 | parent::__construct();
87 |
88 | // Ensure that we always set the database group to 'tests' if
89 | // we are currently running an automated test suite, so that
90 | // we don't overwrite live data on accident.
91 | if (ENVIRONMENT === 'testing')
92 | {
93 | $this->defaultGroup = 'tests';
94 |
95 | // Under Travis-CI, we can set an ENV var named 'DB_GROUP'
96 | // so that we can test against multiple databases.
97 | if ($group = getenv('DB'))
98 | {
99 | if (is_file(TESTPATH . 'travis/Database.php'))
100 | {
101 | require TESTPATH . 'travis/Database.php';
102 |
103 | if (! empty($dbconfig) && array_key_exists($group, $dbconfig))
104 | {
105 | $this->tests = $dbconfig[$group];
106 | }
107 | }
108 | }
109 | }
110 | }
111 |
112 | //--------------------------------------------------------------------
113 |
114 | }
115 |
--------------------------------------------------------------------------------
/app/Config/Email.php:
--------------------------------------------------------------------------------
1 | extend('layout/templates'); ?>
2 |
3 | = $this->Section('content'); ?>
4 |
5 |
6 |
7 |
8 |
Dashboard
9 |
10 | Dashboard
11 |
12 |
13 |
14 |
15 |
Primary Card
16 |
20 |
21 |
22 |
23 |
24 |
Warning Card
25 |
29 |
30 |
31 |
32 |
33 |
Success Card
34 |
38 |
39 |
40 |
41 |
42 |
Danger Card
43 |
47 |
48 |
49 |
50 |
70 |
71 |
72 |
73 | = $this->endSection(); ?>
--------------------------------------------------------------------------------
/app/Views/ajax/view_data.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | No
6 | Name
7 | Description
8 | Price
9 | Date
10 | Option
11 |
12 |
13 |
14 |
16 |
17 | = $no++; ?>
18 | = esc($datas['name']); ?>
19 | = esc($datas['description']); ?>
20 | = esc($datas['price']); ?>
21 | = esc($datas['date']); ?>
22 |
23 |
24 | Update
25 |
26 |
27 |
28 | Delete
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/app/Views/errors/html/debug.js:
--------------------------------------------------------------------------------
1 | //--------------------------------------------------------------------
2 | // Tabs
3 | //--------------------------------------------------------------------
4 |
5 | var tabLinks = new Array();
6 | var contentDivs = new Array();
7 |
8 | function init ()
9 | {
10 |
11 | // Grab the tab links and content divs from the page
12 | var tabListItems = document.getElementById('tabs').childNodes;
13 | console.log(tabListItems);
14 | for (var i = 0; i < tabListItems.length; i ++)
15 | {
16 | if (tabListItems[i].nodeName == "LI")
17 | {
18 | var tabLink = getFirstChildWithTagName(tabListItems[i], 'A');
19 | var id = getHash(tabLink.getAttribute('href'));
20 | tabLinks[id] = tabLink;
21 | contentDivs[id] = document.getElementById(id);
22 | }
23 | }
24 |
25 | // Assign onclick events to the tab links, and
26 | // highlight the first tab
27 | var i = 0;
28 |
29 | for (var id in tabLinks)
30 | {
31 | tabLinks[id].onclick = showTab;
32 | tabLinks[id].onfocus = function () { this.blur() };
33 | if (i == 0)
34 | {
35 | tabLinks[id].className = 'active';
36 | }
37 | i ++;
38 | }
39 |
40 | // Hide all content divs except the first
41 | var i = 0;
42 |
43 | for (var id in contentDivs)
44 | {
45 | if (i != 0)
46 | {
47 | console.log(contentDivs[id]);
48 | contentDivs[id].className = 'content hide';
49 | }
50 | i ++;
51 | }
52 | }
53 |
54 | //--------------------------------------------------------------------
55 |
56 | function showTab ()
57 | {
58 | var selectedId = getHash(this.getAttribute('href'));
59 |
60 | // Highlight the selected tab, and dim all others.
61 | // Also show the selected content div, and hide all others.
62 | for (var id in contentDivs)
63 | {
64 | if (id == selectedId)
65 | {
66 | tabLinks[id].className = 'active';
67 | contentDivs[id].className = 'content';
68 | }
69 | else
70 | {
71 | tabLinks[id].className = '';
72 | contentDivs[id].className = 'content hide';
73 | }
74 | }
75 |
76 | // Stop the browser following the link
77 | return false;
78 | }
79 |
80 | //--------------------------------------------------------------------
81 |
82 | function getFirstChildWithTagName (element, tagName)
83 | {
84 | for (var i = 0; i < element.childNodes.length; i ++)
85 | {
86 | if (element.childNodes[i].nodeName == tagName)
87 | {
88 | return element.childNodes[i];
89 | }
90 | }
91 | }
92 |
93 | //--------------------------------------------------------------------
94 |
95 | function getHash (url)
96 | {
97 | var hashPos = url.lastIndexOf('#');
98 | return url.substring(hashPos + 1);
99 | }
100 |
101 | //--------------------------------------------------------------------
102 |
103 | function toggle (elem)
104 | {
105 | elem = document.getElementById(elem);
106 |
107 | if (elem.style && elem.style['display'])
108 | {
109 | // Only works with the "style" attr
110 | var disp = elem.style['display'];
111 | }
112 | else if (elem.currentStyle)
113 | {
114 | // For MSIE, naturally
115 | var disp = elem.currentStyle['display'];
116 | }
117 | else if (window.getComputedStyle)
118 | {
119 | // For most other browsers
120 | var disp = document.defaultView.getComputedStyle(elem, null).getPropertyValue('display');
121 | }
122 |
123 | // Toggle the state of the "display" style
124 | elem.style.display = disp == 'block' ? 'none' : 'block';
125 |
126 | return false;
127 | }
--------------------------------------------------------------------------------
/env:
--------------------------------------------------------------------------------
1 | #--------------------------------------------------------------------
2 | # Example Environment Configuration file
3 | #
4 | # This file can be used as a starting point for your own
5 | # custom .env files, and contains most of the possible settings
6 | # available in a default install.
7 | #
8 | # By default, all of the settings are commented out. If you want
9 | # to override the setting, you must un-comment it by removing the '#'
10 | # at the beginning of the line.
11 | #--------------------------------------------------------------------
12 |
13 | #--------------------------------------------------------------------
14 | # ENVIRONMENT
15 | #--------------------------------------------------------------------
16 |
17 | # CI_ENVIRONMENT = production
18 |
19 | #--------------------------------------------------------------------
20 | # APP
21 | #--------------------------------------------------------------------
22 |
23 | # app.baseURL = ''
24 | # app.forceGlobalSecureRequests = false
25 |
26 | # app.sessionDriver = 'CodeIgniter\Session\Handlers\FileHandler'
27 | # app.sessionCookieName = 'ci_session'
28 | # app.sessionSavePath = NULL
29 | # app.sessionMatchIP = false
30 | # app.sessionTimeToUpdate = 300
31 | # app.sessionRegenerateDestroy = false
32 |
33 | # app.cookiePrefix = ''
34 | # app.cookieDomain = ''
35 | # app.cookiePath = '/'
36 | # app.cookieSecure = false
37 | # app.cookieHTTPOnly = false
38 |
39 | # app.CSRFProtection = false
40 | # app.CSRFTokenName = 'csrf_test_name'
41 | # app.CSRFCookieName = 'csrf_cookie_name'
42 | # app.CSRFExpire = 7200
43 | # app.CSRFRegenerate = true
44 | # app.CSRFExcludeURIs = []
45 |
46 | # app.CSPEnabled = false
47 |
48 | #--------------------------------------------------------------------
49 | # DATABASE
50 | #--------------------------------------------------------------------
51 |
52 | # database.default.hostname = localhost
53 | # database.default.database = ci4
54 | # database.default.username = root
55 | # database.default.password = root
56 | # database.default.DBDriver = MySQLi
57 |
58 | # database.tests.hostname = localhost
59 | # database.tests.database = ci4
60 | # database.tests.username = root
61 | # database.tests.password = root
62 | # database.tests.DBDriver = MySQLi
63 |
64 | #--------------------------------------------------------------------
65 | # CONTENT SECURITY POLICY
66 | #--------------------------------------------------------------------
67 |
68 | # contentsecuritypolicy.reportOnly = false
69 | # contentsecuritypolicy.defaultSrc = 'none'
70 | # contentsecuritypolicy.scriptSrc = 'self'
71 | # contentsecuritypolicy.styleSrc = 'self'
72 | # contentsecuritypolicy.imageSrc = 'self'
73 | # contentsecuritypolicy.base_uri = null
74 | # contentsecuritypolicy.childSrc = null
75 | # contentsecuritypolicy.connectSrc = 'self'
76 | # contentsecuritypolicy.fontSrc = null
77 | # contentsecuritypolicy.formAction = null
78 | # contentsecuritypolicy.frameAncestors = null
79 | # contentsecuritypolicy.mediaSrc = null
80 | # contentsecuritypolicy.objectSrc = null
81 | # contentsecuritypolicy.pluginTypes = null
82 | # contentsecuritypolicy.reportURI = null
83 | # contentsecuritypolicy.sandbox = false
84 | # contentsecuritypolicy.upgradeInsecureRequests = false
85 |
86 | #--------------------------------------------------------------------
87 | # ENCRYPTION
88 | #--------------------------------------------------------------------
89 |
90 | # encryption.key =
91 | # encryption.driver = OpenSSL
92 |
93 | #--------------------------------------------------------------------
94 | # HONEYPOT
95 | #--------------------------------------------------------------------
96 |
97 | # honeypot.hidden = 'true'
98 | # honeypot.label = 'Fill This Field'
99 | # honeypot.name = 'honeypot'
100 | # honeypot.template = '
{label} '
101 | # honeypot.container = '
{template}
'
102 |
--------------------------------------------------------------------------------
/app/Config/Cache.php:
--------------------------------------------------------------------------------
1 | '127.0.0.1',
82 | 'port' => 11211,
83 | 'weight' => 1,
84 | 'raw' => false,
85 | ];
86 |
87 | /*
88 | | -------------------------------------------------------------------------
89 | | Redis settings
90 | | -------------------------------------------------------------------------
91 | | Your Redis server can be specified below, if you are using
92 | | the Redis or Predis drivers.
93 | |
94 | */
95 | public $redis = [
96 | 'host' => '127.0.0.1',
97 | 'password' => null,
98 | 'port' => 6379,
99 | 'timeout' => 0,
100 | 'database' => 0,
101 | ];
102 |
103 | /*
104 | |--------------------------------------------------------------------------
105 | | Available Cache Handlers
106 | |--------------------------------------------------------------------------
107 | |
108 | | This is an array of cache engine alias' and class names. Only engines
109 | | that are listed here are allowed to be used.
110 | |
111 | */
112 | public $validHandlers = [
113 | 'dummy' => \CodeIgniter\Cache\Handlers\DummyHandler::class,
114 | 'file' => \CodeIgniter\Cache\Handlers\FileHandler::class,
115 | 'memcached' => \CodeIgniter\Cache\Handlers\MemcachedHandler::class,
116 | 'predis' => \CodeIgniter\Cache\Handlers\PredisHandler::class,
117 | 'redis' => \CodeIgniter\Cache\Handlers\RedisHandler::class,
118 | 'wincache' => \CodeIgniter\Cache\Handlers\WincacheHandler::class,
119 | ];
120 | }
121 |
--------------------------------------------------------------------------------
/app/Controllers/Objects.php:
--------------------------------------------------------------------------------
1 | objectModel = new ObjectModel();
14 | helper('form');
15 | }
16 |
17 | public function index()
18 | {
19 | $data = [
20 | 'title' => 'CRUD Object Model',
21 | 'all_data' => $this->objectModel->findAll()
22 | ];
23 |
24 | return view('objects/index', $data);
25 | }
26 |
27 | public function add_data()
28 | {
29 | $data['title'] = 'Add Data';
30 | if ($this->request->getPost()) {
31 | $rules = [
32 | 'name' => 'required|alpha_space',
33 | 'gender' => 'required',
34 | 'address' => 'required',
35 | 'photo' => 'uploaded[photo]|max_size[photo,2048]|is_image[photo]|mime_in[photo,image/jpg,image/jpeg,image/png]'
36 | ];
37 |
38 | if ($this->validate($rules)) {
39 | $photo = $this->request->getFile('photo');
40 | $photoName = $photo->getRandomName();
41 | $photo->move('photos', $photoName);
42 |
43 | $inserted = [
44 | 'name' => $this->request->getPost('name'),
45 | 'gender' => $this->request->getPost('gender'),
46 | 'address' => $this->request->getPost('address'),
47 | 'photo' => $photoName
48 | ];
49 |
50 | $this->objectModel->insert($inserted);
51 | session()->setFlashData('success', 'data has been added to database');
52 | return redirect()->to('/objects');
53 | } else {
54 | session()->setFlashData('failed', \Config\Services::validation()->getErrors());
55 | return redirect()->back()->withInput();
56 | }
57 | }
58 | return view('objects/form_add', $data);
59 | }
60 |
61 | public function delete_data($id)
62 | {
63 | $photoId = $this->objectModel->find($id);
64 | unlink('photos/'.$photoId['photo']);
65 |
66 | $this->objectModel->delete($id);
67 | session()->setFlashData('success', 'data has been deleted from database.');
68 | return redirect()->to('/objects');
69 | }
70 |
71 | public function update_data($id)
72 | {
73 | $data = [
74 | 'title' => 'Update Data',
75 | 'dataById' => $this->objectModel->where('id', $id)->first()
76 | ];
77 |
78 | if ($this->request->getPost()) {
79 | $rules = [
80 | 'name' => 'required|alpha_space',
81 | 'gender' => 'required',
82 | 'address' => 'required',
83 | 'photo' => 'max_size[photo,2048]|is_image[photo]|mime_in[photo,image/jpg,image/jpeg,image/png]'
84 | ];
85 |
86 | if ($this->validate($rules)) {
87 | $photo = $this->request->getFile('photo');
88 | if ($photo->getError() == 4) {
89 | $photoName = $this->request->getPost('Oldphoto');
90 | } else {
91 | $photoName = $photo->getRandomName();
92 | $photo->move('photos', $photoName);
93 | $photo = $this->objectModel->find($id);
94 | if ($photo['photo'] == $photo['photo']) {
95 | unlink('photos/' . $this->request->getPost('Oldphoto'));
96 | }
97 | }
98 |
99 | $inserted = [
100 | 'name' => $this->request->getPost('name'),
101 | 'gender' => $this->request->getPost('gender'),
102 | 'address' => $this->request->getPost('address'),
103 | 'photo' => $photoName
104 | ];
105 |
106 | $this->objectModel->update($id, $inserted);
107 | session()->setFlashData('success', 'data has been updated from database');
108 | return redirect()->to('/objects');
109 | } else {
110 | session()->setFlashData('failed', \Config\Services::validation()->getErrors());
111 | return redirect()->back()->withInput();
112 | }
113 | }
114 | return view('objects/form_update', $data);
115 | }
116 | }
117 |
--------------------------------------------------------------------------------
/app/Views/objects/form_add.php:
--------------------------------------------------------------------------------
1 | = $this->extend('layout/templates'); ?>
2 |
3 | = $this->Section('content'); ?>
4 |
5 |
6 |
7 |
CRUD Object Model
8 |
9 | Dashboard
10 | CRUD Object Model
11 | Add data
12 |
13 |
14 |
18 |
19 | getFlashdata('failed');
21 | if (!empty($errors)) : ?>
22 |
23 |
Failed data not added to database.
24 |
25 |
26 | = esc($e); ?>
27 |
28 |
29 |
30 | ×
31 |
32 |
33 |
34 |
35 |
37 |
38 |
Failed data not added to database.
39 |
40 | = $validation->listErrors() ?>
41 |
42 |
43 | ×
44 |
45 |
46 |
47 |
48 | = form_open_multipart(); ?>
49 | = csrf_field(); ?>
50 |
51 | Name
52 |
53 |
54 |
69 |
70 | Address
71 |
72 |
73 |
74 | Photo
75 |
76 |
77 |
Submit
78 |
Back
79 | = form_close(); ?>
80 |
81 |
82 |
83 |
84 | = $this->endSection(); ?>
--------------------------------------------------------------------------------
/app/Controllers/Ajax.php:
--------------------------------------------------------------------------------
1 | ajax = new AjaxModel();
15 | }
16 |
17 | public function index()
18 | {
19 | $data = [
20 | 'title' => 'CRUD Ajax jQuery'
21 | ];
22 |
23 | return view('ajax/index', $data);
24 | }
25 |
26 | public function get_data()
27 | {
28 | if ($this->request->isAJAX()) {
29 | $data = [
30 | 'data_products' => $this->ajax->findAll()
31 | ];
32 |
33 | $result = [
34 | 'output' => view('ajax/view_data', $data)
35 | ];
36 |
37 | echo json_encode($result);
38 | } else {
39 | exit('404 Not Found');
40 | }
41 | }
42 |
43 | public function get_modal()
44 | {
45 | if ($this->request->isAJAX()) {
46 | $result = [
47 | 'output' => view('ajax/view_modal')
48 | ];
49 |
50 | echo json_encode($result);
51 | } else {
52 | exit('404 Not Found');
53 | }
54 | }
55 |
56 | public function save_data()
57 | {
58 | if ($this->request->isAJAX()) {
59 | $validation = \Config\Services::validation();
60 |
61 | $rules = $this->validate([
62 | 'name' => [
63 | 'label' => 'product name',
64 | 'rules' => 'required|min_length[3]',
65 | ],
66 | 'description' => [
67 | 'label' => 'product desc',
68 | 'rules' => 'required|min_length[3]',
69 | ],
70 | 'price' => [
71 | 'label' => 'product price',
72 | 'rules' => 'required|numeric',
73 | ],
74 | 'date' => [
75 | 'label' => 'product date',
76 | 'rules' => 'required',
77 | ]
78 | ]);
79 |
80 | if (!$rules) {
81 | $result = [
82 | 'error' => [
83 | 'name' => $validation->getError('name'),
84 | 'description' => $validation->getError('description'),
85 | 'price' => $validation->getError('price'),
86 | 'date' => $validation->getError('date')
87 | ]
88 | ];
89 | } else {
90 | $this->ajax->insert([
91 | 'name' => strip_tags($this->request->getPost('name')),
92 | 'description' => strip_tags($this->request->getPost('description')),
93 | 'price' => strip_tags($this->request->getPost('price')),
94 | 'date' => strip_tags($this->request->getPost('date'))
95 | ]);
96 |
97 | $result = [
98 | 'success' => 'Data has been added to database'
99 | ];
100 | }
101 | echo json_encode($result);
102 | } else {
103 | exit('404 Not Found');
104 | }
105 | }
106 |
107 | public function get_modal_edit()
108 | {
109 | if ($this->request->isAJAX()) {
110 | $id = $this->request->getVar('id');
111 |
112 | $row = $this->ajax->find($id);
113 |
114 | $data = [
115 | 'id' => $row['id'],
116 | 'name' => $row['name'],
117 | 'description' => $row['description'],
118 | 'price' => $row['price'],
119 | 'date' => $row['date']
120 | ];
121 |
122 | $result = [
123 | 'output' => view('ajax/view_modal_edit', $data)
124 | ];
125 |
126 | echo json_encode($result);
127 | } else {
128 | exit('404 Not Found');
129 | }
130 | }
131 |
132 | public function update_data()
133 | {
134 | if ($this->request->isAJAX()) {
135 | $validation = \Config\Services::validation();
136 |
137 | $rules = $this->validate([
138 | 'name' => [
139 | 'label' => 'product name',
140 | 'rules' => 'required|min_length[3]',
141 | ],
142 | 'description' => [
143 | 'label' => 'product desc',
144 | 'rules' => 'required|min_length[3]',
145 | ],
146 | 'price' => [
147 | 'label' => 'product price',
148 | 'rules' => 'required|numeric',
149 | ],
150 | 'date' => [
151 | 'label' => 'product date',
152 | 'rules' => 'required',
153 | ]
154 | ]);
155 |
156 | if (!$rules) {
157 | $result = [
158 | 'error' => [
159 | 'name' => $validation->getError('name'),
160 | 'description' => $validation->getError('description'),
161 | 'price' => $validation->getError('price'),
162 | 'date' => $validation->getError('date')
163 | ]
164 | ];
165 | } else {
166 | $id = $this->request->getPost('id');
167 | $this->ajax->update($id, [
168 | 'name' => strip_tags($this->request->getPost('name')),
169 | 'description' => strip_tags($this->request->getPost('description')),
170 | 'price' => strip_tags($this->request->getPost('price')),
171 | 'date' => strip_tags($this->request->getPost('date'))
172 | ]);
173 |
174 | $result = [
175 | 'success' => 'Data has been updated from database'
176 | ];
177 | }
178 | echo json_encode($result);
179 | } else {
180 | exit('404 Not Found');
181 | }
182 | }
183 |
184 | public function delete_data()
185 | {
186 | if ($this->request->isAJAX()) {
187 | $id = $this->request->getVar('id');
188 |
189 | $this->ajax->delete($id);
190 |
191 | $result = [
192 | 'output' => "Data has been deleted from database"
193 | ];
194 |
195 | echo json_encode($result);
196 | } else {
197 | exit('404 Not Found');
198 | }
199 | }
200 | }
201 |
--------------------------------------------------------------------------------
/app/Config/Logger.php:
--------------------------------------------------------------------------------
1 | [
79 |
80 | /*
81 | * The log levels that this handler will handle.
82 | */
83 | 'handles' => [
84 | 'critical',
85 | 'alert',
86 | 'emergency',
87 | 'debug',
88 | 'error',
89 | 'info',
90 | 'notice',
91 | 'warning',
92 | ],
93 |
94 | /*
95 | * The default filename extension for log files.
96 | * An extension of 'php' allows for protecting the log files via basic
97 | * scripting, when they are to be stored under a publicly accessible directory.
98 | *
99 | * Note: Leaving it blank will default to 'log'.
100 | */
101 | 'fileExtension' => '',
102 |
103 | /*
104 | * The file system permissions to be applied on newly created log files.
105 | *
106 | * IMPORTANT: This MUST be an integer (no quotes) and you MUST use octal
107 | * integer notation (i.e. 0700, 0644, etc.)
108 | */
109 | 'filePermissions' => 0644,
110 |
111 | /*
112 | * Logging Directory Path
113 | *
114 | * By default, logs are written to WRITEPATH . 'logs/'
115 | * Specify a different destination here, if desired.
116 | */
117 | 'path' => '',
118 | ],
119 |
120 | /**
121 | * The ChromeLoggerHandler requires the use of the Chrome web browser
122 | * and the ChromeLogger extension. Uncomment this block to use it.
123 | */
124 | // 'CodeIgniter\Log\Handlers\ChromeLoggerHandler' => [
125 | // /*
126 | // * The log levels that this handler will handle.
127 | // */
128 | // 'handles' => ['critical', 'alert', 'emergency', 'debug',
129 | // 'error', 'info', 'notice', 'warning'],
130 | // ]
131 | ];
132 | }
133 |
--------------------------------------------------------------------------------
/tests/README.md:
--------------------------------------------------------------------------------
1 | # Running Application Tests
2 |
3 | This is the quick-start to CodeIgniter testing. Its intent is to describe what
4 | it takes to set up your application and get it ready to run unit tests.
5 | It is not intended to be a full description of the test features that you can
6 | use to test your application. Those details can be found in the documentation.
7 |
8 | ## Resources
9 | * [CodeIgniter 4 User Guide on Testing](https://codeigniter4.github.io/userguide/testing/index.html)
10 | * [PHPUnit docs](https://phpunit.readthedocs.io/en/8.3/index.html)
11 |
12 | ## Requirements
13 |
14 | It is recommended to use the latest version of PHPUnit. At the time of this
15 | writing we are running version 8.5.2. Support for this has been built into the
16 | **composer.json** file that ships with CodeIgniter and can easily be installed
17 | via [Composer](https://getcomposer.org/) if you don't already have it installed globally.
18 |
19 | > composer install
20 |
21 | If running under OS X or Linux, you can create a symbolic link to make running tests a touch nicer.
22 |
23 | > ln -s ./vendor/bin/phpunit ./phpunit
24 |
25 | You also need to install [XDebug](https://xdebug.org/index.php) in order
26 | for code coverage to be calculated successfully.
27 |
28 | ## Setting Up
29 |
30 | A number of the tests use a running database.
31 | In order to set up the database edit the details for the `tests` group in
32 | **app/Config/Database.php** or **phpunit.xml**. Make sure that you provide a database engine
33 | that is currently running on your machine. More details on a test database setup are in the
34 | *Docs>>Testing>>Testing Your Database* section of the documentation.
35 |
36 | If you want to run the tests without using live database you can
37 | exclude @DatabaseLive group. Or make a copy of **phpunit.dist.xml** -
38 | call it **phpunit.xml** - and comment out the
named "database". This will make
39 | the tests run quite a bit faster.
40 |
41 | ## Running the tests
42 |
43 | The entire test suite can be run by simply typing one command-line command from the main directory.
44 |
45 | > ./phpunit
46 |
47 | You can limit tests to those within a single test directory by specifying the
48 | directory name after phpunit.
49 |
50 | > ./phpunit app/Models
51 |
52 | ## Generating Code Coverage
53 |
54 | To generate coverage information, including HTML reports you can view in your browser,
55 | you can use the following command:
56 |
57 | > ./phpunit --colors --coverage-text=tests/coverage.txt --coverage-html=tests/coverage/ -d memory_limit=1024m
58 |
59 | This runs all of the tests again collecting information about how many lines,
60 | functions, and files are tested. It also reports the percentage of the code that is covered by tests.
61 | It is collected in two formats: a simple text file that provides an overview as well
62 | as a comprehensive collection of HTML files that show the status of every line of code in the project.
63 |
64 | The text file can be found at **tests/coverage.txt**.
65 | The HTML files can be viewed by opening **tests/coverage/index.html** in your favorite browser.
66 |
67 | ## PHPUnit XML Configuration
68 |
69 | The repository has a ``phpunit.xml.dist`` file in the project root that's used for
70 | PHPUnit configuration. This is used to provide a default configuration if you
71 | do not have your own configuration file in the project root.
72 |
73 | The normal practice would be to copy ``phpunit.xml.dist`` to ``phpunit.xml``
74 | (which is git ignored), and to tailor it as you see fit.
75 | For instance, you might wish to exclude database tests, or automatically generate
76 | HTML code coverage reports.
77 |
78 | ## Test Cases
79 |
80 | Every test needs a *test case*, or class that your tests extend. CodeIgniter 4
81 | provides a few that you may use directly:
82 | * `CodeIgniter\Test\CIUnitTestCase` - for basic tests with no other service needs
83 | * `CodeIgniter\Test\CIDatabaseTestCase` - for tests that need database access
84 |
85 | Most of the time you will want to write your own test cases to hold functions and services
86 | common to your test suites.
87 |
88 | ## Creating Tests
89 |
90 | All tests go in the **tests/** directory. Each test file is a class that extends a
91 | **Test Case** (see above) and contains methods for the individual tests. These method
92 | names must start with the word "test" and should have descriptive names for precisely what
93 | they are testing:
94 | `testUserCanModifyFile()` `testOutputColorMatchesInput()` `testIsLoggedInFailsWithInvalidUser()`
95 |
96 | Writing tests is an art, and there are many resources available to help learn how.
97 | Review the links above and always pay attention to your code coverage.
98 |
99 | ### Database Tests
100 |
101 | Tests can include migrating, seeding, and testing against a mock or live1 database.
102 | Be sure to modify the test case (or create your own) to point to your seed and migrations
103 | and include any additional steps to be run before tests in the `setUp()` method.
104 |
105 | 1 Note: If you are using database tests that require a live database connection
106 | you will need to rename **phpunit.xml.dist** to **phpunit.xml**, uncomment the database
107 | configuration lines and add your connection details. Prevent **phpunit.xml** from being
108 | tracked in your repo by adding it to **.gitignore**.
109 |
--------------------------------------------------------------------------------
/public/assets/img/error-404-monochrome.svg:
--------------------------------------------------------------------------------
1 | error-404-monochrome
--------------------------------------------------------------------------------
/app/Views/objects/form_update.php:
--------------------------------------------------------------------------------
1 | = $this->extend('layout/templates'); ?>
2 |
3 | = $this->Section('content'); ?>
4 |
5 |
6 |
7 |
CRUD Object Model
8 |
9 | Dashboard
10 | CRUD Object Model
11 | Update data
12 |
13 |
14 |
18 |
19 | getFlashdata('failed');
21 | if (!empty($errors)) : ?>
22 |
23 |
Failed data not added to database.
24 |
25 |
26 | = esc($e); ?>
27 |
28 |
29 |
30 | ×
31 |
32 |
33 |
34 |
35 |
37 |
38 |
Failed data not added to database.
39 |
40 | = $validation->listErrors() ?>
41 |
42 |
43 | ×
44 |
45 |
46 |
47 |
48 | = form_open_multipart(); ?>
49 | = csrf_field(); ?>
50 |
51 |
52 |
53 | Name
54 |
55 |
56 |
86 |
87 | Address
88 |
89 |
90 |
91 | Photo
92 |
93 |
94 |
Previous photo
95 |
Submit
96 |
Back
97 | = form_close(); ?>
98 |
99 |
100 |
101 |
102 | = $this->endSection(); ?>
--------------------------------------------------------------------------------
/app/Views/ajax/view_modal.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
11 | = form_open('ajax-jquery/save_data', ['class' => 'form-add']); ?>
12 | = csrf_field(); ?>
13 |
14 |
23 |
24 |
33 |
34 |
43 |
44 |
53 |
54 |
58 | = form_close(); ?>
59 |
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/app/Views/objects/index.php:
--------------------------------------------------------------------------------
1 | = $this->extend('layout/templates'); ?>
2 |
3 | = $this->Section('content'); ?>
4 |
5 |
6 |
7 |
CRUD Object Model
8 |
9 | Dashboard
10 | = $title; ?>
11 |
12 |
13 |
17 |
18 |
Add data
19 |
20 | getFlashdata('failed');
22 | if (!empty($errors)) : ?>
23 |
24 |
Failed data not added to database.
25 |
26 |
27 | = esc($e); ?>
28 |
29 |
30 |
31 | ×
32 |
33 |
34 |
35 |
36 | getFlashData('success')) : ?>
37 |
38 | Success = session()->getFlashData('success'); ?>
39 |
40 | ×
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 | No
49 | Name
50 | Gender
51 | Address
52 | Photo
53 | Option
54 |
55 |
56 |
57 |
59 |
60 | = $no++; ?>
61 | = esc($datas['name']); ?>
62 | = esc($datas['gender']); ?>
63 | = esc($datas['address']); ?>
64 |
65 |
66 |
67 |
68 |
69 | Update
70 |
71 |
72 | Delete
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
96 |
97 | = form_open('objects/delete_data/'.$datas['id']); ?>
98 | = csrf_field(); ?>
99 |
100 |
Click the submit button to delete data (= $datas['name']; ?>)..!!!
101 |
105 | = form_close(); ?>
106 |
107 |
108 |
109 |
110 |
111 | = $this->endSection(); ?>
--------------------------------------------------------------------------------
/app/Views/ajax/view_modal_edit.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
11 | = form_open('ajax-jquery/update_data', ['class' => 'form-edit']); ?>
12 | = csrf_field(); ?>
13 |
14 |
15 |
24 |
25 |
34 |
35 |
44 |
45 |
54 |
55 |
59 | = form_close(); ?>
60 |
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/app/Views/layout/templates.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
= $title; ?>
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | CodeIgniter 4
23 |
24 |
25 |
33 |
34 |
44 |
45 |
46 | = $this->include('layout/sidebar'); ?>
47 |
48 |
49 | = $this->renderSection('content'); ?>
50 |
51 |
52 |
53 |
54 |
55 |
Development with = date('Y'); ?>
56 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
85 |
86 | Are you sure..?, Please click the 'logout button'...
87 |
88 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
106 |
107 | Email : = user()->email; ?>
108 | Username : = user()->username; ?>
109 |
110 |
113 |
114 |
115 |
116 |
117 |
118 |
--------------------------------------------------------------------------------
/app/Config/UserAgents.php:
--------------------------------------------------------------------------------
1 | 'Windows 10',
18 | 'windows nt 6.3' => 'Windows 8.1',
19 | 'windows nt 6.2' => 'Windows 8',
20 | 'windows nt 6.1' => 'Windows 7',
21 | 'windows nt 6.0' => 'Windows Vista',
22 | 'windows nt 5.2' => 'Windows 2003',
23 | 'windows nt 5.1' => 'Windows XP',
24 | 'windows nt 5.0' => 'Windows 2000',
25 | 'windows nt 4.0' => 'Windows NT 4.0',
26 | 'winnt4.0' => 'Windows NT 4.0',
27 | 'winnt 4.0' => 'Windows NT',
28 | 'winnt' => 'Windows NT',
29 | 'windows 98' => 'Windows 98',
30 | 'win98' => 'Windows 98',
31 | 'windows 95' => 'Windows 95',
32 | 'win95' => 'Windows 95',
33 | 'windows phone' => 'Windows Phone',
34 | 'windows' => 'Unknown Windows OS',
35 | 'android' => 'Android',
36 | 'blackberry' => 'BlackBerry',
37 | 'iphone' => 'iOS',
38 | 'ipad' => 'iOS',
39 | 'ipod' => 'iOS',
40 | 'os x' => 'Mac OS X',
41 | 'ppc mac' => 'Power PC Mac',
42 | 'freebsd' => 'FreeBSD',
43 | 'ppc' => 'Macintosh',
44 | 'linux' => 'Linux',
45 | 'debian' => 'Debian',
46 | 'sunos' => 'Sun Solaris',
47 | 'beos' => 'BeOS',
48 | 'apachebench' => 'ApacheBench',
49 | 'aix' => 'AIX',
50 | 'irix' => 'Irix',
51 | 'osf' => 'DEC OSF',
52 | 'hp-ux' => 'HP-UX',
53 | 'netbsd' => 'NetBSD',
54 | 'bsdi' => 'BSDi',
55 | 'openbsd' => 'OpenBSD',
56 | 'gnu' => 'GNU/Linux',
57 | 'unix' => 'Unknown Unix OS',
58 | 'symbian' => 'Symbian OS',
59 | ];
60 |
61 | // The order of this array should NOT be changed. Many browsers return
62 | // multiple browser types so we want to identify the sub-type first.
63 | public $browsers = [
64 | 'OPR' => 'Opera',
65 | 'Flock' => 'Flock',
66 | 'Edge' => 'Spartan',
67 | 'Chrome' => 'Chrome',
68 | // Opera 10+ always reports Opera/9.80 and appends Version/ to the user agent string
69 | 'Opera.*?Version' => 'Opera',
70 | 'Opera' => 'Opera',
71 | 'MSIE' => 'Internet Explorer',
72 | 'Internet Explorer' => 'Internet Explorer',
73 | 'Trident.* rv' => 'Internet Explorer',
74 | 'Shiira' => 'Shiira',
75 | 'Firefox' => 'Firefox',
76 | 'Chimera' => 'Chimera',
77 | 'Phoenix' => 'Phoenix',
78 | 'Firebird' => 'Firebird',
79 | 'Camino' => 'Camino',
80 | 'Netscape' => 'Netscape',
81 | 'OmniWeb' => 'OmniWeb',
82 | 'Safari' => 'Safari',
83 | 'Mozilla' => 'Mozilla',
84 | 'Konqueror' => 'Konqueror',
85 | 'icab' => 'iCab',
86 | 'Lynx' => 'Lynx',
87 | 'Links' => 'Links',
88 | 'hotjava' => 'HotJava',
89 | 'amaya' => 'Amaya',
90 | 'IBrowse' => 'IBrowse',
91 | 'Maxthon' => 'Maxthon',
92 | 'Ubuntu' => 'Ubuntu Web Browser',
93 | 'Vivaldi' => 'Vivaldi',
94 | ];
95 |
96 | public $mobiles = [
97 | // legacy array, old values commented out
98 | 'mobileexplorer' => 'Mobile Explorer',
99 | // 'openwave' => 'Open Wave',
100 | // 'opera mini' => 'Opera Mini',
101 | // 'operamini' => 'Opera Mini',
102 | // 'elaine' => 'Palm',
103 | 'palmsource' => 'Palm',
104 | // 'digital paths' => 'Palm',
105 | // 'avantgo' => 'Avantgo',
106 | // 'xiino' => 'Xiino',
107 | 'palmscape' => 'Palmscape',
108 | // 'nokia' => 'Nokia',
109 | // 'ericsson' => 'Ericsson',
110 | // 'blackberry' => 'BlackBerry',
111 | // 'motorola' => 'Motorola'
112 |
113 | // Phones and Manufacturers
114 | 'motorola' => 'Motorola',
115 | 'nokia' => 'Nokia',
116 | 'palm' => 'Palm',
117 | 'iphone' => 'Apple iPhone',
118 | 'ipad' => 'iPad',
119 | 'ipod' => 'Apple iPod Touch',
120 | 'sony' => 'Sony Ericsson',
121 | 'ericsson' => 'Sony Ericsson',
122 | 'blackberry' => 'BlackBerry',
123 | 'cocoon' => 'O2 Cocoon',
124 | 'blazer' => 'Treo',
125 | 'lg' => 'LG',
126 | 'amoi' => 'Amoi',
127 | 'xda' => 'XDA',
128 | 'mda' => 'MDA',
129 | 'vario' => 'Vario',
130 | 'htc' => 'HTC',
131 | 'samsung' => 'Samsung',
132 | 'sharp' => 'Sharp',
133 | 'sie-' => 'Siemens',
134 | 'alcatel' => 'Alcatel',
135 | 'benq' => 'BenQ',
136 | 'ipaq' => 'HP iPaq',
137 | 'mot-' => 'Motorola',
138 | 'playstation portable' => 'PlayStation Portable',
139 | 'playstation 3' => 'PlayStation 3',
140 | 'playstation vita' => 'PlayStation Vita',
141 | 'hiptop' => 'Danger Hiptop',
142 | 'nec-' => 'NEC',
143 | 'panasonic' => 'Panasonic',
144 | 'philips' => 'Philips',
145 | 'sagem' => 'Sagem',
146 | 'sanyo' => 'Sanyo',
147 | 'spv' => 'SPV',
148 | 'zte' => 'ZTE',
149 | 'sendo' => 'Sendo',
150 | 'nintendo dsi' => 'Nintendo DSi',
151 | 'nintendo ds' => 'Nintendo DS',
152 | 'nintendo 3ds' => 'Nintendo 3DS',
153 | 'wii' => 'Nintendo Wii',
154 | 'open web' => 'Open Web',
155 | 'openweb' => 'OpenWeb',
156 |
157 | // Operating Systems
158 | 'android' => 'Android',
159 | 'symbian' => 'Symbian',
160 | 'SymbianOS' => 'SymbianOS',
161 | 'elaine' => 'Palm',
162 | 'series60' => 'Symbian S60',
163 | 'windows ce' => 'Windows CE',
164 |
165 | // Browsers
166 | 'obigo' => 'Obigo',
167 | 'netfront' => 'Netfront Browser',
168 | 'openwave' => 'Openwave Browser',
169 | 'mobilexplorer' => 'Mobile Explorer',
170 | 'operamini' => 'Opera Mini',
171 | 'opera mini' => 'Opera Mini',
172 | 'opera mobi' => 'Opera Mobile',
173 | 'fennec' => 'Firefox Mobile',
174 |
175 | // Other
176 | 'digital paths' => 'Digital Paths',
177 | 'avantgo' => 'AvantGo',
178 | 'xiino' => 'Xiino',
179 | 'novarra' => 'Novarra Transcoder',
180 | 'vodafone' => 'Vodafone',
181 | 'docomo' => 'NTT DoCoMo',
182 | 'o2' => 'O2',
183 |
184 | // Fallback
185 | 'mobile' => 'Generic Mobile',
186 | 'wireless' => 'Generic Mobile',
187 | 'j2me' => 'Generic Mobile',
188 | 'midp' => 'Generic Mobile',
189 | 'cldc' => 'Generic Mobile',
190 | 'up.link' => 'Generic Mobile',
191 | 'up.browser' => 'Generic Mobile',
192 | 'smartphone' => 'Generic Mobile',
193 | 'cellphone' => 'Generic Mobile',
194 | ];
195 |
196 | // There are hundreds of bots but these are the most common.
197 | public $robots = [
198 | 'googlebot' => 'Googlebot',
199 | 'msnbot' => 'MSNBot',
200 | 'baiduspider' => 'Baiduspider',
201 | 'bingbot' => 'Bing',
202 | 'slurp' => 'Inktomi Slurp',
203 | 'yahoo' => 'Yahoo',
204 | 'ask jeeves' => 'Ask Jeeves',
205 | 'fastcrawler' => 'FastCrawler',
206 | 'infoseek' => 'InfoSeek Robot 1.0',
207 | 'lycos' => 'Lycos',
208 | 'yandex' => 'YandexBot',
209 | 'mediapartners-google' => 'MediaPartners Google',
210 | 'CRAZYWEBCRAWLER' => 'Crazy Webcrawler',
211 | 'adsbot-google' => 'AdsBot Google',
212 | 'feedfetcher-google' => 'Feedfetcher Google',
213 | 'curious george' => 'Curious George',
214 | 'ia_archiver' => 'Alexa Crawler',
215 | 'MJ12bot' => 'Majestic-12',
216 | 'Uptimebot' => 'Uptimebot',
217 | ];
218 | }
219 |
--------------------------------------------------------------------------------
/app/Config/App.php:
--------------------------------------------------------------------------------
1 |