예제 #1
0
 public static function ExibirRSS()
 {
     $feed = 'http://olhardigital.uol.com.br/rss/ultimas_noticias.php';
     ini_set('allow_url_fopen', true);
     $fp = fopen($feed, 'r');
     $xml = '';
     while (!feof($fp)) {
         $xml .= fread($fp, 128);
     }
     fclose($fp);
     function untag($string, $tag)
     {
         $tmpval = array();
         $preg = "|<{$tag}>(.*?)</{$tag}>|s";
         preg_match_all($preg, $string, $tags);
         foreach ($tags[1] as $tmpcont) {
             $tmpval[] = $tmpcont;
         }
         return $tmpval;
     }
     $items = untag($xml, 'item');
     $html = '<p>';
     foreach ($items as $item) {
         $title = untag($item, 'title');
         $title[0] = str_replace('<', "", $title[0]);
         $title[0] = str_replace('>', "", $title[0]);
         $title[0] = str_replace('![CDATA[', "", $title[0]);
         $title[0] = str_replace(']]', "", $title[0]);
         $title[0] = mb_convert_encoding($title[0], 'utf8');
         $link = untag($item, 'link');
         $html .= '<a href="' . $link[0] . '" target="_blank">' . $title[0] . "</a><br />\n";
     }
     $html .= '</p>';
     echo $html;
 }
