-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathenable.php
More file actions
51 lines (43 loc) · 1.73 KB
/
enable.php
File metadata and controls
51 lines (43 loc) · 1.73 KB
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
<?php
/* Security measure */
if ( !defined( 'IN_CMS' ) )
exit();
if ( !Plugin::isEnabled( 'mm_core' ) ) {
unset( Plugin::$plugins['mm_cache'] );
Plugin::save();
Flash::set( 'error', __( '<b>mm_core</b> plugin not found! <br/>
Download latest <b>mm_core</b> here: <br/>
<a href="http://marekmurawski.pl/en/web/wolf-cms/plugins" target="_blank">http://marekmurawski.pl/en/web/wolf-cms/plugins</a>
' ) );
exit();
}
$settings['extension'] = 'cache';
$settings['dir'] = 'mm_cache';
$settings['default_lifetime'] = '360';
$exists = Plugin::getSetting( 'dir', 'mm_cache' );
if ( !$exists ) {
Plugin::setAllSettings( $settings, 'mm_cache' );
} else {
$settings = Plugin::getAllSettings( 'mm_cache' );
}
$snippetContent = file_get_contents( PLUGINS_ROOT . DS . 'mm_cache' . DS . 'samples' . DS . 'sample_snippet.php' );
$newSnippet = new Snippet;
$newSnippet->name = 'mmCacheExamples';
$newSnippet->created_on = date( 'Y-m-d H:i:s' );
$newSnippet->content = $snippetContent;
$newSnippet->content_html = $snippetContent;
$newSnippet->created_by_id = 1;
if ( $newSnippet->save() ) {
Flash::set( 'info', __( 'A sample snippet "mmCacheExamples" has been created!' ) );
};
try {
if ( !is_dir( CMS_ROOT . DS . $settings['dir'] ) ) {
mkdir( CMS_ROOT . DS . $settings['dir'] );
};
file_put_contents( CMS_ROOT . DS . $settings['dir'] . DS . '.htaccess', 'DENY FROM ALL' );
Flash::set( 'success', 'mmCache plugin successfully activated' );
}
catch ( Exception $e ) {
Flash::set( 'error', 'Error while creating directory and/or .htaccess file!' . '<br/>' . $e->getMessage() );
}
die();