mmcdonald 28 Posting Pro

Hi all,

I'm building a multi-tenant web application in PHP which is hosted on a dedicated Ubuntu 14.04 server (LAMP). I'm trying to figure out the simplest method of allowing my customers (SME's) to connect the application to their active directory server to authenticate users. The only issue is, I don't want all of my customers to have to whitelist my IP's on their firewall (change management will kill my sales) and I don't want them to expose their Active Directory servers to the internet.

The best I've come up with so far is setting up my own IIS server and asking all of my clients to connect to is using federation, but this is very long and very messy.

I'm happy to use a third party such as OneLogin for the task but that requires my customers to trust a third party and install a third part app on at least one of their servers. At least if I've created the connector (whatever it is) I can show this to the customers and over-document the process to provide ease of mind.

I can't help but feel like I'm missing something obvious. I don't even need to store user details as I could use ldap_bind() but this function obviously requires every customer to have their AD server public facing with either a publiv IP or a DNS A record.

It can't be this hard; can it?

mmcdonald 28 Posting Pro

Right I'm sorry the second link was perfect - looks awesome!

mmcdonald 28 Posting Pro

Exactly this - though I'm after the name of the internal component. I built my desk myself and it's quite a large set-up. I can't find a ready made frame for this desk and would most likely need to make it myself. Plus it's more fun :D

mmcdonald 28 Posting Pro

Hey all,

I'm not a mechanic and I know nothing of the topic. I am however looking to replace the legs on my computer desk with some electronic cylinders so that I can raise and lower the desk at the press of a button. The only issue is, I don't think it's a pneumatic cylinder that I'm looking for as their bore is quite small as is their stroke. They're also pretty bloody powerful and might launch the monitors in to the ceiling!

What is the name of the component I'm looking for? The description: a cylinder shaped device that extends in a single direction that can operate at the push of a button and can lift some weight (60-80kg would be ideal).

I think you get my drift... this is a small project I've been interested in screwing around with.

Thanks!
Michael

mmcdonald 28 Posting Pro

Hey thanks for that! I found this page earlier but it doesn't work in Chrome it seems, which is a massive no-go ;P

mmcdonald 28 Posting Pro

Hi all,

I've decided to work on a new project in my spare time and it involves capturing 30 seconds of video from each registered user. Does anyone have any suggestions as to the most widely accepted/compatible method of capturing video in the browser and storing it somewhere such as S3?

This is an exploratory stage, I'm googling around but would be interested to see if anyone has any suggestions on here?

All the best,
M

mmcdonald 28 Posting Pro

This is pretty decent too - forgot I had the tab open: http://css-tricks.com/quick-reminder-about-file-paths/

mmcdonald 28 Posting Pro

From your question above it's quite hard to identify what it is you're actually asking for, so I'll cover file paths in general.

1) Relative File Paths

A relative file path looking like this: <a href="link.php">Link</a> and this is because you can't see the full web address. The name 'relative' is pretty fitting as the link to the file relates to where the current file is located. Examples of relative file paths:

  1. /images/image.jpg
  2. index.php
  3. /folder1/folder2/folder3/file.php

2) Absolute File Paths

An absolute file path can look like any of the following:

  1. /home/www/public/website.com/public/css/theme1/style.css
  2. http://www.example.com/images/banners/banner1.png
  3. http://000.000.000.000/js/jquery.js

It's called absolute because it will work no matter where the current file is located because it starts looking for the referenced file from root level.

I usually always use absolute web addresses, therefore nothing breaks if I ever need to shuffle or reorganise my files and folders (as long as my assets are kept seperate so their location never changes, of course).

My web apps and sites have this typical structure:

/home/www-data/public/website1.com/public/assets/scripts
/home/www-data/public/website1.com/public/assets/css
/home/www-data/public/website1.com/public/assets/images
/home/www-data/public/website1.com/public/

My assets, such as images, classes, stylesheets and scripts are stored seperately from my applications/sites files, which start diretly in public. I can shuffle them about and do whatever I like with them as all of my file dependencies and assets are called with the absolute path of:

/home/www-data/public/website1.com/public/assets/[file_i_want_here]

I usually simplify it further by creating a variable in my config file:

$ASSETS = "/home/www-data/public/website1.com/public/assets/";

