mmcdonald 28 Posting Pro

Yeah it does work (facepalm) - It was the structure of my includes causing the issue. My final code:

<a data-toggle="modal" 
   data-target="#loginModal" 
   id="loginLink" 
   href="javascript:;">Login</a>

<a data-toggle="modal" 
   data-target="#loginModal" 
   id="registerLink" 
   href="javascript:;">Register</a>

<script type="text/javascript">

    $("#loginLink").click(function(e) {
      $("#tab_3_2").removeClass("active");
      $("#tab_3_1").addClass("active");
    });

    $("#registerLink").click(function(e) {
      $("#tab_3_1").removeClass("active");
      $("#tab_3_2").addClass("active");
    });

</script>   

Thank you Jorge!

mmcdonald 28 Posting Pro

Progress!

Okay I like what you're doing here but it wasn't working... I tried this:

<script>
    $("#registerLink").click(function(e) {
      $("#tab_3_1").removeClass("active");
      $("#tab_3_2").addClass("active");
    });
</script>

<a data-toggle="modal" 
   data-target="#loginModal" 
   id="registerLink" 
   href="javascript:;">Register</a>

tab_3_1 is the tab in the modal that's usually open by default. When the link is clicked I want tab_3_2 to be active by default. Any more suggestions? I've also just started reading your JQuery guides @ itgeared.com -> thanks!

mmcdonald 28 Posting Pro

That's exactly the case mate, class="active". I'm obviously having a blonde moment because surely that restricts me to the use of JS? Is there no way HTML can handle this? Would you be as kind to show an example of how I could target a tab in a URL, even if it has to use JQuery (I SERIOUSLY need to sit down and study JS once and for all).

mmcdonald 28 Posting Pro

Boo! Yeah sorry it's me again...

I'm launching a modal with:

<a data-toggle="modal" data-target="#loginModal" href="javascript:;">Register</a>

The modal has 3 tabs. It should usually open on tab one (it does), but in this instance I would like it to automatically open on tab 2 when a particular link is followed... so here is the 'logic':

data-target="#loginModal#tab_2" 

Now the reason I say logic is because that obviously won't work. The real question here is - how does one make it work? To A) target a specific modal and in the same instance B) target a specific tab.

Many kudos!

Michael

mmcdonald 28 Posting Pro

ello ello,

I'm currently calling a file using JQuery but every so often (very randomly) Google Chrome would crash (Just the tab, not the browser). Soooo I began investigating and discovered that browsers cache AJAX calls? This would mean that the tab would be using a stupid amount of memory that would of course cause issues. I also discovered that I should be aborting all 'AJAX' calls before I call this primary one. How on earth..?

Anyway, to see if this was the case I added a random number to the query string on the file call:

function reloadResponses() {
    $('#divid').load('load.php?creatorid=<?php echo $topicInfo['id']; ?>&RandomNumber=' + Math.random());                    
}
setInterval(reloadResponses, 10000);

Now - the issue hasn't reoccured as of yet (I'm still waiting), but I'm very interested and trusting of the feedback from this community. Any suggestions? I would also be glad to read any suggestions for resources regarding tidy and efficient AJAX calls - the ones I seem to be pulling up haven't been updated since the birth of christ himself.

Cheers,
Michael

mmcdonald 28 Posting Pro

I don't know why I couldn't visually see what you've just said! Thanks Jorge you've done it again! I've rebuilt my code to the following, and it works a treat:

var button = document.getElementById('createNew');
var div = document.getElementById('newForm');

    div.style.display = 'none';

    button.onclick = function() {
        if (div.style.display !== 'none'){
            div.style.display = 'none';
        }else {
            div.style.display = 'block';
        }
    };

The difference is simple, I've set div.style.display = 'none'; on page load, rather than just in the true section of the if statement.

Thanks again,
Michael

mmcdonald 28 Posting Pro

Hi all,

I have a hidden division that is supposed to appear when the button, as shown below, is clicked by the user. The division is hidden on page load, and does actually appear when the button is clicked, but nothing happens on the first click. To clarify, you have to click the button twice for the div to appear the first time - and then only once after that to make it disappear and reappear again and again. Why does it need that second click to work the first time? How does someone fix this?

