示例#1
0
function NullCheck($v)
{
    if (IS_NULL($v) || empty($v)) {
        return "NULL";
    } else {
        return $v;
    }
}
 function get_token()
 {
     $dataArray = array("team" => "A21", "name" => "Unknown", "password" => "tuesday");
     $handle = $this->botserver->php_post($dataArray, "/register");
     $agent = new SimpleXMLElement($handle);
     if ($agent->getName() == "error") {
         if (!IS_NULL($this->session->userdata('token'))) {
             return $this->session->userdata('token');
         }
     } else {
         $this->session->set_userdata('token', (string) $agent->token);
         return $agent->token;
     }
 }
示例#3
0
文件: VwGuia.php 项目: hipogea/zega
 public static function hayactivoentransporte($codigoaf, $id = null)
 {
     //$registro=self::model()->find("c_codactivo=:vcodactivo and c_estgui=:vestado AND ",array(":vcodactivo"=>$codigoaf,":vestado"=>ESTADO_GUIA_APROBADA));
     $criteria = new CDBCriteria();
     $criteria->addCondition("c_codactivo=:vcodactivo and c_estgui=:vestado ");
     if (!is_null($id)) {
         $criteria->addCondition(" n_hguia <> :id ");
         $criteria->params = array(":vcodactivo" => $codigoaf, ":vestado" => ESTADO_GUIA_APROBADA, ":id" => $id);
     } else {
         $criteria->params = array(":vcodactivo" => $codigoaf, ":vestado" => ESTADO_GUIA_APROBADA);
     }
     $registro = VwGuia::model()->find($criteria);
     if (!IS_NULL($registro)) {
         return $registro->c_numgui . "   -   " . $registro->c_itguia;
     } else {
         return null;
     }
 }
示例#4
0
function ValidTime($t)
{
    $temptime = split('[:]', $t);
    $hour = $temptime[0];
    $minute = $temptime[1];
    $second = @$temptime[2];
    /* MAY NOT EXIST */
    if (!IS_NULL($hour) && (!IS_NUMERIC($hour) || $hour < 0 || $hour > 60)) {
        return False;
    }
    if (!IS_NULL($minute) && (!IS_NUMERIC($minute) || $minute < 0 || $minute > 60)) {
        return False;
    }
    if (!IS_NULL($second) && (!IS_NUMERIC($second) || $second < 0 || $second > 60)) {
        return False;
    }
    return True;
}
 static function scramble($length = 8, $range = NULL)
 {
     $arrayString = IS_NULL($range) ? self::createString() : self::createString($range);
     shuffle($arrayString);
     $shuffledString = $arrayString;
     $count = (int) count($arrayString);
     $multiShuffle = (int) floor($length / $count);
     if ($multiShuffle < $length) {
         for ($i = 0; $i < $multiShuffle; $i++) {
             shuffle($arrayString);
             $shuffledString = array_merge($arrayString, $shuffledString);
         }
     }
     $string = '';
     for ($i = 0; $i < $length; $i++) {
         $string .= $shuffledString[$i];
     }
     return $string;
 }
