départ sae php
This commit is contained in:
		@@ -89,7 +89,7 @@ $autoload['drivers'] = array();
 | 
			
		||||
|
 | 
			
		||||
|	$autoload['helper'] = array('url', 'file');
 | 
			
		||||
*/
 | 
			
		||||
$autoload['helper'] = array();
 | 
			
		||||
$autoload['helper'] = array('url','html');
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
| -------------------------------------------------------------------
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										135
									
								
								application/config/autoload.php~
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										135
									
								
								application/config/autoload.php~
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,135 @@
 | 
			
		||||
<?php
 | 
			
		||||
defined('BASEPATH') OR exit('No direct script access allowed');
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
| -------------------------------------------------------------------
 | 
			
		||||
| AUTO-LOADER
 | 
			
		||||
| -------------------------------------------------------------------
 | 
			
		||||
| This file specifies which systems should be loaded by default.
 | 
			
		||||
|
 | 
			
		||||
| In order to keep the framework as light-weight as possible only the
 | 
			
		||||
| absolute minimal resources are loaded by default. For example,
 | 
			
		||||
| the database is not connected to automatically since no assumption
 | 
			
		||||
| is made regarding whether you intend to use it.  This file lets
 | 
			
		||||
| you globally define which systems you would like loaded with every
 | 
			
		||||
| request.
 | 
			
		||||
|
 | 
			
		||||
| -------------------------------------------------------------------
 | 
			
		||||
| Instructions
 | 
			
		||||
| -------------------------------------------------------------------
 | 
			
		||||
|
 | 
			
		||||
| These are the things you can load automatically:
 | 
			
		||||
|
 | 
			
		||||
| 1. Packages
 | 
			
		||||
| 2. Libraries
 | 
			
		||||
| 3. Drivers
 | 
			
		||||
| 4. Helper files
 | 
			
		||||
| 5. Custom config files
 | 
			
		||||
| 6. Language files
 | 
			
		||||
| 7. Models
 | 
			
		||||
|
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
| -------------------------------------------------------------------
 | 
			
		||||
|  Auto-load Packages
 | 
			
		||||
| -------------------------------------------------------------------
 | 
			
		||||
| Prototype:
 | 
			
		||||
|
 | 
			
		||||
|  $autoload['packages'] = array(APPPATH.'third_party', '/usr/local/shared');
 | 
			
		||||
|
 | 
			
		||||
*/
 | 
			
		||||
$autoload['packages'] = array();
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
| -------------------------------------------------------------------
 | 
			
		||||
|  Auto-load Libraries
 | 
			
		||||
| -------------------------------------------------------------------
 | 
			
		||||
| These are the classes located in system/libraries/ or your
 | 
			
		||||
| application/libraries/ directory, with the addition of the
 | 
			
		||||
| 'database' library, which is somewhat of a special case.
 | 
			
		||||
|
 | 
			
		||||
| Prototype:
 | 
			
		||||
|
 | 
			
		||||
|	$autoload['libraries'] = array('database', 'email', 'session');
 | 
			
		||||
|
 | 
			
		||||
| You can also supply an alternative library name to be assigned
 | 
			
		||||
| in the controller:
 | 
			
		||||
|
 | 
			
		||||
|	$autoload['libraries'] = array('user_agent' => 'ua');
 | 
			
		||||
*/
 | 
			
		||||
$autoload['libraries'] = array();
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
| -------------------------------------------------------------------
 | 
			
		||||
|  Auto-load Drivers
 | 
			
		||||
| -------------------------------------------------------------------
 | 
			
		||||
| These classes are located in system/libraries/ or in your
 | 
			
		||||
| application/libraries/ directory, but are also placed inside their
 | 
			
		||||
| own subdirectory and they extend the CI_Driver_Library class. They
 | 
			
		||||
| offer multiple interchangeable driver options.
 | 
			
		||||
|
 | 
			
		||||
| Prototype:
 | 
			
		||||
|
 | 
			
		||||
|	$autoload['drivers'] = array('cache');
 | 
			
		||||
|
 | 
			
		||||
| You can also supply an alternative property name to be assigned in
 | 
			
		||||
| the controller:
 | 
			
		||||
|
 | 
			
		||||
|	$autoload['drivers'] = array('cache' => 'cch');
 | 
			
		||||
