Tag: php

  • PHP reading problem with files larger than 2 GB

    PHP reading problem with files larger than 2 GB

    If you’ll ever have problem with opening (fopen) and reading (fread) files larger than 2 GB in your PHP script. Check your version of scripting engine. In my case switching to 64 bit solved the problem. Please mind that this error is very hard to debug because PHP does not log anything (same as MS […]

  • How to pack directory using 7-zip in PHP on Windows?

    How to pack directory using 7-zip in PHP on Windows?

    This one was little bit tricky. If you want to pack files on your IIS webserver follow my guide.

  • How to replace one GET var in Yii 1.1.* when using form?

    How to replace one GET var in Yii 1.1.* when using form?

    I’ve needed URL with one variable replaced so it wouldn’t be duplicated every request. I’ve came up with this simple solution:

  • Permission denied when script is trying to execute ps_files_cleanup_dir

    Permission denied when script is trying to execute ps_files_cleanup_dir

    This is pretty common problem. I’ve encountered it on recent version of the Debian operating system. When you see something like that: Notice: session_start(): ps_files_cleanup_dir: opendir(/var/lib/php5/sessions) failed: Permission denied (13) in /mnt/www-data/htdocs/raportMNW/inc/bryanjhv/slim-session/src/Slim/Middleware/Session.php on line 110 You can fix that easily with following Linux commands: sudo nano /etc/php5/apache2/php.ini Now use CTRL+W to find following string session.save_path and configure it […]

  • Force Yii to republish assets every page refresh

    Force Yii to republish assets every page refresh

    During webapp development you’ll need often assets republication. When you publish assets using directory path, framework won’t republish them automaticaly. So what can you do? It’s plain simple. Use YII_DEBUG constant as fourth argument in publish function. $assetPath = Yii::app()->assetManager->publish(Yii::getPathOfAlias(‘application.modules.components.assets’), false, 1, YII_DEBUG); From this moment Yii will republish assets on every page refresh only […]

  • PHP malicious code analysis no. 1

    PHP malicious code analysis no. 1

    I found this piece of a PHP malware code on a compromised web server that I started to administer. It’s name was random character string eg. acbjxuu.php. There were about 20 more scripts of this kind. It’s rather very simple script for spaming purposes. For your understanding I’ve wrote what it’s doing in comments between code […]

  • Smarty gettext with domain support (block t plugin) [depreciated]

    Smarty gettext with domain support (block t plugin) [depreciated]

    Attention! Official Gettext plugin for Smarty has domain support since version 1.1. Check official repository: https://github.com/smarty-gettext/smarty-gettext. Description: This is a Smarty gettext plugin modification. It enables domain support and utilize gettext wrapper for PHP, Why do I use such wrapper for a gettext? It’s simple, not every server has native support for translation. This crafty script gives you fallback […]