function wp_rss_multi_importer_post($feedID = NULL, $catID = NULL)
{
    $postMsg = FALSE;
    require_once ABSPATH . "wp-admin" . '/includes/media.php';
    require_once ABSPATH . "wp-admin" . '/includes/file.php';
    require_once ABSPATH . "wp-admin" . '/includes/image.php';
    if (!function_exists("wprssmi_hourly_feed")) {
        function wprssmi_hourly_feed()
        {
            return 0;
        }
        // no caching of RSS feed
    }
    add_filter('wp_feed_cache_transient_lifetime', 'wprssmi_hourly_feed');
    $options = get_option('rss_import_options', 'option not found');
    $option_items = get_option('rss_import_items', 'option not found');
    $post_options = get_option('rss_post_options', 'option not found');
    $category_tags = get_option('rss_import_categories_images', 'option not found');
    global $fopenIsSet;
    $fopenIsSet = ini_get('allow_url_fopen');
    if ($option_items == false) {
        return "You need to set up the WP RSS Multi Importer Plugin before any results will show here.  Just go into the <a href='/wp-admin/options-general.php?page=wp_rss_multi_importer_admin'>settings panel</a> and put in some RSS feeds";
    }
    if (!empty($option_items)) {
        $cat_array = preg_grep("^feed_cat_^", array_keys($option_items));
        if (count($cat_array) == 0) {
            // for backward compatibility
            $noExistCat = 1;
        } else {
            $noExistCat = 0;
        }
    }
    if (!IS_NULL($feedID)) {
        $feedIDArray = explode(",", $feedID);
    }
    if (!empty($option_items)) {
        //GET PARAMETERS
        $size = count($option_items);
        $sortDir = 0;
        // 1 is ascending
        $maxperPage = $options['maxperPage'];
        global $setFeaturedImage;
        $setFeaturedImage = $post_options['setFeaturedImage'];
        $addSource = $post_options['addSource'];
        $sourceAnchorText = $post_options['sourceAnchorText'];
        $maxposts = $post_options['maxfeed'];
        $post_status = $post_options['post_status'];
        $addAuthor = $post_options['addAuthor'];
        $bloguserid = $post_options['bloguserid'];
        $post_format = $post_options['post_format'];
        $postTags = $post_options['postTags'];
        global $RSSdefaultImage;
        $RSSdefaultImage = $post_options['RSSdefaultImage'];
        // 0- process normally, 1=use default for category, 2=replace when no image available
        $serverTimezone = $post_options['timezone'];
        $autoDelete = $post_options['autoDelete'];
        $sourceWords = $post_options['sourceWords'];
        $readMore = $post_options['readmore'];
        $includeExcerpt = $post_options['includeExcerpt'];
        global $morestyle;
        $morestyle = ' ...read more';
        $sourceWords_Label = $post_options['sourceWords_Label'];
        if (!is_null($readMore) && $readMore != '') {
            $morestyle = $readMore;
        }
        switch ($sourceWords) {
            case 1:
                $sourceLable = 'Source';
                break;
            case 2:
                $sourceLable = 'Via';
                break;
            case 3:
                $sourceLable = 'Read more here';
                break;
            case 4:
                $sourceLable = 'From';
                break;
            case 5:
                $sourceLable = $sourceWords_Label;
                break;
            default:
                $sourceLable = 'Source';
        }
        if (isset($serverTimezone) && $serverTimezone != '') {
            //set time zone
            date_default_timezone_set($serverTimezone);
            $rightNow = date("Y-m-d H:i:s", time());
        } else {
            $rightNow = date("Y-m-d H:i:s", time());
        }
        if ($post_options['categoryid']['wpcatid'][1] !== NULL) {
            $wpcatids = array_filter($post_options['categoryid']['wpcatid'], 'filter_id_callback');
            //array of post blog categories that have been entered
        }
        if (!empty($wpcatids)) {
            $catArray = get_values_for_id_keys($post_options['categoryid']['plugcatid'], array_keys($wpcatids));
            //array of plugin categories that have an association with post blog categories
            $catArray = array_diff($catArray, array(''));
        } else {
            $catArray = array(0);
        }
        if (!IS_NULL($catID)) {
            $catArray = array($catID);
            //  change to category ID if using external CRON
        }
        $targetWindow = $post_options['targetWindow'];
        // 0=LB, 1=same, 2=new
        if (empty($options['sourcename'])) {
            $attribution = '';
        } else {
            $attribution = $options['sourcename'] . ': ';
        }
        global $ftp;
        $ftp = 1;
        //identify pass to excerpt_functions comes from feed to post
        global $anyimage;
        // to identify any image in description
        $anyimage = 1;
        global $maximgwidth;
        $maximgwidth = $post_options['maximgwidth'];
        $descNum = $post_options['descnum'];
        $stripAll = $post_options['stripAll'];
        $stripSome = $post_options['stripSome'];
        $maxperfetch = $post_options['maxperfetch'];
        $showsocial = $post_options['showsocial'];
        $overridedate = $post_options['overridedate'];
        $commentStatus = $post_options['commentstatus'];
        if ($commentStatus == '1') {
            $comment_status = 'closed';
        } else {
            $comment_status = 'open';
        }
        $adjustImageSize = 1;
        $noFollow = 0;
        $floatType = 1;
        if ($floatType == '1') {
            $float = "left";
        } else {
            $float = "none";
        }
        for ($i = 1; $i <= $size; $i = $i + 1) {
            //  condition here that id number is here
            $key = key($option_items);
            if (!strpos($key, '_') > 0) {
                continue;
            }
            //this makes sure only feeds are included here...everything else are options
            $rssName = $option_items[$key];
            $rssID = str_replace('feed_name_', '', $key);
            //get feed ID number
            next($option_items);
            $key = key($option_items);
            $rssURL = $option_items[$key];
            next($option_items);
            $key = key($option_items);
            $rssCatID = $option_items[$key];
            if (!in_array(0, $catArray) && in_array($option_items[$key], $catArray) || in_array(0, $catArray) || $noExistCat == 1 || !empty($feedIDArray)) {
                //makes sure only desired categories are included
                if (!empty($feedIDArray)) {
                    //only pick up specific feed arrary if indicated in querystring
                    if (!in_array($rssID, $feedIDArray)) {
                        if (count($cat_array) > 0) {
                            // for backward compatibility
                            next($option_items);
                            //skip feed category
                        }
                        continue;
                    }
                }
                $myfeeds[] = array("FeedName" => $rssName, "FeedURL" => $rssURL, "FeedCatID" => $rssCatID);
                //with Feed Category ID
            }
            $cat_array = preg_grep("^feed_cat_^", array_keys($option_items));
            // for backward compatibility
            if (count($cat_array) > 0) {
                next($option_items);
                //skip feed category
            }
        }
        if ($maxposts == "") {
            return "One more step...go into the the <a href='/wp-admin/options-general.php?page=wp_rss_multi_importer_admin&tab=setting_options'>Settings Panel and choose Options.</a>";
        }
        // check to confirm they set options
        if (empty($myfeeds)) {
            return "You've either entered a category ID that doesn't exist or have no feeds configured for this category.  Edit the shortcode on this page with a category ID that exists, or <a href=" . $cat_options_url . ">go here and and get an ID</a> that does exist in your admin panel.";
            exit;
        }
        foreach ($myfeeds as $feeditem) {
            $url = (string) $feeditem["FeedURL"];
            while (stristr($url, 'http') != $url) {
                $url = substr($url, 1);
            }
            $feed = fetch_feed($url);
            if (is_wp_error($feed)) {
                if ($size < 4) {
                    return "You have one feed and it's not valid.  This is likely a problem with the source of the RSS feed.  Contact our support forum for help.";
                    exit;
                } else {
                    //echo $feed->get_error_message();
                    continue;
                }
            }
            $maxfeed = $feed->get_item_quantity(0);
            if ($feedAuthor = $feed->get_author()) {
                $feedAuthor = $feed->get_author()->get_name();
            }
            //SORT DEPENDING ON SETTINGS
            if ($sortDir == 1) {
                for ($i = $maxfeed - 1; $i >= $maxfeed - $maxposts; $i--) {
                    $item = $feed->get_item($i);
                    if (empty($item)) {
                        continue;
                    }
                    if (include_post($feeditem["FeedCatID"], $item->get_content(), $item->get_title()) == 0) {
                        continue;
                    }
                    // FILTER
                    if ($enclosure = $item->get_enclosure()) {
                        if (!IS_NULL($item->get_enclosure()->get_thumbnail())) {
                            $mediaImage = $item->get_enclosure()->get_thumbnail();
                        } else {
                            if (!IS_NULL($item->get_enclosure()->get_link())) {
                                $mediaImage = $item->get_enclosure()->get_link();
                            }
                        }
                    }
                    if ($itemAuthor = $item->get_author()) {
                        $itemAuthor = $item->get_author()->get_name();
                    } else {
                        if (!IS_NULL($feedAuthor)) {
                            $itemAuthor = $feedAuthor;
                        }
                    }
                    $myarray[] = array("mystrdate" => strtotime($item->get_date()), "mytitle" => $item->get_title(), "mylink" => $item->get_permalink(), "myGroup" => $feeditem["FeedName"], "mydesc" => $item->get_content(), "myimage" => $mediaImage, "mycatid" => $feeditem["FeedCatID"], "myAuthor" => $itemAuthor, "feedURL" => $feeditem["FeedURL"]);
                    unset($mediaImage);
                    unset($itemAuthor);
                }
            } else {
                for ($i = 0; $i <= $maxposts - 1; $i++) {
                    $item = $feed->get_item($i);
                    if (empty($item)) {
                        continue;
                    }
                    if (include_post($feeditem["FeedCatID"], $item->get_content(), $item->get_title()) == 0) {
                        continue;
                    }
                    // FILTER
                    if ($enclosure = $item->get_enclosure()) {
                        if (!IS_NULL($item->get_enclosure()->get_thumbnail())) {
                            $mediaImage = $item->get_enclosure()->get_thumbnail();
                        } else {
                            if (!IS_NULL($item->get_enclosure()->get_link())) {
                                $mediaImage = $item->get_enclosure()->get_link();
                            }
                        }
                    }
                    if ($itemAuthor = $item->get_author()) {
                        $itemAuthor = $item->get_author()->get_name();
                    } else {
                        if (!IS_NULL($feedAuthor)) {
                            $itemAuthor = $feedAuthor;
                        }
                    }
                    $myarray[] = array("mystrdate" => strtotime($item->get_date()), "mytitle" => $item->get_title(), "mylink" => $item->get_permalink(), "myGroup" => $feeditem["FeedName"], "mydesc" => $item->get_content(), "myimage" => $mediaImage, "mycatid" => $feeditem["FeedCatID"], "myAuthor" => $itemAuthor, "feedURL" => $feeditem["FeedURL"]);
                    unset($mediaImage);
                    unset($itemAuthor);
                }
            }
        }
        //  CHECK $myarray BEFORE DOING ANYTHING ELSE //
        if ($dumpthis == 1) {
            var_dump($myarray);
        }
        if (!isset($myarray) || empty($myarray)) {
            return "There is a problem with the feeds you entered.  Go to our <a href='http://www.allenweiss.com/wp_plugin'>support page</a> and we'll help you diagnose the problem.";
            exit;
        }
        //$myarrary sorted by mystrdate
        foreach ($myarray as $key => $row) {
            $dates[$key] = $row["mystrdate"];
        }
        //SORT, DEPENDING ON SETTINGS
        if ($sortDir == 1) {
            array_multisort($dates, SORT_ASC, $myarray);
        } else {
            array_multisort($dates, SORT_DESC, $myarray);
        }
        if ($targetWindow == 0) {
            $openWindow = 'class="colorbox"';
        } elseif ($targetWindow == 1) {
            $openWindow = 'target=_self';
        } else {
            $openWindow = 'target=_blank ';
        }
        $total = 0;
        global $wpdb;
        // get all links that have been previously processed
        $wpdb->show_errors = true;
        foreach ($myarray as $items) {
            $total = $total + 1;
            if ($total > $maxperfetch) {
                break;
            }
            $thisLink = trim($items["mylink"]);
            //	echo $thisLink.'<br>';
            // VIDEO CHECK
            if ($targetWindow == 0) {
                $getVideoArray = rssmi_video($items["mylink"]);
                $openWindow = $getVideoArray[1];
                $items["mylink"] = $getVideoArray[0];
            }
            $thisLink = strip_qs_var('bing.com', $thisLink, 'tid');
            // clean time based links from Bing
            $thisLink = mysql_real_escape_string($thisLink);
            $wpdb->flush();
            $mypostids = $wpdb->get_results("select post_id from {$wpdb->postmeta} where meta_key = 'rssmi_source_link' and meta_value like '%" . $thisLink . "%'");
            $myposttitle = $wpdb->get_results("select post_title from {$wpdb->posts} where post_title like '%" . mysql_real_escape_string(trim($items["mytitle"])) . "%'");
            if (empty($mypostids) && $mypostids !== false && empty($myposttitle)) {
                $thisContent = '';
                $post = array();
                $post['post_status'] = $post_status;
                if ($overridedate == 1) {
                    $post['post_date'] = $rightNow;
                } else {
                    $post['post_date'] = date('Y-m-d H:i:s', $items['mystrdate']);
                }
                $post['post_title'] = trim($items["mytitle"]);
                $authorPrep = "By ";
                if (!empty($items["myAuthor"]) && $addAuthor == 1) {
                    $thisContent .= '<span style="font-style:italic; font-size:16px;">' . $authorPrep . ' <a ' . $openWindow . ' href=' . $items["mylink"] . ' ' . ($noFollow == 1 ? 'rel=nofollow' : '') . '">' . $items["myAuthor"] . '</a></span>  ';
                }
                $thisExcerpt = showexcerpt($items["mydesc"], $descNum, $openWindow, $stripAll, $items["mylink"], $adjustImageSize, $float, $noFollow, $items["myimage"], $items["mycatid"], $stripSome);
                $thisContent .= $thisExcerpt;
                if ($addSource == 1) {
                    switch ($sourceAnchorText) {
                        case 1:
                            $anchorText = $items["myGroup"];
                            break;
                        case 2:
                            $anchorText = $items["mytitle"];
                            break;
                        case 3:
                            $anchorText = $items["mylink"];
                            break;
                        default:
                            $anchorText = $items["myGroup"];
                    }
                    $thisContent .= ' <p>' . $sourceLable . ': <a href=' . $items["mylink"] . '  ' . $openWindow . '  title="' . $items["mytitle"] . '">' . $anchorText . '</a></p>';
                }
                if ($showsocial == 1) {
                    $thisContent .= '<span style="margin-left:10px;"><a href="http://www.facebook.com/sharer/sharer.php?u=' . $items["mylink"] . '"><img src="' . WP_RSS_MULTI_IMAGES . 'facebook.png"/></a>&nbsp;&nbsp;<a href="http://twitter.com/intent/tweet?text=' . rawurlencode($items["mytitle"]) . '%20' . $items["mylink"] . '"><img src="' . WP_RSS_MULTI_IMAGES . 'twitter.png"/></a></span>';
                }
                $post['post_content'] = $thisContent;
                if ($includeExcerpt == 1) {
                    $post['post_excerpt'] = $thisExcerpt;
                }
                $mycatid = $items["mycatid"];
                $blogcatid = array();
                if (!empty($post_options['categoryid'])) {
                    $catkey = array_search($mycatid, $post_options['categoryid']['plugcatid']);
                    $blogcatid = $post_options['categoryid']['wpcatid'][$catkey];
                } else {
                    $blogcatid = 0;
                }
                if ($post_options['categoryid']['plugcatid'][1] == '0') {
                    //this gets all the wp categories indicated when All is chosen in the first position
                    $allblogcatid = $post_options['categoryid']['wpcatid'][1];
                    if (is_array($blogcatid)) {
                        $blogcatid = array_merge($blogcatid, $allblogcatid);
                        $blogcatid = array_unique($blogcatid);
                    } else {
                        $blogcatid = $allblogcatid;
                    }
                }
                $post['post_category'] = $blogcatid;
                if (is_null($bloguserid) || empty($bloguserid)) {
                    $bloguserid = 1;
                }
                //check that userid isn't empty else give it admin status
                $post['post_author'] = $bloguserid;
                $post['comment_status'] = $comment_status;
                if (!empty($category_tags[$mycatid]['tags'])) {
                    $postTags = $category_tags[$mycatid]['tags'];
                }
                if ($postTags != '') {
                    $post['tags_input'] = $postTags;
                }
                $post_id = wp_insert_post($post);
                set_post_format($post_id, $post_format);
                if (add_post_meta($post_id, 'rssmi_source_link', $thisLink) != false) {
                    if ($setFeaturedImage == 1 || $setFeaturedImage == 2) {
                        global $featuredImage;
                        if (isset($featuredImage)) {
                            $featuredImageTitle = trim($items["mytitle"]);
                            setFeaturedImage($post_id, $featuredImage, $featuredImageTitle);
                            unset($featuredImage);
                        }
                    }
                } else {
                    wp_delete_post($post_id, true);
                    unset($post);
                    continue;
                }
                unset($post);
            }
            $postMsg = TRUE;
        }
    }
    if ($autoDelete == 1) {
        rssmi_delete_posts();
    }
    return $postMsg;
}
 /**
  * Front-end display of widget.
  *
  * @see WP_Widget::widget()
  *
  * @param array $args     Widget arguments.
  * @param array $instance Saved values from database.
  */
 public function widget($args, $instance)
 {
     add_action('wp_footer', 'rssmi_footer_scripts');
     /* Load the excerpt functions file. */
     global $maximgwidth;
     $maximgwidth = 100;
     $rssmi_global_options = get_option('rssmi_global_options');
     $suppress_warnings = isset($rssmi_global_options['suppress_warnings']) ? $rssmi_global_options['suppress_warnings'] : 0;
     $strDate = rssmi_get_default_date_format();
     require_once WP_RSS_MULTI_INC . 'excerpt_functions.php';
     extract($args);
     $siteurl = get_site_url();
     $widget_images_url = $siteurl . '/wp-content/plugins/wp-rss-multi-importer/images';
     $title = apply_filters('widget_title', $instance['title']);
     $count = $instance['numoption'];
     (array) ($catArray = isset($instance['category']) ? $instance['category'] : null);
     if (empty($catArray)) {
         $catArray = array("0");
     }
     if (!isset($instance['category']) || IS_NULL($instance['category'])) {
         $instance['category'] = array("0");
     }
     $catList = implode(', ', $instance['category']);
     $sortDir = $instance['checkbox'];
     $showdate = $instance['showdate'];
     $showicon = $instance['showicon'];
     $linktitle = $instance['linktitle'];
     $showdesc = $instance['showdesc'];
     $maxposts = $instance['maxposts'];
     $targetwindow = $instance['targetwindow'];
     $simplelist = $instance['simplelist'];
     $showimage = $instance['showimage'];
     $showsource = $instance['showsource'];
     $descNum = $instance['descnum'];
     $strDate = rssmi_get_default_date_format();
     global $RSSdefaultImage;
     $RSSdefaultImage = $instance['rssdefaultimage'];
     // 0- process normally, 1=use default for category, 2=replace when no image available
     //$RSSdefaultImage=1;
     global $isMobileDevice;
     if (isset($isMobileDevice) && $isMobileDevice == 1) {
         //open mobile device windows in new tab
         $targetwindow = 2;
     }
     if (!empty($linktitle)) {
         $title = '<a href="' . $linktitle . '">' . $title . '</a>';
     }
     if ($showicon == 1) {
         $title = '<img src="' . $widget_images_url . '/rss.png" width="14" height="14" style="border:0;margin-right:5px;">' . $title;
     }
     $addmotion = $instance['addmotion'];
     $background = $instance['background'];
     if ($addmotion == 1) {
         add_action('wp_footer', 'widget_footer_scripts');
     }
     if (!function_exists("wprssmi_hourly_feed")) {
         function wprssmi_hourly_feed()
         {
             return 3600;
         }
     }
     add_filter('wp_feed_cache_transient_lifetime', 'wprssmi_hourly_feed');
     if ($targetwindow == 0) {
         add_action('wp_footer', 'colorbox_scripts');
         // load colorbox only if not indicated as conflict
     }
     if (empty($sortDir)) {
         $sortDir = 0;
     }
     echo $before_widget;
     if (!empty($title)) {
         echo $before_title . $title . $after_title;
     }
     $readable = '';
     $options = get_option('rss_import_items', 'option not found');
     if (!empty($options)) {
         //	$targetwindow=(isset($options['targetWindow']) ? $options['targetWindow'] : null);
     } else {
         //	$targetwindow=2;
     }
     global $wpdb;
     $myarray = array();
     if ($catList == 0) {
         $feedQuery = "SELECT * FROM {$wpdb->posts} as a inner join {$wpdb->postmeta} as b ON a.id=b.post_id where post_type='rssmi_feed' AND post_status='publish' AND meta_key='rssmi_url'";
     } else {
         $feedQuery = "SELECT * FROM {$wpdb->posts} as a inner join {$wpdb->postmeta} as b ON a.id=b.post_id where post_type='rssmi_feed' AND post_status='publish' AND meta_key='rssmi_cat' AND meta_value in ({$catList}) ";
     }
     $feed_array = $wpdb->get_results($feedQuery);
     if (empty($feed_array)) {
         //	return _e("There is a problem - it appears you are using categories and no feeds have been put into those categories.", 'wp-rss-multi-importer');
         return;
     }
     foreach ($feed_array as $feed) {
         $feedlimit = 0;
         $rssmi_cat = get_post_meta($feed->ID, 'rssmi_cat', true);
         $rssmi_source = get_the_title($feed->ID);
         $catSourceArray = array("myGroup" => $rssmi_source, "mycatid" => $rssmi_cat);
         $rssmi_sql = "SELECT a.post_id,b.meta_key,b.meta_value FROM {$wpdb->postmeta} as a inner join {$wpdb->postmeta} as b on a.post_id=b.post_id WHERE a.meta_value ={$feed->ID} and b.meta_key='rssmi_item_date' order by b.meta_value ";
         if ($sortDir == 0) {
             $rssmi_sql .= "desc";
         } elseif ($sortDir == 1) {
             $rssmi_sql .= "asc";
         }
         $desc_array = $wpdb->get_results($rssmi_sql);
         foreach ($desc_array as $arrayItem) {
             $feedlimit = $feedlimit + 1;
             if ($feedlimit > $maxposts) {
                 continue;
             }
             $post_ID = $arrayItem->post_id;
             $desc = get_post_meta($post_ID, 'rssmi_item_description', true);
             $arrayItem = array_merge((array) $desc[0], $catSourceArray);
             //  add the source and category ID
             if (include_post($rssmi_cat, $arrayItem['mydesc'], $arrayItem['mytitle']) == 0) {
                 continue;
             }
             // FILTER
             array_push($myarray, $arrayItem);
             //combine into final array
         }
     }
     if (!isset($myarray) || empty($myarray)) {
         if ($suppress_warnings == 0 && current_user_can('edit_post')) {
             return _e("There is a problem with the feeds you entered.  Go to our <a href='http://www.wprssimporter.com/faqs/im-told-the-feed-isnt-valid-or-working/'>support page</a> to see how to solve this.", 'wp-rss-multi-importer');
         }
         return;
     }
     global $isMobileDevice;
     if (isset($isMobileDevice) && $isMobileDevice == 1) {
         //open mobile device windows in new tab
         $targetwindow = 2;
     }
     //$myarrary sorted by mystrdate
     foreach ($myarray as $key => $row) {
         $dates[$key] = $row["mystrdate"];
     }
     //SORT, DEPENDING ON SETTINGS
     if ($sortDir == 1) {
         array_multisort($dates, SORT_ASC, $myarray);
     } else {
         array_multisort($dates, SORT_DESC, $myarray);
     }
     // HOW THE LINK OPENS
     global $isMobileDevice;
     if (isset($isMobileDevice) && $isMobileDevice == 1) {
         //open mobile device windows in new tab
         $targetwindow = 2;
     }
     if ($targetwindow == 0) {
         $openWindow = 'class="colorbox"';
     } elseif ($targetwindow == 1) {
         $openWindow = 'target=_self';
     } else {
         $openWindow = 'target=_blank';
     }
     $total = -1;
     if ($simplelist == 1) {
         echo '<ul class="wprssmi_widget_list">';
         foreach ($myarray as $items) {
             // VIDEO CHECK
             if ($targetwindow == 0) {
                 $getVideoArray = rssmi_video($items["mylink"]);
                 $openWindow = $getVideoArray[1];
                 $items["mylink"] = $getVideoArray[0];
             }
             $openWindow = rssmi_lightbox_filter($items["mylink"], $targetwindow);
             //Lightbox filter
             $total = $total + 1;
             if ($count > 0 && $total >= $count) {
                 break;
             }
             echo '<li class="title"><a ' . $openWindow . ' href="' . $items["mylink"] . '" ' . ($noFollow == 1 ? 'rel=nofollow' : '') . '>' . $items["mytitle"] . '</a>';
             if (!empty($items["mystrdate"]) && $showdate == 1) {
                 echo '<span class="date">' . date_i18n($strDate, $items["mystrdate"]) . '</span>';
             }
             echo '</li>';
         }
         //  don't mess with this php code
         echo '</ul>';
     } else {
         echo ' <div class="news-wrapper" id="newsticker" style="10px;background-color:' . $background . ';">';
         echo '	<div class="news-contents">';
         foreach ($myarray as $items) {
             // VIDEO CHECK
             if ($targetWindow == 0) {
                 $getVideoArray = rssmi_video($items["mylink"], $targetwindow);
                 $openWindow = $getVideoArray[1];
                 $items["mylink"] = $getVideoArray[0];
             }
             $openWindow = rssmi_lightbox_filter($items["mylink"], $targetwindow);
             //Lightbox filter
             $total = $total + 1;
             if ($count > 0 && $total >= $count) {
                 break;
             }
             echo '<div style="top: 101px;margin-left:5px;" class="news">';
             if ($showimage == 1 && $addmotion != 1) {
                 echo showexcerpt($items["mydesc"], 0, $openWindow, 0, $items["mylink"], 1, "left", 0, $items["myimage"], $items["mycatid"]);
             }
             echo '<div class="rssmi_title_class"><a ' . $openWindow . ' href="' . $items["mylink"] . '" class="news_title">' . $items["mytitle"] . '</a></div>';
             if ($showdesc == 1 && $addmotion != 1) {
                 $desc = esc_attr(strip_tags(@html_entity_decode($items["mydesc"], ENT_QUOTES, get_option('blog_charset'))));
                 $desc = str_replace('[...]', '', $desc);
                 $words = explode(" ", trim($desc));
                 $desc = implode(" ", array_splice($words, 0, $descNum));
                 $desc .= ' <a ' . $openWindow . ' href="' . $items["mylink"] . '">[&hellip;]</a>';
                 echo $desc . '<br/>';
             }
             if (!empty($items["mystrdate"]) && $showdate == 1) {
                 echo date_i18n($strDate, $items["mystrdate"]) . '<br />';
             }
             if (!empty($items["myGroup"]) && $showsource == 1) {
                 echo '<span class="rssmi_group_style" style="font-style:italic;">' . $items["myGroup"] . '</span>';
             }
             //	 echo '</p>';
             echo '</div>';
         }
         echo '</div></div>';
     }
     echo $after_widget;
 }
