예제 #1
0
function build($argv)
{
    global $_plugin;
    global $success;
    global $error;
    global $errors;
    plugin_is_installed($_plugin['name']) or $error = $error['not_installed'];
    isset($argv[3]) or $error = $errors['usage'];
    prompt('WARNING: Building a table from a definition will clear all data from your table; are you sure you want to do this?') or $error = $errors['aborted'];
    if (!$error) {
        # Let's get connected!
        db_connect();
        use_db();
        # Get definition config.
        $_definition = get_plugin_config('definitions');
        # At this point, $_definition is overwritten with the defined $_definition in the require.
        require $_definition['dir']['definitions'] . $argv[3] . '.php';
        # Drop the current table. Should really be its own script, no?
        # Check for table existence.
        if (mysql_query('SELECT * FROM ' . $_definition['name'])) {
            mysql_query('DROP TABLE ' . $_definition['name']);
        }
        # Let's build this noise!
        $query = 'CREATE TABLE ' . $_definition['name'] . '(' . "\n";
        # We'll foreach through the table def and build the SQL string as needed.
        foreach ($_definition['fields'] as $field => $data) {
            $query .= $field . ' ' . strtoupper($data['type']);
            if ($data['length']) {
                $query .= '(' . $data['length'] . ')';
            }
            if (!$data['null']) {
                $query .= ' NOT NULL';
            }
            if ($data['auto_inc']) {
                $query .= ' AUTO_INCREMENT';
            }
            # Add a comma and line break.
            $query .= ",\n";
            # Output relational data.
            if (isset($data['relation'])) {
                $query .= 'INDEX ' . $data['relation']['name'] . '_rel(' . $data['relation']['name'] . '_id)';
                $query .= ',' . "\n" . 'FOREIGN KEY(' . $data['relation']['name'] . '_id) REFERENCES ' . $data['relation']['name'] . '(id) ON DELETE CASCADE';
                $query .= ",\n";
            }
        }
        if ($_definition['primary']) {
            $query .= 'PRIMARY KEY(' . $_definition['primary'] . ')';
        }
        # End query here.
        $query .= "\n" . ')';
        //add option to display this!
        echo 'Executing the following query:' . "\n" . $query . "\n\n";
        if (mysql_query($query)) {
            //$success = 'Created ' . $_definition['name'] . ' with the following query: ' . "\n" . $query;
            $success = 'Created "' . $_definition['name'] . '"';
        } else {
            $error = mysql_error();
        }
    }
}
예제 #2
0
function HookApprovalResource_emailFooterbottom()
{
    global $ref;
    $approval_form_id = sql_value("SELECT ref AS value FROM resource_type_field WHERE name = 'approval_form'", FALSE);
    if (!$approval_form_id) {
        return;
    }
    $approval_form = TidyList(get_data_by_field($ref, $approval_form_id));
    if ($approval_form !== 'Yes') {
        return;
    }
    $settings = get_plugin_config('approval');
    echo '
		<script type="text/javascript">
			document.getElementById("message").value = "' . htmlspecialchars($settings['email_message']) . '";
		</script>
	';
}
예제 #3
0
파일: approval.php 프로젝트: EMRL/approval
$comment = getvalescaped('comment', NULL);
// Validate
$valid = TRUE;
if (empty($name) or empty($signature) or !in_array($status, array('approved', 'minor', 'major'))) {
    $valid = FALSE;
}
// If no $_POST or this resource doesn't exist then redirect back to resource
if (empty($_POST) or !$valid or $ref === -999 or (int) sql_value("SELECT COUNT(*) AS value FROM resource WHERE ref = {$ref}", 0) < 1) {
    redirect($referrer);
}
// Insert a new history item
sql_query("INSERT INTO approval (ref, posted, comment, name, signature, status) VALUES ({$ref}, NOW(), '{$comment}', '{$name}', '{$signature}', '{$status}')");
// Update resource approval field
sql_query("UPDATE resource SET approval_status = '{$status}' WHERE ref = {$ref}");
// Get approval plugin settings
$settings = get_plugin_config('approval');
$email_to = val($settings['email_to']);
// If theres no one to email then redirect back to resource
if ($email_to === NULL) {
    redirect($referrer);
}
// Get the emails in the correct format
$email_to = resolve_userlist_groups($email_to);
$email_to = explode(',', $email_to);
$email_to = array_map('trim', $email_to);
$email_to = array_filter($email_to);
// Replace usernames with their emails
foreach ($email_to as $key => $email) {
    $user_email = sql_value("SELECT email AS value FROM user WHERE username = '******'", NULL);
    if ($user_email === NULL) {
        if (strpos($email, '@') === FALSE) {
예제 #4
0
파일: all.php 프로젝트: Jtgadbois/Pedadida
function HookPosixldapauthAllExternalauth($uname, $pword)
{
	include_once "include/collections_functions.php";

	include_once "plugins/posixldapauth/config/config.default.php";
	if (file_exists("plugins/posixldapauth/config/config.php"))
	{
        	include_once("plugins/posixldapauth/config/config.php");
	}
	include_once "plugins/posixldapauth/hooks/ldap_class.php";
	global $username;
	global $password;
	global $password_hash,$use_plugins_manager,$ldapauth;
	$debugMode = false;
        
	if ($use_plugins_manager==true)
	{
		$ldapauth = get_plugin_config("posixldapauth");

		if ($ldapauth==null || $ldapauth['enable']==false) 
		{
			return false;
		}
		if (!isset($ldapauth['ldapgroupcontainer']))
		{
			$ldapauth['ldapgroupcontainer'] = "";
		}
		if (!isset($ldapauth['ldapmemberfield']))
		{
			$ldapauth['ldapmemberfield'] = "";	
		}
			if (!isset($ldapauth['ldapmemberfieldtype']))
		{
			$ldapauth['ldapmemberfieldtype'] = 0;	
		}
	}
	
	if ($uname != "" && $pword != "") 
	{
		// pass the config to the class
		$ldapConf['host'] = $ldapauth['ldapserver'];
		$ldapConf['basedn'] = $ldapauth['basedn'];
		$objLdapAuth = new ldapAuth($ldapConf);	
		// connect to the ldap
		if ($objLdapAuth->connect())
		{
			
			// see if we can bind with the username and password.
			if($objLdapAuth->auth($uname,$pword,$ldapauth['ldaptype'],$ldapauth['ldapusercontainer']))
			{
				if ($debugMode)
				{
					echo "all.php: line 55 : auth to ldap server is successful \r\n";
				}
				$auth = true;
				// get the user info etc	
				$userDetails = $objLdapAuth->getUserDetails($uname);
				//print_r($userDetails);
				if ($debugMode)
				{
					echo "all.php: line 63 : cn=" . $userDetails["cn"] . "\r\n";
					echo "all.php: line 64 : dn=" . $userDetails["dn"] . "\r\n"; 	
				}
				
				$user_cn = $userDetails["cn"];
				$user_dn = $userDetails["dn"];
				
				/* 	Now we have the user details, we need to figure out if the user exists in the 
					RS database allready, in which case we'll update the passsword, or if it's
					a new user and create users is set, then we create a new user.
					
					Maybe w should also check groups as well? So if group membership has changed the user will be updated!
				*/
				
				$uexists=sql_query('select ref from user where username="******"');
				if (count($uexists)>=1) 
				{
					// if we get here, the user has already been added to RS.
					$username=$uname.$ldapauth['usersuffix'];
					$password_hash= md5("RS".$username.$password);
					sql_query('update user set password="******" where username="******"');
					//          $password=sql_value('select password value from user where username="******"',"");
					return true;
				}
				elseif ($ldapauth['createusers']) 
				{
					
					// else, is we have specified to create users from the LDAP, we need to get info about the user
					// to add them to resource space.
					$nuser = array();
					// Start Populating User Fields from LDAP
					$nuser['username']=$uname.$ldapauth['usersuffix'];
					$nuser['fullname']=$user_cn;
					if (isset($userDetails["mail"]))
					{
						$nuser['email']=$userDetails["mail"];
					} else {
						$nuser['email']="$uname@mail";
					}
					$nuser['password']=md5("RS". $nuser['username'].$password);
					
					// Set a var so that we can keep track of the group level as we scan the access groups.
					$currentGroupLevel = 0;
					
				
					
					if ($ldapauth['groupbased'])
					{
						//echo "group based";
						// set match to false as default"
						$match = false;						
						/* 	At this point we want to do a switch on the type of directory we are authenticing against
							so that we can use group matching for the different types of directory layout:
							ie, AD uses memberof, OD doesn't!
							We also need to check for higher numbered groups, ie if a user is amember of staff, and of admin users,
							we need to give them the highest access!
						*/
						//switch ($ldapauth['ldaptype'])
						//{
						//	case 0:
								// Open Directory!
								// set the uid, ie the username...
								$objLdapAuth->userName = $uname;
									
								// now we cycle through the config array to check groups!
								foreach ($ldapauth['groupmap'] as $ldapGrpName => $arrLdapGrp)
								{
									// check to see if we are allowing users in this group to log in?
									if ($arrLdapGrp['enabled'])
									{
										// get the group name and check group membership	
										if ($objLdapAuth->checkGroupByName($ldapGrpName,$ldapauth['ldaptype'],$ldapauth['ldapgroupcontainer'],$ldapauth['ldapmemberfield'],$ldapauth['ldapmemberfieldtype']))
										{
											if ( $match )
											{
												if ($currentGroupLevel < $arrLdapGrp['rsGroup'])
												{
													$nuser['usergroup'] = $arrLdapGrp['rsGroup'];
													$currentGroupLevel = $arrLdapGrp['rsGroup'];
												}
											} else {	
												$match = true;
											
												$nuser['usergroup'] = $arrLdapGrp['rsGroup'];
												$currentGroupLevel = $arrLdapGrp['rsGroup'];
											} 
										}
									}	
								}
								//break;
							//case 1:
								// Active Directory - memberof?
								/* These are the steps we need to take:
								1. Connect
								2. Bind using the supplied credentials - or maybe we don't as the user will have bound!
								3. Get the users info and check 'member of' field
								4. compare to enabled groups.
								*/
						/*		
								break;
							case 2:
								// Novell 
								break;
						}*/
						
						// if we haven't managed to find a group match that is allowed to log into RS, then
						// we return false!	- we ned to modify this to use the group set if group based is not enabled!
						if (!($match)) return false;
						// Create the user
						$ref=new_user($nuser['username']);
						if (!$ref) return false; # Shouldn't ever get here.  Something strange happened
						
						// Update with information from LDAP
						sql_query('update user set password="******", fullname="'.$nuser['fullname'].'", email="'.$nuser['email'].'", usergroup="'.
							$nuser['usergroup'].'", comments="Auto create from LDAP" where ref="'.$ref.'"');
							
						$username=$nuser['username'];
						$password=$nuser['password'];


						// now unbind
						$objLdapAuth->unBind();	
						return true;
					}
				}				
			} else {					
				// username / password is wrong!
				return false;
			}		
		}	
		return false;		
	}
}
예제 #5
0
function hookView_in_finderViewRenderinnerresourcedownloadspace()
{
    global $resource;
    global $afp_server_path;
    global $access;
    global $staticSyncSyncDirField, $staticSyncDirs, $staticSyncUseArray;
    $restrictedAccess = false;
    $viewInFinder = get_plugin_config("view_in_finder");
    /*
    echo "<pre>";
    print_r($viewInFinder);
    echo "</pre>";
    */
    // check to see if we are using permissions, and if yes then do they have access to this resource type?
    if ($viewInFinder['afpServerPath'] && $access != 0) {
        $restrictedAccess = true;
    }
    if (!$restrictedAccess) {
        //echo "Access Allowed... ";
        if ($resource["file_path"] != "") {
            //echo "Got the file path…. ";
            if ($staticSyncUseArray) {
                $syncPath = get_data_by_field($resource['ref'], $staticSyncSyncDirField);
                $found = false;
                $lSyncDir = "";
                if ($syncPath != "") {
                    foreach ($staticSyncDirs as $tDir) {
                        if (!$found) {
                            if (strpos($syncPath, $tDir['syncdir']) !== false) {
                                $found = true;
                                $lSyncDir = $tDir['syncdir'];
                            }
                        }
                    }
                    if ($found) {
                        //echo "sync dir found : ". $lSyncDir;
                        // check the afp path from the config.
                        if (array_key_exists($lSyncDir, $viewInFinder['multiafpServerPath'])) {
                            $afp_link = $viewInFinder['multiafpServerPath'][$lSyncDir] . "/" . $resource["file_path"];
                        } else {
                            // use the default
                            $afp_link = $viewInFinder['afpServerPath'] . "/" . $resource["file_path"];
                        }
                        //echo $afp_link;
                    }
                } else {
                    // $syncPath is empty or not fouond, use the default
                    $afp_link = $viewInFinder['afpServerPath'] . "/" . $resource["file_path"];
                    $found = true;
                }
            } else {
                if (array_key_exists('afpServerPath', $viewInFinder)) {
                    $afp_link = $viewInFinder['afpServerPath'] . "/" . $resource["file_path"];
                    $found = true;
                }
            }
            if ($found) {
                echo "<table>";
                echo '<tr class="DownloadDBlend">';
                echo '<td>Open Original File In Finder</td>';
                $fName = explode("/", $resource["file_path"]);
                $fid = count($fName) - 1;
                echo '<td class="DownloadButton"><a href="' . $afp_link . '">' . $fName[$fid] . '</a></ td>';
                echo '</tr>';
                echo "</table>";
            }
        }
    }
}
예제 #6
0
function HookPosixldapauthAllExternalauth($uname, $pword)
{
    /* Set the following debug flag to true for more debugging information
     */
    $ldap_debug = true;
    include_once "include/collections_functions.php";
    include_once "plugins/posixldapauth/config/config.default.php";
    if (file_exists("plugins/posixldapauth/config/config.php")) {
        include_once "plugins/posixldapauth/config/config.php";
    }
    include_once "plugins/posixldapauth/hooks/ldap_class.php";
    global $username;
    global $password;
    global $password_hash, $use_plugins_manager, $ldapauth;
    $debugMode = false;
    if ($ldap_debug) {
        error_log(__FILE__ . " " . __METHOD__ . " " . __LINE__ . "  Starting Debug");
    }
    if ($use_plugins_manager == true) {
        $ldapauth = get_plugin_config("posixldapauth");
        if ($ldapauth == null || $ldapauth['enable'] == false) {
            return false;
        }
        if (!isset($ldapauth['ldapgroupcontainer'])) {
            $ldapauth['ldapgroupcontainer'] = "";
        }
        if (!isset($ldapauth['port'])) {
            $ldapauth['port'] = 389;
        }
        if (!isset($ldapauth['ldapmemberfield'])) {
            $ldapauth['ldapmemberfield'] = "";
        }
        if (!isset($ldapauth['ldapmemberfieldtype'])) {
            $ldapauth['ldapmemberfieldtype'] = 0;
        }
        if ($ldap_debug) {
            error_log(__FILE__ . " " . __METHOD__ . " " . __LINE__ . "  Configuration");
        }
        if ($ldap_debug) {
            foreach ($ldapauth as $key => $value) {
                if ($key == "groupmap") {
                    foreach ($ldapauth['groupmap'] as $ldapGrpName => $arrLdapGrp) {
                        if ($arrLdapGrp['enabled']) {
                            error_log($ldapGrpName . " is enabled and mapped to " . $arrLdapGrp['rsGroup']);
                        }
                    }
                } else {
                    error_log($key . " = " . $value);
                }
            }
        }
    }
    if ($uname != "" && $pword != "") {
        // pass the config to the class
        $ldapConf['host'] = $ldapauth['ldapserver'];
        $ldapConf['basedn'] = $ldapauth['basedn'];
        $ldapConf['addomain'] = $ldapauth['addomain'];
        $ldapConf['port'] = $ldapauth['port'];
        if ($ldapauth['adusesingledomain']) {
            $singleDomain = true;
        } else {
            $singleDomain = false;
        }
        $objLdapAuth = new ldapAuth($ldapConf);
        if ($ldap_debug) {
            $objLdapAuth->ldap_debug = true;
        }
        // connect to the ldap
        if ($objLdapAuth->connect()) {
            // see if we can bind with the username and password.
            if ($objLdapAuth->auth($uname, $pword, $ldapauth['ldaptype'], $ldapauth['ldapusercontainer'], $singleDomain)) {
                if ($ldap_debug) {
                    error_log(__FILE__ . " " . __METHOD__ . " " . __LINE__ . " auth to ldap server is successful ");
                }
                $auth = true;
                // get the user info etc
                $userDetails = $objLdapAuth->getUserDetails($uname);
                //print_r($userDetails);
                if ($ldap_debug) {
                    error_log(__FILE__ . " " . __METHOD__ . " " . __LINE__ . "  cn=" . $userDetails["cn"]);
                }
                if ($ldap_debug) {
                    error_log(__FILE__ . " " . __METHOD__ . " " . __LINE__ . "  dn=" . $userDetails["dn"]);
                }
                $user_cn = $userDetails["cn"];
                $user_dn = $userDetails["dn"];
                /* 	Now we have the user details, we need to figure out if the user exists in the 
                					RS database allready, in which case we'll update the passsword, or if it's
                					a new user and create users is set, then we create a new user.
                					
                					Maybe w should also check groups as well? So if group membership has changed the user will be updated!
                				*/
                $uexists = sql_query('select ref from user where username="******"');
                if (count($uexists) >= 1) {
                    if ($ldap_debug) {
                        error_log(__FILE__ . " " . __METHOD__ . " " . __LINE__ . "  User has allready been added to RS, updating password");
                    }
                    // if we get here, the user has already been added to RS.
                    $username = $uname . $ldapauth['usersuffix'];
                    $password_hash = hash('sha256', md5('RS' . $username . $password));
                    sql_query('update user set password="******" where username="******"');
                    //          $password=sql_value('select password value from user where username="******"',"");
                    return true;
                } elseif ($ldapauth['createusers']) {
                    if ($ldap_debug) {
                        error_log(__FILE__ . " " . __METHOD__ . " " . __LINE__ . "  Create Users is Enabled");
                    }
                    // else, is we have specified to create users from the LDAP, we need to get info about the user
                    // to add them to resource space.
                    $nuser = array();
                    // Start Populating User Fields from LDAP
                    $nuser['username'] = $uname . $ldapauth['usersuffix'];
                    $nuser['fullname'] = $user_cn;
                    if (isset($userDetails["mail"])) {
                        $nuser['email'] = $userDetails["mail"];
                    } else {
                        $nuser['email'] = "{$uname}@mail";
                    }
                    $nuser['password'] = hash('sha256', md5('RS' . $nuser['username'] . $password));
                    // Set a var so that we can keep track of the group level as we scan the access groups.
                    $currentGroupLevel = 0;
                    if ($ldapauth['groupbased']) {
                        if ($ldap_debug) {
                            error_log(__FILE__ . " " . __METHOD__ . " " . __LINE__ . "  Group Based is Enabled, checking Groups");
                        }
                        // set match to false as default"
                        $match = false;
                        /* 	At this point we want to do a switch on the type of directory we are authenticing against
                        					so that we can use group matching for the different types of directory layout:
                        					ie, AD uses memberof, OD doesn't!
                        					We also need to check for higher numbered groups, ie if a user is amember of staff, and of admin users,
                        					we need to give them the highest access!
                        				*/
                        if ($ldap_debug) {
                            error_log(__FILE__ . " " . __METHOD__ . " " . __LINE__ . "  Group Based is Enabled, checking Groups");
                        }
                        // set the uid, ie the username...
                        $objLdapAuth->userName = $uname;
                        // now we cycle through the config array to check groups!
                        foreach ($ldapauth['groupmap'] as $ldapGrpName => $arrLdapGrp) {
                            // check to see if we are allowing users in this group to log in?
                            if ($arrLdapGrp['enabled']) {
                                if ($ldap_debug) {
                                    error_log(__FILE__ . " " . __METHOD__ . " " . __LINE__ . "  Checking Group " . $ldapGrpName);
                                }
                                // get the group name and check group membership
                                if ($objLdapAuth->checkGroupByName($ldapGrpName, $ldapauth['ldaptype'], $ldapauth['ldapgroupcontainer'], $ldapauth['ldapmemberfield'], $ldapauth['ldapmemberfieldtype'])) {
                                    if ($match) {
                                        if ($currentGroupLevel < $arrLdapGrp['rsGroup']) {
                                            $nuser['usergroup'] = $arrLdapGrp['rsGroup'];
                                            $currentGroupLevel = $arrLdapGrp['rsGroup'];
                                        }
                                    } else {
                                        $match = true;
                                        $nuser['usergroup'] = $arrLdapGrp['rsGroup'];
                                        $currentGroupLevel = $arrLdapGrp['rsGroup'];
                                    }
                                    if ($ldap_debug) {
                                        error_log(__FILE__ . " " . __METHOD__ . " " . __LINE__ . "  Match found in group " . $ldapGrpName);
                                    }
                                }
                            }
                        }
                        // if we haven't managed to find a group match that is allowed to log into RS, then
                        // we return false!	- we ned to modify this to use the group set if group based is not enabled!
                        if (!$match) {
                            return false;
                        }
                        // Create the user
                        if ($ldap_debug) {
                            error_log(__METHOD__ . " " . __LINE__ . "  Creating User: "******" " . __LINE__ . "  User Ref: " . $ref);
                        }
                        if (!$ref) {
                            if ($ldap_debug) {
                                error_log(__FILE__ . " " . __METHOD__ . " " . __LINE__ . "  Group based User creation ref NOT RETURNED, SOMETHING WEIRD HAPPENED!");
                            }
                            return false;
                            # Shouldn't ever get here.  Something strange happened
                        }
                        // Update with information from LDAP
                        sql_query('update user set password="******", fullname="' . $nuser['fullname'] . '", email="' . $nuser['email'] . '", usergroup="' . $nuser['usergroup'] . '", comments="Auto create from LDAP" where ref="' . $ref . '"');
                        $username = $nuser['username'];
                        $password = $nuser['password'];
                        $password_hash = $nuser['password'];
                        // now unbind
                        $objLdapAuth->unBind();
                        if ($ldap_debug) {
                            error_log(__METHOD__ . " " . __LINE__ . "  returning true : successful user creation!");
                        }
                        return true;
                    } else {
                        // non group based user creation.
                        $ref = new_user($nuser['username']);
                        if (!$ref) {
                            if ($ldap_debug) {
                                error_log(__FILE__ . " " . __METHOD__ . " " . __LINE__ . "  NON Group based User creation ref NOT RETURNED, SOMETHING WEIRD HAPPENED!");
                            }
                            return false;
                            # Shouldn't ever get here.  Something strange happened
                        }
                        // Update with information from LDAP
                        sql_query('update user set password="******", fullname="' . $nuser['fullname'] . '", email="' . $nuser['email'] . '", usergroup="' . $ldapauth['newusergroup'] . '", comments="Auto create from LDAP" where ref="' . $ref . '"');
                        $username = $nuser['username'];
                        $password = $nuser['password'];
                    }
                }
            } else {
                // username / password is wrong!
                return false;
            }
        }
        return false;
    }
}
예제 #7
0
    $ldapauth['rootdn'] = $_POST['rootdn'];
    $ldapauth['rootpass'] = $_POST['rootpass'];
    $ldapauth['addomain'] = $_POST['addomain'];
    $ldapauth['ldapgroupcontainer'] = $_POST['ldapgroupcontainer'];
    if (isset($_POST['ldapGroupName'])) {
        $ldapGroupCount = count($_POST['ldapGroupName']);
        for ($ti = 0; $ti < $ldapGroupCount; $ti++) {
            $grpName = $_POST['ldapGroupName'][$ti];
            $ldapauth['groupmap'][$grpName]['rsGroup'] = $_POST['ldapmaptors'][$grpName];
            $ldapauth['groupmap'][$grpName]['enabled'] = isset($_POST['ldapGroupEnable'][$grpName]);
        }
    }
    set_plugin_config("posixldapauth", $ldapauth);
    redirect("pages/team/team_home.php");
} else {
    $ldapauth = get_plugin_config("posixldapauth");
    if ($ldapauth == null) {
        $ldapauth['enable'] = false;
        $ldapauth['ldapserver'] = 'localhost';
        $ldapauth['port'] = '389';
        $ldapauth['basedn'] = 'dc=mydomain,dc=net';
        $ldapauth['loginfield'] = 'uid';
        $ldapauth['usersuffix'] = '';
        $ldapauth['createusers'] = true;
        $ldapauth['groupbased'] = false;
        $ldapauth['newusergroup'] = '2';
        $ldapauth['ldapusercontainer'] = 'cn=users';
        $ldapauth['ldaptype'] = 0;
        $ldapauth['rootdn'] = "*****@*****.**";
        $ldapauth['rootpass'] = "";
        $ldapauth['addomain'] = "example.com";
예제 #8
0
    $viewInFinder = array();
    if ($useMultiples) {
        $arrRef = 0;
        foreach ($staticSyncDirs as $tDir) {
            $postName = "afpServerPath" . $tDir['syncdir'];
            $viewInFinder['multiafpServerPath'][$tDir['syncdir']] = $_POST[$postName];
            $arrRef++;
        }
    }
    $viewInFinder['afpServerPath'] = $_POST['afpServerPath'];
    $viewInFinder['usePerms'] = $_POST['usePerms'];
    //print_r($_POST);
    //exit;
    set_plugin_config("view_in_finder", $viewInFinder);
} else {
    $viewInFinder = get_plugin_config("view_in_finder");
    if ($viewInFinder == null) {
        $viewInFinder['afpServerPath'] = "afp://example.com/share_name";
        $viewInFinder['usePerms'] = 0;
    }
    if (!array_key_exists('afpServerPath', $viewInFinder)) {
        $viewInFinder['afpServerPath'] = "afp://example.com/share_name";
    }
    if (!array_key_exists("usePerms", $viewInFinder)) {
        $viewInFinder['usePerms'] = 0;
    }
    if (!array_key_exists('multiafpServerPath', $viewInFinder)) {
        $viewInFinder['multiafpServerPath'] = array();
    }
}
include "../../../include/header.php";
예제 #9
0
function plugins()
{
    global $ADMIN_CONF;
    global $CatPage;
    global $message;
    global $specialchars;
    global $debug;
    $plugin_manage_open = false;
    # plugins löschen
    if (getRequestValue('plugin-all-del', 'post') and getRequestValue('plugin-del', 'post')) {
        plugin_del();
        $plugin_manage_open = true;
    }
    # hochgeladenes plugin installieren
    if (isset($_FILES["plugin-install-file"]["error"]) and getRequestValue('plugin-install', 'post') and $_FILES["plugin-install-file"]["error"] == 0 and strtolower(substr($_FILES["plugin-install-file"]["name"], -4)) == ".zip") {
        $debug .= "install=" . $_FILES["plugin-install-file"]["name"] . "<br />\n";
        plugin_install();
        $plugin_manage_open = true;
    } elseif ($plugin_select = $specialchars->rebuildSpecialChars(getRequestValue('plugin-install-select', 'post'), false, false) and getRequestValue('plugin-install', 'post') and is_file(PLUGIN_DIR_REL . $specialchars->replaceSpecialChars($plugin_select, false)) !== false and strtolower(substr($plugin_select, -4)) == ".zip") {
        $debug .= "local install=" . getRequestValue('plugin-install-select', 'post') . "<br />\n";
        plugin_install($plugin_select);
        $plugin_manage_open = true;
    }
    $showdebug = false;
    if ($showdebug and !empty($debug)) {
        $message .= returnMessage(false, $debug);
    }
    require_once BASE_DIR_CMS . "Plugin.php";
    if (false !== ($plugin_name = getRequestValue('pluginadmin'))) {
        #,'get'
        if (file_exists(PLUGIN_DIR_REL . $plugin_name)) {
            define("PLUGINADMIN", $plugin_name);
            if (file_exists(PLUGIN_DIR_REL . PLUGINADMIN . "/plugin.conf.php") and file_exists(PLUGIN_DIR_REL . PLUGINADMIN . "/index.php")) {
                require_once PLUGIN_DIR_REL . PLUGINADMIN . "/index.php";
                # Enthält der Code eine Klasse mit dem Namen des Plugins und ist es auch der Dirname?
                if (class_exists(PLUGINADMIN) and in_array(PLUGINADMIN, get_declared_classes())) {
                    # $PLUGIN_ADMIN_ADD_HEAD gibts nur hier und ist für sachen die in den head sollen
                    global $PLUGIN_ADMIN_ADD_HEAD;
                    $PLUGIN_ADMIN_ADD_HEAD = array();
                    $multi_user = "";
                    if (defined('MULTI_USER') and MULTI_USER) {
                        $multi_user = "******";
                    }
                    define("PLUGINADMIN_GET_URL", URL_BASE . ADMIN_DIR_NAME . "/index.php?pluginadmin=" . PLUGINADMIN . "&amp;nojs=true&amp;action=" . ACTION . $multi_user);
                    $plugin = new $plugin_name();
                    $info = $plugin->getInfo();
                    $config = $plugin->getConfig();
                    if (PLUGIN_DIR_REL . $plugin_name . '/' . $config["--admin~~"]["datei_admin"] == PLUGIN_DIR_REL . PLUGINADMIN . "/index.php") {
                        return $plugin->getContent("");
                    } else {
                        return require_once PLUGIN_DIR_REL . $plugin_name . '/' . $config["--admin~~"]["datei_admin"];
                    }
                }
            } else {
                die;
            }
        } else {
            die;
        }
    }
    if (getRequestValue('chanceplugin', 'post') == "true" and false !== ($plugin_name = getRequestValue('plugin_name', 'post'))) {
        if (file_exists(PLUGIN_DIR_REL . $plugin_name) and file_exists(PLUGIN_DIR_REL . $plugin_name . "/plugin.conf.php") and file_exists(PLUGIN_DIR_REL . $plugin_name . "/index.php")) {
            $conf_plugin = new Properties(PLUGIN_DIR_REL . $plugin_name . "/plugin.conf.php");
        } else {
            die("Fatal Error");
        }
        if (false !== ($activ = getRequestValue(array($plugin_name, 'active'), 'post')) and ($activ == "true" or $activ == "false")) {
            $conf_plugin->set("active", $activ);
            ajax_return("success", true);
        } elseif ($conf_plugin->get("active") == "true") {
            require_once PLUGIN_DIR_REL . $plugin_name . "/index.php";
            # Enthält der Code eine Klasse mit dem Namen des Plugins und ist es auch der Dirname?
            if (class_exists($plugin_name) and in_array($plugin_name, get_declared_classes())) {
                $plugin = new $plugin_name();
                # das ist nötig weil es sein kann das in getInfo() variblen initaliesiert werden
                $tmp = $plugin->getInfo();
                $config = $plugin->getConfig();
                echo save_plugin_settings($conf_plugin, $config, $plugin_name);
                exit;
            } else {
                die("Fatal Error");
            }
        }
        die("Fatal Error");
    }
    $pagecontent = '';
    $show = $ADMIN_CONF->get("plugins");
    if (!is_array($show)) {
        $show = array();
    }
    if (ROOT or in_array("plugin_-_manage", $show)) {
        $multi_user = "";
        if (defined('MULTI_USER') and MULTI_USER) {
            $multi_user = "******";
        }
        $html_manage = "";
        $plugin_manage = array();
        $disabled = '';
        if (!function_exists('gzopen')) {
            $disabled = ' disabled="disabled"';
        }
        $plugin_install = array();
        foreach (getDirAsArray(PLUGIN_DIR_REL, array(".zip")) as $zip_file) {
            $plugin_install[] = '<option value="' . mo_rawurlencode($zip_file) . '">' . $zip_file . '</option>';
        }
        $plugin_install_html = "";
        if (count($plugin_install) > 0) {
            $plugin_install_html .= '<br /><select class="mo-install-select mo-select-div" name="plugin-install-select" size="1"' . $disabled . '>' . '<option value="">' . getLanguageValue("plugins_select", true) . '</option>' . implode("", $plugin_install) . '</select>';
        }
        $plugin_manage["plugins_title_manage"][] = '<form id="js-plugin-manage" action="index.php?nojs=true&amp;action=plugins' . $multi_user . '" method="post" enctype="multipart/form-data">' . '<div class="mo-nowrap align-right ui-helper-clearfix">' . '<span class="align-left" style="float:left"><span class="mo-bold">' . getLanguageValue("plugins_text_filebutton") . '</span><br />' . getLanguageValue("plugins_text_fileinfo") . '</span>' . '<input type="file" id="js-plugin-install-file" name="plugin-install-file" class="mo-select-div"' . $disabled . ' />' . $plugin_install_html . '<input type="submit" id="js-plugin-install-submit" name="plugin-install" value="' . getLanguageValue("plugins_button_install", true) . '"' . $disabled . ' /><br />' . '<input type="submit" id="js-plugin-del-submit" value="' . getLanguageValue("plugins_button_delete", true) . '" class="mo-margin-top js-send-del-stop" />' . '</div></form>';
        $plugin_manage["plugins_title_manage"]["toggle"] = true;
        $html_manage = contend_template($plugin_manage);
        $html_manage = str_replace("js-toggle", "js-toggle-manage", $html_manage);
        # es wurde in der template verwaltung was gemacht dann soll die aufgeklapt bleiben
        if ($plugin_manage_open) {
            $html_manage = str_replace("display:none;", "", $html_manage);
        }
        $pagecontent .= $html_manage;
    }
    $pagecontent .= '<ul class="js-plugins mo-ul">';
    $dircontent = getDirAsArray(PLUGIN_DIR_REL, "dir", "natcasesort");
    foreach ($dircontent as $currentelement) {
        $new_plugin_conf = false;
        if (!ROOT and !in_array($currentelement, $show)) {
            continue;
        }
        if (file_exists(PLUGIN_DIR_REL . $currentelement . "/index.php")) {
            if (!is_file(PLUGIN_DIR_REL . $currentelement . "/plugin.conf.php")) {
                if (false === newConf(PLUGIN_DIR_REL . $currentelement . "/plugin.conf.php")) {
                    die;
                } else {
                    $new_plugin_conf = true;
                }
            }
            require_once PLUGIN_DIR_REL . $currentelement . "/index.php";
            # Enthält der Code eine Klasse mit dem Namen des Plugins und ist es auch der Dirname?
            if (class_exists($currentelement) and in_array($currentelement, get_declared_classes())) {
                $plugin = new $currentelement();
            } else {
                # Plugin Dirname stimt nicht mit Plugin Classnamen überein
                continue;
            }
            # plugin.conf.php wurde neu erstelt.
            # Wenn es die getDefaultSettings() gibt fühle die plugin.conf.php damit
            if ($new_plugin_conf and method_exists($plugin, 'getDefaultSettings')) {
                $plugin->settings->setFromArray($plugin->getDefaultSettings());
            }
            $plugin_css_li_error = NULL;
            $plugin_error = false;
            $plugin_info = $plugin->getInfo();
            # Plugin Info Prüfen
            if (isset($plugin_info) and count($plugin_info) > 0) {
                $plugin_name = strip_tags($plugin_info[0], '<b>');
                if (substr(strip_tags($plugin_name), 0, strlen($currentelement)) != $currentelement) {
                    $plugin_name = "<b>" . $currentelement . "</b> " . strip_tags($plugin_name);
                }
                $plugin_name = htmlentities($plugin_name, ENT_COMPAT, CHARSET);
                $plugin_name = str_replace(array("&lt;", "&gt;", "\$"), array("<", ">", ""), $plugin_name);
            } else {
                $plugin_error = '<img class="mo-tool-icon mo-icons-icon mo-icons-error" src="' . ICON_URL_SLICE . '" alt="error" />' . getLanguageValue('plugins_error') . ' <b>' . $currentelement . '</b>';
                $plugin_css_li_error = ' ui-state-error';
            }
            $pagecontent .= '<li class="js-plugin mo-li ui-widget-content ui-corner-all' . $plugin_css_li_error . '">' . '<div class="js-tools-show-hide mo-li-head-tag mo-li-head-tag-no-ul ui-state-active ui-corner-all ui-helper-clearfix">';
            $check_show = ' style="display:none;"';
            if ($plugin_manage_open) {
                $check_show = '';
            }
            if ($plugin_error === false) {
                $pagecontent .= '<span class="js-plugin-name mo-padding-left mo-middle">' . $plugin_name . '</span>' . '<div style="float:right;" class="mo-tag-height-from-icon mo-middle mo-nowrap">' . '<span class="js-plugin-active mo-staus">' . buildCheckBox($currentelement . '[active]', $plugin->settings->get("active") == "true", getLanguageValue("plugins_input_active")) . '</span>' . '<img class="js-tools-icon-show-hide js-toggle mo-tool-icon mo-icons-icon mo-icons-edit" src="' . ICON_URL_SLICE . '" alt="edit" />' . '<input type="checkbox" value="' . $currentelement . '" class="mo-checkbox mo-checkbox-del js-plugin-del"' . $check_show . ' />' . '</div>' . '</div>' . '<div class="js-toggle-content mo-in-ul-ul ui-helper-clearfix" style="display:none;">' . get_plugin_info($plugin_info);
                # geändert damit getConfig() nicht 2mal ausgeführt wird
                $config = $plugin->getConfig();
                # Beschreibung und inputs der Konfiguration Bauen und ausgeben
                $pagecontent .= get_plugin_config($plugin->settings, $config, $currentelement);
            } else {
                $pagecontent .= $plugin_error;
            }
            $pagecontent .= '</div></li>';
            unset($plugin);
        }
    }
    $pagecontent .= '</ul>';
    return $pagecontent;
}