Skip to content

Commit f215143

Browse files
committed
Initial commit
1 parent 22a35c5 commit f215143

File tree

122 files changed

+33003
-0
lines changed

Some content is hidden

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

122 files changed

+33003
-0
lines changed
+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
3+
/***************************************************************************
4+
* Application : Emotion [Athena] *
5+
* ------------------------------------------------------------------- *
6+
* Package : @sample *
7+
* File : config.php *
8+
* ------------------------------------------------------------------- *
9+
* Begin : Wednesday, Jun 30, 2011 *
10+
* CopyRight : (C) 2011 ArvYStaTe.net Team *
11+
* E-Mail : [email protected] *
12+
* Last edit : Wednesday, Jun 30, 2011 *
13+
* *
14+
* *
15+
***************************************************************************
16+
17+
***************************************************************************
18+
* File description *
19+
* ------------------------------------------------------------------- *
20+
* This is a sample config file, to show how are the variables stored *
21+
* in config. It can be generated by online compiler or manually by *
22+
* the developer. *
23+
* It is important to derive from EmotionConfiguration, otherwise *
24+
* automatic loading system will not find it and application will fail *
25+
* to load. *
26+
* ------------------------------------------------------------------- *
27+
* *
28+
***************************************************************************
29+
30+
***************************************************************************
31+
* Change log *
32+
* ------------------------------------------------------------------- *
33+
* + [06/30/11] - No changes since file was created *
34+
* ------------------------------------------------------------------- *
35+
* *
36+
***************************************************************************
37+
38+
***************************************************************************
39+
* *
40+
* Emotion is a powerful PHP framework (kernel) for site generation. *
41+
* ------------------------------------------------------------------- *
42+
* Application is owned and copyrighted by ArvYStaTe.net Team, you are *
43+
* only allowed to modify code, not take ownership or in any way claim *
44+
* you are the creator of any thing else but modifications. *
45+
* ------------------------------------------------------------------- *
46+
* *
47+
***************************************************************************/
48+
49+
class AppConfig extends EmotionConfiguration
50+
{
51+
//
52+
// All config variables are here the same as default ones (incase config is missing, default is already statically compiled into core)
53+
// SetupVariables function
54+
//
55+
56+
protected function CustomVariables ()
57+
{
58+
// Overwrite variables if you want them custom
59+
$this->Set ('autoload', true);
60+
$this->Set ('enable_query_strings', false);
61+
62+
// Add your own variables
63+
$this->Set ('database_host', 'localhost');
64+
$this->Set ('database_user', 'database_username');
65+
$this->Set ('database_pass', 'database_password');
66+
$this->Set ('database_name', 'database_name');
67+
$this->Set ('database_prefix', 'database_prefix');
68+
}
69+
}
70+
?>
+278
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,278 @@
1+
<?php
2+
3+
class AppLoader extends EmotionLoader
4+
{
5+
protected function CustomLoad ()
6+
{
7+
// Session init
8+
$this->Load ('Session')->Initialize ();
9+
10+
$this->Load ('Debug')->SaveMessage ('Reading session data...');
11+
12+
if (!$this->Load ('Session')->SessionRead ())
13+
{
14+
$this->Load ('Debug')->SaveMessage ('Session not created, proceed with creation...');
15+
16+
if ($this->Load ('Session')->SessionCreate ())
17+
{
18+
$this->Load ('Debug')->SaveMessage ('Session successfully created. SID: ' . $this->Load ('Session')->Get ('session_id'));
19+
}
20+
else
21+
{
22+
$this->Load ('Debug')->SaveMessage ('Error creating session.');
23+
}
24+
}
25+
else
26+
{
27+
$this->Load ('Debug')->SaveMessage ('Session successfully read. SID: ' . $this->Load ('Session')->Get ('session_id'));
28+
}
29+
30+
$this->Load ('Security')->SecureGlobals ();
31+
32+
// Load user classes
33+
$this->Load ('Common')->LoadClasses ('application/lib');
34+
35+
$this->Load ('Debug')->SaveMessage ('Loading database.');
36+
37+
$this->Load ('Database')->PrepareDriver ('MySQL');
38+
39+
$this->Load ('Debug')->SaveMessage ('Driver status: ' . $this->Load ('Database')->DriverStatus ());
40+
$this->Load ('Debug')->SaveMessage ('Connecting to database.');
41+
42+
$this->Load ('Database')->SetPrefix ($this->Config ('database_prefix'));
43+
44+
if ($this->Load ('Database')->Connect ($this->Config ('database_host'), $this->Config ('database_user'), $this->Config ('database_pass'), $this->Config ('database_name')))
45+
{
46+
$this->Load ('Debug')->SaveMessage ('Connection successful.');
47+
48+
$this->Load ('Debug')->SaveMessage ('Connection status: ' . $this->Load ('Database')->DriverStatus ());
49+
50+
//
51+
// Checking framework status.. -> Self-check
52+
//
53+
54+
$this->Load ('Debug')->SaveMessage ('Checking framework file structure.');
55+
56+
// Find collection
57+
$collections = $this->Load ('Database')->Select ("collections");
58+
59+
if (count ($collections) == 0)
60+
{
61+
$this->Load ('Debug')->SaveMessage ('No collection found -> creating default EE collection, version: ' . EMOTION_VERSION);
62+
63+
// We do not know download link yet
64+
$this->Load ('Database')->Insert ("collections", "name, version, revision, timestamp, downloads, packages", "'Emotion Engine', '" . EMOTION_VERSION . "', 0, " . time () . ", 0, 0");
65+
66+
$this->Load ('Debug')->SaveMessage ('Default collection created.');
67+
68+
// Get collections again
69+
$collections = $this->Load ('Database')->Select ("collections");
70+
}
71+
72+
$this->Load ('Debug')->SaveMessage ('Scanning collection files. Process may take a while.');
73+
74+
$files = $this->Load ('Database')->Select ("files", "collection_id = '{$collections[0]['collection_id']}'");
75+
76+
// Construct local fileBase
77+
$localScanner = new EmotionStructure ();
78+
79+
$fileBase = $localScanner->GetFiles ();
80+
81+
//
82+
// Db status:
83+
// 0 - new file
84+
// -1 - file found
85+
// array - details of file to be updated
86+
//
87+
88+
for ($i = 0; $i < count ($files); $i++)
89+
{
90+
// Search array for the key
91+
if (array_key_exists ($files[$i]['filename'], $fileBase) === true)
92+
{
93+
// Check for hash comparison
94+
if ($files[$i]['hash'] === $fileBase[$files[$i]['filename']]['hash'])
95+
{
96+
$fileBase[$files[$i]['filename']]['db_status'] = -1;
97+
}
98+
else
99+
{
100+
$fileBase[$files[$i]['filename']]['db_status'] = $files[$i]['file_id'];
101+
}
102+
}
103+
}
104+
105+
$update = false;
106+
107+
// Commence file changes in database
108+
foreach ($fileBase as $key => $value)
109+
{
110+
// Insertion
111+
if ($value['db_status'] === 0)
112+
{
113+
$this->Load ('Database')->Insert ("files", "filename, path, version, revision, hash, timestamp, collection_id", "'{$key}', '{$value['path']}', '" . EMOTION_VERSION . "', 1, '{$value['hash']}', '{$value['modified']}', '{$collections[0]['collection_id']}'");
114+
115+
$update = true;
116+
117+
$this->Load ('Debug')->SaveMessage ('Inserted file: ' . $key);
118+
}
119+
else if ($value['db_status'] !== -1)
120+
{
121+
//$revision = intval ($value['db_status']['revision']) + 1;
122+
$this->Load ('Database')->Update ("files", "file_id='{$value['db_status']}'", "version = '" . EMOTION_VERSION . "', revision = revision + 1, hash = '{$value['hash']}', timestamp = '{$value['modified']}'");
123+
124+
$update = true;
125+
126+
$this->Load ('Debug')->SaveMessage ('Updated file: ' . $key . ' File ID: ' . $value['db_status']);
127+
}
128+
}
129+
130+
// Something was updated, need to update collections
131+
if ($update === true)
132+
{
133+
$tempName = str_replace (' ', '', $collections[0]['name']);
134+
$tempName = $tempName . '_' . EMOTION_VERSION;
135+
136+
// Cleaning up old files
137+
if (is_file ('release/' . $tempName . '.zip') === true)
138+
{
139+
unlink ('release/' . $tempName . '.zip');
140+
}
141+
142+
if (is_file ('release/' . $tempName . '_database.zip') === true)
143+
{
144+
unlink ('release/' . $tempName . '_database.zip');
145+
}
146+
147+
if (is_file ('release/' . $tempName . '_library.zip') === true)
148+
{
149+
unlink ('release/' . $tempName . '_library.zip');
150+
}
151+
152+
if (is_file ('release/' . $tempName . '_system.zip') === true)
153+
{
154+
unlink ('release/' . $tempName . '_system.zip');
155+
}
156+
157+
// Creating release ZIP files with php built in ZIP
158+
if (class_exists ('ZipArchive') === true)
159+
{
160+
$this->Load ('Debug')->SaveMessage ('Recreating download Zip archives using PHP ZipArchive system (faster) ...');
161+
162+
//
163+
// Create release files
164+
//
165+
166+
$zipMain = new ZipArchive ();
167+
$zipDatabase = new ZipArchive ();
168+
$zipLibrary = new ZipArchive ();
169+
$zipSystem = new ZipArchive ();
170+
171+
// Opening zip files
172+
$opened = $zipMain->open ('release/' . $tempName . '.zip', ZIPARCHIVE::CREATE) && $zipDatabase->open ('release/' . $tempName . '_database.zip', ZIPARCHIVE::CREATE) && $zipLibrary->open ('release/' . $tempName . '_library.zip', ZIPARCHIVE::CREATE) && $zipSystem->open ('release/' . $tempName . '_system.zip', ZIPARCHIVE::CREATE);
173+
174+
// Attempt to open new archives
175+
if ($opened === true)
176+
{
177+
$this->Load ('Debug')->SaveMessage ('Opened archive files.');
178+
179+
foreach ($fileBase as $key => $value)
180+
{
181+
// Main release file
182+
$zipMain->addFile ($value['path'], $value['path']);
183+
184+
// Database release file
185+
if ( ($this->Load ('Text')->StartsWith ($value['path'], 'database/') === true) || ($this->Load ('Text')->StartsWith ($key, 'database.') === true) )
186+
{
187+
$zipDatabase->addFile ($value['path'], $value['path']);
188+
}
189+
190+
// Library release file
191+
if ($this->Load ('Text')->StartsWith ($value['path'], 'library/') === true)
192+
{
193+
$zipLibrary->addFile ($value['path'], $value['path']);
194+
}
195+
196+
// System release file
197+
if ($this->Load ('Text')->StartsWith ($value['path'], 'system/') === true)
198+
{
199+
$zipSystem->addFile ($value['path'], $value['path']);
200+
}
201+
}
202+
}
203+
else
204+
{
205+
$this->Load ('Debug')->SaveMessage ('Unable to create archive files.');
206+
}
207+
208+
$zipMain->close ();
209+
$zipDatabase->close ();
210+
$zipLibrary->close ();
211+
$zipSystem->close ();
212+
}
213+
else
214+
{
215+
$this->Load ('Debug')->SaveMessage ('Recreating download Zip archives using Emotion Engine system...');
216+
217+
$this->Load ('zipMain', 'Zip');
218+
$this->Load ('zipDatabase', 'Zip');
219+
$this->Load ('zipLibrary', 'Zip');
220+
$this->Load ('zipSystem', 'Zip');
221+
222+
$this->Load ('zipMain')->AddDirectory ('database');
223+
$this->Load ('zipMain')->AddDirectory ('library');
224+
$this->Load ('zipMain')->AddDirectory ('system');
225+
226+
$this->Load ('zipDatabase')->AddDirectory ('database');
227+
$this->Load ('zipDatabase')->AddDirectory ('library');
228+
229+
$this->Load ('zipLibrary')->AddDirectory ('library');
230+
231+
$this->Load ('zipSystem')->AddDirectory ('system');
232+
233+
foreach ($fileBase as $key => $value)
234+
{
235+
// Main release file
236+
$this->Load ('zipMain')->AddFile ($key, pathinfo ($value['path'], PATHINFO_DIRNAME) );
237+
238+
// Database release file
239+
if ( ($this->Load ('Text')->StartsWith ($value['path'], 'database/') === true) || ($this->Load ('Text')->StartsWith ($key, 'database.') === true) )
240+
{
241+
$this->Load ('zipDatabase')->AddFile ($key, pathinfo ($value['path'], PATHINFO_DIRNAME) );
242+
}
243+
244+
// Library release file
245+
if ($this->Load ('Text')->StartsWith ($value['path'], 'library/') === true)
246+
{
247+
$this->Load ('zipLibrary')->AddFile ($key, pathinfo ($value['path'], PATHINFO_DIRNAME) );
248+
}
249+
250+
// System release file
251+
if ($this->Load ('Text')->StartsWith ($value['path'], 'system/') === true)
252+
{
253+
$this->Load ('zipSystem')->AddFile ($key, pathinfo ($value['path'], PATHINFO_DIRNAME) );
254+
}
255+
}
256+
257+
$this->Load ('zipMain')->Save ('release/' . $tempName . '.zip');
258+
$this->Load ('zipDatabase')->Save ('release/' . $tempName . '_database.zip');
259+
$this->Load ('zipLibrary')->Save ('release/' . $tempName . '_library.zip');
260+
$this->Load ('zipSystem')->Save ('release/' . $tempName . '_system.zip');
261+
}
262+
263+
$revision = intval ($collections[0]['revision']) + 1;
264+
$this->Load ('Database')->Update ("collections", "collection_id = '{$collections[0]['collection_id']}'", "version = '" . EMOTION_VERSION . "', revision = '{$revision}', timestamp = '" . time () . "'");
265+
$this->Load ('Debug')->SaveMessage ('Updated collection. Version: ' . EMOTION_VERSION . ' - ' . date ('M j, Y') . ' Revision: ' . $revision);
266+
}
267+
else
268+
{
269+
$this->Load ('Debug')->SaveMessage ('Nothing new to update.');
270+
}
271+
}
272+
else
273+
{
274+
$error = $this->Load ('Database')->GetErrorList ();
275+
$this->Load ('Debug')->SaveMessage ('Connection unsuccessful: ' . print_r ($error, true) );
276+
}
277+
}
278+
}
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
class Admin extends EmotionController
4+
{
5+
public function index ($password = '')
6+
{
7+
if ($password == 'qwertasdfg')
8+
{
9+
$this->View ('header_no_menu');
10+
11+
echo ('<div id="main_content">
12+
<div id="content">
13+
<div class="front_page">');
14+
15+
echo ($this->Load ('Debug')->GetLog ());
16+
17+
echo ('</div><!-- end .front_page -->
18+
</div><!-- end #content -->
19+
</div><!-- end #main_content -->');
20+
21+
$this->View ('footer');
22+
}
23+
else
24+
{
25+
$this->View ('404');
26+
}
27+
}
28+
}
29+
30+
?>

0 commit comments

Comments
 (0)