function wp_rss_multi_importer_shortcode($atts = array())
{
    add_action('wp_footer', 'footer_scripts');
    if (!function_exists("wprssmi_hourly_feed")) {
        function wprssmi_hourly_feed()
        {
            return 0;
        }
    }
    add_filter('wp_feed_cache_transient_lifetime', 'wprssmi_hourly_feed');
    $siteurl = get_site_url();
    $cat_options_url = $siteurl . '/wp-admin/options-general.php?page=wp_rss_multi_importer_admin&tab=category_options/';
    $images_url = $siteurl . '/wp-content/plugins/' . basename(dirname(__FILE__)) . '/images';
    global $fopenIsSet;
    $fopenIsSet = ini_get('allow_url_fopen');
    $parms = shortcode_atts(array('category' => 0, 'hdsize' => '16px', 'hdweight' => 400, 'anchorcolor' => '', 'testyle' => 'color: #000000; font-weight: bold;margin: 0 0 0.8125em;', 'maximgwidth' => 150, 'datestyle' => 'font-style:italic;', 'floattype' => '', 'showdate' => 1, 'showgroup' => 1, 'thisfeed' => '', 'timer' => 0, 'dumpthis' => 0, 'cachetime' => NULL, 'pinterest' => 0, 'maxperpage' => 0, 'excerptlength' => 50, 'noimage' => 0, 'sortorder' => NULL, 'defaultimage' => NULL, 'showdesc' => NULL, 'mytemplate' => '', 'showmore' => NULL, 'authorprep' => 'by', 'windowstyle' => NULL, 'morestyle' => '[...]'), $atts);
    $showThisDesc = $parms['showdesc'];
    $defaultImage = $parms['defaultimage'];
    $sortOrder = $parms['sortorder'];
    $authorPrep = $parms['authorprep'];
    $anchorcolor = $parms['anchorcolor'];
    $datestyle = $parms['datestyle'];
    $hdsize = $parms['hdsize'];
    $thisCat = $parms['category'];
    $parmfloat = $parms['floattype'];
    $catArray = explode(",", $thisCat);
    $showdate = $parms['showdate'];
    $showgroup = $parms['showgroup'];
    $pshowmore = $parms['showmore'];
    $hdweight = $parms['hdweight'];
    $testyle = $parms['testyle'];
    global $morestyle;
    $morestyle = $parms['morestyle'];
    $warnmsg = $parms['warnmsg'];
    global $maximgwidth;
    $maximgwidth = $parms['maximgwidth'];
    $thisfeed = $parms['thisfeed'];
    // max posts per feed
    $timerstop = $parms['timer'];
    $dumpthis = $parms['dumpthis'];
    //diagnostic parameter
    $cachename = 'wprssmi_' . $thisCat;
    $cachetime = $parms['cachetime'];
    $pinterest = $parms['pinterest'];
    $parmmaxperpage = $parms['maxperpage'];
    $noimage = $parms['noimage'];
    $mytemplate = $parms['mytemplate'];
    $windowstyle = $parms['windowstyle'];
    $excerptlength = $parms['excerptlength'];
    $readable = '';
    $options = get_option('rss_import_options');
    $option_items = get_option('rss_import_items');
    $option_category_images = get_option('rss_import_categories_images');
    if ($option_items == false) {
        return _e("You need to set up the WP RSS Multi Importer Plugin before any results will show here.  Just go into the <a href='/wp-admin/options-general.php?page=wp_rss_multi_importer_admin'>settings panel</a> and put in some RSS feeds", 'wp-rss-multi-importer');
    }
    $cat_array = preg_grep("^feed_cat_^", array_keys($option_items));
    if (count($cat_array) == 0) {
        // for backward compatibility
        $noExistCat = 1;
    } else {
        $noExistCat = 0;
    }
    if (!empty($option_items)) {
        //GET PARAMETERS
        global $RSSdefaultImage;
        $RSSdefaultImage = $options['RSSdefaultImage'];
        // 0- process normally, 1=use default for category, 2=replace when no image available
        $size = count($option_items);
        $sortDir = $options['sortbydate'];
        // 1 is ascending
        $stripAll = $options['stripAll'];
        $todaybefore = $options['todaybefore'];
        $adjustImageSize = $options['adjustImageSize'];
        $showDesc = $options['showdesc'];
        // 1 is show
        $descNum = $options['descnum'];
        $maxperPage = $options['maxperPage'];
        $showcategory = $options['showcategory'];
        $cacheMin = $options['cacheMin'];
        $maxposts = $options['maxfeed'];
        $showsocial = $options['showsocial'];
        $targetWindow = $options['targetWindow'];
        // 0=LB, 1=same, 2=new
        $floatType = $options['floatType'];
        $noFollow = $options['noFollow'];
        $showmore = $options['showmore'];
        $cb = $options['cb'];
        // 1 if colorbox should not be loaded
        $pag = $options['pag'];
        // 1 if pagination
        $perPage = $options['perPage'];
        global $anyimage;
        $anyimage = $options['anyimage'];
        $addAuthor = $options['addAuthor'];
        $warnmsg = $options['warnmsg'];
        $directFetch = $options['directFetch'];
        $forceFeed = $options['forceFeed'];
        $forceFeed = $forceFeed == 1 ? True : False;
        $timeout = $options['timeout'];
        if (!isset($timeout)) {
            $timeout = 10;
        }
        if (!isset($directFetch)) {
            $directFetch = 0;
        }
        if (!is_null($defaultImage)) {
            $RSSdefaultImage = $defaultImage;
        }
        if (!is_null($windowstyle)) {
            $targetWindow = $windowstyle;
        }
        if (!is_null($showThisDesc)) {
            $showDesc = $showThisDesc;
        }
        if (!is_null($sortOrder)) {
            $sortDir = $sortOrder;
        }
        if (!is_null($pshowmore)) {
            $showmore = $pshowmore;
        }
        if (!is_null($excerptlength)) {
            $descNum = $excerptlength;
        }
        if (empty($options['sourcename'])) {
            $attribution = '';
        } else {
            $attribution = $options['sourcename'] . ': ';
        }
        if ($floatType == '1') {
            $float = "left";
        } else {
            $float = "none";
        }
        if ($parmfloat != '') {
            $float = $parmfloat;
        }
        if ($parmmaxperpage != 0) {
            $maxperPage = $parmmaxperpage;
        }
        if ($noimage == 1) {
            $stripAll = 1;
        }
        if ($thisfeed != '') {
            $maxposts = $thisfeed;
        }
        if ($pinterest == 1) {
            $divfloat = "left";
        } else {
            $divfloat = '';
        }
        if ($cacheMin == '') {
            $cacheMin = 0;
        }
        //set caching minutes
        if (!is_null($cachetime)) {
            $cacheMin = $cachetime;
        }
        //override caching minutes with shortcode parameter
        if (is_null($cb) && $targetWindow == 0) {
            add_action('wp_footer', 'colorbox_scripts');
            // load colorbox only if not indicated as conflict
        }
        $template = $options['template'];
        if ($mytemplate != '') {
            $template = $mytemplate;
        }
        //	END PARAMETERS
        timer_start();
        //TIMER START - for testing purposes
        $myarray = get_transient($cachename);
        // added  for transient cache
        if ($cacheMin == 0) {
            delete_transient($cachename);
        }
        if (false === $myarray) {
            //  added  for transient cache - only get feeds and put into array if the array isn't cached (for a given category set)
            for ($i = 1; $i <= $size; $i = $i + 1) {
                $key = key($option_items);
                if (!strpos($key, '_') > 0) {
                    continue;
                }
                //this makes sure only feeds are included here...everything else are options
                $rssName = $option_items[$key];
                next($option_items);
                $key = key($option_items);
                $rssURL = $option_items[$key];
                next($option_items);
                $key = key($option_items);
                $rssCatID = $option_items[$key];
                ///this should be the category ID
                if (!in_array(0, $catArray) && in_array($option_items[$key], $catArray) || in_array(0, $catArray) || $noExistCat == 1) {
                    $myfeeds[] = array("FeedName" => $rssName, "FeedURL" => $rssURL, "FeedCatID" => $rssCatID);
                    //with Feed Category ID
                }
                $cat_array = preg_grep("^feed_cat_^", array_keys($option_items));
                // for backward compatibility
                if (count($cat_array) > 0) {
                    next($option_items);
                    //skip feed category
                }
            }
            if ($maxposts == "") {
                return _e("One more step...go into the the <a href='/wp-admin/options-general.php?page=wp_rss_multi_importer_admin&tab=setting_options'>Settings Panel and choose Options.</a>", 'wp-rss-multi-importer');
            }
            // check to confirm they set options
            if (empty($myfeeds)) {
                return _e("You've either entered a category ID that doesn't exist or have no feeds configured for this category.  Edit the shortcode on this page with a category ID that exists, or <a href=" . $cat_options_url . ">go here and and get an ID</a> that does exist in your admin panel.", 'wp-rss-multi-importer');
                exit;
            }
            if ($dumpthis == 1) {
                rssmi_list_the_plugins();
                echo "<strong>Feeds</strong><br>";
                var_dump($myfeeds);
            }
            foreach ($myfeeds as $feeditem) {
                $url = (string) $feeditem["FeedURL"];
                while (stristr($url, 'http') != $url) {
                    $url = substr($url, 1);
                }
                if (empty($url)) {
                    continue;
                }
                $url = esc_url_raw(strip_tags($url));
                if ($directFetch == 1) {
                    $feed = wp_rss_fetchFeed($url, $timeout, $forceFeed);
                } else {
                    $feed = fetch_feed($url);
                }
                if (is_wp_error($feed)) {
                    if ($dumpthis == 1) {
                        echo $feed->get_error_message();
                    }
                    if ($size < 4) {
                        return _e("You have one feed and it's not a valid RSS feed.  This is likely a problem with the source of the RSS feed.  Contact our support forum for help.", 'wp-rss-multi-importer');
                        exit;
                    } else {
                        //echo $feed->get_error_message();
                        continue;
                    }
                }
                $maxfeed = $feed->get_item_quantity(0);
                if ($feedAuthor = $feed->get_author()) {
                    $feedAuthor = $feed->get_author()->get_name();
                }
                //SORT DEPENDING ON SETTINGS
                if ($sortDir == 1) {
                    for ($i = $maxfeed - 1; $i >= $maxfeed - $maxposts; $i--) {
                        $item = $feed->get_item($i);
                        if (empty($item)) {
                            continue;
                        }
                        if (include_post($feeditem["FeedCatID"], $item->get_content(), $item->get_title()) == 0) {
                            continue;
                        }
                        // FILTER
                        if ($enclosure = $item->get_enclosure()) {
                            if (!IS_NULL($item->get_enclosure()->get_thumbnail())) {
                                $mediaImage = $item->get_enclosure()->get_thumbnail();
                            } else {
                                if (!IS_NULL($item->get_enclosure()->get_link())) {
                                    $mediaImage = $item->get_enclosure()->get_link();
                                }
                            }
                        }
                        if ($itemAuthor = $item->get_author()) {
                            $itemAuthor = $item->get_author()->get_name();
                        } else {
                            if (!IS_NULL($feedAuthor)) {
                                $itemAuthor = $feedAuthor;
                            }
                        }
                        $myarray[] = array("mystrdate" => strtotime($item->get_date()), "mytitle" => $item->get_title(), "mylink" => $item->get_link(), "myGroup" => $feeditem["FeedName"], "mydesc" => $item->get_content(), "myimage" => $mediaImage, "mycatid" => $feeditem["FeedCatID"], "myAuthor" => $itemAuthor);
                        unset($mediaImage);
                        unset($itemAuthor);
                    }
                } else {
                    for ($i = 0; $i <= $maxposts - 1; $i++) {
                        $item = $feed->get_item($i);
                        if (empty($item)) {
                            continue;
                        }
                        if (include_post($feeditem["FeedCatID"], $item->get_content(), $item->get_title()) == 0) {
                            continue;
                        }
                        // FILTER
                        //	$x=1;
                        if ($enclosure = $item->get_enclosure()) {
                            if (!IS_NULL($item->get_enclosure()->get_thumbnail())) {
                                $mediaImage = $item->get_enclosure()->get_thumbnail();
                                //$mediaImage=$mediaImage2[$x];
                            } else {
                                if (!IS_NULL($item->get_enclosure()->get_link())) {
                                    $mediaImage = $item->get_enclosure()->get_link();
                                }
                            }
                        }
                        if ($itemAuthor = $item->get_author()) {
                            $itemAuthor = $item->get_author()->get_name();
                        } else {
                            if (!IS_NULL($feedAuthor)) {
                                $itemAuthor = $feedAuthor;
                            }
                        }
                        $myarray[] = array("mystrdate" => strtotime($item->get_date()), "mytitle" => $item->get_title(), "mylink" => $item->get_link(), "myGroup" => $feeditem["FeedName"], "mydesc" => $item->get_content(), "myimage" => $mediaImage, "mycatid" => $feeditem["FeedCatID"], "myAuthor" => $itemAuthor);
                        unset($mediaImage);
                        unset($itemAuthor);
                    }
                }
            }
            if ($cacheMin !== 0) {
                set_transient($cachename, $myarray, 60 * $cacheMin);
                //  added  for transient cache
            }
        }
        //  added  for transient cache
        if ($timerstop == 1) {
            timer_stop(1);
            echo ' seconds<br>';
            //TIMER END for testing purposes
        }
        //  CHECK $myarray BEFORE DOING ANYTHING ELSE //
        if ($dumpthis == 1) {
            echo "<br><strong>Array</strong><br>";
            var_dump($myarray);
            return;
        }
        if (!isset($myarray) || empty($myarray)) {
            if (!$warnmsg == 1 && current_user_can('edit_post')) {
                return _e("There is a problem with the feeds you entered.  Go to our <a href='http://www.allenweiss.com/faqs/im-told-the-feed-isnt-valid-or-working/'>support page</a> to see how to solve this.", 'wp-rss-multi-importer');
            }
            return;
        }
        global $isMobileDevice;
        if (isset($isMobileDevice) && $isMobileDevice == 1) {
            //open mobile device windows in new tab
            $targetWindow = 2;
        }
        //$myarrary sorted by mystrdate
        foreach ($myarray as $key => $row) {
            $dates[$key] = $row["mystrdate"];
        }
        //SORT, DEPENDING ON SETTINGS
        if ($sortDir == 1) {
            array_multisort($dates, SORT_ASC, $myarray);
        } else {
            array_multisort($dates, SORT_DESC, $myarray);
        }
        // HOW THE LINK OPENS
        if ($targetWindow == 0) {
            $openWindow = 'class="colorbox"';
        } elseif ($targetWindow == 1) {
            $openWindow = 'target="_self"';
        } else {
            $openWindow = 'target="_blank"';
        }
        $total = -1;
        $todayStamp = 0;
        $idnum = 0;
        //for pagination
        $currentPage = trim($_REQUEST[pg]);
        $currentURL = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
        $currentURL = str_replace('&pg=' . $currentPage, '', $currentURL);
        $currentURL = str_replace('?pg=' . $currentPage, '', $currentURL);
        if (strpos($currentURL, '?') == 0) {
            $currentURL = $currentURL . '?';
        } else {
            $currentURL = $currentURL . '&';
        }
        //pagination controls and parameters
        if (!isset($perPage)) {
            $perPage = 5;
        }
        $numPages = ceil(count($myarray) / $perPage);
        if (!$currentPage || $currentPage > $numPages) {
            $currentPage = 0;
        }
        $start = $currentPage * $perPage;
        $end = $currentPage * $perPage + $perPage;
        if ($pag == 1) {
            //set up pagination array and put into myarray
            foreach ($myarray as $key => $val) {
                if ($key >= $start && $key < $end) {
                    $pagedData[] = $myarray[$key];
                }
            }
            $myarray = $pagedData;
        }
        //end set up pagination array and put into myarray
        //  templates checked and added here
        if (!isset($template) || $template == '') {
            return _e("One more step...go into the <a href='/wp-admin/options-general.php?page=wp_rss_multi_importer_admin&tab=setting_options'>Settings Panel and choose a Template.</a>", 'wp-rss-multi-importer');
        }
        require WP_RSS_MULTI_TEMPLATES . $template;
    }
    //pagination controls at bottom
    if ($pag == 1 && $numPages > 1) {
        $readable .= '<div class="rssmi_pagination"><ul>';
        for ($q = 0; $q < $numPages; $q++) {
            if ($currentPage > 0 && $q == 0) {
                $readable .= '<li class="prev"><a href="http://' . $currentURL . 'pg=' . ($currentPage - 1) . '">Prev</a></li>';
            }
            if ($currentPage != $q) {
                $readable .= '<li><a href="http://' . $currentURL . 'pg=' . $q . '"> ' . __($q + 1, 'wp-rss-multi-importer') . '</a></li>';
            } else {
                $readable .= '<li class="active"><a href="#">' . ($q + 1) . '</a></li>';
            }
            if ($q == $numPages - 1 && $currentPage != $numPages - 1) {
                $readable .= '<li class="next"><a href="http://' . $currentURL . 'pg=' . ($currentPage + 1) . '">Next</a></li>';
            }
        }
        $readable .= '</ul></div>';
    }
    //end pagination controls at bottom
    return $readable;
}
示例#9
0
?>
		</td>
	</tr>

	<tr>
		<td width="30%" class="paramlist_key">
			<label for="teil">
				<?php 
