Strict Standards: Non-static method HttpVars::getRequest() should not be called statically in /home/chrismic/public_html/admin/lifetype-1.2.12/rss.php on line 18

Strict Standards: Non-static method SessionManager::init() should not be called statically in /home/chrismic/public_html/admin/lifetype-1.2.12/rss.php on line 29

Strict Standards: Non-static method SessionManager::setSessionSavePath() should not be called statically in /home/chrismic/public_html/admin/lifetype-1.2.12/class/net/http/session/sessionmanager.class.php on line 36

Strict Standards: Non-static method Config::getConfig() should not be called statically in /home/chrismic/public_html/admin/lifetype-1.2.12/class/net/http/session/sessionmanager.class.php on line 124

Strict Standards: Non-static method SessionManager::setSessionCookiePath() should not be called statically in /home/chrismic/public_html/admin/lifetype-1.2.12/class/net/http/session/sessionmanager.class.php on line 39

Strict Standards: Non-static method Config::getConfig() should not be called statically in /home/chrismic/public_html/admin/lifetype-1.2.12/class/net/http/session/sessionmanager.class.php on line 77

Strict Standards: Non-static method SessionManager::setSessionCookieDomain() should not be called statically in /home/chrismic/public_html/admin/lifetype-1.2.12/class/net/http/session/sessionmanager.class.php on line 41

Strict Standards: Non-static method HttpVars::getBaseUrl() should not be called statically in /home/chrismic/public_html/admin/lifetype-1.2.12/class/net/http/session/sessionmanager.class.php on line 99

Strict Standards: Non-static method HttpVars::getServer() should not be called statically in /home/chrismic/public_html/admin/lifetype-1.2.12/class/net/http/httpvars.class.php on line 269

Strict Standards: Non-static method Config::getConfig() should not be called statically in /home/chrismic/public_html/admin/lifetype-1.2.12/class/net/http/session/sessionmanager.class.php on line 45

Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/chrismic/public_html/admin/lifetype-1.2.12/rss.php:18) in /home/chrismic/public_html/admin/lifetype-1.2.12/class/net/http/session/sessionmanager.class.php on line 51

Strict Standards: Non-static method HttpVars::getSession() should not be called statically in /home/chrismic/public_html/admin/lifetype-1.2.12/class/net/http/session/sessionmanager.class.php on line 56

Strict Standards: Non-static method HttpVars::setSession() should not be called statically in /home/chrismic/public_html/admin/lifetype-1.2.12/class/net/http/session/sessionmanager.class.php on line 59

Strict Standards: Non-static method HttpVars::getSession() should not be called statically in /home/chrismic/public_html/admin/lifetype-1.2.12/rss.php on line 30

Strict Standards: Non-static method PluginManager::getPluginManager() should not be called statically in /home/chrismic/public_html/admin/lifetype-1.2.12/rss.php on line 39

Strict Standards: Non-static method HttpVars::getRequest() should not be called statically in /home/chrismic/public_html/admin/lifetype-1.2.12/rss.php on line 43

Strict Standards: Non-static method Pipeline::registerFilter() should not be called statically in /home/chrismic/public_html/admin/lifetype-1.2.12/class/security/pipeline.class.php on line 22

Strict Standards: Declaration of BlogStatus::getStatusList() should be compatible with GenericStatusList::getStatusList($prefix, $statusAllId, $includeStatusAll = false) in /home/chrismic/public_html/admin/lifetype-1.2.12/class/dao/blogstatus.class.php on line 17

Strict Standards: Declaration of Template::display() should be compatible with Smarty::display($resource_name, $cache_id = NULL, $compile_id = NULL) in /home/chrismic/public_html/admin/lifetype-1.2.12/class/template/template.class.php on line 53

Strict Standards: Declaration of Template::fetch() should be compatible with Smarty::fetch($resource_name, $cache_id = NULL, $compile_id = NULL, $display = false) in /home/chrismic/public_html/admin/lifetype-1.2.12/class/template/template.class.php on line 53

Strict Standards: Declaration of CachedTemplate::fetch() should be compatible with Template::fetch() in /home/chrismic/public_html/admin/lifetype-1.2.12/class/template/cachedtemplate.class.php on line 20

Strict Standards: Declaration of CachedTemplate::display() should be compatible with Template::display() in /home/chrismic/public_html/admin/lifetype-1.2.12/class/template/cachedtemplate.class.php on line 20

