forked from Codiad/Codiad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
executable file
·270 lines (204 loc) · 9.38 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
<?php
if(file_exists('config.php')){ require_once('config.php'); }
// Context Menu
$context_menu = file_get_contents(COMPONENTS . "/filemanager/context_menu.json");
$context_menu = json_decode($context_menu,true);
// Right Bar
$right_bar = file_get_contents(COMPONENTS . "/right_bar.json");
$right_bar = json_decode($right_bar,true);
// Components
$components = file_get_contents(COMPONENTS . "/load.json");
$components = json_decode($components,true);
?>
<!doctype html>
<head>
<meta charset="utf-8">
<title>CODIAD</title>
<link rel="stylesheet" href="css/jquery.toastmessage.css">
<link rel="stylesheet" href="css/reset.css">
<link rel="stylesheet" href="css/fonts.css">
<link rel="stylesheet" href="css/screen.css">
<link rel="icon" href="favicon.ico" type="image/x-icon" />
<?php
// Load Component CSS Files
foreach($components as $component){
if(file_exists(COMPONENTS . "/" . $component . "/screen.css")){
echo('<link rel="stylesheet" href="components/'.$component.'/screen.css">');
}
}
?>
</head>
<body>
<script>
var i18n = (function(lang) {
return function(word) {
return (word in lang) ? lang[word] : word;
}
})(<?php echo json_encode($lang); ?>)
</script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script>!window.jQuery && document.write(unescape('%3Cscript src="js/jquery-1.7.2.min.js"%3E%3C/script%3E'));</script>
<script src="js/jquery-ui-1.8.23.custom.min.js"></script>
<script src="js/jquery.css3.min.js"></script>
<script src="js/jquery.easing.js"></script>
<script src="js/jquery.toastmessage.js"></script>
<script src="js/amplify.min.js"></script>
<script src="js/localstorage.js"></script>
<script src="js/jquery.hoverIntent.min.js"></script>
<script src="js/system.js"></script>
<script src="js/sidebars.js"></script>
<script src="js/modal.js"></script>
<script src="js/message.js"></script>
<script src="js/jsend.js"></script>
<div id="message"></div>
<?php
//////////////////////////////////////////////////////////////////
// NOT LOGGED IN
//////////////////////////////////////////////////////////////////
if(!isset($_SESSION['user'])){
$path = rtrim(str_replace("index.php", "", $_SERVER['SCRIPT_FILENAME']),"/");
$users = file_exists($path . "/data/users.php");
$projects = file_exists($path . "/data/projects.php");
$active = file_exists($path . "/data/active.php");
if(!$users && !$projects && !$active){
// Installer
require_once('components/install/view.php');
}else{
// Login form
?>
<form id="login" method="post" style="position: fixed; width: 350px; top: 30%; left: 50%; margin-left: -175px; padding: 35px;">
<label><span class="icon-user login-icon"></span> Username</label>
<input type="text" name="username" autofocus="autofocus" autocomplete="off">
<label><span class="icon-lock login-icon"></span> Password</label>
<input type="password" name="password">
<div class="language-selector">
<label><span class="icon-language login-icon"></span> Language</label>
<select name="language">
<?php
include 'languages/code.php';
foreach(glob("languages/*.php") as $filename):
$lang_code = str_replace(array("languages/", ".php"), "", $filename);
if(!isset($languages[$lang_code])) continue;
$lang_disp = ucfirst(strtolower($languages[$lang_code]));
?>
<option value="<?php echo $lang_code; ?>" <?php if ($lang_code == "en"){echo "selected";}?>><?php echo $lang_disp; ?></option>
<?php endforeach; ?>
</select>
</div>
<button>Login</button>
<a class="show-language-selector">Language</a>
</form>
<script src="components/user/init.js"></script>
<?php
}
//////////////////////////////////////////////////////////////////
// AUTHENTICATED
//////////////////////////////////////////////////////////////////
}else{
?>
<div id="workspace">
<div id="sb-left" class="sidebar">
<div id="sb-left-title">
<h2 id="finder-label"> Explore </h2>
<div id="finder-wrapper">
<a id="finder-options" class="icon icon-cog"></a>
<div id="finder-inner-wrapper">
<input type="text" id="finder"></input>
</div>
<ul id="finder-options-menu" class="options-menu">
<li class="chosen"><a data-option="left_prefix">Prefix</a></li>
<li><a data-option="substring">Substring</a></li>
<li><a data-option="regexp">Regular expression</a></li>
<li><a data-action="search">Search File Contents</a></li>
</ul>
</div>
<a id="lock-left-sidebar" class="icon-lock icon"></a>
<a id="tree-search" class="icon-search icon"></a>
</div>
<div class="sb-left-content">
<div id="context-menu" data-path="" data-type="">
<?php
////////////////////////////////////////////////////////////
// Load Context Menu
////////////////////////////////////////////////////////////
foreach($context_menu as $menu_item=>$data){
if($data['title']=='Break'){
echo('<hr class="'.$data['applies-to'].'">');
}else{
echo('<a class="'.$data['applies-to'].'" onclick="'.$data['onclick'].'"><span class="'.$data['icon'].'"></span>'.$data['title'].'</a>');
}
}
?>
</div>
<div id="file-manager"></div>
<ul id="list-active-files"></ul>
</div>
<div class="sidebar-handle"><span>||</span></div>
</div>
<div id="cursor-position">Ln: 0 · Col: 0</div>
<div id="editor-region">
<div id="editor-top-bar">
<ul id="tab-list-active-files"> </ul>
<div id="tab-dropdown">
<a id="tab-dropdown-button" class="icon-down-open"></a>
</div>
<ul id="dropdown-list-active-files"></ul>
<div class="bar"></div>
</div>
<div id="root-editor-wrapper"></div>
<div id="editor-bottom-bar">
<a id="settings" class="ico-wrapper"><span class="icon-doc-text"></span>Settings</a>
<div class="divider"></div>
<a id="split" class="ico-wrapper"><span class="icon-layout"></span>Split</a>
<div class="divider"></div>
<a id="current-mode"><span class="icon-layout"></span></a>
<div class="divider"></div>
<div id="current-file"></div>
</div>
<ul id="changemode-menu" class="options-menu">
</ul>
<ul id="split-options-menu" class="options-menu">
<li id="split-horizontally"><a> Split Horizontally </a></li>
<li id="split-vertically"><a> Split Vertically </a></li>
<li id="merge-all"><a> Merge all </a></li>
</ul>
</div>
<div id="sb-right" class="sidebar">
<div class="sidebar-handle"><span><a class="icon-menu"></a></span></div>
<div class="sb-right-content">
<?php
////////////////////////////////////////////////////////////
// Load Right Bar
////////////////////////////////////////////////////////////
foreach($right_bar as $item_rb=>$data){
if($data['title']=='break'){
echo("<hr>");
}else{
echo('<a onclick="'.$data['onclick'].'"><span class="'.$data['icon'].' bigger-icon"></span>'.get_i18n($data['title']).'</a>');
}
}
?>
</div>
</div>
</div>
<div id="modal-overlay"></div>
<div id="modal"><div id="drag-handle" class="icon-location"></div><div id="modal-content"></div></div>
<iframe id="download"></iframe>
<div id="autocomplete"><ul id="suggestions"></ul></div>
<!-- ACE -->
<script src="components/editor/ace-editor/ace.js"></script>
<!-- COMPONENTS -->
<?php
//////////////////////////////////////////////////////////////////
// LOAD COMPONENTS
//////////////////////////////////////////////////////////////////
// JS
foreach($components as $component){
if(file_exists(COMPONENTS . "/" . $component . "/init.js")){
echo('<script src="components/'.$component.'/init.js"></script>"');
}
}
}
?>
</body>
</html>