and then I can include a style.css anywhere …

mmcdonald 28 Posting Pro

I ended up getting cable time - we've got a demo kit for 2 months :)

mmcdonald 28 Posting Pro

You have to use a Javascript (or jQuery) AJAX to call a PHP script to perform a MySQL insert.

Sorry Pritaeas - you posted your response whilst I was typing mine :)

mmcdonald 28 Posting Pro

This is pretty straight-forward and is usually easier than most people think. What I would do is call a function in the onchange attribute. In the following example the onchange attribute will be watching a dropdown, so the function will be called upon when the value of the dropdown changes:

<select onchange="myFunction()">

Then in my script I could have a javascript function with a jQuery AJAX block:

function myFunction(){
    $.ajax({url:"script.php", success:function(result){

        something here to output the result, like a div update.

    }});
}

Then in script.php validate and execute your SQL query. The need to call upon another script arises from Javascripts inability to communicate with the server, unless you're using node.js, which is a totally different kettle of fish. Javascript is a client side language and everything it does is completed in the users browser. By using jQuery's Ajax we can call upon a server side script from the users browser when a change is made.

I hope this makes sense, but I didn't have much from you to work with.

See more: http://api.jquery.com/jquery.ajax/

Regards,
M

mmcdonald 28 Posting Pro

Perhaps you can have an advanced filtering system? Including calories, carbs, fat, salt and sugar etc? You can also have a membership level called 'nutritional expert' where people who know a little about nutrition can build diets using recipies on your website, and then users can review, customise and print off complete diet plans based on the data from your portal? Just a quick brain dump but it sounds like a fun project!

Perhaps recipies can have version controls? If they're improved, or modified, they increase a version, just like software does ;)

mmcdonald 28 Posting Pro

Okay chap, I'm sorry I couldn't help at all - good luck!

mmcdonald 28 Posting Pro

So you do, it was me that didn't, sorry!! :D Still reading but what you have looks fine. Have you tried using the style editor in your browser, unchecking certain styles applied on the form, fields and appended icons? I'm struggling simply because everything looks fine with the mark-up above.

mmcdonald 28 Posting Pro

Sorry for the lack of clarity.

Change this:

<div class="input-group-addon">@</div>

to this:

<span class="input-group-addon">@</span>

I'm wondering if it's a style on the division tag that's causing the issue.

mmcdonald 28 Posting Pro

Oooooo funky - can you change the tag from a div to a span please? And in the good spirit of not stealing content on the web, I'm currently reading through this: https://github.com/plataformatec/simple_form/wiki/How-to-use-Bootstrap-3-input-group-in-Simple-Form and this http://www.tutorialspoint.com/bootstrap/bootstrap_input_groups.htm

Take a look. I'll post back if I spot something important!

mmcdonald 28 Posting Pro

The example uses a horizontal form, but that's not what I want. The first column are personal details, the second company details. They can't flow like the example.

<form>
<div class="row">

    <div class="col-lg-6">
        <div class="form-group">
             <div class="input-group">
                    <span class="input-group-addon">@</span>
                    <input runat="server" class="form-control" ... />
              </div>
              <div class="input-group">
                    <span class="input-group-addon">@</span>
                    <input runat="server" class="form-control" ... />
              </div>
              <!-- more personal fields... -->
         </div>
    </div>

    <div class="col-lg-6">
        <div class="form-group">
             <div class="input-group">
                    <span class="input-group-addon">@</span>
                    <input runat="server" class="form-control" ... />
              </div>
              <div class="input-group">
                    <span class="input-group-addon">@</span>
                    <input runat="server" class="form-control" ... />
              </div>
              <!-- more company fields... -->
         </div>
    </div>

</div>
</form>

I've litterally slapped that together on the DW editor so excuse any blatent mistakes, I'm currently stuck on a corporate citrix farm :P I believe the layout above would do the trick? Can you get it displayed and show me a picture to help visualise? Sorry if I'm actually making this experience more painful haha :D

Michael

mmcdonald 28 Posting Pro

A fluid container with two columns is the way I would proceed.

If you want to play around with BS3 forms before you begin check these out:

A form builder:
http://bootsnipp.com/forms?version=3

Some useful example code (All credit to 'pppeater'):
http://www.bootply.com/pppeater/jrNvaahcOh

