3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Remote Negotiation Class, JSON Based * * @author Michael Telatynski <postmaster@t3chguy.co.uk> * @copyright 2014 Web Development Guru * @version 1.0 */ class Remote extends AuthenticatedMySQLi { private $site, $content, $zip; private function selMiddle($a, $b, $s) { return (strpos($s, $a) === FALSE) ?FALSE:strstr(substr($s, strpos($s, $a) + strlen($a)), $b, TRUE); } private function fitData($id, $name) { if(count($rows = $this -> query('SELECT field, data FROM data WHERE uid=? AND file=?', 'is', [$id, $name])) > 0) { foreach ($rows as $curr) { $this -> content = str_ireplace('{{DATA_' . $curr['field'] . '}}', (new Parsedown)->parse($curr['data']), $this -> content); } } } private function fitIncludes() { if (preg_match_all('/{{INCLUDE_([a-zA-Z1-9_].+?)}}/', $this -> content, $m, PREG_SET_ORDER) > 0) { foreach ($m as $c) { if (file_exists($file = $c[1] . '.inc')) { $this -> content = str_ireplace($c[0], @file_get_contents($file), $this -> content); } } } return $this; } private function fitTestimonials($uid) { $lot = $this -> query('SELECT author, content FROM testimonials WHERE uid=? ORDER BY RAND()', 'i', [$uid]); $lot = array_map(function ($val) { return '<li><p class="text">' . $val['content'] . '</p><p class="author">' . $val['author'] . '</p></li>'; }, $lot); $this -> content = str_replace('{{TESTIMONIAL_ARRAY}}', '<ul id="testimonials">' . implode($lot) . '</ul>', $this -> content); return $this; } private function fitDynamics($css='') { foreach(glob('*.css') as $file) { $css .= '/* ' . basename($file) . " */\n" . @file_get_contents($file) . "\n\n"; } $replacements = [ '{{APIKEY}}' => $_GET['db'], '{{CSS_FILE}}' => $css, '{{REMOTE_URL}}' => $this -> site, '{{BLOG_TTL_1}}' => '', '{{BLOG_PRE_1}}' => '', '{{BLOG_TTL_2}}' => '', '{{BLOG_PRE_2}}' => '', '{{BLOG_TTL_3}}' => '', '{{BLOG_PRE_3}}' => '', ]; $this -> content = str_replace(array_keys($replacements), array_values($replacements), $this -> content); return $this; } private function fitStatics() { global $remoteTestimonial; $replacements = [ '{{HOME_URL}}' => 'webdevguru.co.uk', '{{DEFAULT_CSS}}' => '@import url("cms.{{HOME_URL}}/css/{{APIKEY}}/"); a[disabled] { pointer-events: none; }', '{{WEBDEVGURU_LINK}}' => 'Design by: <a href="http://www.webdevguru.co.uk" target="_blank">www.WebDevGuru.co.uk</a>', '{{COPYRIGHT_SNIPPET}}' => date('Y'), '{{TESTIMONIAL_SCRIPT}}' => $remoteTestimonial, "\n" => '', "\r" => '', "\t" => '', ]; $this -> content = str_replace(array_keys($replacements), array_values($replacements), $this -> content); return $this; } private function padBlogging($blogs) { $cframe = $this -> fitStatics() -> fitDynamics() -> selMiddle('{{COMMENTS_START}}', '{{COMMENTS_FINAL}}', $this -> content); foreach ($blogs as $num => $blog) { $replacements = [ '{{BLOG_REFNUM}}' => $num, '{{BLOG_IDNUM}}' => $blog['id'], '{{BLOG_TITLE}}' => $blog['title'], '{{BLOG_IMAGE}}' => $blog['img'], '{{BLOG_CONTENT}}' => $blog['content'], '{{BLOG_PREV_HREF}}' => (in_array($num-1, array_keys($blogs))) ? 'href="page_' . $num-1 . '.buf.html"':'disabled="disabled"', '{{BLOG_NEXT_HREF}}' => (in_array($num+1, array_keys($blogs))) ? 'href="page_' . $num+1 . '.buf.html"':'disabled="disabled"', '{{COMMENTS_START}}' => '', '{{COMMENTS_FINAL}}' => '', ]; if ($cframe !== FALSE) { if (count($comments = $this -> query('SELECT name, data, date FROM blogging_c WHERE live=1 AND blog_uid=? ORDER BY date', 'i', [ $blog['id'] ])) > 0) { $parsedcomments = ''; $commplacements = [ '{{COMMENT_NAME}}' => $comment['name'], '{{COMMENT_DATA}}' => $comment['date'], '{{COMMENT_DATA}}' => $comment['data'], ]; foreach ($comments as $comment) { $parsedcomments .= str_replace(array_keys($commplacements), array_values($commplacements), $cframe); } $iter[$num] = str_replace([array_keys($replacements), $cframe], [array_values($replacements), $parsedcomments], $this -> content); } else { $iter[$num]= str_replace([array_keys($replacements), $cframe], [array_values($replacements)], $this -> content); } } } return $iter; } public function getID($id) { return count($x = $this -> query('SELECT id, name, enabled FROM sites WHERE password(id)=? LIMIT 1', 's', [$id])) ? $x:['enabled' => 'UNKNOWN APIKEY!']; } private function recuriveZipAdd($pattern='') { $this -> zip -> addGlob($pattern . '*.{css,js,png,jpeg,gif,ico,woff,ttf,svg,eot}', GLOB_BRACE); foreach (glob($pattern . '*', GLOB_ONLYDIR | GLOB_MARK) as $file) { $this -> recuriveZipAdd($file); } return $this; } public function createManifest() { if (@chdir('site-data/' . $_GET['db'])) { $this -> zip = new ZipArchive; if (file_exists('manifest.zip')) { unlink('manifest.zip'); } if ($this -> zip -> open('manifest.zip', ZipArchive::CREATE) === TRUE) { $this -> recuriveZipAdd() -> zip -> close(); } die('{"Result":"OK","Message":"Successfully Generated New ZIP Assets Archive!"}'); } else { die('{"Result":"ERROR","Message":"Error Navigating to Directory"}'); } } public function sync() { phpinfo(); var_dump(($id = $this -> getID( $_GET['db'] )); /*$return = ( ($id = $this -> getID( $_GET['db'] ) )['enabled'] === '1899-11-30') ?: $id['enabled'];*/ if ($return === TRUE) { chdir('site-data/' . $id['name']); $this -> site = $id['name']; $output = ['id' => $id['id'], 'name' => $id['name'], 'href' => 'http://cms.webdevguru.co.uk/site-data/' . $id['name'] . '/manifest.zip']; foreach(glob('*.suf') as $file) { if (file_exists($file) && !empty($this -> content = @file_get_contents($file))) { $this -> fitIncludes() -> fitStatics() -> fitTestimonials($id['id']) -> fitDynamics() -> fitData($id['id'], basename($file)); $output['suf'][pathinfo($file, PATHINFO_FILENAME)] = preg_replace(['/<!--(.|\s)*?-->/', '/ {2,}/'], '', $this -> content); } } if (file_exists('blog.buf')) { $blogs = $this -> query('SELECT id, title, img, content FROM blogging_posts WHERE uid=?', 'i', [ $id['id'] ]); if (count($blogs) > 0 && ($this -> content = @file_get_contents('blog.buf'))) { $output['buf'] = $this -> padBlogging($blogs); } } echo json_encode($output); } else { die($return); } } public function conn() { if (@file_get_contents('http://' . $_GET['db'] . '/GuruCMS_Remote.php')) { die('{"Message":"Sync Has Been Completed!"}'); } die('{"Message":"' . $_GET['db'] . ' isn\'t Responding!"}'); } } public function addto() { if (isset($_POST['name'], $_POST['email']) && filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { echo '{"Result":"OK"}'; } else { die('{"Result":"ERROR"}'); } $this -> query('INSERT INTO mailinglists (uid, name, email) VALUES (?, ?, ?)', 'iss', [$this -> getID($_GET['db'])['id'], $_POST['name'], $_POST['email'] ]); } } ?>

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
5.4.310.0070.07319.20
5.4.300.0030.04319.13
5.4.290.0030.07019.31
5.4.280.0070.07018.94
5.4.270.0070.07019.20
5.4.260.0030.06718.97
5.4.250.0030.07319.19
5.4.240.0000.07018.85
5.4.230.0000.07319.05
5.4.220.0130.03718.86
5.4.210.0170.04018.96
5.4.200.0000.04018.84
5.4.190.0000.07719.23
5.4.180.0070.07318.84
5.4.170.0070.07719.30
5.4.160.0000.04719.21
5.4.150.0100.05718.93
5.4.140.0030.06316.51
5.4.130.0000.07316.51
5.4.120.0030.07316.40
5.4.110.0070.04316.63
5.4.100.0070.07016.61
5.4.90.0070.06716.64
5.4.80.0070.06716.42
5.4.70.0000.08016.49
5.4.60.0100.04316.45
5.4.50.0070.06316.50
5.4.40.0070.06716.60
5.4.30.0030.07016.23
5.4.20.0100.04016.56
5.4.10.0030.07016.47
5.4.00.0100.05315.83
5.3.290.0070.04314.79
5.3.280.0030.05714.52
5.3.270.0070.07314.64
5.3.260.0070.04314.58
5.3.250.0030.06714.60
5.3.240.0000.04714.54
5.3.230.0070.06014.52
5.3.220.0070.07014.49
5.3.210.0030.05014.48
5.3.200.0030.04314.55
5.3.190.0000.07314.70
5.3.180.0030.04314.58
5.3.170.0070.05714.55
5.3.160.0030.07714.80
5.3.150.0000.07714.57
5.3.140.0030.07314.48
5.3.130.0030.07314.61
5.3.120.0030.05014.56
5.3.110.0030.07314.57
5.3.100.0070.07013.97
5.3.90.0100.07013.93
5.3.80.0100.06313.99
5.3.70.0030.04013.95
5.3.60.0070.04014.12
5.3.50.0030.06314.01
5.3.40.0000.04714.08
5.3.30.0100.04013.83
5.3.20.0030.05013.80
5.3.10.0000.07013.80
5.3.00.0070.03713.80
5.2.170.0000.04013.80
5.2.160.0000.05013.80
5.2.150.0000.06713.80
5.2.140.0030.05713.80
5.2.130.0070.06013.80
5.2.120.0070.02713.80
5.2.110.0030.03313.80
5.2.100.0100.05713.80
5.2.90.0100.05013.80
5.2.80.0030.06313.80
5.2.70.0030.06013.80
5.2.60.0030.04713.80
5.2.50.0030.05713.80
5.2.40.0070.06313.80
5.2.30.0000.03713.80
5.2.20.0030.06013.80
5.2.10.0000.05713.80
5.2.00.0070.04313.80
5.1.60.0000.05713.80
5.1.50.0070.02013.80
5.1.40.0000.05313.80
5.1.30.0030.03313.80
5.1.20.0000.06013.80
5.1.10.0070.04013.80
5.1.00.0030.05313.80
5.0.50.0000.04013.80
5.0.40.0030.04313.80
5.0.30.0070.06013.80
5.0.20.0070.03313.80
5.0.10.0030.02713.80
5.0.00.0030.03313.80
4.4.90.0000.03713.80
4.4.80.0000.02013.80
4.4.70.0070.02713.80
4.4.60.0000.01713.80
4.4.50.0030.03013.80
4.4.40.0000.02713.80
4.4.30.0030.03313.80
4.4.20.0030.02713.80
4.4.10.0000.03713.80
4.4.00.0070.03013.80
4.3.110.0000.03713.80
4.3.100.0000.03713.80
4.3.90.0000.03013.80
4.3.80.0070.02313.80
4.3.70.0000.03713.80
4.3.60.0000.03013.80
4.3.50.0030.03013.80
4.3.40.0000.05713.80
4.3.30.0070.03313.80
4.3.20.0000.04013.80
4.3.10.0000.03713.80
4.3.00.0000.01713.80

preferences:
139.55 ms | 1394 KiB | 7 Q