I've done some research but all I seem to be reading is to 'reverse the if statement'. I didn't believe it, but tried it - obviously with no success.

Thanks in advance for any help.

HTML
<button type="button" class="btn green" id="createNew">Create</button>

<div class="newForm hide" id="newForm">
    <!-- Hidden division content  -->
</div>
Javascript
var button = document.getElementById('createNew');
button.onclick = function() {
    var div = document.getElementById('newForm');
    if (div.style.display !== 'none') {
        div.style.display = 'none';
    }
    else {
        div.style.display = 'block';
    }
};
mmcdonald 28 Posting Pro

Ugh, what a nervous homepage.

Can't you just deconstruct that webpage? As for the video, low low-res is probably the key.

I understand what you mean by nervous, but I think it's effective when your target audience is usually distracted by something as dull as a fly; so this design should result in a great conversion rate.

I am going to deconstruct it now - I just wondered if anyone had some personal tips. I knew the answer was low res... I just didn't want to believe it :)

Thanks for responding,
Michael

mmcdonald 28 Posting Pro

Hi all,

I have been looking into making a website that has a timelapse video as its background, something similar to: http://www.thecowisgonemoo.com/nervaq/index-video.html

The question is - how does one set a video as the background of a website!? Some of these timelapse videos are 100's of MBs or even 1000's! Is there any off-the-bat advice from the DW community?

Thank you,
Michael

mmcdonald 28 Posting Pro

You should have a workspace within the IDE (NetBeans), this is where your project files should be located. If you're using WAMP or XAMPP then I'd suggest setting your NB workspace to the root folder in your XAMPP or WAMP directories. This will allow you to develop 'live' on your local environment.

I use the term workspace lightly, as I believe they're actually called Project Groups in the NetBeans IDE. Click File and then click Project Groups. You can manage them here.

Good luck,
Michael

mmcdonald 28 Posting Pro

Sorry for missing the recent discussion.

That sucks, I've seen so many funky dropdowns though where there is more spacing, different font sizes, bold options that aren't indented and so on. AFter a little more research it appears that they can't be stryled because they are complied by the browser and not HTML. The only way around this is to use a plugin that complies its own dropdows such as:

http://labs.abeautifulsite.net/jquery-dropdown/

That can be styled and it's being built from lots of components by JQuery.

mmcdonald 28 Posting Pro

Hi all,

I'm trying to add spacing between the <option> tags by padding, height and margin - yet none have worked. Does anyone have any ideas? It's the simple things that stop me in my tracks haha. All of the options look cramped up and untidy, I'd like to give them room to breathe :)

M

mmcdonald 28 Posting Pro

lol believe it or not I was... the issue was that I wasn't writing echo or print before hand... #TIRED.

Cheers all,
M

mmcdonald 28 Posting Pro

Hi all,

This is so simple and it's driving me mad. I've done it many of time before but at this moment in time - blank!

How does one display the text: &copy; and stop it from changing to a copyright symbol?

Thanks,
M

mmcdonald 28 Posting Pro

Just a bit more info:

I have a new web application that will be made available at domain2.com. I would like its users to be able to white-label by using their own domain name. I am using domain1.com for testing.

Currently, www.domain1.com is successfully reaching domain2.com. However, domain1.com (without www.) isn't reaching domain2.com and simply isn't being found.

Michael

mmcdonald 28 Posting Pro

I'm sorry mate but you're going to have to speak to me in lehmans terms as I must be missing something obvious..?

mmcdonald 28 Posting Pro

Hi Jorge, sorry but I must have been unclear. domain2.com is the domain of my web service. domain1.com is the domain name owned by a customer who has chosen to white-label. I have no control over domain1 whatsoever.

What does the customer have to do in order to direct all of their web traffic to both www.domain1.com and domain1.com to domain2.com?

I understand that they must create a CNAME record with the hostname of www which alises to domain2.com but what else? There must be something else they have to change in order to allow domain1.com to work without the subdomain of www.

I have everything else solved.

Michael

mmcdonald 28 Posting Pro

Had no idea where to stick this, so I'll try here :)