Write some code and then post it here and we can all take a look and shuffle bits around :)

Regards,
Michael

mmcdonald 28 Posting Pro

Hi all,

I've just started to work on a lazy mans network - everything is unmanaged. I've now been asked to install a media server so that we can provide a source for the 90+ TV screens in our thirty remote offices, a system such as this: http://www.cabletime.com/how-it-works/

The only issue is, our network doesn't support multicast technologies because our switches do not have any IGMP snooping capabilities, and our routers don't have IGMP querying!

Does anyone know of a solution where this can be achieved without the need for a multicast enabled network?

Thanks,
M

mmcdonald 28 Posting Pro

This is a serious issue and highlights some genuine concerns. I say this is a professional and serious manner - what is the children were foolish enough to engage in sexual acts and/or watch pornography using the school computers? What if the camera was enabled when one of the children were getting changed in front of the laptop, or meeting with their partners?

Schools are not allowed camera in or around their toilets and changing rooms for the very same reason!

Personally, I would like to see heads roll over this as well as legislation put in place making it completely illegal until the laptop has been reported lost or stolen by the student or the students parents.

mmcdonald 28 Posting Pro

Can you please visit both of the pages with firebug activated and let me know if there are any errors on the console? Are both files in the same web root or is one in a directory?

mmcdonald 28 Posting Pro

Instead of <br> try <br />. If that doesn't work use \r\n for a single line break. I'm quite sure \r\n is the solution you're looking for though pritaeas is correct, it depends on how you're sending it and even more so how you're reading/receiving it.

mmcdonald 28 Posting Pro

Now unless I misunderstand the question, this is quite easy to achieve. Each row should have a form and each buy now button should be a form submission button for the row. I personally would do this with jQuery, wrap the whole table in a form, add a custom attribute to each pay now button and .serialize() the submission.

Also, this isn't a 'We give away solutions for nothing' website, you should have given this a go yourself and posted the code from your attempt.

Anyhow seeing as you requested the solution in PHP you can achieve this by accessing the global $_POST array after posting from a HTML form. An example of this is below.

<?php

    if(isset($_POST['buyPlan'])){

        $filterPlan = preg_replace("/[^0-9]/","",$_POST['planId']);
        header('Location: member.php?active_plan='.$filterPlan);

    }

?>

<table>
    <form action="" method="POST">

        <tr>
            <td>
                <input type="hidden" name="planId" value="1" />
                1
            </td>
            <td>
                <button type="submit" name="buyPlan">Buy Now</button>
            </td>
        </tr>
    </form>
</table>

Now this is a poor but working example - you don't get it all for nothing. In the example we collect the id of the plan from the hidden input field and submit the value of that field in a POST to the same file identified by the fields name. We then use the PHP form handler at the top to collect the value of $_POST['planId'], filter the plan id to make sure your visitor hasn't changed the value to something dangerous before submitting the form, and then finally use the header() to redirect to members.php with the query string you wanted.

mmcdonald 28 Posting Pro

Sorted, thanks very much!

mmcdonald 28 Posting Pro

I'll be honest and say this is the first time I've head of a compound key... I'm open to suggestions! (The id column is easily deleted).

DELETE t1 FROM tablename t1, tablename t2 WHERE t1.id > t2.id AND t1.userid = t2.userid AND t1.courseid = t2.courseid

Is it fair to say that the use of t1 and t2 here has totally confused me :/

Sorry for derping Diafol and thanks :)

mmcdonald 28 Posting Pro

Hi all,

I'm looking into the management of duplicate records in MySQL, but this case is a little bit more specific. A record is only duplicated if column A and column B have the same value. So a record is only a duplicate if two specific columns have the same values in more than one record.

Table (excerpt):

| id | userid | courseid | 
|  1 |     23 |        3 |
|  2 |     23 |        3 |
|  3 |     28 |        5 |
|  4 |     28 |        5 |
|  5 |     23 |        5 |
|  6 |     23 |        3 |
|  7 |     29 |        3 |

Duplicate rows above that would be deleted by the query = id's 2, 4 and 6 (as I would like to keep one of the duplicate records, in this case, the record with the lowest id value.

Figuring out a solution:

After playing around and doing a little bit of research, this seemed to work a treat:

