Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1 from ajaxplorer/master
Browse files Browse the repository at this point in the history
Hi, i need to make modifications, but my repo is obsolete :)
  • Loading branch information
joubertredrat committed Aug 24, 2013
2 parents 41989a6 + 0df41be commit 7ea4724
Show file tree
Hide file tree
Showing 2,534 changed files with 94,279 additions and 7,129 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTING.md
@@ -0,0 +1 @@
To get started, please <a href="http://www.clahub.com/agreements/ajaxplorer/ajaxplorer-core">sign the Contributor License Agreement</a>.
27 changes: 22 additions & 5 deletions README.md
Expand Up @@ -4,12 +4,29 @@
[GitHub-Repository](https://github.com/ajaxplorer/ajaxplorer-core) |
[Issue-Tracker](https://github.com/ajaxplorer/ajaxplorer-core)

### License: [AGPLv3](https://www.gnu.org/licenses/agpl.html)

### Developers
* Charles du Jeu (cdujeu): [Github](https://github.com/cdujeu) | [Web](http://cdujeu.me/)
This is the main source code repository of AjaXplorer, containing all the PHP server and HTML5 Web GUI. It was migrated from previous Sourceforge SVN repository, which is hence deprecated.

### Contributations are always welcome
* Latest Stable release : 5.0.0
* Latest Dev release : 4.3.4 (RC for AjaXplorer5)
* License: [AGPLv3](https://www.gnu.org/licenses/agpl.html)
* Lead developer : Charles du Jeu (cdujeu): [Github](https://github.com/cdujeu) | [Twitter](https://twitter.com/AjaXplorer)

### Getting support

Please DO NOT send emails to Charles, but use the forum located on http://forum.ajaxplorer.info instead. Once your problem is qualified, if it's a bug, you will be asked to enter it in the GitHub issue tracker.

### How to contribute / Developer Resources

#### Fixing the Core

If you think you have found a bug and a way to fix it neatly in the code, use a Pull Request to report this change back to us!

#### Writing new plugins

Please read the Developer doc located at https://ajaxplorer.info/documentation/developer, you will find here a bunch of useful information about the plugins architecture, how to create your own plugin, etc. The action.skeleton plugin is a perfect start for that.

New in latest build, in the Settings panel, you can find a new "Developer" node where all actions contributed by all plugins are listed. These can be called either by http, or via the CLI API. At the same location, you will find all "hooks" registered and triggered in the server, that are VERY useful when you want your plugin to be really sandboxed.

#### Signing the CLA

Please <a href="http://www.clahub.com/agreements/ajaxplorer/ajaxplorer-core">sign the Contributor License Agreement</a> before contributing.
Binary file modified core/flex/src/components/admin.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified core/flex/src/components/button_cancel.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified core/flex/src/components/fileclose.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified core/flex/src/components/trashcan_empty.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified core/flex/src/components/view_choose.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified core/flex/src/components/yast_backup.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions core/src/.htaccess
Expand Up @@ -9,6 +9,7 @@ RewriteBase /ajaxplorer
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^shares ./dav.php [L]
RewriteRule ^api ./rest.php [L]

#Following lines seem to be necessary if PHP is working
#with apache as CGI or FCGI. Just remove the #
Expand Down
3 changes: 1 addition & 2 deletions core/src/base.conf.php
Expand Up @@ -24,5 +24,4 @@
define("AJXP_PACKAGING", "zip");
define("AJXP_INSTALL_PATH", realpath(dirname(__FILE__)));
define("AJXP_CONF_PATH", AJXP_INSTALL_PATH."/conf");
require_once(AJXP_CONF_PATH."/bootstrap_context.php");
?>
require_once(AJXP_CONF_PATH."/bootstrap_context.php");
194 changes: 96 additions & 98 deletions core/src/cmd.php
Expand Up @@ -21,7 +21,7 @@
* Description : Command line access of the framework.
*/
if(php_sapi_name() !== "cli"){
die("This is the command line version of the framework, you are not allowed to access this page");
die("This is the command line version of the framework, you are not allowed to access this page");
}

include_once("base.conf.php");
Expand Down Expand Up @@ -51,47 +51,49 @@
$regex = '/^-(-?)([a-zA-z0-9_]*)=(.*)/';
foreach ($argv as $key => $argument){
//echo("$key => $argument \n");
if(preg_match($regex, $argument, $matches)){
if($matches[1] == "-"){
$optArgs[trim($matches[2])] = SystemTextEncoding::toUTF8(trim($matches[3]));
}else{
$options[trim($matches[2])] = SystemTextEncoding::toUTF8(trim($matches[3]));
}
}
if(preg_match($regex, $argument, $matches)){
if($matches[1] == "-"){
$optArgs[trim($matches[2])] = SystemTextEncoding::toUTF8(trim($matches[3]));
}else{
$options[trim($matches[2])] = SystemTextEncoding::toUTF8(trim($matches[3]));
}
}
}

$optUser = $options["u"];
if(!empty($optUser)){

if(isSet($options["p"])){
$optPass = $options["p"];
}else{
// Consider "u" is a crypted version of u:p
$optToken = $options["t"];
$iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND);
$optUser = trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($optToken."\1CDAFx¨op#"), base64_decode($optUser), MCRYPT_MODE_ECB, $iv), "\0");
}
if(strpos($optUser,",") !== false){
$originalOptUser = $optUser;
$nextUsers = explode(",", $optUser);
$optUser = array_shift($nextUsers);
$nextUsers = implode(",",$nextUsers);
}else if(strpos($optUser, "queue:") === 0){
$optUserQueue = substr($optUser, strlen("queue:"));
$optUser = false;
echo("QUEUE : ".$optUserQueue);
if(is_file($optUserQueue)){
$lines = file($optUserQueue);
if(count($lines) && !empty($lines[0])){
$allUsers = explode(",", $lines[0]);
$optUser = array_shift($allUsers);
file_put_contents($optUserQueue, implode(",", $allUsers));
}
if(isSet($options["p"])){
$optPass = $options["p"];
}else{
// Consider "u" is a crypted version of u:p
$optToken = $options["t"];
$iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND);
$optUser = trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($optToken."\1CDAFx¨op#"), base64_decode($optUser), MCRYPT_MODE_ECB, $iv), "\0");
}
if($optUser === false){
if(strpos($optUser,",") !== false){
$originalOptUser = $optUser;
$nextUsers = explode(",", $optUser);
$optUser = array_shift($nextUsers);
$nextUsers = implode(",",$nextUsers);
}else if(strpos($optUser, "queue:") === 0){
$optUserQueue = substr($optUser, strlen("queue:"));
$optUser = false;
//echo("QUEUE : ".$optUserQueue);
if(is_file($optUserQueue)){
unlink($optUserQueue);
$lines = file($optUserQueue);
if(count($lines) && !empty($lines[0])){
$allUsers = explode(",", $lines[0]);
$optUser = array_shift($allUsers);
file_put_contents($optUserQueue, implode(",", $allUsers));
}
}
if($optUser === false){
if(is_file($optUserQueue)){
unlink($optUserQueue);
}
die("No more users inside queue");
}
die("No more users inside queue");
}
}

Expand All @@ -105,19 +107,19 @@
$nextRepositories = implode(",", $nextRepositories);
}

echo("REPOSITORY : ".$optRepoId." USER : ".$optUser."\n");
//echo("REPOSITORY : ".$optRepoId." USER : ".$optUser."\n");

$optDetectUser = $options["detect_user"] OR false;
$detectedUser = false;

if($optRepoId !== false){
$repository = ConfService::getRepositoryById($optRepoId);
if($repository == null){
$repository = ConfService::getRepositoryByAlias($optRepoId);
if($repository != null){
$optRepoId =($repository->isWriteable()?$repository->getUniqueId():$repository->getId());
}
}
$repository = ConfService::getRepositoryById($optRepoId);
if($repository == null){
$repository = ConfService::getRepositoryByAlias($optRepoId);
if($repository != null){
$optRepoId =($repository->isWriteable()?$repository->getUniqueId():$repository->getId());
}
}
if($optDetectUser != false){
$path = $repository->getOption("PATH", true);
if(strpos($path, "AJXP_USER") !== false){
Expand All @@ -135,64 +137,64 @@
}
}
}
ConfService::switchRootDir($optRepoId, true);
ConfService::switchRootDir($optRepoId, true);
}else{
if($optStatusFile){
file_put_contents($optStatusFile, "ERROR:You must pass a -r argument specifying either a repository id or alias");
}
die("You must pass a -r argument specifying either a repository id or alias");
}