I have created a CNAME for domain1 to direct traffic to domain2 that has the value of * (so *.domain1.com goes to domain2.com). This works if the user types www.domain1.com but not if they just type domain1.com which as you are probably aware most users do.

Any ideas how to fix this as simply as possible? My clients will have to add this solution to their own DNS records.

Thank you,
Michael

mmcdonald 28 Posting Pro

No worries Vivo, whatever your choice - good luck!

Perhaps you could combine the two and develop a game or training app for investment banking / market trading :D who knows!

Michael

mmcdonald 28 Posting Pro

Just an update - a friend believes this could be down to not releasing resources such as system memory causing it to build up and then crash the browser tab. But chrome seems to be a a steady 138MB - does this sound likely?

Apart from reloading the file containing the code - is there anything else I should be doing/releasing/closing etc?

mmcdonald 28 Posting Pro

Hi all,

I'm using AJAX to reload a div within my script. However it frequently causes the browser to crash. It's happened on two different local environments and I've only been able to test using chrome. Chrome presents this screen: http://i.imgur.com/wq2v7SJ.png

The code used to reload the div is:

<script type="text/javascript">

jQuery(document).ready(function() {
           reloadResponses();

});

function reloadResponses() {
            $('#responses').load('loadcomments.php?id=<?php echo $id;?>&creatorid=<?php echo $topicInfo['id']; ?>');                    
        }

setInterval(reloadResponses, 4000);
</script>

Does anyone know how to resolve this issue?

mmcdonald 28 Posting Pro

No prit they're on two different machines :) I should have said that

mmcdonald 28 Posting Pro

Hi Atli,

In regards to the mix of OOP and procedural I'm not concerned one bit. The code was written 100% procedural and I was in the process of switching everything over to OOP. I understand what you're saying completely, but it's unrelated to the issue at hand.

In regards to verifying the results of a call are you simply referring to:

if($responseData){
      //code
  }else{
      //code
  }

If so then again I understand what you're saying and again it has nothing to do with the issue at hand. This code was in place, I did however remove it in order to dig into what exactly wasn't working in the change from XAMPP to WAMP.

Thanks for your response though,
Michael

mmcdonald 28 Posting Pro

Hi all, the following PHP MysSQLi query works in XAMPP but not in WAMP:

    <?php
    include('../../inc/config.php');
    $mysqli = mysqli_connect($config['host'], $config['user'], $config['pass'], $config['db']);
    $responseQuery = "SELECT tr.id as trid,tr.topicid,tr.usersid,DATE_FORMAT(tr.date_added,'%b %d, %Y %H:%i') 
                      AS format_date_added,tr.date_added,tr.response,tr.status,
                      t.id, t.usersid as creatorid,
                      u.id, u.authuser, u.memtype, u.fn,u.ln,u.avatar 
                      FROM topic_response tr
                      LEFT OUTER JOIN topic t ON t.id=tr.topicid
                      LEFT OUTER JOIN users u ON u.id=tr.usersid 
                      WHERE tr.topicid='".$_GET['id']."' 
                      ORDER BY tr.date_added";
    $responseData = $mysqli->query($responseQuery);
    $responseCount = mysqli_num_rows($responseData);

In xampp the script works a treat. In WAMP I get this very common error:

 Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in ... on line 14

That error is talking about this line:

 $responseCount = mysqli_num_rows($responseData);

I have the MySQLi extension, I've checked that in my php.ini file and it's enabled. Any ideas people? I've just made the switch from XAMPP to WAMP as XAMPP was having a few issues randomly and corrupting my databases. WAMP works great... apart from this issue.

Michael

mmcdonald 28 Posting Pro

Whats the output from:

$row_cnt = mysqli_num_rows($result);
echo $row_cnt;

?

mmcdonald 28 Posting Pro

Your error states that the problem occures on line 200, but you've only posted 103 lines of code? Could you post all of the code please.

mmcdonald 28 Posting Pro

I agree with Simplypixie and always believed the WordPress programmers should have built 3 models. 1 for bloggers. 1 for webmasters. 1 for webmasters who also like to blog. :)

mmcdonald 28 Posting Pro

