Fix introduced style errors

This commit is contained in:
Bart Visscher 2012-10-27 17:45:09 +02:00
parent d6953fa5ed
commit fecfeac55d
6 changed files with 52 additions and 40 deletions

View File

@ -8,14 +8,16 @@
class OC_Core_LostPassword_Controller { class OC_Core_LostPassword_Controller {
protected static function displayLostPasswordPage($error, $requested) { protected static function displayLostPasswordPage($error, $requested) {
OC_Template::printGuestPage('core/lostpassword', 'lostpassword', array('error' => $error, 'requested' => $requested)); OC_Template::printGuestPage('core/lostpassword', 'lostpassword',
array('error' => $error, 'requested' => $requested));
} }
protected static function displayResetPasswordPage($success, $args) { protected static function displayResetPasswordPage($success, $args) {
$route_args = array(); $route_args = array();
$route_args['token'] = $args['token']; $route_args['token'] = $args['token'];
$route_args['user'] = $args['user']; $route_args['user'] = $args['user'];
OC_Template::printGuestPage('core/lostpassword', 'resetpassword', array('success' => $success, 'args' => $route_args)); OC_Template::printGuestPage('core/lostpassword', 'resetpassword',
array('success' => $success, 'args' => $route_args));
} }
protected static function checkToken($user, $token) { protected static function checkToken($user, $token) {
@ -29,10 +31,12 @@ class OC_Core_LostPassword_Controller {
public static function sendEmail($args) { public static function sendEmail($args) {
if (OC_User::userExists($_POST['user'])) { if (OC_User::userExists($_POST['user'])) {
$token = hash('sha256', OC_Util::generate_random_bytes(30).OC_Config::getValue('passwordsalt', '')); $token = hash('sha256', OC_Util::generate_random_bytes(30).OC_Config::getValue('passwordsalt', ''));
OC_Preferences::setValue($_POST['user'], 'owncloud', 'lostpassword', hash('sha256', $token)); // Hash the token again to prevent timing attacks OC_Preferences::setValue($_POST['user'], 'owncloud', 'lostpassword',
hash('sha256', $token)); // Hash the token again to prevent timing attacks
$email = OC_Preferences::getValue($_POST['user'], 'settings', 'email', ''); $email = OC_Preferences::getValue($_POST['user'], 'settings', 'email', '');
if (!empty($email)) { if (!empty($email)) {
$link = OC_Helper::linkToRoute('core_lostpassword_reset', array('user' => $_POST['user'], 'token' => $token)); $link = OC_Helper::linkToRoute('core_lostpassword_reset',
array('user' => $_POST['user'], 'token' => $token));
$link = OC_Helper::makeURLAbsolute($link); $link = OC_Helper::makeURLAbsolute($link);
$tmpl = new OC_Template('core/lostpassword', 'email'); $tmpl = new OC_Template('core/lostpassword', 'email');

View File

@ -6,7 +6,7 @@
* See the COPYING-README file. * See the COPYING-README file.
*/ */
require_once('settings/routes.php'); require_once 'settings/routes.php';
// Core ajax actions // Core ajax actions
// AppConfig // AppConfig

View File

@ -516,7 +516,8 @@ class OC{
} }
$file_ext = substr($param['file'], -3); $file_ext = substr($param['file'], -3);
if ($file_ext != 'php' if ($file_ext != 'php'
|| !self::loadAppScriptFile($param)) { || !self::loadAppScriptFile($param))
{
header('HTTP/1.0 404 Not Found'); header('HTTP/1.0 404 Not Found');
} }
} }

View File

@ -111,8 +111,8 @@ class OC_OCS {
$format = $parameters['format']; $format = $parameters['format'];
$login = OC_OCS::readData('post', 'login', 'text'); $login = OC_OCS::readData('post', 'login', 'text');
$passwd = OC_OCS::readData('post', 'password', 'text'); $passwd = OC_OCS::readData('post', 'password', 'text');
OC_OCS::personCheck($format,$login,$passwd); OC_OCS::personCheck($format, $login, $passwd);
}) })
->requirements(array('format'=>'xml|json')); ->requirements(array('format'=>'xml|json'));
// ACTIVITY // ACTIVITY
@ -125,7 +125,7 @@ class OC_OCS {
$pagesize = OC_OCS::readData('get', 'pagesize', 'int', 10); $pagesize = OC_OCS::readData('get', 'pagesize', 'int', 10);
if($pagesize<1 or $pagesize>100) $pagesize=10; if($pagesize<1 or $pagesize>100) $pagesize=10;
OC_OCS::activityGet($format, $page, $pagesize); OC_OCS::activityGet($format, $page, $pagesize);
}) })
->requirements(array('format'=>'xml|json')); ->requirements(array('format'=>'xml|json'));
// activityput - POST ACTIVITY // activityput - POST ACTIVITY
$router->create('activity_put', '/activity.{format}') $router->create('activity_put', '/activity.{format}')
@ -134,8 +134,8 @@ class OC_OCS {
->action(function ($parameters) { ->action(function ($parameters) {
$format = $parameters['format']; $format = $parameters['format'];
$message = OC_OCS::readData('post', 'message', 'text'); $message = OC_OCS::readData('post', 'message', 'text');
OC_OCS::activityPut($format,$message); OC_OCS::activityPut($format, $message);
}) })
->requirements(array('format'=>'xml|json')); ->requirements(array('format'=>'xml|json'));
// PRIVATEDATA // PRIVATEDATA
@ -148,7 +148,7 @@ class OC_OCS {
$app = addslashes(strip_tags($parameters['app'])); $app = addslashes(strip_tags($parameters['app']));
$key = addslashes(strip_tags($parameters['key'])); $key = addslashes(strip_tags($parameters['key']));
OC_OCS::privateDataGet($format, $app, $key); OC_OCS::privateDataGet($format, $app, $key);
}) })
->requirements(array('format'=>'xml|json')); ->requirements(array('format'=>'xml|json'));
// set - POST DATA // set - POST DATA
$router->create('privatedata_set', $router->create('privatedata_set',
@ -161,7 +161,7 @@ class OC_OCS {
$key = addslashes(strip_tags($parameters['key'])); $key = addslashes(strip_tags($parameters['key']));
$value=OC_OCS::readData('post', 'value', 'text'); $value=OC_OCS::readData('post', 'value', 'text');
OC_OCS::privateDataSet($format, $app, $key, $value); OC_OCS::privateDataSet($format, $app, $key, $value);
}) })
->requirements(array('format'=>'xml|json')); ->requirements(array('format'=>'xml|json'));
// delete - POST DATA // delete - POST DATA
$router->create('privatedata_delete', $router->create('privatedata_delete',
@ -173,7 +173,7 @@ class OC_OCS {
$app = addslashes(strip_tags($parameters['app'])); $app = addslashes(strip_tags($parameters['app']));
$key = addslashes(strip_tags($parameters['key'])); $key = addslashes(strip_tags($parameters['key']));
OC_OCS::privateDataDelete($format, $app, $key); OC_OCS::privateDataDelete($format, $app, $key);
}) })
->requirements(array('format'=>'xml|json')); ->requirements(array('format'=>'xml|json'));
// CLOUD // CLOUD
@ -184,7 +184,7 @@ class OC_OCS {
->action(function ($parameters) { ->action(function ($parameters) {
$format = $parameters['format']; $format = $parameters['format'];
OC_OCS::systemwebapps($format); OC_OCS::systemwebapps($format);
}) })
->requirements(array('format'=>'xml|json')); ->requirements(array('format'=>'xml|json'));
// quotaget // quotaget
@ -195,7 +195,7 @@ class OC_OCS {
$format = $parameters['format']; $format = $parameters['format'];
$user = $parameters['user']; $user = $parameters['user'];
OC_OCS::quotaGet($format, $user); OC_OCS::quotaGet($format, $user);
}) })
->requirements(array('format'=>'xml|json')); ->requirements(array('format'=>'xml|json'));
// quotaset // quotaset
$router->create('quota_set', $router->create('quota_set',
@ -207,7 +207,7 @@ class OC_OCS {
$user = $parameters['user']; $user = $parameters['user'];
$quota = self::readData('post', 'quota', 'int'); $quota = self::readData('post', 'quota', 'int');
OC_OCS::quotaSet($format, $user, $quota); OC_OCS::quotaSet($format, $user, $quota);
}) })
->requirements(array('format'=>'xml|json')); ->requirements(array('format'=>'xml|json'));
// keygetpublic // keygetpublic
@ -217,8 +217,8 @@ class OC_OCS {
->action(function ($parameters) { ->action(function ($parameters) {
$format = $parameters['format']; $format = $parameters['format'];
$user = $parameters['user']; $user = $parameters['user'];
OC_OCS::publicKeyGet($format,$user); OC_OCS::publicKeyGet($format, $user);
}) })
->requirements(array('format'=>'xml|json')); ->requirements(array('format'=>'xml|json'));
// keygetprivate // keygetprivate
@ -228,8 +228,8 @@ class OC_OCS {
->action(function ($parameters) { ->action(function ($parameters) {
$format = $parameters['format']; $format = $parameters['format'];
$user = $parameters['user']; $user = $parameters['user'];
OC_OCS::privateKeyGet($format,$user); OC_OCS::privateKeyGet($format, $user);
}) })
->requirements(array('format'=>'xml|json')); ->requirements(array('format'=>'xml|json'));
@ -247,7 +247,10 @@ class OC_OCS {
try { try {
$router->match($_SERVER['PATH_INFO']); $router->match($_SERVER['PATH_INFO']);
} catch (ResourceNotFoundException $e) { } catch (ResourceNotFoundException $e) {
$txt='Invalid query, please check the syntax. API specifications are here: http://www.freedesktop.org/wiki/Specifications/open-collaboration-services. DEBUG OUTPUT:'."\n"; $txt='Invalid query, please check the syntax. '
.'API specifications are here: '
.'http://www.freedesktop.org/wiki/Specifications/open-collaboration-services.'
.'DEBUG OUTPUT:'."\n";
$txt.=OC_OCS::getdebugoutput(); $txt.=OC_OCS::getdebugoutput();
echo(OC_OCS::generatexml($format, 'failed', 999, $txt)); echo(OC_OCS::generatexml($format, 'failed', 999, $txt));
} catch (MethodNotAllowedException $e) { } catch (MethodNotAllowedException $e) {
@ -323,7 +326,7 @@ class OC_OCS {
* @param int $itemsperpage * @param int $itemsperpage
* @return string xml/json * @return string xml/json
*/ */
private static function generateXml($format,$status,$statuscode,$message,$data=array(),$tag='',$tagattribute='',$dimension=-1,$itemscount='',$itemsperpage='') { private static function generateXml($format, $status, $statuscode, $message, $data=array(), $tag='', $tagattribute='', $dimension=-1, $itemscount='', $itemsperpage='') {
if($format=='json') { if($format=='json') {
$json=array(); $json=array();
$json['status']=$status; $json['status']=$status;
@ -343,7 +346,7 @@ class OC_OCS {
xmlwriter_write_element($writer, 'status', $status); xmlwriter_write_element($writer, 'status', $status);
xmlwriter_write_element($writer, 'statuscode', $statuscode); xmlwriter_write_element($writer, 'statuscode', $statuscode);
xmlwriter_write_element($writer, 'message', $message); xmlwriter_write_element($writer, 'message', $message);
if($itemscount<>'') xmlwriter_write_element($writer,'totalitems',$itemscount); if($itemscount<>'') xmlwriter_write_element($writer, 'totalitems', $itemscount);
if(!empty($itemsperpage)) xmlwriter_write_element($writer, 'itemsperpage', $itemsperpage); if(!empty($itemsperpage)) xmlwriter_write_element($writer, 'itemsperpage', $itemsperpage);
xmlwriter_end_element($writer); xmlwriter_end_element($writer);
if($dimension=='0') { if($dimension=='0') {
@ -358,7 +361,7 @@ class OC_OCS {
xmlwriter_end_element($writer); xmlwriter_end_element($writer);
}elseif($dimension=='2') { }elseif($dimension=='2') {
xmlwriter_start_element($writer,'data'); xmlwriter_start_element($writer, 'data');
foreach($data as $entry) { foreach($data as $entry) {
xmlwriter_start_element($writer, $tag); xmlwriter_start_element($writer, $tag);
if(!empty($tagattribute)) { if(!empty($tagattribute)) {
@ -413,14 +416,14 @@ class OC_OCS {
} }
} }
public static function toXml($writer,$data,$node) { public static function toXml($writer, $data, $node) {
foreach($data as $key => $value) { foreach($data as $key => $value) {
if (is_numeric($key)) { if (is_numeric($key)) {
$key = $node; $key = $node;
} }
if (is_array($value)) { if (is_array($value)) {
xmlwriter_start_element($writer, $key); xmlwriter_start_element($writer, $key);
OC_OCS::toxml($writer,$value, $node); OC_OCS::toxml($writer, $value, $node);
xmlwriter_end_element($writer); xmlwriter_end_element($writer);
}else{ }else{
xmlwriter_write_element($writer, $key, $value); xmlwriter_write_element($writer, $key, $value);
@ -453,7 +456,7 @@ class OC_OCS {
* @param string $passwd * @param string $passwd
* @return string xml/json * @return string xml/json
*/ */
private static function personCheck($format,$login,$passwd) { private static function personCheck($format, $login, $passwd) {
if($login<>'') { if($login<>'') {
if(OC_User::login($login, $passwd)) { if(OC_User::login($login, $passwd)) {
$xml['person']['personid']=$login; $xml['person']['personid']=$login;
@ -480,7 +483,7 @@ class OC_OCS {
//TODO //TODO
$txt=OC_OCS::generatexml($format, 'ok', 100, '', $xml, 'activity', 'full', 2, $totalcount,$pagesize); $txt=OC_OCS::generatexml($format, 'ok', 100, '', $xml, 'activity', 'full', 2, $totalcount, $pagesize);
echo($txt); echo($txt);
} }
@ -490,7 +493,7 @@ class OC_OCS {
* @param string $message * @param string $message
* @return string xml/json * @return string xml/json
*/ */
private static function activityPut($format,$message) { private static function activityPut($format, $message) {
// not implemented in ownCloud // not implemented in ownCloud
$user=OC_OCS::checkpassword(); $user=OC_OCS::checkpassword();
echo(OC_OCS::generatexml($format, 'ok', 100, '')); echo(OC_OCS::generatexml($format, 'ok', 100, ''));
@ -621,7 +624,7 @@ class OC_OCS {
foreach($apps as $app) { foreach($apps as $app) {
$info=OC_App::getAppInfo($app); $info=OC_App::getAppInfo($app);
if(isset($info['standalone'])) { if(isset($info['standalone'])) {
$newvalue=array('name'=>$info['name'],'url'=>OC_Helper::linkToAbsolute($app,''),'icon'=>''); $newvalue=array('name'=>$info['name'], 'url'=>OC_Helper::linkToAbsolute($app, ''), 'icon'=>'');
$values[]=$newvalue; $values[]=$newvalue;
} }
@ -638,7 +641,7 @@ class OC_OCS {
* @param string $user * @param string $user
* @return string xml/json * @return string xml/json
*/ */
private static function quotaGet($format,$user) { private static function quotaGet($format, $user) {
$login=OC_OCS::checkpassword(); $login=OC_OCS::checkpassword();
if(OC_Group::inGroup($login, 'admin') or ($login==$user)) { if(OC_Group::inGroup($login, 'admin') or ($login==$user)) {
@ -677,7 +680,7 @@ class OC_OCS {
* @param string $quota * @param string $quota
* @return string xml/json * @return string xml/json
*/ */
private static function quotaSet($format,$user,$quota) { private static function quotaSet($format, $user, $quota) {
$login=OC_OCS::checkpassword(); $login=OC_OCS::checkpassword();
if(OC_Group::inGroup($login, 'admin')) { if(OC_Group::inGroup($login, 'admin')) {
@ -700,7 +703,7 @@ class OC_OCS {
* @param string $user * @param string $user
* @return string xml/json * @return string xml/json
*/ */
private static function publicKeyGet($format,$user) { private static function publicKeyGet($format, $user) {
$login=OC_OCS::checkpassword(); $login=OC_OCS::checkpassword();
if(OC_User::userExists($user)) { if(OC_User::userExists($user)) {
@ -718,7 +721,7 @@ class OC_OCS {
* @param string $user * @param string $user
* @return string xml/json * @return string xml/json
*/ */
private static function privateKeyGet($format,$user) { private static function privateKeyGet($format, $user) {
$login=OC_OCS::checkpassword(); $login=OC_OCS::checkpassword();
if(OC_Group::inGroup($login, 'admin') or ($login==$user)) { if(OC_Group::inGroup($login, 'admin') or ($login==$user)) {

View File

@ -106,7 +106,11 @@ class OC_Route extends Route {
* @param $file * @param $file
*/ */
public function actionInclude($file) { public function actionInclude($file) {
$function = create_function('$param', 'unset($param["_route"]);$_GET=array_merge($_GET,$param);unset($param);require_once "'.$file.'";'); $function = create_function('$param',
'unset($param["_route"]);'
.'$_GET=array_merge($_GET,$param);'
.'unset($param);'
.'require_once "'.$file.'";');
$this->action($function); $this->action($function);
} }
} }

View File

@ -35,9 +35,9 @@ class OC_Router {
public function loadRoutes() { public function loadRoutes() {
foreach(OC_APP::getEnabledApps() as $app){ foreach(OC_APP::getEnabledApps() as $app){
$file = OC_App::getAppPath($app).'/appinfo/routes.php'; $file = OC_App::getAppPath($app).'/appinfo/routes.php';
if(file_exists($file)){ if(file_exists($file)) {
$this->useCollection($app); $this->useCollection($app);
require_once($file); require_once $file;
$collection = $this->getCollection($app); $collection = $this->getCollection($app);
$this->root->addCollection($collection, '/apps/'.$app); $this->root->addCollection($collection, '/apps/'.$app);
} }
@ -81,7 +81,7 @@ class OC_Router {
* *
* @param string $url The url to find * @param string $url The url to find
*/ */
public function match($url) { public function match($url) {
$matcher = new UrlMatcher($this->root, $this->context); $matcher = new UrlMatcher($this->root, $this->context);
$parameters = $matcher->match($url); $parameters = $matcher->match($url);
if (isset($parameters['action'])) { if (isset($parameters['action'])) {
@ -93,7 +93,7 @@ class OC_Router {
unset($parameters['action']); unset($parameters['action']);
call_user_func($action, $parameters); call_user_func($action, $parameters);
} elseif (isset($parameters['file'])) { } elseif (isset($parameters['file'])) {
include ($parameters['file']); include $parameters['file'];
} else { } else {
throw new Exception('no action available'); throw new Exception('no action available');
} }