echo JText::_('PARTICIPANT_COUNT');
?>
:
			</label>
		</td>
		<td class="paramlist_value">
			<?php 
if (IS_NULL($this->turnier->rnd) or $this->turnier->rnd == 0) {
    ?>
				<input class="inputbox" onchange="showFormRoundscount();" type="text" name="teil" id="teil" size="10" maxlength="5" value="<?php 
    echo $this->turnier->teil;
    ?>
" />
			<?php 
} else {
    echo $this->turnier->teil;
    echo CLMForm::hidden('teil', $this->turnier->teil);
    // damit JavaScript funktioniert
}
?>
		</td>
	</tr>
示例#10
0
function rss_mediaImage_test($item)
{
    $is_media_image = 0;
    if ($enclosure = $item->get_enclosure()) {
        if (!IS_NULL($item->get_enclosure()->get_thumbnails())) {
            $inum = 0;
            $mediaImageArray = $item->get_enclosure()->get_thumbnails();
            //	$mediaImage=$mediaImageArray[$inum];
            $is_media_image = 1;
        } else {
            if (!IS_NULL($item->get_enclosure()->get_link())) {
                $mediaImage = $item->get_enclosure()->get_link();
                $is_media_image = 1;
            }
        }
    }
    return $is_media_image;
}
示例#11
0
function wp_rss_multi_importer_post($feedID = NULL, $catID = NULL)
{
    $postMsg = FALSE;
    require_once ABSPATH . "wp-admin" . '/includes/media.php';
    require_once ABSPATH . "wp-admin" . '/includes/file.php';
    require_once ABSPATH . "wp-admin" . '/includes/image.php';
    if (!function_exists("wprssmi_hourly_feed")) {
        function wprssmi_hourly_feed()
        {
            return 0;
        }
        // no caching of RSS feed
    }
    add_filter('wp_feed_cache_transient_lifetime', 'wprssmi_hourly_feed');
    $options = get_option('rss_import_options', 'option not found');
    $option_items = get_option('rss_import_items', 'option not found');
    $post_options = get_option('rss_post_options', 'option not found');
    $category_tags = get_option('rss_import_categories_images', 'option not found');
    $rssmi_global_options = get_option('rssmi_global_options');
    global $fopenIsSet;
    $fopenIsSet = ini_get('allow_url_fopen');
    if ($post_options['active'] != 1) {
        return;
        exit;
    }
    if (!IS_NULL($feedID)) {
        $feedIDArray = explode(",", $feedID);
    }
    if (!empty($post_options)) {
        //GET PARAMETERS
        $size = count($option_items);
        $sortDir = 0;
        // 1 is ascending
        $maxperPage = $options['maxperPage'];
        global $setFeaturedImage;
        $setFeaturedImage = $post_options['setFeaturedImage'];
        $addSource = isset($post_options['addSource']) ? $post_options['addSource'] : null;
        $sourceAnchorText = $post_options['sourceAnchorText'];
        $maxposts = $post_options['maxfeed'];
        $post_status = $post_options['post_status'];
        $addAuthor = isset($post_options['addAuthor']) ? $post_options['addAuthor'] : null;
        $post_format = $post_options['post_format'];
        $postTags = isset($post_options['postTags']) ? $post_options['postTags'] : null;
        global $RSSdefaultImage;
        $RSSdefaultImage = $post_options['RSSdefaultImage'];
        // 0- process normally, 1=use default for category, 2=replace when no image available
        $serverTimezone = $post_options['timezone'];
        $autoDelete = isset($post_options['autoDelete']) ? $post_options['autoDelete'] : null;
        $sourceWords = $post_options['sourceWords'];
        $readMore = $post_options['readmore'];
        $showVideo = isset($post_options['showVideo']) ? $post_options['showVideo'] : null;
        $custom_type_name = $post_options['custom_type_name'];
        $includeExcerpt = isset($post_options['includeExcerpt']) ? $post_options['includeExcerpt'] : null;
        global $morestyle;
        $morestyle = ' ...read more';
        $sourceWords_Label = $post_options['sourceWords_Label'];
        if (!is_null($readMore) && strlen($readMore) > 0) {
            $morestyle = $readMore;
        }
        switch ($sourceWords) {
            case 1:
                $sourceLable = 'Source:';
                break;
            case 2:
                $sourceLable = 'Via:';
                break;
            case 3:
                $sourceLable = 'Read more here:';
                break;
            case 4:
                $sourceLable = 'From:';
                break;
            case 5:
                $sourceLable = $sourceWords_Label;
                break;
            default:
                $sourceLable = 'Source';
        }
        if (isset($serverTimezone) && $serverTimezone != '') {
            //set time zone
            date_default_timezone_set($serverTimezone);
            $rightNow = get_date_from_gmt(date("Y-m-d H:i:s", time()));
        } else {
            $rightNow = get_date_from_gmt(date("Y-m-d H:i:s", time()));
        }
        if ($post_options['categoryid']['wpcatid'][1] !== NULL) {
            $wpcatids = array_filter($post_options['categoryid']['wpcatid'], 'filter_id_callback');
            //array of post blog categories that have been entered
        }
        if (!empty($wpcatids)) {
            $catArray = get_values_for_id_keys($post_options['categoryid']['plugcatid'], array_keys($wpcatids));
            //array of plugin categories that have an association with post blog categories
            $catArray = array_diff($catArray, array(''));
        } else {
            $catArray = array(0);
        }
        if (!IS_NULL($catID)) {
            $catArray = array($catID);
            //  change to category ID if using external CRON
        }
        $targetWindow = $post_options['targetWindow'];
        // 0=LB, 1=same, 2=new
        if (empty($options['sourcename'])) {
            $attribution = '';
        } else {
            $attribution = $options['sourcename'] . ': ';
        }
        global $ftp;
        $ftp = 1;
        //identify pass to excerpt_functions comes from feed to post
        global $maximgwidth;
        $maximgwidth = $post_options['maximgwidth'];
        $descNum = $post_options['descnum'];
        $stripAll = $post_options['stripAll'];
        $stripSome = isset($post_options['stripSome']) ? $post_options['stripSome'] : null;
        $maxperfetch = $post_options['maxperfetch'];
        $showsocial = isset($post_options['showsocial']) ? $post_options['showsocial'] : null;
        $overridedate = isset($post_options['overridedate']) ? $post_options['overridedate'] : null;
        $commentStatus = isset($post_options['commentstatus']) ? $post_options['commentstatus'] : null;
        $noFollow = isset($post_options['noFollow']) ? $post_options['noFollow'] : 0;
        if ($commentStatus == '1') {
            $comment_status = 'closed';
        } else {
            $comment_status = 'open';
        }
        $adjustImageSize = 1;
        $floatType = 1;
        if ($floatType == '1') {
            $float = "left";
        } else {
            $float = "none";
        }
        global $wpdb;
        $myarray = array();
        //$feedQuery="SELECT ID FROM $wpdb->posts WHERE  post_type ='rssmi_feed' AND post_status='publish'";
        //first get $catArray and change to comma delimited
        $catString = implode(",", $catArray);
        /*
        if ($catString==0 || !EMPTY($feedIDArray)){
        	$feedQuery="SELECT * FROM wp_posts inner join wp_postmeta ON wp_posts.id=wp_postmeta.post_id where `post_type`='rssmi_feed' AND `post_status`='publish' AND `meta_key`='rssmi_url'"; 
        }else{
        	$feedQuery="SELECT * FROM wp_posts inner join wp_postmeta ON wp_posts.id=wp_postmeta.post_id where `post_type`='rssmi_feed' AND `post_status`='publish' AND `meta_key`='rssmi_cat' AND `meta_value` in ($catString) ";
        	}
        */
        if ($catString == 0 || !empty($feedIDArray)) {
            $feedQuery = "SELECT * FROM {$wpdb->posts} as a inner join {$wpdb->postmeta} as b ON a.id=b.post_id where post_type='rssmi_feed' AND post_status='publish' AND meta_key='rssmi_url'";
        } else {
            $feedQuery = "SELECT * FROM {$wpdb->posts} as a inner join {$wpdb->postmeta} as b ON a.id=b.post_id where post_type='rssmi_feed' AND post_status='publish' AND meta_key='rssmi_cat' AND meta_value in ({$catString}) ";
        }
        $feed_array = $wpdb->get_results($feedQuery);
        //  ***  GET THE FEED URLS  ***
        foreach ($feed_array as $feed) {
            $feedlimit = 0;
            $rssmi_cat = get_post_meta($feed->ID, 'rssmi_cat', true);
            $rssmi_url = get_post_meta($feed->ID, 'rssmi_url', true);
            $rssmi_user = get_post_meta($feed->ID, 'rssmi_user', true);
            $rssmi_title = get_the_title($feed->ID);
            $rssmi_feedID = $feed->ID;
            $catSourceArray = array("myGroup" => $rssmi_title, "mycatid" => $rssmi_cat, "bloguserid" => $rssmi_user);
            $rssmi_sql = "SELECT a.post_id,b.meta_key,b.meta_value FROM {$wpdb->postmeta} as a inner join {$wpdb->postmeta} as b on a.post_id=b.post_id WHERE a.meta_value ={$feed->ID} and b.meta_key='rssmi_item_date' order by b.meta_value desc";
            $desc_array = $wpdb->get_results($rssmi_sql);
            foreach ($desc_array as $arrayItem) {
                $feedlimit = $feedlimit + 1;
                if ($feedlimit > $maxposts) {
                    continue;
                }
                $post_ID = $arrayItem->post_id;
                $desc = get_post_meta($post_ID, 'rssmi_item_description', true);
                $arrayItem = array_merge((array) $desc[0], $catSourceArray);
                //  add the source and category ID
                if (include_post($rssmi_cat, $arrayItem['mydesc'], $arrayItem['mytitle']) == 0) {
                    continue;
                }
                // FILTER
                array_push($myarray, $arrayItem);
                //combine into final array
            }
        }
        $dumpthis = isset($dumpthis) ? $dumpthis : null;
        if (!isset($myfeeds) || empty($myfeeds)) {
            //	return 3;
            //	exit;
        }
        if (is_integer($myarray)) {
            return $myarray;
        }
        // RETURNS ERROR CODE IF PRESENT
        //  CHECK $myarray BEFORE DOING ANYTHING ELSE //
        if (isset($dumpthis) && $dumpthis == 1) {
            var_dump($myarray);
        }
        if (!isset($myarray) || empty($myarray)) {
            return 3;
            exit;
        }
        //$myarrary sorted by mystrdate
        foreach ($myarray as $key => $row) {
            $dates[$key] = $row["mystrdate"];
        }
        //SORT, DEPENDING ON SETTINGS
        if ($sortDir == 1) {
            array_multisort($dates, SORT_ASC, $myarray);
        } else {
            array_multisort($dates, SORT_DESC, $myarray);
        }
        if ($targetWindow == 0) {
            $openWindow = 'class="colorbox"';
        } elseif ($targetWindow == 1) {
            $openWindow = 'target=_self';
        } else {
            $openWindow = 'target=_blank ';
        }
        $total = 0;
        $added = 0;
        global $wpdb;
        // get all links that have been previously processed
        $wpdb->show_errors = true;
        /*
        $rssmi_existing_permalinks = $wpdb->get_col(
                                        "SELECT meta_value
                                        FROM $wpdb->postmeta
                                        WHERE meta_key = 'rssmi_source_link' ORDER BY meta_id DESC limit 0,5000");
        
        $rssmi_existing_titles=	$wpdb->get_col(
        							        "SELECT post_title
        							         FROM $wpdb->posts WHERE post_type = 'post' ORDER BY post_date DESC limit 0,5000");
        */
        foreach ($myarray as $items) {
            $total = $total + 1;
            if ($total > $maxperfetch) {
                break;
            }
            $thisLink = trim($items["mylink"]);
            $useMediaImage = $items["useMediaImage"];
            //	echo $thisLink.'<br>';
            // VIDEO CHECK
            if ($targetWindow == 0) {
                $getVideoArray = rssmi_video($items["mylink"], $targetWindow);
                $openWindow = $getVideoArray[1];
                $items["mylink"] = $getVideoArray[0];
                $vt = $getVideoArray[2];
            }
            $openWindow = rssmi_lightbox_filter($items["mylink"], $targetWindow);
            //Lightbox filter
            $thisLink = strip_qs_var_match('news.google.com', $thisLink, 'url');
            // clean all parameters except the url from links from Google News
            $thisLink = strip_qs_var('bing.com', $thisLink, 'tid');
            // clean time based links from Bing
            $thisLink = esc_url($thisLink);
            $wpdb->flush();
            $mypostids = $wpdb->get_results("select post_id from {$wpdb->postmeta} where meta_key = 'rssmi_source_link' and meta_value like '%" . $thisLink . "%'");
            //	if (!empty($items["mytitle"])){
            //	$myposttitle=$wpdb->get_results("select post_title from $wpdb->posts where post_title like '%".mysql_real_escape_string(trim($items["mytitle"]))."%'");
            //	}
            if (empty($mypostids) && $mypostids !== false) {
                $added = $added + 1;
                $thisContent = '';
                $post = array();
                $post['post_status'] = $post_status;
                if ($overridedate == 1 || IS_NULL($items['mystrdate'])) {
                    $post['post_date'] = $rightNow;
                } else {
                    $post['post_date'] = date('Y-m-d H:i:s', $items['mystrdate']);
                    //$post['post_date'] = get_date_from_gmt(date('Y-m-d H:i:s',$items['mystrdate']));
                }
                $thisTitle = html_entity_decode(trim($items["mytitle"]));
                if ($rssmi_global_options['fb_title_check'] == 1) {
                    $thisTitle = rssmi_fb_title_filter($thisLink, $thisTitle);
                }
                $post['post_title'] = $thisTitle;
                //Beginning of Content
                //Add Author
                $authorPrep = "By ";
                if (!empty($items["myAuthor"]) && $addAuthor == 1) {
                    $thisContent .= '<span style="font-style:italic; font-size:16px;">' . $authorPrep . ' <a ' . $openWindow . ' href=' . $items["mylink"] . ' ' . ($noFollow == 1 ? 'rel=nofollow' : '') . '">' . $items["myAuthor"] . '</a></span>  ';
                }
                //Add main content
                $thisExcerpt = showexcerpt($items["mydesc"], $descNum, $openWindow, $stripAll, $items["mylink"], $adjustImageSize, $float, $noFollow, $items["myimage"], $items["mycatid"], $stripSome, $feedHomePage, $noProcess, $useMediaImage);
                //  Add video if exists
                if ((strpos($items["mylink"], 'www.youtube.com') > 0 || strpos($items["mylink"], 'player.vimeo') > 0) && $showVideo == 1) {
                    if ($vt == 'yt') {
                        $thisExcerpt = rssmi_yt_video_content($items["mydesc"]) . "<br>";
                    } else {
                        if ($vt == 'vm') {
                            $thisExcerpt = rssmi_vimeo_video_content($items["mydesc"]) . "<br>";
                        }
                    }
                    //	$thisContent.="\r\n".$orig_video_link."\r\n";
                    $thisExcerpt .= '<iframe title=".$items["mytitle"]." width="420" height="315" src="' . $items["mylink"] . '" frameborder="0" allowfullscreen allowTransparency="true"></iframe>';
                }
                $thisContent .= $thisExcerpt;
                //Add Source
                if ($addSource == 1) {
                    switch ($sourceAnchorText) {
                        case 1:
                            $anchorText = $items["myGroup"];
                            break;
                        case 2:
                            $anchorText = $items["mytitle"];
                            break;
                        case 3:
                            $anchorText = $items["mylink"];
                            break;
                        default:
                            $anchorText = $items["myGroup"];
                    }
                    $thisContent .= ' <p>' . $sourceLable . ': <a href=' . $items["mylink"] . '  ' . $openWindow . '  title="' . $items["mytitle"] . '" ' . ($noFollow == 1 ? 'rel=nofollow' : '') . '>' . $anchorText . '</a></p>';
                }
                //Social
                if ($showsocial == 1) {
                    $thisContent .= '<span style="margin-left:10px;"><a href="http://www.facebook.com/sharer/sharer.php?u=' . $items["mylink"] . '"><img src="' . WP_RSS_MULTI_IMAGES . 'facebook.png"/></a>&nbsp;&nbsp;<a href="http://twitter.com/intent/tweet?text=' . rawurlencode($items["mytitle"]) . '%20' . $items["mylink"] . '"><img src="' . WP_RSS_MULTI_IMAGES . 'twitter.png"/></a>&nbsp;&nbsp;<a href="http://plus.google.com/share?url=' . rawurlencode($items["mylink"]) . '"><img src="' . WP_RSS_MULTI_IMAGES . 'gplus.png"/></a>&nbsp;&nbsp;<a href="http://www.linkedin.com/shareArticle?mini=true&url=' . rawurlencode($items["mylink"]) . '"><img src="' . WP_RSS_MULTI_IMAGES . 'linkedin.png"/></a></span>';
                }
                //End of Content
                $post['post_content'] = $thisContent;
                if ($includeExcerpt == 1) {
                    $post['post_excerpt'] = $thisExcerpt;
                }
                $mycatid = $items["mycatid"];
                $blogcatid = array();
                if (!empty($post_options['categoryid']['plugcatid'])) {
                    $catkey = array_search($mycatid, $post_options['categoryid']['plugcatid']);
                    $blogcatid = isset($post_options['categoryid']['wpcatid'][$catkey]) ? $post_options['categoryid']['wpcatid'][$catkey] : 0;
                    //$blogcatid=$post_options['categoryid']['wpcatid'][$catkey];
                } else {
                    $blogcatid = 0;
                }
                if ($post_options['categoryid']['plugcatid'][1] == '0') {
                    //this gets all the wp categories indicated when All is chosen in the first position
                    $allblogcatid = $post_options['categoryid']['wpcatid'][1];
                    if (is_array($blogcatid)) {
                        $blogcatid = array_merge($blogcatid, $allblogcatid);
                        $blogcatid = array_unique($blogcatid);
                    } else {
                        $blogcatid = $allblogcatid;
                    }
                }
                $post['post_category'] = $blogcatid;
                if (is_null($items["bloguserid"])) {
                    if (is_null($bloguserid) || empty($bloguserid)) {
                        $bloguserid = 1;
                    }
                    //check that userid isn't empty else give it admin status
                } else {
                    $bloguserid = $items["bloguserid"];
                }
                $post['post_author'] = $bloguserid;
                $post['comment_status'] = $comment_status;
                if (!empty($category_tags[$mycatid]['tags'])) {
                    $postTags = $category_tags[$mycatid]['tags'];
                } else {
                    $postTags = '';
                }
                if ($postTags != '') {
                    $post['tags_input'] = $postTags;
                }
                if ($custom_type_name != '') {
                    $post['post_type'] = $custom_type_name;
                }
                $post_id = wp_insert_post($post);
                set_post_format($post_id, $post_format);
                if (add_post_meta($post_id, 'rssmi_source_link', $thisLink) != false) {
                    add_post_meta($post_id, 'rssmi_source_feed', $items["feedID"]);
                    add_post_meta($post_id, 'rssmi_source_date', $items['mystrdate']);
                    if ($setFeaturedImage == 1 || $setFeaturedImage == 2) {
                        global $featuredImage;
                        if (isset($featuredImage)) {
                            $featuredImage = rssmi_facebook_autopost($featuredImage);
                            $featuredImageTitle = trim($items["mytitle"]);
                            setFeaturedImage($post_id, $featuredImage, $featuredImageTitle);
                            unset($featuredImage);
                        }
                    }
                } else {
                    wp_delete_post($post_id, true);
                    unset($post);
                    continue;
                }
                unset($post);
            }
        }
        if ($added == 0) {
            return 4;
        }
        $postMsg = TRUE;
    }
    if ($autoDelete == 1) {
        rssmi_delete_posts();
    }
    return $postMsg;
}
 /**
  * Front-end display of widget.
  *
  * @see WP_Widget::widget()
  *
  * @param array $args     Widget arguments.
  * @param array $instance Saved values from database.
  */
 public function widget($args, $instance)
 {
     add_action('wp_footer', 'footer_scripts');
     /* Load the excerpt functions file. */
     global $maximgwidth;
     $maximgwidth = 100;
     global $anyimage;
     // to identify any image in description
     $anyimage = 1;
     require_once WP_RSS_MULTI_INC . 'excerpt_functions.php';
     extract($args);
     $siteurl = get_site_url();
     $widget_images_url = $siteurl . '/wp-content/plugins/wp-rss-multi-importer/images';
     $title = apply_filters('widget_title', $instance['title']);
     $count = $instance['numoption'];
     (array) ($catArray = $instance['category']);
     if (empty($catArray)) {
         $catArray = array("0");
     }
     $sortDir = $instance['checkbox'];
     $showdate = $instance['showdate'];
     $showicon = $instance['showicon'];
     $linktitle = $instance['linktitle'];
     $showdesc = $instance['showdesc'];
     $maxposts = $instance['maxposts'];
     $targetwindow = $instance['targetwindow'];
     $simplelist = $instance['simplelist'];
     $showimage = $instance['showimage'];
     $showsource = $instance['showsource'];
     $descNum = $instance['descnum'];
     global $anyimage;
     $anyimage = 1;
     global $RSSdefaultImage;
     $RSSdefaultImage = $instance['rssdefaultimage'];
     // 0- process normally, 1=use default for category, 2=replace when no image available
     //$RSSdefaultImage=1;
     global $isMobileDevice;
     if (isset($isMobileDevice) && $isMobileDevice == 1) {
         //open mobile device windows in new tab
         $targetwindow = 2;
     }
     if (!empty($linktitle)) {
         $title = '<a href="' . $linktitle . '">' . $title . '</a>';
     }
     if ($showicon == 1) {
         $title = '<img src="' . $widget_images_url . '/rss.png" width="14" height="14" style="border:0;margin-right:5px;">' . $title;
     }
     $addmotion = $instance['addmotion'];
     $background = $instance['background'];
     if ($addmotion == 1) {
         add_action('wp_footer', 'widget_footer_scripts');
     }
     if (!function_exists("wprssmi_hourly_feed")) {
         function wprssmi_hourly_feed()
         {
             return 3600;
         }
     }
     add_filter('wp_feed_cache_transient_lifetime', 'wprssmi_hourly_feed');
     if ($cb !== '1' && $targetwindow == 0) {
         add_action('wp_footer', 'colorbox_scripts');
         // load colorbox only if not indicated as conflict
     }
     if (empty($sortDir)) {
         $sortDir = 0;
     }
     echo $before_widget;
     if (!empty($title)) {
         echo $before_title . $title . $after_title;
     }
     $readable = '';
     $options = get_option('rss_import_items', 'option not found');
     $cat_array = preg_grep("^feed_cat_^", array_keys($options));
     if (count($cat_array) == 0) {
         //for backward compatibility
         $noExistCat = 1;
     } else {
         $noExistCat = 0;
     }
     $size = count($options);
     $targetWindow = $options['targetWindow'];
     //	$sortDir=$options['sortbydate'];
     //$sortDir=0;
     for ($i = 1; $i <= $size; $i = $i + 1) {
         $key = key($options);
         if (!strpos($key, '_') > 0) {
             continue;
         }
         //this makes sure only feeds are included here...everything else are options
         $rssName = $options[$key];
         next($options);
         $key = key($options);
         $rssURL = $options[$key];
         next($options);
         $key = key($options);
         $rssCatID = $options[$key];
         if (!in_array(0, $catArray) && in_array($options[$key], $catArray) || in_array(0, $catArray) || $noExistCat == 1) {
             $myfeeds[] = array("FeedName" => $rssName, "FeedURL" => $rssURL, "FeedCatID" => $rssCatID);
         }
         $cat_array = preg_grep("^feed_cat_^", array_keys($options));
         // for backward compatibility
         if (count($cat_array) > 0) {
             next($options);
             //skip feed category
         }
     }
     if (empty($myfeeds)) {
         return "You've either entered a category ID that doesn't exist or have no feeds configured for this category.  Edit the shortcode on this page with a category ID that exists, or <a href=" . $cat_options_url . ">go here and and get an ID</a> that does exist in your admin panel.";
         exit;
     }
     foreach ($myfeeds as $feeditem) {
         $url = (string) $feeditem["FeedURL"];
         while (stristr($url, 'http') != $url) {
             $url = substr($url, 1);
         }
         $feed = fetch_feed($url);
         if (is_wp_error($feed)) {
             continue;
         }
         $maxfeed = $feed->get_item_quantity(0);
         //SORT DEPENDING ON SETTINGS
         if ($sortDir == 1) {
             for ($i = $maxfeed; $i >= $maxfeed - $maxposts; $i--) {
                 $item = $feed->get_item($i);
                 if (empty($item)) {
                     continue;
                 }
                 if (include_post($feeditem["FeedCatID"], $item->get_content(), $item->get_title()) == 0) {
                     continue;
                 }
                 // FILTER
                 if ($enclosure = $item->get_enclosure()) {
                     if (!IS_NULL($item->get_enclosure()->get_thumbnail())) {
                         $mediaImage = $item->get_enclosure()->get_thumbnail();
                     } else {
                         if (!IS_NULL($item->get_enclosure()->get_link())) {
                             $mediaImage = $item->get_enclosure()->get_link();
                         }
                     }
                 }
                 $myarray[] = array("mystrdate" => strtotime($item->get_date()), "mytitle" => $item->get_title(), "mylink" => $item->get_link(), "myGroup" => $feeditem["FeedName"], "mydesc" => $item->get_content(), "myimage" => $mediaImage, "mycatid" => $feeditem["FeedCatID"]);
                 unset($mediaImage);
             }
         } else {
             for ($i = 0; $i <= $maxposts - 1; $i++) {
                 $item = $feed->get_item($i);
                 if (empty($item)) {
                     continue;
                 }
                 if (include_post($feeditem["FeedCatID"], $item->get_content(), $item->get_title()) == 0) {
                     continue;
                 }
                 // FILTER
                 if ($enclosure = $item->get_enclosure()) {
                     if (!IS_NULL($item->get_enclosure()->get_thumbnail())) {
                         $mediaImage = $item->get_enclosure()->get_thumbnail();
                     } else {
                         if (!IS_NULL($item->get_enclosure()->get_link())) {
                             $mediaImage = $item->get_enclosure()->get_link();
                         }
                     }
                 }
                 $myarray[] = array("mystrdate" => strtotime($item->get_date()), "mytitle" => $item->get_title(), "mylink" => $item->get_link(), "myGroup" => $feeditem["FeedName"], "mydesc" => $item->get_content(), "myimage" => $mediaImage, "mycatid" => $feeditem["FeedCatID"]);
                 unset($mediaImage);
             }
         }
     }
     if (!isset($myarray) || empty($myarray)) {
         return _e("There is a problem with the feeds you entered.  Go to our <a href='http://www.allenweiss.com/wp_plugin'>support page</a> and we'll help you diagnose the problem.", 'wp-rss-multi-importer');
         exit;
     }
     //$myarrary sorted by mystrdate
     foreach ($myarray as $key => $row) {
         $dates[$key] = $row["mystrdate"];
     }
     //SORT, DEPENDING ON SETTINGS
     if ($sortDir == 1) {
         array_multisort($dates, SORT_ASC, $myarray);
     } else {
         array_multisort($dates, SORT_DESC, $myarray);
     }
     // HOW THE LINK OPENS
     global $isMobileDevice;
     if (isset($isMobileDevice) && $isMobileDevice == 1) {
         //open mobile device windows in new tab
         $targetWindow = 2;
     }
     if ($targetwindow == 0) {
         $openWindow = 'class="colorbox"';
     } elseif ($targetwindow == 1) {
         $openWindow = 'target=_self';
     } else {
         $openWindow = 'target=_blank';
     }
     $total = -1;
     if ($simplelist == 1) {
         echo '<ul class="wprssmi_widget_list">';
         foreach ($myarray as $items) {
             $total = $total + 1;
             if ($count > 0 && $total >= $count) {
                 break;
             }
             echo '<li class="title"><a ' . $openWindow . ' href="' . $items["mylink"] . '" ' . ($noFollow == 1 ? 'rel=nofollow' : '') . '>' . $items["mytitle"] . '</a>';
             if (!empty($items["mystrdate"]) && $showdate == 1) {
                 echo '<span class="date">' . date_i18n("D, M d, Y", $items["mystrdate"]) . '</span>';
             }
             echo '</li>';
         }
         //  don't mess with this php code
         echo '</ul>';
     } else {
         echo ' <div class="news-wrapper" id="newsticker" style="10px;background-color:' . $background . ';">';
         echo '	<div class="news-contents">';
         foreach ($myarray as $items) {
             $total = $total + 1;
             if ($count > 0 && $total >= $count) {
                 break;
             }
             echo '<div style="top: 101px;margin-left:5px;" class="news">';
             echo '<p class="widget-rss-output" style="margin-right:5px">';
             if ($showimage == 1 && $addmotion != 1) {
                 echo showexcerpt($items["mydesc"], 0, $openWindow, 0, $items["mylink"], 1, "left", 0, $items["myimage"], $items["mycatid"]);
             }
             echo '<a ' . $openWindow . ' href="' . $items["mylink"] . '">' . $items["mytitle"] . '</a><br />';
             if ($showdesc == 1 && $addmotion != 1) {
                 $desc = esc_attr(strip_tags(@html_entity_decode($items["mydesc"], ENT_QUOTES, get_option('blog_charset'))));
                 $desc = str_replace('[...]', '', $desc);
                 $words = explode(" ", trim($desc));
                 $desc = implode(" ", array_splice($words, 0, $descNum));
                 $desc .= ' <a ' . $openWindow . ' href="' . $items["mylink"] . '">[&hellip;]</a>';
                 echo $desc . '<br/>';
             }
             if (!empty($items["mystrdate"]) && $showdate == 1) {
                 echo date_i18n("D, M d, Y", $items["mystrdate"]) . '<br />';
             }
             if (!empty($items["myGroup"]) && $showsource == 1) {
                 echo '<span style="font-style:italic;">' . $attribution . '' . $items["myGroup"] . '</span>';
             }
             echo '</p>';
             echo '</div>';
         }
         echo '</div></div>';
     }
     echo $after_widget;
 }
