Web Development Questions That Don't Need Their Own Thread v2
3,079 replies, posted
[QUOTE=compwhizii;30970962][URL]http://net.tutsplus.com/tutorials/php/user-membership-with-php/[/URL]
Look harder[/QUOTE]
Oh man, that tutorial just fucks best practices right up the ass doesn't it.
[QUOTE=deadeye5362;30973426][php]$pageArray = Array('index', 'mhm');
$directory = '/testmore/'; // Directory if in one. Otherwise, leave it as '/'.
$uriArray = explode('/', strstr($_SERVER['REQUEST_URI'], $directory, '' ));
if (in_array($uriArray[0], $pageArray)) {
dostuff($uriArray[0]);
} else {
echo '404';
}[/php]
No no need to loop.[/QUOTE]
It comes out as 404 for anything.
[editline]8th July 2011[/editline]
[quote][B](User was permabanned for this post ("Facepunch is not your personal army of hackers." - daijitsu))[/B][/quote] :v:
Whats the best place to get textures for the backgrounds of websites? I have been using only gradients and solid colors lately and need some nice textures.
[I]Thanks.[/I]
Wordpress question :suicide:
Part of work experience.
[code]<?php
/* CONFIG */
/* ASK.COM COMPILER /*
/* As ask.com search spider no longer accepts dynamic URLs, this outputs the dynamic URL content into a static one for Ask */
/* */
/* CONFIG */
$url='http://www.ecotecture.co.uk/index.php?xml_sitemap=params=';
$options = array( 'http' => array(
'user_agent' => 'spider', // who am i
'max_redirects' => 1, // stop after 10 redirects
'timeout' => 120, // timeout on response
) );
$context = stream_context_create( $options );
$xml=file_get_contents($url, false,$context) or die('Unable to get XML sitemap from plugin');
$file=fopen($sitemap_yrl,'w') or die('Error opening sitemap.xml');
fwrite($file,$xml);
fclose($file);
$filec=file_get_contents($sitemap_yrl);
if($filec==$xml){
$xml1=str_replace("<","[",$xml);
$xml2=str_replace(">","]",$xml1);
echo "Sitemap build successful<br /><hr /><div id='xml'>";
echo $xml2;
}
else {
echo "Unable to build sitemap.";
}
$dir = dirname(__FILE__);
echo "</div><br /><hr /><br />";
echo "Internal dir " . $dir . "\sitemap.xml";
?>
<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js'></script>
<script>
var xml=$('#xml').text();
var xml1=xml.replace(/\[/g,'<');
var xml_final=xml1.replace(/\]/g,'>');
$('#xml').text(xml_final)
</script>[/code]
SEO-wise, their site is working fine - #1 in most sites EXCEPT for ask.com, because Ask's submission engine doesn't accept dynamic urls.
So this fetches the XML sitemap from the dynamic url and saves it to a file, BUT - where the hell do I put it in wordpress? :L
[QUOTE=RELAXiN;30983225]Whats the best place to get textures for the backgrounds of websites? I have been using only gradients and solid colors lately and need some nice textures.
[I]Thanks.[/I][/QUOTE]
Best ones are made with photoshop. look into that.
[editline]8th July 2011[/editline]
and that other one with yellow logo but made by adobe.
If I were to put a small adsense ad on a machinima site that gets ~15k views a day, how much do you think I would get?
[editline]8th July 2011[/editline]
Woah, I just added it to the feedburner feed, and I've already made $0.01 with 107 impressions!
[editline]8th July 2011[/editline]
nevermind, i figured it out myself, about $7.50 a day with google's early estimates (it's been on there for an hour or two)
Does anyone know any effective ways of detecting if a user has a toolbar installed using javascript?
Currently I'm doing an awful method:
[code]
var numErrors = 0;
$(document).ready(function(){
document.write("<object classid='pluginclassid' onerror='numErrors++'/>");
if(numErrors!=2) // plugins that don't exist return two errors.
alert("Plugin Installed!");
});
[/code]
That's just pseudo of my actual code, I don't have the exact at the moment. I was just wondering if there was a less hacky way of doing it. (I only need this to work on IE.)
[QUOTE=StinkyJoe;30976639]Oh man, that tutorial just fucks best practices right up the ass doesn't it.[/QUOTE]
Could you point out which ones those are? I quickly looked trough it and it seems to be ok, not that I am an expert. (Except he didn't prevent XSS attacks.)
[editline]8th July 2011[/editline]
[QUOTE=isogamete;30993464]If I were to put a small adsense ad on a machinima site that gets ~15k views a day, how much do you think I would get?
[editline]8th July 2011[/editline]
Woah, I just added it to the feedburner feed, and I've already made $0.01 with 107 impressions!
[editline]8th July 2011[/editline]
nevermind, i figured it out myself, about $7.50 a day with google's early estimates (it's been on there for an hour or two)[/QUOTE]
That is 200 dollars in a 28 day month! I would be happy with that much!
How would I go about removing the privilege to see a file itself? I don't want people to see a .swf file unless they're on the page embedding it, is it even possible?
[QUOTE=FlakTheMighty;30997715]How would I go about removing the privilege to see a file itself? I don't want people to see a .swf file unless they're on the page embedding it, is it even possible?[/QUOTE]
if you use Apache, you can use the referrer to see if it came from your site
[QUOTE=FlakTheMighty;30997715]How would I go about removing the privilege to see a file itself? I don't want people to see a .swf file unless they're on the page embedding it, is it even possible?[/QUOTE]
You can check the referrer but that's sketchy and might not always work.
[editline]8th July 2011[/editline]
[QUOTE=Ac!dL3ak;30997832]if you use Apache[/QUOTE]
Only if you use Apache?
[QUOTE=compwhizii;30997858]You can check the referrer but that's sketchy and might not always work.
[editline]8th July 2011[/editline]
Only if you use Apache?[/QUOTE]
I don't know if it would work on other things like apache, and if I said it did, I'd look like an ignorant twit if it didn't
[QUOTE=ThatLuaCoder;30996731]Does anyone know any effective ways of detecting if a user has a toolbar installed using javascript?
Currently I'm doing an awful method:
[code]
var numErrors = 0;
$(document).ready(function(){
document.write("<object classid='pluginclassid' onerror='numErrors++'/>");
if(numErrors!=2) // plugins that don't exist return two errors.
alert("Plugin Installed!");
});
[/code]
That's just pseudo of my actual code, I don't have the exact at the moment. I was just wondering if there was a less hacky way of doing it. (I only need this to work on IE.)[/QUOTE]
I think the way you're using (create an <object> and check if it worked) is the only method that really works in IE, since it doesn't support the standard way of checking.
What the hell am I doing wrong here? probably something simple
[code]$('input').focus(function(){
alert('Focused');
$(this).attr('value','');
});[/code]
Doesn't even trigger the alert.
If it helps, here's the full js.
[code]<?php header('Content-type: application/json'); ?>
/* (C) Ciache Designs | Freelance Web Design /*
<?php echo "/* Current page: ".$_GET['p']." */";?>
/* Slider (C) Nivoslider under GNU publicuse */
/* */
/* Page-related variables */
var page="<?php echo $_GET['p'];?>";
/* Usability Tweaks */
$('input').focus(function(){
alert('Focused');
$(this).attr('value','');
});[/code]
[QUOTE=SataniX;31007352]What the hell am I doing wrong here? probably something simple
[code]$('input').focus(function(){
alert('Focused');
$(this).attr('value','');
});[/code]
Doesn't even trigger the alert.
If it helps, here's the full js.
[code]<?php header('Content-type: [B]application/json[/B]'); ?>
/* (C) Ciache Designs | Freelance Web Design /*
<?php echo "/* Current page: ".$_GET['p']." */";?>
/* Slider (C) Nivoslider under GNU publicuse */
/* */
/* Page-related variables */
var page="<?php echo $_GET['p'];?>";
/* Usability Tweaks */
$('input').focus(function(){
alert('Focused');
$(this).attr('value','');
});[/code][/QUOTE]
that's not json
json:
[code]{
"page": "<?php echo $_GET['p']; ?>",
"tweaks": function(){
$('input').focus(function(){
alert('Focused');$(this).attr('value','');
});
}
}[/code]
of course, you'll have to call the 'tweaks' function to bind the input focus thing. Or you could make it into a javascript file (I think) by changing the Content-Type to javascript and the DataType property on the ajax request to "script".
I have something that I always wanted to know.
If i have a paragraph with url link but you don't add the <a> or [url](for forum), how do you make it so something detects if it is url link then add that<a> or [url] tag infront and back?
[QUOTE=zzlawlzz;31009134]I have something that I always wanted to know.
If i have a paragraph with url link but you don't add the <a> or [url](for forum), how do you make it so something detects if it is url link then add that<a> or [url] tag infront and back?[/QUOTE]
with javascript?
[editline]9th July 2011[/editline]
you can use a regular expression
Hey guys I was on holiday the last week and after coming back I noticed the subforum links changed (again...).
Has anyone bothered writing a greasemonkey script yet to bring back the old style?
[QUOTE=Ac!dL3ak;31008736]that's not json
json:
[code]{
"page": "<?php echo $_GET['p']; ?>",
"tweaks": function(){
$('input').focus(function(){
alert('Focused');$(this).attr('value','');
});
}
}[/code]
of course, you'll have to call the 'tweaks' function to bind the input focus thing. Or you could make it into a javascript file (I think) by changing the Content-Type to javascript and the DataType property on the ajax request to "script".[/QUOTE]
Other javascript works fine.
Is there any way I can view traffic data for 1 particular web page on a site I don't own?
Thanks
[QUOTE=SataniX;31016389]Other javascript works fine.[/QUOTE]
how weird is that
I still say you do the datatype property as script instead of json
[QUOTE=Ac!dL3ak;31008736]that's not json
json:
[code]{
"page": "<?php echo $_GET['p']; ?>",
"tweaks": function(){
$('input').focus(function(){
alert('Focused');$(this).attr('value','');
});
}
}[/code]
of course, you'll have to call the 'tweaks' function to bind the input focus thing. Or you could make it into a javascript file (I think) by changing the Content-Type to javascript and the DataType property on the ajax request to "script".[/QUOTE]
That's still not JSON, you can't store functions in JSON.
Addressing the problem, the content-type headers shouldn't influence the browser enough to mistake it for JSON, it's probably still parsing it as text/javascript. As far a the issue goes, make sure you are including jQuery before the script is being called. If you are sure the script is being called after jQuery, check to see if the Javascript console (Ctrl + Shift + J in chrome) is spitting out any errors.
[QUOTE=deadeye5362;31021073]That's still not JSON, you can't store functions in JSON.
Addressing the problem, the content-type headers shouldn't influence the browser enough to mistake it for JSON, it's probably still parsing it as text/javascript. As far a the issue goes, make sure you are including jQuery before the script is being called. If you are sure the script is being called after jQuery, check to see if the Javascript console (Ctrl + Shift + J in chrome) is spitting out any errors.[/QUOTE]
in plain javascript you can, which is weird to me
Yeah, JSON is different to JavaScript, so even though they share syntax, they differ in some fundamental ways.
is it possible to convert a text string to an integer in any way?
-snip-
[QUOTE=Ac!dL3ak;31023937]is it possible to convert a text string to an integer in any way?[/QUOTE]
Yes, parseInt: [url]https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/parseInt[/url]
heh, I figured it out right after I posted it, sorry
[QUOTE=Ac!dL3ak;31030366]heh, I figured it out right after I posted it, sorry[/QUOTE]
When that happens, leave the question untouched and add your answer, it might be helpful for someone else.
Repost since nobody seemed to notice it earlier:
Is there any way/tool/site that allows me to view traffic for 1 particular page on a website which I don't own?
Thanks
Sorry, you need to Log In to post a reply to this thread.