3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php include("config.php"); if (get_magic_quotes_gpc()) { $process = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST); while (list($key, $val) = each($process)) { foreach ($val as $k => $v) { unset($process[$key][$k]); if (is_array($v)) { $process[$key][stripslashes($k)] = $v; $process[] = &$process[$key][stripslashes($k)]; } else { $process[$key][stripslashes($k)] = stripslashes($v); } } } unset($process); } $sql=mysql_query("SELECT * FROM `settings`") or die(mysql_error()); $settings=array(); while($line=mysql_fetch_assoc($sql)) { $settings[$line['setting']]=stripslashes($line['value']); } $settings['mailadress']=$settings['mailadress']; $servermail=$settings['mailadress']; $systemmail=$settings['mailadress']; $systemmailofferte=$settings['mailadress']; $systemmailorder=$settings['mailadress']; $mailname=$settings['mailname']; $cookiepath='/'; $cookiedomain=$site_url; date_default_timezone_set('Europe/Amsterdam'); setlocale(LC_ALL, 'nl_NL'); setlocale(LC_NUMERIC,""); $errmessg=''; $messg=''; if(is_file('./classes_files/config.php')){ include('./classes_files/config.php'); } $verzendkosten=$settings['shippingcosts']; $verzendkosten_rembours=$settings['costs_rembours']; $home = "home"; $homeId = "1"; $basistitle = $site_url; $basismeta = $site_url; function get_page_id() { global $basistitle,$site_url; $url_string = $_SERVER['REQUEST_URI']; if(strpos($url_string,"?")) $url_string=substr($url_string,0,strpos($url_string,"?")); $basestring = ""; $url_string = str_replace( $basestring, '', $url_string ); $substring = explode( '/', $url_string ); $i = 0; $next_id = 0; foreach( $substring as $title ) { if($title != '') { $i++; $query = "select Id, volg, url from pagina where url = '" . strtolower(addslashes($title)) . "' AND volg = '" . $next_id . "' LIMIT 0,1"; $sql = mysql_query($query) or die ( mysql_error() ); $aantal = mysql_num_rows($sql); if ( $aantal > 0 ) { $line = mysql_fetch_assoc( $sql ); $next_id = $line['Id']; } else { $query="SELECT redirect.volg,redirect.url,redirect.id_nieuw,pagina.title FROM `redirect`,pagina WHERE redirect.id_nieuw=pagina.Id AND `redirect`.`url`='".strtolower(addslashes($title))."' AND `redirect`.volg = '" . $next_id . "'"; $sql_redirect=mysql_query($query) or die (mysql_error()); if(mysql_num_rows($sql_redirect) > 0) { $row_redirect=mysql_fetch_assoc($sql_redirect); $new_id=$row_redirect['id_nieuw']; $location=id2url($new_id); header("Location: $site_url/301.php"); exit; }else{ header("Location: $site_url/404.php"); exit; } } } } return $next_id; } function get_cats($basisID=0) { $cat_array=array(); function cat_line($cat_line_id) { $query="SELECT Id,product FROM pagina WHERE volg='".$cat_line_id."'"; $sql=mysql_query($query); while($row=mysql_fetch_assoc($sql)) { if($row['product']) { return true; }elseif(cat_line($row['Id']) === true) { return true; } } } $sql=mysql_query("SELECT `Id`,`url`,`title`,`picture` FROM `pagina` WHERE `visible`='1' AND `volg`='$basisID' AND `product`='0' ORDER BY `sort`"); while($row=mysql_fetch_assoc($sql)) { if(cat_line($row['Id']) === true) { $cat_array[]=$row; } } return $cat_array; } function secondsToWords($seconds) { $ret = ""; $days = intval(intval($seconds) / (3600*24)); if($days> 0) { $ret .= "$days days "; } $hours = (intval($seconds) / 3600) % 24; if($hours > 0) { $ret .= "$hours hours "; } $minutes = (intval($seconds) / 60) % 60; if($minutes > 0) { $ret .= "$minutes minutes "; } $seconds = intval($seconds) % 60; if ($seconds > 0) { $ret .= "$seconds seconds"; } return $ret; }//print secondsToWords($time); function get_url($pos) { if ( $pos ) { $waardes = explode( "/", $_SERVER['REQUEST_URI'] ); if(strstr($waardes[$pos],'?')) { return ""; } else { return strtolower($waardes[$pos]); } } else { $error = "Geen waarde opgegeven"; return $error; } } function last_url() { $waardes = explode( "/", $_SERVER['REQUEST_URI'] ); foreach( $waardes as $key => $value ){ $laatste = $value; $last_key = $key; } if ( $laatste == "" ) { $nr = $last_key-1; $result = $waardes[$nr]; } else { $result = $laatste; } return $result; } function mkurl($input) { global $errmessg; $site_url = $input; $lettertekens=array('ü'=>'ue', 'ö'=>'oe', 'ä'=>'ae', 'ü'=>'ue', 'ë'=>'e', 'ï'=>'i', 'ÿ'=>'y', 'ij'=>'ij', 'ß'=>'ss', 'í'=>'i', 'é'=>'e', 'á'=>'a', 'ó'=>'o', 'ú'=>'u', 'ì'=>'i', 'è'=>'e', 'à'=>'a', 'ù'=>'u', 'ã'=>'a', 'õ'=>'o', 'ê'=>'e', 'â'=>'a', 'ô'=>'o', 'û'=>'u', 'ç'=>'c', 'æ'=>'ae', '&'=>'+' ); foreach($lettertekens as $origineel=>$nieuw) { $site_url=str_replace($origineel,$nieuw,$site_url); } $site_url = strtolower(trim($site_url)); $site_url = str_replace("%20", " ", $site_url); $site_url = str_replace(" ", "-", $site_url); $site_url = eregi_replace("[^-[:alnum:] +]","",$site_url); $site_url = eregi_replace("-+", "-", $site_url); return $site_url; } function check_img($img, $i) { $imagearray = getimagesize($img); if($i==1) { return $imagearray[0]; } elseif($i==2) { return $imagearray[1]; } } function is_valid_email_address($email){ $no_ws_ctl = "[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f]"; $alpha = "[\\x41-\\x5a\\x61-\\x7a]"; $digit = "[\\x30-\\x39]"; $cr = "\\x0d"; $lf = "\\x0a"; $crlf = "($cr$lf)"; $obs_char = "[\\x00-\\x09\\x0b\\x0c\\x0e-\\x7f]"; $obs_text = "($lf*$cr*($obs_char$lf*$cr*)*)"; $text = "([\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f]|$obs_text)"; $obs_qp = "(\\x5c[\\x00-\\x7f])"; $quoted_pair = "(\\x5c$text|$obs_qp)"; $wsp = "[\\x20\\x09]"; $obs_fws = "($wsp+($crlf$wsp+)*)"; $fws = "((($wsp*$crlf)?$wsp+)|$obs_fws)"; $ctext = "($no_ws_ctl|[\\x21-\\x27\\x2A-\\x5b\\x5d-\\x7e])"; $ccontent = "($ctext|$quoted_pair)"; $comment = "(\\x28($fws?$ccontent)*$fws?\\x29)"; $cfws = "(($fws?$comment)*($fws?$comment|$fws))"; $cfws = "$fws*"; $atext = "($alpha|$digit|[\\x21\\x23-\\x27\\x2a\\x2b\\x2d\\x2f\\x3d\\x3f\\x5e\\x5f\\x60\\x7b-\\x7e])"; $atom = "($cfws?$atext+$cfws?)"; $qtext = "($no_ws_ctl|[\\x21\\x23-\\x5b\\x5d-\\x7e])"; $qcontent = "($qtext|$quoted_pair)"; $quoted_string = "($cfws?\\x22($fws?$qcontent)*$fws?\\x22$cfws?)"; $word = "($atom|$quoted_string)"; $obs_local_part = "($word(\\x2e$word)*)"; $obs_domain = "($atom(\\x2e$atom)*)"; $dot_atom_text = "($atext+(\\x2e$atext+)*)"; $dot_atom = "($cfws?$dot_atom_text$cfws?)"; $dtext = "($no_ws_ctl|[\\x21-\\x5a\\x5e-\\x7e])"; $dcontent = "($dtext|$quoted_pair)"; $domain_literal = "($cfws?\\x5b($fws?$dcontent)*$fws?\\x5d$cfws?)"; $local_part = "($dot_atom|$quoted_string|$obs_local_part)"; $domain = "($dot_atom|$domain_literal|$obs_domain)"; $addr_spec = "($local_part\\x40$domain)"; $done = 0; while(!$done){ $new = preg_replace("!$comment!", '', $email); if (strlen($new) == strlen($email)){ $done = 1; } $email = $new; } return preg_match("!^$addr_spec$!", $email) ? 1 : 0; } function id2url($paginaid){ $i=0; $zoek_url=''; while ($paginaid != 0 && $i<100) { $i++; $query1 = "SELECT `url`, `id`, `volg` FROM `pagina` WHERE `id` = '".$paginaid."' LIMIT 0,1"; $result1 = mysql_query($query1) or die (mysql_error()); while($row1 = mysql_fetch_array($result1)) { $zoek_url = $row1["url"] . "/" . $zoek_url; $paginaid = $row1["volg"]; } } return $zoek_url; } function url2id($url_string='') { global $site_url; if($url_string == '') { $url_string = $_SERVER['REQUEST_URI']; } if(substr($url_string,0,7) == 'http://') $basestring=$site_url; else $basestring = "/"; $substring1 = str_replace( $basestring, '/', $url_string ); if(strpos($substring1,'?')) $substring1 = substr($substring1,0,strpos($substring1,'?')); $substring = explode( '/', $substring1 ); $i = 0; $next_id = 0; foreach( $substring as $title ) { if($title != '') { $query = "SELECT id, volg, url from pagina where url = '".strtolower(addslashes($title))."' AND volg = '".$next_id."' LIMIT 0,1"; $sql = mysql_query($query) or die ( mysql_error() ); $aantal = mysql_num_rows($sql); if ( $aantal > 0 ) { $line = mysql_fetch_assoc($sql); $next_id = $line['id']; } else { return false; } } } return $next_id; } function discount($art_url) { $discount=0; $url_array=explode('/',$art_url); $i=count($url_array)-2; while($i>=0) { $werk_url=''; $c=$i; while($c>=0) { if($url_array[$c] != '') $werk_url=$url_array[$c].'/'.$werk_url; $c--; } $pagina_id=url2id('/'.$werk_url); $query="SELECT `discount` FROM `pagina` WHERE `id`='".$pagina_id."' LIMIT 0,1"; $sql=mysql_query($query); $line_pagina=mysql_fetch_assoc($sql); if(mysql_num_rows($sql) > 0) { if($line_pagina['discount'] > 0) { $discount=$line_pagina['discount']; break 1; } } $i--; } return $discount; } function clean_pages() { global $errmessg,$realpath; $sql=mysql_query("SELECT `id`,`product_id`,`product`,`volg`,`title`,`url` FROM `pagina`") or die(mysql_error()); $pages=array(); while($line = mysql_fetch_assoc($sql)) { $pages[$line['id']]=$line; } $sql=mysql_query("SELECT `id`,`picture` FROM `producten`") or die(mysql_error()); $producten=array(); while($line = mysql_fetch_assoc($sql)) { $producten[$line['id']]=$line; } $update_producten=false; $update_pages=false; foreach($pages as $page) { if($page['product'] == 0) { mysql_query("UPDATE `pagina` SET `product_id`='0' WHERE `id`='".$page['id']."'"); } if(!array_key_exists($page['volg'],$pages) && $page['volg']!= 0) { $query="DELETE FROM `pagina` WHERE `id`='".$page['id']."'"; $errmessg.='Verwijderen van pagina: '.$page['title'].'<br />'; mysql_query($query) or die(mysql_error()); $update_pages=true; } } foreach($producten as $product_line) { $found=false; $productid=$product_line['id']; foreach($pages as $page_line) { if($page_line['product_id'] == $productid && $page_line['product']=='1') { $found=true; } } if($found === false) { if($product_line['picture'] != '') { $pictures=explode(',',$product_line['picture']); foreach($pictures as $picture_line) { $image=$realpath.'images/product-module/'.$picture_line; $errmessg.='picture in database :'.$image.'<br />'; if(is_file($image)) { $errmessg.='picture verwijderd :'.$image.'<br />'; } $image=''; } } $query="DELETE FROM `producten` WHERE `id`='".$productid."'"; mysql_query($query) or die(mysql_error()); $errmessg.='Verwijderen van product '.$productid.'<br />'; $update_producten=true; } } if($update_pages) mysql_query("OPTIMIZE TABLE `pagina`"); if($update_producten) mysql_query("OPTIMIZE TABLE `producten`"); if($update_pages || $update_producten) return true; else return false; } function html2txt($document){ $search = array('@<script[^>]*?>.*?</script>@si', '@<[\\/\\!]*?[^<>]*?>@si', '@<style[^>]*?>.*?</style>@siU', '@<![\\s\\S]*?--[ \\t\\n\\r]*>@' ); $text = preg_replace($search, '', $document); return $text; } if( !function_exists('apache_request_headers') ) { function apache_request_headers() { $arh = array(); $rx_http = '/\AHTTP_/'; foreach($_SERVER as $key => $val) { if( preg_match($rx_http, $key) ) { $arh_key = preg_replace($rx_http, '', $key); $rx_matches = array(); $rx_matches = explode('_', $arh_key); if( count($rx_matches) > 0 and strlen($arh_key) > 2 ) { foreach($rx_matches as $ak_key => $ak_val) $rx_matches[$ak_key] = ucfirst($ak_val); $arh_key = implode('-', $rx_matches); } $arh[$arh_key] = $val; } } return( $arh ); } } function emptyImage($picture) { if ($picture == '') { return NO_IMAGE; } } function getpicture($db_pictures, $nbr = 1) { $pictures = array(); if ($db_pictures != '') { $db_picture = explode(',', $db_pictures); } for ($i=0;$i<$nbr;$i++){ if (is_file(IMAGE_PRODUCT_DIR . $pictures[$i])) { $pictures[$i] = $db_picture[$i]; } else { $pictures[$i] = GEEN_picture; } } return $pictures; } function smart_trim($text, $max_len, $trim_middle = false, $trim_chars = '...') { $text = trim($text); if (strlen($text) < $max_len) { return $text; } elseif ($trim_middle) { $hasSpace = strpos($text, ' '); if (!$hasSpace) { $first_half = substr($text, 0, $max_len / 2); $last_half = substr($text, -($max_len - strlen($first_half))); } else { $last_half = substr($text, -($max_len / 2)); $last_half = trim($last_half); $last_space = strrpos($last_half, ' '); if (!($last_space === false)) { $last_half = substr($last_half, $last_space + 1); } $first_half = substr($text, 0, $max_len - strlen($last_half)); $first_half = trim($first_half); if (substr($text, $max_len - strlen($last_half), 1) == ' ') { $first_space = $max_len - strlen($last_half); } else { $first_space = strrpos($first_half, ' '); } if (!($first_space === false)) { $first_half = substr($text, 0, $first_space); } } return $first_half.$trim_chars.$last_half; } else { $trimmed_text = substr($text, 0, $max_len); $trimmed_text = trim($trimmed_text); if (substr($text, $max_len, 1) == ' ') { $last_space = $max_len; } else { $last_space = strrpos($trimmed_text, ' '); } if (!($last_space === false)) { $trimmed_text = substr($trimmed_text, 0, $last_space); } return remove_trailing_punctuation($trimmed_text).$trim_chars; } } function remove_trailing_punctuation($text) { return preg_replace("'[^a-zA-Z_0-9]+$'s", '', $text); } function xmlspecialchars($text) { return str_replace('&#039;', '&apos;', htmlspecialchars($text, ENT_QUOTES)); } ?> NOWDOC; $new = preg_replace('/mysql_([a-zA-Z_]+)\(/', 'mysqli_$1($GLOBALS[\'link\'], ', $old); $new = str_replace('mysqli_connect($GLOBALS[\'link\'], ', 'mysqli_connect(', $new); $new = str_replace(', )', ')', $new); echo $new;
Output for 7.3.0rc3 - 7.3.0rc4
Warning: include(): open_basedir restriction in effect. File(config.php) is not within the allowed path(s): (/tmp:/in:/etc) in /in/BoATP on line 2 Warning: include(config.php): failed to open stream: Operation not permitted in /in/BoATP on line 2 Warning: include(): Failed opening 'config.php' for inclusion (include_path='.:') in /in/BoATP on line 2 Fatal error: Uncaught Error: Call to undefined function mysql_query() in /in/BoATP:20 Stack trace: #0 {main} thrown in /in/BoATP on line 20
Process exited with code 255.
Output for 7.0.0 - 7.1.10, 7.2.0, 7.3.0alpha1 - 7.3.0beta1
Warning: include(config.php): failed to open stream: No such file or directory in /in/BoATP on line 2 Warning: include(): Failed opening 'config.php' for inclusion (include_path='.:') in /in/BoATP on line 2 Fatal error: Uncaught Error: Call to undefined function mysql_query() in /in/BoATP:20 Stack trace: #0 {main} thrown in /in/BoATP on line 20
Process exited with code 255.
Output for 7.1.20, 7.2.6
Warning: include(): open_basedir restriction in effect. File(config.php) is not within the allowed path(s): (/tmp:/in) in /in/BoATP on line 2 Warning: include(config.php): failed to open stream: Operation not permitted in /in/BoATP on line 2 Warning: include(): Failed opening 'config.php' for inclusion (include_path='.:') in /in/BoATP on line 2 Fatal error: Uncaught Error: Call to undefined function mysql_query() in /in/BoATP:20 Stack trace: #0 {main} thrown in /in/BoATP on line 20
Process exited with code 255.
Output for 5.3.0 - 5.6.28
Warning: include(config.php): failed to open stream: No such file or directory in /in/BoATP on line 2 Warning: include(): Failed opening 'config.php' for inclusion (include_path='.:') in /in/BoATP on line 2 Fatal error: Call to undefined function mysql_query() in /in/BoATP on line 20
Process exited with code 255.