Make some apps compatible

This commit is contained in:
Lukas Reschke 2012-06-11 19:07:51 +02:00
parent 6d68b7620c
commit 2b22c538c8
17 changed files with 64 additions and 35 deletions

View File

@ -54,9 +54,9 @@ OCP\Util::addscript('contacts','jquery.multi-autocomplete');
OCP\Util::addscript('','oc-vcategories'); OCP\Util::addscript('','oc-vcategories');
OCP\App::setActiveNavigationEntry('calendar_index'); OCP\App::setActiveNavigationEntry('calendar_index');
$tmpl = new OCP\Template('calendar', 'calendar', 'user'); $tmpl = new OCP\Template('calendar', 'calendar', 'user');
$tmpl->assign('eventSources', $eventSources); $tmpl->assign('eventSources', $eventSources,false);
$tmpl->assign('categories', $categories); $tmpl->assign('categories', $categories);
if(array_key_exists('showevent', $_GET)){ if(array_key_exists('showevent', $_GET)){
$tmpl->assign('showevent', $_GET['showevent']); $tmpl->assign('showevent', $_GET['showevent'], false);
} }
$tmpl->printPage(); $tmpl->printPage();

View File

@ -82,6 +82,7 @@ if(is_array($value)) {
$value = strip_tags($value); $value = strip_tags($value);
} }
/* preprocessing value */
switch($name) { switch($name) {
case 'BDAY': case 'BDAY':
$date = New DateTime($value); $date = New DateTime($value);
@ -94,6 +95,8 @@ switch($name) {
case 'N': case 'N':
case 'ORG': case 'ORG':
case 'NOTE': case 'NOTE':
$value = str_replace('\n', ' \\n', $value);
break;
case 'NICKNAME': case 'NICKNAME':
// TODO: Escape commas and semicolons. // TODO: Escape commas and semicolons.
break; break;
@ -105,8 +108,14 @@ switch($name) {
break; break;
} }
switch($name) {
case 'NOTE':
$vcard->setString('NOTE', $value);
break;
default:
$property = $vcard->addProperty($name, $value); //, $parameters); $property = $vcard->addProperty($name, $value); //, $parameters);
break;
}
$line = count($vcard->children) - 1; $line = count($vcard->children) - 1;

View File

@ -8,5 +8,5 @@
} }
} }
?> ?>
<li role="button" book-id="<?php echo $contact['addressbookid']; ?>" data-id="<?php echo $contact['id']; ?>"><a href="index.php?id=<?php echo $contact['id']; ?>"><?php echo htmlspecialchars($display); ?></a></li> <li role="button" book-id="<?php echo $contact['addressbookid']; ?>" data-id="<?php echo $contact['id']; ?>"><a href="index.php?id=<?php echo $contact['id']; ?>"><?php echo $display; ?></a></li>
<?php endforeach; ?> <?php endforeach; ?>

View File

@ -38,7 +38,7 @@ foreach( OC_Files::getdirectorycontent( $dir ) as $i ){
} }
$list = new OCP\Template( "files", "part.list", "" ); $list = new OCP\Template( "files", "part.list", "" );
$list->assign( "files", $files ); $list->assign( "files", $files, false );
$data = array('files' => $list->fetchPage()); $data = array('files' => $list->fetchPage());
OCP\JSON::success(array('data' => $data)); OCP\JSON::success(array('data' => $data));

View File