|
 | 
			
		||||
*/
 | 
			
		||||
$autoload['drivers'] = array();
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
| -------------------------------------------------------------------
 | 
			
		||||
|  Auto-load Helper Files
 | 
			
		||||
| -------------------------------------------------------------------
 | 
			
		||||
| Prototype:
 | 
			
		||||
|
 | 
			
		||||
|	$autoload['helper'] = array('url', 'file');
 | 
			
		||||
*/
 | 
			
		||||
$autoload['helper'] = array('url');
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
| -------------------------------------------------------------------
 | 
			
		||||
|  Auto-load Config files
 | 
			
		||||
| -------------------------------------------------------------------
 | 
			
		||||
| Prototype:
 | 
			
		||||
|
 | 
			
		||||
|	$autoload['config'] = array('config1', 'config2');
 | 
			
		||||
|
 | 
			
		||||
| NOTE: This item is intended for use ONLY if you have created custom
 | 
			
		||||
| config files.  Otherwise, leave it blank.
 | 
			
		||||
|
 | 
			
		||||
*/
 | 
			
		||||
$autoload['config'] = array();
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
| -------------------------------------------------------------------
 | 
			
		||||
|  Auto-load Language files
 | 
			
		||||
| -------------------------------------------------------------------
 | 
			
		||||
| Prototype:
 | 
			
		||||
|
 | 
			
		||||
|	$autoload['language'] = array('lang1', 'lang2');
 | 
			
		||||
|
 | 
			
		||||
| NOTE: Do not include the "_lang" part of your file.  For example
 | 
			
		||||
| "codeigniter_lang.php" would be referenced as array('codeigniter');
 | 
			
		||||
|
 | 
			
		||||
*/
 | 
			
		||||
$autoload['language'] = array();
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
| -------------------------------------------------------------------
 | 
			
		||||
|  Auto-load Models
 | 
			
		||||
| -------------------------------------------------------------------
 | 
			
		||||
| Prototype:
 | 
			
		||||
|
 | 
			
		||||
|	$autoload['model'] = array('first_model', 'second_model');
 | 
			
		||||
|
 | 
			
		||||
| You can also supply an alternative model name to be assigned
 | 
			
		||||
| in the controller:
 | 
			
		||||
|
 | 
			
		||||
|	$autoload['model'] = array('first_model' => 'first');
 | 
			
		||||
*/
 | 
			
		||||
$autoload['model'] = array();
 | 
			
		||||
@@ -23,7 +23,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
 | 
			
		||||
| a PHP script and you can easily do that on your own.
 | 
			
		||||
|
 | 
			
		||||
*/
 | 
			
		||||
$config['base_url'] = '';
 | 
			
		||||
$config['base_url'] = '/~teissier/SAe-PHP-S2';
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
|--------------------------------------------------------------------------
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										532
									
								
								application/config/config.php~
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										532
									
								
								application/config/config.php~
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -76,9 +76,9 @@ $query_builder = TRUE;
 | 
			
		||||
