示例#1
0
/**
 * Add a report
 *
 * @param array Array of reported content
 * @param string Type of content being reported
 * @return int Report ID
 */
function add_report($report, $type = 'post')
{
    global $cache, $db, $mybb;
    $insert_array = array('id' => (int) $report['id'], 'id2' => (int) $report['id2'], 'id3' => (int) $report['id3'], 'uid' => (int) $report['uid'], 'reportstatus' => 0, 'reason' => $db->escape_string($report['reason']), 'type' => $db->escape_string($type), 'reports' => 1, 'dateline' => TIME_NOW, 'lastreport' => TIME_NOW, 'reporters' => $db->escape_string(my_serialize(array($report['uid']))));
    if ($mybb->settings['reportmethod'] == "email" || $mybb->settings['reportmethod'] == "pms") {
        return send_report($report);
    }
    $rid = $db->insert_query("reportedcontent", $insert_array);
    $cache->update_reportedcontent();
    return $rid;
}
function mp_deals_importer_do()
{
    if (get_option('mp-deal-importer-enable') != 'YES') {
        return false;
    }
    if (time() - (int) get_option('mp-deal-importer-last-run') < get_option('mp-deal-importer-time')) {
        return;
    }
    $url = get_option('mp-getdeal-feed-url');
    $xml = @simplexml_load_file($url, null, LIBXML_NOCDATA);
    if (!$xml) {
        return false;
    }
    global $user_ID;
    $post_type = 'dagaanbiedingen';
    $array_post_id = array();
    $total = 0;
    try {
        foreach ($xml->item as $post) {
            //if($total == 10)
            //break;
            $title_str = trim($post->title);
            $title_str = esc_attr(htmlspecialchars($title_str));
            $check = get_page_by_title($title_str, 'ARRAY_A', $post_type);
            if (empty($check)) {
                $content = '[tab:Over deze deal]';
                $content .= html_entity_decode($post->description, ENT_QUOTES, 'UTF-8');
                $content .= '[most_important_info]';
                $content .= html_entity_decode($post->accommodation_description, ENT_QUOTES, 'UTF-8');
                $content .= '[/most_important_info]';
                $content .= '[tab:Meer informatie]';
                $content .= html_entity_decode($post->inclusief, ENT_QUOTES, 'UTF-8');
                $content .= '[tab:END]';
                $new_post = array('post_title' => $post->title, 'post_content' => $content, 'post_status' => 'publish', 'post_date' => date('Y-m-d H:i:s'), 'post_author' => $user_ID, 'post_type' => $post_type, 'filter' => true);
                //remove_filter('content_save_pre', 'wp_filter_post_kses');
                //remove_filter('content_filtered_save_pre', 'wp_filter_post_kses');
                $id = wp_insert_post($new_post);
                //add_filter('content_save_pre', 'wp_filter_post_kses');
                //add_filter('content_filtered_save_pre', 'wp_filter_post_kses');
                if ($id) {
                    $total++;
                    update_post_meta($id, "status", '2');
                    update_post_meta($id, "is_show", '1');
                    update_post_meta($id, "owner_name", 'Boekvandaag.nl');
                    update_post_meta($id, "current_price", (double) $post->maximum_price);
                    update_post_meta($id, "our_price", (double) $post->minimum_price);
                    update_post_meta($id, "coupon_type", 1);
                    update_post_meta($id, "coupon_link", (string) $post->link);
                    update_post_meta($id, "coupon_start_date_time", strtotime((string) $post->offer_valid_from_date));
                    update_post_meta($id, "coupon_end_date_time", strtotime((string) $post->offer_valid_to_date));
                    update_post_meta($id, "coupon_end_date_timef", strtotime((string) $post->offer_valid_to_date));
                    update_post_meta($id, "file_name", (string) $post->img_medium);
                    update_post_meta($id, "is_expired", '0');
                    update_post_meta($id, "_yoast_wpseo_title", strip_tags($post->title));
                    update_post_meta($id, "_yoast_wpseo_metadesc", strip_tags(html_entity_decode($post->description, ENT_QUOTES, 'UTF-8')));
                    wp_set_object_terms($id, (array) $post->category, 'deal-categorie', true);
                    /*
                    if(function_exists('mp_getdeal_post_on_fb'))
                    {
                    	$p = query_posts("p=$id&post_type=$post_type");
                    	mp_getdeal_post_on_fb($p,$post->img_medium);
                    }
                    */
                }
                $array_post_id[] = $id;
            }
        }
    } catch (Exception $ex) {
        send_report(time() . var_dump($ex));
    }
    //send_report('Success '.time()."<br/>".var_dump($array_post_id));
    mp_deals_importer_do_dealdonkey();
    mp_deals_importer_do_nudeal();
    update_option('mp-deal-importer-last-run', time());
}
示例#3
0
     break;
     /* Contact Owner */
 /* Contact Owner */
 case "contact":
     contact($link_id, $option);
     break;
 case "send_contact":
     send_contact($link_id, $option);
     break;
     /* Report Listing */
 /* Report Listing */
 case "report":
     report($link_id, $option);
     break;
 case "send_report":
     send_report($link_id, $option);
     break;
     /* Claim Listing */
 /* Claim Listing */
 case "claim":
     claim($link_id, $option);
     break;
 case "send_claim":
     send_claim($link_id, $option);
     break;
     /* Add Listing */
 /* Add Listing */
 case "addlisting":
     editlisting(0, $option);
     break;
 case "editlisting":
