I want to open a url from my app in safari, however the url page requires login details and i'd rather pass these details automatically so the page just opens.
If I add the login details to the URL eg. http://user:pass#myurl.com it opens in safari but I get an anti phishing warning.
Is there an alternative way to avoid getting the warning?
Thanks
If you use a php redirect like this it should work:
<?php
function redirect($url, $statusCode = 302)
{
header('Location: ' . $url, true, $statusCode);
die();
}
$url = 'https://' . $_REQUEST['user'] . ':' . $_REQUEST['password'] . '#myurl.com';
redirect($url);
?>
name that php file 'login.php'
possible html page:
<form action='login.php' method='post'>
username<input type='text' name='user'><br>
password<input type='password' name='password'><br>
<input type='submit' value='login'>
</form>
or open the page:
https://myurl.com/login.php?user=[some script to get username]&password=[password]
these answers would require creating files on the server. I'm not sure if you own the domain or not but these files should work on any server with php and could easily redirect to any website.
hope this helps
Related
I created this script to hide a page only if chrome 18 has not been found, how can I make sure to do the redirect of the url to a external page if chrome 18 has not been found instead of hiding only the page ?
I want to do the redirect to this website http://search.aol.com/aol/webhome
<div id="hiddenContent" style="display: none;">
My hidden content.
</div>
<script>
function GetChromeVersion() {
var raw = navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);
return raw ? parseInt(raw[2], 10) : false;
}
if (GetChromeVersion() == 18)
document.getElementById("hiddenContent").style.display = "";
</script>
It's possible, e.g. by using:
window.location.href='http://search.aol.com/aol/webhome';
Inside your function. BUT I wouldn't recommend you this. You should never trust the client as JavaScript can easily be changed and someone could access your site even despite the JavaScript redirect if they wanted to and made a minimal effort to modify page sources. Javascript is handled on the client-side, while php is completely server-side. In this case I'd use php instead of JavaScript. Try to check it with php and if it's not chrome 18, use: header('Location: http://search.aol.com/aol/webhome');
Edit:
<?php function is_chrome()
{
return(eregi("chrome/18", $_SERVER['HTTP_USER_AGENT'])); } if(is_chrome()) { header('Location: http://www.search.aol.com/aol/webhome'); } ?>
Place it on top of the file, should work, but haven't tested it yet, if not, just change the string in eregi('chrome/18') to what you need (it's a regular expression)
I'm updating my site to a more mobile friendly responsive design using jquerymobile. Usually I have the user login and after checking the details are correct it will refresh them onto a new page.
However, I can't get this working with jquerymobile. Presumably this is because of the Ajax override features? Ajax is currently foreign to me :)
The abridged script is like below:
else
//else, all ok proceed with login
{
if(isset($_GET['redirect']))
{header ("Refresh: 0; URL=" . $_GET['redirect'] . "");}
else{header ("Refresh: 0; URL=cohome.php");
echo "Your login was successful, you are being redirected in one second <br />";
echo "(If your browser doesn't support this, click here)";}
}
many thanks
Actually, to simplify things. I have the same problem with my logout button.
<a href="logout.php">
which leads to
<?php
session_start();
// make double sure that logged out.
$_SESSION['logged'] = "0";
session_destroy();
header("Refresh: 0; URL=index.php");
echo "You have been logged out.<br />";
echo "You are being redirected to the homepage!<br />";
echo "(If your browser doesn't support this, click here)";
?>
Unfortunately, no redirect occurs. It works fine on my standard site, only since starting to change over to jquery mobile.
Ah ok. It seems to work fine if I turn off ajax, using "data-ajax=false".
<form name="login" id="login" action="<?php echo "processCoLogin.php?".$_SERVER['QUERY_STRING']; ?>" data-ajax=false method="post">
or
<a href="logout.php" class="ui-btn" data-ajax=false>Log out</a>
But I'd prefer a solution where I didn't have to turn off ajax & could redirect using header(location) still.
A header with a refresh of 0 makes not much sense. Consider using
header('location:' . $_GET['redirect']);
instead. Or, if you wish to display the redirect message, increase the refresh time. Last, but not least, you could also echo a refresh:
echo "<meta http-equiv='refresh' content='3; url=" . $_GET['redirect']) . "'>";
However, using meta-refresh is not recommended. But if you are using JS and rely on it, you could also use a JS redirection:
echo "setTimeout(\"location.href = '" . $_GET['redirect']) . "';\", 3000);";
There are several ways, but a PHP refresh with 0 seconds isn't the best idea in my opinion.
Friends,
I am going crazy with this issue, I hope you have the answer for me as I have searched wide for this issue. I have a WEB site that has implemented both the 'Like' button and the 'Comments' button. The issue I'm having is actually two-fold:
First:
The usual 'Admin Page' link that goes beside the 'Like' button once the Admin (me) has liked the page is not always present... I can't figure why, because they are exactly the same PHP pages with different info filled from the DB, but they have identical structure. So I don't understand why:
www.rafaelpolit.com/inicio/index.php?sid=14&gim=10
Shows me the Admin Page link, while
www.rafaelpolit.com/inicio/index.php?sid=14&gim=183
Doesn't.
Any ideas?
Second:
The above problem would not be much of an issue if the procedure described on the Open Graph Protocol page (https://developers.facebook.com/docs/opengraph/#publishing) under Publishing would actually work! Here's the actual problem:
My page uses two parameters in the URL to define the page content: one is the section, the other is the image ID.
My other pages that use a single URL attribute, work fine!!! So, if I access (I am using the graph for simplified purposes):
https://graph.facebook.com/http%3A%2F%2Fwww.rafaelpolit.com%2Finicio%2Findex.php%3Fsid%3D106
It correctly shows:
{
"id": "117419061672096",
"name": "Rafael P\u00f3lit - Macro y Objetos",
"picture": "http://profile.ak.fbcdn.net/hprofile-ak-snc4/188186_117419061672096_2606222_s.jpg",
"link": "http://www.rafaelpolit.com/inicio/index.php?sid=106",
"likes": 2,
"category": "Unknown",
"website": "http://www.rafaelpolit.com/inicio/index.php?sid=106",
"description": "-",
"can_post": true
}
But if I access the graph for one of the URLs with multiple arguments, like:
https://graph.facebook.com/http%3A%2F%2Fwww.rafaelpolit.com%2Finicio%2Findex.php%3Fsid%3D14%26gim%3D10
It truncates the second argument and shows:
{
"id": "http://www.rafaelpolit.com/inicio/index.php?sid=14"
}
As you can see if you enter this though:
graph.facebook.com/159684077425429
The Facebook page is actually correctly working!!! :( Is there a way to actually know a Page_ID if I cannot access the page from any place other than my own site?
So, to sum up my issue:
For some pages I don't get the Admin Page link
For those pages, I have no way of knowing the Page_id
The graph options are not working for pages that have multiple URL arguments/parameters
In the exact same fashion, the https://graph.facebook.com/feed option does not send messages to the people that have 'liked' a page for those pages that have multiple URL parameters, it works fine for those with single parameter.
How do I access the information of a page with two or more parameters?
My final goal is to make something like this actually WORK!:
<?php
$ogurl = urlencode("http://www.rafaelpolit.com/inicio/index.php?sid=14&gim=10");
define("FACEBOOK_APP_ID", "15xxxx84127xxxx");
define("FACEBOOK_SECRET", "xxxx5391830xxxx744b171f0d4b5xxxx");
$mymessage = "Thank you for 'Liking' my Picture.";
$access_token_url = "https://graph.facebook.com/oauth/access_token";
$parameters = "grant_type=client_credentials&client_id=" . FACEBOOK_APP_ID .
"&client_secret=" . FACEBOOK_SECRET;
$access_token = file_get_contents($access_token_url . "?" . $parameters);
$apprequest_url = "https://graph.facebook.com/feed";
$parameters = "?" . $access_token . "&message=" .
urlencode($mymessage) . "&id=" . $ogurl . "&method=post";
$myurl = $apprequest_url . $parameters;
$result = file_get_contents($myurl);
// output the post id
echo "post_id" . $result;
?>
I repeat: This works FINE! if I use the URL of pages with a single URL parameter, it does NOT work if I use URL of pages with multiple parameters.
Any insight? This is a complex issue and I am not a native English speaker, so forgive the extension and any confusion. I appreciate all and every help you may provide!
Thanks a lot,
Rafael Pólit.
ps. Please forgive the non-working links, since I'm new only two of them could actually be links. Most work as copy paste links though, except the graph link which needs https:// in the beginning. Thanks for understanding.
Edit 1:
In response to #Abby 's comment bellow, this is the code I'm using (hopefully formatted instead of the responses in my comments) to insert the button:
<div class="fb_cont ui-corner-all" style="width:706px">
<div id="fb-root"></div>
<script type="text/javascript">
//<![CDATA[
window.fbAsyncInit = function() {
FB.init({appId: '154581841273133', status: true, cookie: true, xfbml: true});
};
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol +
'//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
//]]>
</script>
<div class="fb_cont_int" style="padding:5px;">
<div class="fb_likeDiv" style="width:240px;">
<div class="fb-like" data-href="http://www.rafaelpolit.com/inicio/index.php?sid=14&gim=183" data-send="false" data-width="240" data-show-faces="true" data-colorscheme="dark" data-font="tahoma"></div>
</div>
<div class="fb_commentDiv" style="width:446px;">
<div class="fb-comments" data-href="http://www.rafaelpolit.com/inicio/index.php?sid=14&gim=183" data-num-posts="4" data-width="446" data-colorscheme="dark"></div>
</div>
<div class="dummy"><!-- --></div>
</div>
</div>
Thanks again #Abby for looking into my issue.
I am working on an application which is running in CakePHP and I am using AJAX queries from within.
In all the cases for all the ajax post i have used the url as
var ht = $.ajax({
type: "GET",
url: "http://172.20.52.99/FormBuilder/index.php/forms/viewChoices/"+attribute_id,
async: false
}).responseText;
var myObject = eval('(' + ht + ')');
Is there any way in CakePHP where I can give my base URL as http://172.20.52.99/FormBuilder/index.php/ and to call the base URL in all the places I want.
Try writing following code
'http://'.$_SERVER['HTTP_HOST'].$this->base
$_SERVER['HTTP_HOST']----it will give you working host
and $this->base---will give you working url
You can use $this->base to get base url.
you may use
<?php echo Router::fullbaseUrl();?>
as well.
Refer http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html for more details.
You could set default URL for all your ajax requests that way:
$.ajaxSetup({
url: 'http://172.20.52.99/FormBuilder/index.php/'
});
Use any one method of following
<?php echo $this->Html->url('/');?>
<?php Router::url('/', true); ?>
<?php echo $this->base;?>
<?php echo $this->webroot; ?>
Define constant in Config/core.php as define("BASE_URL", "www.yoursite.com/"); and use BASE_URL anywhere in your project
I assume I've the same scenario: for development, the site is available at localhost/cake, whereby in production the site is deployed in the root dir of example.com. In the header I set:
<base href="<?php echo $base_url ?>" />,
in AppContoller::beforeRender() I set:
$this->set('base_url', 'http://'.$_SERVER['SERVER_NAME'].Router::url('/'));.
This works fine for everything, except JS (so thus AJAX), as it ignores base_url.
Therefore I have a workaround (uses jQuery, but easy to substitute without):
forUrl = function(url) {
return $('base').attr('href')+url.substr(1);
}
login = function() {
$.post(forUrl('/ajax/profileDiv'), $('#profile-login-form').serialize(),
function(data) {
(...)
});
}
This might also be helpful:
http://book.cakephp.org/view/1448/url
<?php echo $this->Html->url('/posts', true); ?>
//Output
http://somedomain.com/posts
I am integrating a 3rd party module into my site. I read their documention, but I stuck at this line:
"Your script should then do a server-to-server posting to our server. For example: https://www.domain.com:XXXX/gateway..."
What is it? I write a php page with a POST-form:
<form action"https://www.domain.com:XXXX/..." method="post">
...
<input type="submit">
Is it something like that?
Then do a response, let say they send back "result=ok", then I catch the result and do a check whether the result is okay or failed?
I interpret in this way, I dont know if I am doing the correct thing. CAn anyone advice? What is the server-to-server posting?
A server-to-server posting means that the program running on your server makes an HTTP POST to a gateway running on the vendor's server. The code fragment that you provided is HTML. You will need to have a code fragment in PHP (or some other language) to execute the POST. (If you did it in JavaScript, the post will come from your user's web browser, which is not what you want.)
You want to use the PHP HttpRequest class. Take a look at Example #2 in the PHP Manual, reprinted here:
<?php
$r = new HttpRequest('http://example.com/form.php', HttpRequest::METH_POST);
$r->setOptions(array('cookies' => array('lang' => 'de')));
$r->addPostFields(array('user' => 'mike', 'pass' => 's3c|r3t'));
$r->addPostFile('image', 'profile.jpg', 'image/jpeg');
try {
echo $r->send()->getBody();
} catch (HttpException $ex) {
echo $ex;
}
?>