$db['default'] = array(
 | 
			
		||||
	'dsn'	=> '',
 | 
			
		||||
	'hostname' => 'localhost',
 | 
			
		||||
	'username' => '',
 | 
			
		||||
	'password' => '',
 | 
			
		||||
	'database' => '',
 | 
			
		||||
	'username' => 'teissier',
 | 
			
		||||
	'password' => 'teissier',
 | 
			
		||||
	'database' => 'teissier',
 | 
			
		||||
	'dbdriver' => 'mysqli',
 | 
			
		||||
	'dbprefix' => '',
 | 
			
		||||
	'pconnect' => FALSE,
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										96
									
								
								application/config/database.php~
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										96
									
								
								application/config/database.php~
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,96 @@
 | 
			
		||||
<?php
 | 
			
		||||
defined('BASEPATH') OR exit('No direct script access allowed');
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
| -------------------------------------------------------------------
 | 
			
		||||
| DATABASE CONNECTIVITY SETTINGS
 | 
			
		||||
| -------------------------------------------------------------------
 | 
			
		||||
| This file will contain the settings needed to access your database.
 | 
			
		||||
|
 | 
			
		||||
| For complete instructions please consult the 'Database Connection'
 | 
			
		||||
| page of the User Guide.
 | 
			
		||||
|
 | 
			
		||||
| -------------------------------------------------------------------
 | 
			
		||||
| EXPLANATION OF VARIABLES
 | 
			
		||||
| -------------------------------------------------------------------
 | 
			
		||||
|
 | 
			
		||||
|	['dsn']      The full DSN string describe a connection to the database.
 | 
			
		||||
|	['hostname'] The hostname of your database server.
 | 
			
		||||
|	['username'] The username used to connect to the database
 | 
			
		||||
|	['password'] The password used to connect to the database
 | 
			
		||||
|	['database'] The name of the database you want to connect to
 | 
			
		||||
|	['dbdriver'] The database driver. e.g.: mysqli.
 | 
			
		||||
|			Currently supported:
 | 
			
		||||
|				 cubrid, ibase, mssql, mysql, mysqli, oci8,
 | 
			
		||||
|				 odbc, pdo, postgre, sqlite, sqlite3, sqlsrv
 | 
			
		||||
|	['dbprefix'] You can add an optional prefix, which will be added
 | 
			
		||||
|				 to the table name when using the  Query Builder class
 | 
			
		||||
|	['pconnect'] TRUE/FALSE - Whether to use a persistent connection
 | 
			
		||||
|	['db_debug'] TRUE/FALSE - Whether database errors should be displayed.
 | 
			
		||||
|	['cache_on'] TRUE/FALSE - Enables/disables query caching
 | 
			
		||||
|	['cachedir'] The path to the folder where cache files should be stored
 | 
			
		||||
|	['char_set'] The character set used in communicating with the database
 | 
			
		||||
|	['dbcollat'] The character collation used in communicating with the database
 | 
			
		||||
|				 NOTE: For MySQL and MySQLi databases, this setting is only used
 | 
			
		||||
| 				 as a backup if your server is running PHP < 5.2.3 or MySQL < 5.0.7
 | 
			
		||||
|				 (and in table creation queries made with DB Forge).
 | 
			
		||||
| 				 There is an incompatibility in PHP with mysql_real_escape_string() which
 | 
			
		||||
| 				 can make your site vulnerable to SQL injection if you are using a
 | 
			
		||||
| 				 multi-byte character set and are running versions lower than these.
 | 
			
		||||
| 				 Sites using Latin-1 or UTF-8 database character set and collation are unaffected.
 | 
			
		||||
|	['swap_pre'] A default table prefix that should be swapped with the dbprefix
 | 
			
		||||
|	['encrypt']  Whether or not to use an encrypted connection.
 | 
			
		||||
|
 | 
			
		||||
|			'mysql' (deprecated), 'sqlsrv' and 'pdo/sqlsrv' drivers accept TRUE/FALSE
 | 
			
		||||
|			'mysqli' and 'pdo/mysql' drivers accept an array with the following options:
 | 
			
		||||
|
 | 
			
		||||
|				'ssl_key'    - Path to the private key file
 | 
			
		||||
|				'ssl_cert'   - Path to the public key certificate file
 | 
			
		||||
|				'ssl_ca'     - Path to the certificate authority file
 | 
			
		||||
|				'ssl_capath' - Path to a directory containing trusted CA certificates in PEM format
 | 
			
		||||
|				'ssl_cipher' - List of *allowed* ciphers to be used for the encryption, separated by colons (':')
 | 
			
		||||
|				'ssl_verify' - TRUE/FALSE; Whether verify the server certificate or not
 | 
			
		||||
|
 | 
			
		||||
|	['compress'] Whether or not to use client compression (MySQL only)
 | 
			
		||||
|	['stricton'] TRUE/FALSE - forces 'Strict Mode' connections
 | 
			
		||||
|							- good for ensuring strict SQL while developing
 | 
			
		||||
|	['ssl_options']	Used to set various SSL options that can be used when making SSL connections.
 | 
			
		||||
|	['failover'] array - A array with 0 or more data for connections if the main should fail.
 | 
			
		||||
|	['save_queries'] TRUE/FALSE - Whether to "save" all executed queries.
 | 
			
		||||
| 				NOTE: Disabling this will also effectively disable both
 | 
			
		||||
| 				$this->db->last_query() and profiling of DB queries.
 | 
			
		||||
| 				When you run a query, with this setting set to TRUE (default),
 | 
			
		||||
| 				CodeIgniter will store the SQL statement for debugging purposes.
 | 
			
		||||
| 				However, this may cause high memory usage, especially if you run
 | 
			
		||||
| 				a lot of SQL queries ... disable this to avoid that problem.
 | 
			
		||||
|
 | 
			
		||||
| The $active_group variable lets you choose which connection group to
 | 
			
		||||
| make active.  By default there is only one group (the 'default' group).
 | 
			
		||||
|
 | 
			
		||||
| The $query_builder variables lets you determine whether or not to load
 | 
			
		||||
| the query builder class.
 | 
			
		||||
*/
 | 
			
		||||
$active_group = 'default';
 | 
			
		||||
$query_builder = TRUE;
 | 
			
		||||
 | 
			
		||||
$db['default'] = array(
 | 
			
		||||
	'dsn'	=> '',
 | 
			
		||||
	'hostname' => 'localhost',
 | 
			
		||||
	'username' => 'teissier',
 | 
			
		||||
	'password' => 'teissier',
 | 
			
		||||
	'database' => 'teissier',
 | 
			
		||||
	'dbdriver' => 'mysqli',
 | 
			
		||||
	'dbprefix' => '',
 | 
			
		||||
	'pconnect' => FALSE,
 | 
			
		||||
	'db_debug' => (ENVIRONMENT !== 'production'),
 | 
			
		||||
	'cache_on' => FALSE,
 | 
			
		||||
	'cachedir' => '',
 | 
			
		||||
	'char_set' => 'utf8',
 | 
			
		||||
	'dbcollat' => 'utf8_general_ci',
 | 
			
		||||
	'swap_pre' => '',
 | 
			
		||||
	'encrypt' => FALSE,
 | 
			
		||||
	'compress' => FALSE,
 | 
			
		||||
	'stricton' => FALSE,
 | 
			
		||||
	'failover' => array(),
 | 
			
		||||
	'save_queries' => TRUE
 | 
			
		||||
);
 | 
			
		||||
							
								
								
									
										18
									
								
								application/controllers/Albums.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								application/controllers/Albums.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,18 @@
 | 
			
		||||
<?php
 | 
			
		||||
defined('BASEPATH') OR exit('No direct script access allowed');
 | 
			
		||||
 | 
			
		||||
class Albums extends CI_Controller {
 | 
			
		||||
 | 
			
		||||
	public function __construct(){
 | 
			
		||||
		parent::__construct();
 | 
			
		||||
		$this->load->model('model_music');
 | 
			
		||||
	}
 | 
			
		||||
	public function index(){
 | 
			
		||||
		$albums = $this->model_music->getAlbums();
 | 
			
		||||
		$this->load->view('layout/header');
 | 
			
		||||
		$this->load->view('albums_list',['albums'=>$albums]);
 | 
			
		||||
		$this->load->view('layout/footer');
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										20
									
								
								application/models/Model_music.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								application/models/Model_music.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,20 @@
 | 
			
		||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');                                             
 | 
			
		||||
 | 
			
		||||
class Model_music extends CI_Model {
 | 
			
		||||
	public function __construct(){
 | 
			
		||||
		$this->load->database();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public function getAlbums(){
 | 
			
		||||
		$query = $this->db->query(
 | 
			
		||||
			"SELECT album.name,album.id,year,artist.name as artistName, genre.name as genreName,jpeg 
 | 
			
		||||
			FROM album 
 | 
			
		||||
			JOIN artist ON album.artistid = artist.id
 | 
			
		||||
			JOIN genre ON genre.id = album.genreid
 | 
			
		||||
			JOIN cover ON cover.id = album.coverid
 | 
			
		||||
			ORDER BY year
 | 
			
		||||
			"
 | 
			
		||||
		);
 | 
			
		||||
	return $query->result();
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										14
									
								
								application/views/albums_list.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								application/views/albums_list.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,14 @@
 | 
			
		||||
<h5>Albums list</h5>
 | 
			
		||||
<section class="list">
 | 
			
		||||
<?php
 | 
			
		||||
foreach($albums as $album){
 | 
			
		||||
	echo "<div><article>";
 | 
			
		||||
	echo "<header class='short-text'>";
 | 
			
		||||
	echo anchor("albums/view/{$album->id}","{$album->name}");
 | 
			
		||||
	echo "</header>";
 | 
			
		||||
	echo '<img src="data:image/jpeg;base64,'.base64_encode($album->jpeg).'" />';
 | 
			
		||||
	echo "<footer class='short-text'>{$album->year} - {$album->artistName}</footer>
 | 
			
		||||
	  </article></div>";
 | 
			
		||||
}
 | 
			
		||||
?>
 | 
			
		||||
</section>
 | 
			
		||||
							
								
								
									
										3
									
								
								application/views/layout/footer.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								application/views/layout/footer.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,3 @@
 | 
			
		||||
</main>
 | 
			
		||||
	</body>
 | 
			
		||||
</html>
 | 
			
		||||
							
								
								
									
										25
									
								
								application/views/layout/header.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								application/views/layout/header.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,25 @@
 | 
			
		||||
<!doctype html>
 | 
			
		||||
<html lang="en" class="has-navbar-fixed-top">
 | 
			
		||||
	<head>
 | 
			
		||||
		<meta charset="UTF-8" />
 | 
			
		||||
		<title>MUSIC APP</title>
 | 
			
		||||
<link
 | 
			
		||||
  rel="stylesheet"
 | 
			
		||||
  href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.min.css"
 | 
			
		||||
/>
 | 
			
		||||
 | 
			
		||||
   <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
 | 
			
		||||
   <?=link_tag('assets/style.css')?>
 | 
			
		||||
	</head>
 | 
			
		||||
	<body>
 | 
			
		||||
		<main class='container'>
 | 
			
		||||
			<nav>
 | 
			
		||||
  <ul>
 | 
			
		||||
    <li><strong>Music APP</strong></li>
 | 
			
		||||
  </ul>
 | 
			
		||||
  <ul>
 | 
			
		||||
  <li><?=anchor('albums','Albums');?></li>
 | 
			
		||||
  <li><?=anchor('artistes','Artistes');?></li>
 | 
			
		||||
  <li><?=anchor('playlist','Playlist');?></li>
 | 
			
		||||
  </ul>
 | 
			
		||||
</nav>
 | 
			
		||||
							
								
								
									
										25
									
								
								application/views/layout/header.php~
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								application/views/layout/header.php~
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,25 @@
 | 
			
		||||
<!doctype html>
 | 
			
		||||
<html lang="en" class="has-navbar-fixed-top">
 | 
			
		||||
	<head>
 | 
			
		||||
		<meta charset="UTF-8" />
 | 
			
		||||
		<title>MUSIC APP</title>
 | 
			
		||||
<link
 | 
			
		||||
  rel="stylesheet"
 | 
			
		||||
  href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.min.css"
 | 
			
		||||
/>
 | 
			
		||||
 | 
			
		||||
   <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
 | 
			
		||||
   <?=link_tag('assets/style.css')?>
 | 
			
		||||
	</head>
 | 
			
		||||
	<body>
 | 
			
		||||
		<main class='container'>
 | 
			
		||||
			<nav>
 | 
			
		||||
  <ul>
 | 
			
		||||
    <li><strong>Music APP</strong></li>
 | 
			
		||||
  </ul>
 | 
			
		||||
  <ul>
 | 
			
		||||
  <li><?=anchor('albums','Albums');?></li>
 | 
			
		||||
  <li><?=anchor('artistes','Artistes');?></li>
 | 
			
		||||
  <li><?=anchor('playlist','Playlist');?></li>
 | 
			
		||||
  </ul>
 | 
			
		||||
</nav>
 | 
			
		||||
							
								
								
									
										20
									
								
								assets/style.css
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								assets/style.css
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,20 @@
 | 
			
		||||
section.list
 | 
			
		||||
{
 | 
			
		||||
	display : flex;
 | 
			
		||||
	justify-content : space-between;
 | 
			
		||||
	flex-wrap:wrap;
 | 
			
		||||
}
 | 
			
		||||
section.list > div 
 | 
			
		||||
{
 | 
			
		||||
width : 30%;
 | 
			
		||||
}
 | 
			
		||||
section.list img {
 | 
			
		||||
	display:inline-block;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
.short-text {
 | 
			
		||||
	overflow: hidden;
 | 
			
		||||
	white-space: nowrap;
 | 
			
		||||
	text-overflow: ellipsis;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user