1886 } |
1886 } |
1887 } |
1887 } |
1888 } |
1888 } |
1889 } |
1889 } |
1890 elseif(isset($_POST['install'])) { |
1890 elseif(isset($_POST['install'])) { |
1891 $q = 'SELECT * FROM '.table_prefix.'themes;'; |
1891 $q = 'SELECT theme_id FROM '.table_prefix.'themes;'; |
1892 $s = $db->sql_query($q); |
1892 $s = $db->sql_query($q); |
1893 if(!$s) die('Error getting theme count: '.mysql_error().'<br /><u>SQL:</u><br />'.$q); |
1893 if(!$s) die('Error getting theme count: '.mysql_error().'<br /><u>SQL:</u><br />'.$q); |
1894 $n = $db->numrows($s); |
1894 $n = $db->numrows($s); |
1895 $n++; |
1895 $n++; |
1896 $theme_id = $_POST['theme_id']; |
1896 $theme_id = $_POST['theme_id']; |
1897 $theme = Array(); |
1897 $theme = Array(); |
1898 include('./themes/'.$theme_id.'/theme.cfg'); |
1898 include('./themes/'.$theme_id.'/theme.cfg'); |
1899 $q = 'INSERT INTO '.table_prefix.'themes(theme_id,theme_name,theme_order,enabled) VALUES(\''.$theme['theme_id'].'\', \''.$theme['theme_name'].'\', '.$n.', 1)'; |
1899 if ( !isset($theme['theme_id']) ) |
1900 $s = $db->sql_query($q); |
1900 { |
1901 if(!$s) die('Error inserting theme data: '.mysql_error().'<br /><u>SQL:</u><br />'.$q); |
1901 echo '<div class="error-box">Could not load theme.cfg (theme metadata file)</div>'; |
1902 else echo('<div class="info-box">Theme "'.$theme['theme_name'].'" installed.</div>'); |
1902 } |
|
1903 else |
|
1904 { |
|
1905 $default_style = false; |
|
1906 if ( $dh = opendir('./themes/' . $theme_id . '/css') ) |
|
1907 { |
|
1908 while ( $file = readdir($dh) ) |
|
1909 { |
|
1910 if ( $file != '_printable.css' && preg_match('/\.css$/i', $file) ) |
|
1911 { |
|
1912 $default_style = $file; |
|
1913 break; |
|
1914 } |
|
1915 } |
|
1916 closedir($dh); |
|
1917 } |
|
1918 else |
|
1919 { |
|
1920 die('The /css subdirectory could not be located in the theme\'s directory'); |
|
1921 } |
|
1922 |
|
1923 if ( $default_style ) |
|
1924 { |
|
1925 $q = 'INSERT INTO '.table_prefix.'themes(theme_id,theme_name,theme_order,enabled,default_style) VALUES(\''.$db->escape($theme['theme_id']).'\', \''.$db->escape($theme['theme_name']).'\', '.$n.', 1, \'' . $db->escape($default_style) . '\')'; |
|
1926 $s = $db->sql_query($q); |
|
1927 if(!$s) die('Error inserting theme data: '.mysql_error().'<br /><u>SQL:</u><br />'.$q); |
|
1928 else echo('<div class="info-box">Theme "'.$theme['theme_name'].'" installed.</div>'); |
|
1929 } |
|
1930 else |
|
1931 { |
|
1932 echo '<div class="error-box">Could not determine the default style for the theme.</div>'; |
|
1933 } |
|
1934 } |
1903 } |
1935 } |
1904 echo(' |
1936 echo(' |
1905 <h3>Currently installed themes</h3> |
1937 <h3>Currently installed themes</h3> |
1906 <form action="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module']).'" method="post"> |
1938 <form action="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module']).'" method="post"> |
1907 <p> |
1939 <p> |