Skip to content

Commit cc0545a

Browse files
committed
initial cctrl_tutorial_app commit
0 parents  commit cc0545a

File tree

416 files changed

+25153
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

416 files changed

+25153
-0
lines changed

.ccconfig.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
BaseConfig:
2+
WebContent: /app
3+
AdminEmail: [email protected]

README.md

Whitespace-only changes.

_config.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
/**
4+
*
5+
* Every deployment gets different credentials for each Add-on. Providers
6+
* can change these credentials at any time. It is therefor required to read
7+
* the credentials from the provided JSON file to keep the application running
8+
* in case the credentials change.
9+
*
10+
* The path to the JSON file can be found in the CRED_FILE environment variable.
11+
*
12+
*/
13+
14+
# read the credentials file
15+
$string = file_get_contents($_ENV['CRED_FILE'], false);
16+
if ($string == false) {
17+
die('FATAL: Could not read credentials file');
18+
}
19+
20+
# the file contains a JSON string, decode it and return an associative array
21+
$creds = json_decode($string, true);
22+
23+
# use credentials to set the configuration for MySQL
24+
$config = array(
25+
'MYSQL_HOSTNAME' => $creds['MYSQL']['MYSQL_HOSTNAME'],
26+
'MYSQL_DATABASE' => $creds['MYSQL']['MYSQL_DATABASE'],
27+
'MYSQL_USERNAME' => $creds['MYSQL']['MYSQL_USERNAME'],
28+
'MYSQL_PASSWORD' => $creds['MYSQL']['MYSQL_PASSWORD']
29+
);
30+
31+
?>

app/.htaccess

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<IfModule mod_rewrite.c>
2+
Options -MultiViews
3+
4+
RewriteEngine On
5+
RewriteCond %{REQUEST_FILENAME} !-f
6+
RewriteRule ^ index.php [L]
7+
</IfModule>

app/index.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
require_once __DIR__.'/../silex.phar';
4+
require_once __DIR__.'/../_config.php';
5+
6+
use Symfony\Component\HttpFoundation\Request;
7+
use Symfony\Component\HttpFoundation\Response;
8+
9+
$app = new Silex\Application();
10+
11+
$app->register(new Silex\Provider\TwigServiceProvider(),
12+
array(
13+
'twig.path' => __DIR__.'/../views',
14+
'twig.class_path' => __DIR__.'/../vendor/twig/lib'
15+
)
16+
);
17+
18+
$app->get('/', function() use ($app, $config) {
19+
# check MySQL connection
20+
$success = false;
21+
$conn = mysql_connect($config['MYSQL_HOSTNAME'],
22+
$config['MYSQL_USERNAME'],
23+
$config['MYSQL_PASSWORD']);
24+
if ($conn) {
25+
$success = true;
26+
mysql_close($conn);
27+
}
28+
$is_default = false;
29+
$parsed_dep_name = explode('/', $_SERVER["DEP_NAME"]);
30+
if ($parsed_dep_name[1] == 'default') {
31+
$is_default = true;
32+
}
33+
return $app['twig']->render('index.twig', array(
34+
'success' => $success,
35+
'dep_name' => $_SERVER["DEP_NAME"],
36+
'default' => $is_default
37+
));
38+
});
39+
40+
$app->run();
41+
42+
?>
43+

silex.phar

491 KB
Binary file not shown.

vendor/twig/AUTHORS

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Twig is written and maintained by the Twig Team:
2+
3+
Lead Developer:
4+
5+
- Fabien Potencier <[email protected]>
6+
7+
Project Founder:
8+
9+
- Armin Ronacher <[email protected]>

0 commit comments

Comments
 (0)