Jump to content

Dorky

Members
  • Posts

    287
  • Joined

  • Last visited

    Never

Posts posted by Dorky

  1. any chance i could get you to break this down so i can understand what is happening at each of these steps?

    class myClass {
    private $var1, $var2, $var3;
    
    public display(){
    echo $this->var1, $this->var2, $this->var3;
    }
    }//end class
    

     

    $object = new myClass;
    echo $object->var1;
    

     

  2. ok. i have a lot of php under my belt. i have yet to see a function that says to me "this is the way to go" but for sake of having a clue i feel i should learn this. if anyone is interested in explaining functions and classes(structure, advantages) in a way that can be put into practical use rather then text book theory, i would greatly appreciate it.

     

    p.s. i have looked at php manual and w3schools.com and neither of them explained the how and why to the extent i could understand it. no i didn't post this question here because i'm lazy.

  3. lol, wow. i overlooked it an at a glance assumed jscript. yeah dude escaping is to make it easier to place $var inline with html.

    Escaping 101

    • standard html<div id="whatever">
    • escaped html<div id=/"whatever/">
    • shortcut html<div id='whatever'>

     

    is that a php function? if so you are getting errors because you are trying to open php tags in php tags. why are you doing that? and yes the multiple closing/opening single quotes are coinciding. Next time put code in code tags

     

    function insert() {
        return '<a href="'.c2c_get_custom("main image").'" rel="lightbox" title='".echo c2c_get_custom("title")."'><img src='".c2c_get_custom("thumb")."' width="60" height="45" alt="df" /></a>';
    }
    

  4. Thanks Jay...

     

    I am sorry for being so upfront... I am so frustrated with the code as I just don't get it to do what I want it to do. I am new to php...

     

    Anyway... I was actually thinking it should be before the line you pointed out! I will try again.

    May I print my code on here again if I don't get it right?

     

    ok. this script could and can be consolidated but i wrote it this way because it is easier to edit individual parts for the desired application and transplanting script is less time consuming then writing one for each site. this particular application is used for an image gallery with thumbnail views. after you have taken the time to pick apart and research the parts you do not understand you will by then understand how to integrate this into your script.

    if you try to cut and paste this it will not work. you need to edit the required conditions, file path, desired sizes, and header pref. but if you can handles that then this script should help you. it requires the gd lib on your server and will resize without squishing or squashing the image(keeps proportions). the or statement for jpg and JPG is because digital cameras use the JPG instead of jpg and its just easier to add this then to require clients or users to rename the file ext, that is even if they knew how to.

    if (isset($_SESSION['user'])) 
    {   
    if (isset($_POST['submitimage']))
    { 
    if (isset ($_FILES['new_image']))
    {
    if (!empty($_FILES['new_image']['name']))
    { 
    $imagename = $_FILES['new_image']['name'];
    $charref = substr($imagename, 0, strrpos($imagename, '.')); 
    if(ctype_alnum($charref)) 
    {
    if (($pos = strrpos($imagename, ".")) === FALSE) { echo  "<p class=\"p7\">Fail</p><br />"; exit; }
    else {  $extension = substr($imagename, $pos + 1); }
    if ( $extension == "jpg" || $extension == "JPG" || $extension == "gif" || $extension == "png"   ) 
    { 
    $source = $_FILES['new_image']['tmp_name'];
    $target = "images/gallery/$imagename";
    move_uploaded_file($source, $target);
    $file = "images/gallery/$imagename"; 
    $save = "images/gallery/$imagename";
    list($width, $height) = getimagesize($file) ; 
    if ($width > "300" )
    { 
    $modwidth = 300; 
    }
    else
    {
    $modwidth = $width ;
    } 
    $diff = $width / $modwidth;
    $modheight = $height / $diff; 
    $tn = imagecreatetruecolor($modwidth, $modheight) ; 
    if( $extension == "jpg"  || $extension == "JPG" ) { $image = imagecreatefromjpeg ($file); }
    if( $extension == "gif" ) { $image = imagecreatefromgif ($file);  }
    if( $extension == "png" ) { $image = imagecreatefrompng ($file);  } 
    imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; 
    if( $extension == "jpg" || $extension == "JPG" ) { imagejpeg($tn, $save, 100) ;  }
    if( $extension == "gif" ) { imagegif($tn, $save, 100) ;  }
    if( $extension == "png" ) { imagepng($tn, $save, 9) ;  }
    $save = "images/gallery/thumbs/$imagename";
    list($width, $height) = getimagesize($file) ; 
    if ($width > "100" )
    { 
    $modwidth = 100; 
    }
    else
    {
    $modwidth = $width ;
    }  
    $diff = $width / $modwidth;
    $modheight = $height / $diff; 
    $tn = imagecreatetruecolor($modwidth, $modheight) ; 
    if( $extension == "jpg" || $extension == "JPG" ) { $image = imagecreatefromjpeg ($file); }
    if( $extension == "gif" ) { $image = imagecreatefromgif ($file);  }
    if( $extension == "png" ) { $image = imagecreatefrompng ($file);  } 
    imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; 
    if( $extension == "jpg"  || $extension == "JPG" ) { imagejpeg($tn, $save, 100) ;  }
    if( $extension == "gif" ) { imagegif($tn, $save, 100) ;  }
    if( $extension == "png" ) { imagepng($tn, $save, 9) ;  }
    header("Location: http://#"); exit;
    } 
    else 
    {
    echo "Invalid or empty File <br>Valid file types .jpg .gif .png<br />"; exit; 
    } 
    }
    else 
    { 
    echo "Image name may have alphanumeric characters only and no spaces $charref"; exit;
    }
    }
    else
    { 
    echo "You did not select a file to upload<br />"; exit;
    }
    }
    }
    }

  5. your var = $var for this example

     

    echo "<img src='$var' />";

     

    if it is the url without the http:// then add it

     

    echo "<img src='http://$var' />";

     

    but for sake of argument it is better to use the resize during img upload and if you need this for a gallery, say thumb and full size. upload to two dif folders. one for thumbs and one for full. this requires the server to only compute on the upload and not every single time someone hits the page.

  6. echo  "<div class='whatever'><h3>$row['title']</h3></div> ";

     

    now weather you use class or id, h3 or h1 doesn't matter. this is just an example of how to format such. i use single quotes(as shown above) so i don't have to do all of the escaping of double quotes also cutting down on how much code the server has to render( / for every quote adds up quick). you will need to double quote the echo string. hope this helps.

  7. i saved it for other uses. i found a way to filter browsers with a more efficient script. thx for the help  :)

     

     

    just create a text file called php.ini with the above as it's only contents and place that in your root directory.  That should overwrite that one setting from the hosts php.ini for php scripts called from all folders above it.

  8. ok, sorry but i have to ask you to dumb it down just a bit. still only about a year of self taught php skills. is that what i put in the php.ini and do i name it "php.ini" and can i create just one php.ini in the root or do i need to do it for each directory/site?

     

    thx again.

    usually with shared hosts you can do a custom php.ini in your root folder.  Then use that to specify the location of the browscap.ini file./

     

    like so

    [browscap]
    browscap = /full/path/to/browscap.ini 
    

  9. ok i have a host that refuses to stay current. they control my php settings and libs. is there a way to put the browsercap.ini in my root directory and point to it so that i may use the get_browser function? the workaround for this function is way to to long and not very time efficient for building new sites.

     

    thx in advance.

  10. allow me to expand on this project. i am using a lot of css2 and some css3. to keep my site from being viewed improperly i am filtering pre-mozilla5 browsers but need to allow for ie8 but it uses mozilla4 so its been hard for me to find a way to make an exception for ie8. this is what i have so far. feel free to edit or comment on this

     

    $browserfind = $_SERVER['HTTP_USER_AGENT'] ;
    
    $firstoc = strpos($browserfind, '.');
    $browser = substr($browserfind, 0, $firstoc );
    $listbrowsers = array("Mozilla/4" , "Mozilla/5" , "Opera/9" , "Yandex/1" , "facebookexternalhit/1");
    $redirect="http://studio378d.com?sorry&btype=$browser";
    
    
    if (!in_array( "$browser" , $listbrowsers , true)) 
    {
    header("Location: $redirect"); 
    exit;
    }

  11. WOW. ok can you break down this part for me so i understand what this means

    '~MSIE ([^;]+);~'

     

    Try something like

     

    <?php
    if (preg_match('~MSIE ([^;]+);~', $_SERVER['HTTP_USER_AGENT'], $match)) {
    echo 'Internet Explorer version: ' . htmlentities($match[1]);
    } else {
    echo 'Browser isn\'t Internet Explorer';
    }
    ?>

     

    I'm using htmlentities() because the user agent string can be spoofed by the user, potentially containing malicious code to be executed.

  12. i have looked but i would rather find the command for finding a string(by array) within a string(string). im sure there is a command for this without using 200 lines of code to circumvent knowing the proper command to do so. this is a useful way of comparing for future applications outside of my current project.

     

    just trying to learn :) thx

     

    Try having a look at the notes on the get_browser() page.

     

    There are some examples of functions that use Regex to find the browser name and version number, they might be worth a try...

  13. yes that would be just what the doctor ordered but my host wont install any libs outside what they already have and i dont have enough clients to support the cost of a dedicated or vpn. so i need to do this with standard php5.

     

     

     

    so you want to be able to get the msie version number and put it into a variable

     

    if so i think that this may help you... i haven't tried it but i think it would work

     

    i got this from: http://us2.php.net/manual/en/function.get-browser.php

    $browser = get_browser(null, true);
    echo $browser['version'];
    

     

    may need some changes but i hope i pointed you in the right direction

  14. i have been trying so herd to figure out how to find, isolate, and $var the msie ver from user agent, i have lloked over strstr, strpos, in_array, and so many others. all i want is to put the msie versions into an array and compare that to the user agent string. it sounds so simple yet i cannot find it. but i did find a few forums they let you sign up before telling you they think im going to pay them for their forum lol.

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