Warning: is_readable(): open_basedir restriction in effect. File(./rss/rss10.template) is not within the allowed path(s): (/home/:/tmp/:/usr/local/lib/:/usr/local/apache/conf/:/opt/cpanel/composer/bin/) in /home/chrismic/public_html/admin/lifetype-1.2.12/class/file/file.class.php on line 208

Warning: file_exists(): open_basedir restriction in effect. File(./rss/rss10.template) is not within the allowed path(s): (/home/:/tmp/:/usr/local/lib/:/usr/local/apache/conf/:/opt/cpanel/composer/bin/) in /home/chrismic/public_html/admin/lifetype-1.2.12/class/template/smarty/Smarty.class.php on line 1642

Warning: is_readable(): open_basedir restriction in effect. File(./rss/rss10.template) is not within the allowed path(s): (/home/:/tmp/:/usr/local/lib/:/usr/local/apache/conf/:/opt/cpanel/composer/bin/) in /home/chrismic/public_html/admin/lifetype-1.2.12/class/file/file.class.php on line 208

Warning: Cannot modify header information - headers already sent by (output started at /home/chrismic/public_html/admin/lifetype-1.2.12/rss.php:18) in /home/chrismic/public_html/admin/lifetype-1.2.12/class/view/view.class.php on line 328

Warning: Cannot modify header information - headers already sent by (output started at /home/chrismic/public_html/admin/lifetype-1.2.12/rss.php:18) in /home/chrismic/public_html/admin/lifetype-1.2.12/class/view/view.class.php on line 175

Warning: is_readable(): open_basedir restriction in effect. File(./rss/rss10.template) is not within the allowed path(s): (/home/:/tmp/:/usr/local/lib/:/usr/local/apache/conf/:/opt/cpanel/composer/bin/) in /home/chrismic/public_html/admin/lifetype-1.2.12/class/file/file.class.php on line 208

Warning: Cannot modify header information - headers already sent by (output started at /home/chrismic/public_html/admin/lifetype-1.2.12/rss.php:18) in /home/chrismic/public_html/admin/lifetype-1.2.12/class/view/smartyview.class.php on line 245

