diff --git a/engine/ext.php b/engine/ext.php new file mode 100644 index 0000000..f9d71cf --- /dev/null +++ b/engine/ext.php @@ -0,0 +1,7 @@ + 'admin', 'pass' => 111]; + +extract($user); + +var_dump($login); \ No newline at end of file diff --git a/engine/file1.php b/engine/file1.php new file mode 100644 index 0000000..d77f765 --- /dev/null +++ b/engine/file1.php @@ -0,0 +1,24 @@ + 1, 'name' => 'pop'], - ['id' => 2, 'name' => 'hip-hop'], - ['id' => 3, 'name' => 'rock'], - ['id' => 4, 'name' => 'jazz'], - ['id' => 5, 'name' => 'classic'], -]; +define('FOLDER_TEMPLATE', './template/'); +include "model_box.php"; +function render($tpl, $data) +{ + extract($data); -$music = [ - ['id' => 1, 'id_styles' => 5, 'href' => 'https://azbyka.ru/audio/audio1/Muzyka-i-pesni/populjarnaja-klassicheskaja-muzyka/65_iogann_sebastjyan_bah_i_sharlj_guno__sotis_ave_mariya_.mp3'], - ['id' => 2, 'id_styles' => 5, 'href' => 'https://azbyka.ru/audio/audio1/Muzyka-i-pesni/populjarnaja-klassicheskaja-muzyka/107_zuppe_uvertyura_k_opere_legkaya_kavaleriya.mp3'], - // ['id'=> 3, 'name'=> 'rock'], -// ['id'=> 4, 'name'=> 'jazz'], -// ['id'=> 5, 'name'=> 'classic'], -]; -$str = ""; + // include "model_box.php"; -foreach ($arr as $item) { - $str .= "
  • " . $item['name'] . "
  • "; + // Start output buffering + ob_start(); + + // Include the template file + include FOLDER_TEMPLATE . $tpl; + + // Get the contents of the buffer + $content = ob_get_contents(); + + // End output buffering and erase the buffer's contents + ob_end_clean(); + + // Perform any necessary processing on the template content +// For example, you can replace placeholders, apply filters, etc. +// $content = str_replace('{{title}}', 'My Website', $content); + + // Output the processed content + return $content; } -echo (''); - -$select = ""; - -$options = ""; -foreach ($arr as $item) { - $options .= ""; -} - -$select = ''; - -echo ($select); - -$box = []; -if ( - $handle = - opendir('C:\\Lerning\\lerning-php\\itmo-php-course\\engine\\upload') -) { - // echo "Directory handle: $handle\n"; - // echo "Entries:\n"; - - /* This is the correct way to loop over the directory. */ - while (false !== ($entry = readdir($handle))) { - $ext = pathinfo($entry, PATHINFO_EXTENSION); - // echo $ext ."\n"; - if ($ext == 'mp3') { - array_push($box, "C:\\Lerning\\lerning-php\\itmo-php-course\\engine\\upload\\$entry"); - } - } - - closedir($handle); -} -// var_dump($box); - -$playlist = ""; -foreach ($box as $item) { - $playlist .= ''; -}; - -// $playlist = ""; - -echo ($playlist); +$value = ['box' => $box, 'title' => "God save the King!", 'body' => "Happy New Year!", 'auth' => true]; +$portial = render('tpl_layout.php', $value); +echo $portial; \ No newline at end of file diff --git a/engine/index_music.php b/engine/index_music.php new file mode 100644 index 0000000..1f5e720 --- /dev/null +++ b/engine/index_music.php @@ -0,0 +1,73 @@ + 1, 'name' => 'pop'], + ['id' => 2, 'name' => 'hip-hop'], + ['id' => 3, 'name' => 'rock'], + ['id' => 4, 'name' => 'jazz'], + ['id' => 5, 'name' => 'classic'], +]; + +$music = [ + ['id' => 1, 'id_styles' => 5, 'href' => 'https://azbyka.ru/audio/audio1/Muzyka-i-pesni/populjarnaja-klassicheskaja-muzyka/65_iogann_sebastjyan_bah_i_sharlj_guno__sotis_ave_mariya_.mp3'], + ['id' => 2, 'id_styles' => 5, 'href' => 'https://azbyka.ru/audio/audio1/Muzyka-i-pesni/populjarnaja-klassicheskaja-muzyka/107_zuppe_uvertyura_k_opere_legkaya_kavaleriya.mp3'], + // ['id'=> 3, 'name'=> 'rock'], +// ['id'=> 4, 'name'=> 'jazz'], +// ['id'=> 5, 'name'=> 'classic'], +]; + +$str = ""; + +foreach ($arr as $item) { + $str .= "
  • " . $item['name'] . "
  • "; +} + +echo (''); + +$select = ""; + +$options = ""; +foreach ($arr as $item) { + $options .= ""; +} + +$select = ''; + +echo ($select); + +$box = []; +if ( + $handle = + opendir('./upload') +) { + // echo "Directory handle: $handle\n"; + // echo "Entries:\n"; + + /* This is the correct way to loop over the directory. */ + while (false !== ($entry = readdir($handle))) { + $ext = pathinfo($entry, PATHINFO_EXTENSION); + // echo $ext ."\n"; + if ($ext == 'mp3') { + array_push($box, "./upload/$entry"); + } + } + + closedir($handle); +} +// var_dump($box); + +$playlist = ""; +foreach ($box as $item) { + $playlist .= ''; +} +; +echo ($playlist); + diff --git a/engine/lib/file2.php b/engine/lib/file2.php new file mode 100644 index 0000000..9f9b26a --- /dev/null +++ b/engine/lib/file2.php @@ -0,0 +1,19 @@ + + + + + + + <?php echo $body; ?> + + + + + + +
    exit
    + +
    login
    + + + + + + + + + + \ No newline at end of file