22 define(
"TITLE_CORE_SMAUTH", _(
"SiteMinder_Login"));
27 var $Title = TITLE_CORE_SMAUTH;
29 var $Dependency = array();
30 var $PluginLevel = 1000;
43 if (empty($PG_CONN)) {
66 $session = $container->get(
'session');
67 $session->setName(
'Login');
70 if (array_key_exists(Auth::USER_ID, $_SESSION)) {
71 $SysConf[
'auth'][Auth::USER_ID] = $_SESSION[Auth::USER_ID];
75 if (! empty($_SESSION[
'time']) && @$_SESSION[
'time'] + (60 * 480) < $Now) {
76 $_SESSION[
'User'] = NULL;
77 $_SESSION[Auth::USER_ID] = NULL;
78 $_SESSION[Auth::USER_LEVEL] = NULL;
79 $SysConf[
'auth'][Auth::USER_ID] = NULL;
80 $_SESSION[
'UserEmail'] = NULL;
81 $_SESSION[
'Folder'] = NULL;
82 $_SESSION[
'UiPref'] = NULL;
90 echo
"NO DB connection";
96 if (@$_SESSION[
'User']) {
98 if (
"X" . $_SESSION[Auth::USER_LEVEL] ==
"X") {
101 $Level = $_SESSION[Auth::USER_LEVEL];
104 if (empty($_SESSION[
'time_check'])) {
105 $_SESSION[
'time_check'] = time() + (480 * 60);
107 if (time() >= @$_SESSION[
'time_check']) {
108 $sql =
"SELECT * FROM users WHERE user_pk='" . @$_SESSION[
'UserId'] .
"';";
109 $result = pg_query($PG_CONN, $sql);
111 $R = pg_fetch_assoc($result);
112 pg_free_result($result);
113 $_SESSION[
'User'] = $R[
'user_name'];
114 $_SESSION[
'Folder'] = $R[
'root_folder_fk'];
115 $_SESSION[Auth::USER_LEVEL] = $R[
'user_perm'];
116 $_SESSION[
'UserEmail'] = $R[
'user_email'];
117 $_SESSION[
'UserEnote'] = $R[
'email_notify'];
118 if (empty($R[
'ui_preference'])) {
119 $_SESSION[
'UiPref'] =
'simple';
121 $_SESSION[
'UiPref'] = $R[
'ui_preference'];
123 $Level = $_SESSION[Auth::USER_LEVEL];
127 $Level = $_SESSION[Auth::USER_LEVEL];
131 plugin_disable($Level);
133 $this->
State = PLUGIN_STATE_READY;
148 $Email = str_replace(
"'",
"''", $Email);
149 $FolderName = substr($Email, 0, strpos($Email,
'@'));
150 $FolderName =
trim($FolderName);
151 if (empty($FolderName)) {
154 $FolderDes =
"Folder created for " . $FolderName;
158 $BucketPool =
'null';
159 $sql =
"SELECT typlen FROM pg_type where typname='sysconfig' limit 1";
160 $result = pg_query($PG_CONN, $sql);
162 if (pg_num_rows($result) > 0) {
163 pg_free_result($result);
165 $sql =
"SELECT conf_value FROM sysconfig WHERE variablename = 'UserDesc';";
166 $result = pg_query($PG_CONN, $sql);
168 $R = pg_fetch_assoc($result);
169 pg_free_result($result);
170 if (!empty($R[
'conf_value'])) {
171 $UserDesc =
"'".$R[
'conf_value'].
"'";
175 $sql =
"SELECT conf_value FROM sysconfig WHERE variablename = 'BucketPool';";
176 $result = pg_query($PG_CONN, $sql);
178 $R = pg_fetch_assoc($result);
179 pg_free_result($result);
180 if (!empty($R[
'conf_value'])) {
181 $BucketPool = $R[
'conf_value'];
183 $sql =
"SELECT bucketpool_pk FROM bucketpool WHERE bucketpool_pk=$BucketPool AND active='Y'";
184 $result = pg_query($PG_CONN, $sql);
186 if (pg_num_rows($result) < 1) {
187 $BucketPool =
'null';
189 pg_free_result($result);
192 $sql =
"SELECT bucketpool_pk FROM bucketpool;";
193 $result = pg_query($PG_CONN, $sql);
195 if (pg_num_rows($result) == 1) {
196 $R = pg_fetch_assoc($result);
197 if (!empty($R[
'bucketpool_pk'])) {
198 $BucketPool = $R[
'bucketpool_pk'];
201 $BucketPool =
'null';
203 pg_free_result($result);
206 pg_free_result($result);
210 $sql =
"SELECT * FROM users WHERE user_email = '$Email';";
211 $result = pg_query($PG_CONN, $sql);
213 $R = pg_fetch_assoc($result);
214 pg_free_result($result);
215 if (empty($R[
'user_name'])) {
218 $sql =
"SELECT * FROM folderlist WHERE name = '$FolderName' AND parent = '1' AND foldercontents_mode = '1';";
219 $result = pg_query($PG_CONN, $sql);
221 $row = pg_fetch_assoc($result);
222 pg_free_result($result);
223 if (empty($row[
'name'])) {
225 $sql =
"INSERT INTO folder (folder_name, folder_desc) VALUES ('$FolderName', '$FolderDes');";
226 $result = pg_query($PG_CONN, $sql);
228 pg_free_result($result);
229 $sql =
"SELECT folder_pk FROM folder WHERE folder_name='$FolderName' AND folder_desc = '$FolderDes';";
230 $result = pg_query($PG_CONN, $sql);
232 $row = pg_fetch_assoc($result);
233 pg_free_result($result);
235 if (empty($row[
'folder_pk'])) {
238 $FolderPk = $row[
'folder_pk'];
241 $sql =
"INSERT INTO foldercontents (parent_fk,foldercontents_mode,child_id) VALUES ('1','1','$FolderPk');";
242 $result = pg_query($PG_CONN, $sql);
244 pg_free_result($result);
246 $sql =
"SELECT folder_pk FROM folder WHERE folder_name='$FolderName' AND folder_desc = '$FolderDes';";
247 $result = pg_query($PG_CONN, $sql);
249 $row = pg_fetch_assoc($result);
250 pg_free_result($result);
252 if (empty($row[
'folder_pk'])) {
255 $FolderPk = $row[
'folder_pk'];
260 add_user($Email,$UserDesc,null,null,5,$Email,y,
"agent_bucket,agent_copyright",$FolderPk,$BucketPool);
265 $sql =
"SELECT * FROM users WHERE user_email = '$Email';";
266 $result = pg_query($PG_CONN, $sql);
268 $R = pg_fetch_assoc($result);
269 pg_free_result($result);
272 if (strcmp($Email, $R[
'user_email']) != 0) {
276 $_SESSION[
'User'] = $R[
'user_name'];
277 $_SESSION[
'UserId'] = $R[
'user_pk'];
278 $SysConf[
'auth'][Auth::USER_ID] = $R[
'user_pk'];
279 $_SESSION[
'UserEmail'] = $R[
'user_email'];
280 $_SESSION[
'UserEnote'] = $R[
'email_notify'];
281 if (empty($R[
'ui_preference'])) {
282 $_SESSION[
'UiPref'] =
'simple';
284 $_SESSION[
'UiPref'] = $R[
'ui_preference'];
286 $_SESSION[
'Folder'] = $R[
'root_folder_fk'];
287 $_SESSION[
'time_check'] = time() + (480 * 60);
289 if (
"X" . $R[
'user_perm'] ==
"X") {
292 $_SESSION[Auth::USER_LEVEL] = $R[
'user_perm'];
296 $_SESSION[
'NoPopup'] = 1;
298 $_SESSION[
'NoPopup'] = 0;
308 if ($this->
State != PLUGIN_STATE_READY) {
318 if ($this->OutputType==
"HTML") {
320 $_SESSION[
'User'] = NULL;
321 $_SESSION[Auth::USER_ID] = NULL;
322 $SysConf[
'auth'][Auth::USER_ID] = NULL;
323 $_SESSION[Auth::USER_LEVEL] = NULL;
324 $_SESSION[
'UserEmail'] = NULL;
325 $_SESSION[
'Folder'] = NULL;
326 $_SESSION[
'UiPref'] = NULL;
329 $V.=
"<script language='javascript'>\n";
330 $V.=
"window.open('$Uri','_top');\n";
333 if (!$this->OutputToStdout) {
342 $NewPlugin->Initialize();
Traceback_uri()
Get the URI without query to this location.
#define PLUGIN_DB_ADMIN
Plugin requires admin level permission on DB.
DBconnect($sysconfdir, $options="", $exitOnFail=true)
Connect to database engine. This is a no-op if $PG_CONN already has a value.
add_user($User, $Desc, $Seed, $Hash, $Perm, $Email, $Email_notify, $agentList, $Folder, $default_bucketpool_fk='')
Add a user.
CheckUser($Email)
See if a username is valid.
Output()
generate the output for this plug-in
GetParm($parameterName, $parameterType)
This function will retrieve the variables and check data types.
siteminder_check()
Check if SiteMinder is enabled.
#define PLUGIN_DB_NONE
Plugin requires no DB permission.
#define PLUGIN_DB_WRITE
Plugin requires write permission on DB.
PostInitialize()
This function is called before the plugin is used and after all plugins have been initialized...
This is the Plugin class. All plugins should:
foreach($Options as $Option=> $OptVal) if(0==$reference_flag &&0==$nomos_flag) $PG_CONN
DBCheckResult($result, $sql, $filenm, $lineno)
Check the postgres result for unexpected errors. If found, treat them as fatal.
Install()
Only used during installation. This may be called multiple times. Used to ensure the DB has the right...
char * trim(char *ptext)
Trimming whitespace.