<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Ivan Villareal on Ivan Villareal</title><link>https://ivanvillareal.com/</link><description>Recent content in Ivan Villareal on Ivan Villareal</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><lastBuildDate>Fri, 31 Jan 2020 12:21:51 -0800</lastBuildDate><atom:link href="" rel="self" type="application/rss+xml"/><item><title>LAMP in MacOS with macports</title><link>https://ivanvillareal.com/2020-01-21-lamp-in-macos-with-macports/</link><pubDate>Fri, 31 Jan 2020 12:21:51 -0800</pubDate><guid>https://ivanvillareal.com/2020-01-21-lamp-in-macos-with-macports/</guid><description>&lt;p&gt;Using &lt;a href=&#34;https://www.macports.org&#34;&gt;Macports&lt;/a&gt; is easy to setup a MAMP
environment with all the custom PHP extensions you may need.&lt;/p&gt;
&lt;p&gt;This is what I did to have a dev environment, running on MacOS Catalina:&lt;/p&gt;
&lt;p&gt;Install apache and php&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-bash&#34;&gt;❯ sudo port install php74 php74-xdebug php74-apache2handler php74-mysql php74-sqlite php74-mcrypt php74-mbstring php74-openssl
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Activate mod_php&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-bash&#34;&gt;❯ cd /opt/local/lib/apache2/modules
❯ sudo /opt/local/bin/apxs -a -e -n php7 mod_php74.so
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Activate mod_rewrite&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-ApacheConf&#34;&gt;LoadModule rewrite_module lib/apache2/modules/mod_rewrite.so
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Set a default php.ini&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-bash&#34;&gt;sudo cp /opt/local/etc/php74/php-development.ini /opt/local/etc/php74/php.ini
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Change DirectoryIndex in &lt;code&gt;/opt/local/etc/apache2/httpd.conf&lt;/code&gt; from:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-ApacheConf&#34;&gt;DirectoryIndex index.html
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-ApacheConf&#34;&gt;DirectoryIndex index.php index.html
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Uncomment the vhosts file&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-ApacheConf&#34;&gt;Include etc/apache2/extra/httpd-vhosts.conf
Include etc/apache2/extra/mod_php74.conf
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Create a new vhost in &lt;code&gt;/opt/local/etc/apache2/extra/httpd-vhosts.conf&lt;/code&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-ApacheConf&#34;&gt;&amp;lt;VirtualHost *:80&amp;gt;
ServerName agilistico.test
ServerAdmin webmaster@xilonen.lan
DocumentRoot &amp;quot;/Users/ivan/PhpstormProjects/agilistico.com/public&amp;quot;
&amp;lt;Directory &amp;quot;/Users/ivan/PhpstormProjects/agilistico.com/public&amp;quot;&amp;gt;
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
&amp;lt;/Directory&amp;gt;
ErrorLog &amp;quot;var/log/apache2/agilistico.test-error_log&amp;quot;
CustomLog &amp;quot;var/log/apache2/agilistico.test-access_log&amp;quot; common
&amp;lt;/VirtualHost&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Restart Apache to reflect the config changes&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-bash&#34;&gt;❯ sudo apachectl restart
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And finally add the host to &lt;code&gt;/etc/hosts&lt;/code&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-plaintext&#34;&gt;❯ sudo echo &#39;127.0.0.1 agilistico.test&#39; &amp;gt; /etc/hosts
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now install MySQL (in my case I need 5.7 at the time, but by default network is off so I can install multiple versions)&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-bash&#34;&gt;❯ sudo port install mysql57-server mysql57
❯ sudo /opt/local/lib/mysql57/bin/mysqld --initialize --user=_mysql
❯ sudo chown -R _mysql:_mysql /opt/local/var/db/mysql57/
❯ sudo chown -R _mysql:_mysql /opt/local/var/run/mysql57/
❯ sudo chown -R _mysql:_mysql /opt/local/var/log/mysql57/
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Add mysql_client path to the shell, in my case I&amp;rsquo;ve added the following to &lt;code&gt;~/.zshrc&lt;/code&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-bash&#34;&gt; export PATH=$PATH:/opt/local/lib/mysql57/bin
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Create another mysql user, default root has no password:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-bash&#34;&gt;❯ mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 24
Server version: 5.7.29 Source distribution
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type &#39;help;&#39; or &#39;\h&#39; for help. Type &#39;\c&#39; to clear the current input statement.
mysql &amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then in mysql console&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-sql&#34;&gt;
CREATE USER &#39;ivan&#39;@&#39;%&#39; IDENTIFIED BY &#39;123456&#39;;
GRANT ALL PRIVILEGES ON *.* TO &#39;ivan&#39;@&#39;%&#39;WITH GRANT OPTION;
CREATE USER &#39;ivan&#39;@&#39;localhost&#39; IDENTIFIED BY &#39;123456&#39;;
GRANT ALL PRIVILEGES ON *.* TO &#39;ivan&#39;@&#39;localhost&#39;WITH GRANT OPTION;
flush privileges; 
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Make apache and mysql start at boot:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-bash&#34;&gt;❯ sudo port load mysql57-server
❯ sudo port load apache2
&lt;/code&gt;&lt;/pre&gt;</description></item><item><title>Export a list of AWS EC2 Instances as CSV</title><link>https://ivanvillareal.com/2019-08-21-list-aws-ec2-instances-as-csv/</link><pubDate>Wed, 21 Aug 2019 17:00:38 -0700</pubDate><guid>https://ivanvillareal.com/2019-08-21-list-aws-ec2-instances-as-csv/</guid><description>&lt;p&gt;AWS does not provide a way to export a list of ec2 instances to a csv format,
recently there was a need to create such a list to identify what servers
were being shared in different projects.&lt;/p&gt;
&lt;p&gt;In order to create a excel file with such a list I had to use &lt;a href=&#34;https://github.com/awslabs/aws-shell&#34;&gt;aws-shell&lt;/a&gt; you just need the &lt;code&gt;aws_access_key_id&lt;/code&gt; and &lt;code&gt;aws_secret_access_key&lt;/code&gt;, we also need &lt;a href=&#34;https://stedolan.github.io/jq/&#34;&gt;jq&lt;/a&gt; and &lt;a href=&#34;https://www.gnu.org/software/sed/&#34;&gt;sed&lt;/a&gt; to process the output which is comming in json.&lt;/p&gt;
&lt;pre lang=&#34;python&#34;&gt;
aws-shell
ec2 describe-instances --region &#39;us-west-1&#39;
--region &#39;us-west-2&#39;
--query &#39;Reservations[].Instances[].[LaunchTime,InstanceId,InstanceType,Placement.AvailabilityZone, Tags[?Key==`Name`].Value|[0], State.Name]&#39;
| jq &#39;.[]&#39; --compact-output
| sed &#39;s/\[\|\]//g&#39;
&lt;/pre&gt;
&lt;p&gt;and this will give me what I need:&lt;/p&gt;
&lt;pre lang=&#34;json&#34;&gt;
&#34;2018-09-28T14:34:40.000Z&#34;,&#34;i-0134231e3f5512345&#34;,&#34;m3.large&#34;,&#34;us-west-2c&#34;,&#34;BlacoRa-PROD-Worker-HIGH spawned: Fri Sep 28 07:35:36 PDT 2018&#34;,&#34;running&#34;
&#34;2018-09-28T14:34:40.000Z&#34;,&#34;i-0cbac4aafabd12345&#34;,&#34;m3.large&#34;,&#34;us-west-2c&#34;,&#34;BlacoRa-PROD-Worker-HIGH spawned: Fri Sep 28 07:35:36 PDT 2018&#34;,&#34;running&#34;
&#34;2018-09-28T14:34:40.000Z&#34;,&#34;i-0c32344b965612345&#34;,&#34;m3.large&#34;,&#34;us-west-2c&#34;,&#34;BlacoRa-QA-Worker-BULK spawned: Fri Sep 28 07:35:47 PDT 2018&#34;,&#34;running&#34;
&#34;2018-09-28T14:34:40.000Z&#34;,&#34;i-05cbdf22345c7f518&#34;,&#34;m3.large&#34;,&#34;us-west-2c&#34;,&#34;BlacoRa-QA-Worker-BULK spawned: Fri Sep 28 07:35:44 PDT 2018&#34;,&#34;running&#34;
&#34;2018-09-28T14:34:40.000Z&#34;,&#34;i-02512345671342567f&#34;,&#34;m3.large&#34;,&#34;us-west-2c&#34;,&#34;BlacoRa-QA-Worker-BULK spawned: Fri Sep 28 07:35:45 PDT 2018&#34;,&#34;running&#34;
&#34;2018-09-28T14:34:40.000Z&#34;,&#34;i-0563eabc3445344195&#34;,&#34;m3.large&#34;,&#34;us-west-2c&#34;,&#34;BlacoRa-QA-Worker-BULK spawned: Fri Sep 28 07:35:43 PDT 2018&#34;,&#34;running&#34;
&#34;2018-11-07T22:29:13.000Z&#34;,&#34;i-0e7812fed349834288&#34;,&#34;m3.large&#34;,&#34;us-west-2c&#34;,&#34;BlacoRa-QA-Worker-HIGH spawned: Wed Nov 7 14:30:26 PST 2018&#34;,&#34;running&#34;
&#34;2018-11-07T22:29:13.000Z&#34;,&#34;i-0abcd72c72bcfd3429&#34;,&#34;m3.large&#34;,&#34;us-west-2c&#34;,&#34;BlacoRa-QA-Worker-BULK spawned: Wed Nov 7 14:30:26 PST 2018&#34;,&#34;running&#34;
&lt;/pre&gt;
&lt;p&gt;So we have a tag called Name which we need to map it out to the project, if there were more tags
that we need to include on the report, is just a matter of adding them to the query &lt;code&gt;Tags[?Key==&lt;/code&gt;Project&lt;code&gt;].Value|[0]&lt;/code&gt;&lt;/p&gt;</description></item><item><title>Spatie/Permissions Cache Reset Silent Fail</title><link>https://ivanvillareal.com/spatie-permissions-cache-reset-silent-fail/</link><pubDate>Fri, 10 May 2019 09:58:22 -0700</pubDate><guid>https://ivanvillareal.com/spatie-permissions-cache-reset-silent-fail/</guid><description>
&lt;h2 id=&#34;the-problem&#34;&gt;The Problem&lt;/h2&gt;
&lt;p&gt;Yesterday I was working on a ACL Implementation and I was using the &lt;a title=&#34;Spatie/Permissions.&#34; href=&#34;https://packagist.org/packages/spatie/laravel-permission&#34; target=&#34;_blank&#34;&gt;Spatie/Permissions&lt;/a&gt; library all was ok, until I had to run a clean migration to test all my factories.&lt;/p&gt;
&lt;p&gt;I was getting the following error:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-php&#34; data-lang=&#34;php&#34;&gt;Spatie\Permission\Exceptions\PermissionAlreadyExists : A `view backend` permission already exists for guard `web`.&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;I was confused the Permissions table was empty, I was forcing to clear the permission cache file just before starting to add new permissions.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-php&#34; data-lang=&#34;php&#34;&gt;// Reset cached roles and permissions
app()[&amp;#39;cache&amp;#39;]-&amp;gt;forget(&amp;#39;spatie.permission.cache&amp;#39;);&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;I even ran my custom composer &lt;code&gt;clear-all&lt;/code&gt; command to clear all the cache from views/routes/permission etc.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&amp;gt; @php artisan clear-compiled
Compiled services and packages files removed!
&amp;gt; @php artisan cache:clear
Application cache cleared!
&amp;gt; @php artisan route:clear
Route cache cleared!
&amp;gt; @php artisan view:clear
Compiled views cleared!
&amp;gt; @php artisan config:clear
Configuration cache cleared!
&amp;gt; @php artisan permission:cache-reset
Permission cache flushed.
&amp;gt; composer dumpautoload -o
Generating optimized autoload files&amp;gt; Illuminate&lt;span style=&#34;color:#ae81ff&#34;&gt;\F&lt;/span&gt;oundation&lt;span style=&#34;color:#ae81ff&#34;&gt;\C&lt;/span&gt;omposerScripts::postAutoloadDump
&amp;gt; @php artisan ide-helper:generate
A new helper file was written to _ide_helper.php
&amp;gt; @php artisan ide-helper:meta
A new meta file was written to .phpstorm.meta.php
&amp;gt; @php artisan package:discover --ansi
Discovered Package: arcanedev/log-viewer
Discovered Package: arcanedev/no-captcha
Discovered Package: barryvdh/laravel-debugbar
Discovered Package: barryvdh/laravel-ide-helper
Discovered Package: beyondcode/laravel-dump-server
Discovered Package: creativeorange/gravatar
Discovered Package: davejamesmiller/laravel-breadcrumbs
Discovered Package: fideloper/proxy
Discovered Package: hieu-le/active
Discovered Package: ivaano/laravel-code-generator
Discovered Package: laravel/tinker
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Discovered Package: spatie/laravel-html
Discovered Package: spatie/laravel-permission
Discovered Package: webpatser/laravel-uuid
Package manifest generated successfully.
Generated optimized autoload files containing &lt;span style=&#34;color:#ae81ff&#34;&gt;4595&lt;/span&gt; classes&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;But the error kept showing every time i tried to seed, It worked if I changed the permission name or created a new permissions, but it didnt worked with the &lt;code&gt;view backend&lt;/code&gt; permission. I spent about an hour looking into this, this happened on my linux laptop I didnt have this issue on OSX, so I left that until Today, so Today I was looking at the permissions library and didnt found anything weird, that was until I&amp;rsquo;ve decided to see what permissions where being returned, this is the method from the Permissions library&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-php&#34; data-lang=&#34;php&#34;&gt;/**
* Get the permissions based on the passed params.
*
* @param array $params
*
* @return \Illuminate\Support\Collection
*/
public function getPermissions(array $params = []): Collection
{
if ($this-&amp;gt;permissions === null) {
$this-&amp;gt;permissions = $this-&amp;gt;cache-&amp;gt;remember(self::$cacheKey, self::$cacheExpirationTime, function () {
return $this-&amp;gt;getPermissionClass()
-&amp;gt;with(&amp;#39;roles&amp;#39;)
-&amp;gt;get();
});
}
$permissions = clone $this-&amp;gt;permissions;
foreach ($params as $attr =&amp;gt; $value) {
$permissions = $permissions-&amp;gt;where($attr, $value);
}
return $permissions;
}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;So I found that the cache was returning the &lt;code&gt;view backend&lt;/code&gt; permission even though I have cleared the cache, so I dig a little more and found the file that was being called by the cacheManager class, and it was there and it did in fact had the &lt;code&gt;view backedn&lt;/code&gt; key, so the command &lt;code&gt;php artisan permission:cache-reset&lt;/code&gt; was not clearing the cache also calling it from the code was failing &lt;code&gt;app()[&#39;cache&#39;]-&amp;gt;forget(&#39;spatie.permission.cache&#39;);&lt;/code&gt;. (It was expected as the command is just a wrapper for this call)&lt;/p&gt;
&lt;p&gt;In the end the problem was the file ownership, the cache was created by the apache user &lt;code&gt;www-data&lt;/code&gt;, on OSX I didnt have this issue because I&amp;rsquo;m running apache with the same user I&amp;rsquo;m logged in.&lt;/p&gt;
&lt;h2 id=&#34;the-solution&#34;&gt;The Solution&lt;/h2&gt;
&lt;p&gt;A quick solution would be to just remove the file manually, but I will have to find the file and remove it manually everytime I need to clear the cache, so the next approach would be to make apache run as the user I&amp;rsquo;m logged just like my OSX approach, this would also have other benefits in my dev machine, as I wont have to worry about files created by apache that I cant manage from the cli with my user.&lt;/p&gt;
&lt;p&gt;Running apache as a different user is pretty simple in ubuntu just change the user:group in the file &lt;code&gt;/etc/apache2/envvars&lt;/code&gt;, restart apache and change all the files to the user that will be running apache.&lt;/p&gt;
&lt;h2 id=&#34;lessons-learned&#34;&gt;Lessons learned&lt;/h2&gt;
&lt;p&gt;Silent Failing is always bad, If I dont see an error where I&amp;rsquo;m expecting certain behavior I will assume the problem is somewhere else, so it will be a waste of time trying to find the error. This is a Library problem, laravel is returning false when the delete method is called &lt;code&gt;/laravel/framework/src/Illuminate/Filesystem/Filesystem.php&lt;/code&gt;, but the library is just assuming that there will be no problems when the cache is cleared.&lt;/p&gt;
&lt;p&gt;The fix is simple, just return the result from the cache call and if it fails at least print an error, I&amp;rsquo;ve sent a PR &lt;a title=&#34;Spatie/Permissions Cache reset Fail silentl.&#34; href=&#34;https://github.com/spatie/laravel-permission/pull/1097/commits/37843d668be48b266069dd3643ba2378edbc2290&#34; target=&#34;_blank&#34;&gt;Show error when cache:reset command fails&lt;/a&gt; to fix this, hopefully it gets accepted.&lt;/p&gt;</description></item><item><title>Old Blog revived</title><link>https://ivanvillareal.com/old-blog-revived/</link><pubDate>Wed, 17 Apr 2019 16:45:29 +0000</pubDate><guid>https://ivanvillareal.com/old-blog-revived/</guid><description>&lt;p&gt;I&amp;rsquo;ve been trying to revive my blog for a while, I was going to use GH pages with Jekyll because Wordpress is such a burden to maintain.&lt;/p&gt;
&lt;p&gt;When I started writing my blog I was paying $25 per month to host my blog on a VPS, I had little use for the VPS so most of the time it was just there doing nothing but serving my blog with wordpress, from time to time I had to log into the server update all the packages, and upgrade the wordpress instance. Last time I logged into the server I saw that I haven&amp;rsquo;t logged in 11 months or so, I was very busy at that time and didnt want to have that server hacked because lack of maintenance, that plus $300 a year in server costs didnt help to make a case on keeping the server.&lt;/p&gt;
&lt;p&gt;I knew there was multiple blog platforms but because I want to be in control of my content that discarded every platform, so my only option was a static site, but that didnt happen for another 4 years, I did some previous attempts with Jekyll and Lektor but it was just to much work migrating the content every time I&amp;rsquo;ve spent an hour or 2 just to be frustrated so I never did the move.&lt;/p&gt;
&lt;p&gt;This month I had some spare time, and I&amp;rsquo;ve decided to do the migration, I was familiar with &lt;a href=&#34;https://gohugo.io&#34; rel=&#34;nofollow noreferrer&#34;&gt;hugo&lt;/a&gt; so I gave it a try, and in less than 2 minutes I had a working site, so I&amp;rsquo;ve looked in my backups and found my old wp files, along with the db, I thought it would be easy to just get the content from the db dump, but it was not going to work because it had a lot of html embedded and the images were doing references to absolute urls.&lt;/p&gt;
&lt;p&gt;So my other option was to try to make the old instance work, I have an Ubuntu 14 VM for legacy projects, so I did quick vhost setup, restored the db put the files, and fixed the config and wordpress worked!&lt;/p&gt;
&lt;p&gt;I was planning to use this &lt;a href=&#34;https://github.com/SchumacherFM/wordpress-to-hugo-exporter&#34; rel=&#34;nofollow noreferrer&#34;&gt;hugo exporter plugin&lt;/a&gt; but the admin dashboard was broken with the following error in the logs:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;[Wed Apr 03 20:36:27.151639 2019] [:error] [pid 19662] [client 192.168.8.198:41112] PHP Fatal error: Access to undeclared static property: WP_Screen::$this in /var/www/blogwp.fiv/wp-admin/includes/screen.php on line 706, referer: http://ivanvillareal.com/wp-admin/options-privacy.php&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;So I edited that part and changed the &lt;code&gt;$this&lt;/code&gt; to &lt;code&gt;self&lt;/code&gt; and the dashboard worked, I disabled the plugins, and I was able to update the wp instance from the dashboard, I had version 3.4 and it updated to 5.1 without any other issue I have to admit that I was impressed by such feat.&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;ve performed the plugin installation and then exported everything, it did a decent job I had to do some edits to remove the cache stuff, and change the format of the code blocks, but all went ok.&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;ve spent some time on the design and Today I just finished moving all the content. I think all I&amp;rsquo;ve written is not useful anymore, but reading my old posts brings back memories from a different time, and that has value to me.&lt;/p&gt;
&lt;p&gt;Since I stopped writing in this blog I&amp;rsquo;ve worked with many different technologies, but as today my work is mostly Python on backend services, so I&amp;rsquo;m going to write about that.&lt;/p&gt;</description></item><item><title>Setup iTerm2 to behave like guake</title><link>https://ivanvillareal.com/setup-iterm2-to-behave-like-guake/</link><pubDate>Wed, 04 Apr 2012 17:50:29 +0000</pubDate><guid>https://ivanvillareal.com/setup-iterm2-to-behave-like-guake/</guid><description>&lt;p&gt;In my journey of moving from Linux to OSX, I’m always trying to find the tools that I’m used to work, because that&amp;rsquo;s the way I’m more productive, and one of the most important tools is a good terminal, on linux I used a combination of guake and terminator, the first one to run commands that I need the output immediately the latter to do actual programming stuff, that is because guake can be called from a hotkey and shows a small terminal coming from the top like quake used to do it, this is a fantastic way to run simple commands because the terminal is always open, we just show/hide and only uses a part of the screen, also when it is called is always ready to be used for example if I need to do a quick grep on a project I would do F12 (this is my hotkey) then type grep ‘pattern’ ~/Project/project123 -R then just hide the terminal and continue my work.&lt;/p&gt;
&lt;p&gt;When I moved into OS X I searched for a good terminal replacement, one that supported 256 colors with good emulation, and also with the ability to split panes like terminator, and I found iTerm2 a wonderful terminal application that has everything, after setting my profile to work with my vim color scheme, and putting all my stuff from .bashrc I wanted to have a guake like terminal to run commands quickly, and I found the hotkey function so this is how I set it up to work like guake.&lt;/p&gt;
&lt;p&gt;First thing is to create a new Profile or duplicate the one that you use the most, then on the Window Tab I set the style as Top of Screen on Main Screen (I have 2 monitors) and on all Spaces. I set 160 columns by 25 Rows.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://ivanvillareal.com/assets/2012-04-04-setup-iterm2-to-behave-like-guake/create_new_iterm_profile.png&#34; alt=&#34;Create new Profile&#34; /&gt;&lt;/p&gt;
&lt;p&gt;After I have my profile done, I clicked on the Keys Icon then activated the “Show/hide iTerm2 with a system-wide hotkey” I’m unable to use F12 because that moves me to the dashboard so used ⌘F12 then selected the profile I’ve created and done&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://ivanvillareal.com/assets/2012-04-04-setup-iterm2-to-behave-like-guake/assign_a_hotkey.png&#34; alt=&#34;Assign a hotkey&#34; /&gt;&lt;/p&gt;
&lt;p&gt;here is a small demonstration of how it works after the setup&lt;/p&gt;
&lt;iframe width=&#34;480&#34; height=&#34;360&#34; src=&#34;https://www.youtube.com/embed/kx28CDBYc30&#34; frameborder=&#34;0&#34; allowfullscreen&gt;&lt;/iframe&gt;</description></item><item><title>Create a multiuser git repository with gitolite</title><link>https://ivanvillareal.com/create-a-multiuser-git-repository-with-gitolite/</link><pubDate>Tue, 01 Nov 2011 22:57:54 +0000</pubDate><guid>https://ivanvillareal.com/create-a-multiuser-git-repository-with-gitolite/</guid><description>
&lt;p&gt;I use git for almost all my dev work, is fast, it works locally, and I can even use it as a quick deployment tool, by adding hooks, but when it comes to sharing a repository to other developers, I dont like the idea of creating a user account in the system for each developer, so the easiest and fastest way to solve this issue for me is using &lt;a href=&#34;https://github.com/sitaramc/gitolite&#34; rel=&#34;nofollow noreferrer&#34;&gt;gitolite&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;In this post I will describe the steps needed to setup a central repository for multiple users. I&amp;rsquo;m using Centos 5.5 as server and debian as a workstation&lt;/p&gt;
&lt;h3 id=&#34;create-a-user-account-in-the-server-and-install-git&#34;&gt;Create a user account in the server and install git&lt;/h3&gt;
&lt;pre lang=&#34;bash&#34;&gt;[root@bp ~]# useradd -m git
[root@bp ~]# passwd git
[root@bp ~]# yum install git
&lt;/pre&gt;
&lt;h3 id=&#34;copy-your-public-key-from-our-workstation-to-the-server&#34;&gt;Copy your public key from our workstation to the server&lt;/h3&gt;
&lt;p&gt;If you don&amp;#8217;t know how to setup an ssh passwordless login, take a look &lt;a href=&#34;https://ivanvillareal.com/setting-up-ssh-keys-for-passwordless-login/&#34;&gt;here&lt;/a&gt;&lt;/p&gt;
&lt;pre lang=&#34;bash&#34;&gt;ivan@scorpion:~$ scp ~/.ssh/id_rsa.pub git@bp.com:~/ivan.pub
&lt;/pre&gt;
&lt;h3 id=&#34;clone-gitolite-into-the-server&#34;&gt;Clone gitolite into the server&lt;/h3&gt;
&lt;pre lang=&#34;bash&#34;&gt;ivan@scorpion:~$ ssh git@bp
git@bp: ~$ git clone git://github.com/sitaramc/gitolite
git@bp: ~$ cd gitolite
git@bp: ~$ src/gl-system-install
git@bp: ~$ gl-setup ~/ivan.pub
&lt;/pre&gt;
&lt;h3 id=&#34;go-to-the-workstation-to-manage-the-git-repo&#34;&gt;Go to the workstation to manage the git repo&lt;/h3&gt;
&lt;pre lang=&#34;bash&#34;&gt;ivan@scorpion:~$ mkdir -p git/bprepo
ivan@scorpion:~$ cd git/bprepo
ivan@scorpion:~$ git clone git@bp:gitolite-admin
&lt;/pre&gt;
&lt;p&gt;At this point we have 2 folders inside gitolite-admin conf/ and keydir/ the first one is used to create new repositories or add users to repositories the second one is for adding each user public key.&lt;/p&gt;
&lt;p&gt;Once you have added new repositories and users you need to do a&lt;/p&gt;
&lt;p&gt;&lt;code&gt;git push origin master&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;on each new repo.&lt;/p&gt;</description></item><item><title>NFS Mac OSX Lion</title><link>https://ivanvillareal.com/osx/nfs-mac-osx-lion/</link><pubDate>Mon, 29 Aug 2011 19:37:57 +0000</pubDate><guid>https://ivanvillareal.com/osx/nfs-mac-osx-lion/</guid><description>&lt;p&gt;I was in the need of sharing files from a mac osx 10.7 and some linux servers, so I thought this would be a simple process just like in linux, but I found some issues that prevented me to mount the exported dirs to the mac or to setup a nfsd on the mac OS, this is more a reminder to my self about how I was able to perform that.&lt;/p&gt;
&lt;p&gt;Case 1 - Mac OSX as NFS server:&lt;/p&gt;
&lt;p&gt;the problem with this one is that the syntax of the exports is different from what I know, but after changing some options I was able to export the Users folder on the mac with the following line:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;/Users -alldirs -network 192.168.0.0 -mask 255.255.0.0&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;to mount the above on my linux box I used this:&lt;/p&gt;
&lt;pre lang=&#34;bash&#34;&gt;ivan@orion:~$ sudo mount -t nfs macbox:Users/ivan/ ivanomac&lt;/pre&gt;
&lt;p&gt;Only problem found was the weird group and user numbers, so that needs to be mapped out, but because I was only in the need to read some files from the mac I didn’t bother doing that.&lt;/p&gt;
&lt;p&gt;Case 2 - Linux NFS server Mac OSX client:&lt;/p&gt;
&lt;p&gt;This case is because I have a dev vm, and I need to do constant changes onn it from the mac, the linux flavor of the vm is Ubuntu Server 11.04 and to get the nfs server running I did the following:&lt;/p&gt;
&lt;pre lang=&#34;bash&#34;&gt;scorpion ~# apt-get install nfs-kernel-server nfs-common portmap
scorpion ~# echo “/var/www 192.168.0.0/16(rw,no_subtree_check,no_root_squash)” &amp;gt;&amp;gt; /etc/exports
scorpion ~# exportfs -a&lt;/pre&gt;
&lt;p&gt;and on the mac I ran the following:&lt;/p&gt;
&lt;pre lang=&#34;bash&#34;&gt;[ivan@kunglao:~$sudo mount -t nfs -o resvport,vers=4 scorpion:/var/www scorpion&lt;/pre&gt;
&lt;p&gt;with the above I was able to view the files from the ubuntu server, however when I mounted the same export on another ubuntu machine I got the uid/gid wrong, to fix that I just ran the idmapd service on the client machine.&lt;/p&gt;
&lt;pre lang=&#34;bash&#34;&gt;orion ~ # service idmapd start
orion ~# mount -t nfs scorpion:/var/www scorpion&lt;/pre&gt;</description></item><item><title>Perl script to manage add/remove Apache virtual hosts</title><link>https://ivanvillareal.com/perl-script-to-manage-virtual-hosts/</link><pubDate>Wed, 08 Jun 2011 19:54:57 +0000</pubDate><guid>https://ivanvillareal.com/perl-script-to-manage-virtual-hosts/</guid><description>&lt;p&gt;I wrote this script a while back, and I&amp;rsquo;ve been using it on gentoo, ubuntu and centos distros with a few changes between each distro, this can be extended to add new functionality, and it may contain bugs, but so far it has worked for me pretty well, I can add/remove virtual hosts very quickly.&lt;/p&gt;
&lt;p&gt;To use this script you only need the packages File::Path and Getopt::Long; both of them are already on newer distros, just put the script somewhere in your bin path, I have it in /usr/local/bin and call it with sudo.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;ivan@orion:/var/www/vhosts$ sudo vhost-updater.pl --add --domain test.orion&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;This is the output:&lt;/p&gt;
&lt;pre lang=&#34;bash&#34;&gt;Creating docroot dir: /var/www/vhosts/test.orion/public_html
Creating log dir: /var/www/vhosts/test.orion/logs
Site File: /etc/apache2/sites-available/test.orion
Creating Vhost...
Adding host test.orion
Run &#39;/etc/init.d/apache2 reload&#39; to activate new configuration!
Restarting apache
* Restarting web server apache2
... waiting ...done.&lt;/pre&gt;
&lt;p&gt;Once it has finished, point your browser to &lt;a href=&#34;http://test.orion&#34; rel=&#34;nofollow noreferrer&#34;&gt;http://test.orion&lt;/a&gt;, and you&amp;rsquo;re done.&lt;/p&gt;
&lt;p&gt;Enjoy!&lt;/p&gt;
&lt;pre lang=&#34;perl&#34;&gt;#!/usr/bin/perl -w
#############################################################
# The purpose of this script is to add/remove #
# virtual hosts easily, this script runs #
# on Ubuntu/Debian withouth modifications. #
# #
# #
# Author Ivan Villareal ivaano@gmail.com #
# #
#############################################################
use strict;
use File::Path qw(mkpath rmtree);
use Getopt::Long;
our $ipAddress = &#39;127.0.0.1&#39;;
our $apacheConfigDir = &#39;/etc/apache2&#39;;
our $sitesAvailable = &#39;sites-available&#39;;
our $docRootPrefix = &#39;/var/www/vhosts&#39;;
our $docRoot = &#39;public_html&#39;;
our $logsDir = &#39;logs&#39;;
my $del = &#39;&#39;;
my $add = &#39;&#39;;
my $domain = &#39;&#39;;
if (getpwuid( $&amp;lt; ) ne &#39;root&#39;) {
print &#34;Script needs root privileges \n&#34;;
exit();
}
unless (GetOptions (
&#39;del&#39; =&gt; \$del,
&#39;add&#39; =&gt; \$add,
&#39;domain=s&#39; =&gt; \$domain) or usage()) {
usage();
}
#print $paramResults;
if ($add || $del) {
if ($domain) {
if ($add) {
createVhost($domain);
} elsif ($del) {
deleteVhost($domain);
}
} else {
usage();
}
} else {
usage();
}
sub usage {
print &amp;lt; &amp;lt;USAGE
This program will add or remove apache virtual hosts.
usage: vhost-updater.pl [--add | --del] --domain newhost.tld
USAGE
}
sub returnVhostPaths
{
my $vhost = shift;
my @dir = split(/\//, $docRootPrefix);
my %res;
push(@dir, $vhost);
my $hostDir = join(&#39;/&#39;, @dir);
$res{&#39;docRoot&#39;} = $hostDir . &#39;/&#39; . $docRoot;
$res{&#39;logsDir&#39;} = $hostDir . &#39;/&#39; . $logsDir;
$res{&#39;hostDir&#39;} = $hostDir;
#todo dir validation
@dir = split(/\//, $apacheConfigDir);
push(@dir, $sitesAvailable);
push(@dir, $vhost);
$res{&#39;apacheConfig&#39;} = join(&#39;/&#39;, @dir);
return %res;
}
sub createVhost {
my $vhost = shift;
#first create the docRoot
my %vhostInfo = returnVhostPaths($vhost);
informOut(&#34;Creating docroot dir: $vhostInfo{&#39;docRoot&#39;}&#34;);
mkpath($vhostInfo{&#39;docRoot&#39;});
my $user = getlogin();
my $uid = getpwnam($user);
my $gid = getgrnam($user);
chown $uid, $gid, $vhostInfo{&#39;hostDir&#39;};
chown $uid, $gid, $vhostInfo{&#39;docRoot&#39;};
informOut(&#34;Creating log dir: $vhostInfo{&#39;logsDir&#39;}&#34;);
mkpath($vhostInfo{&#39;logsDir&#39;});
informOut(&#34;Site File: $vhostInfo{&#39;apacheConfig&#39;}&#34;);
my $vhostContent = &amp;lt;&amp;lt; &#34;EOF&#34;;
&amp;lt;VirtualHost *:80&gt;
ServerName $vhost
DocumentRoot $vhostInfo{&#39;docRoot&#39;}
&amp;lt;directory $vhostInfo{&#39;docRoot&#39;}&gt;
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
&amp;lt;/directory&gt;
ErrorLog $vhostInfo{&#39;logsDir&#39;}/error_log
CustomLog $vhostInfo{&#39;logsDir&#39;}/access_log &#34;%h %l %u %t \\&#34;%r\\&#34; %&gt;s %b \\&#34;%{Referer}i\\&#34; \\&#34;%{User-agent}i\\&#34;&#34;
LogLevel debug
EOF
informOut(&#34;Creating Vhost...&#34;);
open FILE, &#34;&gt;&#34;, $vhostInfo{&#39;apacheConfig&#39;} or die $!;
print FILE $vhostContent;
close FILE;
informOut(&#34;Adding host $vhost&#34;);
open FILE, &#34;&gt;&gt;&#34;, &#39;/etc/hosts&#39; or die $!;
print FILE $ipAddress .&#34;\t&#34;. $vhost .&#34;\n&#34;;
close FILE;
my $output = `/usr/sbin/a2ensite $vhost`;
print $output;
restartApache();
#print $vhostConten t;
}
sub restartApache
{
informOut(&#34;Restarting apache&#34;);
my $output = `/etc/init.d/apache2 restart`;
print $output;
}
sub deleteVhost
{
my $vhost = shift;
my %vhostInfo = returnVhostPaths($vhost);
informOut(&#34;Removing $vhost from hosts file&#34;);
open IN, &#39;&amp;lt; &#39;, &#39;/etc/hosts&#39; or die $!;
my @hostsFile = &amp;lt;IN&gt;;
close IN;
my @contents = grep(!/^127.0.0.1\t$vhost/, @hostsFile);
open FILE, &#34;&gt;&#34;, &#39;/etc/hosts&#39; or die $!;
print FILE @contents;
close FILE;
my $output = `/usr/sbin/a2dissite $vhost`;
print $output;
informOut(&#34;Removing $vhostInfo{&#39;apacheConfig&#39;} file&#34;);
unlink($vhostInfo{&#39;apacheConfig&#39;});
restartApache();
print &#34; manually remove $vhostInfo{&#39;docRoot&#39;}... \n&#34;;
}
sub informOut {
my $message = shift;
print &#34;$message \n&#34;;
}
&lt;/pre&gt;</description></item><item><title>Dynamic multi form on same page with jQuery and PHP</title><link>https://ivanvillareal.com/dynamic-multi-form-on-same-page-with-jquery-and-php/</link><pubDate>Tue, 19 Apr 2011 20:13:50 +0000</pubDate><guid>https://ivanvillareal.com/dynamic-multi-form-on-same-page-with-jquery-and-php/</guid><description>&lt;p&gt;This is a little demo of a small app that allow us to have several forms displayed on the same page, organized by sections, a static multiform can be easily created by putting the form contents on divs and hiding them, then when the user clicks on a specific section we hide the previous div, and show the new one, we can wrap it up everything inside a big form, and submit that.&lt;/p&gt;
&lt;p&gt;The approach I did for having this same functionality allows me to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Save each section form before editing a new one&lt;/li&gt;
&lt;li&gt;Change any form inputs depending on received data&lt;/li&gt;
&lt;li&gt;Validate in the front and backend each section&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The main disadvantage is that for each section I&amp;rsquo;ll do an ajax call, to submit and retrieve the form.&lt;/p&gt;
&lt;p&gt;The first thing I did was to write the main html layout I did a simple 2 column layout to use the left block as a form navigator and the right block to show the actual form.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-html&#34; data-lang=&#34;html&#34;&gt;&amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;div&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;class&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;left_block_box&amp;#34;&lt;/span&gt;&amp;gt;
&amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;div&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;class&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;left_block_title&amp;#34;&lt;/span&gt;&amp;gt;
Form Steps
&amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;div&lt;/span&gt;&amp;gt;
&amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;div&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;id&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;edit_step_box&amp;#34;&lt;/span&gt;&amp;gt;
&amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;table&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;width&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;100%&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;cellspacing&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;0&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;cellpadding&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;0&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;border&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;0&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;style&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;font-size: 11px;&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;id&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;stepTable&amp;#34;&lt;/span&gt;&amp;gt;
&amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;tr&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;class&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;stepSelected&amp;#34;&lt;/span&gt;&amp;gt;
&amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;td&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;class&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;formStep&amp;#34;&lt;/span&gt;&amp;gt;
Name
&amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;td&lt;/span&gt;&amp;gt;
&amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;td&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;class&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;stepEdit&amp;#34;&lt;/span&gt;&amp;gt;
&amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;span&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;id&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;formstep1&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;class&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;pointer placeEdit&amp;#34;&lt;/span&gt;&amp;gt;Edit&amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;span&lt;/span&gt;&amp;gt;
&amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;td&lt;/span&gt;&amp;gt;
&amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;tr&lt;/span&gt;&amp;gt;
&amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;tr&lt;/span&gt;&amp;gt;
&amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;td&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;class&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;formStep&amp;#34;&lt;/span&gt;&amp;gt;
Address
&amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;td&lt;/span&gt;&amp;gt;
&amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;td&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;class&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;stepEdit&amp;#34;&lt;/span&gt;&amp;gt;
&amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;span&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;id&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;formstep2&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;class&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;pointer placeEdit&amp;#34;&lt;/span&gt;&amp;gt;Edit&amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;span&lt;/span&gt;&amp;gt;
&amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;td&lt;/span&gt;&amp;gt;
&amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;tr&lt;/span&gt;&amp;gt;
&amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;tr&lt;/span&gt;&amp;gt;
&amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;td&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;class&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;formStep&amp;#34;&lt;/span&gt;&amp;gt;
Interests:
&amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;td&lt;/span&gt;&amp;gt;
&amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;td&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;class&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;stepEdit&amp;#34;&lt;/span&gt;&amp;gt;
&amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;span&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;id&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;formstep3&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;class&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;pointer placeEdit&amp;#34;&lt;/span&gt;&amp;gt;Edit&amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;span&lt;/span&gt;&amp;gt;
&amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;td&lt;/span&gt;&amp;gt;
&amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;tr&lt;/span&gt;&amp;gt;
&amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;table&lt;/span&gt;&amp;gt;
&amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;div&lt;/span&gt;&amp;gt;
&amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;div&lt;/span&gt;&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;I&amp;rsquo;ve used a table so I can navigate more easily the DOM with jquery, but this can be changed an ul and it will work the same, the next thing I wrote was the other column wrapper the right block which will holde the actual form retrieved from the server.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-html&#34; data-lang=&#34;html&#34;&gt;&amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;div&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;class&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;right_block_box&amp;#34;&lt;/span&gt;&amp;gt;
&amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;div&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;class&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;right_block_title&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;id&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;formTitle&amp;#34;&lt;/span&gt;&amp;gt;
Form 1
&amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;div&lt;/span&gt;&amp;gt;
&amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;div&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;class&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;multiform_part&amp;#34;&lt;/span&gt;&amp;gt;
Aqui va la forma
&amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;div&lt;/span&gt;&amp;gt;
&amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;div&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;id&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;form_step_nav_wrap&amp;#34;&lt;/span&gt;&amp;gt;
&amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;div&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;id&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;form_step_nav&amp;#34;&lt;/span&gt;&amp;gt;
&amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;div&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;id&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;form_step_left&amp;#34;&lt;/span&gt;&amp;gt;
&amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;input&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;type&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;button&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;value&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Previous Step&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;id&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;prevStepBtn&amp;#34;&lt;/span&gt; /&amp;gt;
&amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;div&lt;/span&gt;&amp;gt;
&amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;div&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;id&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;form_step_right&amp;#34;&lt;/span&gt;&amp;gt;
&amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;input&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;type&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;button&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;value&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Next Step&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;id&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;nextStepBtn&amp;#34;&lt;/span&gt; /&amp;gt;
&amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;input&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;type&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;button&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;value&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Preview Data&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;style&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;display: none&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;id&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;previewBtn&amp;#34;&lt;/span&gt; /&amp;gt;
&amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;div&lt;/span&gt;&amp;gt;
&amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;div&lt;/span&gt;&amp;gt;
&amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;div&lt;/span&gt;&amp;gt;
&amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;div&lt;/span&gt;&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Once I had my basic layout I started with the javascript functionality, the first thing was to create a function that allow me to move from one form to another, passing current form values to the calling script and displaying the new form.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-javascript&#34; data-lang=&#34;javascript&#34;&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;selectStep&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;step&lt;/span&gt;) {
&lt;span style=&#34;color:#66d9ef&#34;&gt;var&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;thisStep&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;$&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;step&lt;/span&gt;).&lt;span style=&#34;color:#a6e22e&#34;&gt;children&lt;/span&gt;().&lt;span style=&#34;color:#a6e22e&#34;&gt;attr&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;id&amp;#39;&lt;/span&gt;);
&lt;span style=&#34;color:#75715e&#34;&gt;//get current form data to be passed later
&lt;/span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;var&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;curr&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;$&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;.stepSelected&amp;#34;&lt;/span&gt;).&lt;span style=&#34;color:#a6e22e&#34;&gt;children&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;:eq(1)&amp;#39;&lt;/span&gt;).&lt;span style=&#34;color:#a6e22e&#34;&gt;children&lt;/span&gt;().&lt;span style=&#34;color:#a6e22e&#34;&gt;attr&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;id&amp;#39;&lt;/span&gt;);
&lt;span style=&#34;color:#66d9ef&#34;&gt;var&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;formData&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;$&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;#form_&amp;#34;&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;+&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;curr&lt;/span&gt;).&lt;span style=&#34;color:#a6e22e&#34;&gt;serialize&lt;/span&gt;();
&lt;span style=&#34;color:#75715e&#34;&gt;//add class to selected step
&lt;/span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;$&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;#stepTable tr&amp;#34;&lt;/span&gt;).&lt;span style=&#34;color:#a6e22e&#34;&gt;removeClass&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;stepSelected&amp;#39;&lt;/span&gt;);
&lt;span style=&#34;color:#a6e22e&#34;&gt;$&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;step&lt;/span&gt;).&lt;span style=&#34;color:#a6e22e&#34;&gt;parent&lt;/span&gt;().&lt;span style=&#34;color:#a6e22e&#34;&gt;addClass&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;stepSelected&amp;#39;&lt;/span&gt;);
&lt;span style=&#34;color:#75715e&#34;&gt;//put name of step that is going to be edited
&lt;/span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;$&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;#formTitle&amp;#34;&lt;/span&gt;).&lt;span style=&#34;color:#a6e22e&#34;&gt;text&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;$&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;.stepSelected :eq(0)&amp;#34;&lt;/span&gt;).&lt;span style=&#34;color:#a6e22e&#34;&gt;text&lt;/span&gt;());
&lt;span style=&#34;color:#a6e22e&#34;&gt;$&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;.multiform_part&amp;#34;&lt;/span&gt;).&lt;span style=&#34;color:#a6e22e&#34;&gt;html&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Loading...&amp;#34;&lt;/span&gt;);
&lt;span style=&#34;color:#75715e&#34;&gt;//send data to php, and draw new form
&lt;/span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;$&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;post&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;processForm.php&amp;#39;&lt;/span&gt;, {
&lt;span style=&#34;color:#a6e22e&#34;&gt;step&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;thisStep&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;saveData&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;curr&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;formData&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;formData&lt;/span&gt;
}
,&lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;data&lt;/span&gt;) {
&lt;span style=&#34;color:#75715e&#34;&gt;//draw new form
&lt;/span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;$&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;.multiform_part&amp;#34;&lt;/span&gt;).&lt;span style=&#34;color:#a6e22e&#34;&gt;html&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;data&lt;/span&gt;);
}
);
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This was easy, then I just binded a click event to each step&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-javascript&#34; data-lang=&#34;javascript&#34;&gt;&lt;span style=&#34;color:#75715e&#34;&gt;// handle the edit link on each step
&lt;/span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;$&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;.stepEdit&amp;#34;&lt;/span&gt;).&lt;span style=&#34;color:#a6e22e&#34;&gt;each&lt;/span&gt;(&lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;index&lt;/span&gt;){
&lt;span style=&#34;color:#a6e22e&#34;&gt;$&lt;/span&gt;(&lt;span style=&#34;color:#66d9ef&#34;&gt;this&lt;/span&gt;).&lt;span style=&#34;color:#a6e22e&#34;&gt;click&lt;/span&gt;(&lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;e&lt;/span&gt;){
&lt;span style=&#34;color:#a6e22e&#34;&gt;selectStep&lt;/span&gt;(&lt;span style=&#34;color:#66d9ef&#34;&gt;this&lt;/span&gt;);
}
);
});
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;And now I have a functional multiform pane, that gets its form from php, the backend was also ver simple to make:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-php&#34; data-lang=&#34;php&#34;&gt;&lt;span style=&#34;color:#75715e&#34;&gt;&amp;lt;?php&lt;/span&gt;
&lt;span style=&#34;color:#a6e22e&#34;&gt;session_start&lt;/span&gt;();
$step &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; $_REQUEST[&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;step&amp;#39;&lt;/span&gt;];
$formData &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; $_REQUEST[&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;formData&amp;#39;&lt;/span&gt;];
&lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;save&lt;/span&gt;($step, $data) {
$fields &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;explode&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;&amp;amp;&amp;#39;&lt;/span&gt;,$data);
&lt;span style=&#34;color:#66d9ef&#34;&gt;foreach&lt;/span&gt; ($fields &lt;span style=&#34;color:#66d9ef&#34;&gt;as&lt;/span&gt; $field) {
$keyVal &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;explode&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;=&amp;#39;&lt;/span&gt;, $field);
$key &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;urldecode&lt;/span&gt;($keyVal[&lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt;]);
$val &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;urldecode&lt;/span&gt;($keyVal[&lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;]);
$_SESSION[$step][$key] &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; $val;
}
}
&lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; ($formData) {
$formStep &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; $_REQUEST[&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;saveData&amp;#39;&lt;/span&gt;];
&lt;span style=&#34;color:#a6e22e&#34;&gt;save&lt;/span&gt;($formStep, $_REQUEST[&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;formData&amp;#39;&lt;/span&gt;]);
}
&lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; ($step) {
&lt;span style=&#34;color:#66d9ef&#34;&gt;switch&lt;/span&gt; ($step) {
&lt;span style=&#34;color:#66d9ef&#34;&gt;case&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;formstep1&amp;#39;&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt;
$html &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;lt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;FORM&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; &amp;lt;form id=&amp;#34;form_{$step}&amp;#34; name=&amp;#34;form_{$step}&amp;#34;&amp;gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; &amp;lt;fieldset&amp;gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; &amp;lt;legend&amp;gt;Personal information&amp;lt;/legend&amp;gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; &amp;lt;div class=&amp;#34;fm-req&amp;#34;&amp;gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; &amp;lt;label for=&amp;#34;fm-firstname&amp;#34;&amp;gt;First name:&amp;lt;/label&amp;gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; &amp;lt;input name=&amp;#34;fm-firstname&amp;#34; id=&amp;#34;fm-firstname&amp;#34; type=&amp;#34;text&amp;#34; value=&amp;#34;{$_SESSION[$step][&amp;#39;fm-firstname&amp;#39;]}&amp;#34;/&amp;gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; &amp;lt;/div&amp;gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; &amp;lt;div class=&amp;#34;fm-opt&amp;#34;&amp;gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; &amp;lt;label for=&amp;#34;fm-middlename&amp;#34;&amp;gt;Middle name:&amp;lt;/label&amp;gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; &amp;lt;input id=&amp;#34;fm-middlename&amp;#34; name=&amp;#34;fm-middlename&amp;#34; type=&amp;#34;text&amp;#34; value=&amp;#34;{$_SESSION[$step][&amp;#39;fm-middlename&amp;#39;]}&amp;#34;/&amp;gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; &amp;lt;/div&amp;gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; &amp;lt;div class=&amp;#34;fm-req&amp;#34;&amp;gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; &amp;lt;label for=&amp;#34;fm-lastname&amp;#34;&amp;gt;Last name:&amp;lt;/label&amp;gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; &amp;lt;input name=&amp;#34;fm-lastname&amp;#34; id=&amp;#34;fm-lastname&amp;#34; type=&amp;#34;text&amp;#34; value=&amp;#34;{$_SESSION[$step][&amp;#39;fm-lastname&amp;#39;]}&amp;#34;/&amp;gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; &amp;lt;/div&amp;gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; &amp;lt;/fieldset&amp;gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; &amp;lt;/fieldset&amp;gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; &amp;lt;/form&amp;gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;FORM&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;echo&lt;/span&gt; $html;
&lt;span style=&#34;color:#66d9ef&#34;&gt;break&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;case&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;formstep2&amp;#39;&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt;
$html &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;lt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;FORM&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; &amp;lt;form id=&amp;#34;form_{$step}&amp;#34; name=&amp;#34;form_{$step}&amp;#34;&amp;gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;lt;fieldset&amp;gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;lt;legend&amp;gt;Address &amp;lt;/legend&amp;gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; &amp;lt;div class=&amp;#34;fm-opt&amp;#34;&amp;gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; &amp;lt;label for=&amp;#34;fm-addr&amp;#34;&amp;gt;Address:&amp;lt;/label&amp;gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; &amp;lt;input id=&amp;#34;fm-addr&amp;#34; name=&amp;#34;fm-addr&amp;#34; type=&amp;#34;text&amp;#34; value=&amp;#34;{$_SESSION[$step][&amp;#39;fm-addr&amp;#39;]}&amp;#34;/&amp;gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; &amp;lt;/div&amp;gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; &amp;lt;div class=&amp;#34;fm-opt&amp;#34;&amp;gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; &amp;lt;label for=&amp;#34;fm-city&amp;#34;&amp;gt;City or Town:&amp;lt;/label&amp;gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; &amp;lt;input id=&amp;#34;fm-city&amp;#34; name=&amp;#34;fm-city&amp;#34; type=&amp;#34;text&amp;#34; value=&amp;#34;{$_SESSION[$step][&amp;#39;fm-city&amp;#39;]}&amp;#34;/&amp;gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; &amp;lt;/div&amp;gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; &amp;lt;div class=&amp;#34;fm-opt&amp;#34;&amp;gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; &amp;lt;label for=&amp;#34;fm-state&amp;#34;&amp;gt;State:&amp;lt;/label&amp;gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; &amp;lt;input id=&amp;#34;fm-state&amp;#34; name=&amp;#34;fm-state&amp;#34; type=&amp;#34;text&amp;#34; value=&amp;#34;{$_SESSION[$step][&amp;#39;fm-state&amp;#39;]}&amp;#34;/&amp;gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; &amp;lt;/div&amp;gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; &amp;lt;div class=&amp;#34;fm-req&amp;#34;&amp;gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; &amp;lt;label for=&amp;#34;fm-zipcode&amp;#34;&amp;gt;Zip code:&amp;lt;/label&amp;gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; &amp;lt;input id=&amp;#34;fm-zipcode&amp;#34; name=&amp;#34;fm-zipcode&amp;#34; type=&amp;#34;text&amp;#34; value=&amp;#34;{$_SESSION[$step][&amp;#39;fm-zipcode&amp;#39;]}&amp;#34;/&amp;gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; &amp;lt;/div&amp;gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; &amp;lt;/fieldset&amp;gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;lt;/form&amp;gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;FORM&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;echo&lt;/span&gt; $html;
&lt;span style=&#34;color:#66d9ef&#34;&gt;break&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;case&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;formstep3&amp;#39;&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt;
$html &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;lt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;FORM&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; &amp;lt;form id=&amp;#34;form_{$step}&amp;#34; name=&amp;#34;form_{$step}&amp;#34;&amp;gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;lt;fieldset&amp;gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;lt;legend&amp;gt;Interests &amp;lt;/legend&amp;gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; &amp;lt;div class=&amp;#34;fm-opt&amp;#34;&amp;gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; &amp;lt;label for=&amp;#34;fm-int1&amp;#34;&amp;gt;Interest 1:&amp;lt;/label&amp;gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; &amp;lt;input id=&amp;#34;fm-int1&amp;#34; name=&amp;#34;fm-int1&amp;#34; type=&amp;#34;text&amp;#34; value=&amp;#34;{$_SESSION[$step][&amp;#39;fm-int1&amp;#39;]}&amp;#34;/&amp;gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; &amp;lt;/div&amp;gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; &amp;lt;div class=&amp;#34;fm-opt&amp;#34;&amp;gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; &amp;lt;label for=&amp;#34;fm-int2&amp;#34;&amp;gt;Interest 2:&amp;lt;/label&amp;gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; &amp;lt;input id=&amp;#34;fm-int2&amp;#34; name=&amp;#34;fm-int2&amp;#34; type=&amp;#34;text&amp;#34; value=&amp;#34;{$_SESSION[$step][&amp;#39;fm-int2&amp;#39;]}&amp;#34;/&amp;gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; &amp;lt;/div&amp;gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; &amp;lt;/fieldset&amp;gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;lt;/form&amp;gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;FORM&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;echo&lt;/span&gt; $html;
&lt;span style=&#34;color:#66d9ef&#34;&gt;break&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;case&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;getAllData&amp;#39;&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt;
&lt;span style=&#34;color:#66d9ef&#34;&gt;echo&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;&amp;lt;h3&amp;gt;Saved Data&amp;lt;/h3&amp;gt;&amp;#39;&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;echo&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;&amp;lt;div style=&amp;#34;text-align: left;&amp;#34;&amp;gt;&amp;lt;pre&amp;gt;&amp;#39;&lt;/span&gt;;
&lt;span style=&#34;color:#a6e22e&#34;&gt;print_r&lt;/span&gt;($_SESSION);
&lt;span style=&#34;color:#66d9ef&#34;&gt;echo&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;&amp;lt;/pre&amp;gt;&amp;lt;/div&amp;gt;&amp;#39;&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;break&lt;/span&gt;;
}
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Finally I&amp;#8217;ve added some css styles to make it &amp;#8220;pretty&amp;#8221; and add some other js functionality to navigate back and forth.&lt;/p&gt;
&lt;p&gt;You can checkout the working solution &lt;a href=&#34;#&#34;&gt;&lt;del&gt;here&lt;/del&gt;&lt;/a&gt;, or get the files &lt;a href=&#34;https://github.com/ivaano/dynamic_multiform_on_samepage&#34; rel=&#34;nofollow noreferrer&#34;&gt;here&lt;/a&gt; this demo saves user data in session, and the session is destroyed each time you load the index page.&lt;/p&gt;</description></item><item><title>Script to copy data from MySQL to postgreSQL</title><link>https://ivanvillareal.com/script-to-copy-data-from-mysql-to-postgres/</link><pubDate>Sat, 02 Apr 2011 12:28:32 +0000</pubDate><guid>https://ivanvillareal.com/script-to-copy-data-from-mysql-to-postgres/</guid><description>&lt;p&gt;This is a perl script I&amp;#8217;ve used to move data from mysql 5.1 to postgres 9, this script doesn&amp;#8217;t create a schema, it only grabs the data from mysql and try to put it on the same table in postgres.&lt;/p&gt;
&lt;p&gt;The only requirement is DBI for mysql and postgres.&lt;/p&gt;
&lt;pre lang=&#34;perl&#34;&gt;#!/usr/bin/perl
#
# this script moves all the data from mysql to postgres
# modules required are:
#
# http://search.cpan.org/~timb/DBI-1.616/DBI.pm
#
# please change the dsn, srcUser/srcPass and dstUser/Pass variables.
use DBI;
use strict;
my $srcUser = &#39;ivan&#39;;
my $srcPass = &#39;123&#39;;
my $srcDbName = &#39;datatocopy&#39;;
my $srcDbHost = &#39;mini&#39;;
my $dstUser = &#39;ivan&#39;;
my $dstPass = &#39;456&#39;;
my $dstDbName = &#39;migrateddata&#39;;
my $dstDbHost = &#39;192.168.1.145&#39;;
### do not modify ##
my $srcDb = DBI-&gt;connect(&#34;dbi:mysql:database=$srcDbName;host=$srcDbHost&#34;, $srcUser, $srcPass) or die;
my $dstDb = DBI-&gt;connect(&#34;dbi:Pg:database=$dstDbName;host=$dstDbHost&#34;, $dstUser, $dstPass) or die;
####main########
print &#34;Starting to move data from $srcDbHost to $dstDbHost\n&#34;;
$srcDb-&gt;do(&#34;SET NAMES \&#39;UTF8\&#39;&#34;);
$dstDb-&gt;do(&#34;SET CLIENT_ENCODING=\&#39;UTF8\&#39;&#34;) or die;
my $srcTables = $srcDb-&gt;selectall_arrayref(&#34;SHOW TABLES&#34;);
my $dstTables = $dstDb-&gt;selectall_hashref(&#34;SELECT * FROM pg_tables WHERE NOT tablename ~\&#39;^(pg_|sql_)\&#39;&#34;,&#34;tablename&#34;);
my $seqlist = $dstDb-&gt;selectall_arrayref(&#34;SELECT RELNAME FROM pg_class WHERE relkind=\&#39;S\&#39;&#34;);
my $seqmap;
foreach my $s(@$seqlist) {
my $seqname = $s-&gt;[0];
if ($seqname=~/^(.*)_([a-z]+)_([a-z]+$)/) {
my $item;
$item-&gt;{seq}=$seqname;
$item-&gt;{field}=$2;
my $table = $1;
if (exists $dstTables-&gt;{$table}) {
push @{$seqmap-&gt;{$table}},$item;
} else {
print STDERR &#34;WARN: cannot find table for sequence $seqname\n&#34;;
}
}
}
$dstDb-&gt;{AutoCommit}=0;
my $totalRowCount = 0;
foreach my $t(@$srcTables) {
my $table = $t-&gt;[0];
unless (exists $dstTables-&gt;{$table}) {
print STDERR &#34;WARN: table $table does not exists in dest db Pg:$dstDbName\n&#34;;
next;
}
print &#34;Clearing data from table $table in $dstDbHost\n&#34;;
clear_table($dstDb,$table);
next if $table=~/^cache/;
next if $table=~/^locales/;
print &#34;Copying data from mysql table $table in $srcDbHost to postgres table $table in $dstDbHost\n&#34;;
my $cnt = copy_table($srcDb,$dstDb,$table) unless $table=~/^cache/;
$totalRowCount = $totalRowCount + $cnt;
print &#34;$cnt rows copied ($table)\n&#34;;
init_seq($dstDb,$table,$seqmap-&gt;{$table}); # if (exists $seqmap-&gt;{$table});
}
print &#34;Commiting changes \n&#34;;
$dstDb-&gt;commit;
print &#34;$totalRowCount rows were copied.\n&#34;;
exit 0;
sub init_seq {
my ($db,$table,$list)=@_;
return unless $list;
for my $item (@{$list}) {
my $ref = $db-&gt;selectall_arrayref(&#34;SELECT MAX($item-&gt;{field}) FROM $table&#34;) or die;
my $val = $ref-&gt;[0]-&gt;[0];
if ($val) {
$db-&gt;do(&#34;SELECT SETVAL(\&#39;$item-&gt;{seq}\&#39;,$val)&#34;) or die;
}
}
}
sub clear_table {
my ($dbh,$table)=@_;
return unless $table;
$dbh-&gt;do(&#34;DELETE FROM $table&#34;) or die;
}
sub copy_table {
my ($srcDb,$dstDb,$table)=@_;
die unless $table;
my $slf = $srcDb-&gt;prepare(&#34;select * from $table limit 1&#34;);
my $rows = $slf-&gt;execute() or die;
return 0 if $rows &amp;lt; 1;
my $rec1 = $slf-&gt;fetchrow_hashref;
$slf-&gt;finish;
my @fieldnames = sort keys %$rec1;
my @qm = map { &#39;?&#39;} @fieldnames;
my $ins = $dstDb-&gt;prepare(&#34;INSERT INTO $table (&#34;.join(&#34;,&#34;,@fieldnames).&#34;) VALUES(&#34;.join(&#34;,&#34;,@qm).&#34;)&#34;);
my $sel = $srcDb-&gt;prepare(&#34;SELECT * FROM $table&#34;);
$sel-&gt;execute or die;
my $cnt = 0;
while (my $data = $sel-&gt;fetchrow_hashref) {
$ins-&gt;execute(map {$data-&gt;{$_}} @fieldnames) or die;
$cnt++;
}
$ins-&gt;finish;
$sel-&gt;finish;
return $cnt;
}
&lt;/pre&gt;</description></item><item><title>Use hotkeys for switching between dual monitors</title><link>https://ivanvillareal.com/use-hotkeys-for-switching-between-dual-monitors/</link><pubDate>Mon, 21 Mar 2011 18:46:57 +0000</pubDate><guid>https://ivanvillareal.com/use-hotkeys-for-switching-between-dual-monitors/</guid><description>&lt;p&gt;I just got 2 Asus ML228 wide-screen monitors, this is a big update from my previous monitors resolution that were 1280x760, and they were not wide-screen, so it took me a while to get used to these wide screen displays, I have them in Full HD via DVI to HDMI connector, and i&amp;rsquo;m using nVidia twinview instead of Xinerama because I can use compiz with twiview and not with Xinerama, the total display I get from both monitors is 3840x1080 pixels (966x272 millimeters), so I have to move my hand a lot to switch between one monitor and the other with the mouse, I also have my laptop on the left because that is were i have my chat and email apps, so to get there from the right screen I have to move even more my hand until I get to the end of the mousepad.&lt;/p&gt;
&lt;p&gt;A friend of mine recommend to use a program to switch between my two monitors with a hotkey, he told me the program he used for windows, I look for it, and I didnt found anything that could work in linux, because I was to busy I left that, until this past week where I just got tired to move from one window to another to check my tests, so I checked again what were my options, and again didnt found nothing that was simple to run.&lt;/p&gt;
&lt;p&gt;I knew that I could leverage the commands plugin from compiz to grab the hotkeys, I just needed a way to move the cursor, so I did a quick search in the aptitude repository&lt;/p&gt;
&lt;pre lang=&#34;bash&#34;&gt;ivan@orion:~$ apt-cache search input move&lt;/pre&gt;
&lt;p&gt;gave me this:&lt;/p&gt;
&lt;pre lang=&#34;bash&#34;&gt;xdotool - simulate X11 keyboard/mouse input
&lt;/pre&gt;
&lt;p&gt;That looked like the thing i was looking for, so i&amp;rsquo;ve installed &lt;code&gt;xdotool&lt;/code&gt; and started playing with it, i quickly found that this little tool has a lot of choices that can be used for many, many things, so what I did to achieve my goal was the following:&lt;/p&gt;
&lt;pre lang=&#34;bash&#34;&gt;ivan@orion:~$ xdotool --help
Available commands:
getactivewindow
getwindowfocus
getwindowpid
search
help
version
click
getmouselocation
key
keydown
keyup
mousedown
mousemove
mousemove_relative
mouseup
type
windowactivate
windowfocus
windowmap
windowmove
windowraise
windowsize
windowunmap
set_window
set_num_desktops
get_num_desktops
set_desktop
get_desktop
set_desktop_for_window
get_desktop_for_window
ivan@orion:~$ xdotool getmouselocation
x:379 y:361 screen:0
ivan@orion:~$ xdotool mousemove 800 200
&lt;/pre&gt;
&lt;p&gt;and with that my pointer moved to a random position 🙂 (800x200) I moved the mouse to the center of left screen and used &lt;code&gt;getmouselocation&lt;/code&gt; to get the screen coordinates, I did the same for right screen and with this parameters i&amp;rsquo;ve opened my compiz configuration and created the following 2 hotkeys:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://ivanvillareal.com/assets/2011-03-21-use-hotkeys-for-switching-between-dual-monitors/compiz-commands.png&#34; alt=&#34;Compiz Commands&#34; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://ivanvillareal.com/assets/2011-03-21-use-hotkeys-for-switching-between-dual-monitors/compiz-commands-key.png&#34; alt=&#34;Compiz Command Key&#34; /&gt;&lt;/p&gt;</description></item><item><title>Decrypting SourceCop php files</title><link>https://ivanvillareal.com/decrypting-sourcecop-php-files/</link><pubDate>Wed, 10 Feb 2010 19:41:46 +0000</pubDate><guid>https://ivanvillareal.com/decrypting-sourcecop-php-files/</guid><description>&lt;p&gt;Every once in a while, I receive code that is encrypted using one of many php encoder software out there, so when I face this situation and if the project is worth it, I start playing around with the encrypted files to see how the encoding algorithm works, so far I’ve been able to successful decrypt files encoded with Zend, and ioncube, I don’t remember the versions of the encoders but I remember that the latter one took me some time, but I decode the source.&lt;/p&gt;
&lt;p&gt;I must say that decoding files also becomes a personal challenge, it is like a hobby when I have the time to play with it.&lt;/p&gt;
&lt;p&gt;Yesterday I received a couple of files encoded with an unknown encoder for me, it didnt require any php modification or extension install, so I tough that it would be easy to break it, because at some point the code must be evaluated, so after I opened the zip file, I noticed a folder called “scopbin“, that contained only 1 php file named “911006.php“, the two encoded files were including this file so I assumed that this is were the decryption logic had to be.&lt;/p&gt;
&lt;p&gt;I was exhausted by a long working day, and when I got this files and saw that they were encrypted I placed them in my laptop for later analysis. This analysis was done the next day, I didnt research the encoding process, or did anything that give me some pointers, I just started playing around with the code to see how far I could get.&lt;/p&gt;
&lt;p&gt;My objective this time was getting this files decrypted, and not analysing the steps of the algorithm, so with this in mind, this is what I did:&lt;/p&gt;
&lt;p&gt;This was the original “911006.php” file:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-php&#34; data-lang=&#34;php&#34;&gt;&lt;span style=&#34;color:#75715e&#34;&gt;&amp;lt;?php&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;ini_set&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;include_path&amp;#39;&lt;/span&gt;,&lt;span style=&#34;color:#a6e22e&#34;&gt;dirname&lt;/span&gt;(&lt;span style=&#34;color:#66d9ef&#34;&gt;__FILE__&lt;/span&gt;));&lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;A4540acdeed38d4cd9084ade1739498&lt;/span&gt;($x897356954c2cd3d41b221e3f24f99bba,$x276e79316561733d64abdf00f8e8ae48){&lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; $Xew6e79316561733d64abdf00f8e8ae48;}&lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;b5434f0acdeed38d4cd9084ade1739498&lt;/span&gt;($x897356954c2cd3d41b221e3f24f99bba,$x276e79316561733d64abdf00f8e8ae48){&lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; $Xew6e79316561733d64abdf00f8e8ae48;}&lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;c43dsd0acdeed38d4cd9084ade1739498&lt;/span&gt;($x897356954c2cd3d41b221e3f24f99bba,$x276e79316561733d64abdf00f8e8ae48){&lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; $Xew6e79316561733d64abdf00f8e8ae48;}&lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;Xdsf0acdeed38d4cd9084ade1739498&lt;/span&gt;($x897356954c2cd3d41b221e3f24f99bba,$x276e79316561733d64abdf00f8e8ae48){&lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; $Xew6e79316561733d64abdf00f8e8ae48;}&lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;y0666f0acdeed38d4cd9084ade1739498&lt;/span&gt;($x897356954c2cd3d41b221e3f24f99bba,$x276e79316561733d64abdf00f8e8ae48){$x0b43c25ccf2340e23492d4d3141479dc&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;&amp;#39;&lt;/span&gt;;$x71510c08e23d2083eda280afa650b045&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt;;$x16754c94f2e48aae0d6f34280507be58&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;strlen&lt;/span&gt;($x897356954c2cd3d41b221e3f24f99bba);$x7a86c157ee9713c34fbd7a1ee40f0c5a&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;hexdec&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;&amp;amp;H&amp;#39;&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;substr&lt;/span&gt;($x276e79316561733d64abdf00f8e8ae48,&lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt;,&lt;span style=&#34;color:#ae81ff&#34;&gt;2&lt;/span&gt;));&lt;span style=&#34;color:#66d9ef&#34;&gt;for&lt;/span&gt;($x1b90e1035d4d268e0d8b1377f3dc85a2&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;2&lt;/span&gt;;$x1b90e1035d4d268e0d8b1377f3dc85a2&lt;span style=&#34;color:#f92672&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;strlen&lt;/span&gt;($x276e79316561733d64abdf00f8e8ae48);$x1b90e1035d4d268e0d8b1377f3dc85a2&lt;span style=&#34;color:#f92672&#34;&gt;+=&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;2&lt;/span&gt;){$xe594cc261a3b25a9c99ec79da9c91ba5&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;hexdec&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;trim&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;substr&lt;/span&gt;($x276e79316561733d64abdf00f8e8ae48, $x1b90e1035d4d268e0d8b1377f3dc85a2, &lt;span style=&#34;color:#ae81ff&#34;&gt;2&lt;/span&gt;)));$x71510c08e23d2083eda280afa650b045&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;(($x71510c08e23d2083eda280afa650b045&lt;span style=&#34;color:#f92672&#34;&gt;&amp;lt;&lt;/span&gt;$x16754c94f2e48aae0d6f34280507be58)&lt;span style=&#34;color:#f92672&#34;&gt;?&lt;/span&gt;$x71510c08e23d2083eda280afa650b045 &lt;span style=&#34;color:#f92672&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;);$xab6389e47b1edcf1a5267d9cfb513ce5&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;$xe594cc261a3b25a9c99ec79da9c91ba5 &lt;span style=&#34;color:#f92672&#34;&gt;^&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;ord&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;substr&lt;/span&gt;($x897356954c2cd3d41b221e3f24f99bba, $x71510c08e23d2083eda280afa650b045&lt;span style=&#34;color:#f92672&#34;&gt;-&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;, &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;));&lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt;($xab6389e47b1edcf1a5267d9cfb513ce5&lt;span style=&#34;color:#f92672&#34;&gt;&amp;lt;=&lt;/span&gt;$x7a86c157ee9713c34fbd7a1ee40f0c5a)$xab6389e47b1edcf1a5267d9cfb513ce5&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;255&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;+&lt;/span&gt;$xab6389e47b1edcf1a5267d9cfb513ce5&lt;span style=&#34;color:#f92672&#34;&gt;-&lt;/span&gt;$x7a86c157ee9713c34fbd7a1ee40f0c5a;&lt;span style=&#34;color:#66d9ef&#34;&gt;else&lt;/span&gt; $xab6389e47b1edcf1a5267d9cfb513ce5&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;$xab6389e47b1edcf1a5267d9cfb513ce5&lt;span style=&#34;color:#f92672&#34;&gt;-&lt;/span&gt;$x7a86c157ee9713c34fbd7a1ee40f0c5a;$x0b43c25ccf2340e23492d4d3141479dc&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;$x0b43c25ccf2340e23492d4d3141479dc&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;chr&lt;/span&gt;($xab6389e47b1edcf1a5267d9cfb513ce5);$x7a86c157ee9713c34fbd7a1ee40f0c5a&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;$xe594cc261a3b25a9c99ec79da9c91ba5;} &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; $x0b43c25ccf2340e23492d4d3141479dc;}&lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;f5434f0acdeed38d4cd9084ade1739498&lt;/span&gt;($x897356954c2cd3d41b221e3f24f99bba,$x276e79316561733d64abdf00f8e8ae48){&lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;file_exists&lt;/span&gt;($x456e79316561733d64abdf00f8e8ae48)){&lt;span style=&#34;color:#a6e22e&#34;&gt;unlink&lt;/span&gt;($x456e79316561733d64abdf00f8e8ae48);};&lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; $Xew6e79316561733d64abdf00f8e8ae48;}&lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;j43dsd0acdeed38d4cd9084ade1739498&lt;/span&gt;($x897356954c2cd3d41b221e3f24f99bba,$x276e79316561733d64abdf00f8e8ae48){&lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;file_exists&lt;/span&gt;($x456e79316561733d64abdf00f8e8ae48)){&lt;span style=&#34;color:#a6e22e&#34;&gt;unlink&lt;/span&gt;($x456e79316561733d64abdf00f8e8ae48);};&lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; $Xew6e79316561733d64abdf00f8e8ae48;}&lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;hdsf0acdeed38d4cd9084ade1739498&lt;/span&gt;($x897356954c2cd3d41b221e3f24f99bba,$x276e79316561733d64abdf00f8e8ae48){&lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;file_exists&lt;/span&gt;($x456e79316561733d64abdf00f8e8ae48)){&lt;span style=&#34;color:#a6e22e&#34;&gt;unlink&lt;/span&gt;($x456e79316561733d64abdf00f8e8ae48);};&lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; $Xew6e79316561733d64abdf00f8e8ae48;}&lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;tr5434f0acdeed38d4cd9084ade1739498&lt;/span&gt;($x897356954c2cd3d41b221e3f24f99bba,$x276e79316561733d64abdf00f8e8ae48){&lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;file_exists&lt;/span&gt;($x456e79316561733d64abdf00f8e8ae48)){&lt;span style=&#34;color:#a6e22e&#34;&gt;unlink&lt;/span&gt;($x456e79316561733d64abdf00f8e8ae48);};&lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; $Xew6e79316561733d64abdf00f8e8ae48;}&lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;f0666f0acdeed38d4cd9084ade1739498&lt;/span&gt;($x) { &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;implode&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;&amp;#39;&lt;/span&gt;,&lt;span style=&#34;color:#a6e22e&#34;&gt;file&lt;/span&gt;($x));} &lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;g0666f0acdeed38d4cd9084ade1739498&lt;/span&gt;($s){&lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;strstr&lt;/span&gt;($s,&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;echo&amp;#39;&lt;/span&gt;)&lt;span style=&#34;color:#f92672&#34;&gt;==&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;false&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;?&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;strstr&lt;/span&gt;($s,&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;print&amp;#39;&lt;/span&gt;)&lt;span style=&#34;color:#f92672&#34;&gt;==&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;false&lt;/span&gt;)&lt;span style=&#34;color:#f92672&#34;&gt;?&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;strstr&lt;/span&gt;($s,&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;sprint&amp;#39;&lt;/span&gt;)&lt;span style=&#34;color:#f92672&#34;&gt;==&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;false&lt;/span&gt;)&lt;span style=&#34;color:#f92672&#34;&gt;?&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;strstr&lt;/span&gt;($s,&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;sprintf&amp;#39;&lt;/span&gt;)&lt;span style=&#34;color:#f92672&#34;&gt;==&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;false&lt;/span&gt;)&lt;span style=&#34;color:#f92672&#34;&gt;?&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;false&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;exit&lt;/span&gt;()&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;exit&lt;/span&gt;()&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;exit&lt;/span&gt;()&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;exit&lt;/span&gt;());}&lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;hyr3dsd0acdeed38d4cd9084ade1739498&lt;/span&gt;($x897356954c2cd3d41b221e3f24f99bba,$x276e79316561733d64abdf00f8e8ae48){&lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;file_exists&lt;/span&gt;($x456e79316561733d64abdf00f8e8ae48)){&lt;span style=&#34;color:#a6e22e&#34;&gt;unlink&lt;/span&gt;($x456e79316561733d64abdf00f8e8ae48);};&lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; $Xew6e79316561733d64abdf00f8e8ae48;}&lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;uygf0acdeed38d4cd9084ade1739498&lt;/span&gt;($x897356954c2cd3d41b221e3f24f99bba,$x276e79316561733d64abdf00f8e8ae48){&lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;file_exists&lt;/span&gt;($x456e79316561733d64abdf00f8e8ae48)){&lt;span style=&#34;color:#a6e22e&#34;&gt;unlink&lt;/span&gt;($x456e79316561733d64abdf00f8e8ae48);};&lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; $Xew6e79316561733d64abdf00f8e8ae48;}&lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;drfg34f0acdeed38d4cd9084ade1739498&lt;/span&gt;($x897356954c2cd3d41b221e3f24f99bba,$x276e79316561733d64abdf00f8e8ae48){&lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;file_exists&lt;/span&gt;($x456e79316561733d64abdf00f8e8ae48)){&lt;span style=&#34;color:#a6e22e&#34;&gt;unlink&lt;/span&gt;($x456e79316561733d64abdf00f8e8ae48);};&lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; $Xew6e79316561733d64abdf00f8e8ae48;}&lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;jhkgvdsd0acdeed38d4cd9084ade1739498&lt;/span&gt;($x897356954c2cd3d41b221e3f24f99bba,$x276e79316561733d64abdf00f8e8ae48){&lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;file_exists&lt;/span&gt;($x456e79316561733d64abdf00f8e8ae48)){&lt;span style=&#34;color:#a6e22e&#34;&gt;unlink&lt;/span&gt;($x456e79316561733d64abdf00f8e8ae48);};&lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; $Xew6e79316561733d64abdf00f8e8ae48;}&lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;yrdhhdacdeed38d4cd9084ade1739498&lt;/span&gt;($x897356954c2cd3d41b221e3f24f99bba,$x276e79316561733d64abdf00f8e8ae48){&lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;file_exists&lt;/span&gt;($x456e79316561733d64abdf00f8e8ae48)){&lt;span style=&#34;color:#a6e22e&#34;&gt;unlink&lt;/span&gt;($x456e79316561733d64abdf00f8e8ae48);};&lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; $Xew6e79316561733d64abdf00f8e8ae48;} &lt;span style=&#34;color:#a6e22e&#34;&gt;ini_set&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;include_path&amp;#39;&lt;/span&gt;,&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;.&amp;#39;&lt;/span&gt;);
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;I’ve used a code formatter to make the code more readable:&lt;/p&gt;
&lt;pre lang=&#34;bash&#34;&gt;
ivan@mini:/var/www/copdecrypt/scopbin$ phpCB --space-after-if \
--space-after-switch \
--space-after-while \
--space-before-srt-angle-bracket \
--space-after-end-angle-bracket \
--glue-amperscore \
--change-shell-comment-to-double-slashes-comment \
--force-large-php-code-tag \
--force-true-false-null-contant-lowercase \
--align-equal-statements \
--comment-rendering-style PEAR \
--equal-align-position 50 \
--padding-char-count 4 \
911006.php
&lt;/pre&gt;
&lt;p&gt;And this was the result:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-php&#34; data-lang=&#34;php&#34;&gt;&lt;span style=&#34;color:#75715e&#34;&gt;&amp;lt;?php&lt;/span&gt;
&lt;span style=&#34;color:#a6e22e&#34;&gt;ini_set&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;include_path&amp;#39;&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;dirname&lt;/span&gt;(&lt;span style=&#34;color:#66d9ef&#34;&gt;__FILE__&lt;/span&gt;));
&lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;A4540acdeed38d4cd9084ade1739498&lt;/span&gt;($x897356954c2cd3d41b221e3f24f99bba, $x276e79316561733d64abdf00f8e8ae48) {
&lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; $Xew6e79316561733d64abdf00f8e8ae48;
}
&lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;b5434f0acdeed38d4cd9084ade1739498&lt;/span&gt;($x897356954c2cd3d41b221e3f24f99bba, $x276e79316561733d64abdf00f8e8ae48) {
&lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; $Xew6e79316561733d64abdf00f8e8ae48;
}
&lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;c43dsd0acdeed38d4cd9084ade1739498&lt;/span&gt;($x897356954c2cd3d41b221e3f24f99bba, $x276e79316561733d64abdf00f8e8ae48) {
&lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; $Xew6e79316561733d64abdf00f8e8ae48;
}
&lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;Xdsf0acdeed38d4cd9084ade1739498&lt;/span&gt;($x897356954c2cd3d41b221e3f24f99bba, $x276e79316561733d64abdf00f8e8ae48) {
&lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; $Xew6e79316561733d64abdf00f8e8ae48;
}
&lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;y0666f0acdeed38d4cd9084ade1739498&lt;/span&gt;($x897356954c2cd3d41b221e3f24f99bba, $x276e79316561733d64abdf00f8e8ae48) {
$x0b43c25ccf2340e23492d4d3141479dc &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;&amp;#39;&lt;/span&gt;;
$x71510c08e23d2083eda280afa650b045 &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt;;
$x16754c94f2e48aae0d6f34280507be58 &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;strlen&lt;/span&gt;($x897356954c2cd3d41b221e3f24f99bba);
$x7a86c157ee9713c34fbd7a1ee40f0c5a &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;hexdec&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;&amp;amp;H&amp;#39;&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;substr&lt;/span&gt;($x276e79316561733d64abdf00f8e8ae48, &lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt;, &lt;span style=&#34;color:#ae81ff&#34;&gt;2&lt;/span&gt;));
&lt;span style=&#34;color:#66d9ef&#34;&gt;for&lt;/span&gt;($x1b90e1035d4d268e0d8b1377f3dc85a2 &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;2&lt;/span&gt;;$x1b90e1035d4d268e0d8b1377f3dc85a2 &lt;span style=&#34;color:#f92672&#34;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;strlen&lt;/span&gt;($x276e79316561733d64abdf00f8e8ae48);$x1b90e1035d4d268e0d8b1377f3dc85a2 &lt;span style=&#34;color:#f92672&#34;&gt;+=&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;2&lt;/span&gt;) {
$xe594cc261a3b25a9c99ec79da9c91ba5 &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;hexdec&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;trim&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;substr&lt;/span&gt;($x276e79316561733d64abdf00f8e8ae48, $x1b90e1035d4d268e0d8b1377f3dc85a2, &lt;span style=&#34;color:#ae81ff&#34;&gt;2&lt;/span&gt;)));
$x71510c08e23d2083eda280afa650b045 &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; (($x71510c08e23d2083eda280afa650b045 &lt;span style=&#34;color:#f92672&#34;&gt;&amp;lt;&lt;/span&gt; $x16754c94f2e48aae0d6f34280507be58)&lt;span style=&#34;color:#f92672&#34;&gt;?&lt;/span&gt;$x71510c08e23d2083eda280afa650b045 &lt;span style=&#34;color:#f92672&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;);
$xab6389e47b1edcf1a5267d9cfb513ce5 &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; $xe594cc261a3b25a9c99ec79da9c91ba5 &lt;span style=&#34;color:#f92672&#34;&gt;^&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;ord&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;substr&lt;/span&gt;($x897356954c2cd3d41b221e3f24f99bba, $x71510c08e23d2083eda280afa650b045&lt;span style=&#34;color:#f92672&#34;&gt;-&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;, &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;));
&lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; ($xab6389e47b1edcf1a5267d9cfb513ce5 &lt;span style=&#34;color:#f92672&#34;&gt;&amp;lt;=&lt;/span&gt; $x7a86c157ee9713c34fbd7a1ee40f0c5a)$xab6389e47b1edcf1a5267d9cfb513ce5 &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;255&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;+&lt;/span&gt; $xab6389e47b1edcf1a5267d9cfb513ce5 &lt;span style=&#34;color:#f92672&#34;&gt;-&lt;/span&gt; $x7a86c157ee9713c34fbd7a1ee40f0c5a;
&lt;span style=&#34;color:#66d9ef&#34;&gt;else&lt;/span&gt; $xab6389e47b1edcf1a5267d9cfb513ce5 &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; $xab6389e47b1edcf1a5267d9cfb513ce5 &lt;span style=&#34;color:#f92672&#34;&gt;-&lt;/span&gt; $x7a86c157ee9713c34fbd7a1ee40f0c5a;
$x0b43c25ccf2340e23492d4d3141479dc &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; $x0b43c25ccf2340e23492d4d3141479dc &lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;chr&lt;/span&gt;($xab6389e47b1edcf1a5267d9cfb513ce5);
$x7a86c157ee9713c34fbd7a1ee40f0c5a &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; $xe594cc261a3b25a9c99ec79da9c91ba5;
}
&lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; $x0b43c25ccf2340e23492d4d3141479dc;
}
&lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;f5434f0acdeed38d4cd9084ade1739498&lt;/span&gt;($x897356954c2cd3d41b221e3f24f99bba, $x276e79316561733d64abdf00f8e8ae48) {
&lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;file_exists&lt;/span&gt;($x456e79316561733d64abdf00f8e8ae48)) {
&lt;span style=&#34;color:#a6e22e&#34;&gt;unlink&lt;/span&gt;($x456e79316561733d64abdf00f8e8ae48);
} ;
&lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; $Xew6e79316561733d64abdf00f8e8ae48;
}
&lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;j43dsd0acdeed38d4cd9084ade1739498&lt;/span&gt;($x897356954c2cd3d41b221e3f24f99bba, $x276e79316561733d64abdf00f8e8ae48) {
&lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;file_exists&lt;/span&gt;($x456e79316561733d64abdf00f8e8ae48)) {
&lt;span style=&#34;color:#a6e22e&#34;&gt;unlink&lt;/span&gt;($x456e79316561733d64abdf00f8e8ae48);
} ;
&lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; $Xew6e79316561733d64abdf00f8e8ae48;
}
&lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;hdsf0acdeed38d4cd9084ade1739498&lt;/span&gt;($x897356954c2cd3d41b221e3f24f99bba, $x276e79316561733d64abdf00f8e8ae48) {
&lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;file_exists&lt;/span&gt;($x456e79316561733d64abdf00f8e8ae48)) {
&lt;span style=&#34;color:#a6e22e&#34;&gt;unlink&lt;/span&gt;($x456e79316561733d64abdf00f8e8ae48);
} ;
&lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; $Xew6e79316561733d64abdf00f8e8ae48;
}
&lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;tr5434f0acdeed38d4cd9084ade1739498&lt;/span&gt;($x897356954c2cd3d41b221e3f24f99bba, $x276e79316561733d64abdf00f8e8ae48) {
&lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;file_exists&lt;/span&gt;($x456e79316561733d64abdf00f8e8ae48)) {
&lt;span style=&#34;color:#a6e22e&#34;&gt;unlink&lt;/span&gt;($x456e79316561733d64abdf00f8e8ae48);
} ;
&lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; $Xew6e79316561733d64abdf00f8e8ae48;
}
&lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;f0666f0acdeed38d4cd9084ade1739498&lt;/span&gt;($x) {
&lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;implode&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;&amp;#39;&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;file&lt;/span&gt;($x));
}
&lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;g0666f0acdeed38d4cd9084ade1739498&lt;/span&gt;($s) {
&lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;strstr&lt;/span&gt;($s, &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;echo&amp;#39;&lt;/span&gt;) &lt;span style=&#34;color:#f92672&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;false&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;?&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;strstr&lt;/span&gt;($s, &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;print&amp;#39;&lt;/span&gt;) &lt;span style=&#34;color:#f92672&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;false&lt;/span&gt;)&lt;span style=&#34;color:#f92672&#34;&gt;?&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;strstr&lt;/span&gt;($s, &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;sprint&amp;#39;&lt;/span&gt;) &lt;span style=&#34;color:#f92672&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;false&lt;/span&gt;)&lt;span style=&#34;color:#f92672&#34;&gt;?&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;strstr&lt;/span&gt;($s, &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;sprintf&amp;#39;&lt;/span&gt;) &lt;span style=&#34;color:#f92672&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;false&lt;/span&gt;)&lt;span style=&#34;color:#f92672&#34;&gt;?&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;false&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;exit&lt;/span&gt;()&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;exit&lt;/span&gt;()&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;exit&lt;/span&gt;()&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;exit&lt;/span&gt;());
}
&lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;hyr3dsd0acdeed38d4cd9084ade1739498&lt;/span&gt;($x897356954c2cd3d41b221e3f24f99bba, $x276e79316561733d64abdf00f8e8ae48) {
&lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;file_exists&lt;/span&gt;($x456e79316561733d64abdf00f8e8ae48)) {
&lt;span style=&#34;color:#a6e22e&#34;&gt;unlink&lt;/span&gt;($x456e79316561733d64abdf00f8e8ae48);
} ;
&lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; $Xew6e79316561733d64abdf00f8e8ae48;
}
&lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;uygf0acdeed38d4cd9084ade1739498&lt;/span&gt;($x897356954c2cd3d41b221e3f24f99bba, $x276e79316561733d64abdf00f8e8ae48) {
&lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;file_exists&lt;/span&gt;($x456e79316561733d64abdf00f8e8ae48)) {
&lt;span style=&#34;color:#a6e22e&#34;&gt;unlink&lt;/span&gt;($x456e79316561733d64abdf00f8e8ae48);
} ;
&lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; $Xew6e79316561733d64abdf00f8e8ae48;
}
&lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;drfg34f0acdeed38d4cd9084ade1739498&lt;/span&gt;($x897356954c2cd3d41b221e3f24f99bba, $x276e79316561733d64abdf00f8e8ae48) {
&lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;file_exists&lt;/span&gt;($x456e79316561733d64abdf00f8e8ae48)) {
&lt;span style=&#34;color:#a6e22e&#34;&gt;unlink&lt;/span&gt;($x456e79316561733d64abdf00f8e8ae48);
} ;
&lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; $Xew6e79316561733d64abdf00f8e8ae48;
}
&lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;jhkgvdsd0acdeed38d4cd9084ade1739498&lt;/span&gt;($x897356954c2cd3d41b221e3f24f99bba, $x276e79316561733d64abdf00f8e8ae48) {
&lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;file_exists&lt;/span&gt;($x456e79316561733d64abdf00f8e8ae48)) {
&lt;span style=&#34;color:#a6e22e&#34;&gt;unlink&lt;/span&gt;($x456e79316561733d64abdf00f8e8ae48);
} ;
&lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; $Xew6e79316561733d64abdf00f8e8ae48;
}
&lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;yrdhhdacdeed38d4cd9084ade1739498&lt;/span&gt;($x897356954c2cd3d41b221e3f24f99bba, $x276e79316561733d64abdf00f8e8ae48) {
&lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;file_exists&lt;/span&gt;($x456e79316561733d64abdf00f8e8ae48)) {
&lt;span style=&#34;color:#a6e22e&#34;&gt;unlink&lt;/span&gt;($x456e79316561733d64abdf00f8e8ae48);
} ;
&lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; $Xew6e79316561733d64abdf00f8e8ae48;
}
&lt;span style=&#34;color:#a6e22e&#34;&gt;ini_set&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;include_path&amp;#39;&lt;/span&gt;, &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;.&amp;#39;&lt;/span&gt;);
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;After a quick review of this file, I saw that it had several functions with the same logic, return an unknow variable or delete the file that this unknown variable had, appart from all this “useless” functions I quickly found what appeared to be the decryption function this was the function named &lt;strong&gt;y0666f0acdeed38d4cd9084ade1739498&lt;/strong&gt; with this information I ran a quick check by passing the content of one of the encrypted files, and this is the response I got from that function:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-php&#34; data-lang=&#34;php&#34;&gt;&lt;span style=&#34;color:#75715e&#34;&gt;&amp;lt;?php&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt;(&lt;span style=&#34;color:#f92672&#34;&gt;!&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;function_exists&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;findsysfolder&amp;#39;&lt;/span&gt;)){&lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;findsysfolder&lt;/span&gt;($fld){$fld1&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;dirname&lt;/span&gt;($fld);$fld&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;$fld1&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;/scopbin&amp;#39;&lt;/span&gt;;&lt;span style=&#34;color:#a6e22e&#34;&gt;clearstatcache&lt;/span&gt;();&lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt;(&lt;span style=&#34;color:#f92672&#34;&gt;!&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;is_dir&lt;/span&gt;($fld))&lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;findsysfolder&lt;/span&gt;($fld1);&lt;span style=&#34;color:#66d9ef&#34;&gt;else&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; $fld;}}&lt;span style=&#34;color:#66d9ef&#34;&gt;require_once&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;findsysfolder&lt;/span&gt;(&lt;span style=&#34;color:#66d9ef&#34;&gt;__FILE__&lt;/span&gt;)&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;/911006.php&amp;#39;&lt;/span&gt;);$REXISTHECAT4FBI&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;FE50E574D754E76AC679F242F450F768FB5DCB77F34DE341 660C280D176E374DE7FB3B090A782B6B68DBC97BEAD93B681C452F25BE26&amp;#39;&lt;/span&gt;;&lt;span style=&#34;color:#a6e22e&#34;&gt;g0666f0acdeed38d4cd9084ade1739498&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;f0666f0acdeed38d4cd9084ade1739498&lt;/span&gt;(&lt;span style=&#34;color:#66d9ef&#34;&gt;__FILE__&lt;/span&gt;));$REXISTHEDOG4FBI&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;9CEF6BE117B329ADFC4560538EBF16BB6DAD1748FE354E8EDA7AABFA376EB6938496F43560E4123D85D272E342E363FD51F3181763A3F623 660B6E2369243EE5781CD76A133E272E37DACA198968397F150425B4326A126CD64F051F35287DE7BD3 5354276B880BDEF525247533610 64282D07BA63861F81DB715C115BC1BD57FC5D9C8 225D2 A F177EDC7EA026A7E74D37AC28A125D1B8F73B63C6D1C3A1E137639BEECEDACFDBBD9F8D948CE93D6FCDCDD8CCA98B36AA21A08B8BD87FD8 15143C2C2D37593B82857516FC9ABF9237BDEC9DBB9F92F7BDEB8EE3B6AEA153C9DF3 A2CAE2CD218B1E566C0D274D6 F32DC2A E20 512 062A2F72C 96FB9ED3B6FC9ABF927A34985CAB5D3 65D89B315B3E61076D8 E4488B2127FCEF82C78DDBBED3A6FBB7FCEEACEE04453412363B6E246F05086C7 52E C408CC263E078A53461E0 331B71EB81DC475DB6CAC9531914393D4 22AC9C3D7CE7194438AD638 03D6FCDCDD8CCA98F99211B1177D5C7DEC6A3F427 5 510 461C7D1C51AB492F850FA56FE445EC0154885BDACDC 819BD76A72A419A4D859CFE5A5268CDABFD2A7FAB8DEF227BA3869183E12277A386E03763B6E241F75282CDBFCA187ECE74D7 D1D4881D3C7432177D4 E3F83DA54417EAA8FE93C68BDE94C2E7CA5FD5B4C5E3C9993A98CEA3D69BCE84F2D989C9EEECFDDBFFF15 164C2D471D3 228D3 51CBA75D4 A3C85C1 4618EC5 E6BE91FCD F4D87BE F 56BFB5BFE2A3EA923BDDDBB9D26BE13CD 41F6E584D593C1A C18 D19D29D958C94F12577D5D5C0D4B19781958094F21EB6EF20CC77D87CD0CDC57FA13D8484F61076D47ED5 366F521A6FA2FEFBAF22772A680E23168B0958290F23366B297F12470A5F1543664EF6DA42DAD5E5EB718C569EA2C5F8AE81BBF16BE489E3EE13D7FBD98FE297DA8FC5B396BB2EA4E594B2969D3C7689230A1F4441763B1E83114 31173B3E6331670A6F22672D4B6E43C64C1D6C475FA5AFB2BDF36A83F9F55F8 62A C69BEEC4F4F5A4E2B D1B F1A E68CAD86F44 B1C E6CACF92E B6DDCDDD26437 3&amp;#39;&lt;/span&gt;;$REXISTHECAT4FBI&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;94CD76CD371C5A7BC70C186E779C293B9B49BACA5A781A6&amp;#39;&lt;/span&gt;; &lt;span style=&#34;color:#66d9ef&#34;&gt;eval&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;y0666f0acdeed38d4cd9084ade1739498&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;4EF6454FB298E72B 5&amp;#39;&lt;/span&gt;,$REXISTHEDOG4FBI));&lt;span style=&#34;color:#75715e&#34;&gt;?&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Again I used the code beautifier to make the file more readable:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-php&#34; data-lang=&#34;php&#34;&gt;&lt;span style=&#34;color:#75715e&#34;&gt;&amp;lt;?php&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#f92672&#34;&gt;!&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;function_exists&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;findsysfolder&amp;#39;&lt;/span&gt;)) {
&lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;findsysfolder&lt;/span&gt;($fld) {
$fld1 &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;dirname&lt;/span&gt;($fld);
$fld &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; $fld1 &lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;/scopbin&amp;#39;&lt;/span&gt;;
&lt;span style=&#34;color:#a6e22e&#34;&gt;clearstatcache&lt;/span&gt;();
&lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#f92672&#34;&gt;!&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;is_dir&lt;/span&gt;($fld))&lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;findsysfolder&lt;/span&gt;($fld1);
&lt;span style=&#34;color:#66d9ef&#34;&gt;else&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; $fld;
}
}
&lt;span style=&#34;color:#66d9ef&#34;&gt;require_once&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;findsysfolder&lt;/span&gt;(&lt;span style=&#34;color:#66d9ef&#34;&gt;__FILE__&lt;/span&gt;) &lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;/911006.php&amp;#39;&lt;/span&gt;);
$REXISTHECAT4FBI &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;FE50E574D754E76AC679F242F450F768FB5DCB77F34DE341 660C280D176E374DE7FB3B090A782B6B68DBC97BEAD93B681C452F25BE26&amp;#39;&lt;/span&gt;;
&lt;span style=&#34;color:#a6e22e&#34;&gt;g0666f0acdeed38d4cd9084ade1739498&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;f0666f0acdeed38d4cd9084ade1739498&lt;/span&gt;(&lt;span style=&#34;color:#66d9ef&#34;&gt;__FILE__&lt;/span&gt;));
$REXISTHEDOG4FBI &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;9CEF6BE117B329ADFC4560538EBF16BB6DAD1748FE354E8EDA7AABFA376EB6938496F43560E4123D85D272E342E363FD51F3181763A3F623 660B6E2369243EE5781CD76A133E272E37DACA198968397F150425B4326A126CD64F051F35287DE7BD3 5354276B880BDEF525247533610 64282D07BA63861F81DB715C115BC1BD57FC5D9C8 225D2 A F177EDC7EA026A7E74D37AC28A125D1B8F73B63C6D1C3A1E137639BEECEDACFDBBD9F8D948CE93D6FCDCDD8CCA98B36AA21A08B8BD87FD8 15143C2C2D37593B82857516FC9ABF9237BDEC9DBB9F92F7BDEB8EE3B6AEA153C9DF3 A2CAE2CD218B1E566C0D274D6 F32DC2A E20 512 062A2F72C 96FB9ED3B6FC9ABF927A34985CAB5D3 65D89B315B3E61076D8 E4488B2127FCEF82C78DDBBED3A6FBB7FCEEACEE04453412363B6E246F05086C7 52E C408CC263E078A53461E0 331B71EB81DC475DB6CAC9531914393D4 22AC9C3D7CE7194438AD638 03D6FCDCDD8CCA98F99211B1177D5C7DEC6A3F427 5 510 461C7D1C51AB492F850FA56FE445EC0154885BDACDC 819BD76A72A419A4D859CFE5A5268CDABFD2A7FAB8DEF227BA3869183E12277A386E03763B6E241F75282CDBFCA187ECE74D7 D1D4881D3C7432177D4 E3F83DA54417EAA8FE93C68BDE94C2E7CA5FD5B4C5E3C9993A98CEA3D69BCE84F2D989C9EEECFDDBFFF15 164C2D471D3 228D3 51CBA75D4 A3C85C1 4618EC5 E6BE91FCD F4D87BE F 56BFB5BFE2A3EA923BDDDBB9D26BE13CD 41F6E584D593C1A C18 D19D29D958C94F12577D5D5C0D4B19781958094F21EB6EF20CC77D87CD0CDC57FA13D8484F61076D47ED5 366F521A6FA2FEFBAF22772A680E23168B0958290F23366B297F12470A5F1543664EF6DA42DAD5E5EB718C569EA2C5F8AE81BBF16BE489E3EE13D7FBD98FE297DA8FC5B396BB2EA4E594B2969D3C7689230A1F4441763B1E83114 31173B3E6331670A6F22672D4B6E43C64C1D6C475FA5AFB2BDF36A83F9F55F8 62A C69BEEC4F4F5A4E2B D1B F1A E68CAD86F44 B1C E6CACF92E B6DDCDDD26437 3&amp;#39;&lt;/span&gt;;
$REXISTHECAT4FBI &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;94CD76CD371C5A7BC70C186E779C293B9B49BACA5A781A6&amp;#39;&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;eval&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;y0666f0acdeed38d4cd9084ade1739498&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;4EF6454FB298E72B 5&amp;#39;&lt;/span&gt;, $REXISTHEDOG4FBI));
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;So what we have here is more obfuscated code, but a simple to understand, we have 2 variables and 3 functions, the variable that has the encrypted code should be the larger one so In the above file I&amp;rsquo;m assuming that is the &lt;strong&gt;&amp;rdquo;$REXISTHEDOG4FBI&amp;rdquo;&lt;/strong&gt; variable, the other one apparently isn&amp;rsquo;t used, so what I did at this point was to print the results of the evaluated function which corresponds to the function where the decrypt logic is (below is the decryption function deobfuscated):&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-php&#34; data-lang=&#34;php&#34;&gt;function ($key, $program) {
$result = &amp;#39;&amp;#39;;
$position = 0;
$keyLength = strlen($key);
$decValue = hexdec(&amp;#39;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&amp;amp;&lt;/span&gt;H&amp;#39; . substr($program, 0, 2));
for($i = 2;$i &amp;amp;lt; strlen($program);$i += 2) {
$decProgram = hexdec(trim(substr($program, $i, 2)));
$position = (($position &amp;amp;lt; $keyLength) ? $position + 1 : 1);
$ascii = $decProgram^ ord(substr($key, $position-1, 1));
if ($ascii &amp;amp;lt;= $decValue) $ascii = 255 + $ascii - $decValue;
else $ascii = $ascii - $decValue;
$result = $result . chr($ascii);
$decValue = $decProgram;
}
return $result;
} &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;unfortunately printing the result didn&amp;rsquo;t work, so I did a review to check why, and I found that the other 2 functions where the problem, let me explain what happens, first a call is made to:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-php&#34; data-lang=&#34;php&#34;&gt;function f0666f0acdeed38d4cd9084ade1739498($x) {
return implode(&amp;#39;&amp;#39;, file($x));
}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;this function receives the name of the executing file (test.php in my case), read its content in an array, then glues all lines to create a 1 line string, without any new lines, then this result is passed to the following function:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-php&#34; data-lang=&#34;php&#34;&gt;function g0666f0acdeed38d4cd9084ade1739498($s) {
return (strstr($s, &amp;#39;echo&amp;#39;) == false ? (strstr($s, &amp;#39;print&amp;#39;) == false) ? (strstr($s, &amp;#39;sprint&amp;#39;) == false) ? (strstr($s, &amp;#39;sprintf&amp;#39;) == false) ? false : exit() : exit() : exit() : exit());
}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;which are a series of nested ternary conditions, looking for the words &amp;#8220;echo,print,sprint,sprintf&amp;#8221;, if any of this words are in the encrypted file, then the script simply exits, that&amp;#8217;s why I was unable to print the decrypted code after calling the decoding function, so simply avoiding the call to this function will fix the issue and I will get the decrypted code.&lt;/p&gt;
&lt;p&gt;However, I didnt want to modify the original encrypted files, so a second approach I took was to modify the decryption function and printing the output from there, so I&amp;rsquo;ve added a couple of lines (15 and 16) to the &amp;#8220;&lt;strong&gt;y0666f0acdeed38d4cd9084ade1739498&lt;/strong&gt;&amp;#8221; function:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-php&#34; data-lang=&#34;php&#34;&gt;function y0666f0acdeed38d4cd9084ade1739498($x897356954c2cd3d41b221e3f24f99bba, $x276e79316561733d64abdf00f8e8ae48) {
$x0b43c25ccf2340e23492d4d3141479dc = &amp;#39;&amp;#39;;
$x71510c08e23d2083eda280afa650b045 = 0;
$x16754c94f2e48aae0d6f34280507be58 = strlen($x897356954c2cd3d41b221e3f24f99bba);
$x7a86c157ee9713c34fbd7a1ee40f0c5a = hexdec(&amp;#39;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&amp;amp;&lt;/span&gt;H&amp;#39; . substr($x276e79316561733d64abdf00f8e8ae48, 0, 2));
for($x1b90e1035d4d268e0d8b1377f3dc85a2 = 2;$x1b90e1035d4d268e0d8b1377f3dc85a2 &amp;amp;lt; strlen($x276e79316561733d64abdf00f8e8ae48);$x1b90e1035d4d268e0d8b1377f3dc85a2 += 2) {
$xe594cc261a3b25a9c99ec79da9c91ba5 = hexdec(trim(substr($x276e79316561733d64abdf00f8e8ae48, $x1b90e1035d4d268e0d8b1377f3dc85a2, 2)));
$x71510c08e23d2083eda280afa650b045 = (($x71510c08e23d2083eda280afa650b045 &amp;amp;lt; $x16754c94f2e48aae0d6f34280507be58)?$x71510c08e23d2083eda280afa650b045 + 1:1);
$xab6389e47b1edcf1a5267d9cfb513ce5 = $xe594cc261a3b25a9c99ec79da9c91ba5 ^ ord(substr($x897356954c2cd3d41b221e3f24f99bba, $x71510c08e23d2083eda280afa650b045-1, 1));
if ($xab6389e47b1edcf1a5267d9cfb513ce5 &amp;amp;lt;= $x7a86c157ee9713c34fbd7a1ee40f0c5a)$xab6389e47b1edcf1a5267d9cfb513ce5 = 255 + $xab6389e47b1edcf1a5267d9cfb513ce5 - $x7a86c157ee9713c34fbd7a1ee40f0c5a;
else $xab6389e47b1edcf1a5267d9cfb513ce5 = $xab6389e47b1edcf1a5267d9cfb513ce5 - $x7a86c157ee9713c34fbd7a1ee40f0c5a;
$x0b43c25ccf2340e23492d4d3141479dc = $x0b43c25ccf2340e23492d4d3141479dc . chr($xab6389e47b1edcf1a5267d9cfb513ce5);
$x7a86c157ee9713c34fbd7a1ee40f0c5a = $xe594cc261a3b25a9c99ec79da9c91ba5;
}
echo $x0b43c25ccf2340e23492d4d3141479dc;
die();
return $x0b43c25ccf2340e23492d4d3141479dc;
} &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;And voilà, I was able to see the source code.&lt;/p&gt;
&lt;p&gt;TL:DR, just print the output of the decrypt function, and kill the script to get the decrypted code, I don&amp;rsquo;t know if there are any other versions of the &amp;ldquo;911006.php&amp;rdquo; file, but I guess that the same logic applies.&lt;/p&gt;
&lt;p&gt;At least The IonCube and Zend Loaders does this with an engine extension, so there is no way you can view the source withouth modifyng the php engine, but this &amp;ldquo;encryptors&amp;rdquo; that offer &amp;ldquo;security by obscurity&amp;rdquo; is never a good idea, also most of the time the source encrypted is most likely a pile of garbage.&lt;/p&gt;</description></item><item><title>Ubuntu 9.10 on an hp mini 110-1125nr</title><link>https://ivanvillareal.com/ubuntu-9-10-on-an-hp-mini-110-1125nr/</link><pubDate>Wed, 27 Jan 2010 00:56:14 +0000</pubDate><guid>https://ivanvillareal.com/ubuntu-9-10-on-an-hp-mini-110-1125nr/</guid><description>&lt;p&gt;I got this new mini 110, it came with Windows 7 Starter, and after a day of using it I was very frustrated because it was very limited, for example, I was unable to change my Desktop background, the network management is confusing and frustrating, and it had a lot of crapware, except for the hp games which some of them are fun.&lt;/p&gt;
&lt;p&gt;Anyway, right now I don’t have time to spend getting a new OS on this machine, I just want something that works, I don’t plan using this to work, but I would like to have some of the tools I use into this.&lt;/p&gt;
&lt;p&gt;So my options were, trying Ubuntu remix or Windows Xp, after checking that hp had the drivers for XP, I was going to change Windows 7 to Xp, but I was reading how to create a USB boot drive, and it was too much hassle for me. (I’m very lazy for any Microsoft stuff).&lt;/p&gt;
&lt;p&gt;My next option was Ubuntu remix, I’m not a big fan of Ubuntu, but I wanted something that just worked out of the box, also this little netbook comes with splashtop, a really nice firmware browser for checking stuff online fast, and I didn’t want to loose that so I really didn’t knew how well this was going to work.&lt;/p&gt;
&lt;p&gt;I started downloading Ubuntu 9.10 Karmic yesterday night, just in case, Today after I&amp;rsquo;ve found more frustrating things, I decided to give Karmic a try.&lt;/p&gt;
&lt;p&gt;I grabbed my usb pendrive, a 1gb &amp;nbsp;kingston traveler, mounted the ISO and ran usbinst.exe, it was pretty straightforward, my only advice would be to avoid saving space for your documents in the usb, my first try I set this to 30Mb and the boot failed, so I set the do not save feature.&lt;/p&gt;
&lt;p&gt;It took about 40 minutes to finish copying the files, after it was done, I restarted the netbook with the pendrive connected, and at the first boot screen I pressed F9 key for booting options, selected the pendrive and that was it.&lt;/p&gt;
&lt;p&gt;After testing ubuntu from the pendrive, it ran pretty well and everything but the wifi worked, I did an installation, keeping the windows partition and the hp restore partition, just in case.&lt;/p&gt;
&lt;p&gt;The installation was pretty smooth, no issues at all, after the first boot I just installed the broadcom drivers, it was easy with the driver manager in ubuntu, and the wifi was working&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Update 03/05/2010:&lt;/strong&gt; My hp mini was stolen by a couple of elderly people at Walmart, I saw the security video :(, so I’m unable to play more with this, but the time I had this laptop I was very happy with it, it performed well on linux.&lt;/p&gt;</description></item><item><title>File Type Detection in PHP</title><link>https://ivanvillareal.com/file-type-detecion-in-php/</link><pubDate>Fri, 25 Dec 2009 04:47:24 +0000</pubDate><guid>https://ivanvillareal.com/file-type-detecion-in-php/</guid><description>&lt;p&gt;I’m working on a project where the users can upload files, and I need to know the type of file they are uploading, a simple solution would be to check the extensions of the files, but this has many flaws, so I was looking for a reliable way to detect the type of file, and I found a PECL extension called &lt;a href=&#34;http://pecl.php.net/package/Fileinfo/php-src/ext/fileinfo&#34; rel=&#34;nofollow noreferrer&#34;&gt;file info&lt;/a&gt; this extension is enabled by default in PHP 5.3, unfortunately I’m running PHP 5.2.10, and the prod server also has this version.&lt;/p&gt;
&lt;p&gt;So what I did to install this on ubuntu 9.10 karmic was the following:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;root@mini:/etc/php5/apache2# apt-get install php5-dev libmagic-dev php-pear
....
root@mini:/etc/php5/apache2# pear channel-update pear.php.net
...
root@mini:/etc/php5/apache2# pecl install Fileinfo
....
Build process completed successfully
Installing &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;/usr/lib/php5/20060613+lfs/fileinfo.so&amp;#39;&lt;/span&gt;
install ok: channel://pear.php.net/Fileinfo-1.0.4&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;and finally I added the extension to php.ini&lt;/p&gt;
&lt;p&gt;&lt;code&gt;extension=fileinfo.so&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;I restarted the apache server, and tested with this&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-php&#34; data-lang=&#34;php&#34;&gt;$fileInfo = new finfo(FILEINFO_MIME);
$mimeType = $fileInfo-&amp;gt;buffer(file_get_contents($uploadedFile));&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description></item><item><title>Format a Mysql DateTime Field with Zend_Date</title><link>https://ivanvillareal.com/format-a-mysql-datetime-field-with-zend_date/</link><pubDate>Thu, 10 Dec 2009 19:54:41 +0000</pubDate><guid>https://ivanvillareal.com/format-a-mysql-datetime-field-with-zend_date/</guid><description>&lt;p&gt;&lt;a title=&#34;Zend_Date component offers a detailed, but simple API for manipulating dates and times&#34; href=&#34;http://framework.zend.com/manual/en/zend.date.html&#34; target=&#34;_blank&#34;&gt;Zend_Date&lt;/a&gt; is really a time saver class, I use it in almost every project I work, It handles time_zones, and date formatting pretty easy, leaving me more time to focus on other things.&lt;/p&gt;
&lt;p&gt;The files that I need to use Zend_Date as a standalone class are:&lt;/p&gt;
&lt;p&gt;Date.php and the Date folder from the Zend distribution package, and this is how I use it:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-php&#34; data-lang=&#34;php&#34;&gt;&lt;span style=&#34;color:#75715e&#34;&gt;&amp;lt;?php&lt;/span&gt;
&lt;span style=&#34;color:#a6e22e&#34;&gt;set_include_path&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;./lib&amp;#39;&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;PATH_SEPARATOR&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;get_include_path&lt;/span&gt;());
&lt;span style=&#34;color:#66d9ef&#34;&gt;include_once&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;Zend/Date.php&amp;#39;&lt;/span&gt;;
$tugId &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;isset&lt;/span&gt;($_GET[&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;tugId&amp;#39;&lt;/span&gt;]) &lt;span style=&#34;color:#f92672&#34;&gt;?&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;int&lt;/span&gt;) $_GET[&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;tugId&amp;#39;&lt;/span&gt;] &lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;false&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;formatDate&lt;/span&gt;($date) {
&lt;span style=&#34;color:#e6db74&#34;&gt;/**
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; * List of supported timezones
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; * http://php.net/manual/en/timezones.php
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; */&lt;/span&gt;
&lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; ($date) {
$fmtDate &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;new&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;Zend_Date&lt;/span&gt;($date, &lt;span style=&#34;color:#a6e22e&#34;&gt;Zend_Date&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;::&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;ISO_8601&lt;/span&gt;);
$fmtDate&lt;span style=&#34;color:#f92672&#34;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;setTimezone&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;America/Los_Angeles&amp;#39;&lt;/span&gt;);
&lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; $fmtDate&lt;span style=&#34;color:#f92672&#34;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;toString&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;Zend_Date&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;::&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;DATETIME&lt;/span&gt;);
} &lt;span style=&#34;color:#66d9ef&#34;&gt;else&lt;/span&gt; {
&lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;&amp;#39;&lt;/span&gt;;
}
}
&lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;is_int&lt;/span&gt;($tugId)) {
$sql &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;SELECT modified_date FROM tuggler WHERE tug_id = &amp;#39;&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt; $tugId;
$result &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; $db&lt;span style=&#34;color:#f92672&#34;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;fetchAssoc&lt;/span&gt;($sql);
$response &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;Last Record Update: &amp;#39;&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;formatDate&lt;/span&gt;($row[&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;modified_date&amp;#39;&lt;/span&gt;]) &lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;&amp;#39;&lt;/span&gt;;
} &lt;span style=&#34;color:#66d9ef&#34;&gt;else&lt;/span&gt; {
$response &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;nothing to return&amp;#34;&lt;/span&gt;;
}
&lt;span style=&#34;color:#66d9ef&#34;&gt;echo&lt;/span&gt; $response;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The response from the above would be &lt;strong&gt;&lt;span style=&#34;color: #0000ff;&#34;&gt;Jul 9, 2009 11:41:20 AM &lt;span style=&#34;font-weight: normal;&#34;&gt;&lt;span style=&#34;color: #000000;&#34;&gt;but I can easily change it using one of the &lt;a title=&#34;Predefined constants for Zend_Date&#34; href=&#34;http://framework.zend.com/manual/en/zend.date.constants.html&#34;&gt;predefined constants&lt;/a&gt;, or I can make my own format.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item></channel></rss>