Skip to content

Commit 836bb93

Browse files
author
Dan Patrick
committed
rebuild for osticket on app service
1 parent 2bb2d27 commit 836bb93

File tree

998 files changed

+227079
-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.

998 files changed

+227079
-0
lines changed

account.php

+124
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
<?php
2+
/*********************************************************************
3+
profile.php
4+
5+
Manage client profile. This will allow a logged-in user to manage
6+
his/her own public (non-internal) information
7+
8+
Peter Rotich <[email protected]>
9+
Jared Hancock <[email protected]>
10+
Copyright (c) 2006-2013 osTicket
11+
http://www.osticket.com
12+
13+
Released under the GNU General Public License WITHOUT ANY WARRANTY.
14+
See LICENSE.TXT for details.
15+
16+
vim: expandtab sw=4 ts=4 sts=4:
17+
$Id: $
18+
**********************************************************************/
19+
require 'client.inc.php';
20+
21+
$inc = 'register.inc.php';
22+
23+
$errors = array();
24+
25+
if (!$cfg || !$cfg->isClientRegistrationEnabled()) {
26+
Http::redirect('index.php');
27+
}
28+
29+
elseif ($thisclient) {
30+
// Guest registering for an account
31+
if ($thisclient->isGuest()) {
32+
foreach ($thisclient->getForms() as $f) {
33+
if ($f->get('object_type') == 'U') {
34+
$user_form = $f;
35+
$user_form->getField('email')->configure('disabled', true);
36+
}
37+
}
38+
}
39+
// Existing client (with an account) updating profile
40+
else {
41+
$user = User::lookup($thisclient->getId());
42+
$content = Page::lookupByType('registration-thanks');
43+
$inc = isset($_GET['confirmed'])
44+
? 'register.confirmed.inc.php' : 'profile.inc.php';
45+
}
46+
}
47+
48+
if ($user && $_POST) {
49+
if ($acct = $thisclient->getAccount()) {
50+
$acct->update($_POST, $errors);
51+
}
52+
if (!$errors && $user->updateInfo($_POST, $errors))
53+
Http::redirect('tickets.php');
54+
}
55+
56+
elseif ($_POST) {
57+
$user_form = UserForm::getUserForm()->getForm($_POST);
58+
if ($thisclient) {
59+
$user_form->getField('email')->configure('disabled', true);
60+
$user_form->getField('email')->value = $thisclient->getEmail();
61+
}
62+
63+
if (!$user_form->isValid(function($f) { return !$f->isVisibleToUsers(); }))
64+
$errors['err'] = __('Incomplete client information');
65+
elseif (!$_POST['backend'] && !$_POST['passwd1'])
66+
$errors['passwd1'] = __('New password is required');
67+
elseif (!$_POST['backend'] && $_POST['passwd2'] != $_POST['passwd1'])
68+
$errors['passwd1'] = __('Passwords do not match');
69+
70+
// XXX: The email will always be in use already if a guest is logged in
71+
// and is registering for an account. Instead,
72+
elseif (($addr = $user_form->getField('email')->getClean())
73+
&& ClientAccount::lookupByUsername($addr)) {
74+
$user_form->getField('email')->addError(
75+
sprintf(__('Email already registered. Would you like to %1$s sign in %2$s?'),
76+
'<a href="login.php?e='.urlencode($addr).'" style="color:inherit"><strong>',
77+
'</strong></a>'));
78+
$errors['err'] = __('Unable to register account. See messages below');
79+
}
80+
// Users created from ClientCreateRequest
81+
elseif (isset($_POST['backend']) && !($user = User::fromVars($user_form->getClean())))
82+
$errors['err'] = __('Unable to create local account. See messages below');
83+
// Registration for existing users
84+
elseif (!$user && !$thisclient && !($user = User::fromVars($user_form->getClean())))
85+
$errors['err'] = __('Unable to register account. See messages below');
86+
// New users and users registering from a ticket access link
87+
elseif (!$user && !($user = $thisclient ?: User::fromForm($user_form)))
88+
$errors['err'] = __('Unable to register account. See messages below');
89+
else {
90+
if (!($acct = ClientAccount::createForUser($user)))
91+
$errors['err'] = __('Unable to create new account.')
92+
.' '.__('Internal error occurred');
93+
elseif (!$acct->update($_POST, $errors))
94+
$errors['err'] = __('Errors configuring your profile. See messages below');
95+
}
96+
97+
if (!$errors) {
98+
switch ($_POST['do']) {
99+
case 'create':
100+
$content = Page::lookupByType('registration-confirm');
101+
$inc = 'register.confirm.inc.php';
102+
$acct->sendConfirmEmail();
103+
break;
104+
case 'import':
105+
if ($bk = UserAuthenticationBackend::getBackend($_POST['backend'])) {
106+
$cl = new ClientSession(new EndUser($user));
107+
if (!$bk->supportsInteractiveAuthentication())
108+
$acct->set('backend', null);
109+
$acct->confirm();
110+
if ($user = $bk->login($cl, $bk))
111+
Http::redirect('tickets.php');
112+
}
113+
break;
114+
}
115+
}
116+
117+
if ($errors && $user && $user != $thisclient)
118+
$user->delete();
119+
}
120+
121+
include(CLIENTINC_DIR.'header.inc.php');
122+
include(CLIENTINC_DIR.$inc);
123+
include(CLIENTINC_DIR.'footer.inc.php');
124+

