The Disqus SSO actually works great for me, but the problem is that it is working only intermittently. Sometimes the user is logged in, and the Disqus comment box works fine, but other times, it doesn't log my user in..it is pretty much ignoring the code below, or that is not working correctly:
<script type="text/javascript">
var disqus_config = function() {
this.page.remote_auth_s3 = "<?php echo "$message $hmac $timestamp"; ?>";
this.page.api_key = "<?php echo DISQUS_PUBLIC_KEY; ?>";
}
</script>
I'm sure I have everything configured correctly, having used this below my disqus comment box:
https://github.com/disqus/DISQUS-API-Recipes/blob/master/sso/php/sso.php
The error I get in the Chrome console when my user is not automatically authenticated in the Disqus comment box is below:
> http://disqus.com/api/3.0/embed/threadDetails.json?thread=___…1&api_key=___404 (NOT FOUND) lib.js:162 send lib.js:162 e.extend.ajax lib.js:157 d
> client.js:27 g.call client.js:28 u.extend.fetch client.js:85
> Backbone.View.extend.fetchSession client.js:122
> Backbone.View.extend.initSession client.js:118
> Backbone.View.extend.bootstrap client.js:113 w lib.js:216
> n.Events.trigger lib.js:215 messageHandler
However, when this error does show, and I refresh the page, oftentimes, it goes away and the user is authenticated. Really not sure what it can be. I've tried moving the javascript for the sso around, such as putting it into the document head, but I'm getting nowhere now.
I'm sure I have everything configured correctly, having used this below my disqus comment box:
Disqus php api example
After I left the whole thing alone...the problem went away. If you have this same problem, don't waste your time trying to fix it, give it a day or 2 first
Related
I'm a bit lost at the moment and I hope that you can help!
I try to recognize people with OpenCV in Python. This is working so far. With the id of the recognized person I want to display information which belong to her or him.
For that I tried something like this:
1)
import webbrowser
webbrowser.open('http://mysite/index.php?userID=XYZ', new = 0)
But although I wrote the "new = 0" it opens a new browser tab everytime an other userID stands in the link.
2) An other approach was to send information via a http post request to the website like:
url = 'http://mysite/index.php'
query = {'personID': XYZ}
res = requests.post(url, data=query)
But doing this I don't have any idea how to work with this post command in my PHP code so it refreshes the site with the data belonging to user XYZ..
May you help me please?
Kind regards
Edit1 - START:
A small php example with using GET parameters would be something like this
<?php
echo("<html><head><title></title></head><body>");
if ($_GET['userID'] == 1) {
echo("<div id='userContent'>Hello User 1</div>");
}
else if ($_GET['userID'] == 2) {
echo("<div id='userContent'>Hello User 2</div>");
}
else {
echo("<div id='userContent'>Public, non user specific information</div>");
}
echo("</body></html>");
?>
But at this point I don't know how to make this site to a dynamic one which shows different information when Python sends a request..
Edit1 - END
This is not possible in webdriver currently. The 0 flag refers to the window, not the tab. See a discussion of this on reddit here. Another question also asked this on Stack Overflow but got no answers.
It is possible however with the much more feature rich package Selenium.
import time
from selenium import webdriver
link1="http://mysite/index.php?userID=ABC"
link2="http://mysite/index.php?userID=XYZ"
driver=webdriver.Firefox()
driver.get(link1)
time.sleep(5)
driver.get(link2)
Selenium does require some installation steps: http://selenium-python.readthedocs.io/installation.html
Regarding using requests, there's no reason you can't do a GET request so you don't have to worry about handling a post request:
import requests
url = "http://mysite/index.php?userID=ABC"
res = requests.get(url)
print(res.text)
Without seeing more of your php code or knowing more details, it is hard to say what approach is best for you but this should get you past the issues you mentioned.
I should start by saying that I am not super familiar with deploying apps. Most of my web development has been through a framework that handles everything for me, or it's been done locally. Now that I'm trying to deploy a personal project, I'm having issues.
I have a PHP website that I have deployed on Heroku. I have been having one issue after another with sessions (everything is working perfectly locally, but breaks on Heroku). I have solved most of the issues by going through about a million other posts. I'm using Memcachier, I'm making sure there is a favicon, I went through and added "exit();" after each header("location: ... ") call, etc.
Finally, I have sessions working almost perfectly except on one page. I have on this page the following code:
<?php
include('header.php');
include('functions.php');
//if id is set, flag as help needed
if(isset($_GET['id'])) {
flagHelped($_GET['id'], 1);
}
//if cancel is set, unflag as help needed
if(isset($_GET['cancel'])){
flagHelped($_GET['cancel'], 0);
}
//start the session and store userID in variables.
session_start();
$userID = $_SESSION['user_id'];
//grab all pets attached to this user.
$pets = getPets($userID);
?>
<!-- create table of pets -->
<div class='container bg-white'>
<table class='table'>
<tr><th>Picture</th><th>Pet Type</th><th>Pet Name</th><th>Zip Code</th><th> Profile </th></tr>
<?php
if($pets != null){
foreach($pets as $pet){
echo "<tr>";
echo "<td><img style='width:150px' src=\"".$pet["pictureLink"]."\"></td>";
echo "<td>".$pet["type"]."</td>";
echo "<td>".$pet["name"]."</td>";
echo "<td>".$pet["zipCode"]."</td>";
if($pet["needsHelp"] == 0){
echo "<td><button class = 'btn btn-success'>Request An Angel</button></td>";
}
else{
echo "<td><button class = 'btn btn-danger'>Cancel Request</button></td>";
}
echo "</tr>";
}
}
?>
</table>
<?php
include('footer.php');
?>
flagHelped() looks like this:
function flagHelped($petId, $status){
echo "in flag helped";
$connection = new mysqli(//credentials here);
$connection->query("UPDATE Pets Set `needsHelp`=".$status." where `petId`=".$petId.";");
$connection->close();
return;
}
It's a pretty simple page that prints a list of pets associated with the user that is logged in, and prints a button that redirects back to the current page as a get request with a URL variable.
The first time the pages loads (with no URL variable), there is no issue. After clicking a button, it calls the flagHelped() method, gets all the way through, saves properly to the database and returns. However, session_start() doesn't seem to do anything on return and it never gets to getPets();
I have put debugging print statements pretty much everywhere, and I have reordered the page in different ways. If I set the session before calling flagHelped(), I am able to print the $userID variable, but once I return from that function (which is in functions.php), $userID is no longer valid. Since I didn't need any of the session variables for that function, I decided I would just call the session variables after I returned. But even that isn't working.
Again, I'm sorry if I'm asking a dumb question here, I've been at it for hours and I'm at my wit's end.
Side Note: I am aware that there might be security risks on this page. This is for an application I built in less than 16 hours at a hackathon, so I'm not worried about the security risks. I'm purposely putting up how far I got before the code turn-in time. The database is filled with fake data and I have a disclaimer where I link to it saying not to use real information because of potential risks.
Edit: Adding pictures:
First time going through page (no URL variable) with echo statements
Second time going thorugh page (with URL variable) with echo statements
Ok, so I finally figured it out. I'm posting here in case any one else runs into this issue and comes across my post.
This worked locally and not on heroku and I couldn't figure out why. It turns out it's because I was trying to store images locally on heroku's server. When I stored them locally in my own project, they would stay in the folder that I saved them. When I stored them locally on heroku (if a user uploaded a picture on the heroku url while deployed), once my application slept after 30 minutes of inactivity, it would delete the picture.
What was happening was that my project couldn't find that image, and for whatever reason, that caused a session invalidation. Locally, all worked fine (even without being able to find the image), it only stopped working once deployed on heroku. I manually deleted those records from the database, and that page worked perfectly again.
(Now I'm looking into heroku storage options for projects to help permanently solve the problem.)
This may be hard to help me with but I'm out of options and have no hair left so here goes;
I have this simple part in my program where if a check box is disabled and the user is using the site on a device like an iPad they will get an alert box popup if they touch the check box. The problem that I'm having is that it works as expected on one domain but then on another domain it just flashes very quickly then goes away.
Because I don't have a Mac computer I can't use the Safari Web Console installed to see if any errors are coming up.
Here's the code to generate the alert;
if ($device == 'TAB') {
echo "<div id='" . preg_replace('/[^a-zA-Z0-9]/', '', $menu_name) . "OV'
class=\"overlay\" onClick=\"alert('My message');\"></div></div>";
} else {
echo "</div>";
}
Any ideas of why this would work in one place and not the other and anything that I can do to try to get the iPad to give me more info to what's going on here?
Here is where it works, interactive-floor-plan dot com/ifp.php?width=633&ProductID=1
and here is where it doesn't
plangator dot com/demo/ifp.php?width=633&ProductID=1
Your code seems completely fine to me, although your echo is a little bit unclear, because it's on one line. The problem should be somewhere else on your page. Try to find out what's happening with firebug. Here's a SO post about it.
iPad firebug lite or similar
Both links on that page seem useful to me.
Good luck!
I am completely stumped on this one. COMPLETELY stumped.
I'm building the framework for an ad network. While prototyping, I did most my building at Kodingen. Everything worked fine over there.
I just migrated to a new host, though, and I've got this one weird problem. Weird.
Bear with me as I explain this.
The ads for my ad network are placed through a code snippet that the user places on his site. Here's the code snippet:
<script type="text/javascript">
document.write('<scr' + 'ipt type="text/javascript" src="http://mysite.net/ad_engine.php?pid=333"></scr' + 'ipt>');
</script>
And, after PHP processes the request, here's the output on the ad_engine.php page:
document.write("<div class='adframe' style='min-width:250px; min-height:100px;'><a href='click.php?adid=4224&pid=333' target='_self''><img src='http://mysite.net/ads/image.png' border='0' class='adimage' style='min-width:125px; min-height:100px;' /></a><span class='adtext'><a href='click.php?adid=4224&pid=333' target='_self''>This is the ad contents right here</a></span></div>");
This method worked fine when I was developing on Kodingen. The ad appeared on any page I placed this snippet on. But, since having migrated to my new server - and not having changed anything - this method won't work.
ON THE NEW SERVER: ad_engine.php, when typed directly into the address bar, shows the ad like usual. But when it's loaded onto any other page via that first code snippet I showed you, the ad won't appear. Strangely enough, the OLD ad_engine.php file - the one on my old host - still works fine even if I load it onto a page on my new host. Follow?
Although no ad appears, I know that the ad_engine.php page, the one on my new host, I know that it IS being processed, because MySQL changes are made like they're supposed to.
I've tried to be as clear as I can in explaining this problem, if you've got any questions just let me know.
Help?
Already tested a caching problem? Maybe your new host has different cache settings?
Try adding some random number to the .php call:
document.write('<scr' + 'ipt type="text/javascript" src="http://mysite.net/ad_engine.php?pid=333&x=RANDOM_NUMBER_GOES_HERE"></scr' + 'ipt>');
I'm having issues with a application that I am writing that uses Dojo and Zend Framework. The issue only effects Internet Explorer 6, other versions of IE, ff, chrome and safari work fine with no issues.
When IE6 lands on the login page it crashes with the send details to microsoft dialog box. The login script uses dojo to provide some validation for the users to ensure that their passwords are formatted correctly etc.
I've seen on some forums that addOnLoad() function call in dojo could be the cause and a window.setTimeout() would help. http://www.dojotoolkit.org/forum/dojo-core-dojo-0-9/dojo-core-support/dom-manipulation-addonload-crashes-ie6
The problem I have is how to manipulate the dojo header that we have in the layout.phtml in the application. We currently have in the file this code in the header.
<?php
$this->dojo()->setLocalPath($this->baseUrl().'/javascript/dojo/dojo.js');
$this->dojo()->addStylesheetModule('dijit.themes.tundra');
echo $this->dojo();
?>
This produces the following in the html.
dojo.require("dijit.form.ValidationTextBox");
dojo.require("dijit.form.Button");
dojo.require("dojo.parser");
dojo.addOnLoad(function() {
dojo.forEach(zendDijits, function(info) {
var n = dojo.byId(info.id);
if (null != n) {
dojo.attr(n, dojo.mixin({ id: info.id }, info.params));
}
});
dojo.parser.parse();
});
var zendDijits = [{"id":"username","params":{"regExp":"[a-z0-9_\\+-]+(\\.[a-z0-9_\\+-]+)*#[a-z0-9-]+(\\.[a-z0-9-]+)*\\.([a-z]{2,4})$","invalidMessage":"Please enter a valid email address","trim":"true","required":"true","dojoType":"dijit.form.ValidationTextBox"}},{"id":"password1","params":{"trim":"true","lowercase":"true","regExp":"^.*(?=.{6,})(?=.*\\d)(?=.*[a-zA-Z]).*$","invalidMessage":"Invalid Password. Password must be at least 6 alphanumeric characters","required":"true","dojoType":"dijit.form.ValidationTextBox"}},{"id":"submit","params":{"label":"Login","dojoType":"dijit.form.Button"}}];
How can I change this to try and add the fixes mentioned in the link, or is there another way to write this without IE6 crashing all the time?? I would prefer to fix this than remove all the client validation, just in case the client is using IE6.
thanks...
Can you reduce it down until you find what is crashing IE6? Save off your output as static html, confirm it still crashes IE and start removing code. Take that addOnLoad out altogether - does it still crash? if not, take out the forEach, and so on. Start removing elements from zendDijits array - is there one in particular that causes the trouble?
Is this a stock IE6? Any plugins/addons?
Your php there should be producing a script element to pull dojo.js. You've got soemthing wierd going on - that Zend code is known to work so we need all the information if you want to solve this.