示例#13
0
     $err_array = array();
     $stmt2->execute();
     if (count($err_array) != 0) {
         throw new Exception("Error executing query - PDO::errorInfo(): " . print_r($stmt2->errorInfo(), true));
     }
     //fetch
     $row = $stmt2->fetch(PDO::FETCH_ASSOC);
     if (!$row) {
         throw new Exception("Error fetching data - PDO::errorInfo(): " . print_r($conn2->errorInfo(), true));
     }
     //check if already responded
     if ($who == 'biz_mgr' && !IS_NULL($row['date_of_response'])) {
         Utilities::msg_alert("You have already responded to this request.", "");
         $disabled = 'disabled';
     }
     if ($who == 'admin' && !IS_NULL($row['date_admin_submit'])) {
         Utilities::msg_alert("This request was already processed and the notices were sent out.", "");
         $disabled = 'disabled';
     }
 }
 //end who = biz_mgr/admin
 // ==================================================================================
 // MYSQL DATABASE CONNECTION - facil_csc (stores dept,clerk,biz_mgr lists)
 // ==================================================================================
 $connector = new DBConnection('facil');
 $conn = $connector->openConnection();
 // ==================================================================================
 // BOOTSTRAP PAGE TOP WITH NAVIGATION
 // ==================================================================================
 $page_view = new PageView();
 $page_view->createHTMLHead('Additional Pay Form::Facilities and Services:: University of Rochester');