The only way to get an answer for this question is to do some tests for yourself, or perhao an automated tester to colelct a few thousand results. In each test record exactly how much bandwidth is used, then multiple that by expected traffic and voila.

FYI this is a breach of the forum rules:

I posted this message under both Web Development (Web Design, HTML, and CSS) and under (JAVASCRIPT, DHTML, and AJAX) as I was not sure where to post it.

mmcdonald 28 Posting Pro

It would be great to see DaniWeb recruit official video moderators and hit mediums such as youtube with the recordings. Even if it was a video blog that was run for 6 months. If there is a justifiable difference in traffic sourced from the likes of YouTube then it would be continued? Thoughts?

mmcdonald 28 Posting Pro

Glad to hear it Dani :D

mmcdonald 28 Posting Pro

Okay for anyone who needs this in the future. It's come down to me creating a wildcard CNAME record and then telling users to point their domains to bob.mywebsite.com. Then I'll use code like this to collect the value of the subdomain in order to pull up the correct site settings for that user:

$url = '$_SERVER["REQUEST_URI"]';
$parsedUrl = parse_url($url);
$host = explode('.', $parsedUrl['host']);
$subdomain = $host[0];

Using bob.example.com, $subdomain would have the value of bob.

Thanks to JorgeM for helping my get my head around this process!

mmcdonald 28 Posting Pro

Well done, and sorry I couldn't help. You might want to leave this open for the next day before you mark it as solved as someone might spot what's wrong with your original code. To be honest I think the problem probably existed outside of the snippet you posted as I can't see anything wrong. At least you have it working now!

mmcdonald 28 Posting Pro

Hey hey!

I'm about 70% into completing a web application that will allow our clients to white label our service. They can then in turn resell the service to their audiences without any involvement from me or my colleagues. Now, something I need to figure out is how to allow my clients to set their own domain name from within their settings so that their users can reach our service using our clients custom domain?

Our clients are not permitted to see the source at all, so rather then allowing them to download the package I'd like to allow them to setup a custom domain name that points to our webserver. Just an insight as to why this is pretty much my only option.

I'm currently thinking that the best way to do this is to use mod_rewrite or possibly CNAME records (which I believe can be modified automatically using my registrars API?).

Could I please have some feedback from the seasoned programmers amoungst you? All I would want my client to have to do is to A) set their domain name in their settings and B) set an IP address in their chosen domains A records. Then after 12-72 hours it should be active.

Example:
1) Bobs audience currently visits bob.mybrand.com, but he wants to use bob.com!
2) Bob goes into his settings and enters bob.com into the custom URL field.
3) Bob is then presented with an IP address (or should he get name servers?) …

mmcdonald 28 Posting Pro

And what's its value?

mmcdonald 28 Posting Pro

If you're only getting 1 row back from $query? Where is $count coming from? It looks okay to be hinest unless I'm missing something too. What's the value of $count?

mmcdonald 28 Posting Pro

Marking as solved was a miss click, sorry! As for server security that's not my concern. I would like to ask anyone to attempt a DDoS, they'll fail miserably - I've got a dedi in the London Docklands Datacentre as I've worked there before and I'm close friends with most of the team :) I'm in the rack right next to Her Majesties Revenue and Customs! haha As the topic is titled, my focus is application security, but thanks for the suggestion.

Broj1 - great post, quite an interesting list :)

mmcdonald 28 Posting Pro

Disadvantages are lack of control to users who have no or little programming experience. The framework can throw a user right off! Another disadvantage is that it's a very well-known framework meaning that hackers and attackers find it easy to work around basic security - there are great plugins to make a blog almost unbreakable - again it comes down to user experience and research.

Upgrading your wordpress blog is required to use the latest plugins. Failure to do so and then installing a plugin that isn't compatible can ruin your blog (I've even seen many instances of people closing down their blogs because malicious plugins have ruin their data ... their own fault really). People also go plugin crazy which devours resources, keep it under control :)

Another disadvantage is SEO - WordPress, unless you know what you're doing, is an SEO ASSASSIN! Repeat tagging without noindex can lead to crawlers registering duplicate content time and time again - it can kill your SEO.

