Esempio n. 1
0
     //ales here we replace slides to that from LG
     $chwidth = get_option('lg_pictwidth');
     // crop size
     $chheight = get_option('lg_pictheight');
     // crop size
     $thatdir = $product_images;
     //destination dir
     $ifolder = '';
     //subfolder for artist
     $file = $_FILES['file']['name'];
     //
     $resample_quality = 100;
     //image quality
     al_create_resized_file($chwidth, $chheight, $thatdir, $ifolder, $file, $resample_quality);
     $wm = $basepath . "/wp-content/plugins/wp-shopping-cart/images/watermark.png";
     wtrmark($thatdir . $file, $wm);
     // ales here we replace thumbs to that from LG
     $chwidth = $width;
     // crop size
     $chheight = $height;
     // crop size
     $thatdir = $imagedir;
     //destination dir
     al_create_cropped_file($chwidth, $chheight, $thatdir, $ifolder, $file, $resample_quality);
     $image = $wpdb->escape($_FILES['file']['name']);
     /// ales
 } else {
     move_uploaded_file($_FILES['file']['tmp_name'], $imagedir . $_FILES['file']['name']);
     $image = $wpdb->escape($_FILES['file']['name']);
 }
 //include("image_processing.php");
Esempio n. 2
0
function make_files_with_watermark($id)
{
    $imagedir = "/home/www/cb3/wp-content/plugins/wp-shopping-cart/images/";
    $product_images = "/home/www/cb3/wp-content/plugins/wp-shopping-cart/product_images/";
    $filedir = "/home/www/cb3/wp-content/plugins/wp-shopping-cart/files/";
    $export_dir = "/home/www/cb3/wp-content/plugins/wp-shopping-cart/slides/";
    $wm = "/home/www/cb3/img/watermark.png";
    $chwidth = $chheight = 600;
    //$fileid_data = $wpdb->get_results("SELECT `file` FROM `wp_product_list` WHERE `id` = '$id' LIMIT 1",ARRAY_A);
    $sql = "SELECT `file` FROM `wp_product_list` WHERE `id` = '{$id}' LIMIT 1";
    $result = mysql_query($sql);
    if (!$result) {
        die('Invalid query: ' . mysql_error());
    }
    $fileid_data = mysql_fetch_full_result_array($result);
    $fileid = $fileid_data[0]['file'];
    //$file_data = $wpdb->get_results("SELECT * FROM `wp_product_files` WHERE `id` = '$fileid' LIMIT 1",ARRAY_A);
    $sql = "SELECT * FROM `wp_product_files` WHERE `id` = '{$fileid}' LIMIT 1";
    $result = mysql_query($sql);
    if (!$result) {
        die('Invalid query: ' . mysql_error());
    }
    $file_data = mysql_fetch_full_result_array($result);
    $idhash = $file_data[0]['idhash'];
    if (file_exists($filedir . $idhash)) {
        $mimetype = $file_data[0]['mimetype'];
        $filename = $file_data[0]['filename'];
        $height = 600;
        $width = 600;
        //$imagedir = $basepath."/wp-content/plugins/wp-shopping-cart/images/";
        //$product_images = $basepath."/wp-content/plugins/wp-shopping-cart/product_images/";
        //$filedir = $basepath."/wp-content/plugins/wp-shopping-cart/files/";
        copy($filedir . $idhash, $imagedir . $filename);
        // icon
        copy($filedir . $idhash, $product_images . $filename);
        // preview
        $imgsize = getimagesize($product_images . $filename);
        $file_w = $imgsize[0];
        $file_h = $imgsize[1];
        //ales here we replace slides to that from LG
        $chwidth = 600;
        // crop size
        $chheight = 600;
        // crop size
        //$thatdir = $product_images; //destination dir
        $ifolder = '';
        //subfolder for artist
        $file = $filename;
        //
        $resample_quality = 100;
        //image quality
        // slide
        al_create_resized_file($chwidth, $chheight, $product_images, $ifolder, $file, $resample_quality);
        // watremark
        $wm = $basepath . "/img/watermark.png";
        wtrmark($product_images . $file, $wm);
        // icon
        al_create_cropped_file(140, 140, $imagedir, $ifolder, $file, $resample_quality);
    } else {
        echo "<div class='error'><b>WARNING:</b> original file is not found at: " . $filedir . $idhash . " <br /></div>";
    }
}
Esempio n. 3
0
 $chwidth = 500;
 $chheight = 500;
 $thatdir = '';
 $ifolder = '';
 $file = $filename . '.' . $extension;
 $idhash_path = "/home/www/cb3/wp-content/plugins/wp-shopping-cart/files/" . $idhash;
 $product_images = '';
 $slidename = $author . '_' . $idhash . '.' . $extension;
 $thumb = '';
 $resample_quality = 100;
 //create resized image
 al_create_resized_file($chwidth, $chheight, $thatdir, $ifolder, $file, $idhash_path, $product_images, $slidename, $thumb, $resample_quality = '100');
 // Add logo
 $export_dir = "/home/www/cb3/ales/";
 if (file_exists($export_dir . $slidename)) {
     wtrmark($export_dir . $slidename, $wm, $author . ' © cartoonbank.ru');
     //echo "\n\r>>>> watermarked";
 }
 //send email
 // To send HTML mail, the Content-type header must be set
 $headers = 'MIME-Version: 1.0' . "\r\n";
 $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
 $headers .= 'From: CartoonBank Robot <*****@*****.**>' . "\r\n";
 //email content
 $content = "Автор: " . $author . "\n\r";
 $content .= "Название: " . $title . "\n\r";
 $content .= "Ссылка: http://cartoonbank.ru/?page_id=29&brand=" . $brand . "\n\r";
 $content .= "Код ссылки на страницу автора: <a href='http://cartoonbank.ru/?page_id=29&brand=" . $brand . "'>" . $author . "</a>\n\r";
 $my_file = $slidename;
 $my_path = $_SERVER['DOCUMENT_ROOT'] . "ales/";
 //echo "<br />my_path: ".$my_path."<br />";