示例#4
0
/**
 * import deals in a type
 * @param string $url url get data
 * @param int $maximumImportDeal
 * @param string $dealType type name
 * @return none
 */
function mp_deals_importer_type_of_deal($url = '', $maximumImportDeal = 0, $dealType = 'Eten')
{
    $maxDeal = intval($maximumImportDeal) ? intval($maximumImportDeal) : 1;
    // get data
    $xml = @simplexml_load_file($url, null, LIBXML_NOCDATA);
    if (!$xml) {
        return false;
    }
    global $user_ID;
    $post_type = 'deal';
    $array_post_id = array();
    $total = 0;
    try {
        if (!isset($xml->item) || empty($xml->item)) {
            return false;
        }
        foreach ($xml->item as $deal) {
            if ($total == $maxDeal) {
                break;
            }
            $trim_title = trim($deal->title);
            $title_str = esc_attr(htmlspecialchars($trim_title));
            $check = get_page_by_title($title_str, 'ARRAY_A', $post_type);
            if (empty($check)) {
                $post_desc = isset($deal->description) ? $deal->description : '';
                $post_commodation_desc = isset($deal->accommodation_description) ? $deal->accommodation_description : '';
                $content = html_entity_decode($post_desc, ENT_QUOTES, 'UTF-8');
                $content .= empty($post_commodation_desc) ? '' : '<br/>' . html_entity_decode($post_commodation_desc, ENT_QUOTES, 'UTF-8');
                $content .= empty($deal->inclusief) ? '' : '<br/>' . html_entity_decode($deal->inclusief, ENT_QUOTES, 'UTF-8');
                $new_post = array('post_title' => (string) $deal->title, 'post_content' => $content, 'post_status' => 'publish', 'post_date' => date('Y-m-d H:i:s'), 'post_author' => $user_ID, 'post_type' => $post_type, 'filter' => true);
                //remove_filter('content_save_pre', 'wp_filter_post_kses');
                //remove_filter('content_filtered_save_pre', 'wp_filter_post_kses');
                $post_id = wp_insert_post($new_post);
                //add_filter('content_save_pre', 'wp_filter_post_kses');
                //add_filter('content_filtered_save_pre', 'wp_filter_post_kses');
                if ($post_id) {
                    $total++;
                    // update post meta
                    update_deal_meta_data($post_id, $deal, $dealType);
                    /*
                                        if (function_exists('mp_getdeal_post_on_fb')) {
                       $p = query_posts("p=$post_id&post_type=$post_type");
                       mp_getdeal_post_on_fb($p, $deal->img_medium);
                                        }
                    */
                }
                $array_post_id[] = $post_id;
            }
        }
    } catch (Exception $ex) {
        send_report(time() . var_dump($ex));
    }
    // send_report('Success '.time()."<br/>".var_dump($array_post_id));
}