There aren't many disadvantages and I honestly think the advantages seriously outweigh the disadvantages.

Goodluck!

mmcdonald 28 Posting Pro

No worries, well done! Make sure you mark this topic as resolved :)

mmcdonald 28 Posting Pro

I have a series of index files in directories that contain a header redirection to the site index :P

And as for session permissions..?

mmcdonald 28 Posting Pro

@Benjamin

@mmcdonald programmers never say never

You'll actually find that I haven't used 'never' once on this page :) I actually said good luck!

Michael

mmcdonald 28 Posting Pro

You can temporarily use a service provider such as GMail, Yahoo and Hotmail for testing your script, even locally.

I always use the PHPMailer class (It's active on 3 projects of mine) and it hasn't let me down once.

Michael

mmcdonald 28 Posting Pro

Cheers diafol, I gather thats done by sanatising?

mmcdonald 28 Posting Pro

I have come across securing/filtering AJAX calls... and I am making AJAX calls in my application - thoughts? http://stackoverflow.com/questions/7953714/php-help-secure-filter-ajax-calls Could I have a seasoned programmers opinion regarding the answer in that article?

In fact I've just read about sanatising which should obviously be my next step. I gather that sanatising is simply the checking of variable values to ensure they are what's expected by using functions such as settype() and isnumeric()? If so, then I haven't sanatised a single database input :L

mmcdonald 28 Posting Pro

I've focused my night on better grapsing authentication security and believe I have made good progress. To date I have simply relied on SHA1 hashing and prepared statements - not much, right... So I knew it was time to pick up some new skills.

What I came across was very new, BlowFish, which I have never heard of, and salting, which I have heard of but not deeply looked into before. I was amazed about how simple they were to grasp! I'm now using a salt, using blowfish and then encrypting the whole lot with PHPs crypt() function. Woo!

What I would like to know is - what else can be done, whether basic or very very advanced, to further secure a web application, other than transport layer such as SSL certificates.

I've considered the adoption of checking for perculiar characters within fields to increase the difficulty for attackers but with the use of prepared statements I believe this is no longer a problem?

What does someone do next to increase security? Is there something that can be done to secure sessions? Do sessions need securing beyond their core security built into PHP? I've become really interested in security now and would love to hear your suggestions. In the mean time I will be googling PHP web app security :P

Michael

mmcdonald 28 Posting Pro

Thanks for sharing Dani! It's nice to see Google make a step in the right direction for once. Perhaps they've finally realised how much they've slipped over the passed 36 months in regards to their AdWords/AdSense. I personally feel they got too comfortable with their 'legacy' layout, I also can't agree more about how complicated they made a system that could have been so simple.

Looking forward to checking out the new system.

Michael

mmcdonald 28 Posting Pro

Hi and welcome! If anyone asks where you came from tell them mmcdonald sent you... it may not be true (It isn't.. but they don't know that), and I'll send you a cookie. That way you get a cookie and I get a pat on the back :3

DaniWeb is a great place to learn and over the last year I have picked up so much. In fact a year ago I didn't really know anything about programming at all!

If you want the best responses just be clear with your questions and they will usually just roll in. Don't be lazy though and make sure you have a go at something first! No one will mock you here for posting weak or insecure code; so be confident!

Good luck with you learning,
Michael

Dani commented: Great advice +0
mmcdonald 28 Posting Pro

No worries. I'm a fan of POP myself and as your daughter is a paying customer I belive they should be providing a much better serivce; telling you to use IMAP is not customer support but a weak work around. I personally would stand my ground and strive to have POP3 operational - that is however totally up to your daughter. Good luck with it!

Michael

mmcdonald 28 Posting Pro

No worries JorgeM, they've been quite useful as I've been asked many o' time before to recommend a 'good' (<---lol) free web host :D

mmcdonald 28 Posting Pro

Yeah that's true - but you didn't say that above :D Still not a very 'acceptable' method of doing business - but each to their own! You are losing focus on your end goal however, and that was to build a responsive website. You shouldn't lose this focus - keep working towards a totally responsive website! It'll pay off in the end

mmcdonald 28 Posting Pro

Woah... that's a terrible move O.o At worst you should remove the image and have a solid background...