ajax.php

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
/*********************************************************************
3+
ajax.php
4+
5+
Ajax utils for client interface.
6+
7+
Peter Rotich <[email protected]>
8+
Copyright (c) 2006-2013 osTicket
9+
http://www.osticket.com
10+
11+
Released under the GNU General Public License WITHOUT ANY WARRANTY.
12+
See LICENSE.TXT for details.
13+
14+
vim: expandtab sw=4 ts=4 sts=4:
15+
**********************************************************************/
16+
17+
function clientLoginPage($msg='Unauthorized') {
18+
Http::response(403,'Must login: '.Format::htmlchars($msg));
19+
exit;
20+
}
21+
22+
require('client.inc.php');
23+
24+
if(!defined('INCLUDE_DIR')) Http::response(500, 'Server configuration error');
25+
require_once INCLUDE_DIR.'/class.dispatcher.php';
26+
require_once INCLUDE_DIR.'/class.ajax.php';
27+
28+
$dispatcher = patterns('',
29+
url('^/config/', patterns('ajax.config.php:ConfigAjaxAPI',
30+
url_get('^client$', 'client')
31+
)),
32+
url('^/draft/', patterns('ajax.draft.php:DraftAjaxAPI',
33+
url_post('^(?P<id>\d+)$', 'updateDraftClient'),
34+
url_delete('^(?P<id>\d+)$', 'deleteDraftClient'),
35+
url_post('^(?P<id>\d+)/attach$', 'uploadInlineImageClient'),
36+
url_post('^(?P<namespace>[\w.]+)/attach$', 'uploadInlineImageEarlyClient'),
37+
url_get('^(?P<namespace>[\w.]+)$', 'getDraftClient'),
38+
url_post('^(?P<namespace>[\w.]+)$', 'createDraftClient')
39+
)),
40+
url('^/form/', patterns('ajax.forms.php:DynamicFormsAjaxAPI',
41+
url_get('^help-topic/(?P<id>\d+)$', 'getClientFormsForHelpTopic'),
42+
url_post('^upload/(\d+)?$', 'upload'),
43+
url_post('^upload/(\w+)?$', 'attach')
44+
)),
45+
url('^/i18n/(?P<lang>[\w_]+)/', patterns('ajax.i18n.php:i18nAjaxAPI',
46+
url_get('(?P<tag>\w+)$', 'getLanguageFile')
47+
))
48+
);
49+
Signal::send('ajax.client', $dispatcher);
50+
print $dispatcher->resolve($ost->get_path_info());
51+
?>

api/.htaccess

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<IfModule mod_rewrite.c>
2+
3+
RewriteEngine On
4+
5+
RewriteCond %{REQUEST_FILENAME} !-f
6+
RewriteCond %{REQUEST_FILENAME} !-d
7+
RewriteCond %{REQUEST_URI} (.*/api)
8+
9+
RewriteRule ^(.*)$ %1/http.php/$1 [L]
10+
11+
</IfModule>

api/api.inc.php

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
/*********************************************************************
3+
api.inc.php
4+
5+
File included on every API page...handles common includes.
6+
7+
Peter Rotich <[email protected]>
8+
Copyright (c) 2006-2013 osTicket
9+
http://www.osticket.com
10+
11+
Released under the GNU General Public License WITHOUT ANY WARRANTY.
12+
See LICENSE.TXT for details.
13+
14+
vim: expandtab sw=4 ts=4 sts=4:
15+
**********************************************************************/
16+
file_exists('../main.inc.php') or die('System Error');
17+
18+
// Disable sessions for the API. API should be considered stateless and
19+
// shouldn't chew up database records to store sessions
20+
if (!defined('DISABLE_SESSION'))
21+
define('DISABLE_SESSION', true);
22+
23+
require_once('../main.inc.php');
24+
require_once(INCLUDE_DIR.'class.http.php');
25+
require_once(INCLUDE_DIR.'class.api.php');
26+
27+
?>

