Jump to content

meltingpoint

Members
  • Posts

    194
  • Joined

  • Last visited

Posts posted by meltingpoint

  1. Placed the below in the .htaccess file and it works perfectly!

     

    <FilesMatch ".(pdf)$">
    FileETag None
    <ifModule mod_headers.c>
    Header unset ETag
    Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
    Header set Pragma "no-cache"
    Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"
    </ifModule>
    </FilesMatch>

     

    Excellent!

    Keith

  2. I would like to say away form appending the url if possible.

     

    Is there a way to serve it up with php so as to pull the newest updated file?  If yes, can you point me in the direction as to how that is done.  I have a support ticket with my host to see if it is something they can change on their end for me.

     

    Thanks- Keith

  3. I have a website where I allow people to submit a .pdf file and it is then displayed in an iframe or in a pdf object in a div.  The names of the files always stay the same, and are uploaded to a specific folder.

     

    Problem is- when they upload a new .pdf file....the browser always displays the old .pdf file. 

     

    Deleting temp files- doesn't change.

    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">  does not work

     

    Is there a way to make sure that the current and updated pdf file gets served to the browser and it displays it?

     

    Any suggestions would help.

     

    Andy

  4. This works:

    if($ABC == 'Yes' and $X != $Y){
    echo "Error";
    exit();
    }

     

    I need to evaluate one more set of variables in this statement like so;

     

    This does not work:

    if($ABC == 'Yes' and $X != $Y or $Z != $Y){
    echo "Error";
    exit();
    }

     

    So basically I need to echo an error if $ABC == Yes and both $X and $Z do not equal $Y

     

    If gives an error because it is obviously not correct.  I do not know how to make it correct.  Any suggestions?

  5. In your second if statement- if the session time has expired you have it re-direct to the login page. 

     

    Where are you destroying the session in the 2nd if statment?  The session id is still set- just the time will trigger a redirect.

     

    I would include ;

     

    $_SESSION['login_time'] = "";

    $_SESSION_DESTROY();

     

    in the 2nd if statement.  That way it is all gone for sure.

     

    Just a thought.

  6. I really do not know.  You are piece-mealing code out a little at a time.  I am not sure what is included on each page nor

    do I know what is on menu.php and Safe.php.

     

    You said you added ob_start() along time ago.  I assume that this script was working for a while and now has issues.  If that is the case,

    what exactly have you changed?

  7. <?php
    include_once("connect.php");
    if(isset($_SESSION['user_id'])) 
    { 
    $sql = "UPDATE users SET lastactive = NOW() WHERE id='".mysql_real_escape_string($_SESSION['user_id'])."'";
    
    mysql_query($sql); // updates the last activity of user
    
    if ($_SESSION['login_time'] < strtotime('-60 minutes')) 
    {
    $_session['login_time'] = "";//-------to kill for sure the variable
    session_destroy();
    header("Location: signup.php");
    exit;
    }
    }
    

     

    ob_start() is for output buffering.  Don't know all your code so not sure if you need it or are using it properly.

     

    Give the above a try

  8. Tested this on my server and it works fine.  There may well be a simpler solution, but until we determine why the MODX id is padding with spaces or \n, this is the only way I could think to do it.

    <?php
    $webpage = $_SERVER['SCRIPT_NAME'];//-----gets the page url as a string
    
    $find_string = 'id=';//-------defines our search starting point to find the position just before the Modx page ID number ex.  id=18
    //------*****THIS MUST MATCH EXACTLY HOW MODX SHOWS THE ID IN THE URL.  If you need to- modify it in the line above
    
    $pos = strpos($webpage, $find_string);//---finds the character position where id= is found
    
    $v = substr($webpage, $pos+3 , 3);//----creates our id variable from the MODX url
    $v = trim($v);
    //----   id=  is a string with 3 characters.  So we add 3 to the located position thus winding up with the Modx page ID  ex. 18
    //          this will extract any page id between 1 and 999.  **This assumes MODX always puts the page id last in the url
    //
    //----------------------------------------------------------------------------------------------------
    //------now lets create an easier way to accomplish your task of outputting html depdending on the page selected
    //----------------OR, if you are more comfortable you can implement your if and elseif statements as you had them
    //
    $resource1 = array("3", "24", "32", "35", "38", "42", "44", "47");//---------define our array for certain group of pages
    if(in_array($v, $resource1))//--------if the page id matches this group, echo the html
    {
    echo "[[!include? &file==`assets/templates/inc/newslisting.php]]";
    exit;
    }
    //
    $resource2 = array("54", "64", "75");//---------define our array for another set of pages
    if(in_array($v, $resource2))//--------if the page id matches this group, echo the html
    {
    echo "[[!include?&file==`assets/templates/inc/bloglisting.php]]";
    exit;
    }
    //
    $resource3 = array("56");
    if(in_array($v, $resource3))//--------if the page id matches this group, echo the html
    {
    echo  "[[!include?&file==`assets/templates/inc/contact.php]]";
    exit;
    }
    //
    $merged = array_merge($resource1, $resource2, $resource3);//--- HERE WE CREATE THE DEFAULT.  IF THE ID ISN'T IN ANY OF THE ABOVE
    if(!in_array($v, $merged))
    {
    echo  "[[!include?&file==`assets/templates/inc/textContent.php]]";
    exit;
    }
    
    ?>
    

  9. var_dump() is simply used to see exactly what your variable is.  For example;

    <?php
    $a = ' a';//------blank space before the a
    $b = 'b';//------ b with no spaces
    $c = '   1';//-------c with 3 spaces before it
    $d = array("a", "b", "c");
    
    var_dump($a);
    echo "<br>";
    var_dump($b);
    echo "<br>";
    var_dump($c);
    echo "<br>";
    var_dump($d);
    ?>

    This would out put :

    string(2) " a"

    string(1) "b"

    string(4) " 1"

    array(3) { [0]=> string(1) "a" [1]=> string(1) "b" [2]=> string(1) "c" }

     

    You would then be able to evaluate if the variable that you are comparing (in this case $id) is what you are expecting it to be and if

    the php parser is seeing it as such.  Example above if you were expecting the variable $a to out put 'a' and you compare it to that- it would be false

    as it is actually a space and then a - see the out put is a string with (2) characters

     

    or in the case of $d - it is an array

  10. <?php
    
    $id = '2';
    
    if ($id=="1" || $id=="2")
    {
    echo "we are in 1 or 2";
    }
    elseif ($id=="3" || $id=="4")
    {
    echo "we are in 3 or 4";
    }
    else
    {
    echo "not in 1 to 4";
    }
    
    ?>

     

    This works for me.  If your $id is as it should be- then it should work.  Have your tried var_dump($id) to make sure?  Also, I have run across this before where I need to trim($id) and then do the comparison as in some instances a new line or space was there that was not making it evaluate correctly.  Just a thought.

  11. Not nearly enough info to give a good answer.  Would need to know;

     

    What type of project? 

    Internet or Intranet? 

    Need for stringent security or not so much? 

    How many users? 

    What kind of data and how much?

    What is your experience with Web Building/programing?

     

    As to learning php- the PHP and MySQL5 manual is great.  There are numerous tutorials on the net.  VTC.com has a great PHP dvd tutorial that

    I have used and it was very inexpensive.

     

     

×
×
  • 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.