if(AuthService::usersEnabled())
if(AuthService::usersEnabled() && !empty($optUser))
{
$seed = AuthService::generateSeed();
if($seed != -1){
$optPass = md5(md5($optPass).$seed);
}
$loggingResult = AuthService::logUser($optUser, $optPass, isSet($optToken), false, $seed);
// Check that current user can access current repository, try to switch otherwise.
$loggedUser = AuthService::getLoggedUser();
$seed = AuthService::generateSeed();
if($seed != -1){
$optPass = md5(md5($optPass).$seed);
}
$loggingResult = AuthService::logUser($optUser, $optPass, isSet($optToken), false, $seed);
// Check that current user can access current repository, try to switch otherwise.
$loggedUser = AuthService::getLoggedUser();
if($loggedUser != null && $detectedUser !== false && $loggedUser->isAdmin()){
AuthService::disconnect();
AuthService::logUser($detectedUser, "empty", true, false, "");
$loggedUser = AuthService::getLoggedUser();
}

if($loggedUser != null)
{
$currentRepoId = ConfService::getCurrentRootDirIndex();
$lastRepoId = $loggedUser->getArrayPref("history", "last_repository");
$defaultRepoId = AuthService::getDefaultRootId();
if($defaultRepoId == -1){
AuthService::disconnect();
$loggingResult = -3;
}else {
if($lastRepoId != "" && $lastRepoId!=$currentRepoId && $optRepoId===false && $loggedUser->canSwitchTo($lastRepoId)){
ConfService::switchRootDir($lastRepoId);
}else if(!$loggedUser->canSwitchTo($currentRepoId)){
ConfService::switchRootDir($defaultRepoId);
}
}
}
if($loggedUser == null)
{
// Try prelogging user if the session expired but the logging data is in fact still present
// For example, for basic_http auth.
AuthService::preLogUser((isSet($httpVars["remote_session"])?$httpVars["remote_session"]:""));
$loggedUser = AuthService::getLoggedUser();
if($loggedUser == null) $requireAuth = true;
}
if(isset($loggingResult) && $loggingResult != 1)
{
AJXP_XMLWriter::header();
AJXP_XMLWriter::loggingResult($loggingResult, false, false, "");
AJXP_XMLWriter::close();
if($loggedUser != null)
{
$currentRepoId = ConfService::getCurrentRepositoryId();
$lastRepoId = $loggedUser->getArrayPref("history", "last_repository");
$defaultRepoId = AuthService::getDefaultRootId();
if($defaultRepoId == -1){
AuthService::disconnect();
$loggingResult = -3;
}else {
if($lastRepoId != "" && $lastRepoId!=$currentRepoId && $optRepoId===false && $loggedUser->canSwitchTo($lastRepoId)){
ConfService::switchRootDir($lastRepoId);
}else if(!$loggedUser->canSwitchTo($currentRepoId)){
ConfService::switchRootDir($defaultRepoId);
}
}
}
if($loggedUser == null)
{
// Try prelogging user if the session expired but the logging data is in fact still present
// For example, for basic_http auth.
AuthService::preLogUser((isSet($httpVars["remote_session"])?$httpVars["remote_session"]:""));
$loggedUser = AuthService::getLoggedUser();
if($loggedUser == null) $requireAuth = true;
}
if(isset($loggingResult) && $loggingResult != 1)
{
AJXP_XMLWriter::header();
AJXP_XMLWriter::loggingResult($loggingResult, false, false, "");
AJXP_XMLWriter::close();
if($optStatusFile){
file_put_contents($optStatusFile, "ERROR:No user logged");
}
}
}
}else{
AJXP_Logger::debug(ConfService::getCurrentRootDirIndex());
AJXP_Logger::debug(ConfService::getCurrentRepositoryId());
}

