|
@@ 1658-1698 (lines=41) @@
|
| 1655 |
|
|
| 1656 |
|
if (isset($_SESSION['settings']['enable_attachment_encryption']) && $_SESSION['settings']['enable_attachment_encryption'] === "1" && isset($image_status) && $image_status === "clear") { |
| 1657 |
|
// file needs to be encrypted |
| 1658 |
|
if (file_exists($_SESSION['settings']['path_to_upload_folder'].'/'.$image_code)) { |
| 1659 |
|
// make a copy of file |
| 1660 |
|
if (!copy( |
| 1661 |
|
$_SESSION['settings']['path_to_upload_folder'].'/'.$image_code, |
| 1662 |
|
$_SESSION['settings']['path_to_upload_folder'].'/'.$image_code.".copy" |
| 1663 |
|
)) { |
| 1664 |
|
$error = "Copy not possible"; |
| 1665 |
|
exit; |
| 1666 |
|
} else { |
| 1667 |
|
// do a bck |
| 1668 |
|
copy( |
| 1669 |
|
$_SESSION['settings']['path_to_upload_folder'].'/'.$image_code, |
| 1670 |
|
$_SESSION['settings']['path_to_upload_folder'].'/'.$image_code.".bck" |
| 1671 |
|
); |
| 1672 |
|
} |
| 1673 |
|
|
| 1674 |
|
// Open the file |
| 1675 |
|
unlink($_SESSION['settings']['path_to_upload_folder'].'/'.$image_code); |
| 1676 |
|
$fp = fopen($_SESSION['settings']['path_to_upload_folder'].'/'.$image_code.".copy", "rb"); |
| 1677 |
|
$out = fopen($_SESSION['settings']['path_to_upload_folder'].'/'.$image_code, 'wb'); |
| 1678 |
|
|
| 1679 |
|
// ecnrypt |
| 1680 |
|
stream_filter_append($out, 'mcrypt.tripledes', STREAM_FILTER_WRITE, $opts); |
| 1681 |
|
|
| 1682 |
|
// read file and create new one |
| 1683 |
|
while (($line = fgets($fp)) !== false) { |
| 1684 |
|
fputs($out, $line); |
| 1685 |
|
} |
| 1686 |
|
fclose($fp); |
| 1687 |
|
fclose($out); |
| 1688 |
|
|
| 1689 |
|
// update table |
| 1690 |
|
DB::update( |
| 1691 |
|
prefix_table('files'), |
| 1692 |
|
array( |
| 1693 |
|
'status' => 'encrypted' |
| 1694 |
|
), |
| 1695 |
|
"id=%i", |
| 1696 |
|
substr($_POST['uri'], 1) |
| 1697 |
|
); |
| 1698 |
|
} |
| 1699 |
|
} elseif (isset($_SESSION['settings']['enable_attachment_encryption']) && $_SESSION['settings']['enable_attachment_encryption'] === "0" && isset($image_status) && $image_status === "encrypted") { |
| 1700 |
|
// file needs to be decrypted |
| 1701 |
|
if (file_exists($_SESSION['settings']['path_to_upload_folder'].'/'.$image_code)) { |
|
@@ 1701-1741 (lines=41) @@
|
| 1698 |
|
} |
| 1699 |
|
} elseif (isset($_SESSION['settings']['enable_attachment_encryption']) && $_SESSION['settings']['enable_attachment_encryption'] === "0" && isset($image_status) && $image_status === "encrypted") { |
| 1700 |
|
// file needs to be decrypted |
| 1701 |
|
if (file_exists($_SESSION['settings']['path_to_upload_folder'].'/'.$image_code)) { |
| 1702 |
|
// make a copy of file |
| 1703 |
|
if (!copy( |
| 1704 |
|
$_SESSION['settings']['path_to_upload_folder'].'/'.$image_code, |
| 1705 |
|
$_SESSION['settings']['path_to_upload_folder'].'/'.$image_code.".copy" |
| 1706 |
|
)) { |
| 1707 |
|
$error = "Copy not possible"; |
| 1708 |
|
exit; |
| 1709 |
|
} else { |
| 1710 |
|
// do a bck |
| 1711 |
|
copy( |
| 1712 |
|
$_SESSION['settings']['path_to_upload_folder'].'/'.$image_code, |
| 1713 |
|
$_SESSION['settings']['path_to_upload_folder'].'/'.$image_code.".bck" |
| 1714 |
|
); |
| 1715 |
|
} |
| 1716 |
|
|
| 1717 |
|
// Open the file |
| 1718 |
|
unlink($_SESSION['settings']['path_to_upload_folder'].'/'.$image_code); |
| 1719 |
|
$fp = fopen($_SESSION['settings']['path_to_upload_folder'].'/'.$image_code.".copy", "rb"); |
| 1720 |
|
$out = fopen($_SESSION['settings']['path_to_upload_folder'].'/'.$image_code, 'wb'); |
| 1721 |
|
|
| 1722 |
|
// ecnrypt |
| 1723 |
|
stream_filter_append($fp, 'mdecrypt.tripledes', STREAM_FILTER_READ, $opts); |
| 1724 |
|
|
| 1725 |
|
// read file and create new one |
| 1726 |
|
while (($line = fgets($fp)) !== false) { |
| 1727 |
|
fputs($out, $line); |
| 1728 |
|
} |
| 1729 |
|
fclose($fp); |
| 1730 |
|
fclose($out); |
| 1731 |
|
|
| 1732 |
|
// update table |
| 1733 |
|
DB::update( |
| 1734 |
|
prefix_table('files'), |
| 1735 |
|
array( |
| 1736 |
|
'status' => 'clear' |
| 1737 |
|
), |
| 1738 |
|
"id=%i", |
| 1739 |
|
substr($_POST['uri'], 1) |
| 1740 |
|
); |
| 1741 |
|
} |
| 1742 |
|
} |
| 1743 |
|
} |
| 1744 |
|
|