Jump to content

newbtophp

Members
  • Posts

    631
  • Joined

  • Last visited

Posts posted by newbtophp

  1. I'm not sure but I think that www.xyz.com is the same as xyz.com. Somehow. The 'true' subdomains tho are different. Either way if you begin in a specific domain name and set some cookies in the root folder they will be there for any users of said domain. What else could you want? In what world would you need cross-referencing of them between apps running in different domains?

     

    I guess cookies being readable on the www. version is really a no issue, the main concern lies with cookies being readable on subdomains - which I don't want (due to security).

  2. Yes I am. And I see now how confusing my answer was to you. IF I had bothered to check first I would have said that the \ in the 4th argument would ensure that your cookies would be in the correct place regardless of what domain name was in $site. The cookies will be in the domain root because of the \ although the absolute path of that location will be different depending upon the current $site/domain value.

     

    Appreciate you clarifying, however if $site was set to domain.com, would cookies be readable on any other variation such as www.domain.com or somethingelse.domain.com or www.somethingelse.domain.com (which is what I don't want)?

  3. I have a script where $site (location of where it's hosted) will either be in the format of a subdomain e.g. 'something.domain.com' or a domain 'domain.com', and the cookies are handled like the following:



    ini_set('session.cookie_domain', $site); //for sessions

    setcookie($name, $value, $expiry, '/', $site, false, true); //for others

    My question is the script's canonical url is non-www and I don't want other subdomains for various reasons (including security) being able to access/read the cookies (e.g. 'www.something.domain.com' or 'www.domain.com' or 'somethingelse.domain.com' or 'www.somethingelse.domain.com'), so would you say the above will work okay (providing $site does not proceed with www. or .)?


     


    I have searched around (also referred to php.net) and believe the above will be okay from my understanding - but wanted reassurance as I had read many conflicting/confusing information!


     


    Edit: If the above won't work - I thought about maybe setting $site to false (the .htaccess code would enforce access only via non-www)?


  4. Heya!

     

    I've coded a small php template parser, so templates can be easily parsed, and the variables within the templates are like {variable_name} e.g.

     

    <title>{title}</title>

     

    Can you suggest me possible if/else statement syntax?

     

    I've thought of doing something like:

     

    {if {logged_in}: TRUE}

    Your logged in...

    {else}

    Your not...

    {/if}

     

    and...

     

    {if {logged_in}: TRUE}

    Your logged in...

    {/if}

     

    The above demonstrates basic if/else template syntax (it checks if the variable logged_in == true), but since I'm more of a coder then designer, was wondering if I can have your input (so designers can easily understand the syntax without knowledge of server-side coding).

     

    Cheers!

  5. i figured out how to convert a TimeStamp to real time

    by doing this

    $time	 	= $_SERVER['REQUEST_TIME'];//Onix Time Format
    print date('Y-m-d H:i:s', $time); // 2010-09-26 04:25:49
    

     

    But i dont know how to convert 2010-09-26 04:25:49 Back to a Time Stamp

    Any ideas?

     

     

    nevermind .. i figured how to do it

    seems that the mktime function dos it

     

    strtotime does that

  6. I currently have the query below:

     

    SELECT table1.id, table1.review, table1.time, table2.author, table2.title FROM table1, table2 WHERE table1.id = table2.id AND table1.reviewer = '{$username}' ORDER BY table1.id

     

    Im using the above quite alot around my sites code...and sometimes adding the table prefixes etc. before the column names can make the query very long and take up quite alot of lines.

     

    Is their a way to make the above query more simple/easier, as its quite basic as I just followed the basic tizag examples.

     

    Hope someone can help!

  7. Hi

     

    First problem is that you need to join the tables on a field. What you have is a cross join, and will bring back every combination of the rows from the 2 tables.

     

    As to checking an aggregate value, use a GROUP BY to group the records you want to count and use a HAVING clause to check the value.

     

    All the best

     

    Keith

     

     

     

        $pm_query = "SELECT table2.id FROM table1, table2 WHERE table2.id = table1.id AND table1.author = '{$username}'";        $pm_reply_count = mysql_num_rows(mysql_query($pm_query));    //final query (which shall be used within a while loop)    $pm_id_query = "SELECT id FROM table1 WHERE (id = '{$id}' AND author = '{$username}' OR pm_author = '{$username}' AND {$pm_reply_count} > 0) AND deleted = 0";

     

     

    I've come up with the above? but its kinda hackish? - their must be a better way I'm just unsure on how to

  8. SELECT table1.title, table1.status FROM table1, table2 WHERE table1.author = '{$username}' AND COUNT(table2.id) > 0 AND table2.deleted = 0

     

    But I get an error, but when I remove the ' AND COUNT(table2.id) > 0' the error goes; theirfore whats the correct way to do this?

     

    :(

  9. I don't see anything wrong with your current method. That is generally how all star voting systems work. People vote 1-5 and you display the average of those votes. So what if the first vote is 5 and that boosts it to 5 automatically? That's why you also display the number of votes so people don't get the wrong idea.

     

    Well I know but say if theirs 1 vote of 5, the score will = 5 (however thats 1 voters opinion which can effect the importance or quality of the content), and if for example I display a 'Top X' based upon their score, they can jump to the list.

     

    I googled around and found the following:

     

    http://www.thebroth.com/blog/118/bayesian-rating

     

    But seems abit too mathematical for me to integrate, so was hoping someone could help me.

     

     

    EDIT: added a better example

  10. Someone suggest using bayesian algorithm, but I'm not sure how to implant that using my current db structure (without the score going over 5)

     

    Any help or any better way you can think of (to improve upon my current method)?

  11. I want to display 50 results, theirfore I'm using a while loop to do so, the issue is, if $row consists of results lower then 50 (it will display them) and not display 50..so I'm trying to figure out a way so even if $row doesn't cosist of 50 i'll display what it has aswell as continue the $i (and for the rest display NO CONTENT).

     

    I've come up with the following on the spot (not sure if it even would work) - but was wanting a better solution.

     

    $i = 0;
    
    $results = mysql_num_rows($result);
    while ($row = mysql_fetch_assoc($result)) {
    $i++;
    
    echo $i .' CONTENT '.$row['name'].'<br />';
    }
    
    if ($result < 50) {
    
    for($i <= 50 - $result; $i++) {
    echo $i .' NO CONTENT<br />';
    }
    }
    

  12. I'm trying to do a for loop to provide 2 numbers $x and $i, +199 every time?.

     

    E.g.

     

    First loop:

    $i = 200;

     

    $x = 399;

     

    Second loop:

     

    $i = 400;

     

    $x = 599;

     

    Third loop:

     

    $i = 600;

     

    $x = 799;

     

    and so on until $x = 1400; (then stop).

  13. ~^(??<!\-)[a-z0-9\-]{2,}(?!\-)|(?<!\-)[a-z0-9\-]+(?!\-)\.(?<!\-)[a-z0-9\-]{2,}(?!\-))$~D

     

    I have the above expression, which will match the specified characters (with the specified length) and optionally a fullstop followed by more specified characters (with the specified length).

     

    Im trying to make it so it matches only if its not proceeded by a - and not followed by a - .

     

    So example the following will match:

     

    hey.phpfreaks

    hey

    yo-u.me

     

    However the following will not match:

    -hey

    hey-

    -hey-

    you.-he

     

    I've tried using (?<!\-) (not proceeded by -) and (?!\-) (not followed by -) but that doesn't seem to work?  :wtf:

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.