ALTER IGNORE TABLE table ADD UNIQUE INDEX tmpindex (userid,courseid);
ALTER TABLE table DROP INDEX tmpindex;

My only concern is that this probably isn't the fastest or safest method of achieving the same result, this query could be executed dozens of times an hour or thousands of times by a rouge user (I'll add a control/restriction eventually). Does anyone have any feedback or suggestions? I would truly appreciate a bit more wisdom.

Another thought, would it …

mmcdonald 28 Posting Pro

Brilliant Cereal thank you :) I did figure this out about 2 hours ago using overflow: scroll; and max-height: 450px; but was simply applying it to the wrong element, either due to Bank Holiday alcoholism or sheer tiredness! haha You're right however and that's a good find.

Kudos!

mmcdonald 28 Posting Pro

Change this:

echo 'There are . $result . 'members';}

to this:

echo 'There are '.$result.' members.';}

Check out this PHP doc on string operators: http://www.php.net/manual/en/language.operators.string.php, specifically concatenation.

If that's not the issue you could change your select statement and try something like this:

<?php

$result = mysql_query("SELECT COUNT(*) as count FROM registration") or DIE(mysql_error());

if($result['count'] > 0){
    echo 'There are . $result . 'members';
}else{
    echo 'There are no registered members yet!';
}

?>

(Note: untested, probably won't work as-is!)

If that doesn't work let me know and I'll have another look through.

Michael

mmcdonald 28 Posting Pro

Hi jKidz - I would love to help you here but it would be great to see you have a go first. Also, tell us more about the technologies you're using. MySQL? MySQLi? PDO?

Have a go yourself here - no one is going to judge you or your work. Once you've had a go we can make some adjustments and corrections if required and you will learn a lot from the discussion.

I'll watch this discussion and post back when you do :) Good luck!

Michael

mmcdonald 28 Posting Pro

Hi all,

I'm working on an old project of mine that I used to self-study PHP which used Bootstrap 2. Revisiting the project a year on I'm looking to restrict the max-height of dropdown.js but can't - for the life of me - get it done. The best solution would be to have an overflow: scroll; max-height: 450px; situation.

Checkout the dropdown menu in this example: http://jsfiddle.net/S3XLH/, you'll see that the menu item named 'dropdown' is far too big for the page. How can I limit the height of dropdown menu?

Thanks for any help - I thought I knew how to do it but I've tried everything I can think of.

Michael

mmcdonald 28 Posting Pro

12 lawyers weren't able to come up with air tight wording for this and asked a non-lawyer to get the opinions of other non-lawyers? Hmm

They didn't ask me, I just couldn't get in touch with them because of the timezone difference; I could have waiting but chose not to. They haven't yet come up with air tight wording for this business at all, my client is a hedge fund and his internal departments are working on 100's of new businesses. They didn't ask me to get the opinions of non-lawyers. In fact I don't even think this project has even involved his legal team yet.

You've made that all up in your head :)

I'm starting to see the DW community in another light, I came here with a small and simple question which was answered almost immediately, but it seems everyone wants to have a say on a matter that is not only out of their hands, but out of the OPs hands also. I feel like this topic is starting to move to a 'My dad is better than your dad' format, with people trying to prove they're right or that they know more than someone else - even when they know nothing of the scenario whatsoever!

I'm not going to reply in this topic anymore and have unsubscribed. Thanks to those who helped answer my question! You have been given rep.

Michael

mmcdonald 28 Posting Pro

I build the registration system. I get paid. I walk away.

Beers all round!

@Diafol - Adult nude is sexually provocative photography.

mmcdonald 28 Posting Pro

In the industry there are dozens of different types of nude photography, again I'm not touching the legal. I do know that the agency is legit 100%, a passport, birth certificate and national insurance number (UK) is required before the agency produces a contract. Furthermore, the agency doesn't provide a photography service, it's down to the model to produce a portfolio to the agency. They do recommend photographers and studios however, and I believe they audit them first.

mmcdonald 28 Posting Pro

Hi Mike,

In this particular instance it's not the case (I'll try to explain with clarity - I'm no lawyer thank god). Under agency rules (which applicants are required to agree to, sign and return) the subject must only partake in activities that are legal for them to undertake in their country of citizenship. According to my clients lawyers this is a legally binding contract and any model who agrees to this clause and ignores it is liable to a lawsuit.

By no means am I a specialist in law, I just know that my client has a 12-man strong in-house legal team; so I'm sure they'll figure out the rest and make it happen. Either way I am grateful for your input! I'm just constructing the 8 phase registration system.

FYI: All of this information came from a 5 minute phone call, so I'm not holding my hand on the bible and saying it's 100% accurate.

All the best,
Michael

mmcdonald 28 Posting Pro

My client has a legal team who will be going through the system to check for legalities pre-beta - this is just something that was bugging me!

"country of citizenship" was the term I couldn't grasp!

Thank you :)

