コード例 #1
0
         <div class="listing-pagination">
           <h5 class="title pull-left"><?php 
_e('Available Rooms', 'bookingwp');
?>
</h5>
         </div>
         <?php 
wp_reset_query();
get_accommodations();
if (have_posts()) {
    while (have_posts()) {
        the_post();
        $price = get_post_meta($post->ID, 'min_price', true);
        ?>
    <?php 
        if (is_available($post->ID, $_GET['checkin'], $_GET['checkout'])) {
            ?>
         <!-- room list -->
         <div class="listing-room-list">
           <?php 
            $attachments = OneGallery($post->ID);
            if (count($attachments > 1)) {
                ?>
           <div class="thumbnail">
             <div class="thumbnail-slider">
               <?php 
                foreach ($attachments as $attachment) {
                    $img = wp_get_attachment_image_src($attachment->ID, 'thumbnail', false);
                    ?>
               <img src="<?php 
                    echo $img[0];
コード例 #2
0
ファイル: linkcheck.php プロジェクト: AmsterdamData/CKAN
<body>
<h1>URLS met een andere response-code dan 200</h1>
<p>Let op: indien niet lokaal uitgevoerd, kunnen bestanden op amsterdamopendata.nl onterecht als 404 gezien worden.</p>
    <table>
        <thead>
            <tr><th>status</th><th>url</th><th>dataset</th><th>beschijving url</th></tr>
        </thead>
        <tbody>
    <?php 
$count = 0;
$ckan = new CKAN();
$ckan->getDatasets();
foreach ($ckan->datasets as $key => $set) {
    foreach ($set->res_url as $i => $url) {
        $count++;
        $code = is_available($url);
        if ($code != 200) {
            print "<TR><TD><a onClick='\$(\".row\").hide(); \$(\"#row" . $count . "\").show();'>&gt;</a></TD><TD>" . $code . "</TD><TD><a href='" . $url . "' target='_blank'>" . max_length($url, 60) . "</a></TD><TD>" . $set->name . "</TD><TD>" . $set->res_description[$i] . "</TR>";
            print "<TR id='row" . $count . "' class='row' style='display:none'><TD colspan = 5>";
            print "<form onSubmit='\$.post(\"setresource.php\", {name: \"" . $key . "\", res: " . $i . ", url: this.url" . $count . ".value, desc: this.desc" . $count . ".value}, function(data){\n                 \$(\"#feedback" . $count . "\").html(data);});return false; '>";
            print "URL: <input type='text' id='url" . $count . "' value='" . $url . "' SIZE=80><BR/>";
            print "DESC: <input type='text' id='desc" . $count . "' value='" . addslashes($set->res_description[$i]) . "' SIZE=80><BR/>";
            print "<input type='submit' value='Change'><br/>";
            print "</form>";
            print "<div id='feedback" . $count . "'></div>";
            print "</TD></TR>";
        }
    }
}
?>
  
コード例 #3
0
ファイル: products.php プロジェクト: keshavkatwe/Products
    $product_id = $content['productid'];
    $product_type = $content['producttype'];
    $udate = $content['udate'];
    if ($conn->query("insert into user_products (user_id, product_id, product_type, udate) values ({$user_id}, '{$product_id}', '{$product_type}', '{$udate}')")) {
        $response = array('success' => TRUE);
    } else {
        $response = array('success' => FALSE);
    }
    echo json_encode($response);
} else {
    if ($_GET['type'] == "get") {
        $sql = "SELECT * from user_products where user_id=" . $_GET['user_id'] . " order by uproduct_id desc";
        $result = $conn->query($sql);
        $products_array = array();
        while ($row = $result->fetch_assoc()) {
            $row['is_available'] = is_available($row['product_id'], $conn);
            $products_array[] = $row;
        }
        echo json_encode($products_array);
    } else {
        if ($_GET['type'] == "edit") {
            $uproduct_id = $_GET['uproduct_id'];
            $user_id = $content['userid'];
            $product_id = $content['productid'];
            $product_type = $content['producttype'];
            $udate = $content['udate'];
            if ($conn->query("update user_products set product_id = '{$product_id}', product_type = '{$product_type}', udate = '{$udate}' where uproduct_id={$uproduct_id}")) {
                $response = array('success' => TRUE);
            } else {
                $response = array('success' => FALSE);
            }
コード例 #4
0
ファイル: section_class.php プロジェクト: jackieramos/pnhs
<!DOCTYPE html>
<?php 
@session_start();
include_once "../db/db.php";
include "actions/class_functions.php";
include "actions/subject_functions.php";
//require "actions/sched_functions.php";
$msg = NULL;
if (isset($_POST['add'])) {
    $section = $_GET['section_id'];
    $subject = $_POST['subject'];
    $sy_id = get_active_sy();
    $teacher = $_POST['teacher'];
    if ($section) {
        if (does_yr_level_match($section, $subject)) {
            if (is_available($section, $subject, $teacher)) {
                if (!($msg = is_teacher_max($teacher, $subject))) {
                    //is_unit_maxed($lvl_id, 0, $subject_unit)
                    //$subject_unit = $_POST['subject_unit'];
                    mysql_query("INSERT INTO class_t VALUES('','{$section}', '{$sy_id}', '{$subject}',{$teacher})") or die(mysql_error());
                    mysql_query("COMMIT;");
                    //header("location: subjects.php?curriculum_code={$get_curriculum_code}");
                    $msg = "SUCCESS!";
                } else {
                    //$msg = "Units maxed out.";
                }
            } else {
                $msg = "Class Already Exists";
            }
        } else {
            $msg = "Year level does not match.";
コード例 #5
0
function curl_loadLink($url, $default_date, $default_description, $default_language, $default_title, $default_site_name)
{
    global $logService;
    global $error;
    global $ds;
    global $root;
    global $host;
    if (empty($approved)) {
        $approved = 0;
    }
    $parsed = parse_url($url);
    $host = $parsed['host'];
    if (!$root) {
        $root = $host;
    }
    $session = curl_init($url);
    // indicates that we want the response back rather than just returning a "TRUE" string
    curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($session, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($session, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($session, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($session, CURLOPT_HEADER, false);
    curl_setopt($session, CURLOPT_TIMEOUT, 60);
    curl_setopt($session, CURLOPT_ENCODING, "");
    //curl_setopt ($session, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.104 Safari/537.36");
    $header = array();
    $header[] = 'Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5';
    $header[] = 'Connection: keep-alive';
    $header[] = 'Keep-Alive: 300';
    /*$header[] = 'Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7';
    $header[] = 'Accept-Language: en-us,en;q=0.5';
     */
    //curl_setopt($session, CURLOPT_HTTPHEADER,$header)
    // execute GET and get the session backs
    $t = microtime(TRUE) * 1000000;
    $logService->log('TRACE LINK URL', 'CURL GET START', $url, '');
    $html = curl_exec($session);
    $logService->log('TRACE LINK URL', 'CURL GET STOP(' . number_format(microtime(TRUE) * 1000000 - $t) . 'mks)', '', '');
    curl_close($session);
    if (!$html) {
        $error = "FAILED TO LOAD document: " . $url;
        return false;
    }
    if (stripos($url, 'novayagazeta') === FALSE && stripos($url, 'sotnik') === FALSE && stripos($url, 'ej.ru') === FALSE && stripos($url, 'newtimes') === FALSE) {
        $html = @mb_convert_encoding($html, 'HTML-ENTITIES', 'utf-8');
    }
    $body = strip_html_tags($html);
    /*$file = fopen("body.html", "w") or die("Unable to open file!");
      fwrite($file, $body);
      fclose($file);*/
    $logService->log('TRACE ', 'Stripped html', $content, '');
    libxml_use_internal_errors(true);
    // Yeah if you are so worried about using @ with warnings
    $dom = new DomDocument();
    /*$st=mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8');
      if($dom->loadHTML($st)===FALSE){
          $error="FAILED TO PARSE document: ".$url;
          return false;
      }*/
    $encodingHint = '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">';
    if (stripos($html, 'Windows-1251') === FALSE && stripos($url, 'ej.ru') === FALSE) {
        $html = $encodingHint . $html;
    }
    if ($dom->loadHTML($html) === FALSE) {
        $error = "FAILED TO PARSE document: " . $url;
        return false;
    }
    $dom->preserveWhiteSpace = false;
    $updated_time = '';
    $modified_time = '';
    $image = '';
    $title = '';
    $link = '';
    $site_name = $root;
    $lang = '';
    $description = '';
    $twitter_image = '';
    $i = 0;
    $metas = $dom->getElementsByTagName('meta');
    $countMetas = sizeof($metas);
    $author = '';
    $locale = '';
    $sailthru_date = '';
    $dcterms_date = '';
    $basic_date = '';
    $basic_publish_date = '';
    //politico
    $date = '';
    $dcterms_created = '';
    $dcterms_modified = '';
    $noconvert = false;
    $noconvertPublished = false;
    $pdate = 0;
    $basic_description = '';
    $published_time = '';
    foreach ($metas as $tag) {
        // $logService->log('DEBUG','meta',var_log($tag),'crawler');
        $property = $tag->getAttribute('property');
        $name = $tag->getAttribute('name');
        $content = $tag->getAttribute('content');
        $http_equiv = $tag->getAttribute('http-equiv');
        //$logService->log('TRACE LINK ','metas',var_log($property,'$property').';'.var_log($name,'$name').';'.var_log($content,'$content'),'blah');
        if ($property === 'og:image') {
            $image = $content;
            // $logService->log('DEBUG','1 og:image=',$image,'crawler');
            $parsed = parse_url($image);
            if (!array_key_exists('host', $parsed)) {
                $image = "http://" . $host . $image;
            }
            if (!is_available($image)) {
                $image = "";
            }
            //$logService->log('DEBUG','og:image=',$image,'crawler');
            continue;
        }
        if ($property === 'og:title') {
            $title = $content;
            $metafound = true;
            continue;
        }
        if ($property === 'twitter:title') {
            if (!$title) {
                $title = $content;
            }
            $metafound = true;
            continue;
        }
        if ($property === 'og:url') {
            $link = $content;
            $metafound = true;
            $parsed = parse_url($link);
            if (!array_key_exists('host', $parsed)) {
                $link = "http://" . $host . $link;
            }
            continue;
        }
        if ($property === 'og:site_name') {
            $site_name = $content;
            continue;
        }
        if ($property === 'og:locale') {
            $locale = $content;
            //$logService->log('DEBUG','og:locale=',$locale,'crawler');
            continue;
        }
        if ($property === 'og:description') {
            $description = $content;
            continue;
        }
        if ($property === 'twitter:description') {
            if (!$description) {
                $description = $content;
            }
            continue;
        }
        if ($property === 'og:date') {
            //CNN, Thank you!
            $date = $content;
            continue;
        }
        if ($property === 'og:pubdate') {
            //CNN, Thank you!
            $date = $content;
            continue;
        }
        if ($name === 'og:image') {
            //espreso.tv
            $image = $content;
            $parsed = parse_url($image);
            if (!array_key_exists('host', $parsed)) {
                $image = "http://" . $host . $image;
            }
            if (!is_available($image)) {
                $image = "";
            }
            continue;
        }
        if ($name === 'og:title') {
            $title = $content;
            $metafound = true;
            continue;
        }
        if ($name === 'sailthru.title') {
            if (!$title) {
                $title = $content;
            }
            $metafound = true;
            continue;
        }
        if ($name === 'og:url') {
            $link = $content;
            $metafound = true;
            $parsed = parse_url($link);
            if (!array_key_exists('host', $parsed)) {
                $link = "http://" . $host . $link;
            }
            continue;
        }
        if ($name === 'og:site_name') {
            $site_name = $content;
            continue;
        }
        if ($name === 'og:locale') {
            $locale = $content;
            continue;
        }
        if (strcasecmp($name, 'language') == 0) {
            $lang = $content;
            continue;
        }
        if ($name === 'og:description') {
            $description = $content;
            continue;
        }
        if ($name === 'og:date') {
            $date = $content;
            continue;
        }
        if ($name === 'og:pubdate') {
            $date = $content;
            continue;
        }
        if ($name === 'twitter:image:src') {
            $twiter_image = $content;
            if (!is_available($twiter_image)) {
                $twiter_image = "";
            }
            continue;
        }
        if ($name === 'sailthru.date') {
            $sailthru_date = $content;
            continue;
        }
        if ($name === 'sailthru.author') {
            $author = $content;
            continue;
        }
        if ($name === 'dcterms.date') {
            $dcterms_date = $content;
            continue;
        }
        if ($name === 'dcterms.created') {
            $dcterms_created = $content;
            continue;
        }
        if ($name === 'dcterms.modified') {
            $dcterms_modified = $content;
            continue;
        }
        if ($name === 'date') {
            $basic_date = $content;
            continue;
        }
        if ($name === 'publish_date') {
            //Politico TODO If no time zone, add utc
            $basic_publish_date = $content;
            //.' utc';
            continue;
        }
        if ($name === 'lastmod') {
            $basic_date = $content;
            continue;
        }
        if ($name === 'author') {
            $author = $content;
            continue;
        }
        if ($name === 'pdate') {
            $year = substr($content, 0, 4);
            $mo = substr($content, 4, 2);
            $day = substr($content, 6, 2);
            $pdate = $year . '-' . $mo . '-' . $day;
            continue;
        }
        if ($name === 'dat') {
            //NYTimes!
            $basic_date = $dat;
            //"May 12, 2015"
            continue;
        }
        if (strcasecmp($name, 'description') == 0) {
            //Ej, Mark Steyn - all caps - Sotnik
            $basic_description = $content;
            //
            $metafound = true;
            continue;
        }
        if ($property === 'article:published_time') {
            $published_time = $content;
            // $logService->log('DEBUG','Published time raw',$published_time,'crawler');
            continue;
        }
        if ($property === 'article:modified_time') {
            $updated_time = $content;
            // $logService->log('DEBUG','Updated time raw',$updated_time,'crawler');
            continue;
        }
        if ($http_equiv === 'Last-Modified') {
            //censor.net.ua
            $updated_time = $content;
        }
        if (strcasecmp($http_equiv, 'Content-Language') == 0) {
            $lang = $content;
        }
    }
    // $logService->log('DEBUG','inside-after metas',$url,'crawler');
    // if($metafound){
    /*  $logService->log('cDEBUG','Meta found url='.$url,'Updated time'.$updated_time.';Published time='.$published_time
        .';date='.$date.';title='.$title.';image='.$image.';description='.$description
        ,'','crawler');*/
    /* if(!$title){
         $logService->log('CDEBUG','NO TITLE url='.$url,'Updated time'.$updated_time.';Published time='.$published_time
               .';date='.$date.';title='.$title.';image='.$image.';description='.$description
               ,'','crawler');         
           $titletags=$dom->getElementsByTagName('title'); // mark steyn
           foreach ( $titletags as $titletag) {
                $logService->log('CDEBUG','TITLE tag='.$titletag->textContent,'Updated time'.$updated_time.';Published time='.$published_time
               .';date='.$date.';title='.$title.';image='.$image.';description='.$description
               ,'','crawler');          
               $title=$titletag->textContent;
           }
       }*/
    if ($lang && !$locale) {
        $locale = $lang . '_' . $lang;
    }
    //$logService->log('DEBUG','inside-after metas 001',$url,'crawler');
    if (!$locale && !$lang) {
        $locale = "en_US";
        $lang = "en";
        /*      $re = "/(?:<html|(?<!^)\\G)\\h*(?:([^=\\n\\h]+)=(['\"]+)((?:\\\\\\2|(?!\\2).)*)\\2+)?/mi"; 
                 $logService->log('DEBUG','inside-after metas 0100',$url,'crawler');
                  ini_set("pcre.backtrack_limit",10000);
                  $logService->log('DEBUG','inside-after metas 0110',$url,'crawler');
                 preg_match_all($re,$html,$matches,PREG_SET_ORDER);
                 $logService->log('DEBUG','inside-after metas 0101',$url,'crawler');
                 foreach((array)$matches as $match){
                    if(sizeof($match)<3)
                        continue;
                    $t=$match[1];
                    if($t=='lang'||$t=='xml:lang'){
                        $lang=$match[3];
                        break;
                    }
                 }
                 $logService->log('DEBUG','inside-after metas 002',$url,'crawler');
                 $locale=str_replace('-', '_', $lang);
                 if(strlen($locale)==2)
                    $locale=$locale.'_'.strtoupper($locale);
                //$lang=substr($lang,0,2);
                */
    }
    if (!$link) {
        $link = $url;
    }
    $text = "";
    // $logService->log('DEBUG','inside-after metas 0',$url,'crawler');
    if (!$description) {
        $description = $basic_description;
    }
    if (empty($title)) {
        $title_tags = $dom->getElementsByTagName('title');
        //ej.ru
        if ($title_tags->length > 0) {
            //$logService->log('DEBUG','Setting title tag',$title_tag->textContent,'crawler');
            $title = $title_tags->item(0)->textContent;
        }
    }
    if (stripos($title, 'steyn')) {
        //yes, he is that important
        $author = 'Mark Steyn';
    }
    if (stripos($title, 'Breitbart')) {
        $author = 'Breitbart';
        if (stripos($title, 'Author')) {
            return false;
        }
        if (stripos($title, 'Stories')) {
            return false;
        }
    }
    if (stripos($title, 'derbyshire') || stripos($link, 'derbyshire')) {
        //yes, he is that important
        $author = 'John Derbyshire';
    }
    if (!$image) {
        $image = $twitter_image;
    }
    // $logService->log('DEBUG','inside-after metas 2',$url,'crawler');
    if (!$author) {
        $title_tags = $dom->getElementsByTagName('title');
        //ej.ru
        if ($title_tags->length > 0) {
            //$logService->log('DEBUG','Setting title tag',$title_tag->textContent,'crawler');
            $t = $title_tags->item(0)->textContent;
            if (stripos($t, 'The Weekly Standard')) {
                $author = 'The Weekly Standard';
            }
            if (!$image) {
                //sotnik tv
                $image_tags = $dom->getElementsByTagName('img');
                $found = false;
                foreach ($image_tags as $img) {
                    $alt = $img->getAttribute('alt');
                    if (stripos($t, $alt) !== FALSE) {
                        $image = $img->getAttribute('src');
                        $found = true;
                        break;
                    }
                }
                if ($found) {
                    $parsed = parse_url($image);
                    if (!array_key_exists('host', $parsed)) {
                        $image = "http://" . $host . $image;
                    }
                }
            }
        }
    }
    //if(/*!empty($description)&&*/!empty($title)){
    // $logService->log('DEBUG','description and image',$url,'crawler');
    $description = substr($description, 0, 1024);
    if (!$updated_time) {
        $updated_time = $date;
    }
    if (!$updated_time) {
        $updated_time = $published_time;
    }
    if (!$updated_time) {
        $updated_time = $dcterms_date;
    }
    if (!$published_time) {
        $published_time = $dcterms_date;
    }
    if (!$updated_time) {
        $updated_time = $basic_date;
    }
    if (!$published_time) {
        $published_time = $basic_date;
    }
    if (!$updated_time) {
        $updated_time = $basic_publish_date;
    }
    if (!$published_time) {
        $published_time = $basic_publish_date;
    }
    if (!$updated_time) {
        $updated_time = $dcterms_modified;
    }
    if (!$published_time) {
        $published_time = $dcterms_modified;
    }
    if (!$updated_time) {
        $updated_time = $pdate;
    }
    if (!$published_time && $pdate) {
        $published_time = $pdate;
    }
    if (!$updated_time && !empty($sailthru_date)) {
        $updated_time = $sailthru_date . " EDT";
    }
    //so far I've seen it in NRO only and being in East COast
    if (!$published_time && !empty($sailthru_date)) {
        $published_time = $sailthru_date . " EDT";
    }
    /*if(empty($updated_time)||empty($published_time)){
           $logService->log('DEBUG','Empty time url='.$url,'Updated time'.$updated_time.';Published time='.$published_time
            .';date='.$date.';dcterms_date='.$dcterms_date.';basic_publish_date='.$basic_publish_date.';basic_date='.$basic_date.';dcterms_modified='.$dcterms_modified.';pdate='.$pdate
            ,'','crawler');
      }*/
    if (!$updated_time && !empty($default_date)) {
        $updated_time = $default_date;
    }
    if (!$published_time && !empty($default_date)) {
        $published_time = $default_date;
    }
    if (!$description && !empty($default_description) && stripos($url, 'huff') === FALSE) {
        // staying away from using RSS data as defaults on Huffington Post due to their posting
        $description = $default_description;
    }
    if (!$title && !empty($default_title) && stripos($url, 'huff') === FALSE) {
        $title = $default_title;
    }
    if (!$locale && !empty($default_language)) {
        $locale = $default_language;
    }
    if (!$site_name && !empty($default_site_name)) {
        $site_name = $default_site_name;
    }
    $published_time = strtotime($published_time);
    $updated_time = strtotime($updated_time);
    if (stripos($title, 'Mark Levin')) {
        //yes, he is that important
        $author = 'Mark Levin';
    }
    if (stripos($url, 'sotnik')) {
        $author = 'SotnikTV';
    }
    /* if(empty($updated_time)||empty($published_time)){
         $logService->log('DEBUG','2 Empty time url='.$url,'Updated time'.$updated_time.';Published time='.$published_time
             .';date='.$date.';dcterms_date='.$dcterms_date.';basic_publish_date='.$basic_publish_date.';basic_date'.$basic_date.';dcterms_modified'.$dcterms_modified.';pdate'.$pdate
             ,'','crawler');
       }*/
    //  $logService->log('DEBUG','Encoding='.$dom->encoding.';Updated time',$updated_time,'crawler');
    /*if(!$locale)
      $locale="en_US";*/
    if (!$site_name) {
        $site_name = $root;
    }
    // $logService->log('DEBUG','Encoding='.  mb_detect_encoding($title).';Title',$title,'crawler');
    if (stripos($description, '&lt;') !== FALSE) {
        $description = '';
    }
    if (stripos($html, '1251') !== FALSE) {
        $title = mb_convert_encoding($title, "utf-8", "auto");
        $logService->log('DEBUG', 'After conversion Encoding=' . $dom->encoding . ';Title', $title, 'crawler');
        // $logService->log('DEBUG','ABefore conversion Encoding='.$dom->encoding.';Description',$description,'crawler');
        $description = mb_convert_encoding($description, "utf-8", "auto");
        $logService->log('DEBUG', 'After conversion Encoding=' . $dom->encoding . ';Description', $description, 'crawler');
        if (!$locale) {
            $locale = "ru_RU";
        }
    }
    if (stripos($url, 'ej.ru')) {
        $site_name = 'Ежедневный Журнал';
        $locale = "ru_RU";
    }
    if (stripos($url, 'slon.ru')) {
        $site_name = 'SLON';
        $locale = "ru_RU";
        $author = "Slon";
    }
    if (stripos($url, 'liga.net')) {
        $locale = "ru_RU";
    }
    if (stripos($url, 'zn.ua')) {
        $locale = "ru_RU";
    }
    if (stripos($url, 'liga.net/ua')) {
        $locale = "uk_UA";
    }
    if (stripos($url, 'alternet')) {
        continue;
    }
    if (stripos($url, 'dt.ua')) {
        $locale = "uk_UA";
    }
    if (stripos($url, 'obozrevatel')) {
        $locale = "ru_RU";
    }
    if (stripos($url, 'nv.ua')) {
        $locale = "ru_RU";
    }
    if (stripos($url, 'gordonua.com')) {
        $locale = "ru_RU";
    }
    if (stripos($url, 'tvrain')) {
        $locale = "ru_RU";
    }
    if (stripos($url, 'english.gordonua')) {
        $locale = "en_EN";
    }
    if (stripos($url, 'hromadske')) {
        $locale = "uk_UA";
    }
    if (stripos($url, 'telegraph')) {
        $locale = "en_EN";
    }
    if (stripos($url, 'politico') && !$locale) {
        $locale = "en_EN";
    }
    if (stripos($url, 'americanthinker')) {
        $site_name = 'American Thinker';
        $locale = "en_EN";
    }
    if (stripos($url, 'washingtonpost')) {
        $locale = "en_EN";
    }
    if (stripos($url, 'thenation')) {
        $locale = "en_EN";
    }
    if (stripos($url, 'wsj')) {
        $locale = "en_EN";
    }
    if (mb_stripos($url, 'cnn') && !$locale) {
        $locale = "en_EN";
    }
    if (mb_stripos($url, 'salon') && !$locale) {
        $locale = "en_EN";
    }
    if (mb_stripos($url, 'politico') && !$locale) {
        $locale = "en_EN";
    }
    if (mb_stripos($url, 'petrimaz') && !$locale) {
        $locale = "ru_RU";
    }
    /*if(stripos($url,'lesoir')&&!$locale){
            $locale="fr_FR";
      
        }*/
    if (!$locale && (mb_stripos($url, '.be') || mb_stripos($url, '.fr'))) {
        $locale = "fr_FR";
    }
    if (!$author && stripos($url, 'nationalreview')) {
        $site_name = 'National Review';
        $locale = "en_EN";
        $author = "National Review";
        if (stripos($title, 'author')) {
            return false;
        }
    }
    if ($locale) {
        if (stripos($locale, "en") === 0) {
            $locale = 'en_EN';
        }
    }
    if ($locale) {
        if (stripos($locale, "ru") === 0) {
            $locale = 'ru_RU';
        }
    }
    if ($locale) {
        if (stripos($locale, "uk") === 0) {
            $locale = 'uk_UA';
        }
    }
    if ($locale) {
        if (stripos($locale, "en") === 0) {
            $locale = 'en_EN';
        }
    }
    if ($author) {
        /*$logService->log('CDEBUG','AUTHOR! url='.$url,'Updated time'.$updated_time.';Published time='.$published_time
          .';date='.$date.';dcterms_date='.$dcterms_date.';basic_publish_date='.$basic_publish_date.';basic_date'.$basic_date.';dcterms_modified'.$dcterms_modified.';pdate'.$pdate
          ,'','crawler');*/
        $author_record = $ds->checkAuthor($author);
        /*$logService->log('CDEBUG','AUTHOR record='.var_log($author_record),'Updated time'.$updated_time.';Published time='.$published_time
          .';date='.$date.';dcterms_date='.$dcterms_date.';basic_publish_date='.$basic_publish_date.';basic_date'.$basic_date.';dcterms_modified'.$dcterms_modified.';pdate'.$pdate
          ,'','crawler');*/
        /*$logService->log('CDEBUG','before image='.$author_record['image'],'$image='.$image.' author='.$author.' author_record='.$author_record
          .';date='.$date.';dcterms_date='.$dcterms_date.';basic_publish_date='.$basic_publish_date.';basic_date'.$basic_date.';dcterms_modified'.$dcterms_modified.';pdate'.$pdate
          ,'','crawler');*/
        if ($author_record) {
            /*  $logService->log('CDEBUG','image='.$author_record['image'],'Updated time'.$updated_time.';Published time='.$published_time
                .';date='.$date.';dcterms_date='.$dcterms_date.';basic_publish_date='.$basic_publish_date.';basic_date'.$basic_date.';dcterms_modified'.$dcterms_modified.';pdate'.$pdate
                ,'','crawler');*/
            if ($author != "Breitbart") {
                $image = $author_record['image'];
            } else {
                if (!$image) {
                    $image = $author_record['image'];
                }
            }
        }
    }
    //last redoubt
    if (!$description) {
        $xpath = new DOMXPath($dom);
        $textnodes = $xpath->query('//text()');
        foreach ($textnodes as $node) {
            $text = $node->textContent;
            if (strlen($text) < 128) {
                continue;
            }
            if (stripos($text, 'CDATA') !== FALSE) {
                continue;
            }
            if (stripos($text, 'window.') !== FALSE) {
                continue;
            }
            if (stripos($text, 'viewport') !== FALSE) {
                continue;
            }
            if (stripos($text, 'jQuery') !== FALSE) {
                continue;
            }
            if (stripos($text, 'function') !== FALSE) {
                continue;
            }
            if (stripos($text, 'google') !== FALSE) {
                continue;
            }
            if (stripos($text, 'google') !== FALSE) {
                continue;
            }
            if (stripos($text, '!important') !== FALSE) {
                continue;
            }
            if (stripos($text, 'font') !== FALSE) {
                continue;
            }
            if (stripos($text, 'css') !== FALSE) {
                continue;
            }
            if (stripos($text, '$(') !== FALSE) {
                continue;
            }
            if (stripos($text, '==') !== FALSE) {
                continue;
            }
            if (stripos($text, '{') !== FALSE) {
                continue;
            }
            if (strcasecmp($text, $title) == 0) {
                continue;
            }
            if (strlen($text) > 128) {
                $description = $text;
                break;
            }
        }
    }
    if (!$image) {
        $xpath = new DOMXPath($dom);
        $imagenodes = $xpath->query('//img[@width>300][@height>300]');
        foreach ($imagenodes as $node) {
            $src = $node->getAttribute('src');
            $image = $src;
            break;
        }
    }
    if (!$image) {
        $logService->log('CDEBUG', 'SAVING WITH NO IMAGE time=' . $updated_time . ';Published time=' . $published_time, 'link=' . $link . ';title=' . $title . ';image=' . $image . ';site_name=' . $site_name . ';description=' . $description . ';locale=' . $locale, 'crawler');
        $image = "/build/css/logo2pale.png";
    }
    //}
    $ret = array("link" => $link, "image" => $image, "title" => $title, "description" => $description, "site_name" => $site_name, "published_time" => $published_time, "updated_time" => $updated_time, "author" => $author, "locale" => $locale, "body" => $body);
    $logService->log('CDEBUG', 'returning metas url=' . $url, var_log($ret, '$ret'), '');
    if ($author) {
        $ret["author_categoryid"] = $author_record['categoryid'];
    }
    $ret['tags'] = $dom->getElementsByTagName('a');
    return $ret;
}
コード例 #6
0
ファイル: ajax-handler.php プロジェクト: bulini/booking-wp
function home_booking()
{
    if (!$_POST) {
        if (!defined("PHP_EOL")) {
            define("PHP_EOL", "\r\n");
        }
    }
    $name = $_POST['name'];
    $email = $_POST['email'];
    $phone = $_POST['phone'];
    $checkin = $_POST['checkin'];
    $checkout = $_POST['checkout'];
    $room_id = $_POST['room_id'];
    $room = $_POST['room'];
    $adults = $_POST['adults'];
    $children = $_POST['children'];
    $room_number = $_POST['room_number'];
    $message = $_POST['message'];
    $lang = $_POST['current_lang'];
    //if availability
    if (!is_available($room_id, $checkin, $checkout)) {
        echo '<div class="alert alert-danger alert-dismissable">
	  <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>La camera richiesta risulta occupata nelle date richieste!</div>';
        exit;
    }
    if (trim($email) == '') {
        echo '<div class="alert alert-danger alert-dismissable">
	  <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>Attention! Please enter a valid email address.</div>';
        exit;
    } else {
        if (trim($room) == '') {
            echo '<div class="alert alert-danger alert-dismissable">
	  <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>Attention! Please enter what kind of room.</div>';
            exit;
        } else {
            if (trim($checkin) == '') {
                echo '<div class="alert alert-danger alert-dismissable">
	  <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>Attention! Please enter your check-in date.</div>';
                exit;
            } else {
                if (trim($checkout) == '') {
                    echo '<div class="alert alert-danger alert-dismissable">
	  <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>Attention! Please enter your check-out date.</div>';
                    exit;
                } else {
                    if (!isEmail($email)) {
                        echo '<div class="alert alert-danger alert-dismissable">
	  <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>Attention! You have enter an invalid e-mail address, try again.</div>';
                        exit;
                    }
                }
            }
        }
    }
    if (get_magic_quotes_gpc()) {
        $comments = stripslashes($comments);
    }
    //titolo stanza composto da nome hotel + stanza x evitare duplicati...
    $main_name = 'booking ';
    $camera = get_the_title($room);
    // ADD THE FORM INPUT TO $new_post ARRAY
    $new_booking = array('post_title' => $main_name . ' - ' . $camera, 'post_type' => 'bookings', 'post_status' => 'waiting');
    //SAVE THE POST
    $bid = wp_insert_post($new_booking);
    $price = check_price($checkin, $checkout, $room, $room_number);
    $token = uniqid();
    $request_page = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
    $manager_url = get_bloginfo('siteurl') . '/reservations-system/?token=' . $token;
    update_post_meta($bid, 'name', $name);
    update_post_meta($bid, 'email', $email);
    update_post_meta($bid, 'phone', $phone);
    update_post_meta($bid, 'room', $room);
    update_post_meta($bid, 'room_id', $room_id);
    update_post_meta($bid, 'token', $token);
    update_post_meta($bid, 'manager_url', $manager_url);
    update_post_meta($bid, 'checkin', convert_date_to_timestamp($checkin));
    update_post_meta($bid, 'checkout', convert_date_to_timestamp($checkout));
    update_post_meta($bid, 'adults', $adults);
    update_post_meta($bid, 'children', $children);
    update_post_meta($bid, 'room_number', $room_number);
    update_post_meta($bid, 'message', $message);
    update_post_meta($bid, 'lang', $lang);
    if ($price) {
        update_post_meta($bid, 'price', $price);
    }
    $room_type = get_the_title($room);
    //$address = "*****@*****.**";
    $address = mytheme_get_option('email');
    $from = mytheme_get_option('place_name') . ' <' . $address . '>';
    $email_bcc = get_bloginfo('admin_email');
    // Configuration option.
    $e_subject = 'Booking n # ' . $bid . ' da ' . $email;
    $e_body = "Richiesta di prenotazione da <b>: {$name} {$email} tel. {$phone}</b>\n\n\t\tRichiesta prenotazione per le seguenti date<br />\n\t\tCheckin: <b>: {$checkin} </b><br />\n\t\tCheck-out <b>: {$checkout} </b><br />\n\t\tmessaggio <b>: {$message} </b><br />\n\n\t\tLa richiesta &egrave; di n, <b>{$room_number}</b>  <b>{$room_type}</b> per <b>{$adults} Adulti</b> e <b>{$children} bambini</b>.<br />\n\t\tIl prezzo proposto dal sistema in base alle tue impostazioni &egrave; di &euro; <b>{$price}</b> .<br />\n\t\tRicevuta da: {$request_page}.<br />\n\t\tin lingua: {$lang}.<br />\n\t\t<hr />\n\t\t<a href='{$manager_url}'>Gestisci</a>" . PHP_EOL . PHP_EOL;
    $e_reply = "<br />You can contact the customer via email, {$email} or hit 'reply' in your email browser to make the reservation complete.";
    $msg = wordwrap($e_body . $e_reply, 70);
    $headers[] = "From: {$from}" . PHP_EOL;
    $headers[] = "Bcc: {$email_bcc}" . PHP_EOL;
    //if(mail($address, $e_subject, $msg, $headers)) {
    if (wp_mail($address, $e_subject, $e_body, $headers)) {
        //email to customer
        // Reset content-type to avoid conflicts -- http://core.trac.wordpress.org/ticket/23578
        remove_filter('wp_mail_content_type', 'set_html_content_type');
        $price = check_price($checkin, $checkout, $room);
        // Email has sent successfully, echo a success page.
        //try to understand what kind of booking: instant on-request
        $booking_type = booking_get_option('booking_type');
        if ($booking_type == 'instant') {
            $confirmation_url = get_bloginfo('siteurl') . '/confirm-reservation?token=' . $token;
            //stop mostra prezzo per ora..
            echo '<div id="success_page" class="alert alert-warning"><h4><i class="fa fa-bolt"></i> ' . __('Secure instant booking', 'bookingwp') . '</h4></div>';
            echo '<h5>' . __('Price for your reservation is &euro;', 'bookingwp') . ' <b>' . $price . '</b></h5><br />';
            echo __('You can confirm now your reservation by clicking this link and leave your credit card as warranty or paying the entire fee of your booking with Paypal and instantly book the room!', 'bookingwp') . '<br /><hr />';
            echo '<a href="' . $confirmation_url . '" class="btn btn-success btn-block">Confirm reservation</a></p>';
        } else {
            echo '<div id="success_page" class="alert alert-success"><p>' . __('Your reservation has been submitted to us and well contact you as quickly as possible to complete your booking. Thank you', 'bookingwp') . '</p></div>';
        }
        exit;
    } else {
        echo 'ERROR!';
    }
}
コード例 #7
0
/**
 * \brief validation function check_logo_image_url().
 * check if the url is available,
 *
 * \param $url - the url which will be checked 
 *
 * \return 1: the url is available, 0: unavailable
 */
function check_logo_image_url($url)
{
    global $SysConf;
    if (empty($url)) {
        return 1;
    }
    /* logo url can be null, with the default */
    $LogoLink = @$SysConf["LogoLink"];
    $new_url = $LogoLink . $url;
    if (is_available($url) || is_available($new_url)) {
        return 1;
    } else {
        return 0;
    }
}
コード例 #8
-2
ファイル: ImageCopies.php プロジェクト: takashiki/image-force
 public function getAvailability()
 {
     foreach (static::getSchemes() as $key => $scheme) {
         $url = $this->getUrl($scheme);
         $this->status = is_available($url, config('app.check_timeout')) ? $this->status | $key : $this->status ^ $key;
     }
     return $this->status;
 }
コード例 #9
-2
ファイル: pluginserver.php プロジェクト: mneumann/tulip
function find_plugin($name, $os, $arch, $category, $tulip)
{
    $serverxml = simplexml_load_file('server.xml');
    $result = array();
    $pluginsxml = $serverxml->xpath("plugins");
    foreach ($pluginsxml[0] as $plugin) {
        $attr = $plugin->attributes();
        $attr_name = $attr['name'];
        $pluginname = (string) $attr_name;
        // Check if plugin name matches query
        if (contains($pluginname, $name) === true) {
            $plugindesc = array();
            foreach ($plugin->attributes() as $id => $value) {
                $plugindesc[$id] = (string) $value;
            }
            if (is_available($plugindesc['path'], $os, $arch) && contains($plugindesc['category'], $category) && $plugindesc['tulip'] === $tulip) {
                array_push($result, $plugindesc);
            }
        }
    }
    return $result;
}