示例#14
0
/**
 *
 * @param array $params
 * @param array $values
 * @param string $extends entity that this custom field extends (e.g. contribution, event, contact)
 * @param string $entityId ID of entity per $extends
 */
function _civicrm_api3_custom_format_params($params, &$values, $extends, $entityId = NULL)
{
    $values['custom'] = array();
    foreach ($params as $key => $value) {
        list($customFieldID, $customValueID) = CRM_Core_BAO_CustomField::getKeyID($key, TRUE);
        if ($customFieldID && !IS_NULL($value)) {
            CRM_Core_BAO_CustomField::formatCustomField($customFieldID, $values['custom'], $value, $extends, $customValueID, $entityId, FALSE, FALSE);
        }
    }
}
示例#15
0
/**
 * Fetches feed items for a specific feed
 */
function rssmi_fetch_feed_items($post_id, $feed_total_fetch = 10)
{
    $rssmi_global_options = get_option('rssmi_global_options');
    $noDirectFetch = isset($rssmi_global_options['noForcedFeed']) ? $rssmi_global_options['noForcedFeed'] : 0;
    $timeout = 20;
    $forceFeed = true;
    $showVideo = 1;
    global $wpdb;
    $didUpdate = 0;
    $post = get_post($post_id);
    if ($post->post_type == 'rssmi_feed' && $post->post_status == 'publish') {
        // Get the feed source
        $query = "SELECT ID, post_date, post_title, guid FROM {$wpdb->posts} WHERE post_status = 'publish' AND post_type = 'rssmi_feed' AND ID = {$post_id}";
        $feed_source = $wpdb->get_results($query);
        if (!empty($feed_source)) {
            $feed_ID = $post_id;
            $feed_url = get_post_meta($post_id, 'rssmi_url', true);
            $feed_cat = get_post_meta($post_id, 'rssmi_cat', true);
            $rssmi_user = get_post_meta($post_id, 'rssmi_user', true);
            $rssmi_title = get_the_title($post_id);
            if (!empty($feed_url)) {
                $url = esc_url_raw(strip_tags($feed_url));
                if ($noDirectFetch == 1) {
                    $feed = fetch_feed($url);
                } else {
                    $feed = wp_rss_fetchFeed($url, $timeout, $forceFeed, $showVideo);
                }
                if (!is_wp_error($feed)) {
                    // Limit  to 10 unless fetched from feed page.
                    $maxitems = $feed->get_item_quantity($feed_total_fetch);
                    // Build an array of all the items, starting with element 0 (first element).
                    $items = $feed->get_items(0, $maxitems);
                } else {
                    return;
                }
            }
            if (!empty($items)) {
                foreach ($items as $item) {
                    $cleanLink = strip_qs_var_match('news.google.com', $item->get_permalink(), 'url');
                    // clean all parameters except the url from links from Google News
                    $mypostids = $wpdb->get_results("select post_id from {$wpdb->postmeta} where meta_key = 'rssmi_item_permalink' and meta_value like '%" . $cleanLink . "%'");
                    //	$myposttitle=$wpdb->get_results("select post_title from $wpdb->posts where post_type='rssmi_feed_item' and post_title like '%".mysql_real_escape_string(trim($item->get_title()))."%'");
                    if (empty($mypostids) && $mypostids !== false) {
                        $didUpdate = 1;
                        if (IS_NULL($item->get_date())) {
                            $post_date = $rightNow;
                            $unix_date = strtotime($rightNow);
                        } else {
                            $post_date = get_date_from_gmt($item->get_date('Y-m-d H:i:s'));
                            $unix_date = $item->get_date('U');
                        }
                        if (rssmi_is_not_fresh($post_date) == 1) {
                            continue;
                        }
                        //filter for days old
                        // Create post object
                        $feed_item = array('post_title' => html_entity_decode($item->get_title()), 'post_content' => '', 'post_date' => $post_date, 'post_status' => 'publish', 'post_type' => 'rssmi_feed_item');
                        remove_action('save_post', 'rssmi_save_custom_fields');
                        $inserted_ID = wp_insert_post($feed_item);
                        add_action('save_post', 'rssmi_save_custom_fields');
                        if ($feedAuthor = $item->get_author()) {
                            $feedAuthor = $item->get_author()->get_name();
                        }
                        if ($enclosure = $item->get_enclosure()) {
                            $FeedMediaID = get_post_meta($feed_ID, 'rssmi_mediaID', true);
                            // GET THE CHOSEN MEDIA IMAGE FROM THE ENCLOSURE
                            $useMediaImage = $FeedMediaID > 0 ? 1 : 0;
                            $inum = isset($FeedMediaID) ? $FeedMediaID - 1 : 0;
                            if (!IS_NULL($item->get_enclosure()->get_thumbnails())) {
                                $mediaImageArray = $item->get_enclosure()->get_thumbnails();
                                $mediaImage = $mediaImageArray[$inum];
                            } else {
                                if (!IS_NULL($item->get_enclosure()->get_link())) {
                                    $mediaImage = $item->get_enclosure()->get_link();
                                }
                            }
                        }
                        if (!IS_Null($item->get_categories())) {
                            $categoryTerms = "";
                            foreach ($item->get_categories() as $category) {
                                $categoryTerms .= $category->get_term() . ', ';
                            }
                            $postCategories = rtrim($categoryTerms, ', ');
                        } else {
                            $postCategories = Null;
                        }
                        if ($itemAuthor = $item->get_author()) {
                            $itemAuthor = !IS_NULL($item->get_author()->get_name()) ? $item->get_author()->get_name() : $item->get_author()->get_email();
                            $itemAuthor = html_entity_decode($itemAuthor, ENT_QUOTES, 'UTF-8');
                        } else {
                            if (!IS_NULL($feedAuthor)) {
                                $itemAuthor = $feedAuthor;
                                $itemAuthor = html_entity_decode($itemAuthor, ENT_QUOTES, 'UTF-8');
                            }
                        }
                        $myarray[] = array("mystrdate" => strtotime($post_date), "mytitle" => html_entity_decode($item->get_title()), "mylink" => $item->get_permalink(), "mydesc" => $item->get_content(), "myimage" => $mediaImage, "myAuthor" => $itemAuthor, "itemcategory" => $postCategories, "mycatid" => $feed_cat, "myGroup" => $rssmi_title, "feedID" => $feed_ID, "useMediaImage" => $useMediaImage);
                        unset($mediaImage);
                        unset($itemAuthor);
                        unset($useMediaImage);
                        unset($post_date);
                        unset($rssmi_title);
                        unset($feed_cat);
                        update_post_meta($inserted_ID, 'rssmi_item_permalink', $cleanLink);
                        update_post_meta($inserted_ID, 'rssmi_item_description', $myarray);
                        update_post_meta($inserted_ID, 'rssmi_item_date', $unix_date);
                        // Save as Unix timestamp format
                        update_post_meta($inserted_ID, 'rssmi_item_feed_id', $post_id);
                        unset($myarray);
                        unset($unix_date);
                        unset($cleanLink);
                    }
                    //end if
                }
                //end foreach
            }
            // end if
        }
        // end if not empty
        if ($didUpdate == 1) {
            update_post_meta($feed_ID, 'rssmi_last_update', time());
        }
    }
    // end if
}
示例#16
0
 public function actionCrearconcodpro()
 {
     $model = new Lugares();
     if (isset($_GET['codpro'])) {
         $codigoprov = MiFactoria::cleanInput($_GET['codpro']);
         $registro = Clipro::model()->findBypK($codigoprov);
         if (IS_NULL($registro)) {
             throw new CHttpException(500, __CLASS__ . '' . __FUNCTION__ . '   ' . __LINE__ . '    El codigo de proveedor Especificado no existe');
         }
         if (count($registro->direcciones) == 0) {
             Yii::app()->user->setFlash('error', " Error :  El proveedor indicado no cuenta con direcciones fiscales, debe de crear una por lo menos ");
         }
         if (isset($_POST['Lugares'])) {
             $model->attributes = $_POST['Lugares'];
             $model->codpro = $codigoprov;
             if ($model->save()) {
                 Yii::app()->user->setFlash('success', " Se ha creado el Lugar  " . $model->deslugar);
             } else {
                 Yii::app()->user->setFlash('error', " Error :  ");
             }
             $this->redirect(array('admin'));
         }
         $this->render('_form_con_codpro', array('model' => $model, 'codpro' => $codigoprov, 'modeloclipro' => $registro));
     } else {
         throw new CHttpException(500, 'El codigo de proveedor no ha sido espeificado');
     }
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
 }
