3v4l.org

run code in 300+ PHP versions simultaneously
<?php $tpl['title']='Админка'; include 'func.php'; if (isset($_COOKIE['user']) && $_COOKIE['status']<=3) { $tpl['menu']='<a href="build.php"> BUILD</a><br> <a href="admin.php?act=pages">Страницы</a><br> <a href="admin.php?act=users">Пользователи</a><br> <a href="admin.php?act=files">Файлы</a><br> <a href="admin.php?act=settings">Настройки</a><br> <a href="admin.php?act=upload">UPLOAD</a>'; function perms($file) { echo substr(sprintf('%o', fileperms($file)), -4); } $dirrw=realpath(isset($_REQUEST['dir'])? $_REQUEST['dir']:'.').'/'; $htmlchars = Array( "<" => "&lt;", ">" => "&gt;", "\"" => "&quot;", "&" => "&amp;"); $p=$_REQUEST; if (isset($_GET['dir'])) $p['act']='files'; switch ($p['act']) { case 'recrmdir': function dir_remove($dir) { if (!file_exists($dir)) return false; $dir_arr = array_diff( scandir($dir), Array('.', '..') ); foreach ($dir_arr as $f) { if (is_file($dir.'/'.$f)) { unlink($dir.'/'.$f); echo 'Удален файл '.$dir.'/'.$f.'<br>'; } elseif (is_dir($dir.'/'.$f)) { echo 'Удалена папка '.$dir.'/'.$f.'<br>'; dir_remove($dir.'/'.$f); } } if(file_exists($dir)) rmdir($dir); } echo '<div class="ok">'; dir_remove($p['z']); echo '</div>'; break; case 'chmod': eval('chmod(\'' . $p['z'] . '\',0' . $p['x'] . ');'); echo 'Права изменены '.$p['z'] . '--> ' . $p['x']; break; case 'save': $asg = str_replace($p['r'], $p['t'], implode("\n", array_filter($p['s']))); $asg=str_replace("\n\n","\n",$asg); $cv = file_put_contents($p['a'], $asg); break; case 'edit': echo '</div><form action="admin.php" method="post"> <input type="hidden" name="act" value="rename"> <input type="hidden" name="z" value="' . $p['z'] . '"><br> Переименовать:<br><input type="text" name="newname" value="'.basename($p['z']).'"><input type="submit"></form> <form action="admin.php" method="post"> <input type="hidden" name="act" value="chmod"> <input type="hidden" name="z" value="' . $p['z'] . '"><br>Изм. права:<br><input type="text" name="x" value="'; perms($p['z']); echo '"><input type="submit"></form><br><a href="admin.php?act=editstr&z=' . $p['z'] . '">Редактировать</a><br><br>'; tpl(); case 'editstr': { $countt=count(file($p['z'])); echo '</div><form action="admin.php" method="post"> <input type="hidden" name="act" value="save"> <input type="textarea" value="' . $p['z'] . '" name="a"><br>Заменить:<textarea name="r"></textarea> <br>На:<textarea name="t"></textarea><br> <textarea name="s[]" rows="'.$countt.'" cols="50">' . strtr(file_get_contents($p['z']), $htmlchars) . '</textarea> <br><input type="submit"></form>'; tpl(); break; } case 'rename': { rename($p['z'], dirname($p['z']).'/'.$p['newname']); break; } case 'Переместить': { foreach ($p['file'] as $files) { if (rename($files,realpath(dirname($files).'/'.$p['dirr']).'/'.basename($files))) { echo 'Перемещено!'; } } break; } case 'Копировать': { foreach ($p['file'] as $files) { if (copy($files,realpath(dirname($files).'/'.$p['dirr']).'/'.basename($files))) { echo 'Скопирован' . $files . ' в ' . $p['dirr'] . '<br>'; } else echo 'Не скопирован: ' . $p['z']; } break; } case 'Удалить': { foreach ($p['file'] as $files) { if (unlink($files)) echo 'Удален файл ' . $files . '<br>'; } break; } case 'mkdir': { if (mkdir($p['z'], 0777)) echo '<div class="ok">Папка ' . $p['z'] . ' создана</div>'; else echo '<div class="error">Папка ' . $p['z'] . ' не создана</div>'; break; } case 'rmdir': { if (rmdir($p['z'])) echo '<div class="ok">Папка ' . $p['z'] . ' удалена</div>'; else echo '<div class="error">Папка ' . $p['z'] . ' не удалена</div>'; break; } case 'mkfile': { if (file_exists($p['z'])) echo '<div class="warning">Файл ' . $p['z'] . ' существует</div>'; else { echo '<div class="ok">Файл ' . $p['z'] . ' создан</div>'; $fp = fopen($p['z'], 'w+'); } } break; case 'files': echo '<br>'; #start of file list if ($handle = opendir($dirrw)) { echo '<form action="admin.php" method="post"><input type="text" name="z"><select name="act"><option value="mkdir">Папка <option value="mkfile">Файл</select><input type="submit" value="Создать"></form><form action="admin.php" method="get"> <input type="submit" name="act" value="Удалить"><br> <input type="submit" name="act" value="Переместить"><br> <input type="submit" name="act" value="Копировать"><br> <input type="text" name="dirr"><br>'; $arrwe = Array(); while (false !== ($fle = readdir($handle))) { if ($fle != ".") { if (is_dir($dirrw.$fle)) { $arrdirs[] = $fle; } else { $arrfls[]= $fle; } } } if (count($arrdirs)>=1) { sort($arrdirs); foreach ($arrdirs as $arrw) { echo '<b><a href="admin.php?dir=' . $dirrw . $arrw . '/">' . $arrw . '/</a></b> <a href="admin.php?act=rmdir&z=' . $dirrw . $arrw . '">[Удалить</a><a href="admin.php?act=recrmdir&z=' . $dirrw . $arrw . '">[рекурс.]]</a> '; $perms = $dirrw . $arrw; perms($perms); echo '<hr>'; } } else echo '<br>Нет папок!<br>'; if (count($arrfls)>=1) { sort($arrfls); echo 'Файлы:<br>'; foreach ($arrfls as $arrw) { echo '<input type="checkbox" name="file[]" value="' . $dirrw . $arrw . '">'; echo '<a href="admin.php?act=edit&z='.$dirrw.$arrw . '">' . $arrw . '</a>'; if (strstr($arrw, '.zip')) echo ' <a href="arch.php?file=' . $dirrw . $arrw . '">[Просм.]</a> <a href="arch.php?s=unpack&file=' . $dirrw . $arrw . '">[^^^]</a> '; echo ' <a href="dl.php?f=' . $dirrw . $arrw . '&name='.$arrw.'">[Скачать]</a> <a href="look.php?q='.$dirrw.$arrw.'">[Откр.]</a><br> '; if (filesize($dirrw.$arrw)<1000) echo filesize($dirrw.$arrw).' байт'; elseif (filesize($dirrw.$arrw)>(1024*1024)) echo round(filesize($dirrw.$arrw)/(1024*1024),1).' Мб'; elseif (filesize($dirrw.$arrw)>999) echo round(filesize($dirrw.$arrw)/1024,1).' Кб'; echo ' ('; perms($dirrw.$arrw); echo ')<hr>'; } } else echo '<div class="warning">Нет файлов!</div>'; closedir($handle); echo '</form>'; } break; case 'upload': echo '<form enctype="multipart/form-data" action="upload.php" method="post"> <input type="file" name="1" size=11><br> <input type="textarea" name="filename1"><br> <input type="file" name="2" size=11><br> <input type="textarea" name="filename2"><br> <input type="file" name="3" size=11><br> <input type="textarea" name="filename3" value=""><br> Папка:<br><input type="textarea" name="dir" value=""><br> <input type="submit" value="Выкачать"> </form>'; break; case 'pages': { if ($handle = opendir('pages')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != ".." && !is_dir('pages/'.$file)) { echo '<a href="index.php?a='.$file.'">'.$file.'</a>'; echo ' <a href="admin.php?act=Удалить&file[]=pages/'.$file.'">Удалить</a> '; echo ' <a href="admin.php?act=edit&z=pages/'.$file.'">Ред.</a><hr>'; } } closedir($handle); } } break; case 'users': { if (!empty($p['ban'])) { echo 'Пользователь "'.$p['ban'].'" забанен!<br>'; replace_ini('users/'.$p['ban'],array('ban'=>'1')); } if (!empty($p['del'])) { unlink('users/'.$p['del']); } if ($handle = opendir('users')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != ".." && !is_dir('users/'.$file)) { echo '<a href="user.php?user='.$file.'">'.$file.'</a>'; echo ' <a href="admin.php?act=users&del='.$file.'">Удалить</a> '; echo ' <a href="admin.php?act=edit&z=users/'.$file.'">Ред.</a> <a href="admin.php?act=users&ban='.$file.'">Банить</a><hr>'; } } closedir($handle); } break; } case 'settings': { echo '<form action="admin.php" method="post"><input type="hidden" name="z" value="config.ini"><input type="hidden" name="act" value="conf">'; $conf=parse_ini_file('config.ini'); echo 'Имя сайта:<textarea name="s[sitename]" cols="40" rows="3">' . $conf['sitename'] . '</textarea><br>'; echo 'Адрес сайта:<textarea name="s[addr]" cols="40" rows="3">' . $conf['addr'] . '</textarea><br>'; echo 'Сообщение о закрытом сайте:<textarea name="s[offmsg]" cols="40" rows="3">' . $conf['offmsg'] . '</textarea><br>'; echo '<input type="radio" name="site" value="1" '; if ($conf['site']==1) echo 'checked'; echo '> Сайт вкл.<input type="submit" value="save"></form>'; } break; case 'conf': { replace_ini($p['z'],$p['s']); } break; } } else echo '<div class="error">404 страница не найдена</div>'; tpl(); ?>
Output for 8.0.14 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Warning: include(): open_basedir restriction in effect. File(func.php) is not within the allowed path(s): (/tmp:/in:/etc) in /in/qbRm7 on line 3 Warning: include(func.php): Failed to open stream: Operation not permitted in /in/qbRm7 on line 3 Warning: include(): Failed opening 'func.php' for inclusion (include_path='.:') in /in/qbRm7 on line 3 <div class="error">404 страница не найдена</div> Fatal error: Uncaught Error: Call to undefined function tpl() in /in/qbRm7:222 Stack trace: #0 {main} thrown in /in/qbRm7 on line 222
Process exited with code 255.
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Warning: include(): open_basedir restriction in effect. File(func.php) is not within the allowed path(s): (/tmp:/in:/etc) in /in/qbRm7 on line 3 Warning: include(func.php): Failed to open stream: Operation not permitted in /in/qbRm7 on line 3 Warning: include(): Failed opening 'func.php' for inclusion (include_path='.:') in /in/qbRm7 on line 3 <div class="error">404 страница не найдена</div> Fatal error: Uncaught Error: Call to undefined function tpl() in /in/qbRm7:222 Stack trace: #0 {main} thrown in /in/qbRm7 on line 222
Process exited with code 255.
Output for 8.0.0 - 8.0.13
Warning: include(func.php): Failed to open stream: No such file or directory in /in/qbRm7 on line 3 Warning: include(): Failed opening 'func.php' for inclusion (include_path='.:') in /in/qbRm7 on line 3 <div class="error">404 страница не найдена</div> Fatal error: Uncaught Error: Call to undefined function tpl() in /in/qbRm7:222 Stack trace: #0 {main} thrown in /in/qbRm7 on line 222
Process exited with code 255.
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.25, 7.4.33
Warning: include(func.php): failed to open stream: No such file or directory in /in/qbRm7 on line 3 Warning: include(): Failed opening 'func.php' for inclusion (include_path='.:') in /in/qbRm7 on line 3 <div class="error">404 страница не найдена</div> Fatal error: Uncaught Error: Call to undefined function tpl() in /in/qbRm7:222 Stack trace: #0 {main} thrown in /in/qbRm7 on line 222
Process exited with code 255.
Output for 7.4.26 - 7.4.32
Warning: include(): open_basedir restriction in effect. File(func.php) is not within the allowed path(s): (/tmp:/in:/etc) in /in/qbRm7 on line 3 Warning: include(func.php): failed to open stream: Operation not permitted in /in/qbRm7 on line 3 Warning: include(): Failed opening 'func.php' for inclusion (include_path='.:') in /in/qbRm7 on line 3 <div class="error">404 страница не найдена</div> Fatal error: Uncaught Error: Call to undefined function tpl() in /in/qbRm7:222 Stack trace: #0 {main} thrown in /in/qbRm7 on line 222
Process exited with code 255.
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
Warning: include(func.php): failed to open stream: No such file or directory in /in/qbRm7 on line 3 Warning: include(): Failed opening 'func.php' for inclusion (include_path='.:') in /in/qbRm7 on line 3 <div class="error">404 страница не найдена</div> Fatal error: Call to undefined function tpl() in /in/qbRm7 on line 222
Process exited with code 255.

preferences:
264.32 ms | 402 KiB | 385 Q