Skip to content

Commit 4d97933

Browse files
committed
Merge branch 'bugfix' into stable-v0.5
2 parents d0c8b8d + 1b74f7d commit 4d97933

File tree

23 files changed

+636
-522
lines changed

23 files changed

+636
-522
lines changed

data/media/.htaccess

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
Allow from all
22
Options -Indexes
3+
4+
<Files *.php>
5+
Order Deny,Allow
6+
Deny from all
7+
</Files>

edit_part_info.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565

6666
// section: part attributes
6767
$part_id = isset($_REQUEST['pid']) ? (integer)$_REQUEST['pid'] : -1;
68-
$new_name = isset($_POST['name']) ? (string)$_POST['name'] : '';
68+
$new_name = isset($_REQUEST['name']) ? (string)$_REQUEST['name'] : '';
6969
$new_description = isset($_POST['description']) ? (string)$_POST['description'] : '';
7070
$new_manufacturer_id = isset($_POST['manufacturer_id']) ? (integer)$_POST['manufacturer_id'] : 0;
7171
$new_instock = isset($_POST['instock']) ? (integer)$_POST['instock'] : 0;
@@ -91,7 +91,7 @@
9191
$new_is_master_picture = isset($_POST['is_master_picture']);
9292
$attachement_id = isset($_POST['attachement_id']) ? (integer)$_POST['attachement_id'] : 0;
9393
$new_attachement_type_id = isset($_POST['attachement_type_id']) ? (integer)$_POST['attachement_type_id'] : 0;
94-
$new_name = isset($_POST['name']) ? (string)$_POST['name'] : '';
94+
$new_name = isset($_REQUEST['name']) ? (string)$_REQUEST['name'] : '';
9595
$new_filename = isset($_POST['attachement_filename']) ? toUnixPath(trim((string)$_POST['attachement_filename'])) : '';
9696
$download_file = isset($_POST['download_file']);
9797

@@ -287,6 +287,8 @@
287287
global $config;
288288
if ($config['edit_parts']['created_go_to_info'] xor $rightclicked) {
289289
$html->redirect("show_part_info.php?pid=" . $part->getID(), true);
290+
} else {
291+
$html->redirect("edit_part_info.php?pid=" . $part->getID(), true);
290292
}
291293
} else {
292294
$partname_hint = $category->getPartnameHint(true, false);
@@ -325,9 +327,9 @@
325327
$messages[] = array('html' => generateInputHidden("comment", $new_comment), 'no_linebreak' => 'true');
326328
$messages[] = array('html' => generateInputHidden("visible", $new_visible), 'no_linebreak' => 'true');
327329

328-
329330
$partname_invalid = true;
330331
}
332+
331333
} catch (Exception $e) {
332334
$messages[] = array('text' => nl2br($e->getMessage()), 'strong' => true, 'color' => 'red');
333335
}

inc/config_defaults.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@
271271
$config['table']['noprice_parts']['columns'] = 'hover_picture;name;description;instock_mininstock;footprint;storelocation;suppliers;supplier_partnrs;button_edit';
272272
$config['table']['unknown_instock_parts']['columns'] = 'hover_picture;name;description;mininstock;footprint;storelocation;suppliers;supplier_partnrs;button_edit';
273273
$config['table']['order_parts']['columns'] = 'hover_picture;name_description;instock_mininstock;footprint;storelocation;suppliers_radiobuttons;supplier_partnrs;single_prices;total_prices;order_quantity_edit;order_options';
274-
$config['table']['searched_device_parts']['columns'] = 'hover_picture;quantity_edit;mountnames_edit;name;description;category;footprint;storelocation;manufacturer';
274+
$config['table']['searched_device_parts']['columns'] = 'hover_picture;quantity_edit;mountnames_edit;name;description;instock_mininstock;category;footprint;storelocation';
275275
$config['table']['device_parts']['columns'] = 'hover_picture;name_description;quantity_edit;mountnames_edit;footprint;instock;storelocation;suppliers;supplier_partnrs;single_prices;total_prices';
276276
$config['table']['imported_parts']['columns'] = 'hover_picture;name;description;instock_mininstock;footprint;storelocation;suppliers;supplier_partnrs;single_prices;datasheets;attachements';
277277
$config['table']['location_parts']['columns'] = 'hover_picture;name;description;category;instock;mininstock;footprint;storelocation;datasheets;attachements;button_decrement;button_increment;button_edit';

inc/lib.php

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,13 @@ function uploadFile($file_array, $destination_directory, $destination_filename =
270270
throw new Exception(_('Ungültiges Array übergeben!'));
271271
}
272272

273+
//Dont allow to upload a PHP file.
274+
if(strpos($file_array['name'], ".php") != false
275+
|| strpos($destination_filename, ".php") != false)
276+
{
277+
throw new \Exception(_("Es ist nicht erlaubt PHP Dateien hochzuladen!"));
278+
}
279+
273280
if ($destination_filename == null) {
274281
$destination_filename = $file_array['name'];
275282
}
@@ -561,6 +568,11 @@ function downloadFile($url, $path, $filename = "", $download_override = false)
561568
$filename = basename($parts['path']);
562569
}
563570