示例#17
0
defined('_VALID_MVH') or die('Direct Access to this location is not allowed.');
/*** CLASS FOR SITE SETUP ***/
require_once $GLOBALS['dr'] . "classes/setup/setup.php";
$setup = new Setup();
require_once $GLOBALS['dr'] . "include/functions/design/curve_boxes.php";
/* SESSION ID */
if (isset($_SESSION['sid'])) {
    $sid = $_SESSION['sid'];
    $user_id = $_SESSION['user_id'];
    require_once $GLOBALS['dr'] . "classes/user/user_info.php";
    require_once $GLOBALS['dr'] . "include/functions/date_time/set_timezone.php";
    $ui = new UserInfo($user_id);
    $workspace_id = $ui->WorkspaceID();
    $teamspace_id = $ui->TeamspaceID();
    //echo $teamspace_id;
    //if (IS_NULL($teamspace_id)) { echo "NULL teamspace"; } else { echo "Not null teamspace"; }
    SetTimezone($ui->Timezone());
    if (IS_NULL($ui->TeamspaceID())) {
        $teamspace_sql = "IS NULL";
        $teamspace_id = "NULL";
    } else {
        $teamspace_sql = "= {$teamspace_id}";
    }
}
/* CREATE AN INSTANCE OF THE WORKSPACE */
if (isset($_SESSION['sid']) && IS_NUMERIC($ui->WorkspaceID())) {
    require_once $GLOBALS['dr'] . "modules/workspace/classes/workspace_user_info.php";
    $wui = new WorkspaceUserInfo($_SESSION['user_id'], $ui->WorkspaceID());
}
/* JPGRAPH SETTINGS */
$jpgraph_font_dir = $dr . "include/jpgraph/fonts/";
示例#18
0
/**
 *
 * @param array $params
 * @param array $values
 * @param string $extends entity that this custom field extends (e.g. contribution, event, contact)
 * @param string $entityId ID of entity per $extends
 */
