@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | $etag = '"'.md5($config.$link_registry).'"'; |
| 33 | 33 | |
| 34 | 34 | // headers to allow caching, egw_framework specifies etag on url to force reload, even with Expires header |
| 35 | -Api\Session::cache_control(86400); // cache for one day |
|
| 35 | +Api\Session::cache_control(86400); // cache for one day |
|
| 36 | 36 | Header('Content-Type: text/javascript; charset=utf-8'); |
| 37 | 37 | Header('ETag: '.$etag); |
| 38 | 38 | |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | $content .= 'egw.set_link_registry('.$link_registry.", undefined, egw && egw.window !== window);\n"; |
| 48 | 48 | |
| 49 | 49 | // we run our own gzip compression, to set a correct Content-Length of the encoded content |
| 50 | -if (in_array('gzip', explode(',',$_SERVER['HTTP_ACCEPT_ENCODING'])) && function_exists('gzencode')) |
|
| 50 | +if (in_array('gzip', explode(',', $_SERVER['HTTP_ACCEPT_ENCODING'])) && function_exists('gzencode')) |
|
| 51 | 51 | { |
| 52 | 52 | $content = gzencode($content); |
| 53 | 53 | header('Content-Encoding: gzip'); |
@@ -16,18 +16,18 @@ |
||
| 16 | 16 | |
| 17 | 17 | use EGroupware\Api; |
| 18 | 18 | |
| 19 | -Api\Framework::includeJS('.','etemplate2','etemplate'); |
|
| 20 | -Api\Framework::includeJS('jquery','jquery.tools.min','phpgwapi'); // Not needed once JS require works for files like this |
|
| 21 | -Api\Framework::includeJS('jquery','jquery.html5_upload','phpgwapi'); // Not needed once JS require works for files like this |
|
| 19 | +Api\Framework::includeJS('.', 'etemplate2', 'etemplate'); |
|
| 20 | +Api\Framework::includeJS('jquery', 'jquery.tools.min', 'phpgwapi'); // Not needed once JS require works for files like this |
|
| 21 | +Api\Framework::includeJS('jquery', 'jquery.html5_upload', 'phpgwapi'); // Not needed once JS require works for files like this |
|
| 22 | 22 | Api\Framework::includeCSS('/api/js/etemplate/test/test.css'); |
| 23 | 23 | |
| 24 | 24 | /* |
| 25 | 25 | * Test using any actual template |
| 26 | 26 | */ |
| 27 | 27 | $template = 'etemplate.et2_test_file_upload'; |
| 28 | - if($template) { |
|
| 28 | + if ($template) { |
|
| 29 | 29 | $etemplate = new Api\Etemplate('etemplate.et2_test_file_upload'); |
| 30 | - $etemplate->exec('',array()); |
|
| 30 | + $etemplate->exec('', array()); |
|
| 31 | 31 | return; |
| 32 | 32 | } |
| 33 | 33 | echo $GLOBALS['egw']->framework->header(); |
@@ -25,7 +25,8 @@ |
||
| 25 | 25 | * Test using any actual template |
| 26 | 26 | */ |
| 27 | 27 | $template = 'etemplate.et2_test_file_upload'; |
| 28 | - if($template) { |
|
| 28 | + if($template) |
|
| 29 | + { |
|
| 29 | 30 | $etemplate = new Api\Etemplate('etemplate.et2_test_file_upload'); |
| 30 | 31 | $etemplate->exec('',array()); |
| 31 | 32 | return; |
@@ -30,11 +30,11 @@ discard block |
||
| 30 | 30 | $appname = $_GET['app'] && $GLOBALS['egw_info']['apps'][$_GET['app']] ? $_GET['app'] : Api\Categories::GLOBAL_APPNAME; |
| 31 | 31 | |
| 32 | 32 | $cats = new Api\Categories('', $appname); |
| 33 | -$categories = $cats->return_array('all',0, false, '', 'ASC','',$appname==Api\Categories::GLOBAL_APPNAME); |
|
| 33 | +$categories = $cats->return_array('all', 0, false, '', 'ASC', '', $appname == Api\Categories::GLOBAL_APPNAME); |
|
| 34 | 34 | |
| 35 | 35 | $content = "/* Category CSS for $appname */\n\n"; |
| 36 | 36 | |
| 37 | -foreach($categories as $cat) |
|
| 37 | +foreach ($categories as $cat) |
|
| 38 | 38 | { |
| 39 | 39 | if (!isset($cat['data'])) continue; |
| 40 | 40 | if (!empty($cat['data']['color'])) |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | } |
| 46 | 46 | if (!empty($cat['data']['icon'])) |
| 47 | 47 | { |
| 48 | - $content .= ".cat_{$cat['id']} .cat_icon { background-image: url('". admin_categories::icon_url($cat['data']['icon']) ."');} /*{$cat['name']}*/\n"; |
|
| 48 | + $content .= ".cat_{$cat['id']} .cat_icon { background-image: url('".admin_categories::icon_url($cat['data']['icon'])."');} /*{$cat['name']}*/\n"; |
|
| 49 | 49 | } |
| 50 | 50 | } |
| 51 | 51 | |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | $etag = '"'.md5($content).'"'; |
| 54 | 54 | |
| 55 | 55 | // headers to allow caching, egw_framework specifies etag on url to force reload, even with Expires header |
| 56 | -Api\Session::cache_control(86400); // cache for 1 day |
|
| 56 | +Api\Session::cache_control(86400); // cache for 1 day |
|
| 57 | 57 | Header('Content-Type: text/css; charset=utf-8'); |
| 58 | 58 | Header('ETag: '.$etag); |
| 59 | 59 | |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | // we run our own gzip compression, to set a correct Content-Length of the encoded content |
| 68 | -if (in_array('gzip', explode(',',$_SERVER['HTTP_ACCEPT_ENCODING'])) && function_exists('gzencode')) |
|
| 68 | +if (in_array('gzip', explode(',', $_SERVER['HTTP_ACCEPT_ENCODING'])) && function_exists('gzencode')) |
|
| 69 | 69 | { |
| 70 | 70 | $content = gzencode($content); |
| 71 | 71 | header('Content-Encoding: gzip'); |
@@ -36,7 +36,10 @@ |
||
| 36 | 36 | |
| 37 | 37 | foreach($categories as $cat) |
| 38 | 38 | { |
| 39 | - if (!isset($cat['data'])) continue; |
|
| 39 | + if (!isset($cat['data'])) |
|
| 40 | + { |
|
| 41 | + continue; |
|
| 42 | + } |
|
| 40 | 43 | if (!empty($cat['data']['color'])) |
| 41 | 44 | { |
| 42 | 45 | // Use slightly more specific selector that just class, to allow defaults |
@@ -70,9 +70,9 @@ discard block |
||
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - if (!preg_match('/^[a-z0-9_-]+$/i',$app)) |
|
| 73 | + if (!preg_match('/^[a-z0-9_-]+$/i', $app)) |
|
| 74 | 74 | { |
| 75 | - die('Stop'); // just to prevent someone doing nasty things |
|
| 75 | + die('Stop'); // just to prevent someone doing nasty things |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | return $app; |
@@ -83,8 +83,7 @@ discard block |
||
| 83 | 83 | */ |
| 84 | 84 | function get_maxsize() |
| 85 | 85 | { |
| 86 | - $preset = !($GLOBALS['egw_info']['server']['link_list_thumbnail'] > 0) ? 64 : |
|
| 87 | - $GLOBALS['egw_info']['server']['link_list_thumbnail']; |
|
| 86 | + $preset = !($GLOBALS['egw_info']['server']['link_list_thumbnail'] > 0) ? 64 : $GLOBALS['egw_info']['server']['link_list_thumbnail']; |
|
| 88 | 87 | |
| 89 | 88 | // Another maximum size may be passed if thumbnails are turned on |
| 90 | 89 | if ($preset != 0 && isset($_GET['thsize']) && is_numeric($_GET['thsize'])) |
@@ -150,7 +149,7 @@ discard block |
||
| 150 | 149 | } |
| 151 | 150 | $dst = gen_dstfile($stat && !empty($stat['url']) ? $stat['url'] : $src, $maxsize, $height, $width, $minsize); |
| 152 | 151 | $dst_dir = dirname($dst); |
| 153 | - if(file_exists($dst_dir)) |
|
| 152 | + if (file_exists($dst_dir)) |
|
| 154 | 153 | { |
| 155 | 154 | // Check whether the destination file already exists and is newer than |
| 156 | 155 | // the source file. Assume the file doesn't exist if thumbnailing is turned off. |
@@ -190,7 +189,7 @@ discard block |
||
| 190 | 189 | { |
| 191 | 190 | // Allow client to cache these, makes scrolling in filemanager much nicer |
| 192 | 191 | // setting maximum allow caching time of one year, if url contains (non-empty) moditication time |
| 193 | - Api\Session::cache_control(empty($_GET['mtime']) ? 300 : 31536000, true); // true = private / browser only caching |
|
| 192 | + Api\Session::cache_control(empty($_GET['mtime']) ? 300 : 31536000, true); // true = private / browser only caching |
|
| 194 | 193 | header('Content-Type: '.$output_mime); |
| 195 | 194 | readfile($dst); |
| 196 | 195 | return true; |
@@ -212,7 +211,7 @@ discard block |
||
| 212 | 211 | * @param int $minsize =null |
| 213 | 212 | * @return string |
| 214 | 213 | */ |
| 215 | -function gen_dstfile($src, $maxsize, $height=null, $width=null, $minsize=null) |
|
| 214 | +function gen_dstfile($src, $maxsize, $height = null, $width = null, $minsize = null) |
|
| 216 | 215 | { |
| 217 | 216 | // Use the egroupware file cache to store the thumbnails on a per instance basis |
| 218 | 217 | $cachefile = new Api\Cache\Files(array()); |
@@ -238,7 +237,7 @@ discard block |
||
| 238 | 237 | * TODO: As this is a general purpose function, it might probably be moved |
| 239 | 238 | * to some other php file or an "image utils" class. |
| 240 | 239 | */ |
| 241 | -function get_scaled_image_size($w, $h, $maxw, $maxh, $minw=0, $minh=0) |
|
| 240 | +function get_scaled_image_size($w, $h, $maxw, $maxh, $minw = 0, $minh = 0) |
|
| 242 | 241 | { |
| 243 | 242 | //Scale will contain the factor by which the image has to be scaled down |
| 244 | 243 | $scale = 1.0; |
@@ -299,7 +298,7 @@ discard block |
||
| 299 | 298 | * @param int $maxh the maximum height of the thumbnail |
| 300 | 299 | * @returns boolean|resource false or a gd_image |
| 301 | 300 | */ |
| 302 | -function gd_image_load($file,$maxw,$maxh) |
|
| 301 | +function gd_image_load($file, $maxw, $maxh) |
|
| 303 | 302 | { |
| 304 | 303 | // Get mime type |
| 305 | 304 | list($type, $image_type) = explode('/', $mime = Vfs::mime_content_type($file)); |
@@ -307,9 +306,9 @@ discard block |
||
| 307 | 306 | if (!$type) list($type, $image_type) = explode('/', $mime = Api\MimeMagic::filename2mime($file)); |
| 308 | 307 | |
| 309 | 308 | // Call the according gd constructor depending on the file type |
| 310 | - if($type == 'image') |
|
| 309 | + if ($type == 'image') |
|
| 311 | 310 | { |
| 312 | - if (in_array($image_type, array('tiff','jpeg')) && ($image = exif_thumbnail_load($file))) |
|
| 311 | + if (in_array($image_type, array('tiff', 'jpeg')) && ($image = exif_thumbnail_load($file))) |
|
| 313 | 312 | { |
| 314 | 313 | return $image; |
| 315 | 314 | } |
@@ -332,12 +331,12 @@ discard block |
||
| 332 | 331 | else if ($type == 'application') |
| 333 | 332 | { |
| 334 | 333 | $thumb = false; |
| 335 | - if(strpos($image_type,'vnd.oasis.opendocument.') === 0) |
|
| 334 | + if (strpos($image_type, 'vnd.oasis.opendocument.') === 0) |
|
| 336 | 335 | { |
| 337 | 336 | // OpenDocuments have thumbnails inside already |
| 338 | 337 | $thumb = get_opendocument_thumbnail($file); |
| 339 | 338 | } |
| 340 | - else if($image_type == 'pdf') |
|
| 339 | + else if ($image_type == 'pdf') |
|
| 341 | 340 | { |
| 342 | 341 | $thumb = get_pdf_thumbnail($file); |
| 343 | 342 | } |
@@ -347,7 +346,7 @@ discard block |
||
| 347 | 346 | //$thumb = get_msoffice_thumbnail($file); |
| 348 | 347 | } |
| 349 | 348 | // Mark it with mime type icon |
| 350 | - if($thumb) |
|
| 349 | + if ($thumb) |
|
| 351 | 350 | { |
| 352 | 351 | // Need to scale first, or the mark will be wrong size |
| 353 | 352 | $scaled = get_scaled_image_size(imagesx($thumb), imagesy($thumb), $maxw, $maxh); |
@@ -387,8 +386,8 @@ discard block |
||
| 387 | 386 | |
| 388 | 387 | // Image is already there, but we can't access them directly through VFS |
| 389 | 388 | $ext = $mimetype == 'application/vnd.oasis.opendocument.text' ? '.odt' : '.ods'; |
| 390 | - $archive = tempnam($GLOBALS['egw_info']['server']['temp_dir'], basename($file,$ext).'-'); |
|
| 391 | - copy($file,$archive); |
|
| 389 | + $archive = tempnam($GLOBALS['egw_info']['server']['temp_dir'], basename($file, $ext).'-'); |
|
| 390 | + copy($file, $archive); |
|
| 392 | 391 | |
| 393 | 392 | $thumbnail_url = 'zip://'.$archive.'#Thumbnails/thumbnail.png'; |
| 394 | 393 | $image = imagecreatefromstring(file_get_contents($thumbnail_url)); |
@@ -442,7 +441,7 @@ discard block |
||
| 442 | 441 | */ |
| 443 | 442 | function get_pdf_thumbnail($file) |
| 444 | 443 | { |
| 445 | - if(!pdf_thumbnails_available()) return false; |
|
| 444 | + if (!pdf_thumbnails_available()) return false; |
|
| 446 | 445 | |
| 447 | 446 | // switch off max_excution_time, as some thumbnails take longer and |
| 448 | 447 | // will be startet over and over again, if they dont finish |
@@ -471,7 +470,7 @@ discard block |
||
| 471 | 470 | $target_height = imagesy($target_image); |
| 472 | 471 | |
| 473 | 472 | // Find mime image, if no tag image set |
| 474 | - if(!$tag_image && $mime) |
|
| 473 | + if (!$tag_image && $mime) |
|
| 475 | 474 | { |
| 476 | 475 | list($app, $icon) = explode('/', Vfs::mime_icon($mime), 2); |
| 477 | 476 | list(, $path) = explode($GLOBALS['egw_info']['server']['webserver_url'], |
@@ -482,16 +481,16 @@ discard block |
||
| 482 | 481 | |
| 483 | 482 | // Find correct size - max 1/3 target |
| 484 | 483 | $tag_size = get_scaled_image_size(imagesx($tag_image), imagesy($tag_image), $target_width / 3, $target_height / 3); |
| 485 | - if(!$tag_size) return; |
|
| 486 | - list($tag_width,$tag_height) = $tag_size; |
|
| 484 | + if (!$tag_size) return; |
|
| 485 | + list($tag_width, $tag_height) = $tag_size; |
|
| 487 | 486 | |
| 488 | 487 | // Put it in |
| 489 | - if($mime) |
|
| 488 | + if ($mime) |
|
| 490 | 489 | { |
| 491 | - imagecopyresampled($target_image,$tag_image, |
|
| 490 | + imagecopyresampled($target_image, $tag_image, |
|
| 492 | 491 | $target_width - $tag_width, |
| 493 | 492 | $target_height - $tag_height, |
| 494 | - 0,0, |
|
| 493 | + 0, 0, |
|
| 495 | 494 | $tag_width, |
| 496 | 495 | $tag_height, |
| 497 | 496 | imagesx($tag_image), |
@@ -545,7 +544,7 @@ discard block |
||
| 545 | 544 | function gd_image_thumbnail($file, $maxw, $maxh, $minw, $minh) |
| 546 | 545 | { |
| 547 | 546 | //Load the image |
| 548 | - if (($img_src = gd_image_load($file,$maxw,$maxh)) !== false) |
|
| 547 | + if (($img_src = gd_image_load($file, $maxw, $maxh)) !== false) |
|
| 549 | 548 | { |
| 550 | 549 | //Get the constraints of the image |
| 551 | 550 | $w = imagesx($img_src); |
@@ -575,14 +574,14 @@ discard block |
||
| 575 | 574 | */ |
| 576 | 575 | function gdVersion($user_ver = 0) |
| 577 | 576 | { |
| 578 | - if (! extension_loaded('gd')) { return; } |
|
| 577 | + if (!extension_loaded('gd')) { return; } |
|
| 579 | 578 | static $gd_ver = 0; |
| 580 | 579 | |
| 581 | 580 | // Just accept the specified setting if it's 1. |
| 582 | 581 | if ($user_ver == 1) { $gd_ver = 1; return 1; } |
| 583 | 582 | |
| 584 | 583 | // Use the static variable if function was called previously. |
| 585 | - if ($user_ver !=2 && $gd_ver > 0 ) { return $gd_ver; } |
|
| 584 | + if ($user_ver != 2 && $gd_ver > 0) { return $gd_ver; } |
|
| 586 | 585 | |
| 587 | 586 | // Use the gd_info() function if possible. |
| 588 | 587 | if (function_exists('gd_info')) { |
@@ -244,10 +244,13 @@ discard block |
||
| 244 | 244 | $scale = 1.0; |
| 245 | 245 | |
| 246 | 246 | //Select the constraining dimension |
| 247 | - if ($w > $h) // landscape image: constraining factor $minh or $maxw |
|
| 247 | + if ($w > $h) |
|
| 248 | + { |
|
| 249 | + // landscape image: constraining factor $minh or $maxw |
|
| 248 | 250 | { |
| 249 | 251 | $scale = $minh ? $minh / $h : $maxw / $w; |
| 250 | 252 | } |
| 253 | + } |
|
| 251 | 254 | else // portrail image: constraining factor $minw or $maxh |
| 252 | 255 | { |
| 253 | 256 | $scale = $minw ? $minw / $w : $maxh / $h; |
@@ -304,7 +307,10 @@ discard block |
||
| 304 | 307 | // Get mime type |
| 305 | 308 | list($type, $image_type) = explode('/', $mime = Vfs::mime_content_type($file)); |
| 306 | 309 | // if $file is not from vfs, use Api\MimeMagic::filename2mime to get mime-type from extension |
| 307 | - if (!$type) list($type, $image_type) = explode('/', $mime = Api\MimeMagic::filename2mime($file)); |
|
| 310 | + if (!$type) |
|
| 311 | + { |
|
| 312 | + list($type, $image_type) = explode('/', $mime = Api\MimeMagic::filename2mime($file)); |
|
| 313 | + } |
|
| 308 | 314 | |
| 309 | 315 | // Call the according gd constructor depending on the file type |
| 310 | 316 | if($type == 'image') |
@@ -442,7 +448,10 @@ discard block |
||
| 442 | 448 | */ |
| 443 | 449 | function get_pdf_thumbnail($file) |
| 444 | 450 | { |
| 445 | - if(!pdf_thumbnails_available()) return false; |
|
| 451 | + if(!pdf_thumbnails_available()) |
|
| 452 | + { |
|
| 453 | + return false; |
|
| 454 | + } |
|
| 446 | 455 | |
| 447 | 456 | // switch off max_excution_time, as some thumbnails take longer and |
| 448 | 457 | // will be startet over and over again, if they dont finish |
@@ -482,7 +491,10 @@ discard block |
||
| 482 | 491 | |
| 483 | 492 | // Find correct size - max 1/3 target |
| 484 | 493 | $tag_size = get_scaled_image_size(imagesx($tag_image), imagesy($tag_image), $target_width / 3, $target_height / 3); |
| 485 | - if(!$tag_size) return; |
|
| 494 | + if(!$tag_size) |
|
| 495 | + { |
|
| 496 | + return; |
|
| 497 | + } |
|
| 486 | 498 | list($tag_width,$tag_height) = $tag_size; |
| 487 | 499 | |
| 488 | 500 | // Put it in |
@@ -575,17 +587,24 @@ discard block |
||
| 575 | 587 | */ |
| 576 | 588 | function gdVersion($user_ver = 0) |
| 577 | 589 | { |
| 578 | - if (! extension_loaded('gd')) { return; } |
|
| 590 | + if (! extension_loaded('gd')) |
|
| 591 | + { |
|
| 592 | +return; } |
|
| 579 | 593 | static $gd_ver = 0; |
| 580 | 594 | |
| 581 | 595 | // Just accept the specified setting if it's 1. |
| 582 | - if ($user_ver == 1) { $gd_ver = 1; return 1; } |
|
| 596 | + if ($user_ver == 1) |
|
| 597 | + { |
|
| 598 | +$gd_ver = 1; return 1; } |
|
| 583 | 599 | |
| 584 | 600 | // Use the static variable if function was called previously. |
| 585 | - if ($user_ver !=2 && $gd_ver > 0 ) { return $gd_ver; } |
|
| 601 | + if ($user_ver !=2 && $gd_ver > 0 ) |
|
| 602 | + { |
|
| 603 | +return $gd_ver; } |
|
| 586 | 604 | |
| 587 | 605 | // Use the gd_info() function if possible. |
| 588 | - if (function_exists('gd_info')) { |
|
| 606 | + if (function_exists('gd_info')) |
|
| 607 | + { |
|
| 589 | 608 | $ver_info = gd_info(); |
| 590 | 609 | $match = null; |
| 591 | 610 | preg_match('/\d/', $ver_info['GD Version'], $match); |
@@ -594,11 +613,15 @@ discard block |
||
| 594 | 613 | } |
| 595 | 614 | |
| 596 | 615 | // If phpinfo() is disabled use a specified / fail-safe choice... |
| 597 | - if (preg_match('/phpinfo/', ini_get('disable_functions'))) { |
|
| 598 | - if ($user_ver == 2) { |
|
| 616 | + if (preg_match('/phpinfo/', ini_get('disable_functions'))) |
|
| 617 | + { |
|
| 618 | + if ($user_ver == 2) |
|
| 619 | + { |
|
| 599 | 620 | $gd_ver = 2; |
| 600 | 621 | return 2; |
| 601 | - } else { |
|
| 622 | + } |
|
| 623 | + else |
|
| 624 | + { |
|
| 602 | 625 | $gd_ver = 1; |
| 603 | 626 | return 1; |
| 604 | 627 | } |
@@ -607,6 +630,9 @@ discard block |
||
| 607 | 630 | ob_start(); |
| 608 | 631 | phpinfo(8); |
| 609 | 632 | $info = stristr(ob_get_clean(), 'gd version'); |
| 610 | - if (preg_match('/\d/', $info, $match)) $gd_ver = $match[0]; |
|
| 633 | + if (preg_match('/\d/', $info, $match)) |
|
| 634 | + { |
|
| 635 | + $gd_ver = $match[0]; |
|
| 636 | + } |
|
| 611 | 637 | return $match[0]; |
| 612 | 638 | } |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | $etag = '"'.md5($preferences.$ab_preferences.$user).'"'; |
| 34 | 34 | |
| 35 | 35 | // headers to allow caching, egw_framework specifies etag on url to force reload, even with Expires header |
| 36 | -Api\Session::cache_control(86400); // cache for 1 day |
|
| 36 | +Api\Session::cache_control(86400); // cache for 1 day |
|
| 37 | 37 | Header('Content-Type: text/javascript; charset=utf-8'); |
| 38 | 38 | Header('ETag: '.$etag); |
| 39 | 39 | |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | $content .= 'egw.set_user('.$user.", egw && egw.window !== window);\n"; |
| 50 | 50 | |
| 51 | 51 | // we run our own gzip compression, to set a correct Content-Length of the encoded content |
| 52 | -if (in_array('gzip', explode(',',$_SERVER['HTTP_ACCEPT_ENCODING'])) && function_exists('gzencode')) |
|
| 52 | +if (in_array('gzip', explode(',', $_SERVER['HTTP_ACCEPT_ENCODING'])) && function_exists('gzencode')) |
|
| 53 | 53 | { |
| 54 | 54 | $content = gzencode($content); |
| 55 | 55 | header('Content-Encoding: gzip'); |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | * @param string $config_passwd=null pw of above user |
| 24 | 24 | * @param boolean $verbose=false if true, echos out some status information during the run |
| 25 | 25 | */ |
| 26 | - function __construct($domain,$config_user=null,$config_passwd=null) |
|
| 26 | + function __construct($domain, $config_user = null, $config_passwd = null) |
|
| 27 | 27 | { |
| 28 | 28 | if (!is_array($domain)) |
| 29 | 29 | { |
@@ -45,17 +45,17 @@ discard block |
||
| 45 | 45 | * @throws Exception(lang('Wrong credentials to access the header.inc.php file!'),2); |
| 46 | 46 | * @throws Exception('header.inc.php not found!'); |
| 47 | 47 | */ |
| 48 | - protected function exec($check_only=false) |
|
| 48 | + protected function exec($check_only = false) |
|
| 49 | 49 | { |
| 50 | - if ($check_only) return true; // nothing to check, no arguments ... |
|
| 50 | + if ($check_only) return true; // nothing to check, no arguments ... |
|
| 51 | 51 | |
| 52 | 52 | // instanciate setup object and check authorisation |
| 53 | - $this->check_setup_auth($this->config_user,$this->config_passwd,$this->domain); |
|
| 53 | + $this->check_setup_auth($this->config_user, $this->config_passwd, $this->domain); |
|
| 54 | 54 | |
| 55 | - $this->check_installed($this->domain,15,$this->verbose); |
|
| 55 | + $this->check_installed($this->domain, 15, $this->verbose); |
|
| 56 | 56 | |
| 57 | 57 | global $setup_info; |
| 58 | - foreach($setup_info as $appname => $info) |
|
| 58 | + foreach ($setup_info as $appname => $info) |
|
| 59 | 59 | { |
| 60 | 60 | if ($info['currentver']) self::$egw_setup->register_hooks($appname); |
| 61 | 61 | } |
@@ -47,7 +47,11 @@ discard block |
||
| 47 | 47 | */ |
| 48 | 48 | protected function exec($check_only=false) |
| 49 | 49 | { |
| 50 | - if ($check_only) return true; // nothing to check, no arguments ... |
|
| 50 | + if ($check_only) |
|
| 51 | + { |
|
| 52 | + return true; |
|
| 53 | + } |
|
| 54 | + // nothing to check, no arguments ... |
|
| 51 | 55 | |
| 52 | 56 | // instanciate setup object and check authorisation |
| 53 | 57 | $this->check_setup_auth($this->config_user,$this->config_passwd,$this->domain); |
@@ -57,7 +61,10 @@ discard block |
||
| 57 | 61 | global $setup_info; |
| 58 | 62 | foreach($setup_info as $appname => $info) |
| 59 | 63 | { |
| 60 | - if ($info['currentver']) self::$egw_setup->register_hooks($appname); |
|
| 64 | + if ($info['currentver']) |
|
| 65 | + { |
|
| 66 | + self::$egw_setup->register_hooks($appname); |
|
| 67 | + } |
|
| 61 | 68 | } |
| 62 | 69 | $this->restore_db(); |
| 63 | 70 | |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * false: the complete header vars, plus install_id and webserver_url from the config table, |
| 33 | 33 | * null: only the header vars |
| 34 | 34 | */ |
| 35 | - function __construct($data=true,$header_admin_user=null,$header_admin_password=null) |
|
| 35 | + function __construct($data = true, $header_admin_user = null, $header_admin_password = null) |
|
| 36 | 36 | { |
| 37 | 37 | if (!is_array($data)) |
| 38 | 38 | { |
@@ -54,16 +54,16 @@ discard block |
||
| 54 | 54 | * @throws Exception(lang('Wrong credentials to access the header.inc.php file!'),2); |
| 55 | 55 | * @throws Exception('header.inc.php not found!'); |
| 56 | 56 | */ |
| 57 | - function exec($check_only=false) |
|
| 57 | + function exec($check_only = false) |
|
| 58 | 58 | { |
| 59 | - if ($this->remote_id && $check_only) return true; // cant check for the remote site locally! |
|
| 59 | + if ($this->remote_id && $check_only) return true; // cant check for the remote site locally! |
|
| 60 | 60 | |
| 61 | 61 | $this->_check_header_access(); |
| 62 | 62 | |
| 63 | 63 | if ($check_only) return true; |
| 64 | 64 | |
| 65 | 65 | $egw_info_backup = $GLOBALS['egw_info']; |
| 66 | - $GLOBALS['egw_info'] = array ( |
|
| 66 | + $GLOBALS['egw_info'] = array( |
|
| 67 | 67 | 'flags' => array( |
| 68 | 68 | 'noapi' => true, |
| 69 | 69 | ), |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | { |
| 73 | 73 | throw new Exception('header.inc.php not found!'); |
| 74 | 74 | } |
| 75 | - eval(str_replace(array('<?php','perfgetmicrotime'),array('','perfgetmicrotime2'),$header)); |
|
| 75 | + eval(str_replace(array('<?php', 'perfgetmicrotime'), array('', 'perfgetmicrotime2'), $header)); |
|
| 76 | 76 | |
| 77 | 77 | // unset the flags, they are not part of the header |
| 78 | 78 | unset($GLOBALS['egw_info']['flags']); |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | $GLOBALS['egw_info']['server']['versions']['phpgwapi'] = $egw_info_backup['server']['versions']['phpgwapi']; |
| 82 | 82 | |
| 83 | 83 | // fetching the install id's stored in the database |
| 84 | - foreach($GLOBALS['egw_domain'] as &$data) |
|
| 84 | + foreach ($GLOBALS['egw_domain'] as &$data) |
|
| 85 | 85 | { |
| 86 | 86 | if (!is_null($this->hash_only)) |
| 87 | 87 | { |
@@ -89,9 +89,9 @@ discard block |
||
| 89 | 89 | } |
| 90 | 90 | try { |
| 91 | 91 | // it's saver to only send the remote_hash and not install_id and config_pw |
| 92 | - $data['remote_hash'] = admin_cmd::remote_hash($data['install_id'],$data['config_passwd']); |
|
| 92 | + $data['remote_hash'] = admin_cmd::remote_hash($data['install_id'], $data['config_passwd']); |
|
| 93 | 93 | } |
| 94 | - catch(Exception $e) { |
|
| 94 | + catch (Exception $e) { |
|
| 95 | 95 | if ($data['install_id']) $data['error'] .= $e->getMessage(); |
| 96 | 96 | } |
| 97 | 97 | if ($this->hash_only) |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | 'remote_hash' => $data['remote_hash'], |
| 101 | 101 | 'webserver_url' => $data['webserver_url'], |
| 102 | 102 | 'install_id' => $data['install_id'], |
| 103 | - )+($data['error'] ? array( |
|
| 103 | + ) + ($data['error'] ? array( |
|
| 104 | 104 | 'error' => $data['error'], |
| 105 | 105 | ) : array()); |
| 106 | 106 | } |
@@ -133,17 +133,17 @@ discard block |
||
| 133 | 133 | { |
| 134 | 134 | $db = new Api\Db(); |
| 135 | 135 | |
| 136 | - ob_start(); // not available db connection echos a lot grab ;-) |
|
| 136 | + ob_start(); // not available db connection echos a lot grab ;-) |
|
| 137 | 137 | $err_rep = error_reporting(0); |
| 138 | 138 | |
| 139 | 139 | $config = array(); |
| 140 | 140 | try { |
| 141 | - $db->connect($data['db_name'],$data['db_host'],$data['db_port'],$data['db_user'],$data['db_pass'],$data['db_type']); |
|
| 141 | + $db->connect($data['db_name'], $data['db_host'], $data['db_port'], $data['db_user'], $data['db_pass'], $data['db_type']); |
|
| 142 | 142 | $db->set_app('phpgwapi'); |
| 143 | - $db->select('egw_config','config_name,config_value',array( |
|
| 144 | - 'config_name'=>array('install_id','webserver_url','account_repository','allow_remote_admin','mail_suffix'), |
|
| 143 | + $db->select('egw_config', 'config_name,config_value', array( |
|
| 144 | + 'config_name'=>array('install_id', 'webserver_url', 'account_repository', 'allow_remote_admin', 'mail_suffix'), |
|
| 145 | 145 | 'config_app'=>'phpgwapi', |
| 146 | - ),__LINE__,__FILE__); |
|
| 146 | + ), __LINE__, __FILE__); |
|
| 147 | 147 | while (($row = $db->row(true))) |
| 148 | 148 | { |
| 149 | 149 | $config[$row['config_name']] = $row['config_value']; |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | * @param boolean $set_modifier =true set the current user as modifier or 0 (= run by the system) |
| 168 | 168 | * @return boolean true on success, false otherwise |
| 169 | 169 | */ |
| 170 | - function save($set_modifier=true) |
|
| 170 | + function save($set_modifier = true) |
|
| 171 | 171 | { |
| 172 | 172 | if ($this->remote_id) |
| 173 | 173 | { |
@@ -56,11 +56,18 @@ discard block |
||
| 56 | 56 | */ |
| 57 | 57 | function exec($check_only=false) |
| 58 | 58 | { |
| 59 | - if ($this->remote_id && $check_only) return true; // cant check for the remote site locally! |
|
| 59 | + if ($this->remote_id && $check_only) |
|
| 60 | + { |
|
| 61 | + return true; |
|
| 62 | + } |
|
| 63 | + // cant check for the remote site locally! |
|
| 60 | 64 | |
| 61 | 65 | $this->_check_header_access(); |
| 62 | 66 | |
| 63 | - if ($check_only) return true; |
|
| 67 | + if ($check_only) |
|
| 68 | + { |
|
| 69 | + return true; |
|
| 70 | + } |
|
| 64 | 71 | |
| 65 | 72 | $egw_info_backup = $GLOBALS['egw_info']; |
| 66 | 73 | $GLOBALS['egw_info'] = array ( |
@@ -92,7 +99,10 @@ discard block |
||
| 92 | 99 | $data['remote_hash'] = admin_cmd::remote_hash($data['install_id'],$data['config_passwd']); |
| 93 | 100 | } |
| 94 | 101 | catch(Exception $e) { |
| 95 | - if ($data['install_id']) $data['error'] .= $e->getMessage(); |
|
| 102 | + if ($data['install_id']) |
|
| 103 | + { |
|
| 104 | + $data['error'] .= $e->getMessage(); |
|
| 105 | + } |
|
| 96 | 106 | } |
| 97 | 107 | if ($this->hash_only) |
| 98 | 108 | { |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | * @param boolean $verbose =false if true, echos out some status information during the run |
| 31 | 31 | * @param string $app =null single application to update or install |
| 32 | 32 | */ |
| 33 | - function __construct($domain,$config_user=null,$config_passwd=null,$backup=null,$verbose=false,$app=null) |
|
| 33 | + function __construct($domain, $config_user = null, $config_passwd = null, $backup = null, $verbose = false, $app = null) |
|
| 34 | 34 | { |
| 35 | 35 | if (!is_array($domain)) |
| 36 | 36 | { |
@@ -55,32 +55,32 @@ discard block |
||
| 55 | 55 | * @throws Exception(lang('Wrong credentials to access the header.inc.php file!'),2); |
| 56 | 56 | * @throws Exception('header.inc.php not found!'); |
| 57 | 57 | */ |
| 58 | - protected function exec($check_only=false) |
|
| 58 | + protected function exec($check_only = false) |
|
| 59 | 59 | { |
| 60 | 60 | global $setup_info; |
| 61 | 61 | |
| 62 | 62 | // instanciate setup object and check authorisation |
| 63 | - $this->check_setup_auth($this->config_user,$this->config_passwd,$this->domain); |
|
| 63 | + $this->check_setup_auth($this->config_user, $this->config_passwd, $this->domain); |
|
| 64 | 64 | |
| 65 | - $this->check_installed($this->domain,array(14),$this->verbose); |
|
| 65 | + $this->check_installed($this->domain, array(14), $this->verbose); |
|
| 66 | 66 | |
| 67 | 67 | if ($GLOBALS['egw_info']['setup']['stage']['db'] != 4 && |
| 68 | 68 | (!$this->app || !in_array($this->app, self::$apps_to_install) && !in_array($this->app, self::$apps_to_upgrade)) && |
| 69 | 69 | !self::check_autoinstall()) |
| 70 | 70 | { |
| 71 | - return lang('No update necessary, domain %1(%2) is up to date.',$this->domain,$GLOBALS['egw_domain'][$this->domain]['db_type']); |
|
| 71 | + return lang('No update necessary, domain %1(%2) is up to date.', $this->domain, $GLOBALS['egw_domain'][$this->domain]['db_type']); |
|
| 72 | 72 | } |
| 73 | 73 | if ($check_only) return lang('Update necessary.'); |
| 74 | 74 | |
| 75 | 75 | $setup_info = self::$egw_setup->detection->upgrade_exclude($setup_info); |
| 76 | 76 | |
| 77 | - self::$egw_setup->process->init_process(); // we need a new schema-proc instance for each new domain |
|
| 77 | + self::$egw_setup->process->init_process(); // we need a new schema-proc instance for each new domain |
|
| 78 | 78 | |
| 79 | 79 | // request to install a single app |
| 80 | 80 | if ($this->app && in_array($this->app, self::$apps_to_install)) |
| 81 | 81 | { |
| 82 | 82 | $app_title = $setup_info[$this->app]['title'] ? $setup_info[$this->app]['title'] : $setup_info[$this->app]['name']; |
| 83 | - self::_echo_message($this->verbose,lang('Start installing application %1 ...',$app_title)); |
|
| 83 | + self::_echo_message($this->verbose, lang('Start installing application %1 ...', $app_title)); |
|
| 84 | 84 | ob_start(); |
| 85 | 85 | $terror = array($this->app => $setup_info[$this->app]); |
| 86 | 86 | |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | { |
| 89 | 89 | $errors = self::$egw_setup->process->current($terror, $this->verbose); |
| 90 | 90 | $terror = self::$egw_setup->process->default_records($errors, $this->verbose); |
| 91 | - echo $app_title . ' ' . lang('tables installed, unless there are errors printed above') . '.'; |
|
| 91 | + echo $app_title.' '.lang('tables installed, unless there are errors printed above').'.'; |
|
| 92 | 92 | } |
| 93 | 93 | else |
| 94 | 94 | { |
@@ -102,20 +102,20 @@ discard block |
||
| 102 | 102 | { |
| 103 | 103 | self::$egw_setup->register_app($setup_info[$this->app]['name']); |
| 104 | 104 | } |
| 105 | - echo $app_title . ' ' . lang('registered') . '.'; |
|
| 105 | + echo $app_title.' '.lang('registered').'.'; |
|
| 106 | 106 | |
| 107 | 107 | if ($setup_info[$this->app]['hooks']) |
| 108 | 108 | { |
| 109 | 109 | self::$egw_setup->register_hooks($setup_info[$this->app]['name']); |
| 110 | - echo "\n".$app_title . ' ' . lang('hooks registered') . '.'; |
|
| 110 | + echo "\n".$app_title.' '.lang('hooks registered').'.'; |
|
| 111 | 111 | } |
| 112 | 112 | } |
| 113 | 113 | } |
| 114 | 114 | else |
| 115 | 115 | { |
| 116 | - self::_echo_message($this->verbose,lang('Start updating the database ...')); |
|
| 116 | + self::_echo_message($this->verbose, lang('Start updating the database ...')); |
|
| 117 | 117 | ob_start(); |
| 118 | - self::$egw_setup->process->pass($setup_info,'upgrade',false); |
|
| 118 | + self::$egw_setup->process->pass($setup_info, 'upgrade', false); |
|
| 119 | 119 | } |
| 120 | 120 | $messages = ob_get_contents(); |
| 121 | 121 | ob_end_clean(); |
@@ -70,7 +70,10 @@ discard block |
||
| 70 | 70 | { |
| 71 | 71 | return lang('No update necessary, domain %1(%2) is up to date.',$this->domain,$GLOBALS['egw_domain'][$this->domain]['db_type']); |
| 72 | 72 | } |
| 73 | - if ($check_only) return lang('Update necessary.'); |
|
| 73 | + if ($check_only) |
|
| 74 | + { |
|
| 75 | + return lang('Update necessary.'); |
|
| 76 | + } |
|
| 74 | 77 | |
| 75 | 78 | $setup_info = self::$egw_setup->detection->upgrade_exclude($setup_info); |
| 76 | 79 | |
@@ -119,7 +122,10 @@ discard block |
||
| 119 | 122 | } |
| 120 | 123 | $messages = ob_get_contents(); |
| 121 | 124 | ob_end_clean(); |
| 122 | - if ($messages && $this->verbose) echo strip_tags($messages)."\n"; |
|
| 125 | + if ($messages && $this->verbose) |
|
| 126 | + { |
|
| 127 | + echo strip_tags($messages)."\n"; |
|
| 128 | + } |
|
| 123 | 129 | |
| 124 | 130 | $this->restore_db(); |
| 125 | 131 | |
@@ -38,8 +38,8 @@ discard block |
||
| 38 | 38 | * @param array $config =array() extra config for the account object: account_repository, ldap_* |
| 39 | 39 | * @param string $lang ='en' |
| 40 | 40 | */ |
| 41 | - function __construct($domain,$config_user=null,$config_passwd=null,$admin_user=null,$admin_password=null, |
|
| 42 | - $admin_firstname=null,$admin_lastname=null,$admin_email=null,array $config=array(),$lang='en') |
|
| 41 | + function __construct($domain, $config_user = null, $config_passwd = null, $admin_user = null, $admin_password = null, |
|
| 42 | + $admin_firstname = null, $admin_lastname = null, $admin_email = null, array $config = array(), $lang = 'en') |
|
| 43 | 43 | { |
| 44 | 44 | if (!is_array($domain)) |
| 45 | 45 | { |
@@ -68,21 +68,21 @@ discard block |
||
| 68 | 68 | * @throws Exception(lang('Wrong credentials to access the header.inc.php file!'),2); |
| 69 | 69 | * @throws Exception('header.inc.php not found!'); |
| 70 | 70 | */ |
| 71 | - protected function exec($check_only=false) |
|
| 71 | + protected function exec($check_only = false) |
|
| 72 | 72 | { |
| 73 | 73 | if ($check_only && $this->remote_id) |
| 74 | 74 | { |
| 75 | - return true; // can only check locally |
|
| 75 | + return true; // can only check locally |
|
| 76 | 76 | } |
| 77 | - $this->check_installed($this->domain,15); |
|
| 77 | + $this->check_installed($this->domain, 15); |
|
| 78 | 78 | |
| 79 | 79 | if (!$this->admin_firstname) $this->set_defaults['admin_firstname'] = $this->admin_firstname = lang('Admin'); |
| 80 | 80 | if (!$this->admin_lastname) $this->set_defaults['admin_lastname'] = $this->admin_lastname = lang('User'); |
| 81 | - if (strpos($this->admin_email,'$') !== false) |
|
| 81 | + if (strpos($this->admin_email, '$') !== false) |
|
| 82 | 82 | { |
| 83 | 83 | $this->set_defaults['email'] = $this->admin_email = str_replace( |
| 84 | - array('$domain','$uid','$account_lid'), |
|
| 85 | - array($this->domain,$this->admin_user,$this->admin_user),$this->admin_email); |
|
| 84 | + array('$domain', '$uid', '$account_lid'), |
|
| 85 | + array($this->domain, $this->admin_user, $this->admin_user), $this->admin_email); |
|
| 86 | 86 | } |
| 87 | 87 | $_POST['username'] = $this->admin_user; |
| 88 | 88 | $_POST['passwd2'] = $_POST['passwd'] = $this->admin_password; |
@@ -99,9 +99,9 @@ discard block |
||
| 99 | 99 | switch ($error) |
| 100 | 100 | { |
| 101 | 101 | case 41: |
| 102 | - throw new Api\Exception\WrongUserinput(lang('Error in admin-creation !!!'),41); |
|
| 102 | + throw new Api\Exception\WrongUserinput(lang('Error in admin-creation !!!'), 41); |
|
| 103 | 103 | case 42: |
| 104 | - throw new Api\Exception\WrongUserinput(lang('Error in group-creation !!!'),42); |
|
| 104 | + throw new Api\Exception\WrongUserinput(lang('Error in group-creation !!!'), 42); |
|
| 105 | 105 | } |
| 106 | 106 | $this->restore_db(); |
| 107 | 107 | |
@@ -112,13 +112,13 @@ discard block |
||
| 112 | 112 | if (php_sapi_name() !== 'cli' || !file_exists(EGW_SERVER_ROOT.'/stylite') || file_exists(EGW_SERVER_ROOT.'/managementserver')) |
| 113 | 113 | { |
| 114 | 114 | $output = $ret = null; |
| 115 | - exec($cmd,$output,$ret); |
|
| 115 | + exec($cmd, $output, $ret); |
|
| 116 | 116 | } |
| 117 | - $output = implode("\n",$output); |
|
| 117 | + $output = implode("\n", $output); |
|
| 118 | 118 | //echo "ret=$ret\n".$output; |
| 119 | 119 | if ($ret) |
| 120 | 120 | { |
| 121 | - throw new Api\Exception ($output,$ret); |
|
| 121 | + throw new Api\Exception($output, $ret); |
|
| 122 | 122 | } |
| 123 | 123 | return lang('Admin account successful created.'); |
| 124 | 124 | } |
@@ -76,8 +76,14 @@ |
||
| 76 | 76 | } |
| 77 | 77 | $this->check_installed($this->domain,15); |
| 78 | 78 | |
| 79 | - if (!$this->admin_firstname) $this->set_defaults['admin_firstname'] = $this->admin_firstname = lang('Admin'); |
|
| 80 | - if (!$this->admin_lastname) $this->set_defaults['admin_lastname'] = $this->admin_lastname = lang('User'); |
|
| 79 | + if (!$this->admin_firstname) |
|
| 80 | + { |
|
| 81 | + $this->set_defaults['admin_firstname'] = $this->admin_firstname = lang('Admin'); |
|
| 82 | + } |
|
| 83 | + if (!$this->admin_lastname) |
|
| 84 | + { |
|
| 85 | + $this->set_defaults['admin_lastname'] = $this->admin_lastname = lang('User'); |
|
| 86 | + } |
|
| 81 | 87 | if (strpos($this->admin_email,'$') !== false) |
| 82 | 88 | { |
| 83 | 89 | $this->set_defaults['email'] = $this->admin_email = str_replace( |