571+
//Dont allow to upload a PHP file.
572+
if(strpos($filename, ".php") != false) {
573+
throw new \Exception(_("Es ist nicht erlaubt PHP Dateien herunterzuladen!"));
574+
}
575+
564576
set_time_limit(30);
565577

566578
createPath($path);
@@ -1353,13 +1365,18 @@ function formatTimestamp($timestamp)
13531365
}
13541366
}
13551367

1356-
function generatePagination($page_link, $selected_page, $limit, $max_entries)
1368+
function generatePagination($page_link, $selected_page, $limit, $max_entries, $get_params = null)
13571369
{
13581370
$links = array();
13591371

1372+
$get_string = "";
1373+
if(!empty($get_params)) {
1374+
$get_string = '&' . http_build_query($get_params);
1375+
}
1376+
13601377
//Back to first page
13611378
$links[] = array("label" => '<i class="fa fa-angle-double-left" aria-hidden="true"></i>',
1362-
"href" => $page_link . "&page=1&limit=$limit",
1379+
"href" => $page_link . "&page=1&limit=$limit" . $get_string,
13631380
"disabled" => $selected_page == 1,
13641381
"hint" => _("Springe zur ersten Seite"));
13651382

@@ -1376,24 +1393,31 @@ function generatePagination($page_link, $selected_page, $limit, $max_entries)
13761393

13771394
for ($n=$min_number; $n <= $max_number; $n++) {
13781395
$links[] = array("label" => $n,
1379-
"href" => $page_link . "&page=" . ($n). "&limit=$limit",
1396+
"href" => $page_link . "&page=" . ($n). "&limit=$limit" . $get_string,
13801397
"active" => $n == $selected_page);
13811398
}
13821399

13831400
//Jump to last page.
13841401
$links[] = array("label" => '<i class="fa fa-angle-double-right" aria-hidden="true"></i>',
1385-
"href" => $page_link . "&page=$max_page&limit=$limit",
1402+
"href" => $page_link . "&page=$max_page&limit=$limit" . $get_string,
13861403
"disabled" => $selected_page == $max_page,
13871404
"hint" => _("Springe zur letzten Seite"));
13881405

13891406
//Show all results
13901407
$links[] = array("label" => '<i class="fa fa-bars" aria-hidden="true"></i>',
1391-
"href" => $page_link . "&page=0",
1408+
"href" => $page_link . "&page=0" . $get_string,
13921409
"active" => $selected_page == 0,
1393-
"hint" => _("Zeige alle Bauteile"));
1410+
"hint" => _("Alle anzeigen"));
1411+
1412+
$upper_results = ($selected_page * $limit + 1) <= $max_entries && $selected_page > 0 ? $selected_page * $limit : $max_entries;
1413+
if($upper_results == 0) {
1414+
$lower_results = 0;
1415+
} else {
1416+
$lower_results = $selected_page > 0 ? ($selected_page - 1) * $limit + 1 : 1;
1417+
}
13941418

1395-
return array("lower_result" => $selected_page > 0 ? ($selected_page -1) * $limit + 1 : 1,
1396-
"upper_result" => ($selected_page * $limit +1) <= $max_entries && $selected_page > 0 ? $selected_page * $limit +1 : $max_entries,
1419+
return array("lower_result" => $lower_results,
1420+
"upper_result" => $upper_results,
13971421
"max_entries" => $max_entries,
13981422
"entries" => $links);
13991423
}

lib/Attachement.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,11 @@ public function getElement()
223223
return $this->element;
224224
}
225225

226+
public function isFileExisting()
227+
{
228+
return file_exists($this->getFilename()) || isURL($this->getFilename());
229+
}
230+
226231
/**
227232
* Get the filename (absolute path from filesystem root, as a UNIX path [only slashes])
228233
*

lib/LogSystem/InstockChangedEntry.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,9 @@ public static function add(&$database, &$current_user, &$log, &$part, $old_insto
198198
}
199199

200200
if (!is_int($old_instock) || !is_int($new_instock)) {
201+
if (is_float($old_instock) || is_float($new_instock)) {
202+
throw new \RuntimeException(sprintf(_('Es können maximal %d Bauteile vorhanden sein!'), PHP_INT_MAX));
203+
}
201204
throw new \RuntimeException(_('$old_instock und $new_instock müssen vom Typ int sein'));
202205
}
203206

lib/Part.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1541,10 +1541,9 @@ public function buildTemplateTableRowArray($table_type, $row_index, $additional_
15411541
switch ($caption) {
15421542
case 'hover_picture':
15431543
$picture_filename = str_replace(BASE, BASE_RELATIVE, $this->getMasterPictureFilename(true));
1544-
if(!file_exists($this->getMasterPictureFilename(true))) { //When filename is invalid then dont show picture.
1544+
if($this->getMasterPictureAttachement() != null && !$this->getMasterPictureAttachement()->isFileExisting()) { //When filename is invalid then dont show picture.
15451545
$picture_filename = "";
15461546
}
1547-
15481547
$row_field['picture_name'] = strlen($picture_filename) ? basename($picture_filename) : '';
15491548
$row_field['small_picture'] = strlen($picture_filename) ? $picture_filename : '';
15501549
$row_field['hover_picture'] = strlen($picture_filename) ? $picture_filename : '';

locale/en/LC_MESSAGES/php.mo

347 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)