diff -r 0d9a58d2c515 -r 0d28b7c10758 web/wp-content/themes/selecta/ocmx/ocmx-functions.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/wp-content/themes/selecta/ocmx/ocmx-functions.php Fri Mar 12 13:29:04 2010 +0000 @@ -0,0 +1,192 @@ + + + + + + + +query("DELETE FROM $wpdb->options + WHERE `option_name` LIKE 'ocmx_main_%' + OR `option_name` LIKE 'ocmx_maincategory_%' + OR `option_name` LIKE 'ocmx_menu_page%' + OR `option_name` LIKE 'ocmx_subpage_%' + OR `option_name` = 'ocmx_gallery_page' + OR `option_name` = 'ocmx_archives_page'"); + endif; + while (list($key,$value) = each($_POST)){ + if (substr($key, 0, 4) == "ocmx") : + wp_cache_flush(); + $clear_options = $wpdb->query("DELETE FROM $wpdb->options WHERE `option_name` = '".$key."'"); + if(!get_option($key)): + add_option($key, $value); + else : + update_option($key, $value); + endif; + + endif; + } + update_option("posts_per_page", get_option("ocmx_home_page_posts")); + if(!$_POST["ocmx_gallery_update"]) : + while (list($key,$value) = each($_FILES)){ + $image_name = strtolower($_FILES[$key]["name"]); + if($image_name !== "") : + $final_upload = ABSPATH."wp-content/uploads/".$image_name; + if(move_uploaded_file($_FILES[$key]["tmp_name"], $final_upload) === true) : + $test = move_uploaded_file($_FILES[$key]["tmp_name"], $final_upload); + else : + $test = "0"; + endif; + if($test !== "0") : + if(!get_option($key)): + add_option($key, $image_name); + else : + update_option($key, $image_name); + endif; + endif; + endif; + } + endif; +endif; +function ocmx_save_resample($upload_image, $new_image, $mime_type, $resize_type, $resize_height, $resize_width, $resize_percent, $image_width, $image_height) + { + global $upload_image, $new_image, $mime_type, $resize_type, $resize_height, $resize_width, $resize_percent, $image_width, $image_height; + + if($resize_type == "w" && ($resize_width < $image_width)) : + if($resize_width !== "0") : + $new_width = $resize_width; + else : + $new_width = $resize_height; + endif; + $new_height = ($image_height*($resize_width/$image_width)); + elseif($resize_type == "h" && ($resize_height < $image_height)) : + if($resize_height !== "0") : + $new_height = $resize_height; + else : + $new_height = $resize_width; + endif; + $new_width = ($image_width*($resize_height/$image_height)); + elseif($resize_type == "p") : + /* Set Resize Percentage */ + $resize_percent = ($resize_percent); + $new_width = ($image_width*$resize_percent); + $new_height = ($image_height*$resize_percent); + else : + $new_width = ($image_width); + $new_height = ($image_height); + endif; + + // Creat Canvas + $canvas = imagecreatetruecolor($new_width, $new_height); + + // Resample + if(imagecopyresampled($canvas, $new_image, 0, 0, 0, 0, $new_width, $new_height, $image_width, $image_height) === true) : + // Save + if($mime_type == "gif") : + imagegif($canvas, $upload_image, 100); + elseif($mime_type == "jpg") : + imagejpeg($canvas, $upload_image, 100); + elseif($mime_type == "png") : + imagepng($canvas, $upload_image); + endif; + endif; + + } +function ocmx_commentmeta_update($cid)//, $comment_twitter, $comment_subscribe, $comment_author_email + { + global $wpdb; + $commentId = (int) $cid; + $comment_table = $wpdb->prefix . "ocmx_comment_meta"; + if($_POST['twitter'] == "undefined" && $_POST['twitter'] == "Twitter Name") : + $use_twitter = ""; + else : + $use_twitter = $_POST['twitter']; + endif; + + if($_POST['email_subscribe'] == "true") : + $subscribe_me = 1; + else : + $subscribe_me = 0; + endif; + + $meta_update = $wpdb->query + ($wpdb->prepare + ("INSERT INTO $comment_table + (commentId, twitter, email_subscribe) + VALUES + (%d, %s, %s);", + $cid, $use_twitter, $subscribe_me) + ); + ocmx_comment_email($cid); + } +function ocmx_comment_email($cid)//, $comment_twitter, $comment_subscribe, $comment_author_email + { + global $wpdb; + $commentId = (int) $cid; + $comment_table = $wpdb->prefix . "ocmx_comment_meta"; + + $comment = $wpdb->get_row("SELECT $wpdb->comments.*, $comment_table.* FROM $wpdb->comments INNER JOIN $comment_table ON $wpdb->comments.comment_ID = $comment_table.commentId WHERE $wpdb->comments.comment_ID='".$cid."'"); + $post_details = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID='".$comment->comment_post_ID."' LIMIT 1"); + + $fetch_subscribers = $wpdb->get_results("SELECT $wpdb->comments.*, $comment_table.* + FROM $wpdb->comments INNER JOIN $comment_table + ON $wpdb->comments.comment_ID = $comment_table.commentId + WHERE $wpdb->comments.comment_post_ID = '".$comment->comment_post_ID."' + AND $comment_table.email_subscribe = '1' + GROUP BY $wpdb->comments.comment_author_email"); + + foreach($fetch_subscribers as $subscriber) : + $to = $subscriber->comment_author_email; + $headers = "From: \"".get_bloginfo("name")."\" Comments"; + $headers .= "MIME-Version: 1.0\n"; + $headers .= "Content-type: text/html; charset=iso-8859-1 \r\n"; + $body = ""; + $body .= "

".$post->post_title."

"; + $body .= "

".$comment->comment_author." has commented on ". $post_details->post_title."

"; + $body .= "

Link: comment_author."\">".$comment->comment_author_url."

"; + $body .= "

Twitter Name: twitter."\">".$comment->twitter."

"; + $body .= "

Comment:

"; + $body .= "
"; + $body .= "

".$comment->comment_content."

"; + $body .= "
"; + $body .= "

Go go straight to the post comment_post_ID)."#comments\">".get_permalink($comment->comment_post_ID).".

"; + $body .= "

Unsubscribe from this comment feed ".get_permalink($comment->comment_post_ID).".

"; + wp_mail($to, $subject, $body, $headers); + endforeach; + } +function ocmx_unsubscribe($comment_id)//, $comment_twitter, $comment_subscribe, $comment_author_email + { + global $wpdb, $comment_id, $the_post; + $comment_id = $_GET["comment"]; + $comment_table = $wpdb->prefix . "ocmx_comment_meta"; + $the_comment = get_comment($comment_id); + + $subscriber_email = $the_comment->comment_author_email; + + $post_id = $the_comment->comment_post_ID; + $the_post = get_post($the_comment->comment_post_ID); + + $comment_args = array("post_id" => $post_id); + + $post_comments = get_comments($comment_args); + + foreach($post_comments as $this_comment) : + if($subscriber_email == $this_comment->comment_author_email) + $wpdb->update($comment_table , array( 'email_subscribe' => '0'), array( 'commentId' => $this_comment->comment_ID ), array( '%d' ), array( '%d' ) ); + endforeach; + } + +?> \ No newline at end of file