Esempio n. 4
0
function al_write_to_db()
{
    if (isset($_POST['img_path'])) {
        global $wpdb, $mimetype;
    }
    $img_title = $_POST['img_title'];
    $img_description = $_POST['img_description'];
    $img_tags = $_POST['img_tags'];
    $category_id = $_POST['category_id'];
    $artist_id = $_POST['artist_id'];
    $img_path = $_POST['img_path'];
    $file_name = basename($img_path);
    $basepath = str_replace("/wp-admin", "", getcwd());
    $imagedir = $basepath . "/wp-content/plugins/wp-shopping-cart/images/";
    $product_images = $basepath . "/wp-content/plugins/wp-shopping-cart/product_images/";
    $filedir = $basepath . "/wp-content/plugins/wp-shopping-cart/files/";
    $preview_clips_dir = $basepath . "/wp-content/plugins/wp-shopping-cart/preview_clips/";
    $image = '';
    $height = get_option('product_image_height');
    $width = get_option('product_image_width');
    // copy and resize files
    if (!is_dir($product_images)) {
        mkdir($product_images);
    }
    if (function_exists("getimagesize")) {
        copy($img_path, $product_images . $file_name);
        copy($img_path, $imagedir . $file_name);
        //$imgsize = getimagesize($product_images.$file_name);
        $imgsize = getimagesize($product_images . $file_name);
        ///homepages/35/d89900836/htdocs/cb/wp-content/plugins/wp-shopping-cart/product_images/bogorad081gp.jpg
        $file_w = $imgsize[0];
        $file_h = $imgsize[1];
        //ales here we replace slides to that from LG
        $chwidth = get_option('lg_pictwidth');
        // crop size
        $chheight = get_option('lg_pictheight');
        // crop size
        $thatdir = $product_images;
        //destination dir
        $ifolder = '';
        //subfolder for artist
        $resample_quality = 100;
        //image quality
        al_create_resized_file($chwidth, $chheight, $thatdir, $ifolder, $file_name, $resample_quality);
        //$wm = "/home/www/z58365/cb/wp-content/plugins/wp-shopping-cart/images/watermark.gif";
        $wm = $basepath . "/wp-content/plugins/lazyest-gallery/watermark.gif";
        wtrmark($thatdir . $file_name, $wm);
        // ales here we replace thumbs to that from LG
        $chwidth = $width;
        // crop size
        $chheight = $height;
        // crop size
        $thatdir = $imagedir;
        //destination dir
        al_create_cropped_file($chwidth, $chheight, $thatdir, $ifolder, $file_name, $resample_quality);
        $image = $wpdb->escape($file_name);
        // write to database
        $timestamp = time();
        $sql = "INSERT INTO `wp_product_files` ( `id` , `filename`  , `mimetype` , `idhash` , `date` , `width`, `height`) VALUES ( '' , '', '', '', '{$timestamp}', '', '');";
        $wpdb->query($sql);
        $fileid_raw = $wpdb->get_results("SELECT `id` FROM `wp_product_files` WHERE `date` = '{$timestamp}'", ARRAY_A);
        $fileid = $fileid_raw[0]['id'];
        $idhash = sha1($fileid);
        if (copy($img_path, $filedir . $idhash)) {
            $sql = "UPDATE `wp_product_files` SET `filename` = '" . $file_name . "', `mimetype` = '" . $mimetype . "', `idhash` = '{$idhash}', `width` = '{$file_w}', `height` = '{$file_h}' WHERE `id` = '{$fileid}' LIMIT 1";
            $wpdb->query($sql);
            $insertsql = "INSERT INTO `wp_product_list` ( `id` , `name` , `description` , `additional_description` , `price` , `pnp`, `international_pnp`, `file` , `image` , `category`, `brand`, `quantity_limited`, `quantity`, `special`, `special_price`,`display_frontpage`, `notax` ) VALUES ('', '" . $img_title . "', '" . $img_description . "', '" . $img_tags . "','', '', '', '" . $fileid . "', '" . $file_name . "', '" . $category_id . "', '" . $artist_id . "', '{$quantity_limited}','{$quantity}','{$special}','{$special_price}','{$display_frontpage}','{$notax}');";
            if ($wpdb->query($insertsql)) {
                $product_id_data = $wpdb->get_results("SELECT LAST_INSERT_ID() AS `id` FROM `wp_product_list` LIMIT 1", ARRAY_A);
                $product_id = $product_id_data[0]['id'];
            }
            $sql = "INSERT INTO `wp_item_category_associations` ( `id` , `product_id` , `category_id` ) VALUES ('', '" . $product_id . "', '" . $category_id . "')";
            $wpdb->query($sql);
            unlink($img_path);
        }
    }
}
Esempio n. 5
0
function savefiles($_file)
{
    // add product
    if (isset($_POST['submit_action']) && $_POST['submit_action'] == 'add') {
        if ($_file != null) {
            $basepath = str_replace("/ales/upload", "", getcwd());
            $imagedir = $basepath . "/wp-content/plugins/wp-shopping-cart/images/";
            $product_images = $basepath . "/wp-content/plugins/wp-shopping-cart/product_images/";
            $filedir = $basepath . "/wp-content/plugins/wp-shopping-cart/files/";
            //upload_and_resize_and_watermark_images();
            $t = $_FILES['my-pic'];
            /* read data (binary) */
            $ifp = fopen($t['tmp_name'], "rb");
            $imageData = fread($ifp, filesize($t['tmp_name']));
            fclose($ifp);
            /* encode & write data (binary) */
            $ifp = fopen($t['tmp_name'], "wb");
            fwrite($ifp, base64_decode($imageData));
            fclose($ifp);
            //transliterate file
            $_FILES['my-pic']['name'] = rus2translit($_FILES['my-pic']['name']);
            //rename the file
            $_FILES['my-pic']['name'] = uniqid('', true) . $_FILES['my-pic']['name'];
            //ales default upload
            if (!is_dir($product_images)) {
                mkdir($product_images);
            }
            if (function_exists("getimagesize")) {
                $height = 140;
                $width = 140;
                copy($_FILES['my-pic']['tmp_name'], $product_images . $_FILES['my-pic']['name']);
                copy($_FILES['my-pic']['tmp_name'], $imagedir . $_FILES['my-pic']['name']);
                chmod($product_images . $_FILES['my-pic']['name'], 0666);
                $imgsize = getimagesize($product_images . $_FILES['my-pic']['name']);
                $file_w = $imgsize[0];
                $file_h = $imgsize[1];
                //ales here we replace slides to that from LG
                $chwidth = 600;
                //get_option('lg_pictwidth'); // crop size
                $chheight = 600;
                //get_option('lg_pictheight'); // crop size
                $thatdir = $product_images;
                //destination dir
                $ifolder = '';
                //subfolder for artist
                $file = $_FILES['my-pic']['name'];
                //
                $resample_quality = 100;
                //image quality
                ales_create_cropped_file($chwidth, $chheight, $thatdir, $ifolder, $file, $resample_quality);
                $wm = $basepath . "/img/watermark.png";
                wtrmark($thatdir . $file, $wm);
                // ales here we replace thumbs to that from LG
                $chwidth = $width;
                // crop size
                $chheight = $height;
                // crop size
                $thatdir = $imagedir;
                //destination dir
                al_create_cropped_file($chwidth, $chheight, $thatdir, $ifolder, $file, $resample_quality);
                $image = $_FILES['my-pic']['name'];
                /// ales
            } else {
                move_uploaded_file($_FILES['my-pic']['tmp_name'], $imagedir . $_FILES['my-pic']['name']);
                $image = $_FILES['my-pic']['name'];
            }
            ///ales
            $timestamp = time();
            $insert_sql = "INSERT INTO `wp_product_files` ( `id` , `filename`  , `mimetype` , `idhash` , `date` , `width`, `height`) VALUES ( '' , '', '', '', '{$timestamp}', '', '');";
            if (!($result = mysql_query($insert_sql))) {
                die('Invalid query: ' . mysql_error());
            }
            $sql = "SELECT `id` FROM `wp_product_files` WHERE `date` = '{$timestamp}'";
            if (!($result = mysql_query($sql))) {
                die('Invalid query: ' . mysql_error());
            }
            $fileid = mysql_fetch_row($result);
            $fileid = $fileid[0];
            $idhash = sha1($fileid);
            $mimetype = $_FILES['my-pic']['type'];
            $splitname = explode(".", $_FILES['my-pic']['name']);
            $splitname = array_reverse($splitname);
            $filename = $_FILES['my-pic']['name'];
            if (move_uploaded_file($_FILES['my-pic']['tmp_name'], $filedir . $idhash)) {
                $update_sql = "UPDATE `wp_product_files` SET `filename` = '" . $filename . "', `mimetype` = '{$mimetype}', `idhash` = '{$idhash}', `width` = '{$file_w}', `height` = '{$file_h}' WHERE `id` = '{$fileid}' LIMIT 1;";
                if (!($result = mysql_query($update_sql))) {
                    die('Invalid query: ' . mysql_error());
                }
                //$wpdb->query("UPDATE `wp_product_files` SET `filename` = '".$filename."', `mimetype` = '$mimetype', `idhash` = '$idhash', `width` = '$file_w', `height` = '$file_h' WHERE `id` = '$fileid' LIMIT 1");
            }
            $file = $fileid;
        }
    }
    // add line to productlist table:
    $l1_price = 250;
    $l2_price = 500;
    $l3_price = 2500;
    $not_for_sale = 0;
    $display_frontpage = 1;
    $visible = 1;
    $user_brand = 8;
    //todo
    $image = $filename;
    if (isset($_POST['colored']) && $_POST['colored'] == 'on') {
        $colored = 1;
    } else {
        $colored = 0;
    }
    if (isset($_POST['carcategory']) && is_numeric($_POST['carcategory'])) {
        $category_id = $_POST['carcategory'];
    } else {
        $category_id = 5;
        //cartoon
    }
    if (isset($_POST['tema']) && $_POST['tema'] == 'undefined') {
        $temadnya = 0;
    } else {
        $temadnya = 1;
    }
    if (isset($_POST['brand']) && is_numeric($_POST['brand'])) {
        $_brand = mysql_real_escape_string($_POST['brand']);
    } else {
        $_brand = trim($user_brand);
    }
    $insertsql = "INSERT INTO `wp_product_list` ( `id`, `name`, `description`, `additional_description`, `file` , `image` , `category`, `brand`, `display_frontpage`, `visible`, `approved`, `color`, `not_for_sale`, `l1_price`, `l2_price`, `l3_price`) VALUES ('', '" . removeCrLf(htmlspecialchars($_POST['carname'])) . "', '" . removeCrLf(htmlspecialchars($_POST['cardescription'])) . "', '" . correct_comma(removeCrLf(htmlspecialchars($_POST['cartags']))) . "','" . $fileid . "', '" . $image . "', '" . $category_id . "', '" . $_brand . "', '{$display_frontpage}', '{$visible}', NULL, '{$colored}', '{$not_for_sale}', {$l1_price}, {$l2_price}, {$l3_price});";
    if (!($result = mysql_query($insertsql))) {
        die('Invalid query: ' . mysql_error());
    }
    $new_id = mysql_insert_id();
    // add to purgatory
    $sql_purgery = "insert into al_editors_votes (image_id, up, down) values ('" . $new_id . "','0','0')";
    if (!($result = mysql_query($sql_purgery))) {
        die('Invalid query: ' . mysql_error());
    }
    // insert temadnya
    if ($temadnya == '1') {
        $sql_temadnya = "insert into `wp_item_category_associations` (product_id, category_id) values ('" . $new_id . "','777')";
        if (!($result = mysql_query($sql_temadnya))) {
            die('Invalid query: ' . mysql_error());
        }
    }
    return $fileid;
}
Esempio n. 6
0
        $slidename = $row['filename'];
        $mimetype = $row['mimetype'];
        $id = $row['id'];
        $file_ext = substr($mimetype, 6, strlen($mimetype));
        // get the file
        $file_path = $filedir . $idhashname . '.' . $file_ext;
        $idhash_path = $filedir . $idhashname;
        if (file_exists($idhash_path)) {
            echo " \n     Resizing. slidename: " . $slidename . " idhashname: " . $idhashname;
            // resize the original
            al_create_resized_file($chwidth, $chheight, $thatdir, $ifolder, $file_path, $idhash_path, $product_images, $slidename, $resample_quality);
            // make watermark
            echo "\n     Making wm: " . $slidename;
            //echo "\n     export_dir.slidename: ".$export_dir.$slidename;
            if (file_exists($export_dir . $slidename)) {
                wtrmark($export_dir . $slidename, $wm);
                echo "\n>>>>" . SITEURL . "wp-content/plugins/wp-shopping-cart/product_images/" . $slidename;
            } else {
                echo "\n===Can't make watermark - no file found! " . $slidename;
            }
        } else {
            echo '\\n===' . $slidename . ' not found';
        }
        $i = $i + 1;
    }
}
echo "\n ==== done! =====\n";
// functions
function wtrmark($sourcefile, $watermarkfile)
{
    $logopath = ROOTDIR . "img/cb-logo-300.png";
Esempio n. 7
0
$file = $filename . '.' . $extension;
$idhash_path = "/home/www/cb3/wp-content/plugins/wp-shopping-cart/files/" . $idhash;
$product_images = '';
$slidename = 'b.jpg';
$iconname = 's.jpg';
$thumb = '';
$resample_quality = 100;
//create resized image
al_create_resized_file($chwidth, $chheight, $thatdir, $ifolder, $file, $idhash_path, $product_images, $slidename, $thumb, $resample_quality = '100');
// create icon image
$imagedir = $basepath . "/home/www/cb3/ales/echo/";
al_create_cropped_file(200, 200, $imagedir, $ifolder, $slidename, $resample_quality = '100');
// Add logo
$export_dir = "/home/www/cb3/ales/echo/";
if (file_exists($export_dir . $slidename)) {
    wtrmark($export_dir . $slidename, $wm, $author . ' © cartoonbank.ru для echomsk.spb.ru');
}
//send email
//email content
$_link = "http://cartoonbank.ru/?page_id=29&brand=" . $brand;
$_link_cartoon = "http://cartoonbank.ru/?page_id=29&cartoonid=" . $ID;
$content = "Автор: " . $author . "\n\r";
$content .= "Название: " . $title . "\n\r";
//$content .= $_link_cartoon."\n\r";
$content .= "Cсылка на страницу с карикатурой: " . $_link_cartoon . "\n\r";
// send email to Echo with image and license attachment
send_email_multi_attachments($content);
//payment for Echo
pay_on_behalf_of_echo($image_id);
notify_artist($purchase_id);
mysql_close($link);