mercredi 28 octobre 2015

301 redirect in IIS

So we have a client whereby we are hosting their site but with 2 different domains mapped (we have bindings for both domains) to the same site in IIS. this is primarily because when they started with us they could only purchase the domain they didn't ultimately want to use going forwards.

For example the domains are www.some-thing.com and www.something.com.

They have asked if I can put a 301 permanent redirect in on the URL with the hyphen so then users should always go to the non hyphen version of the site.

I have tried URL rewrite rules and using the HTTP redirect in IIS however the site is then in a re-direct loop and I think this is down to the fact I have both domains bound to the site in IIS.

Help !!

Thanks in advance




suming column values based on condition and store it in variable MVC4?

I have enrollment_ms table in which fields are studentID, SUbjectID, GPA i want to calculate cummulative CPGA by adding the GPA column values where sutdent id is same and display it on view !! CGPA=suming of GPA of every subject there and divided by no. of subjects!!




d3 - trigger mouseover event on mobile devices(touch screens)

Is there any way to trigger the .on("mouseover") event by dragging the finger over the svgs on the touchscreens and not by clicking on each of them. (or is there any other event to do that)

You can check the link below.

http://ift.tt/1P49lAO




Changing embedded video's width and height

I used the video tag in my HTML5 doc to put a video on my webpage. I adjusted the width and height since the video was showing up way too big, but the controls bar was not shortened/affected by doing this so what I have is a re-sized video display screen box but an over-sized controls bar.

Here's my video tag

                <video width="50%" height="50%" controls >
                    <source src="/media/video/Monkaa.mp4" type="video/mp4">
                </video> 

So, how do I get the controls bar to adjust proportionally?




RabbitMQ: Works in terminal, but not with PHP

for a project I am currently working on I am using rabbitMQ to queue tasks, and send messages. If I run the server and the client from a terminal I will receive data, but if I try to include the php in an index.php that tries to display the into to a web page it does not work. What am I doing wrong, I tried wrapping the testRabbitMQClient.php in a function but this still does not work.What am I missing?

   <?php
//index.php

require 'openid.php';
require 'functions.php';
require 'testRabbitMQClient.php';
/*
#connects to my database and checks to make sure its connected.
*/
$apikey="key";
try {
   $openid = new LightOpenID('localhost');
    if(!$openid->mode) {
        if(isset($_GET['login'])) {
            $openid->identity = 'http://ift.tt/1glcWoz';
            header('Location: ' . $openid->authUrl());
        }
?>
<h1>Hey ____ thank you for using FOF.com</h1>

<br>
<?php 
    //showFriends(xxxxxxxxxxxxxxxxx); 
    //calls function from testRabbitMQClient.php    
    send("friends");

?>
<form action="?login" method="post">
    <input type="image" src="http://ift.tt/1dHz8Pc">
</form>
<?php
    } elseif($openid->mode == 'cancel') {
        echo 'User has canceled authentication!';
    } else {
        if($openid->validate()) {
                $id = $openid->identity;
                // identity is something like: http://ift.tt/1jQj7Lz
                // we only care about the unique account ID at the end of the URL.
                $ptn = "/^http:\/\/steamcommunity\.com\/openid\/id\/(7[0-9]{15,25}+)$/";
                preg_match($ptn, $id, $matches);
                echo "User is logged in (steamID: $matches[1])\n";
    } 
    else 
    {
                echo "User is not logged in.\n";
        }

    }
} catch(ErrorException $e) {
    echo $e->getMessage();
}
?>

#!/usr/bin/php
<?php
//rabbit mq client;
require_once('path.inc');
require_once('get_host_info.inc');
require_once('rabbitMQLib.inc');

function send($type){
    $client = new rabbitMQClient("testRabbitMQ.ini","testServer");
    if (isset($argv[1]))
    {
        $msg = $argv[1];
    }
    else
    {
        $msg = "test message";
    }

    $request = array();
    $request['type'] = "friends";
    $request['username'] = "steve";
    $request['password'] = "password";
    $request['message'] = $msg;
    $response = $client->send_request($request);
    //$response = $client->publish($request);

    echo "client received response: ".PHP_EOL;
    echo $response;
    echo "\n\n";

    echo $argv[0]." END".PHP_EOL;
}

?>




mardi 27 octobre 2015

Is there any way for adding non-form elements to GET URL?

I need to pass some data over GET URL which is not in form, is there any way to include non-form data into GET method?

http://localhost/land1/index.php?visitorName=&visitorPhone=&submit=Submit

which is ok for form elements like visitorName and visitorPhone, but i need to pass some other info also with this, like some fixed non-form data.

And i have to use only html, in form submitting page, no php.., target is php.




How to scrape google images with node.js and cheerio

Does anyone know how to use node and cheerio to scrape images from google? I have tried using cheerio to scrape images from a given website like reddit.com or the yellow pages.com and it works fine. But how would I be a be able to put in a search query and scrape the images under google images? For example, I put in a query for "cats" and using cheerio, I return all the url under google images for "cats".