示例#1
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>";
    }
}
示例#2
0
 array_push($arrAuthors, $author);
 //image
 $filename = "/home/www/cb3/wp-content/plugins/wp-shopping-cart/product_images/" . $image;
 //resize the image
 $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";
示例#3
0
     $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
     $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']);
示例#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);
        }
    }
}