Skip to content

Commit 7e27d5c

Browse files
committed
Extract Lite version
0 parents  commit 7e27d5c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+23077
-0
lines changed

.gitattributes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
* text=auto
2+
*.css linguist-vendored
3+
*.scss linguist-vendored
4+
*.js linguist-vendored
5+
CHANGELOG.md export-ignore

.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Codeigniter
2+
.htaccess
3+
/install
4+
/application/sessions/*
5+
/application/logs/*
6+
/vendor
7+
composer.lock
8+
9+
# OSX Specific files
10+
.DS_Store
11+
/__MACOXS
12+
13+
# custom
14+
application/config/dev
15+
application/config/live

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Addchat Codeigniter API
2+
3+
This is API for addchat vuejs app
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# ************************************************************
2+
# Sequel Pro SQL dump
3+
# Version 4541
4+
#
5+
# http://www.sequelpro.com/
6+
# https://github.com/sequelpro/sequelpro
7+
#
8+
# Host: 127.0.0.1 (MySQL 5.7.24)
9+
# Database: addchat_db
10+
# Generation Time: 2019-10-18 13:08:10 +0000
11+
# ************************************************************
12+
13+
14+
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
15+
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
16+
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
17+
/*!40101 SET NAMES utf8 */;
18+
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
19+
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
20+
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
21+
22+
23+
# Dump of table ac_messages
24+
# ------------------------------------------------------------
25+
26+
DROP TABLE IF EXISTS `ac_messages`;
27+
28+
CREATE TABLE `ac_messages` (
29+
`id` int(11) NOT NULL AUTO_INCREMENT,
30+
`m_from` int(11) NOT NULL DEFAULT '0',
31+
`m_to` int(11) NOT NULL,
32+
`message` text COLLATE utf8mb4_unicode_ci NOT NULL,
33+
`is_read` tinyint(1) NOT NULL DEFAULT '0',
34+
`m_from_delete` tinyint(1) NOT NULL DEFAULT '0',
35+
`m_to_delete` tinyint(1) NOT NULL DEFAULT '0',
36+
`dt_updated` datetime DEFAULT NULL,
37+
PRIMARY KEY (`id`)
38+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
39+
40+
41+
42+
# Dump of table ac_profiles
43+
# ------------------------------------------------------------
44+
45+
DROP TABLE IF EXISTS `ac_profiles`;
46+
47+
CREATE TABLE `ac_profiles` (
48+
`id` int(11) NOT NULL AUTO_INCREMENT,
49+
`user_id` int(11) DEFAULT NULL,
50+
`fullname` varchar(256) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
51+
`avatar` varchar(256) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
52+
`status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '0:offline;1:online;2:away;3:busy',
53+
`dt_updated` datetime DEFAULT NULL,
54+
PRIMARY KEY (`id`)
55+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
56+
57+
58+
59+
# Dump of table ac_settings
60+
# ------------------------------------------------------------
61+
62+
DROP TABLE IF EXISTS `ac_settings`;
63+
64+
CREATE TABLE `ac_settings` (
65+
`id` int(11) NOT NULL AUTO_INCREMENT,
66+
`s_name` varchar(512) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
67+
`s_value` text COLLATE utf8mb4_unicode_ci,
68+
`dt_updated` datetime DEFAULT NULL,
69+
PRIMARY KEY (`id`)
70+
) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
71+
72+
LOCK TABLES `ac_settings` WRITE;
73+
/*!40000 ALTER TABLE `ac_settings` DISABLE KEYS */;
74+
75+
INSERT INTO `ac_settings` (`id`, `s_name`, `s_value`, `dt_updated`)
76+
VALUES
77+
(1,'admin_user_id','1','2019-10-18 12:53:26'),
78+
(2,'pagination_limit','5','2019-10-18 12:53:26'),
79+
(3,'img_upload_path','upload','2019-03-06 00:00:00'),
80+
(4,'assets_path','assets','2019-10-18 12:53:26'),
81+
(5,'users_table','users','2019-10-18 12:53:26'),
82+
(6,'users_col_id','id','2019-10-18 12:53:26'),
83+
(7,'users_col_email','email','2019-10-18 12:53:26'),
84+
(8,'site_name','AddChat','2019-10-18 12:53:26'),
85+
(9,'site_logo',NULL,'2019-09-06 08:25:52'),
86+
(10,'chat_icon',NULL,'2019-09-06 08:24:20'),
87+
(11,'notification_type','0','2019-10-18 12:53:26'),
88+
(12,'footer_text','AddChat | by Classiebit','2019-10-18 12:53:26'),
89+
(13,'footer_url','https://classiebit.com/addchat-codeigniter-pro','2019-10-18 12:53:26');
90+
91+
/*!40000 ALTER TABLE `ac_settings` ENABLE KEYS */;
92+
UNLOCK TABLES;
93+
94+
95+
# Dump of table ac_users_messages
96+
# ------------------------------------------------------------
97+
98+
DROP TABLE IF EXISTS `ac_users_messages`;
99+
100+
CREATE TABLE `ac_users_messages` (
101+
`id` int(11) NOT NULL AUTO_INCREMENT,
102+
`users_id` int(11) NOT NULL,
103+
`buddy_id` int(11) NOT NULL,
104+
`messages_count` int(11) NOT NULL DEFAULT '1',
105+
PRIMARY KEY (`id`),
106+
UNIQUE KEY `users_id` (`users_id`,`buddy_id`)
107+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
108+
109+
110+
111+
112+
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
113+
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
114+
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
115+
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
116+
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
117+
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
<?php
2+
3+
class Core {
4+
5+
// Function to validate the post data
6+
function validate_post($data)
7+
{
8+
/* Validating the hostname, the database name and the username. The password is optional. */
9+
return !empty($data['hostname']) && !empty($data['username']) && !empty($data['database']);
10+
}
11+
12+
// Function to show an error
13+
function show_message($type,$message)
14+
{
15+
return $message;
16+
}
17+
18+
// Function to write the config file
19+
function write_config($data = [])
20+
{
21+
// Config path
22+
$template_path = 'src/config/addchat.php';
23+
$output_path = '../'.$data['config'].'/addchat.php';
24+
25+
// Open the source file
26+
$config_file = file_get_contents($template_path);
27+
// replace by user input
28+
$new = str_replace("%LOGGED_USER_ID%",$data['session_user_id'],$config_file);
29+
30+
// Write the new addchat.php file on the destination
31+
$handle = fopen($output_path,'w+');
32+
33+
// Chmod the file, in case the user forgot
34+
@chmod($output_path,0777);
35+
36+
// Verify file permissions
37+
if(is_writable($output_path))
38+
{
39+
// Write the file
40+
if(fwrite($handle,$new))
41+
return true;
42+
else
43+
return false;
44+
}
45+
else
46+
{
47+
return false;
48+
}
49+
50+
}
51+
52+
function transfer_files($data = [])
53+
{
54+
$transfer = array();
55+
56+
// 1. Assets
57+
$transfer[0]['source'] = 'src/assets/';
58+
$transfer[0]['path'] = 'Assets Path - '.$data['assets'];
59+
$transfer[0]['destination'] = '../'.$data['assets'].'/';
60+
$transfer[0]['file_check'] = 'addchat/index.html';
61+
$transfer[0]['make_dir'] = TRUE;
62+
63+
// 2. controller
64+
$transfer[1]['source'] = 'src/controllers/';
65+
$transfer[1]['path'] = 'Controllers Path - '.$data['controllers'];
66+
$transfer[1]['destination'] = '../'.$data['controllers'].'/';
67+
$transfer[1]['file_check'] = 'Addchat_api.php';
68+
$transfer[1]['make_dir'] = FALSE;
69+
70+
// 3. libraries
71+
$transfer[2]['source'] = 'src/libraries/';
72+
$transfer[2]['path'] = 'Libraries Path - '.$data['libraries'];
73+
$transfer[2]['destination'] = '../'.$data['libraries'].'/';
74+
$transfer[2]['file_check'] = 'Addchat_lib.php';
75+
$transfer[2]['make_dir'] = FALSE;
76+
77+
// 4. language
78+
$transfer[3]['source'] = 'src/language/';
79+
$transfer[3]['path'] = 'Language (english) Path - '.$data['language'];
80+
$transfer[3]['destination'] = '../'.$data['language'].'/';
81+
$transfer[3]['file_check'] = 'addchat_lang.php';
82+
$transfer[3]['make_dir'] = FALSE;
83+
84+
85+
// Bulk transfer
86+
foreach($transfer as $trans)
87+
{
88+
$flag = $this->xcopy($trans);
89+
90+
// now check if files are transferred or not
91+
if(! file_exists($trans['destination'].$trans['file_check']))
92+
{
93+
$response = array('response'=>false, 'error'=>"Invalid ".$trans['path']);
94+
95+
return false;
96+
}
97+
}
98+
99+
return TRUE;
100+
}
101+
102+
/**
103+
* Copy a file, or recursively copy a folder and its contents
104+
* @author Aidan Lister <[email protected]>
105+
* @version 1.0.1
106+
* @link http://aidanlister.com/2004/04/recursively-copying-directories-in-php/
107+
* @param string $source Source path
108+
* @param string $dest Destination path
109+
* @param int $permissions New folder creation permissions
110+
* @return bool Returns true on success, false on failure
111+
*/
112+
function xcopy($trans = array())
113+
{
114+
// Simple copy for a file
115+
if (is_file($trans['source'])) {
116+
return copy($trans['source'], $trans['destination']);
117+
}
118+
119+
// Make destination directory
120+
if (!is_dir($trans['destination']))
121+
{
122+
if($trans['make_dir'])
123+
{
124+
mkdir($trans['destination'], 0777, true);
125+
}
126+
else
127+
{
128+
return false;
129+
}
130+
}
131+
132+
// Loop through the folder
133+
$dir = dir($trans['source']);
134+
while (false !== $entry = $dir->read()) {
135+
// Skip pointers
136+
if ($entry == '.' || $entry == '..') {
137+
continue;
138+
}
139+
140+
// Deep copy directories
141+
$this->xcopy(array('source'=>"".$trans['source']."/".$entry."", 'destination'=>"".$trans['destination']."/".$entry."", 'make_dir'=>$trans['make_dir']));
142+
}
143+
144+
// Clean up
145+
$dir->close();
146+
return true;
147+
}
148+
149+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
class Database {
4+
5+
// Connect to the application database
6+
function connect_database($data)
7+
{
8+
// Connect to the database
9+
$mysqli = new mysqli($data['hostname'],$data['username'],$data['password'],$data['database']);
10+
11+
// Check for errors
12+
if(mysqli_connect_errno())
13+
return false;
14+
15+
// Close the connection
16+
$mysqli->close();
17+
18+
return true;
19+
}
20+
21+
// Function to create the tables and fill them with the default data
22+
function create_tables($data)
23+
{
24+
// Connect to the database
25+
$mysqli = new mysqli($data['hostname'],$data['username'],$data['password'],$data['database']);
26+
27+
// Check for errors
28+
if(mysqli_connect_errno())
29+
return false;
30+
31+
// Open the default SQL file
32+
// install addchat tables
33+
$query = file_get_contents('database/addchat_db.sql');
34+
35+
// Execute a multi query
36+
$mysqli->multi_query($query);
37+
38+
// Close the connection
39+
$mysqli->close();
40+
41+
return TRUE;
42+
}
43+
}

0 commit comments

Comments
 (0)