api/cron.php

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
/*********************************************************************
3+
cron.php
4+
5+
File to handle LOCAL cron job calls.
6+
7+
Peter Rotich <[email protected]>
8+
Copyright (c) 2006-2013 osTicket
9+
http://www.osticket.com
10+
11+
Released under the GNU General Public License WITHOUT ANY WARRANTY.
12+
See LICENSE.TXT for details.
13+
14+
vim: expandtab sw=4 ts=4 sts=4:
15+
**********************************************************************/
16+
@chdir(dirname(__FILE__).'/'); //Change dir.
17+
require('api.inc.php');
18+
19+
if (!osTicket::is_cli())
20+
die(__('cron.php only supports local cron calls - use http -> api/tasks/cron'));
21+
22+
require_once(INCLUDE_DIR.'api.cron.php');
23+
LocalCronApiController::call();
24+
?>

api/http.php

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
/*********************************************************************
3+
http.php
4+
5+
HTTP controller for the osTicket API
6+
7+
Jared Hancock
8+
Copyright (c) 2006-2013 osTicket
9+
http://www.osticket.com
10+
11+
Released under the GNU General Public License WITHOUT ANY WARRANTY.
12+
See LICENSE.TXT for details.
13+
14+
vim: expandtab sw=4 ts=4 sts=4:
15+
**********************************************************************/
16+
// Use sessions — it's important for SSO authentication, which uses
17+
// /api/auth/ext
18+
define('DISABLE_SESSION', false);
19+
20+
require 'api.inc.php';
21+
22+
# Include the main api urls
23+
require_once INCLUDE_DIR."class.dispatcher.php";
24+
25+
$dispatcher = patterns('',
26+
url_post("^/tickets\.(?P<format>xml|json|email)$", array('api.tickets.php:TicketApiController','create')),
27+
url('^/tasks/', patterns('',
28+
url_post("^cron$", array('api.cron.php:CronApiController', 'execute'))
29+
))
30+
);
31+
32+
Signal::send('api', $dispatcher);
33+
34+
# Call the respective function
35+
print $dispatcher->resolve($ost->get_path_info());
36+
?>

api/index.php

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
header('Location: ../');
3+
?>

api/pipe.php

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/php -q
2+
<?php
3+
/*********************************************************************
4+
pipe.php
5+
6+
Converts piped emails to ticket. Just local - remote must use /api/tickets.email
7+
8+
Peter Rotich <[email protected]>
9+
Copyright (c) 2006-2013 osTicket
10+
http://www.osticket.com
11+
12+
Released under the GNU General Public License WITHOUT ANY WARRANTY.
13+
See LICENSE.TXT for details.
14+
15+
vim: expandtab sw=4 ts=4 sts=4:
16+
**********************************************************************/
17+
ini_set('memory_limit', '256M'); //The concern here is having enough mem for emails with attachments.
18+
@chdir(dirname(__FILE__).'/'); //Change dir.
19+
require('api.inc.php');
20+
21+
//Only local piping supported via pipe.php
22+
if (!osTicket::is_cli())
23+
die(__('pipe.php only supports local piping - use http -> api/tickets.email'));
24+
25+
require_once(INCLUDE_DIR.'api.tickets.php');
26+
PipeApiController::process();
27+
?>

apps/.htaccess

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<IfModule mod_rewrite.c>
2+
3+
RewriteEngine On
4+
5+
RewriteCond %{REQUEST_FILENAME} !-f
6+
RewriteCond %{REQUEST_FILENAME} !-d
7+
RewriteCond %{REQUEST_URI} (.*/apps)
8+
9+
RewriteRule ^(.*)$ %1/dispatcher.php/$1 [L]
10+
11+
</IfModule>

apps/dispatcher.php

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
/*********************************************************************
3+
dispatcher.php
4+
5+
Dispatcher for client applications
6+
7+
Jared Hancock <[email protected]>
8+
Peter Rotich <[email protected]>
9+
Copyright (c) 2006-2013 osTicket
10+
http://www.osticket.com
11+
12+
Released under the GNU General Public License WITHOUT ANY WARRANTY.
13+
See LICENSE.TXT for details.
14+
15+
vim: expandtab sw=4 ts=4 sts=4:
16+
**********************************************************************/
17+
18+
function clientLoginPage($msg='Unauthorized') {
19+
Http::response(403,'Must login: '.Format::htmlchars($msg));
20+
exit;
21+
}
22+
23+
require('client.inc.php');
24+
25+
if(!defined('INCLUDE_DIR')) Http::response(500, 'Server configuration error');
26+
require_once INCLUDE_DIR.'/class.dispatcher.php';
27+
28+
$dispatcher = new Dispatcher();
29+
30+
Signal::send('ajax.client', $dispatcher);
31+
print $dispatcher->resolve($ost->get_path_info());

assets/default/css/print.css

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)