@ -73,12 +73,12 @@ foreach( explode( '/', $dir ) as $i ){
// make breadcrumb und filelist markup // make breadcrumb und filelist markup
$list = new OCP\Template( 'files', 'part.list', '' ); $list = new OCP\Template( 'files', 'part.list', '' );
$list->assign( 'files', $files ); $list->assign( 'files', $files, false );
$list->assign( 'baseURL', OCP\Util::linkTo('files', 'index.php').'&dir='); $list->assign( 'baseURL', OCP\Util::linkTo('files', 'index.php').'&dir=', false);
$list->assign( 'downloadURL', OCP\Util::linkTo('files', 'download.php').'?file='); $list->assign( 'downloadURL', OCP\Util::linkTo('files', 'download.php').'?file=', false);
$breadcrumbNav = new OCP\Template( 'files', 'part.breadcrumb', '' ); $breadcrumbNav = new OCP\Template( 'files', 'part.breadcrumb', '' );
$breadcrumbNav->assign( 'breadcrumb', $breadcrumb ); $breadcrumbNav->assign( 'breadcrumb', $breadcrumb, false );
$breadcrumbNav->assign( 'baseURL', OCP\Util::linkTo('files', 'index.php').'&dir='); $breadcrumbNav->assign( 'baseURL', OCP\Util::linkTo('files', 'index.php').'&dir=', false);
$upload_max_filesize = OCP\Util::computerFileSize(ini_get('upload_max_filesize')); $upload_max_filesize = OCP\Util::computerFileSize(ini_get('upload_max_filesize'));
$post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size')); $post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size'));
@ -89,8 +89,8 @@ $freeSpace=max($freeSpace,0);
$maxUploadFilesize = min($maxUploadFilesize ,$freeSpace); $maxUploadFilesize = min($maxUploadFilesize ,$freeSpace);
$tmpl = new OCP\Template( 'files', 'index', 'user' ); $tmpl = new OCP\Template( 'files', 'index', 'user' );
$tmpl->assign( 'fileList', $list->fetchPage() ); $tmpl->assign( 'fileList', $list->fetchPage(), false );
$tmpl->assign( 'breadcrumb', $breadcrumbNav->fetchPage() ); $tmpl->assign( 'breadcrumb', $breadcrumbNav->fetchPage(), false );
$tmpl->assign( 'dir', $dir); $tmpl->assign( 'dir', $dir);
$tmpl->assign( 'readonly', !OC_Filesystem::is_writable($dir.'/')); $tmpl->assign( 'readonly', !OC_Filesystem::is_writable($dir.'/'));
$tmpl->assign( 'files', $files ); $tmpl->assign( 'files', $files );

View File

