break;
    case "subscriber":
        $user_role_permission = "read";
        break;
}
if (!current_user_can($user_role_permission)) {
    return;
} else {
    if (isset($_REQUEST["param"])) {
        if ($_REQUEST["param"] == "add_new_dynamic_row_for_image") {
            $img_path = esc_attr($_REQUEST["img_path"]);
            $img_name = esc_attr($_REQUEST["img_name"]);
            $img_width = intval($_REQUEST["image_width"]);
            $img_height = intval($_REQUEST["image_height"]);
            $picid = intval($_REQUEST["picid"]);
            process_image_upload($img_path, $img_width, $img_height);
            $column1 = "<input type=\"checkbox\" id=\"ux_grp_select_items_" . $picid . "\" name=\"ux_grp_select_items_" . $picid . "\" value=\"" . $picid . "\" />";
            array_push($dynamicArray, $column1);
            $column2 = "<a  href=\"javascript:void(0);\" title=\"" . $img_name . "\" >\n\t\t\t\t\t<img type=\"image\" imgPath=\"" . $img_path . "\"  src=\"" . GALLERY_BK_THUMB_SMALL_URL . $img_path . "\" id=\"ux_gb_img\" name=\"ux_gb_img\" class=\"img dynamic_css\" imageid=\"" . $picid . "\" width=\"" . $img_width . "\"/></a><br/>\n\t\t\t\t\t<label><strong>" . $img_name . "</strong></label><br/><label>" . date("F j, Y") . "</label><br/>\n\t\t\t\t\t<input type=\"radio\" style=\"cursor: pointer;\" onclick=\"select_one_radio(this);\" id=\"ux_rdl_cover\" name=\"ux_album_cover\" /><label>" . __(" Set as Album Cover", gallery_bank) . "</label>";
            array_push($dynamicArray, $column2);
            $column3 = "<input placeholder=\"" . __("Enter your Title", gallery_bank) . "\" class=\"layout-span12\" type=\"text\" name=\"ux_img_title_" . $picid . "\" id=\"ux_img_title_" . $picid . "\" />\n\t\t\t\t\t<textarea placeholder=\"" . __("Enter your Description ", gallery_bank) . "\" style=\"margin-top:20px\" rows=\"5\" class=\"layout-span12\" name=\"ux_txt_desc_" . $picid . "\"  id=\"ux_txt_desc_" . $picid . "\"></textarea>";
            array_push($dynamicArray, $column3);
            $column4 = "<input placeholder=\"" . __("Enter your Tags", gallery_bank) . "\" class=\"layout-span12\" readonly=\"readonly\" type=\"text\" onkeypress=\"return preventDot(event);\" name=\"ux_txt_tags_" . $picid . "\" id=\"ux_txt_tags_" . $picid . "\" />";
            array_push($dynamicArray, $column4);
            $column5 = "<input value=\"http://\" type=\"text\" id=\"ux_txt_url_" . $picid . "\" name=\"ux_txt_url_" . $picid . "\" class=\"layout-span12\" />";
            array_push($dynamicArray, $column5);
            $column6 = "<a class=\"btn hovertip\" id=\"ux_btn_delete\" style=\"cursor: pointer;\" data-original-title=\"" . __("Delete Image", gallery_bank) . "\" onclick=\"deleteImage(this);\" controlId =\"" . $picid . "\" ><i class=\"icon-trash\"></i></a>";
            array_push($dynamicArray, $column6);
            echo json_encode($dynamicArray);
            die;
        } else {
 if (isset($_REQUEST["param"])) {
     if ($_REQUEST["param"] == "update_global_settings") {
         $settings_array = json_decode(stripcslashes(html_entity_decode($_REQUEST["settings_array"])));
         $thumb_width = intval($_REQUEST["thumb_width"]);
         $thumb_height = intval($_REQUEST["thumb_height"]);
         $cover_width = intval($_REQUEST["cover_width"]);
         $cover_height = intval($_REQUEST["cover_height"]);
         foreach ($settings_array as $val => $innerKey) {
             $wpdb->query($wpdb->prepare("UPDATE " . gallery_bank_settings() . " SET setting_value = %s WHERE setting_key = %s", (string) current($innerKey), key($innerKey)));
         }
         ////////////CODE FOR CREATING THUMBNAILS///////////
         $album_pics = $wpdb->get_results("SELECT * FROM " . gallery_bank_pics() . " order by sorting_order asc");
         $album_covers = $wpdb->get_results("SELECT * FROM " . gallery_bank_pics() . " where album_cover = 1 order by sorting_order asc");
         for ($flag = 0; $flag < count($album_pics); $flag++) {
             if ($album_pics[$flag]->video != 1) {
                 process_image_upload($album_pics[$flag]->thumbnail_url, $thumb_width, $thumb_height);
             }
         }
         for ($flag1 = 0; $flag1 < count($album_covers); $flag1++) {
             if ($album_covers[$flag1]->thumbnail_url != "") {
                 process_album_upload($album_covers[$flag1]->thumbnail_url, $cover_width, $cover_height);
             }
         }
         die;
     } else {
         if ($_REQUEST["param"] == "restore_settings") {
             $sql = "TRUNCATE TABLE " . gallery_bank_settings();
             $wpdb->query($sql);
             include GALLERY_BK_PLUGIN_DIR . "/lib/include_settings.php";
             die;
         } else {
    }
    switch ($temp_type) {
        case IMAGETYPE_GIF:
            break;
        case IMAGETYPE_JPEG:
            break;
        case IMAGETYPE_PNG:
            break;
        default:
            return false;
    }
    $uploaded_file_path = UPLOADED_IMAGE_DESTINATION . $temp_file_name;
    $processed_file_path = PROCESSED_IMAGE_DESTINATION . preg_replace('/\\.[^\\.]+$/', '.jpg', $temp_file_name);
    move_uploaded_file($temp_file_path, $uploaded_file_path);
    $result = create_watermark($uploaded_file_path, $processed_file_path);
    if ($result === false) {
        return false;
    } else {
        return array($uploaded_file_path, $processed_file_path);
    }
}
/*
 * Here is how to call the function(s)
 */
$result = process_image_upload('File1');
if ($result === false) {
    echo '<br>An error occurred during file processing.';
} else {
    echo '<br>Original image saved as <a href="' . $result[0] . '" target="_blank">' . $result[0] . '</a>';
    echo '<br>Watermarked image saved as <a href="' . $result[1] . '" target="_blank">' . $result[1] . '</a>';
}
Example #4
0
             } else {
                 $file_path = $album_pics[$flag]->pic_path;
                 $file_name_exct = explode("/", $album_pics[$flag]->pic_path);
                 $file_name = $file_name_exct[count($file_name_exct) - 1];
                 $src = str_replace(site_url("/"), "", $file_path);
                 $destination = GALLERY_MAIN_UPLOAD_DIR . $file_name;
                 if (PHP_VERSION > 5) {
                     copy(ABSPATH . $src, $destination);
                 } else {
                     $content = file_get_contents(ABSPATH . $src);
                     $fp = fopen($destination, "w");
                     fwrite($fp, $content);
                     fclose($fp);
                 }
                 if (file_exists($destination)) {
                     process_image_upload($file_name, 160, 120);
                 }
                 $wpdb->query($wpdb->prepare("INSERT INTO " . gallery_bank_pics() . "(pic_id, album_id, title, description, thumbnail_url,\n                    sorting_order, date, url, video, tags, pic_name, album_cover) VALUES(%d, %d, %s, %s, %s, %d, %s,\n                    %s, %d, %s, %s, %d)", $album_pics[$flag]->pic_id, $album_pics[$flag]->album_id, $album_pics[$flag]->title, $album_pics[$flag]->description, $file_name, $album_pics[$flag]->sorting_order, $album_pics[$flag]->date, $album_pics[$flag]->url, $album_pics[$flag]->video, isset($album_pics[$flag]->tags) ? $album_pics[$flag]->tags : "", $file_name, $album_id == $album_pics[$flag]->album_id ? 0 : 1));
                 if ($album_id != $album_pics[$flag]->album_id) {
                     process_album_upload($file_name, 160, 120);
                 }
                 $album_id = $album_pics[$flag]->album_id;
             }
         }
     }
 }
 if (count($wpdb->get_var("SHOW TABLES LIKE '" . gallery_bank_settings() . "'")) == 0) {
     create_table_album_settings();
 } else {
     $sql = "DROP TABLE " . gallery_bank_settings();
     $wpdb->query($sql);
Example #5
0
    $temp_file_name = WATERMARK_SOURCE_NAME;
    list(, , $temp_type) = getimagesize($temp_file_path);
    if ($temp_type === NULL) {
        return false;
    }
    switch ($temp_type) {
        case IMAGETYPE_GIF:
            break;
        case IMAGETYPE_JPEG:
            break;
        case IMAGETYPE_PNG:
            break;
        default:
            return false;
    }
    $uploaded_file_path = UPLOADED_IMAGE_DESTINATION . $temp_file_name;
    $processed_file_path = PROCESSED_IMAGE_DESTINATION . $temp_file_name;
    move_uploaded_file($temp_file_path, $uploaded_file_path);
    $result = create_watermark($uploaded_file_path, $processed_file_path);
    if ($result === false) {
        return false;
    } else {
        return array($uploaded_file_path, $processed_file_path);
    }
}
$result = process_image_upload();
if ($result === false) {
    echo 'Error';
} else {
    echo WATERMARK_SOURCE_NAME;
}
Example #6
0
            break;
        default:
            return false;
    }
    $uploaded_image_path = UPLOADED_IMAGE_DESTINATION . $temp_image_name;
    move_uploaded_file($temp_image_path, $uploaded_image_path);
    $thumbnail_image_path = THUMBNAIL_IMAGE_DESTINATION . preg_replace('{\\.[^\\.]+$}', '.jpg', $temp_image_name);
    $main_image_path = MAIN_IMAGE_DESTINATION . preg_replace('{\\.[^\\.]+$}', '.jpg', $temp_image_name);
    $result = generate_image_thumbnail($uploaded_image_path, $thumbnail_image_path, 150, 150);
    if ($result) {
        $result = generate_image_thumbnail($uploaded_image_path, $main_image_path, 400, 400, true);
    }
    return $result ? array($uploaded_image_path, $thumbnail_image_path) : false;
}
if (isset($_POST['upload'])) {
    $result = process_image_upload('image');
    if ($result === false) {
        update_option('meme_message', '<div class="error" style="margin-left:0;"><p>An error occurred while processing upload</p></div>');
    } else {
        if ($result === 'empty') {
            update_option('meme_message', '<div class="error" style="margin-left:0;"><p>Please select a Image file</p></div>');
        } elseif ($result === 'size') {
            update_option('meme_message', '<div class="error" style="margin-left:0;"><p>Image width must be greater than 400px;</p></div>');
        } else {
            update_option('meme_message', '<div style="margin-left:0;" class="updated"><p>Image uploaded successfully</p></div>');
            $guploaderr = false;
            $count = intval(get_option('meme_image_count'));
            update_option('meme_image_count', $count + 1);
        }
    }
}