function _civicrm_api3_custom_format_params($params, &$values, $extends, $entityId = NULL)
{
    $values['custom'] = array();
    $checkCheckBoxField = FALSE;
    $entity = $extends;
    if (in_array($extends, array('Household', 'Individual', 'Organization'))) {
        $entity = 'Contact';
    }
    $fields = civicrm_api($entity, 'getfields', array('version' => 3, 'action' => 'create'));
    if (!$fields['is_error']) {
        // not sure if fields could be error - maybe change to using civicrm_api3 wrapper later - this is conservative
        $fields = $fields['values'];
        $checkCheckBoxField = TRUE;
    }
    foreach ($params as $key => $value) {
        list($customFieldID, $customValueID) = CRM_Core_BAO_CustomField::getKeyID($key, TRUE);
        if ($customFieldID && !IS_NULL($value)) {
            if ($checkCheckBoxField && !empty($fields['custom_' . $customFieldID]) && $fields['custom_' . $customFieldID]['html_type'] == 'CheckBox') {
                formatCheckBoxField($value, 'custom_' . $customFieldID, $entity);
            }
            CRM_Core_BAO_CustomField::formatCustomField($customFieldID, $values['custom'], $value, $extends, $customValueID, $entityId, FALSE, FALSE);
        }
    }
}
 // ======================================================================================= //
 $reqID = filter_input(INPUT_POST, 'id', FILTER_SANITIZE_NUMBER_INT);
 $response = filter_input(INPUT_POST, 'response', FILTER_SANITIZE_STRING);
 // ========================================================================================
 // SPAM CHECK
 // ========================================================================================
 if ($_POST['permanganese'] == '' || !isset($_POST['permanganese'])) {
     $pdo = $connector->set_connection('facil2_pdo');
     // ========================================================================================
     // CHECK: HAS ALREADY RESPONDED?
     // ========================================================================================
     $sql1 = "SELECT date_of_response \n\t\tFROM request \n\t\tWHERE request_id = {$reqID}";
     $stmt1 = $pdo->query($sql1);
     $row1 = $stmt1->fetch(PDO::FETCH_ASSOC);
     $date_of_response = $row1['date_of_response'];
     if (!IS_NULL($row['date_of_response'])) {
         throw new Exception("This request was already processed and the notices were sent out.");
     }
     // ========================================================================================
     // UPDATE RECORD IN DATABASE
     // ========================================================================================
     $sql2 = "UPDATE request SET `date_of_response` = CURDATE(), `response` = '{$response}' WHERE request_id = {$reqID}";
     $stmt2 = $pdo->query($sql2);
     if (!$stmt2) {
         throw new Exception("Error getting statement handle - PDO::errorInfo(): " . print_r($pdo->errorInfo(), true));
     }
     $stmt2->execute();
     if ($stmt2->error) {
         throw new Exception($stmt2->errno . ' ' . $stmt2->error . '<br/>There was an error processing your response.  Please click the back button and try again.');
         exit;
     }
示例#20
0

<?php 
$modelodetalle = Maestrodetalle::model()->findByPk(array('codart' => $codigo, 'codcentro' => $centro, 'codal' => $codal));
$habilitado = 'disabled';
if (!IS_NULL($modelodetalle)) {
    ?>

<div class="wide form">
<div class="row">
		<?php 
    echo CHtml::label($modelodetalle->getAttributeLabel('codcentro'), 'fgr258trtr');
    ?>
		<?php 
    echo CHtml::textField('', $modelodetalle->codcentro, array('size' => 4, 'maxlength' => 4, 'disabled' => 'disabled'));
    ?>

	</div>


	<div class="row">
        <?php 
    echo CHtml::label($modelodetalle->getAttributeLabel('codal'), 'fgrtrt25r');
    ?>
        <?php 
    echo CHtml::textField('', $modelodetalle->codal, array('size' => 3, 'maxlength' => 3, 'disabled' => 'disabled'));
    ?>

	</div>

    <div class="row">