@ -141,7 +141,7 @@ class TileStack extends TileBase {
} }
public function get() { public function get() {
$r = '<div class="title gallery_div">'.htmlentities($this->stack_name).'</div>'; $r = '<div class="title gallery_div">'.$this->stack_name.'</div>';
for ($i = 0; $i < count($this->tiles_array); $i++) { for ($i = 0; $i < count($this->tiles_array); $i++) {
$top = rand(-5, 5); $top = rand(-5, 5);
$left = rand(-5, 5); $left = rand(-5, 5);
@ -168,7 +168,7 @@ class TileStack extends TileBase {
} }
public function getOnClickAction() { public function getOnClickAction() {
return 'javascript:openNewGal(\''.htmlentities($this->stack_name).'\');'; return 'javascript:openNewGal(\''.$this->stack_name.'\');';
} }
private $tiles_array; private $tiles_array;

View File

@ -186,7 +186,7 @@ class OC_GROUP_LDAP extends OC_Group_Backend {
if(!$this->configured) { if(!$this->configured) {
return array(); return array();
} }
if(is_null($this->_groups)) { if(empty($this->_groups)) {
$ldap_groups = OC_LDAP::fetchListOfGroups($this->ldapGroupFilter, array(OC_LDAP::conf('ldapGroupDisplayName'), 'dn')); $ldap_groups = OC_LDAP::fetchListOfGroups($this->ldapGroupFilter, array(OC_LDAP::conf('ldapGroupDisplayName'), 'dn'));
$this->_groups = OC_LDAP::ownCloudGroupNames($ldap_groups); $this->_groups = OC_LDAP::ownCloudGroupNames($ldap_groups);
} }

View File

@ -20,7 +20,7 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
$params = array('ldap_host', 'ldap_port', 'ldap_dn', 'ldap_agent_password', 'ldap_base', 'ldap_base_users', 'ldap_base_groups', 'ldap_userlist_filter', 'ldap_login_filter', 'ldap_group_filter', 'ldap_display_name', 'ldap_tls', 'ldap_nocase', 'ldap_quota_def', 'ldap_quota_attr', 'ldap_email_attr', 'ldap_group_member_assoc_attribute'); $params = array('ldap_host', 'ldap_port', 'ldap_dn', 'ldap_agent_password', 'ldap_base', 'ldap_base_users', 'ldap_base_groups', 'ldap_userlist_filter', 'ldap_login_filter', 'ldap_group_filter', 'ldap_display_name', 'ldap_group_display_name', 'ldap_tls', 'ldap_nocase', 'ldap_quota_def', 'ldap_quota_attr', 'ldap_email_attr', 'ldap_group_member_assoc_attribute');
OCP\Util::addscript('user_ldap', 'settings'); OCP\Util::addscript('user_ldap', 'settings');
@ -47,13 +47,14 @@ if ($_POST) {
// fill template // fill template
$tmpl = new OCP\Template( 'user_ldap', 'settings'); $tmpl = new OCP\Template( 'user_ldap', 'settings');
foreach($params as $param){ foreach($params as $param){
$value = htmlentities(OCP\Config::getAppValue('user_ldap', $param,'')); $value = OCP\Config::getAppValue('user_ldap', $param,'');
$tmpl->assign($param, $value); $tmpl->assign($param, $value);
} }
// settings with default values // settings with default values
$tmpl->assign( 'ldap_port', OCP\Config::getAppValue('user_ldap', 'ldap_port', '389')); $tmpl->assign( 'ldap_port', OCP\Config::getAppValue('user_ldap', 'ldap_port', '389'));
$tmpl->assign( 'ldap_display_name', OCP\Config::getAppValue('user_ldap', 'ldap_display_name', 'uid')); $tmpl->assign( 'ldap_display_name', OCP\Config::getAppValue('user_ldap', 'ldap_display_name', 'uid'));
$tmpl->assign( 'ldap_group_display_name', OCP\Config::getAppValue('user_ldap', 'ldap_group_display_name', 'cn'));
$tmpl->assign( 'ldap_group_member_assoc_attribute', OCP\Config::getAppValue('user_ldap', 'ldap_group_member_assoc_attribute', 'uniqueMember')); $tmpl->assign( 'ldap_group_member_assoc_attribute', OCP\Config::getAppValue('user_ldap', 'ldap_group_member_assoc_attribute', 'uniqueMember'));
$tmpl->assign( 'ldap_agent_password', base64_decode(OCP\Config::getAppValue('user_ldap', 'ldap_agent_password'))); $tmpl->assign( 'ldap_agent_password', base64_decode(OCP\Config::getAppValue('user_ldap', 'ldap_agent_password')));

View File

@ -22,6 +22,7 @@
<p><input type="checkbox" id="ldap_nocase" name="ldap_nocase" value="1"<?php if (isset($_['ldap_nocase']) && ($_['ldap_nocase'])) echo ' checked'; ?>><label for="ldap_nocase"><?php echo $l->t('Case insensitve LDAP server (Windows)');?></label></p> <p><input type="checkbox" id="ldap_nocase" name="ldap_nocase" value="1"<?php if (isset($_['ldap_nocase']) && ($_['ldap_nocase'])) echo ' checked'; ?>><label for="ldap_nocase"><?php echo $l->t('Case insensitve LDAP server (Windows)');?></label></p>
<p><label for="ldap_display_name"><?php echo $l->t('Display Name Field');?></label><input type="text" id="ldap_display_name" name="ldap_display_name" value="<?php echo $_['ldap_display_name']; ?>" /> <p><label for="ldap_display_name"><?php echo $l->t('Display Name Field');?></label><input type="text" id="ldap_display_name" name="ldap_display_name" value="<?php echo $_['ldap_display_name']; ?>" />
<small><?php echo $l->t('Currently the display name field needs to be the same you matched %%uid against in the filter above, because ownCloud doesn\'t distinguish between user id and user name.');?></small></p> <small><?php echo $l->t('Currently the display name field needs to be the same you matched %%uid against in the filter above, because ownCloud doesn\'t distinguish between user id and user name.');?></small></p>
<p><label for="ldap_group_display_name"><?php echo $l->t('Group Display Name Field');?></label><input type="text" id="ldap_group_display_name" name="ldap_group_display_name" value="<?php echo $_['ldap_group_display_name']; ?>" /></p>
<p><label for="ldap_quota_attr">Quota Attribute</label><input type="text" id="ldap_quota_attr" name="ldap_quota_attr" value="<?php echo $_['ldap_quota_attr']; ?>" /> <p><label for="ldap_quota_attr">Quota Attribute</label><input type="text" id="ldap_quota_attr" name="ldap_quota_attr" value="<?php echo $_['ldap_quota_attr']; ?>" />
<label for="ldap_quota_def">Quota Default</label><input type="text" id="ldap_quota_def" name="ldap_quota_def" value="<?php if (isset($_['ldap_quota_def'])) echo $_['ldap_quota_def']; ?>" />bytes</p> <label for="ldap_quota_def">Quota Default</label><input type="text" id="ldap_quota_def" name="ldap_quota_def" value="<?php if (isset($_['ldap_quota_def'])) echo $_['ldap_quota_def']; ?>" />bytes</p>
<p><label for="ldap_email_attr">Email Attribute</label><input type="text" id="ldap_email_attr" name="ldap_email_attr" value="<?php echo $_['ldap_email_attr']; ?>" /></p> <p><label for="ldap_email_attr">Email Attribute</label><input type="text" id="ldap_email_attr" name="ldap_email_attr" value="<?php echo $_['ldap_email_attr']; ?>" /></p>

View File

@ -1,7 +1,7 @@
<!--[if IE 8]><style>input[type="checkbox"]{padding:0;}</style><![endif]--> <!--[if IE 8]><style>input[type="checkbox"]{padding:0;}</style><![endif]-->
<form action="index.php" method="post"> <form action="index.php" method="post">
<fieldset> <fieldset>
<?php if(!empty($_['redirect'])) { echo '<input type="hidden" name="redirect_url" value="'.htmlentities($_['redirect']).'" />'; } ?> <?php if(!empty($_['redirect'])) { echo '<input type="hidden" name="redirect_url" value="'.$_['redirect'].'" />'; } ?>
<?php if($_['error']): ?> <?php if($_['error']): ?>
<a href="./core/lostpassword/"><?php echo $l->t('Lost your password?'); ?></a> <a href="./core/lostpassword/"><?php echo $l->t('Lost your password?'); ?></a>
<?php endif; ?> <?php endif; ?>

View File

@ -112,6 +112,7 @@ elseif(OC_User::isLoggedIn()) {
if (OC_User::login($_SERVER["PHP_AUTH_USER"],$_SERVER["PHP_AUTH_PW"])) { if (OC_User::login($_SERVER["PHP_AUTH_USER"],$_SERVER["PHP_AUTH_PW"])) {
//OC_Log::write('core',"Logged in with HTTP Authentication",OC_Log::DEBUG); //OC_Log::write('core',"Logged in with HTTP Authentication",OC_Log::DEBUG);
OC_User::unsetMagicInCookie(); OC_User::unsetMagicInCookie();
$_REQUEST['redirect_url'] = (isset($_SERVER['REQUEST_URI'])?$_SERVER['REQUEST_URI']:'');
OC_Util::redirectToDefaultPage(); OC_Util::redirectToDefaultPage();
}else{ }else{
$error = true; $error = true;

View File

@ -286,11 +286,9 @@ class OC_Template{
* This function is internally used to sanitize HTML. * This function is internally used to sanitize HTML.
*/ */
private static function sanitizeHTML( &$value ){ private static function sanitizeHTML( &$value ){
if(is_string($value)) { $value = htmlentities( $value );
$value = htmlentities( $value, ENT_QUOTES );
return $value; return $value;
} }
}
/** /**
* @brief Appends a variable * @brief Appends a variable
@ -528,13 +526,13 @@ class OC_Template{
$_ = array_merge( $additionalparams, $this->vars ); $_ = array_merge( $additionalparams, $this->vars );
} }
// Einbinden // Include
ob_start(); ob_start();
include( $this->path.$file.'.php' ); include( $this->path.$file.'.php' );
$data = ob_get_contents(); $data = ob_get_contents();
@ob_end_clean(); @ob_end_clean();
// Daten zurückgeben // Return data
return $data; return $data;
} }
@ -548,7 +546,7 @@ class OC_Template{
public static function printUserPage( $application, $name, $parameters = array() ){ public static function printUserPage( $application, $name, $parameters = array() ){
$content = new OC_Template( $application, $name, "user" ); $content = new OC_Template( $application, $name, "user" );
foreach( $parameters as $key => $value ){ foreach( $parameters as $key => $value ){
$content->assign( $key, $value ); $content->assign( $key, $value, false );
} }
print $content->printPage(); print $content->printPage();
} }
@ -563,7 +561,7 @@ class OC_Template{
public static function printAdminPage( $application, $name, $parameters = array() ){ public static function printAdminPage( $application, $name, $parameters = array() ){
$content = new OC_Template( $application, $name, "admin" ); $content = new OC_Template( $application, $name, "admin" );
foreach( $parameters as $key => $value ){ foreach( $parameters as $key => $value ){
$content->assign( $key, $value ); $content->assign( $key, $value, false );
} }
return $content->printPage(); return $content->printPage();
} }
@ -578,7 +576,7 @@ class OC_Template{
public static function printGuestPage( $application, $name, $parameters = array() ){ public static function printGuestPage( $application, $name, $parameters = array() ){
$content = new OC_Template( $application, $name, "guest" ); $content = new OC_Template( $application, $name, "guest" );
foreach( $parameters as $key => $value ){ foreach( $parameters as $key => $value ){
$content->assign( $key, $value ); $content->assign( $key, $value,false );
} }
return $content->printPage(); return $content->printPage();
} }

21
lib/util.php Normal file → Executable file
View File

@ -332,7 +332,8 @@ class OC_Util {
* Redirect to the user default page * Redirect to the user default page
*/ */
public static function redirectToDefaultPage(){ public static function redirectToDefaultPage(){
if(isset($_REQUEST['redirect_url']) && substr($_REQUEST['redirect_url'], 0, strlen(OC::$WEBROOT)) == OC::$WEBROOT) { OC_Log::write('core','redirectToDefaultPage',OC_Log::DEBUG);
if(isset($_REQUEST['redirect_url']) && (substr($_REQUEST['redirect_url'], 0, strlen(OC::$WEBROOT)) == OC::$WEBROOT || $_REQUEST['redirect_url'][0] == '/')) {
header( 'Location: '.$_REQUEST['redirect_url']); header( 'Location: '.$_REQUEST['redirect_url']);
} else { } else {
header( 'Location: '.OC::$WEBROOT.'/'.OC_Appconfig::getValue('core', 'defaultpage', '?app=files')); header( 'Location: '.OC::$WEBROOT.'/'.OC_Appconfig::getValue('core', 'defaultpage', '?app=files'));
@ -358,12 +359,30 @@ class OC_Util {
* Todo: Write howto * Todo: Write howto
*/ */
public static function callRegister(){ public static function callRegister(){
//mamimum time before token exires
$maxtime=(60*60); // 1 hour
// generate a random token. // generate a random token.
$token=mt_rand(1000,9000).mt_rand(1000,9000).mt_rand(1000,9000); $token=mt_rand(1000,9000).mt_rand(1000,9000).mt_rand(1000,9000);
// store the token together with a timestamp in the session. // store the token together with a timestamp in the session.
$_SESSION['requesttoken-'.$token]=time(); $_SESSION['requesttoken-'.$token]=time();
// cleanup old tokens garbage collector
// only run every 20th time so we don´t waste cpu cycles
if(rand(0,20)==0) {
foreach($_SESSION as $key=>$value) {
// search all tokens in the session
if(substr($key,0,12)=='requesttoken') {
if($value+$maxtime<time()){
// remove outdated tokens
unset($_SESSION[$key]);
}
}
}
}
// return the token // return the token
return($token); return($token);
} }

View File

@ -22,7 +22,7 @@ function compareEntries($a,$b){
} }
usort($entries, 'compareEntries'); usort($entries, 'compareEntries');
$tmpl->assign('loglevel',OC_Config::getValue( "loglevel", 2 )); $tmpl->assign('loglevel',OC_Config::getValue( "loglevel", 2 ), false);
$tmpl->assign('entries',$entries); $tmpl->assign('entries',$entries);
$tmpl->assign('forms',array()); $tmpl->assign('forms',array());
foreach($forms as $form){ foreach($forms as $form){

View File

@ -92,7 +92,7 @@ usort($apps, 'app_sort');
$tmpl = new OC_Template( "settings", "apps", "user" ); $tmpl = new OC_Template( "settings", "apps", "user" );
$tmpl->assign('apps',$apps); $tmpl->assign('apps',$apps, false);
$tmpl->printPage(); $tmpl->printPage();

View File

@ -29,7 +29,7 @@ $levels=array('Debug','Info','Warning','Error','Fatal');
<?php echo $entry->app;?> <?php echo $entry->app;?>
</td> </td>
<td> <td>
<?php echo htmlentities($entry->message);?> <?php echo $entry->message;?>
</td> </td>
<td> <td>
<?php echo OC_Util::formatDate($entry->time);?> <?php echo OC_Util::formatDate($entry->time);?>

View File

@ -26,9 +26,9 @@
<?php foreach($_["kbe"] as $kb): ?> <?php foreach($_["kbe"] as $kb): ?>
<div class="helpblock"> <div class="helpblock">
<?php if($kb["preview1"] <> "") { echo('<img class="preview" src="'.$kb["preview1"].'" />'); } ?> <?php if($kb["preview1"] <> "") { echo('<img class="preview" src="'.$kb["preview1"].'" />'); } ?>
<?php if($kb['detailpage']<>'') echo('<p><a target="_blank" href="'.$kb['detailpage'].'"><strong>'.htmlentities($kb["name"]).'</strong></a></p>');?> <?php if($kb['detailpage']<>'') echo('<p><a target="_blank" href="'.$kb['detailpage'].'"><strong>'.$kb["name"].'</strong></a></p>');?>
<p><?php echo htmlentities($kb['description']);?></p> <p><?php echo $kb['description'];?></p>
<?php if($kb['answer']<>'') echo('<p><strong>'.$l->t('Answer').':</strong><p>'.htmlentities($kb['answer']).'</p>');?> <?php if($kb['answer']<>'') echo('<p><strong>'.$l->t('Answer').':</strong><p>'.$kb['answer'].'</p>');?>
</div> </div>
<?php endforeach; <?php endforeach;
endif?> endif?>