Michael

mmcdonald 28 Posting Pro

Geeks,

My client, an international online modelling agency, needs to state the following:

"Age restrictions depend on the juristiction over your nationality".

He has a section where applicants can apply for Nude photography (Nude Artistic, Nude Erotic, Adult Nude and semi-nude). Some countries require you to be 21 and some require you to be 18. How do you corrently write the statement above?

Thanks in advance,
Michael

mmcdonald 28 Posting Pro

Hi pritaeas,

I had 4x4 checkboxes but could only figure out how to disable them in one direction

M

mmcdonald 28 Posting Pro

Hi DW'ers,

Any other suggestions here? My research isn't going very well and I'm stumped

M

mmcdonald 28 Posting Pro

I see what you mean. but what would be even better is if 4 is already set, if they choose 4 again it is removed from it's previous selection? same for all numbers. Then they can't repeat their entry

mmcdonald 28 Posting Pro

Thanks urtrivedi, I really like your suggestion, especially the validation method of checking that the total value of answers for each question = 10. Simple yet effective.

One thing I would like to do to increase ease of use pre-validation is to remove a number from the other dropdowns when it's selected in a dropdown. So if they chose 4 for mum, it wouldn't be available as an option for dad, siblings or doctor.

How would I go about this? I'm struggling to even visualise the logic and I really do not know why.

+1 for your answer above

mmcdonald 28 Posting Pro

Hi all,

I'm currently building a questionnaire and I've run into a head scratcher. Some of the questions require the user to give a number to represent the importance of the answer. Example:

Instruction: Please select the radio buttons according to your preferred option, 
with 1 representing the most important down to 4 which for you is least important.

1) If you're worried or concerned about a health related issue - who are you more likely to consult first?
    a. Mum
    b. Dad
    c. Doctor
    d. Sibling(s)

The user must give a number to each answer, between 1 and 4, like the following:

1) If you're worried or concerned about a health related issue - who are you more likely to consult first?
    a. Mum = 1
    b. Dad = 3
    c. Doctor = 2
    d. Sibling(s) = 4

or

1) If you're worried or concerned about a health related issue - who are you more likely to consult first?
    a. Mum = 4
    b. Dad = 2
    c. Doctor = 1
    d. Sibling(s) = 3

The point is, they can't use the same number twice... so they're producing an order of importance to them.

What is the way to go about creating and validating this? I have grouped the radio buttons vertically which is great as it means the user can only choose 1, 2, 3 or 4 once in every question, but they're still able to stack 1, 2, 3 and 4 …

mmcdonald 28 Posting Pro

Understood, cheers fella

mmcdonald 28 Posting Pro

Whoops - totally missed this topic, sorry!

I have done this and it seems to be working perfectly. Sorry for not getting back to you.

I must ask, what's the benefit of using cache: false and AJAX over JQuery .load and a random number and/or a timestamp?

Michael

mmcdonald 28 Posting Pro

That's one of the few cons of collaborative coding. However I know that this was J as I've already spoken to him on the phone and he's the only one who has seen that script since its creation. I can clearly see what you're hinting at, as can the rest of the community - but I couldn't care less. There are too many errors that are of my doing; so it's a beautiful thing when I discover one that's not! (Insert cheesey grin here)

One thing to leave you with,

“Sarcasm is the lowest form of wit.”
― Oscar Wilde

Good luck,
Michael

mmcdonald 28 Posting Pro

Good news people - problem solved!

After hours of... cursing... the problem was caused by a very close friend who hid a very sneaky <form> tag towards to the top of the page. Turns out it's payback for going on a date with his ex-ex-ex-ex (Four times removed).