//Set language
Expand All @@ -202,25 +204,24 @@
$mess = ConfService::getMessages();

// THIS FIRST DRIVERS DO NOT NEED ID CHECK
$ajxpDriver = AJXP_PluginsService::findPlugin("gui", "ajax");
$ajxpDriver->init(ConfService::getRepository());
//$ajxpDriver = AJXP_PluginsService::findPlugin("gui", "ajax");
$authDriver = ConfService::getAuthDriverImpl();
// DRIVERS BELOW NEED IDENTIFICATION CHECK
if(!AuthService::usersEnabled() || ConfService::getCoreConf("ALLOW_GUEST_BROWSING", "auth") || AuthService::getLoggedUser()!=null){
$confDriver = ConfService::getConfStorageImpl();
$Driver = ConfService::loadRepositoryDriver();
$confDriver = ConfService::getConfStorageImpl();
$Driver = ConfService::loadRepositoryDriver();
}
AJXP_PluginsService::getInstance()->initActivePlugins();
require_once(AJXP_BIN_FOLDER."/class.AJXP_Controller.php");
$xmlResult = AJXP_Controller::findActionAndApply($optAction, $optArgs, array());
if($xmlResult !== false && $xmlResult != ""){
AJXP_XMLWriter::header();
print($xmlResult);
AJXP_XMLWriter::close();
AJXP_XMLWriter::header();
print($xmlResult);
AJXP_XMLWriter::close();
}else if(isset($requireAuth) && AJXP_Controller::$lastActionNeedsAuth){
AJXP_XMLWriter::header();
AJXP_XMLWriter::requireAuth();
AJXP_XMLWriter::close();
AJXP_XMLWriter::header();
AJXP_XMLWriter::requireAuth();
AJXP_XMLWriter::close();
}
//echo("NEXT REPO ".$nextRepositories." (".$options["r"].")\n");
//echo("NEXT USERS ".$nextUsers." ( ".$originalOptUser." )\n");
Expand All @@ -235,7 +236,7 @@
}
if(!empty($optUserQueue)){
sleep(1);
echo("Should go to next with $optUserQueue");
//echo("Should go to next with $optUserQueue");
$process = AJXP_Controller::applyActionInBackground($options["r"], $optAction, $optArgs, "queue:".$optUserQueue, $optStatusFile);
if($process != null && is_a($process, "UnixProcess") && isSet($optStatusFile)){
file_put_contents($optStatusFile, "RUNNING:".$process->getPid());
Expand All @@ -254,7 +255,4 @@
$status = explode(":", file_get_contents($optStatusFile));
file_put_contents($optStatusFile, "FINISHED".(in_array("QUEUED", $status)?":QUEUED":""));

}


?>
}

0 comments on commit 7ea4724

Please sign in to comment.