예제 #2
0
 }
 if (isset($dbname) and isset($mtable) and isset($pixidname) and isset($pixid) and isset($del)) {
     echo "hello";
     mysql_select_db($dbname) or die("Не могу выбрать базу данных");
     mysql_query("delete from {$mtable} where {$pixidname}='{$pixid}'");
     echo "<head><meta http-equiv=\"refresh\" content=\"0;URL={$PHP_SELF}?dbname={$dbname}&table={$mtable}&db_server={$db_server}&db_user={$db_user}&db_pass={$db_pass}\"></head>";
 }
 if (isset($dbname) and isset($mtable) and isset($var) and isset($pixidname) and isset($pixid) and isset($textofmysql)) {
     mysql_select_db($dbname) or die("Не могу выбрать базу данных");
     mysql_query("update {$mtable} set {$var}='{$textofmysql}' where {$pixidname}={$pixid}");
 }
 if (isset($dbname) and isset($mtable) and isset($var) and isset($pixidname) and isset($pixid)) {
     mysql_select_db($dbname) or die("Не могу выбрать базу данных");
     $re = mysql_query("select {$var} from {$mtable} where {$pixidname}='{$pixid}'");
     $res = mysql_fetch_array($re);
     $text = untag($res[$var]);
     echo "\n<form  action=\"{$PHP_SELF}\" method=\"POST\">\n<textarea name=\"textofmysql\" rows=\"25\" cols=\"60\" wrap=\"OFF\">{$text}</textarea>\n<input type=\"hidden\" name=\"dbname\" value=\"{$dbname}\" >\n<input type=\"hidden\" name=\"mtable\" value=\"{$mtable}\" >\n<input type=\"hidden\" name=\"var\" value=\"{$var}\" >\n<input type=\"hidden\" name=\"pixidname\" value=\"{$pixidname}\" >\n<input type=\"hidden\" name=\"pixid\" value=\"{$pixid}\" >\n<input type=\"hidden\" name=\"db_server\" value=\"{$db_server}\" >\n<input type=\"hidden\" name=\"db_user\" value=\"{$db_user}\" >\n<input type=\"hidden\" name=\"db_pass\" value=\"{$db_pass}\" >\n<br><input type=\"submit\"  value=\"            Изменить            \" >\n</form>\n<a href={$PHP_SELF}?dbname={$dbname}&table={$mtable}&db_server={$db_server}&db_user={$db_user}&db_pass={$db_pass}>Вернуться к списку</a>\n";
 }
 if (isset($showdb) && empty($showtables)) {
     $re = mysql_query("show databases");
     echo "<table width='505' border='1' align='center' cellpadding='0' cellspacing='0' bordercolor='#CCCCFF' bgcolor='#FFFFFF'>";
     echo "<tr><td><center><div style='background-color:#CCCCFF'><span class='style5'>Список доступных БД:</span></div></center></td></tr>";
     while ($res = mysql_fetch_array($re)) {
         echo "<tr><td><center><a href={$PHP_SELF}?showtables={$res['0']}&db_server={$db_server}&db_user={$db_user}&db_pass={$db_pass}>{$res['0']}</a></center></td></tr>";
     }
     echo "</table>";
 }
 if (isset($showtables) and !empty($showtables)) {
     if (isset($xlimit)) {
         $_SESSION[limit] = $xlimit;
         if (isset($xlenth)) {
     break;
 case "NOTE":
     validateReceivedSMS($sms->Number(), count($args), 2, _('with bike number/stand name and problem description:') . " NOTE 47 " . _('Flat tire on front wheel'));
     note($sms->Number(), $args[1], trim(urldecode($sms->Text())));
     break;
 case "TAG":
     validateReceivedSMS($sms->Number(), count($args), 2, _('with stand name and problem description:') . " TAG MAINSQUARE " . _('vandalism'));
     tag($sms->Number(), $args[1], trim(urldecode($sms->Text())));
     break;
 case "DELNOTE":
     validateReceivedSMS($sms->Number(), count($args), 1, _('with bike number and optional pattern. All messages or notes matching pattern will be deleted:') . " NOTE 47 wheel");
     delnote($sms->Number(), $args[1], trim(urldecode($sms->Text())));
     break;
 case "UNTAG":
     validateReceivedSMS($sms->Number(), count($args), 1, _('with stand name and optional pattern. All notes matching pattern will be deleted for all bikes on that stand:') . " UNTAG SAFKO1 pohoda");
     untag($sms->Number(), $args[1], trim(urldecode($sms->Text())));
     break;
 case "LIST":
     //checkUserPrivileges($sms->Number()); //allowed for all users as agreed
     checkUserPrivileges($sms->Number());
     validateReceivedSMS($sms->Number(), count($args), 2, _('with stand name:') . " LIST RACKO");
     listBikes($sms->Number(), $args[1]);
     break;
 case "ADD":
     checkUserPrivileges($sms->Number());
     validateReceivedSMS($sms->Number(), count($args), 3, _('with email, phone, fullname:') . " ADD king@earth.com 0901456789 Martin Luther King Jr.");
     add($sms->Number(), $args[1], $args[2], trim(urldecode($sms->Text())));
     break;
 case "REVERT":
     checkUserPrivileges($sms->Number());
     validateReceivedSMS($sms->Number(), count($args), 2, _('with bike number:') . " REVERT 47");
예제 #4
0
$xml = new SimpleXMLElement(tidy_repair_string(file_get_contents('php://stdin'), $config, 'utf8'));
foreach ($xml->xpath('//div[@class="brewery"]/ul[@class="vcard simple"]') as $block) {
    $name = filter((string) $block->xpath('li[@class="name"]')[0]);
    $addrBlock = $block->xpath('li[@class="address"]');
    if (empty($addrBlock)) {
        $address1 = '';
        $address2 = filter((string) $block->xpath('li[@class="name"]/following-sibling::li')[0]);
    } else {
        $address1 = filter((string) $addrBlock[0]);
        $address2 = filter((string) $block->xpath('li[@class="address"]/following-sibling::li')[0]);
    }
    if (preg_match('/^([^,]+)\\s*,\\s*([A-Z]{2})\\s+([\\d-]+)/', $address2, $match)) {
        $address2 = '';
        $city = $match[1];
        $state = $match[2];
        $zip = $match[3];
    } else {
        $city = '';
        $state = '';
        $zip = '';
    }
    $phoneBlock = $block->xpath('li[@class="telephone"]');
    $phone = empty($phoneBlock) ? '' : phone(untag(filter((string) $phoneBlock[0])));
    $typeBlock = $block->xpath('li[@class="brewery_type"]');
    $type = empty($typeBlock) ? '' : strtolower(untag(filter((string) $typeBlock[0])));
    $urlBlock = $block->xpath('li[@class="url"]/a');
    $url = empty($urlBlock) ? '' : strtolower(filter((string) $urlBlock[0]->attributes()->href));
    $data = ['name' => $name, 'address1' => $address1, 'address2' => $address2, 'city' => $city, 'state' => $state, 'zip' => $zip, 'phone' => $phone, 'type' => $type, 'url' => $url];
    fputcsv($fp, $data);
}
fclose($fp);
예제 #5
0
					$preg = "|<$tag>(.*?)</$tag>|s";
					preg_match_all($preg, $string, $tags);
					foreach ($tags[1] as $tmpcont){
						$tmpval[] = $tmpcont;
					}
					return $tmpval;
				}
				
				$items = untag($xml, 'item');
				
				$html = '<p>';
				foreach ($items as $item) {
					
					$title = untag($item, 'title');
					$link = untag($item, 'link');
					$data = untag($item,'pubDate');
					
					$html .= '<font face="Tahoma" size="2" color="#CB281E" style="margin-left:8px;">'.date('d/m/Y H:i',strtotime($data[0])).' <a href="' . $link[0] . '" target="_blank">' . $title[0] ."</a></font></b><br/><br>\n";
				}
				$html .= '</p>';
				
				echo utf8_encode($html);
			?>


        </div>

        <br /><br /><br />
    </div>
</div>
 	
예제 #6
0
/**
 * smarty template function
 * name: rss fetch resource
 * package: InSpire CMS
 * author: Kulikov Alexey <alex [at] inses [dot] ru
 * 
 * params:
 *   mandatory: 	'source' rss source (string) 
 *   optional:		'items' items to fetch (int)				default: 10
 * 					'var' smarty variable name (string) 		default: rss
 * 					'cache' whether to cache the result	(bool)	default: true
 * 					'cachelt' lifetime of cache in seconds (int)default: 86400 seconds or one day
 * @version 1.2
 * @copyright 2004, InSES Corporation and Alexey Kulikov
 * 
 * @note 	make sure you have a template named empty.txt that contains nothing
 * 			but {$someData} in it. This template will be used to cache RSS feeds
 * 			locally. Also note that caching can be disabled, but this makes
 * 			syndication with slow servers rather inefficient
 **/
function smarty_function_rss($params, &$smarty)
{
    //error check
    if (empty($params['source'])) {
        $smarty->trigger_error("rss: missing 'source' parameter");
        return;
    }
    //check for optional variables
    //smarty variable name
    if (!empty($params['var'])) {
        $variableName = (string) $params['var'];
    } else {
        $variableName = "rss";
    }
    //items to fetch
    if (!empty($params['items'])) {
        $itemsToGet = (int) $params['items'];
    } else {
        $itemsToGet = 10;
    }
    //cache feed?
    if (!empty($params['cache'])) {
        if ($params['cache'] == 'false') {
            $cache = false;
        } else {
            $cache = true;
        }
    } else {
        $cache = true;
    }
    //cache lifetime
    if (!empty($params['cachelt'])) {
        $lifeTime = (int) $params['cachelt'];
    } else {
        $lifeTime = 86400;
    }
    ## GET RSS CONTENT ###################################
    #
    //set cache status
    //$oldCacheStatus = $smarty->caching;
    //$oldCacheLifetime = $smarty->cache_lifetime;
    //$smarty->caching = $cache;
    //$smarty->cache_lifetime = $lifeTime;
    //$cacheID = "rss|".md5($params['source']);
    //was the feed cached?
    //if(!$smarty->is_cached('empty.txt',$cacheID)){ //no
    //set ini setting to allow to read remote files
    //if(@ini_get("allow_url_fopen") == 0) {
    //	@ini_set("allow_url_fopen", 1);
    //}
    //fetch file
    if ($file = fopen($params['source'], "r")) {
        $content = '';
        while (!feof($file)) {
            $content .= fread($file, 8192);
        }
        fclose($file);
        //}else{
        //	return;
    }
    //$smarty->assign("someData",$content);
    //}
    //get content from smarty
    //$content = $smarty->fetch('empty.txt',$cacheID);
    //reset cache status
    //$smarty->caching = $oldCacheStatus;
    //$smarty->cache_lifetime = $oldCacheLifetime;
    #
    ## /END GET RSS CONTENT ##############################
    //process content
    $items = explode("<item", $content);
    unset($items[0]);
    //drop first reference
    $data = array();
    $tempArray = array();
    $counter = 0;
    //print "<hr>";
    //print htmlentities( print_r($items,1) );
    //print "<hr>";
    $search = array("<![CDATA[", "]]>");
    $replace = array("", "");
    foreach ($items as $item) {
        $tempArray['title'] = untag($item, "title");
        $tempArray['description'] = str_replace($search, $replace, untag($item, "description"));
        $tempArray['link'] = untag($item, "link");
        $data[] = $tempArray;
        //increment counter
        $counter++;
        if ($counter >= $itemsToGet) {
            break;
        }
    }
    //give data to smarty and terminate
    $smarty->assign($variableName, $data);
    return;
}
예제 #7
0
function checkversion($checkversion, $width = '200', $border = "dashed", $method = CHECK_METHOD, $dev = false, $version_server = CHECK_SERVER, $project_shortcut = CHECK_PROJECT_SC)
{
    global $locale;
    //Set allow_urlfopen to true
    ini_set('allow_url_fopen', true);
    //URL Prefix
    $urlprefix = !strstr($version_server, "http://") ? "http://" : "";
    //Compelte URL to the rss feed
    $vf_url = "{$urlprefix}{$version_server}/infusions/version_updater/feed.php?project_sc={$project_shortcut}&old_v={$checkversion}" . ($dev == true ? "&dev" : "");
    //Download URL for new versions
    $vs_down = "{$urlprefix}{$version_server}/infusions/version_updater/download_updater.php?ps={$project_shortcut}&amp;version={$checkversion}" . ($dev == true ? "&amp;dev" : "");
    if (url_exists($vf_url)) {
        if (ini_get('allow_url_fopen') == '1') {
            $feed = $vf_url;
            //Open conection to the feed
            $fp = fopen($feed, 'r');
            $xml = '';
            while (!feof($fp)) {
                $xml .= fread($fp, 128);
            }
            fclose($fp);
            //Connection closed and content stored
            //Render and display feed
            $items = untag($xml, 'item');
            $limit = 1;
            $count = 0;
            foreach ($items as $item) {
                if ($count == $limit) {
                    break;
                } else {
                    $count++;
                }
                $version = untag($item, 'title');
                $description = untag($item, 'description');
            }
            //Render og display done
            if (!empty($version)) {
                //If a newer version is available
                $return = "<table width='{$width}'>\n<tr>";
                $return .= "<td align='left' valign='top' style='border: {$border}'>\n";
                $return .= "<a href='{$vs_down}' target='_blank'>";
                $return .= "<img src='" . CHECKER_IMAGES . "download_update.png' align='right' title='" . $locale['vup102'] . "' alt='" . $locale['vup102'] . "' border='0' />\n";
                $return .= "</a>\n";
                $return .= "<img src='" . CHECKER_IMAGES . "version_old.gif' title='" . $locale['vup101'] . "' alt='" . $locale['vup101'] . "' border='0px' /><br />\n";
                $return .= "<strong>" . $locale['vup104'] . "</strong> - v" . $version[0] . "\n";
                if ($method == "rss") {
                    $return .= "<br />" . $description[0] . "\n";
                }
                $return .= "</td>\n";
                $return .= "</tr>\n</table>\n";
                return $return;
            } else {
                //Else if you have the lates version
                return "<img src='" . CHECKER_IMAGES . "version.gif' title='" . $locale['vup100'] . "' alt='' />";
            }
        } else {
            //allow_url_fopen failture
            return $locale['vup105'] . "<br />" . $locale['vup106'] . " <a href='" . SUPPORT_SITE_URL . "' target='_blank'>" . SUPPORT_SITE_NAME . "</a>.";
        }
    } else {
        //Else if the url to the version file dos not exist
        return $locale['vup103'] . "<a href='" . SUPPORT_SITE_URL . "' target='_BLANK'>" . SUPPORT_SITE_NAME . "</a>.";
    }
}