Last time I leave my PC unlocked when he visits!

mmcdonald 28 Posting Pro

I missed you, what do you mean 'pass a manage variable'? I've never heard that term before.

mmcdonald 28 Posting Pro

I've said above three times mate, and there is no HTML file.

My HTML code is in /administration/forums.php and my PHP form handler is in administration.php.

mmcdonald 28 Posting Pro

I wouldn't mind, not at all, but the script is huge and split all over the place, sorry!

Basically, administration.php?manage=forums is our current location, but it could be administration.php?manage=blog, administration.php?manage=addons, administration.php?manage=settings, administration.php?manage=support or administration.php?manage=theme. Each ?manage query string opens a different file.

So, administration.php looks a little like this:
if($_GET['manage'] == "forum"){
    include('pages/administration/forums.php');
}

if($_GET['manage'] == "addons"){
    include('pages/administration/addons.php');
}

if($_GET['manage'] == "api"){
    include('pages/administration/api.php');
}

but with more control, obviously :) and:

pages/administration/forums.php has this in it:
    <form>
        <div class="span6">
            <form action="" method="POST" name="createForumCategory" id="createForumCategory">
                <label>Create a new category:</label> 
                <input type="text" name="category" id="category" class="m-wrap" />
                <input type="hidden" name="lmsid" id="lmsid" value="<?php echo $core['id']; ?>" />
                <button class="btn green" type="submit">Add Category</button>
            </form>
        </div>
    </form>

The HTML forms are located within the includes (I.E. pages/administration/forums.php) and the PHP form handlers are located at the top of administration.php. So the PHP handlers are there by default, and the HTML forms are included.

Does that make more sense?

I have, for troubleshooting purposes, tried having the handler in the same file as the form, the same issue occured. I just can't seem to get ANY form to submit in this file - they all add on to the query string as $_POST's!

mmcdonald 28 Posting Pro

die(print_r($_POST)); outputs Array ( ) 1. die(print_r($_SESSION)); is correct 100%.

I've already tried echoing before and after, but this of course doersn't matter - the IF statement isn't executing.

Unless $_POST['id'] is received as a string

This may be a potential issue further down the line but not now as the form handler isn't even executing. All that happens when the form is submitted is a change to the query string.

I should add to the OP that the form is located in pages/forums.php and the handler is located in administration.php, but pages/forums.php is included in administration.php.

Thanks for your input,
Michael

mmcdonald 28 Posting Pro

Hi all. I'm having a mad issue... totally mad. I mean I've never had this before.

I have the following HTML form:

<form action="" method="POST" name="createForumCategory">
    <label>Create a new category:</label> 
    <input type="text" name="category" class="m-wrap placeholder-no-fix" />
    <input type="hidden" name="id" id="id" value="<?php echo $forumOrange['id']; ?>" />
    <button class="btn green" type="submit">Add Category</button>
</form>

That uses the following PHP handler:

if(isset($_SESSION['authenticatedStaff'], $_POST["category"], $_POST["id"])){

        $mysqli = mysqli_connect($config['host'], $config['user'], $config['pass'], $config['db']);

        $category = $mysqli->real_escape_string($_POST['category']);
        $position = "99999";

        $query = "INSERT INTO topic_category (id,name,position) VALUES (?, ?, ?)";
        $stmt = $mysqli->prepare($query);
        $stmt->bind_param('isi', $_POST['id'], $_POST["category"], $position);
        $result = $stmt->execute();
        $mysqli->close();
}

I know there is no error handling - but there is no need! The reason being is that the form handler doesn't seem to detect any $_POST variables. The HTML form submits and the only thing that changes is the files query string. It changes from localhost/manage.php to localhost/manage.php?category=test&id=1 (Where test was the value of the category field). So the forms data is being set in the query string, but not processed as per usual.

I could change:

if(isset($_SESSION['authenticatedStaff'], $_POST["category"], $_POST["id"])){

to:

if(isset($_SESSION['authenticatedStaff'], $_GET["category"], $_GET["id"])){

but this is a weak work around and I'd rather try and get to the bottom of why this is occuring in the first place. Any thoughts?

+1 to the individual who spots the magic mistake that I obviously can't.

Thanks in advance,
Michael

N.B. Please ignore the 'unique' blend of procedural and OO code!