$myID = 2;
// необходимо получить юзера, который не ты, из первой колонки или из второй
$result = mysql_query("SELECT * FROM dialogs WHERE user_one <> '$myID' OR user_two <> '$myID'");
if (!$result) {
die('Сворачиваемся посоны: ' . mysql_error());
}
$myID = 2;
$result = mysql_query("SELECT * FROM users WHERE users.id = ((SELECT user_one FROM dialogs WHERE user_two = '$myID')OR (SELECT user_two FROM dialogs WHERE user_one = '$myID'))");
function getHTMLOfSelection () {
var range;
if (document.selection && document.selection.createRange) {
range = document.selection.createRange();
return range.htmlText;
}
else if (window.getSelection) {
var selection = window.getSelection();
if (selection.rangeCount > 0) {
range = selection.getRangeAt(0);
var clonedSelection = range.cloneContents();
var div = document.createElement('div');
div.appendChild(clonedSelection);
return div.innerHTML;
}
else {
return '';
}
}
else {
return '';
}
}
var text = window.getSelection();
document.getElementByID('ID поля').value(text);
public function resize($w, $h)
{
if ( isset($this->source) )
{
$set_width = $width = imagesx($this->source);
$set_height = $height = imagesy($this->source);
if ( $h > $height )
$h = $height;
if ( $w > $width )
$w = $width;
if ( $w > 0 && $h > 0 )
{
if ( $width / $height > $w / $h )
$h = 0;
else
$w = 0;
}
if ( $w > 0 )
{
$set_width = $w;
$set_height = $height * $w / $width;
}
if ( $h > 0 )
{
$set_height = $h;
$set_width = $width * $h / $height;
}
$tmp = imagecreatetruecolor($set_width, $set_height);
imagealphablending($tmp, false);
imagesavealpha($tmp, true);
imagecopyresampled($tmp, $this->source, 0, 0, 0, 0, $set_width, $set_height, $width, $height);
return $tmp;
}
}
$this->source = imagecreatefromjpeg($image_file_path);
$src = './orig.jpg';
$trg = './thumb.jpg';
cropAndResize2Square($src, 128, $trg);
function cropAndResize2Square($originalPath, $targetSquareSide, $targetPath){
//get original's dimension
list($origW, $origH) = getimagesize($originalPath);
//create images
$srcImg = imagecreatefromjpeg($originalPath);
$trgImg = imagecreatetruecolor($targetSquareSide, $targetSquareSide);
//calculate source square position and side
if($origW >= $origH){
$srcSquareSide = $origH;
$srcSquareX = ($origW - $targetSquareSide) / 2;
$srcSquareY = 0;
} else {
$srcSquareSide = $origW;
$srcSquareX = 0;
$srcSquareY = ($origH - $targetSquareSide) / 2;
}
imagecopyresampled($trgImg, $srcImg,
0, 0, $srcSquareX, $srcSquareY,
$targetSquareSide, $targetSquareSide, $srcSquareSide, $srcSquareSide);
//encode and save result (default quality 75%)
imagejpeg($trgImg, $targetPath);
//clean up
imagedestroy($srcImg);
imagedestroy($trgImg);
}
// $target path (полный путь до файла)
$t = new \Imagick($target);
// нужный размер
$t->ThumbnailImage(90, 90, true);
// Формат
$t->setFormat("jpg");
$t->writeImage("Куда сохранить /var/www/domen.tdl/public...");