vave
Полезный
- Регистрация
- 22 Июн 2007
- Сообщения
- 467
- Реакции
- 16
- Автор темы
- #1
Как сделать что бы картинки (превьюшки) обрезались по центру?
вот код
и вот
вот код
PHP:
<?
function safe_data ($firste, $second)
{
if ($second == 'query')
{
if (is_array ($firste))
{
foreach ($firste as $safedatafor => $safedatasry)
{
if (get_magic_quotes_gpc ())
{
$safedatasry = stripslashes ($safedatasry);
}
$firste[$safedatafor] = addslashes ($safedatasry);
}
return $firste;
}
if (get_magic_quotes_gpc ())
{
$safedatasry = stripslashes ($safedatasry);
}
$firste = addslashes (stripslashes ($firste));
return $firste;
}
if ($second == 'display')
{
if (is_array ($firste))
{
foreach ($firste as $safedatafor => $safedatasry)
{
$firste[$safedatafor] = htmlspecialchars (stripslashes ($safedatasry), ENT_QUOTES);
}
return $firste;
}
$firste = htmlspecialchars (stripslashes ($firste), ENT_QUOTES);
}
return $firste;
}
function price ($price)
{
$price = ereg_replace ('[^0-9.]', '', $price);
$price = explode ('.', $price);
return $price[0];
}
function check_pass ($checkpassfirste, $checkpasssecond)
{
$checkpassry = true;
if ($checkpassfirste !== $checkpasssecond)
{
$checkpassry = false;
}
if (!((!(strlen ($checkpassfirste) < 6) AND !(20 < strlen ($checkpassfirste)))))
{
$checkpassry = false;
}
if (!((!ereg ('[[:punct:]]', $checkpassfirste) AND !ereg ('[[:space:]]', $checkpassfirste))))
{
$checkpassry = false;
}
return $checkpassry;
}
function check_user ($checkuserone)
{
$checkpassry = true;
if (!((!(strlen ($checkuserone) < 6) AND !(20 < strlen ($checkuserone)))))
{
$checkpassry = false;
}
if (!((!ereg ('[[:punct:]]', $checkuserone) AND !ereg ('[[:space:]]', $checkuserone))))
{
$checkpassry = false;
}
return $checkpassry;
}
function check_email ($checkemailone)
{
$checkemailtou = '^([_a-z0-9-]+)(\\.[_a-z0-9-]+)*@([a-z0-9-]+)(\\.[a-z0-9-]+)*(\\.[a-z]{2,4})$';
$checkpassry = false;
if (eregi ($checkemailtou, $checkemailone))
{
$checkpassry = true;
}
return $checkpassry;
}
function summary ($summaryone, $summarytou)
{
if ($summarytou < substr_count ($summaryone, ' '))
{
$summaryone = explode (' ', $summaryone);
$summaryone = array_slice ($summaryone, 0, $summarytou);
$summaryone = implode (' ', $summaryone) . ' ...';
}
return $summaryone;
}
function new_dim ($newdimone, $newdimtou, $newdimsry, $newdimfor)
{
if ($newdimsry < $newdimone)
{
$newdimfive = $newdimsry / $newdimone;
$newdimone = $newdimsry;
$newdimtou = round ($newdimtou * $newdimfive);
}
if ($newdimfor < $newdimtou)
{
$newdimfive = $newdimfor / $newdimtou;
$newdimtou = $newdimfor;
$newdimone = round ($newdimone * $newdimfive);
}
return array ('x' => $newdimone, 'y' => $newdimtou);
}
function resize ($resizeone, $resizetou, $newdimone, $newdimtou, $resizestry, $resizefor, $resizefive)
{
if ($resizefive == 2)
{
$resizeone = imagecreatefromjpeg ($resizeone);
$resizesex = imagecreatetruecolor ($resizestry, $resizefor);
imagecopyresampled ($resizesex, $resizeone, 0, 0, 0, 0, $resizestry, $resizefor, $newdimone, $newdimtou);
touch ($resizetou);
imagejpeg ($resizesex, $resizetou, 100);
imagedestroy ($resizesex);
return null;
}
if ($resizefive == 3)
{
$resizeone = imagecreatefrompng ($resizeone);
$resizesex = imagecreatetruecolor ($resizestry, $resizefor);
imagecopyresampled ($resizesex, $resizeone, 0, 0, 0, 0, $resizestry, $resizefor, $newdimone, $newdimtou);
touch ($resizetou);
imagepng ($resizesex, $resizetou, 100);
imagedestroy ($resizesex);
}
}
function dropdown ($dropdownone, $dropdowntou)
{
foreach ($dropdownone as $safedatasry)
{
$safedatasry = str_replace ('', '', $safedatasry);
echo '<option value=\'' . $safedatasry . '\'';
if (trim ($safedatasry) == $dropdowntou)
{
echo ' selected=\'selected\'';
}
echo '>' . trim ($safedatasry) . '</option>';
}
}
function page_links ($firste, $pagelinksone, $pagelinkstou)
{
foreach ($firste as $safedatafor => $safedatasry)
{
if ($safedatafor != 'page')
{
$checkpassfirste .= '&' . $safedatafor . '=' . $safedatasry;
continue;
}
}
if (1 < $firste[page])
{
echo '<a href=\'' . $pagelinkstou . '?page=' . ($firste[page] - 1) . $checkpassfirste . '\'>Prev</a> ';
}
if (1 < $pagelinksone)
{
if (1 <= $firste[page] - 5)
{
$pagelinkssri = $firste[page] - 5;
}
else
{
$pagelinkssri = 1;
}
if ($pagelinkssri + 9 <= $pagelinksone)
{
$pagelinksfor = $pagelinkssri + 9;
}
else
{
$pagelinksfor = $pagelinksone;
if (1 <= $pagelinksfor - 9)
{
$pagelinkssri = $pagelinksfor - 9;
}
else
{
$pagelinkssri = 1;
}
}
for ($pagelinksfive = $pagelinkssri; $pagelinksfive <= $pagelinksfor; ++$pagelinksfive)
{
echo '<a ';
if ($pagelinksfive == $firste[page])
{
echo 'class=\'current\'';
}
echo ' href=\'' . $pagelinkstou . '?page=' . $pagelinksfive . $checkpassfirste . ('\'>' . $pagelinksfive . '</a> ');
}
}
if ($firste[page] < $pagelinksone)
{
echo ' <a href=\'' . $pagelinkstou . '?page=' . ($firste[page] + 1) . $checkpassfirste . '\'>Next</a>';
}
}
function filter_string ($summaryone)
{
$filterstringone = array ('content-type', 'mime-version', 'multipart/mixed', 'content-transfer-encoding', 'bcc:', 'cc:', 'to:');
foreach ($filterstringone as $filterstringtou)
{
if (substr_count (strtolower ($summaryone), $filterstringtou))
{
exit ('Suspected email injection attempt from ' . $_SERVER[REMOTE_ADDR] . ' - mail not being sent.');
}
}
}
function filter_newline ($summaryone)
{
if (preg_match ('/(%0a|%0d|\\n+|\\r+)/i', strtolower ($summaryone)) != 0)
{
exit ('Suspected email injection attempt from ' . $_SERVER[REMOTE_ADDR] . ' - mail not being sent.');
}
}
?>
и вот
PHP:
<?
$lgen = '7jse87w34f';
$user_types = array (1 => 'User', 'Administrator', 'Superuser');
$status = array (1 => 'Available', 'Sale Pending', 'Sold');
$sizes = array ('enlarge' => array (600, 500), 'large' => array (390, 293), 'thumb' => array (150, 250), 'small' => array (67, 50));
?>