在friendfeed上看到这个链接 —— The 140 Characters Webapp Challenge!,这个比赛要求用140个字符的代码造就一个web应用。
里头有36个程序可供投票,基本上全是脚本语言大杂烩:php,perl,ruby,javascript。实现的应用也是五花八门,有相册,类twitter,小游戏,甚至还有php代码框架?摘录如下:
require __DIR__.'/c.php';
if (!is_callable($c = @$_GET['c'] ?: function() { echo 'Woah!'; }))
throw new Exception('Error');
$c();
这段代码利用了php5.3的一些新特性:
__DIR__
Anonymous functions
?:运算符
代码只有131个字符,由于代码极为简陋,安全性也是没得保障的,只能算一个程序的统一入口罢了。
如果用php 5.2来写这段代码,大概就是:
require dirname(__FILE__).'/c.php';
if (!is_callable($c = @$_GET['c'] ? $_GET['c'] : create_function('', "echo 'Woah!';")))
throw new Exception('Error');
$c();
如果要让这段代码变得实用点,可以在$c前面加上一个前缀,这样安全性会有进一步提升,代码也会相应的增加若干字节。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Notepad++7.3.1
Easy-to-use and free code editor
