Ejemplo n.º 1
0
                $buyback_prices = json_decode(file_get_contents_curl_mine($url));
                $buyback_offers = $buyback_prices->response->page->offers;
                foreach ($buyback_offers->merchant as $offer) {
                    $mprice = 0;
                    foreach ($offer->prices as $price) {
                        $mprice = array_values((array) $price[0]);
                    }
                    $buyback_vendors[] = array('isbn' => $isbn, 'name' => $offer->name, 'price' => $mprice[1]);
                }
            }
            //var_dump($buyback_vendors);
            //die();
            if (isset($_POST['cb_sales'])) {
                //Sales prices
                $url = "http://api2.campusbooks.com/12/rest/prices?key=" . APIKey . "&isbn=" . $isbn . "&format=json";
                $sales_prices = json_decode(file_get_contents_curl_mine($url));
                $sales_offers = $sales_prices->response->page->offers->condition;
                for ($i = 0; $i < sizeof($sales_offers); $i++) {
                    for ($j = 0; $j < sizeof($sales_offers[$i]->offer); $j++) {
                        if (in_array($sales_offers[$i]->offer[$j]->condition_text, array('New', 'Used'))) {
                            $sales_vendors[] = array('isbn' => $isbn, 'name' => $sales_offers[$i]->offer[$j]->merchant_name, 'price' => $sales_offers[$i]->offer[$j]->total_price);
                        }
                    }
                }
            }
        }
        $resultId = $dbConn->insert("results", array("BookInfo" => json_encode($book_infos), "BuyBackPrices" => json_encode($buyback_vendors), "SalesPrices" => json_encode($sales_vendors), "Isbns" => json_encode($isbns)));
    }
}
function file_get_contents_curl_mine($url)
{
Ejemplo n.º 2
0
    /** @see WP_Widget::form */
    function form($instance)
    {
        /**
         * Set Default Value for widget form
         */
        $default_value = array("width" => "250", "height" => "350", "show_faces" => 1, "show_header" => 1, "show_border" => 0, 'select_lng' => 'en_US');
        $instance = wp_parse_args((array) $instance, $default_value);
        $title = esc_attr($instance['title']);
        $app_id = esc_attr($instance['app_id']);
        $fb_url = esc_attr($instance['fb_url']);
        $width = esc_attr($instance['width']);
        $height = esc_attr($instance['height']);
        $color_scheme = esc_attr($instance['color_scheme']);
        $show_border = esc_attr($instance['show_border']);
        $custom_css = esc_attr($instance['custom_css']);
        $select_lng = esc_attr($instance['select_lng']);
        ?>
		<p>
			<label for="<?php 
        echo $this->get_field_id('title');
        ?>
"><?php 
        _e('Title:');
        ?>
</label>
			<input class="widefat" id="<?php 
        echo $this->get_field_id('title');
        ?>
" name="<?php 
        echo $this->get_field_name('title');
        ?>
" type="text" value="<?php 
        echo empty($title) ? 'Like Us On Facebook' : $title;
        ?>
" />
        </p>
		
        <p>
        	<label for="<?php 
        echo $this->get_field_id('app_id');
        ?>
"><?php 
        _e('Facebook Application Id:');
        ?>
</label>
        	<input class="widefat" id="<?php 
        echo $this->get_field_id('app_id');
        ?>
" name="<?php 
        echo $this->get_field_name('app_id');
        ?>
" type="text" value="<?php 
        echo empty($app_id) ? '503595753002055' : $app_id;
        ?>
" />
        </p>
        
        <p>
          	<label for="<?php 
        echo $this->get_field_id('fb_url');
        ?>
"><?php 
        _e('Facebook Page Url:');
        ?>
</label>
          	<input class="widefat" id="<?php 
        echo $this->get_field_id('fb_url');
        ?>
" name="<?php 
        echo $this->get_field_name('fb_url');
        ?>
" type="text" value="<?php 
        echo empty($fb_url) ? 'http://www.facebook.com/wordpress' : $fb_url;
        ?>
" />
          	<small>
          		<?php 
        _e('Works with only');
        ?>
          		<a href="http://www.facebook.com/help/?faq=174987089221178" target="_blank">
          			<?php 
        _e('Valid Facebook Pages');
        ?>
          		</a>
          	</small>
        </p>
        
        <p>
        	<input class="checkbox" type="checkbox" <?php 
        checked($instance['show_faces'], true);
        ?>
 id="<?php 
        echo $this->get_field_id('show_faces');
        ?>
" name="<?php 
        echo $this->get_field_name('show_faces');
        ?>
" />
        	<label for="<?php 
        echo $this->get_field_id('show_faces');
        ?>
"><?php 
        _e('Show Friends\' Faces');
        ?>
</label>
        </p>
        
        <p>
        	<input class="checkbox" type="checkbox" <?php 
        checked($instance['data_stream'], true);
        ?>
 id="<?php 
        echo $this->get_field_id('data_stream');
        ?>
" name="<?php 
        echo $this->get_field_name('data_stream');
        ?>
" />
        	<label for="<?php 
        echo $this->get_field_id('data_stream');
        ?>
"><?php 
        _e('Show Posts');
        ?>
</label>
        </p> 
        
        <p>
        	<input class="checkbox" type="checkbox" <?php 
        checked($instance['show_header'], true);
        ?>
 id="<?php 
        echo $this->get_field_id('show_header');
        ?>
" name="<?php 
        echo $this->get_field_name('show_header');
        ?>
" />
         	<label for="<?php 
        echo $this->get_field_id('show_header');
        ?>
"><?php 
        _e('Show Header');
        ?>
</label>
        </p>
        
        <p>
        	<label for="<?php 
        echo $this->get_field_id('width');
        ?>
"><?php 
        _e('Set Width:');
        ?>
</label>
        	<input size="5" id="<?php 
        echo $this->get_field_id('width');
        ?>
" name="<?php 
        echo $this->get_field_name('width');
        ?>
" type="text" value="<?php 
        echo $width;
        ?>
" />
        </p>
        
        <p>
        	<label for="<?php 
        echo $this->get_field_id('height');
        ?>
"><?php 
        _e('Set Height:');
        ?>
</label>
        	<input size="5" id="<?php 
        echo $this->get_field_id('height');
        ?>
" name="<?php 
        echo $this->get_field_name('height');
        ?>
" type="text" value="<?php 
        echo $height;
        ?>
" />
        </p>
        
        <p>
        	<label for="<?php 
        echo $this->get_field_id('color_scheme');
        ?>
"><?php 
        _e('Color Scheme:');
        ?>
</label>
    		<select name="<?php 
        echo $this->get_field_name('color_scheme');
        ?>
" id="<?php 
        echo $this->get_field_id('color_scheme');
        ?>
">
    			<option value="light"<?php 
        selected($instance['color_scheme'], 'light');
        ?>
><?php 
        _e('Light');
        ?>
</option>
    			<option value="dark"<?php 
        selected($instance['color_scheme'], 'dark');
        ?>
><?php 
        _e('Dark');
        ?>
</option>
        	</select>
        </p>
        
       <p>
        	<label for="<?php 
        echo $this->get_field_id('show_border');
        ?>
"><?php 
        _e('Show Border:');
        ?>
</label>
    		<select name="<?php 
        echo $this->get_field_name('show_border');
        ?>
" id="<?php 
        echo $this->get_field_id('show_border');
        ?>
">
    			<option value="Yes"<?php 
        selected($instance['show_border'], 'Yes');
        ?>
><?php 
        _e('Yes');
        ?>
</option>
    			<option value="No"<?php 
        selected($instance['show_border'], 'No');
        ?>
><?php 
        _e('No');
        ?>
</option>
        	</select>
        </p>
        <?php 
        $filename = "http://www.facebook.com/translations/FacebookLocales.xml";
        if (ini_get('allow_url_fopen')) {
            $langs = file_get_contents($filename);
            $xmlcont = new SimpleXMLElement($langs);
            ?>
        <p>
        	<label for="<?php 
            echo $this->get_field_id('select_lng');
            ?>
"><?php 
            _e('Select Language:');
            ?>
</label>
                <select name="<?php 
            echo $this->get_field_name('select_lng');
            ?>
" id="<?php 
            echo $this->get_field_id('select_lng');
            ?>
">
                    <?php 
            if (!empty($xmlcont)) {
                foreach ($xmlcont as $languages) {
                    $representation = $languages[0]->codes->code->standard->representation[0];
                    ?>
                            <option value="<?php 
                    echo $representation;
                    ?>
"<?php 
                    selected($instance['select_lng'], $representation);
                    ?>
><?php 
                    _e($title . " => " . $representation);
                    ?>
</option>
                            <?php 
                }
            }
            ?>
            </select>
        </p>
        <?php 
        } elseif (function_exists('curl_version')) {
            if (!function_exists('file_get_contents_curl_mine')) {
                function file_get_contents_curl_mine($url)
                {
                    $ch = curl_init();
                    curl_setopt($ch, CURLOPT_HEADER, 0);
                    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                    curl_setopt($ch, CURLOPT_URL, $url);
                    $data = curl_exec($ch);
                    curl_close($ch);
                    return $data;
                }
            }
            if (!function_exists('xmlstring2array_mine')) {
                function xmlstring2array_mine($string)
                {
                    $xml = simplexml_load_string($string, 'SimpleXMLElement', LIBXML_NOCDATA);
                    $array = json_decode(json_encode($xml), TRUE);
                    return $array;
                }
            }
            $langs = file_get_contents_curl_mine($filename);
            $xmlcont = xmlstring2array_mine($langs);
            $xmlcont = $xmlcont['locale'];
            ?>
   
            <p>
        	<label for="<?php 
            echo $this->get_field_id('select_lng');
            ?>
"><?php 
            _e('Select Language:');
            ?>
</label>
                <select name="<?php 
            echo $this->get_field_name('select_lng');
            ?>
" id="<?php 
            echo $this->get_field_id('select_lng');
            ?>
">
                    <?php 
            if (!empty($xmlcont)) {
                foreach ($xmlcont as $languages) {
                    $title = $languages['englishName'];
                    $representation = $languages['codes']['code']['standard']['representation'];
                    ?>
                            <option value="<?php 
                    echo $representation;
                    ?>
"<?php 
                    selected($instance['select_lng'], $representation);
                    ?>
><?php 
                    _e($title . " => " . $representation);
                    ?>
</option>
                            <?php 
                }
            }
            ?>
                </select>
        </p>    
            <?php 
        } else {
            ?>
            <p>
        	<label for="<?php 
            echo $this->get_field_id('select_lng');
            ?>
"><?php 
            _e('Language : ');
            ?>
</label>
                <b>English</b> <br />(Your PHP configuration does not allow to read <a href="http://www.facebook.com/translations/FacebookLocales.xml" target="_blank">this</a> file.
                To unable language option, enable curl extension OR allow_url_fopen in your server configuration.)
        </p>       
            <?php 
        }
        ?>
        <p>
        	<label for="<?php 
        echo $this->get_field_id('custom_css');
        ?>
"><?php 
        _e('Custom Css:');
        ?>
</label>
                <textarea rows="4" cols="30" name="<?php 
        echo $this->get_field_name('custom_css');
        ?>
"><?php 
        if (!empty($custom_css)) {
            echo trim($custom_css);
        }
        ?>
</textarea>
        </p>
        <?php 
    }
Ejemplo n.º 3
0
    /** @see WP_Widget::form */
    function form($instance)
    {
        /**
         * Set Default Value for widget form
         */
        $defaults = array('title' => 'Like Us On Facebook', 'width' => '250', 'height' => '350', 'select_lng' => 'en_US', 'data_small_header' => 'false', 'data_adapt_container_width' => 'false', 'data_hide_cover' => 'false', 'data_show_facepile' => 'on', 'data_show_posts' => 'on');
        $instance = wp_parse_args((array) $instance, $defaults);
        $title = esc_attr($instance['title']);
        $app_id = isset($instance['app_id']) ? esc_attr($instance['app_id']) : "503595753002055";
        $fb_url = isset($instance['fb_url']) ? esc_attr($instance['fb_url']) : "http://www.facebook.com/wordpress";
        $width = esc_attr($instance['width']);
        $height = esc_attr($instance['height']);
        $data_adapt_container_width = esc_attr($instance['data_adapt_container_width']);
        $data_hide_cover = esc_attr($instance['data_hide_cover']);
        $data_show_facepile = esc_attr($instance['data_show_facepile']);
        $data_show_posts = esc_attr($instance['data_show_posts']);
        $custom_css = isset($instance['custom_css']) ? esc_attr($instance['custom_css']) : "";
        $select_lng = esc_attr($instance['select_lng']);
        ?>
        <p>
            <label for="<?php 
        echo $this->get_field_id('title');
        ?>
"><?php 
        _e('Title:');
        ?>
</label>
            <input class="widefat" id="<?php 
        echo $this->get_field_id('title');
        ?>
" name="<?php 
        echo $this->get_field_name('title');
        ?>
" type="text" value="<?php 
        echo $title;
        ?>
" />
        </p>
        <p>
            <label for="<?php 
        echo $this->get_field_id('app_id');
        ?>
"><?php 
        _e('Facebook Application Id:');
        ?>
</label>
            <input class="widefat" id="<?php 
        echo $this->get_field_id('app_id');
        ?>
" name="<?php 
        echo $this->get_field_name('app_id');
        ?>
" type="text" value="<?php 
        echo $app_id;
        ?>
" />
        </p>
        <p>
            <label for="<?php 
        echo $this->get_field_id('fb_url');
        ?>
"><?php 
        _e('Facebook Page Url:');
        ?>
</label>
            <input class="widefat" id="<?php 
        echo $this->get_field_id('fb_url');
        ?>
" name="<?php 
        echo $this->get_field_name('fb_url');
        ?>
" type="text" value="<?php 
        echo $fb_url;
        ?>
" />
            <small>
                <?php 
        _e('Works with only');
        ?>
                <a href="http://www.facebook.com/help/?faq=174987089221178" target="_blank">
                    <?php 
        _e('Valid Facebook Pages');
        ?>
                </a>
            </small>
        </p>
        <p>
            <input class="checkbox" type="checkbox" <?php 
        checked($instance['data_show_posts'], "on");
        ?>
 id="<?php 
        echo $this->get_field_id('data_show_posts');
        ?>
" name="<?php 
        echo $this->get_field_name('data_show_posts');
        ?>
" />
            <label for="<?php 
        echo $this->get_field_id('data_show_posts');
        ?>
"><?php 
        _e('Show posts from the Page timeline');
        ?>
</label>
        </p>
        <p>
            <input class="checkbox" type="checkbox" <?php 
        checked($instance['data_hide_cover'], "on");
        ?>
 id="<?php 
        echo $this->get_field_id('data_hide_cover');
        ?>
" name="<?php 
        echo $this->get_field_name('data_hide_cover');
        ?>
" />
            <label for="<?php 
        echo $this->get_field_id('data_hide_cover');
        ?>
"><?php 
        _e('Hide Cover');
        ?>
</label>
        </p>
         <p>
            <input class="checkbox" type="checkbox" <?php 
        checked($instance['data_show_facepile'], "on");
        ?>
 id="<?php 
        echo $this->get_field_id('data_show_facepile');
        ?>
" name="<?php 
        echo $this->get_field_name('data_show_facepile');
        ?>
" />
            <label for="<?php 
        echo $this->get_field_id('data_show_facepile');
        ?>
"><?php 
        _e('Show profile photos when friends like this');
        ?>
</label>
        </p>
        <p>
            <input class="checkbox" type="checkbox" <?php 
        checked($instance['data_small_header'], "on");
        ?>
 id="<?php 
        echo $this->get_field_id('data_small_header');
        ?>
" name="<?php 
        echo $this->get_field_name('data_small_header');
        ?>
" />
            <label for="<?php 
        echo $this->get_field_id('data_small_header');
        ?>
"><?php 
        _e('Show Small Header');
        ?>
</label>
        </p>
        <p>
            <input onclick="shoWidth();" class="checkbox" type="checkbox" <?php 
        checked($instance['data_adapt_container_width'], "on");
        ?>
 id="<?php 
        echo $this->get_field_id('data_adapt_container_width');
        ?>
" name="<?php 
        echo $this->get_field_name('data_adapt_container_width');
        ?>
" />
            <label for="<?php 
        echo $this->get_field_id('data_adapt_container_width');
        ?>
"><?php 
        _e('Adapt To Plugin Container Width');
        ?>
</label>
        </p>
        <p class="width_option <?php 
        echo $instance['data_adapt_container_width'] == 'on' ? 'hideme' : '';
        ?>
">
           <label for="<?php 
        echo $this->get_field_id('width');
        ?>
"><?php 
        _e('Set Width:');
        ?>
</label>
           <input size="5" id="<?php 
        echo $this->get_field_id('width');
        ?>
" name="<?php 
        echo $this->get_field_name('width');
        ?>
" type="text" value="<?php 
        echo $width;
        ?>
" />
        </p>
        <p>
           <label for="<?php 
        echo $this->get_field_id('height');
        ?>
"><?php 
        _e('Set Height:');
        ?>
</label>
           <input size="5" id="<?php 
        echo $this->get_field_id('height');
        ?>
" name="<?php 
        echo $this->get_field_name('height');
        ?>
" type="text" value="<?php 
        echo $height;
        ?>
" />
        </p>
        <?php 
        $filename = "http://www.facebook.com/translations/FacebookLocales.xml";
        if (ini_get('allow_url_fopen')) {
            $langs = file_get_contents($filename);
            $xmlcont = new SimpleXMLElement($langs);
            ?>
            <p>
               <label for="<?php 
            echo $this->get_field_id('select_lng');
            ?>
"><?php 
            _e('Language:');
            ?>
</label>
               <select name="<?php 
            echo $this->get_field_name('select_lng');
            ?>
" id="<?php 
            echo $this->get_field_id('select_lng');
            ?>
">
                <?php 
            if (!empty($xmlcont)) {
                foreach ($xmlcont as $languages) {
                    $lan_title = $languages->englishName;
                    $representation = $languages[0]->codes->code->standard->representation[0];
                    ?>
                        <option value="<?php 
                    echo $representation;
                    ?>
"<?php 
                    selected($instance['select_lng'], $representation);
                    ?>
><?php 
                    _e($lan_title . " => " . $representation);
                    ?>
</option>
                        <?php 
                }
            }
            ?>
            </select>
        </p>
        <?php 
        } elseif (function_exists('curl_version')) {
            if (!function_exists('file_get_contents_curl_mine')) {
                function file_get_contents_curl_mine($url)
                {
                    $ch = curl_init();
                    curl_setopt($ch, CURLOPT_HEADER, 0);
                    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                    curl_setopt($ch, CURLOPT_URL, $url);
                    $data = curl_exec($ch);
                    curl_close($ch);
                    return $data;
                }
            }
            if (!function_exists('xmlstring2array_mine')) {
                function xmlstring2array_mine($string)
                {
                    $xml = simplexml_load_string($string, 'SimpleXMLElement', LIBXML_NOCDATA);
                    $array = json_decode(json_encode($xml), TRUE);
                    return $array;
                }
            }
            $langs = file_get_contents_curl_mine($filename);
            $xmlcont = xmlstring2array_mine($langs);
            $xmlcont = $xmlcont['locale'];
            ?>
   
        <p>
           <label for="<?php 
            echo $this->get_field_id('select_lng');
            ?>
"><?php 
            _e('Language:');
            ?>
</label>
           <select name="<?php 
            echo $this->get_field_name('select_lng');
            ?>
" id="<?php 
            echo $this->get_field_id('select_lng');
            ?>
">
            <?php 
            if (!empty($xmlcont)) {
                foreach ($xmlcont as $languages) {
                    $title = $languages['englishName'];
                    $representation = $languages['codes']['code']['standard']['representation'];
                    ?>
                    <option value="<?php 
                    echo $representation;
                    ?>
"<?php 
                    selected($instance['select_lng'], $representation);
                    ?>
><?php 
                    _e($title . " => " . $representation);
                    ?>
</option>
                    <?php 
                }
            }
            ?>
            </select>
        </p>    
        <?php 
        } else {
            ?>
        <p>
           <label for="<?php 
            echo $this->get_field_id('select_lng');
            ?>
"><?php 
            _e('Language : ');
            ?>
</label>
           <b>English</b> <br />(Your PHP configuration does not allow to read <a href="http://www.facebook.com/translations/FacebookLocales.xml" target="_blank">this</a> file.
           To unable language option, enable curl extension OR allow_url_fopen in your server configuration.)
        </p>
        <?php 
        }
        ?>
        <p>
           <label for="<?php 
        echo $this->get_field_id('custom_css');
        ?>
"><?php 
        _e('Custom Css:');
        ?>
</label>
           <textarea rows="4" cols="30" name="<?php 
        echo $this->get_field_name('custom_css');
        ?>
"><?php 
        echo trim($custom_css);
        ?>
</textarea>
        </p>
        <script type="text/javascript">
        function shoWidth() {
            if (jQuery(".width_option").hasClass('hideme'))
                jQuery(".width_option").removeClass('hideme');
            else
                jQuery(".width_option").addClass('hideme');
        }
        </script>
        <style type="text/css">.hideme {display: none;}</style>
        <?php 
    }