1<?php
2
3/**
4 * Installs SVG Plugin files
5 */
6function syntax_plugin_svg_install()
7{
8	if( !file_exists( SYNTAX_PLUGIN_SVG_MEDIADIR ) )
9	{
10		if( !mkdir( SYNTAX_PLUGIN_SVG_MEDIADIR, 0755 ) )
11		{
12			return false;
13		}
14	}
15	else
16	{
17		if( !is_dir( SYNTAX_PLUGIN_SVG_MEDIADIR ) ||
18			 !@file_exists( SYNTAX_PLUGIN_SVG_MEDIADIR . '.' ) )
19		{
20			return false;
21		}
22	}
23
24	if( !file_exists( SYNTAX_PLUGIN_SVG_MEDIADIR . 'tmp' ) )
25	{
26		if( !mkdir( SYNTAX_PLUGIN_SVG_MEDIADIR . 'tmp', 0755 ) )
27		{
28			return false;
29		}
30	}
31	else
32	{
33		if( !is_dir( SYNTAX_PLUGIN_SVG_MEDIADIR . 'tmp' ) ||
34			 !@file_exists( SYNTAX_PLUGIN_SVG_MEDIADIR . 'tmp/.' ) )
35		{
36			return false;
37		}
38	}
39
40	if( !file_exists( SYNTAX_PLUGIN_SVG_MEDIADIR . 'media' ) )
41	{
42		if( !mkdir( SYNTAX_PLUGIN_SVG_MEDIADIR . 'media', 0755 ) )
43		{
44			return false;
45		}
46	}
47	else
48	{
49		if( !is_dir( SYNTAX_PLUGIN_SVG_MEDIADIR . 'media' ) ||
50			 !@file_exists( SYNTAX_PLUGIN_SVG_MEDIADIR . 'media/.' ) )
51		{
52			return false;
53		}
54	}
55
56	// make sure we don't do this every time
57	$fh = fopen( SYNTAX_PLUGIN_SVG_MEDIADIR . '.install.php', 'w' );
58	fwrite( $fh, '<?php define("SYNTAX_PLUGIN_SVG_INSTALLED",true); ?>' );
59	fclose( $fh );
60
61	$fh = fopen( SYNTAX_PLUGIN_SVG_MEDIADIR . 'media/.htaccess', 'w' );
62	fwrite( $fh, "order allow,deny\nallow from all\n" );
63	fclose( $fh );
64
65	return true;
66}
67
68?>
69