WebProgramming
HTTP http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol
http://en.wikipedia.org/wiki/Web_service
http://en.wikipedia.org/wiki/Service-oriented_architecture
< stands for '< ' > is used for '>' " for "
and because these codes also give the ampersand character a special meaning, a plain '&' is written as '&'.
http://javascript.ru http://www.webreference.com/programming/javascript
http://www.javascript-coder.com
http://interglacial.com/hoj/hoj.html Higher-Order JavaScript
http://www.crockford.com http://video.yahoo.com/watch/111593
http://jslint.com Lint
function forEach(array, action) {
for (var i = 0; i < array.length; i++)
action(array[i]);
}
forEach(["Wampeter", "Foma", "Granfalloon"], print);
function map(func, array) {
var result = [];
forEach(array, function (element) {
result.push(func(element));
});
return result;
}
show(map(Math.round, [0.01, 2, 9.89, Math.PI]));
function reduce(combine, base, array) {
forEach(array, function (element) {
base = combine(base, element);
});
return base;
}
function add(a, b) {
return a + b;
}
function sum(numbers) {
return reduce(add, 0, numbers);
}
show(sum([1,2,3]));
//we can write reduce(op["+"], 0, [1, 2, 3, 4, 5]) to sum array
var op = {
"+": function(a, b){return a + b;},
"==": function(a, b){return a == b;},
"===": function(a, b){return a === b;},
"!": function(a){return !a;}
/* and so on */
};
function asArray(quasiArray, start) {
var result = [];
for (var i = (start || 0); i < quasiArray.length; i++)
result.push(quasiArray[i]);
return result;
}
function partial(func) {
var fixedArgs = asArray(arguments, 1);
return function(){
return func.apply(null, fixedArgs.concat(asArray(arguments)));
};
}
//High order function:
function compose(func1, func2) {
return function() {
return func1(func2.apply(null, arguments));
};
}
function filter(test, array) {
var result = [];
forEach(array, function (element) {
if (test(element))
result.push(element);
});
return result;
}
show(filter(partial(op[">"], 5), [0, 4, 8, 12]));
var isUndefined = partial(op["==="], undefined);
var isDefined = compose(op["!"], isUndefined);
show(isDefined(Math.PI));
show(isDefined(Math.PIE));
function square(x) {return x * x;}
show(map(partial(map, square), [[10, 100], [12, 16], [0, 1]]));
можно сказать браузеру и прокси о том, что страницу не стоит куда-либо сохранять. Для этого в протоколе HTTP есть несколько полей заголовка:
Expires - время жизни страницы;
Last-Modidied - дата последнего изменения;
Cache-Control - параметры управления кешем;
Pragma - тоже самое для версии 1.0;
Подбирая значения этих полей можно управлять процессом кеширования страницы. Например, если дата последнего изменения страницы Last-Modified меньше, чем ее время жизни Expires, то браузер посчитает весьма закономерным поместить эту страницу в кеш. Если мы насильно поменяем значения этих полей, чтобы такое сравнение больше не проходило, то браузер перестанет кешировать эту страницу. Для вывода заголовков HTTP в PHP существует специальная функция header(), в описании которой в качестве примера приведен именно процесс контроля кешем:
<?php
// Date in the past
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
// always modified
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
// HTTP/1.1
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
// HTTP/1.0
header("Pragma: no-cache");
?>
Если Вы будет вставлять этот код в начало каждого PHP файла, то он не будет кешироваться.
Этот код на Internet Explorer действует безотказно, зато почему-то не всегда на Opera и Firefox, возможно и на другие браузеры. Алгоритм их работы не всем известен, и возможно они игнорируют некоторые поля в заголовках ответов HTTP. Тогда в таком случае можно попробовать продублировать эти настройки в коде HTML, про это вы можете подробнее почитать в "Шаг 5 - Что умеет <head> ?".
Например можно создать такой код:
<?php
echo "<meta http-equiv=\"cache-control\" content=\"no-store, no-cache, must-revalidate\">";
echo "<meta http-equiv=\"expires\" content=\"Mon, 26 Jul 1997 05:00:00 GMT\">";
echo "<meta http-equiv=\"last-modified\" content=\"". gmdate("D, d M Y H:i:s") . " GMT\">";
?>
Just use something like this in your CSS styes:
table {
empty-cells:show;
border-collapse:collapse;
}
./bin/apachectl start (stop)
/usr/local/apacheXXX/conf/ file httpd.conf
ServerName 127.0.0.1 localhost
in httpd.conf edit 3 lines : 1) ScriptAlias /php/ "PHP folder name here/" 2) AddType and 3) Action
AddType application/x-httpd-php .php
ScriptAlias /php/ "C:/Program Files/PHP/"
Action application/x-httpd-php "C:/Program Files/PHP/php-cgi.exe"
To find out the currently set time limit, use
ini_get('max_execution_time');
How to change it: http://us3.php.net/set_time_limit
max_execution_time in your php.ini
php_value max_execution_time 60 in the .htaccess
<? set_time_limit(0); ?>
instead creating the file with line <? phpinfo() ?> just type in console: php -i
http://www.onlamp.com/pub/a/php/2004/08/26/PHPformhandling.html
<FORM method=POST action=$PHP_SELF>
<form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
File a1.php:
<form action="a2.php" method="POST">
<?
$arr[]=10; $arr[]=20; $arr[]=30;
$arr = urlencode(serialize($arr));
echo "<input type=hidden name=arr value=$arr />";
?>
<input type="submit" value="GO" />
</form>
File a2.php:
<?php
$arr=$_POST['arr'];
$arr=unserialize(urldecode($arr));
echo "<br>arr count=".count($arr);
print_r($arr);
while (list($key, $value) = each ($arr) )
{ echo "<br>".$key ."=".$value; }
?>
It assumed in next code that your form is submitted via the POST method:
<?php
foreach($_POST as $key=>$value){
if ($key!="submit"){
$value=htmlentities(stripslashes(strip_tags($value)));
echo "\t<input type=\"hidden\" name=\"$key\" value=\"$value\">\n";
}
}
?>
What's that bit of code do? If you were to place the above code between your opening <form> tag and the closing </form> tag, it will look at all values received from the prior page, strips out any HTML tags, replaces any character entities with their appropriate code and writes them to hidden inputs in the current form. It will skip a value of "submit" so it won't duplicate your submit button. If you name your submit button something other than "submit", you should change that bit in the code.
$_FILES["file"]["name"] - the name of the uploaded file
$_FILES["file"]["type"] - the type of the uploaded file , e.g. "image/gif"
$_FILES["file"]["size"] - the size in bytes of the uploaded file
$_FILES["file"]["tmp_name"] - the name of the temporary copy of the file stored on the server
$_FILES["file"]["error"] - the error code resulting from the file upload
temporary copy of the uploaded file located in the PHP temp folder on the server.
The temporary copied files disappears when the script ends. To store the uploaded file we need to copy it to a different location ussing move_uploaded_file
Check the php.ini settings "post_max_size" and "upload_max_size"
memory_limit = 128M
post_max_size = 64M
upload_max_filesize = 32M
file: php.conf
LimitRequestBody=
if POST size exceeds server limit then $_POST and $_FILES arrays become empty. You can track this using $_SERVER['CONTENT_LENGTH'].
<?php
$POST_MAX_SIZE = ini_get('post_max_size');
$mul = substr($POST_MAX_SIZE, -1);
$mul = ($mul == 'M' ? 1048576 : ($mul == 'K' ? 1024 : ($mul == 'G' ? 1073741824 : 1)));
if ($_SERVER['CONTENT_LENGTH'] > $mul*(int)$POST_MAX_SIZE && $POST_MAX_SIZE) $error = true;
?>
http://us2.php.net/manual/ru/features.file-upload.php
http://www.raditha.com/megaupload/ upload progress bar
<?
$max_no_img=4; // Maximum number of images
echo "<form method=post action=up2.php enctype='multipart/form-data'>";
echo "<table border='0' width='400' cellspacing='0' cellpadding='0' align=center>";
for($i=1; $i<=$max_no_img; $i++){
echo "<tr><td>Upload $i</td><td>
<input type=file name='images[]' class='bginput'></td></tr>";
}
echo "</table>";
echo "Parameter:<input type=text name=test value=2>";
echo "<br>";
echo "<input type=submit value='GO'>";
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
echo "</form>";
?>
<html>
<head>
<title>up2.php</title>
</head>
<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">
<?
echo "TEST=".$_POST['test'];
echo "<br>";
while(list($key,$value) = each($_FILES[images][name]))
{
if(!empty($value))
{
$filename = $value;
$add = "upimg/$filename";
echo $_FILES[images][type][$key];
echo "<br>";
copy($_FILES[images][tmp_name][$key], $add);
chmod("$add",0777);
}
}
?>
<center><a href='http://www.plus2net.com'>PHP SQL HTML free tutorials and scripts</a></center>
</body>
</html>
Web services APIs (application programming interfaces), web services protocols like REST and SOAP, the new Facebook platform, Amazon's web services efforts including EC2 and S3,
REST Representational State Transfer http://en.wikipedia.org/wiki/Representational_State_Transfer
The term is often used in a looser sense to describe any simple interface that transmits domain-specific data over HTTP without an additional messaging layer such as SOAP or session tracking via HTTP cookies. These two meanings can conflict as well as overlap. It is possible to design any large software system in accordance with Fielding's REST architectural style without using the HTTP protocol and without interacting with the world wide web. It is also possible to design simple XML+HTTP interfaces that do not conform to REST principles, and instead follow a Remote Procedure Call model. The two different uses of the term "REST" cause some confusion in technical discussions.
Systems that follow Fielding's REST principles are often referred to as RESTful
REST is neither a technology nor a standard; it's an architectural style for exposing resources over the Web. The RESTful architecture adheres to several principles:
Requests are client-server, and by nature, use a pull-based interaction style. Consuming components pull representations of state from the server.
Requests are stateless. Each request from client to server must contain all the information needed to understand the request and cannot take advantage of any stored context on the server.
REST does not necessarily mean there is no state on the middle tier; it means the state to fulfill the request for a resource is not dependent on that state.
Clients and server adhere to a uniform interface. All resources are accessed with a generic interface in the Web-extended SOA world—HTTP along with the HTTP methods: GET, POST, PUT, DELETE.
Clients access named resources. The system comprises resources that are named using a URL, such as an HTTP URL
http://www.silverstripe.org CMS based on PHP
http://start.websitebaker2.org/en/introduction.html CMS based on PHP
http://wiki.python.org/moin/WebFrameworks
http://pinaxproject.com Django extension
Web2py.com http://werkzeug.pocoo.org/
http://galaxy.psu.edu BioInformatics