Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ajouts #12

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion app/Config/Schema/schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ public function after($event = array(), $install = false, $updateContent = array
'passwords_hash' => 'sha256',
'passwords_salt' => 0,
'forced_updates' => 1,
'session_type' => 'php'
'session_type' => 'php',
'github_client_id' => '',
'github_client_secret' => ''
));

$configuration->save();
Expand Down Expand Up @@ -225,6 +227,8 @@ public function after($event = array(), $install = false, $updateContent = array
'passwords_salt' => array('type' => 'integer', 'null' => true, 'default' => 0, 'length' => 1, 'unsigned' => false),
'forced_updates' => array('type' => 'integer', 'null' => true, 'default' => 1, 'length' => 1, 'unsigned' => false),
'session_type' => array('type' => 'string', 'null' => true, 'default' => null, 'length' => 10, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'),
'github_client_id' => array('type' => 'string', 'null' => true, 'default' => null, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'),
'github_client_secret' => array('type' => 'string', 'null' => true, 'default' => null, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'),
'indexes' => array(
'PRIMARY' => array('column' => 'id', 'unique' => 1)
),
Expand Down
17 changes: 16 additions & 1 deletion app/Controller/AppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ public function __initConfiguration()
$youtube_link = $this->Configuration->getKey('youtube');
$twitter_link = $this->Configuration->getKey('twitter');

//partie github
$github_client_id = $this->Configuration->getKey("github_client_id");
$github_client_secret = $this->Configuration->getKey("github_client_secret");

// Variables
$google_analytics = $this->Configuration->getKey('google_analytics');
$configuration_end_code = $this->Configuration->getKey('end_layout_code');
Expand All @@ -141,7 +145,9 @@ public function __initConfiguration()
'twitter_link',
'findSocialButtons',
'google_analytics',
'configuration_end_code'
'configuration_end_code',
'github_client_id',
'github_client_secret'
));
}

Expand Down Expand Up @@ -477,13 +483,22 @@ public function blackhole($type)

public function sendGetRequest($url)
{
if(strpos($url, "api.github.com") !== false){
$github_client_id = $this->Configuration->getKey("github_client_id");
$github_client_secret = $this->Configuration->getKey("github_client_secret");

if($github_client_id != "" && $github_client_secret != "")
$url = $url . "?client_id={$github_client_id}&client_secret={$github_client_secret}";
}

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'User-Agent: MineWebCMS'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seul cette ligne est donc utile

$result = curl_exec($ch);
curl_close($ch);
return $result;
Expand Down
26 changes: 25 additions & 1 deletion app/View/Configuration/admin_index.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,31 @@
</div>

</div>

<hr>
<div>
<div class="form-group">
<label><?= $Lang->get('CONFIG_GITHUB_CLIENT_ID') ?></label>
<?= $this->Form->input(false, array(
'div' => false,
'type' => 'text',
'name' => 'github_client_id',
'class' => 'form-control',
'value' => $config['github_client_id']
)); ?>
</div>

<div class="form-group">
<label><?= $Lang->get('CONFIG_GITHUB_CLIENT_SECRET') ?></label>
<?= $this->Form->input(false, array(
'div' => false,
'type' => 'text',
'name' => 'github_client_secret',
'class' => 'form-control',
'value' => $config['github_client_secret']
)); ?>
</div>
<small><?= $Lang->get('CONFIG_GITHUB_EXPLAIN') ?></small>
</div>
</div>
<!-- /.tab-pane -->
</div>
Expand Down
5 changes: 4 additions & 1 deletion lang/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,10 @@
"CONFIG__KEY_SESSION_TYPE_INFO": "This is an advanced tuning of your site, you do not need to change it if you do not use it, by default the CMS uses php sessions.",
"CONFIG__KEY_SESSION_TYPE_PHP": "PHP / Default",
"CONFIG__KEY_SESSION_TYPE_DB": "Database",

"CONFIG_GITHUB_CLIENT_ID": "Github Client ID",
"CONFIG_GITHUB_CLIENT_SECRET": "Github Client Secret",
"CONFIG_GITHUB_EXPLAIN": "We are now using the github api in order to fetch datas around MineWeb. By default there is a rate limit which is 60request/hour. <br> If you want to increase this limit, please look at the documentation<a href=\"https://docs.mineweb.org/#github\">documentation</a>.",

"EMAIL__TITLE_CONFIRM_MAIL": "Confirm your email",
"EMAIL__CONTENT_CONFIRM_MAIL": "Hi {USERNAME}! <br> You registered on {DATE} with IP <b> {IP} </b>, you have to confirm your email by going to this link <a href=\"{LINK}\">{LINK}</a>. <br> <br> <br> This email is automatic, no need to answer. ",

Expand Down
3 changes: 3 additions & 0 deletions lang/fr_FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@
"CONFIG__KEY_SESSION_TYPE_INFO":"Ceci est un réglage avancé de votre site, il n'est pas nécessaire de le modifier si vous n'en avez pas l'utilité. Par défaut, le CMS utilise les sessions php.",
"CONFIG__KEY_SESSION_TYPE_PHP":"PHP / Par défaut",
"CONFIG__KEY_SESSION_TYPE_DB":"Base de données",
"CONFIG_GITHUB_CLIENT_ID": "Id client github",
"CONFIG_GITHUB_CLIENT_SECRET": "Clé secrète github",
"CONFIG_GITHUB_EXPLAIN": "Nous utilisons maintenant l'api de github pour pouvoir récupérer toutes les données relatives au cms. <br>Une limite de 60 requêtes par heure est imposée. Si vous souhaitez l'augmenter veuillez suivre la <a href=\"https://docs.mineweb.org/#github\">documentation</a>",

"EMAIL__TITLE_CONFIRM_MAIL": "Confirmer votre email",
"EMAIL__CONTENT_CONFIRM_MAIL": "Salut {USERNAME} ! <br> Tu t'es inscrit le {DATE} avec l'IP <b>{IP}<\/b>, tu dois confirmer ton email en te rendant sur ce lien <a href=\"{LINK}\">{LINK}<\/a>.<br><br><br>Cet email est automatique, inutile d'y répondre.",
Expand Down