kritbit

kritbit Commit Details


Date:2015-11-22 22:05:45 (9 years 29 days ago)
Author:root
Branch:master
Commit:a9094e4b945722c869b1f620b8b351177c8b8f0d
Parents: 689e8a6fb9471d2bc1dad67d5737b146b7bdbc25
Message:Fixing case

Changes:

File differences

web/application/models/Histories.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
namespace application\models;
class Histories extends \system\engine\HF_Model {
public $output;
public $jobs_id;
public $run_date;
public $time_taken;
public $result = null;
public $nonce;
public $h2o_safe = true;
public function getTRClass() {
if ($this->result == null) {
return "";
} elseif ($this->result == 0) {
return "success";
} else {
return "danger";
}
}
}
web/application/models/Jobs.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
namespace application\models;
class Jobs extends \system\engine\HF_Model {
public $jobName;
public $runType;
public $runScript;
public $cron;
public $failScript;
public $last_run;
public $last_result = null;
public $user_id;
public $hash;
public $sharedkey;
public $view_private;
public $force_run;
public $comments;
public $h2o_safe = true;
public function getRunType() {
switch ($this->runType) {
case "1":
return "Ran by Kritbit";
break;
case "2":
return "External Source";
break;
}
return "";
}
public function getLastRun() {
if ($this->last_run == "") {
return "Never";
} else {
return $this->last_run;
}
}
public function getTRClass() {
if ($this->last_run == "" || $this->last_result == null) {
return "";
} elseif ($this->last_result == 0) {
return "success";
} else {
return "danger";
}
}
}
web/application/models/Sessions.php
1
2
3
4
5
6
7
8
9
10
<?php
namespace application\models;
class Sessions extends \system\engine\HF_Model {
public $sessionid;
public $ip;
public $userAgent;
public $data;
}
web/application/models/Users.php
1
2
3
4
5
6
7
8
9
10
<?php
namespace application\models;
use system\engine\HF_Model;
class Users extends HF_Model
{
public $email;
}
web/application/models/histories.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
namespace application\models;
class Histories extends \system\engine\HF_Model {
public $output;
public $jobs_id;
public $run_date;
public $time_taken;
public $result = null;
public $nonce;
public $h2o_safe = true;
public function getTRClass() {
if ($this->result == null) {
return "";
} elseif ($this->result == 0) {
return "success";
} else {
return "danger";
}
}
}
web/application/models/jobs.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
namespace application\models;
class Jobs extends \system\engine\HF_Model {
public $jobName;
public $runType;
public $runScript;
public $cron;
public $failScript;
public $last_run;
public $last_result = null;
public $user_id;
public $hash;
public $sharedkey;
public $view_private;
public $force_run;
public $comments;
public $h2o_safe = true;
public function getRunType() {
switch ($this->runType) {
case "1":
return "Ran by Kritbit";
break;
case "2":
return "External Source";
break;
}
return "";
}
public function getLastRun() {
if ($this->last_run == "") {
return "Never";
} else {
return $this->last_run;
}
}
public function getTRClass() {
if ($this->last_run == "" || $this->last_result == null) {
return "";
} elseif ($this->last_result == 0) {
return "success";
} else {
return "danger";
}
}
}
web/application/models/sessions.php
1
2
3
4
5
6
7
8
9
10
<?php
namespace application\models;
class Sessions extends \system\engine\HF_Model {
public $sessionid;
public $ip;
public $userAgent;
public $data;
}
web/application/models/users.php
1
2
3
4
5
6
7
8
9
10
<?php
namespace application\models;
use system\engine\HF_Model;
class Users extends HF_Model
{
public $email;
}
web/system/engine/hf_smtp.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
namespace system\engine;
// Based on tutorial from here: https://portal.cyberhostpro.com/knowledgebase/170/PHP-Mail-Script-with-SMTP-Authentication.html
class HF_SMTP
{
private $from = "";
private $to = "";
private $subject = "";
private $msg = "";
private $user = null;
private $password = null;
private $port = 25;
private $server = "localhost";
private $smtpserverconn = null;
public function __construct($from, $to, $subject, $msg, $server = "localhost", $user = null, $password = null, $port = 25)
{
$this->from = $from;
$this->to = $to;
$this->subject = $subject;
$this->msg = $msg;
$this->user = $user;
$this->password = $password;
$this->port = $port;
$this->server = $server;
}
public function send($html=false)
{
$err = null;
$errstr = "";
$this->smtpserverconn = fsockopen($this->server, $this->port, $err, $errstr, 100);
$response = fgets($this->smtpserverconn, 515);
if ($response === false)
{
throw new Exception("Could not connect to SMTP server!");
}
if ($this->user != null && $this->password != null)
{
$this->sendCommand("AUTH LOGIN");
$this->sendCommand(base64_encode($this->user));
$this->sendCommand(base64_encode($this->password));
}
$this->sendCommand("HELO " . $_SERVER["SERVER_NAME"]);
$this->sendCommand("MAIL FROM: " . $this->from);
$this->sendCommand("RCPT TO: " . $this->to);
$this->sendCommand("DATA");
if ($html)
{
$this->sendCommand("MIME-Version: 1.0", false);
$this->sendCommand("Content-type: text/html; charset=iso-8859-1", false);
}
$this->sendCommand("From: " . $this->from, false);
$this->sendCommand("To: " . $this->to, false);
$this->sendCommand("Subject: " . $this->subject, false);
$this->sendCommand($this->msg, false);
$this->sendCommand("", false);
$this->sendCommand(".", false);
$this->sendCommand("QUIT");
}
private function sendCommand($command, $return = true)
{
fputs($this->smtpserverconn, $command . "\r\n");
if ($return)
return fgets($this->smtpserverconn, 515);
else
return null;
}
}
web/system/engine/smtp.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
namespace system\engine;
// Based on tutorial from here: https://portal.cyberhostpro.com/knowledgebase/170/PHP-Mail-Script-with-SMTP-Authentication.html
class HF_SMTP
{
private $from = "";
private $to = "";
private $subject = "";
private $msg = "";
private $user = null;
private $password = null;
private $port = 25;
private $server = "localhost";
private $smtpserverconn = null;
public function __construct($from, $to, $subject, $msg, $server = "localhost", $user = null, $password = null, $port = 25)
{
$this->from = $from;
$this->to = $to;
$this->subject = $subject;
$this->msg = $msg;
$this->user = $user;
$this->password = $password;
$this->port = $port;
$this->server = $server;
}
public function send($html=false)
{
$err = null;
$errstr = "";
$this->smtpserverconn = fsockopen($this->server, $this->port, $err, $errstr, 100);
$response = fgets($this->smtpserverconn, 515);
if ($response === false)
{
throw new Exception("Could not connect to SMTP server!");
}
if ($this->user != null && $this->password != null)
{
$this->sendCommand("AUTH LOGIN");
$this->sendCommand(base64_encode($this->user));
$this->sendCommand(base64_encode($this->password));
}
$this->sendCommand("HELO " . $_SERVER["SERVER_NAME"]);
$this->sendCommand("MAIL FROM: " . $this->from);
$this->sendCommand("RCPT TO: " . $this->to);
$this->sendCommand("DATA");
if ($html)
{
$this->sendCommand("MIME-Version: 1.0", false);
$this->sendCommand("Content-type: text/html; charset=iso-8859-1", false);
}
$this->sendCommand("From: " . $this->from, false);
$this->sendCommand("To: " . $this->to, false);
$this->sendCommand("Subject: " . $this->subject, false);
$this->sendCommand($this->msg, false);
$this->sendCommand("", false);
$this->sendCommand(".", false);
$this->sendCommand("QUIT");
}
private function sendCommand($command, $return = true)
{
fputs($this->smtpserverconn, $command . "\r\n");
if ($return)
return fgets($this->smtpserverconn, 515);
else
return null;
}
}
web/system/vendor/phpoauthlib2/OAuth.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php
namespace system\vendor\phpoauthlib2;
class OAuth {
protected $oauthProvider = null;
protected $request = null;
public function __construct($provider, $request) {
$this->oauthProvider = $provider;
$this->request = $request;
}
public function check() {
if (isset($this->request["code"]) && !empty($this->request["code"])) {
$this->oauthProvider->getProfile();
return true;
} else {
return $this->oauthProvider->getLoginUrl();
}
}
public function getProfile() {
return $this->oauthProvider->getProfile();
}
}
web/system/vendor/phpoauthlib2/OAuthDataProvider.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?php
namespace system\vendor\phpoauthlib2;
require "ccurl.php";
use phpoauthlib2\ccurl;
class OAUTH_SCOPES {
const EMAIL = "EMAIL";
}
class OAuthDataProvider {
protected $version = "2.0";
protected $name = "undefined";
protected $responseType = "code";
protected $header = "Authorization: Bearer";
protected $profile = "";
protected $dialog = "";
protected $nonce = null;
protected $accessToken = null;
protected $state = "";
protected $redirectURL = "";
protected $scope = "";
protected $clientId = "";
protected $client_secret = "";
protected $request = null;
protected $profileData = [];
public function __construct($profile, $dialog, $accessToken, $request, $header="Authorization: Bearer") {
$this->profile = $profile;
$this->dialog = $dialog;
$this->accessToken = $accessToken;
$this->header = $header;
$this->request = $request;
}
public function getLoginUrl() {
$urlBuilder = [];
$urlBuilder[] = "client_id=" . $this->clientId;
$urlBuilder[] = "response_type=" . $this->responseType;
$urlBuilder[] = "scope=" . $this->scope;
$urlBuilder[] = "state=" . $this->state;
$urlBuilder[] = "redirect_uri=" . urlencode($this->redirectURL);
return $this->dialog . "?" . implode("&", $urlBuilder);
}
protected function getToken() {
$tokenBuilder = [];
$tokenBuilder["client_id"] = $this->clientId;
$tokenBuilder["client_secret"] = $this->client_secret;
$tokenBuilder["grant_type"] = "authorization_code";
$tokenBuilder["redirect_uri"] = htmlspecialchars($this->redirectURL);
$tokenBuilder["code"] = $this->request["code"];
$curl = new ccurl($this->accessToken);
$curl->setPost($tokenBuilder);
$curl->createCurl();
return (string)$curl;
}
protected function parseToken() {
$token = $this->getToken();
$convertedToken = json_decode($token, true);
if (!$convertedToken) {
$realToken = $token;
} else {
$realToken = $convertedToken["access_token"];
}
return $realToken;
}
public function getProfile() {
$token = $this->parseToken();
$profileUrl = $this->profile . "=" . $token;
$curl = new ccurl($profileUrl);
$curl->addHeader($this->header . " " . $token);
$curl->createCurl();
$this->profileData = json_decode((string)$curl, true);
return (string)$curl;
}
public function getEmail() {
return null;
}
public function getFirstName() {
return null;
}
public function getLastName() {
return null;
}
public function getGender() {
return null;
}
public function getId() {
return null;
}
public function getRawProfile() {
return $this->profileData;
}
public function getSource() {
return null;
}
}
web/system/vendor/phpoauthlib2/oauth.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php
namespace system\vendor\phpoauthlib2;
class OAuth {
protected $oauthProvider = null;
protected $request = null;
public function __construct($provider, $request) {
$this->oauthProvider = $provider;
$this->request = $request;
}
public function check() {
if (isset($this->request["code"]) && !empty($this->request["code"])) {
$this->oauthProvider->getProfile();
return true;
} else {
return $this->oauthProvider->getLoginUrl();
}
}
public function getProfile() {
return $this->oauthProvider->getProfile();
}
}
web/system/vendor/phpoauthlib2/oauthdataprovider.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?php
namespace system\vendor\phpoauthlib2;
require "ccurl.php";
use phpoauthlib2\ccurl;
class OAUTH_SCOPES {
const EMAIL = "EMAIL";
}
class OAuthDataProvider {
protected $version = "2.0";
protected $name = "undefined";
protected $responseType = "code";
protected $header = "Authorization: Bearer";
protected $profile = "";
protected $dialog = "";
protected $nonce = null;
protected $accessToken = null;
protected $state = "";
protected $redirectURL = "";
protected $scope = "";
protected $clientId = "";
protected $client_secret = "";
protected $request = null;
protected $profileData = [];
public function __construct($profile, $dialog, $accessToken, $request, $header="Authorization: Bearer") {
$this->profile = $profile;
$this->dialog = $dialog;
$this->accessToken = $accessToken;
$this->header = $header;
$this->request = $request;
}
public function getLoginUrl() {
$urlBuilder = [];
$urlBuilder[] = "client_id=" . $this->clientId;
$urlBuilder[] = "response_type=" . $this->responseType;
$urlBuilder[] = "scope=" . $this->scope;
$urlBuilder[] = "state=" . $this->state;
$urlBuilder[] = "redirect_uri=" . urlencode($this->redirectURL);
return $this->dialog . "?" . implode("&", $urlBuilder);
}
protected function getToken() {
$tokenBuilder = [];
$tokenBuilder["client_id"] = $this->clientId;
$tokenBuilder["client_secret"] = $this->client_secret;
$tokenBuilder["grant_type"] = "authorization_code";
$tokenBuilder["redirect_uri"] = htmlspecialchars($this->redirectURL);
$tokenBuilder["code"] = $this->request["code"];
$curl = new ccurl($this->accessToken);
$curl->setPost($tokenBuilder);
$curl->createCurl();
return (string)$curl;
}
protected function parseToken() {
$token = $this->getToken();
$convertedToken = json_decode($token, true);
if (!$convertedToken) {
$realToken = $token;
} else {
$realToken = $convertedToken["access_token"];
}
return $realToken;
}
public function getProfile() {
$token = $this->parseToken();
$profileUrl = $this->profile . "=" . $token;
$curl = new ccurl($profileUrl);
$curl->addHeader($this->header . " " . $token);
$curl->createCurl();
$this->profileData = json_decode((string)$curl, true);
return (string)$curl;
}
public function getEmail() {
return null;
}
public function getFirstName() {
return null;
}
public function getLastName() {
return null;
}
public function getGender() {
return null;
}
public function getId() {
return null;
}
public function getRawProfile() {
return $this->profileData;
}
public function getSource() {
return null;
}
}
web/system/vendor/phpoauthlib2/providers/FacebookAuthProvider.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
namespace system\vendor\phpoauthlib2\providers;
require "OAuthDataProvider.php";
use phpoauthlib2\ccurl;
use phpoauthlib2\OAUTH_SCOPES;
use phpoauthlib2\OAuthDataProvider;
class FacebookAuthProvider extends OAuthDataProvider {
public function __construct($request, $conf, $scopes=[OAUTH_SCOPES::EMAIL]) {
parent::__construct(
"https://graph.facebook.com/me",
"https://www.facebook.com/dialog/oauth",
"https://graph.facebook.com/oauth/access_token",
$request
);
$this->client_secret = $conf["client_secret"];
$this->redirectURL = $conf["redirect_uri"];
$this->clientId = $conf["client_id"];
$tempScopes = [];
foreach($scopes as $scope) {
switch ($scope) {
case OAUTH_SCOPES::EMAIL:
$tempScopes[] = "email";
}
}
$tempScopes[] = "public_profile";
$this->scope = implode(" ", $tempScopes);
}
public function getEmail() {
return $this->profileData["email"];
}
public function getFirstName() {
return $this->profileData["first_name"];
}
public function getLastName() {
return $this->profileData["last_name"];
}
public function getId() {
return $this->profileData["id"];
}
public function getSource() {
return "FACEBOOK";
}
public function parseToken() {
$token = $this->getToken();
return explode("=", $token)[1];
}
public function getProfile() {
$token = $this->parseToken();
$profileUrl = $this->profile . "?fields=first_name,last_name,name,email,age_range&access_token=" . $token;
$curl = new ccurl($profileUrl);
$curl->createCurl();
$ret = (string)$curl;
$this->profileData = json_decode($ret, true);
return $ret;
}
}
web/system/vendor/phpoauthlib2/providers/GoogleAuthProvider.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
namespace system\vendor\phpoauthlib2\providers;
use phpoauthlib2\ccurl;
use system\vendor\phpoauthlib2\OAUTH_SCOPES;
use system\vendor\phpoauthlib2\OAuth;
use system\vendor\phpoauthlib2\OAuthDataProvider;
class GoogleAuthProvider extends OAuthDataProvider {
public function __construct($request, $conf, $scopes=[OAUTH_SCOPES::EMAIL]) {
parent::__construct(
"https://www.googleapis.com/oauth2/v1/userinfo?access_token",
"https://accounts.google.com/o/oauth2/auth",
"https://accounts.google.com/o/oauth2/token", $request);
$this->client_secret = $conf["client_secret"];
$this->redirectURL = $conf["redirect_uri"];
$this->clientId = $conf["client_id"];
$tmpScopes = [];
foreach($scopes as $scope) {
switch ($scope) {
case OAUTH_SCOPES::EMAIL:
$tmpScopes[] = "https://www.googleapis.com/auth/userinfo.email";
}
}
$this->scope = implode(" ", $tmpScopes);
}
public function getEmail() {
return $this->profileData["email"];
}
public function getFirstName() {
return $this->profileData["given_name"];
}
public function getLastName() {
return $this->profileData["family_name"];
}
public function getGender() {
return $this->profileData["gender"];
}
public function getId() {
return $this->profileData["id"];
}
public function getSource() {
return "GOOGLE";
}
}
web/system/vendor/phpoauthlib2/providers/facebookauthprovider.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
namespace system\vendor\phpoauthlib2\providers;
require "OAuthDataProvider.php";
use phpoauthlib2\ccurl;
use phpoauthlib2\OAUTH_SCOPES;
use phpoauthlib2\OAuthDataProvider;
class FacebookAuthProvider extends OAuthDataProvider {
public function __construct($request, $conf, $scopes=[OAUTH_SCOPES::EMAIL]) {
parent::__construct(
"https://graph.facebook.com/me",
"https://www.facebook.com/dialog/oauth",
"https://graph.facebook.com/oauth/access_token",
$request
);
$this->client_secret = $conf["client_secret"];
$this->redirectURL = $conf["redirect_uri"];
$this->clientId = $conf["client_id"];
$tempScopes = [];
foreach($scopes as $scope) {
switch ($scope) {
case OAUTH_SCOPES::EMAIL:
$tempScopes[] = "email";
}
}
$tempScopes[] = "public_profile";
$this->scope = implode(" ", $tempScopes);
}
public function getEmail() {
return $this->profileData["email"];
}
public function getFirstName() {
return $this->profileData["first_name"];
}
public function getLastName() {
return $this->profileData["last_name"];
}
public function getId() {
return $this->profileData["id"];
}
public function getSource() {
return "FACEBOOK";
}
public function parseToken() {
$token = $this->getToken();
return explode("=", $token)[1];
}
public function getProfile() {
$token = $this->parseToken();
$profileUrl = $this->profile . "?fields=first_name,last_name,name,email,age_range&access_token=" . $token;
$curl = new ccurl($profileUrl);
$curl->createCurl();
$ret = (string)$curl;
$this->profileData = json_decode($ret, true);
return $ret;
}
}
web/system/vendor/phpoauthlib2/providers/googleauthprovider.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
namespace system\vendor\phpoauthlib2\providers;
use phpoauthlib2\ccurl;
use system\vendor\phpoauthlib2\OAUTH_SCOPES;
use system\vendor\phpoauthlib2\OAuth;
use system\vendor\phpoauthlib2\OAuthDataProvider;
class GoogleAuthProvider extends OAuthDataProvider {
public function __construct($request, $conf, $scopes=[OAUTH_SCOPES::EMAIL]) {
parent::__construct(
"https://www.googleapis.com/oauth2/v1/userinfo?access_token",
"https://accounts.google.com/o/oauth2/auth",
"https://accounts.google.com/o/oauth2/token", $request);
$this->client_secret = $conf["client_secret"];
$this->redirectURL = $conf["redirect_uri"];
$this->clientId = $conf["client_id"];
$tmpScopes = [];
foreach($scopes as $scope) {
switch ($scope) {
case OAUTH_SCOPES::EMAIL:
$tmpScopes[] = "https://www.googleapis.com/auth/userinfo.email";
}
}
$this->scope = implode(" ", $tmpScopes);
}
public function getEmail() {
return $this->profileData["email"];
}
public function getFirstName() {
return $this->profileData["given_name"];
}
public function getLastName() {
return $this->profileData["family_name"];
}
public function getGender() {
return $this->profileData["gender"];
}
public function getId() {
return $this->profileData["id"];
}
public function getSource() {
return "GOOGLE";
}
}

Archive Download the corresponding diff file

Branches

Number of commits:
Page rendered in 0.12826s using 13 queries.