Warning: is_readable(): open_basedir restriction in effect. File(./rss/rss10.template) is not within the allowed path(s): (/home/:/tmp/:/usr/local/lib/:/usr/local/apache/conf/:/opt/cpanel/composer/bin/) in /home/chrismic/public_html/admin/lifetype-1.2.12/class/file/file.class.php on line 208
Chris Michaelides | Tech Artist http://chrismichaelides.eu/admin/lifetype-1.2.12/index.php?blogId=1 chris 2014-12-30T13:59:16Z How to get an image out of a given URL with PHP http://chrismichaelides.eu/admin/lifetype-1.2.12/index.php?op=ViewArticle&articleId=17&blogId=1 <p><img style="margin: 5px;" src="http://chrismichaelides.eu/admin/lifetype-1.2.12/gallery/1/PHP.png" alt="alt" /><br />Sometimes there are URLs which point to images. While it's easy to just<br />[code]<br />&lt;img src="URL" /&gt;<br />[/code]</p> <p>in HTML, there are cases where this is not possible, or will not work.</p> <p>In such cases, this handy PHP method will come to the solution:</p> <p>[code]<br />&lt;?php <br />function remoteImage($URL) {<br /><br />$remoteImage = htmlentities($URL);<br />$imginfo = exif_imagetype($remoteImage);<br /><br />$image = false;<br />switch ($imginfo) {<br />&nbsp;&nbsp;&nbsp; case "IMAGETYPE_JPEG":<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $image = imagecreatefromjpeg($remoteImage);<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $imginfo = "image/jpeg";<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $type = "imagejpeg";<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $filename = time().mt_rand().'.jpg'; // if you want to save it locally<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; break;<br />&nbsp;&nbsp;&nbsp; case "IMAGETYPE_PNG":<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $image = imagecreatefrompng($remoteImage);<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $imginfo = "image/png";<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $type = "imagepng";<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $filename = time().mt_rand().'.png'; // if you want to save it locally<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; break;<br />&nbsp;&nbsp;&nbsp; case "IMAGETYPE_GIF";<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $image = imagecreatefromgif($remoteImage);<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $imginfo = "image/gif";<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $type = "imagegif";<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $filename = time().mt_rand().'.gif'; // if you want to save it locally<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; break;<br />}<br /><br />if ($image) {<br /><br />&nbsp; ob_start();<br />&nbsp; header( "Content-type: ".$imginfo );<br />&nbsp; $type( $image, NULL, 100 );<br />&nbsp; imagedestroy( $image );<br />&nbsp; $i = ob_get_clean();<br />&nbsp; return "data:" . $imginfo . ";base64," . base64_encode( $i );<br />&nbsp; <br />}<br />else return false;<br /><br />}<br />?&gt;<br />[/code]</p> <p>And you can call it like this:</p> <p>[code]<br />&lt;?php<br />$remoteImage = remoteImage("http://www.example.com/somefile_that_generates_an_image");<br />if ($remoteImage) echo "&lt;img src='". $remoteImage ."' /&gt;";<br />else echo "Image not found!";<br />?&gt;<br />[/code]</p> Web Development 2014-12-30T13:39:25Z chris Git pull, push, and commit - Quick tutorial http://chrismichaelides.eu/admin/lifetype-1.2.12/index.php?op=ViewArticle&articleId=16&blogId=1 <p><img style="margin: 5px;" src="http://chrismichaelides.eu/admin/lifetype-1.2.12/gallery/1/130712_git_github_topdenota1.jpg" alt="alt" /></p> <p>GitHub's a great tool to maintain your code, but it's definitely a little confusing the first time around (and, possibly, a few times after that). Here is a quick guide on how to use it efficiently.</p> <p>To start working with GitHub, first you have to <a href="https://github.com/" target="_blank">sign up on the GitHub</a> frontpage. Once you've signed up, <a href="https://help.github.com/articles/create-a-repo/" target="_blank">create a repository</a> where all your project's code will be maintained.</p> <p>Once you are all set on the GitHub site, you have to <a href="http://git-scm.com/downloads" target="_blank">install git</a> on your local machine.</p> <p>Now you are ready to upload your local files to your repository. To do that, first we must initialize some settings in git:</p> <p>Open up a terminal and enter the following two commands:</p> <p><code>git config --global user.name "Your Name Here"</code></p> <p><code>git config --global user.email "your_email@youremail.com"</code></p> <p>Make sure that you give your GitHub email address as user.email. As user.name you can enter whatever you like.</p> <p>After the initial configuration is done, you can synchronize your local files with your repository. Go to the local directory where your project's files reside and enter the command:</p> <p><code>git init</code></p> <p>With git, you synchronize yor files through commits. Each commit contains files that you specify to be uploaded to GitHub. To add files to a commit enter:</p> <p><code>git add example.php</code></p> <p>The above will add example.php to the next commit. If you want to add all files and folders, you enter the command:</p> <p><code>git add -A<br /></code></p> <p>Once you are happy with the files you want uploaded to GitHub, enter the command:</p> <p><code>git commit -m "optional message. usually the purpose of this commit, eg. why changes were made"</code></p> <p>This will get all files you added ready for uploading to GitHub. To actually upload them, you enter the commands:</p> <p><code>git remote add origin https://github.com/yourusername/nameofyourrepository</code></p> <p><code>git push origin master</code></p> <p>If you get an error message, it can be that the GitHub repository contains files not currently on your local folder. In that case you have to "pull"(download) them first from GitHub, before you can synchronize your project. To pull files from GitHub you enter the command:</p> <p><code>git pull https://github.com/yourusername/nameofyourrepository</code></p> <p>After "pulling" has finished, you can try to "push"(upload) your commit again:</p> <p><code>git push origin master</code></p> <p>That's it! You've "pushed" your local files to your GitHub repository.</p> <p>Now whenever you make changes to your local files, you can add them to a commit and push them to the repository. You can also pull from the repository to work on other people's commits (if you're working on a team's projects). Another scenario is that you can revert to a previous commit in GitHub, and pull the files from that commit to your local folder to work on them.</p> Web Development 2014-12-26T17:06:24Z chris My thoughts about TheGrid.io http://chrismichaelides.eu/admin/lifetype-1.2.12/index.php?op=ViewArticle&articleId=15&blogId=1 <p><img style="margin: 5px;" src="http://chrismichaelides.eu/admin/lifetype-1.2.12/gallery/1/thegrid.png" alt="TheGrid.io" height="350" width="564" /></p> <p>A lot of hype on the social media about TheGrid.io.<br />The Grid will supposedly harness the power of artificial intelligence to take everything you throw at it - videos, images, text, urls and more - and automatically shape them into a custom website unique to you.</p> <p>Let's have a closer look at this.</p> <p>First let's take a look at their own site <a href="http://thegrid.io">thegrid.io</a>.</p> <p>This site was built with TheGrid AI, and immediately we can identify it as a modern landing page.<br />As it seems the AI knows how to create landing pages. The layout is good, responsive, and feels modern like any other landing page template. What is revolutionary here is the automation of content, so users with no HTML knowledge can use TheGrid as simple as posting on their Facebook page. TheGrid AI takes care of color matching and arranging content in a neat layout.</p> <p>But let's dig a little deeper...</p> <p>First of all, TheGrid AI seems like it can only render landing pages. For every new page you want to add to your site, you will have to get a new design. Complex stuff that are needed by sites that are not just personal/portfolio/presentation sites are not possible. To get complex stuff working you still have to get your hands dirty and dig into the code. Compatibility issues and hitting walls thoughts come to mind...</p> <p>Each TheGrid site will be posted on github, so you (and others) can look at the code of your site (and make changes) whenever you need to. TheGrid.io website is also posted on github. Let's take a look at it:</p> <p><a class="ot-anchor aaTEdf" dir="ltr" rel="nofollow" href="https://github.com/the-domains/the-grid/blob/gh-pages/index.html" target="_blank">https://github.com/the-domains/the-grid/blob/gh-pages/</a></p> <p>Here you can see that each page is a new design.<br />Also what strikes most is the size of the pages! Take a look at the index.html page:</p> <p><a class="ot-anchor aaTEdf" dir="ltr" rel="nofollow" href="https://github.com/the-domains/the-grid/blob/gh-pages/index.html" target="_blank">https://github.com/the-domains/the-grid/blob/gh-pages/index.html</a></p> <p>Their homepage index.html file is 1887.137 kb<strong></strong>! Incredibly huge! That simply won't do.</p> <p>Now if you go to their website, you will see a perfect example of dishonest marketing and over-exaggeration. A lot of big claims and framing everything in a mysterious science-fiction "AI" context. This may be good marketing to target certain people but I just find it dishonest.<br /><br />What do those blue dots and edges represent on the little girl photo? Face detection algorithms (Viola-Jones, CNNs etc) usually don't work like this. Are you doing single-photo 3D reconstuction? Or maybe, just maybe, you just put whatever looks cool and evokes futuristic feelings in the viewer...<br /><br />This just seems like a web template for personal sites that figures out how to lay out your content boxes in some table arrangement according to a certain optimization criterion. I'm not impressed.</p> <p>Not to mention they're going to host all this, so the idea of no walled garden is just a lie. You can take everything that's been rendered, but you wont be able to build any more pages. Since no templates etc. you're completely locked in unless you get a new design.<br /><br />It all sounds nice until you dig into the details...</p> <p><strong>Conclusion:</strong></p> <p>TheGrid.io is just a good example of excellent marketing. &nbsp;It's nothing new, just an extremely improved (but also very limiting) WYSIWYG web builder.</p> <p>I look at this Grid product and see it as a glorified website builder, using the same old stock templates, and then making "decisions" based on Analytics and market data. The thinking part goes to maximize return while minimizing negative reactions. So the best version of safe.</p> <div class="Aq DK Bt UR gA"> <div class="Ct">Design, branding and strategy will always be needed and a necessity for many. Likewise, &ldquo;run-of-the-mill&rdquo; products like TheGrid.io will be good enough for many others. There are businesses and then there are businesses &mdash; the smart ones will continue to stand apart for many reasons, this one included.</div> </div> <p>There will always be people in search of a quick fix. This tool is for all the people who wouldn't pay for a professional website anyway.</p> <p>But let the kids enjoy their new shiny toys and let TheGrid cash out their money, nothing I or anyone educated enough to know what this really is can do anything about it. They are already hyped its done.</p> Web Design 2014-12-25T09:18:26Z chris How to make an iframe fit its parent element (or in any part of a page for that matter) http://chrismichaelides.eu/admin/lifetype-1.2.12/index.php?op=ViewArticle&articleId=14&blogId=1 <p><img src="http://www.startupgreece.gov.gr/sites/default/files/iframe_0.jpg" alt="alt" height="140" width="280" /></p> <div class="post-text"> <p>Since we are in the age of CSS3, you can do this by using viewport units. These units allow you to specify sizes in terms of percentages of the viewport width and viewport height. This is the user's viewport, also known as screen. However, in all major browsers I've tried it, if you put an iframe inside a div, which is inside another div and positioned relative, the viewport units are relative to this div. And since 100 viewport height units mean 100% height, you can do like this:</p> <p>[code]<br />&lt;div id="parent"&gt;<br />&nbsp;&nbsp;&nbsp; &lt;div id="wrapper" style="position:relative"&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;iframe style="position:absolute;top:0px;width:100%;height:100vh;" src="http://anydomain.com"&gt;&lt;/iframe&gt;<br />&nbsp;&nbsp;&nbsp; &lt;/div&gt;<br />&lt;/div&gt;<br />[/code]</p> <p>I find this to be the best solution possible, since it is <strong>cross-domain</strong>, and displays exactly like you want it without any javascript or other complex stuff.</p> <p>And most importantly, it works on all browsers, even mobile ones (tested on android and iphone)!</p> </div> Web Design 2014-03-13T18:42:10Z chris The Zen of Python http://chrismichaelides.eu/admin/lifetype-1.2.12/index.php?op=ViewArticle&articleId=13&blogId=1 <h3><img src="http://thezenofpython.com/xpython-logo-master-v3-TM.png.pagespeed.ic.WwZSb3B1-6.png" alt="The Zen of Python" height="203" width="601" /></h3> <h3>Programming (and Life) Principles:</h3> <p>Beautiful is better than ugly.</p> <p>Explicit is better than implicit.</p> <p>Simple is better than complex.</p> <p>Complex is better than complicated. Flat is better than nested.</p> <p>Sparse is better than dense.</p> <p>Readability counts.</p> <p>Special cases aren't special enough to break the rules.</p> <p>Although practicality beats purity.</p> <p>Errors should never pass silently.</p> <p>Unless explicitly silenced.</p> <p>In the face of ambiguity, refuse the temptation to guess.</p> <p>There should be one-- and preferably only one --obvious way to do it.</p> <p>Although that way may not be obvious at first unless you're Dutch.</p> <p>Now is better than never.</p> <p>Although never is often better than *right* now.</p> <p>If the implementation is hard to explain, it's a bad idea.</p> <p>If the implementation is easy to explain, it may be a good idea.</p> <p>Namespaces are one honking great idea -- let's do more of those!</p> General 2014-02-27T01:11:13Z chris Download a file with cURL http://chrismichaelides.eu/admin/lifetype-1.2.12/index.php?op=ViewArticle&articleId=12&blogId=1 <p><img src="http://curl.haxx.se/pix/curl-refined.jpg" alt="alt" height="175" width="471" /></p> <p>In many situations you want to download a file (or a page) from another server to your server. You can do this with cURL! Here is a function which does that, written in PHP.</p> <p>[code]&lt;?php<br />function downloadFile($url, $path='', $file='', $options = array())<br />&nbsp; {<br />&nbsp;&nbsp;&nbsp; //make sure the options is an array<br />&nbsp;&nbsp;&nbsp; if (!is_array($options)) $options = array();<br />&nbsp;&nbsp;&nbsp; //add default options. You can remove these from here, but make sure you give the options you removed, when you call this method<br />&nbsp;&nbsp;&nbsp; $options = array_merge(array(<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'connectionTimeout' =&gt; 5, // seconds<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'timeout' =&gt; 10, // seconds<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'sslVerifyPeer' =&gt; false,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'followLocation' =&gt; false, // if true, limit recursive redirection by<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'maxRedirs' =&gt; 1, // setting value for "maxRedirs"<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ), $options<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; );<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; // if no filename given, create a random filename (with no extension)<br />&nbsp;&nbsp;&nbsp; if (empty($filename)) $filename = rand();<br />&nbsp;&nbsp;&nbsp; // create a file (we are assuming that we can write to the system's directory)<br />&nbsp;&nbsp;&nbsp; $FileName = $path.$filename;<br />&nbsp;&nbsp;&nbsp; $fh = fopen($FileName, 'w');<br /><br />&nbsp;&nbsp;&nbsp; $curl = curl_init($url);<br />&nbsp;&nbsp;&nbsp; curl_setopt($curl, CURLOPT_FILE, $fh);<br />&nbsp;&nbsp;&nbsp; curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, $options['connectionTimeout']);<br />&nbsp;&nbsp;&nbsp; curl_setopt($curl, CURLOPT_TIMEOUT, $options['timeout']);<br />&nbsp;&nbsp;&nbsp; curl_setopt($curl, CURLOPT_HEADER, false);<br />&nbsp;&nbsp;&nbsp; curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, $options['sslVerifyPeer']);<br />&nbsp;&nbsp;&nbsp; curl_setopt($curl, CURLOPT_FOLLOWLOCATION, $options['followLocation']);<br />&nbsp;&nbsp;&nbsp; curl_setopt($curl, CURLOPT_MAXREDIRS, $options['maxRedirs']);<br />&nbsp;&nbsp;&nbsp; curl_exec($curl);<br /><br />&nbsp;&nbsp;&nbsp; curl_close($curl);<br />&nbsp;&nbsp;&nbsp; fclose($fh);<br /><br />&nbsp;&nbsp;&nbsp; return $FileName;<br />&nbsp; }<br />?&gt;[/code]</p> Web Development 2014-02-26T10:07:50Z chris New iOS flaw makes devices susceptible to covert keylogging, researchers say! http://chrismichaelides.eu/admin/lifetype-1.2.12/index.php?op=ViewArticle&articleId=11&blogId=1 <p><img src="http://cdn.arstechnica.net/wp-content/uploads/2014/02/iphone-640x360.jpg" alt="alt" height="360" width="640" /></p> <h2 class="standalone-deck">Proof-of-concept app in Apple's App Store sent keystrokes to remote server.</h2> <p>Researchers said they have identified a flaw in Apple's iOS that makes it possible for attackers to surreptitiously log every touch a user makes, including characters typed into the keyboard, TouchID presses, and adjustments to the volume control.</p> <p>The vulnerability affects even non-jailbroken iPhones and iPads running iOS versions 7.0.4, 7.0.5, and 7.0.6, as well as those running on 6.1.x, researchers from security firm FireEye wrote in a <a href="http://www.fireeye.com/blog/technical/2014/02/background-monitoring-on-non-jailbroken-ios-7-devices-and-a-mitigation.html">blog post published Monday night</a>. They said attackers could carry out the covert monitoring using an app that bypasses Apple's stringent app review process. The app uses <a href="http://support.apple.com/kb/ht4211">multitasking capabilities built into iOS</a> to capture user inputs.</p> <p>The disclosure comes three days after Apple patched an extremely critical iOS vulnerability that gave attackers an easy way to bypass encryption many browsers and other types of apps use to prevent eavesdropping of passwords and other sensitive data. Dubbed "goto fail," after one of the lines of code responsible for the bug, the flaw <a href="http://arstechnica.com/security/2014/02/extremely-critical-crypto-flaw-in-ios-may-also-affect-fully-patched-macs/">remains unfixed in OS X 10.9.0 and 10.9.1</a>. Apple has yet to say when a patch will be released.</p> Technology 2014-02-26T06:35:13Z chris PHP function to return PhantomJS result http://chrismichaelides.eu/admin/lifetype-1.2.12/index.php?op=ViewArticle&articleId=10&blogId=1 <p><img style="margin: 5px;" src="http://chrismichaelides.eu/admin/lifetype-1.2.12/gallery/1/phantomjs-wordle.png" alt="alt" /></p> <p>If you want a function that will return the result of a PhantomJS script, you may find this handy.</p> <p>It takes an array of options to be passed as arguments to the phantomJS file, executes it, and returns its results.</p> <p>I guess you have already installed phantomJS on your server, and configured it to run with no problems for the current user, right?</p> <p>Here is the code:</p> <p>[code]&lt;?php<br />/**<br />* To get this to work on my server for user "axxis" I had to edit /etc/sudoers and add:<br />* axxis ALL=(ALL) NOPASSWD: /usr/bin/phantomjs<br />**/<br />// // Enable Error Reporting<br />// ini_set('display_errors',1);<br />// ini_set('display_startup_errors',1);<br />// error_reporting(-1);<br /><br />// A check to see that console commands work. Displays also the current user<br />//$user = exec("whoami");<br />//echo "Current user: ".$user;<br /><br />// the important stuff...<br />function callPhantom($options) {<br />&nbsp;&nbsp;&nbsp; $proxySettings &nbsp;&nbsp;&nbsp; = isset($options['proxy']) ? $options['proxy'] : ''; //"--proxy=ip:port --proxy-type=https";<br />&nbsp;&nbsp;&nbsp; $scripttoload &nbsp;&nbsp;&nbsp; = $options['phantomfile']; // phantomjs script that loads the url<br />&nbsp;&nbsp;&nbsp; $URLtoload &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; = $options['url']; // the url with the jacascript<br />&nbsp;&nbsp;&nbsp; $Referer&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; = isset($options['referer']) ? $options['referer'] : ''; //'Me';<br />&nbsp;&nbsp;&nbsp; $UserAgent&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; = isset($options['useragent']) ? $options['useragent'] : ''; //'MyBrowser';<br />&nbsp;&nbsp;&nbsp; if ($options['args']) { // any args you want to send to the loaded url, eg. time=198322<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $args = '';<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; foreach ($options['args'] as $arg) {<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $args .= escapeshellarg($now); // Don't forget to escape args!<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; } // To grab the args in the js file, that's another story (and another article!) ;)<br /><br />&nbsp;&nbsp;&nbsp; $cmd = 'phantomjs' . ' '<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; . $proxy . ' '<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; . "--web-security=no" . ' '<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; . $scripttoload . ' '<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; . $args . ' '<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; . escapeshellarg($URLtoload) . ' '<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; . escapeshellarg($Referer) . ' '<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; . escapeshellarg($UserAgent) . ' '<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; . ' 2&gt;&amp;1'; // let's capture STDERR as well<br />&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; // execute phantomjs script, let the javascript on this page execute,<br />&nbsp;&nbsp;&nbsp; // and get the finished page in a variable: $code_of_loaded_content<br />&nbsp;&nbsp;&nbsp; exec($cmd, $op, $er);<br />&nbsp;&nbsp;&nbsp; $code_of_loaded_content = implode("",$op);<br />&nbsp;&nbsp;&nbsp; if (!empty($er)) {<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; echo "&lt;h1&gt;ERRORS&lt;/h1&gt;";<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; echo $er;<br />&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; //echo "&lt;h1&gt;RESULT&lt;/h1&gt;";<br />&nbsp;&nbsp;&nbsp; return $code_of_loaded_content;<br />}<br />// EXAMPLE<br />/*<br />echo callPhantom(array(<br />&nbsp;&nbsp;&nbsp; 'phantomfile' =&gt; DIRNAME(__FILE__).'/take_screenshot.js',<br />&nbsp;&nbsp;&nbsp; 'url' =&gt; 'http://chrismichaelides.eu/'<br />));<br />*/<br />?&gt;[/code]</p> <p>The function passes the given options over to the phantom js file, but to see how they are being handled, you'll have to wait for the next article! :)</p> Web Development 2014-02-25T07:16:12Z chris Execute code only on the last call of a re-used method http://chrismichaelides.eu/admin/lifetype-1.2.12/index.php?op=ViewArticle&articleId=9&blogId=1 <p><img style="margin: 5px;" src="http://chrismichaelides.eu/admin/lifetype-1.2.12/gallery/1/slide-image-5.jpg" alt="alt" /></p> <p>There are situations where you call a method which recalls itself multiple times, or calls other methods which recall the original method. But you want code of the original method execute only one time, and that, on the last call! What do you do?</p> <p>A static variable is the solution to this situation. And it's a very simple solution too.<br />Here is how you do it:<br />[code]<br />&lt;?php<br />function recall($option) {<br />&nbsp; static $times=0;<br />&nbsp; //on method entry you always add to the $times variable<br />&nbsp; $times++;<br />&nbsp; <br />&nbsp; //some code that re-calls this method...<br />&nbsp; // eg. a file inclusion or another method call which re-calls this method<br />&nbsp; // or a recall straight from within the method.<br />&nbsp; // for any of the above scenarios $option is assumed to change on each call, and the re-calls can only happen on certain $options<br />&nbsp; // this way we avoid falling in an endless loop...<br />&nbsp; <br />&nbsp; //Now make sure only the last call of this method gets to execute this code below...<br />&nbsp; if ($times&gt;0) {<br />&nbsp;&nbsp;&nbsp; // put here any code you want executed only at the last call of the function.<br />&nbsp;&nbsp;&nbsp; // it is important that you put this below the code that would eventually recall the function<br />&nbsp; }<br />&nbsp; <br />&nbsp; // when done, make sure you set $times back to 0<br />&nbsp; $times = 0;<br />}<br />[/code]</p> <p>So, what's basically happening here, is that each call is nested, and since PHP is a synchronous language, each call has to wait for the "child" call to finish execution, in order to proceed with its own execution.</p> <p>Example: <span style="background-color: #ffffff;">Call A($times=1) =&gt; Call B($times=2) =&gt; Call C($times=3)</span></p> <p>Now based on the above sample code, <strong>Call A</strong> has to wait for<strong> Call B</strong> to finish, before evaluating <span style="background-color: #c0c0c0;"><em>if ($times&gt;0)</em></span>.<br />And <strong>Call B</strong> has to wait for<strong> Call C </strong>to finish, before continuing with its own evaluation.</p> <p><strong>Call C</strong> doesn't have to wait for anybody, and simply continues execution until the end of the method. It evaluates that <span style="background-color: #c0c0c0;"><em>$times&gt;0</em></span> (3), and executes the code that should be executed only on the last call. Then it goes to the end of the method, and sets $times=0.</p> <p>Execution of<strong> Call C</strong> is finished, so now <strong>Call B</strong> can resume execution. It evaluates <em><span style="background-color: #c0c0c0;">$times&gt;0</span></em> as false (since <strong>Call C</strong> has set <span style="background-color: #c0c0c0;"><em>$times</em></span> to 0), and correctly doesn't execute the code that shouldn't be executed. Same happens to <strong>Call A</strong>.</p> <p>At the end, the method is at its initial state, and waits for new calls. One time calls will be executed just fine, and nested calls will always execute restricted code only on the last call.</p> <h2>The problem that lead to the solution</h2> <p>In my years of PHP coding, I haven't ever met a situation where I needed this. Until today!<br />I am developing a CMS from scratch, basically because I want something that can work on any HTML template, and because on many situations the available CMSes are overkill (call me Joomla/WordPress), or simply weak and ugly (no names here). My CMS is simple, fast, lightweight, and can be used on any HTML template out there. Anyway, the situation that gave me this problem (and made me think of the solution) is this:</p> <p>My CMS produces SEF URLs. On page load, it has to parse these URLs back to original URLs and redirect to the correct file, based on the URL. Now, there are situations where a file may redirect to another file, based on user input, data processing, etc. This is very common in other CMS platforms as well. In such situations, we don't want the URL to change (header locations are a no-go), but we do want the page contents to change. It is also important that we do not re-load the page, because we don't want to renew anything on the PHP side. We want all properties, variables, objects, etc. to remain intact!</p> <p>My CMS redirects by the <span style="background-color: #ffffff;"><strong>redirect($uri)</strong></span> method, parses the <span style="background-color: #c0c0c0;"><em>$uri</em></span>, and includes the appropriate file. After inclusion, it adds all its metadata, styles, and scripts to the head of the buffered document, and then outputs it to the browser.</p> <p><strong>&lt;head&gt;</strong> data change according to which page is loaded, and what is needed. Eg. page title, description, and Open Graph properties need to change according to the loaded page.</p> <p>A second redirection made a double inclusion of everything! Metadata from both pages were added to a single <span style="background-color: #ffffff;"><em>&lt;head&gt; </em></span>making a mess!</p> <p>By adding the inclusion code inside the <em><span style="background-color: #c0c0c0;">if ($times&gt;0)</span></em> block, I made sure the <span style="background-color: #ffffff;"><em>&lt;head&gt;</em></span> information of only the last page was inserted to the document.</p> <p>Do you know any other situations were this solution might be useful?</p> Web Development 2014-02-24T08:12:44Z chris Costumes for Programmers! http://chrismichaelides.eu/admin/lifetype-1.2.12/index.php?op=ViewArticle&articleId=8&blogId=1 <p>I know Halloween is over, but back here in Europe it's Carnival time.</p> <p>Here are some nice ideas for programmers who want to impress!!</p> <p><img style="margin: 5px;" src="http://chrismichaelides.eu/admin/lifetype-1.2.12/gallery/1/halloweenCostumesForProgrammers1.png" alt="alt" /></p> <p><img style="margin: 5px;" src="http://chrismichaelides.eu/admin/lifetype-1.2.12/gallery/1/halloweenCostumesForProgrammers.png" alt="alt" /></p> General 2014-02-24T07:34:10Z chris