1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-24 06:20:56 +01:00

Merge pull request #11 from cadamo/master

Fix regenerate arcanist cert, setup stuff and avoid accept non valid image files as profile picture.
This commit is contained in:
Evan Priestley 2011-06-03 00:22:52 -07:00
commit 9ff124e5de
5 changed files with 64 additions and 32 deletions

View file

@ -32,7 +32,7 @@ class PhabricatorPeopleProfileEditController
$profile->setUserPHID($user->getPHID());
}
$errors = array();
if ($request->isFormPost()) {
$profile->setTitle($request->getStr('title'));
$profile->setBlurb($request->getStr('blurb'));
@ -41,14 +41,29 @@ class PhabricatorPeopleProfileEditController
$err = idx($_FILES['image'], 'error');
if ($err != UPLOAD_ERR_NO_FILE) {
$file = PhabricatorFile::newFromPHPUpload($_FILES['image']);
$profile->setProfileImagePHID($file->getPHID());
$okay = $file->isTransformableImage();
if ($okay) {
$profile->setProfileImagePHID($file->getPHID());
} else {
$errors[] =
'Only valid image files (jpg, jpeg, png or gif) '.
'will be accepted.';
}
}
}
$profile->save();
$response = id(new AphrontRedirectResponse())
->setURI('/p/'.$user->getUsername().'/');
return $response;
if (!$errors) {
$profile->save();
$response = id(new AphrontRedirectResponse())
->setURI('/p/'.$user->getUsername().'/');
return $response;
}
}
if ($errors) {
$error_view = new AphrontErrorView();
$error_view->setTitle('Form Errors');
$error_view->setErrors($errors);
}
$form = new AphrontFormView();
@ -88,7 +103,10 @@ class PhabricatorPeopleProfileEditController
$panel->setWidth(AphrontPanelView::WIDTH_FORM);
return $this->buildStandardPageResponse(
$panel,
array(
$error_view,
$panel,
),
array(
'title' => 'Edit Profile',
));

View file

@ -15,6 +15,7 @@ phutil_require_module('phabricator', 'view/form/control/file');
phutil_require_module('phabricator', 'view/form/control/submit');
phutil_require_module('phabricator', 'view/form/control/text');
phutil_require_module('phabricator', 'view/form/control/textarea');
phutil_require_module('phabricator', 'view/form/error');
phutil_require_module('phabricator', 'view/layout/panel');
phutil_require_module('phutil', 'utils');

View file

@ -118,14 +118,22 @@ class PhabricatorUserSettingsController extends PhabricatorPeopleController {
$err = idx($_FILES['profile'], 'error');
if ($err != UPLOAD_ERR_NO_FILE) {
$file = PhabricatorFile::newFromPHPUpload($_FILES['profile']);
$user->setProfileImagePHID($file->getPHID());
$okay = $file->isTransformableImage();
if ($okay) {
$user->setProfileImagePHID($file->getPHID());
} else {
$errors[] =
'Only valid image files (jpg, jpeg, png or gif) '.
'will be accepted.';
}
}
}
$user->setRealName($request->getStr('realname'));
if (!strlen($user->getRealName())) {
$errors[] = 'Real name must be nonempty';
$errors[] = 'Real name must be nonempty.';
$e_realname = 'Required';
}
@ -245,7 +253,6 @@ class PhabricatorUserSettingsController extends PhabricatorPeopleController {
$regen_form = new AphrontFormView();
$regen_form
->setUser($user)
->setWorkflow(true)
->setAction('/settings/page/arcanist/')
->appendChild(
'<p class="aphront-form-instructions">You can regenerate this '.
@ -526,7 +533,5 @@ class PhabricatorUserSettingsController extends PhabricatorPeopleController {
return $notice.$panel->render();
}
}

View file

@ -130,18 +130,28 @@ class PhabricatorSetup {
self::writeDoc('article/Configuration_Guide.html');
return;
} else {
self::write(" okay Custom configuration loaded.\n");
}
if (!PhabricatorEnv::getEnvConfig('phabricator.base-uri')) {
self::writeFailure();
self::write(
"Setup failure! You must specify 'phabricator.base-uri' in your ".
"custom config file. Refer to 'default.conf.php' for documentation ".
"on configuration options.\n");
return;
} else {
self::write(" okay phabricator.base-uri\n");
$host = PhabricatorEnv::getEnvConfig('phabricator.base-uri');
$protocol = id(new PhutilURI($host))->getProtocol();
if (!($protocol === 'http') || !($protocol === 'https')) {
self::writeFailure();
self::write(
"You must specify the protocol over which your host works (e.g.: ".
"\"http:// or https://\")\nin your custom config file.\nRefer to ".
"'default.conf.php' for documentation on configuration options.\n");
return;
}
if (preg_match('/.*\/$/', $host)) {
self::write(" okay phabricator.base-uri\n");
} else {
self::writeFailure();
self::write(
"You must add a trailing slash at the end of the host\n(e.g.: ".
"\"http://phabricator.example.com/ instead of ".
"http://phabricator.example.com\")\nin your custom config file.".
"\nRefer to 'default.conf.php' for documentation on configuration ".
"options.\n");
return;
}
}
self::write("[OKAY] Basic configuration OKAY\n");

View file

@ -4,8 +4,6 @@
* @generated
*/
phutil_require_module('phabricator', 'infrastructure/env');
phutil_require_module('phabricator', 'infrastructure/setup/sql');
phutil_require_module('phabricator', 'storage/connection/mysql');
@ -14,7 +12,7 @@ phutil_require_module('phabricator', 'storage/queryfx');
phutil_require_module('phutil', 'filesystem');
phutil_require_module('phutil', 'future/exec');
phutil_require_module('phutil', 'moduleutils');
phutil_require_module('phutil', 'parser/uri');
phutil_require_module('phutil', 'utils');
phutil_require_source('PhabricatorSetup.php');