Jump to content

Scooby08

Members
  • Posts

    244
  • Joined

  • Last visited

Posts posted by Scooby08

  1. I'm trying to preg_replace the following, but it seems to only find the base href in caps.. What can I do to fix?? Or is it possible to search for both with one search line?? if that makes any sense??

     

    <?php
    function TranslateVariables($input)
    {
    global $SITEURL;
    $search = array("/<BASE HREF=\"(.*?)\">/",
    				"/<base href=\"(.*?)\" \/>/"
    				);
    $replace = array("<BASE HREF=\"$SITEURL/\">",
    				 "<base href=\"$SITEURL/\" />"
    				 ); 
    return preg_replace ($search, $replace, $input); 
    }
    ?>
    

  2. Sudden - I've been looking on yahoo finance and have been unsuccessful in finding the .csv file that has this information.. Perhaps you might know of a link??

     

    dropfaith - Thanks for that lovely list.. I'm ultimately trying to find some sort of live stream of this information, which if I can find it on yahoo finance I'd be in business..

  3. How would I go about splitting these dynamically generated options into optgroups by using the directory names??  Here is an example of what is generated:

     

    <select>
    <option value="one/a.php">one/a.php</option>
        <option value="one/b.php">one/b.php</option>
        <option value="one/c.php">one/c.php</option>
        <option value="two/a.php">two/a.php</option>
        <option value="two/b.php">two/b.php</option>
        <option value="two/c.php">two/c.php</option>
        <option value="three/a.php">three/a.php</option>
        <option value="three/b.php">three/b.php</option>
        <option value="three/c.php">three/c.php</option>
    </select>
    

     

    This is what I'm trying to change that too:

     

    <select>
    <optgroup label="one">
    <option value="one/a.php">one/a.php</option>
        <option value="one/b.php">one/b.php</option>
        <option value="one/c.php">one/c.php</option>
        </optgroup>
        <optgroup label="two">
        <option value="two/a.php">two/a.php</option>
        <option value="two/b.php">two/b.php</option>
        <option value="two/c.php">two/c.php</option>
        </optgroup>
        <optgroup label="three">
        <option value="three/a.php">three/a.php</option>
        <option value="three/b.php">three/b.php</option>
        <option value="three/c.php">three/c.php</option>
        </optgroup>
    </select>
    

     

    Could anybody get me pointed in the right direction??

  4. Would it be possible to break these dynamically generated options into optgroups?? Say "Group1" and "Group2"..

     

    <script>
    function setOptions(chosen) { 
    var selbox = document.mainform.new_image; 
    selbox.options.length = 0; 
    
    if (chosen == "/") { 
    	selbox.options[selbox.options.length] = new Option('<?=$imgname?>','<?=$image?>'); 
    }
        
        if (chosen == "/test/") { 
    	selbox.options[selbox.options.length] = new Option('<?=$imgname?>','<?=$image?>'); 
    }
    } 
    </script>
    

  5. I'm just wondering if anybody has run into this problem, and what they did to fix it..

     

    The problem is that when I upload a PDF and it then creates a thumbnail of the first page, which is fine, but some of the text ends up having black blocks around it, sort of like it's highlighted and it shows up in the thumbnails.. Has anybody ran across this problem before??

     

    Here is the line I have that creates the thumbnail:

     

    exec("/usr/local/bin/convert $supplied_dir/$new_file_name'[0]' -thumbnail '75x100' $supplied_dir/.thumbs/viewer_75x100_$new_file_name_image");

     

    Perhaps there is something I am doing incorrectly here..

  6. I have been searching around for answers as to how I can change the php_ini settings without actually having access to that file.. I am trying to increase the size of files that one may upload.. I have tried a couple different ways so far..

     

    First I tried putting this at the top of the page:

     

    <?php

    ini_set('post_max_size', '4M');

    ini_set('upload_max_filesize', '4M');

    ?>

     

    No luck there.. I have read somewhere that you cannot change these settings in the file itself. So then I tried through .htaccess file using this..

     

    php_value post_max_size 4M

    php_value upload_max_filesize 4M

     

    Any ideas out there for me to try??

  7. Say I have this input:

     

    <input type="file" name="userfile" width="55" />

     

    Is there a way to keep the path to whatever file they chose to upload in the field after they submit and there is an error? Maybe something like this, but this does not work..

     

    <input type="file" name="userfile" value="<?=$_POST['userfile'];?>" width="55" />

  8. I'm trying to match up and tell whether an image is linked or just plain text is linked.. Here is what I have that works separately, but I need them to both be unique when searching a match.. Here is what I have..

     

    /<a href=\"(.*)\" target=\"_blank\"><img border=\"0\" src=\"(.*)\" \/><\/a>/

     

    /<a href=\"(.*)\" target=\"_blank\">(.*)<\/a>/

     

    Right now the second one lists the image code rather than just plain text.. How do I remedy this situation??

  9. Would anybody happen to know why this:

     

    <hr width=$hrwidth size=$hrheight />
    

     

    works with this:

     

    preg_match("/<hr width=(\d*) size=(\d*) \/>/", $input, $match);
    

     

    but this:

     

    <hr width=$hrwidth size=$hrheight color=$hrcolor />
    

     

    does not work with this:

     

    preg_match("/<hr width=(\d*) size=(\d*) color=(\d*) \/>/", $input, $match);
    

     

    All I did was add the color attribute and for some reason it will not match up?? Am I missing something here, or did I not supply enough information for this to be answered?? I'm also having a hell of a time understanding preg_match..

  10. I'm trying to create a thumbnail of just the first page of a pdf and have been unsuccessful.. Here is the code that works perfectly, but creates thumbnails for all pages..

     

    <?php
    $new_file_name = preg_replace("/[^a-z0-9\.]/i",'_',$_FILES['uploaded_image']['name']);
    exec("/usr/local/bin/convert \"".$_FILES['uploaded_image']['tmp_name']."\" -colorspace RGB $supplied_dir/". $new_file_name . "");
    $patterns = array ('/[^a-z0-9\.]/i','/pdf/','/PDF/');
    $replace = array ('_','jpg','jpg');
    $new_file_name_image = preg_replace($patterns,$replace,$_FILES['uploaded_image']['name']);
    exec("/usr/local/bin/convert $supplied_dir/$new_file_name -thumbnail '150x150' $supplied_dir/.thumbs/viewer_150x150_$new_file_name_image");
    ?>
    

     

    I read that I can add a zero in brackets somewhere after the pdf file, but this doesn't seem to work..

     

    <?php
    exec("/usr/local/bin/convert $supplied_dir/$new_file_name[0] -thumbnail '150x150' $supplied_dir/.thumbs/viewer_150x150_$new_file_name_image");
    ?>
    

     

    What am I missing here?

  11. I'm creating a site for a company that wants to display a specific phone number on the site according to the users ip address.. He has many different offices in different locations, and wanted the number that is local to the user to display according to their ip address.. Can this be done successfully?  And if so, how would one go about this?

     

    Thankyou..

  12. How would I go about altering this function to format a negative number?

     

    <?php
    function show_price($price) { 
    $price = round(100*$price)/100;
    if (round($price*10) == $price*10 && round($price)!=$price) 
    	$price = "$price"."0";
    if (round($price) == $price) 
    	$price = "$price".".00";
    
    return "$".number_format($price,2);
    }
    ?>
    

     

    Right now the negative number formats like so:

     

    $-99.99

     

    and I'm looking to format it like so:

     

    -$99.99

     

    Can anybody help me out??

     

     

  13. I'm trying to incorporate it into this function:

     

    <?php
    function GetMyTime($input_location_id,$myTime)
    {
    global $dst;
    
    /* Check for valid location ID, return 0 date if invalid */
    	if ($input_location_id > 0)
    	{
    		$result = mysql_query("SELECT timezoneid, gmt_offset, dst_offset, timezone_code FROM dw_timezone WHERE timezoneid = '$input_location_id'");
    		list($timezoneid, $gmt_offset, $dst_offset, $timezone_code) = mysql_fetch_array($result);
    	}
    	else
    	/*	This is the default date returned upon first accessing the page */
    		return date('F jS Y, g:i A',strtotime($myTime));
    
    	if ($dst_offset > 0)
    	{
    		if (!($dst))
    		{
    		/*	Set the DST offset to zero if the box is not checked
    			and append the standard time acronym to the timezone code */
    			$dst_offset = 0;
    			$timezone_code = getTimeZoneCode($timezone_code, $gmt_offset + $dst_offset, "ST");
    		}
    		else if (!isDaylightSaving($timezoneid, $gmt_offset))
    		{
    		/*	Set the DST offset to zero if the timezone is not currently
    			in DST and append the standard time acronym to the timezone code */
    			$dst_offset = 0;
    			$timezone_code = getTimeZoneCode($timezone_code, $gmt_offset + $dst_offset, "ST");
    		}
    		else if ($timezone_code != '')
    		/*	Leave the DST offset and append the daylight saving time acronym
    			to the timezone code */
    			$timezone_code = getTimeZoneCode($timezone_code, $gmt_offset + $dst_offset, "DT");
    		else
    		/*	Assign a timezone code */
    			$timezone_code = getTimeZoneCode($timezone_code, $gmt_offset + $dst_offset, "");
    	}
    /*	Does not observe DST at all */
    	else
    		$timezone_code = getTimeZoneCode($timezone_code, $gmt_offset + $dst_offset, "ST");
    
    /* Get the DST offset in minutes */
    	$dst_offset *= 60;
    /* Get the GMT offset in minutes */
    	$gmt_offset *= 60;
    	$gmt_hour = gmdate('H');
    	$gmt_minute = gmdate('i');
    /* Calculate the time in the timezone */
    	$time = $gmt_hour * 60 + $gmt_minute + $gmt_offset + $dst_offset;
    
    /* Convert time back into hours and minutes when returning */
    	return = date('F jS Y - g:i A', mktime($time / 60, $time % 60, 0, gmdate('m'), gmdate('d'), gmdate('Y'))) . " $timezone_code";
    }
    ?>
    

  14. Not quite sure how to explain, but I added this:

     

    strtotime($myTime)

     

    to this:

     

    return date('F jS Y, g:i A',strtotime($myTime));

     

    Can the same be done to this some how??

     

    return = date('F jS Y - g:i A', mktime($time / 60, $time % 60, 0, gmdate('m'), gmdate('d'), gmdate('Y'))) . " $timezone_code";

     

     

  15. No problem.. I appreciate the attempt.. However I did try global like so and it seemed to work:

     

    <?php
    $q  = "SELECT * FROM dw_company";
    $r = mysql_query($q) or die(mysql_error());
    while($row = mysql_fetch_array($r)) {
    $company_name = $row['company_name'];
    }
    
    class PDF extends FPDF {
    function Header() {
    
                    global $company_name;
    
                    $this->SetFont('Arial','',9);
    	$this->Cell(0,10,$company_name,0,1,'C',0);
    }
    }
    ?>
    

     

    Would there be anything wrong with doing it that way??

  16. No problem guyfromfl.. Thanks for the response...

     

    genericnumber1, I have tried your code and it would probably work, but for this code it needs to be in this fashion.. This code spits out the word "test" on the pdf..

     

    <?php
    $q  = "SELECT * FROM dw_company";
    $r = mysql_query($q) or die(mysql_error());
    while($row = mysql_fetch_array($r)) {
    $company_name = $row['company_name'];
    }
    
    class PDF extends FPDF {
    function Header() {
    	$this->SetFont('Arial','B',10);
    	$this->Cell(0,10,'test',0,1,'C',0);
    }
    }
    
    $pdf=new PDF();
    $pdf->Output();
    ?>
    

     

    new PDF() automatically calls the header here, so how would I arrange it now?? Sorry I didnt post this in the first place..  I have tried this:

     

    <?php
    $q  = "SELECT * FROM dw_company";
    $r = mysql_query($q) or die(mysql_error());
    while($row = mysql_fetch_array($r)) {
    $company_name = $row['company_name'];
    }
    
    class PDF extends FPDF {
    public function Header($company_name) {
    	$this->SetFont('Arial','B',10);
    	$this->Cell(0,10,$company_name,0,1,'C',0);
    }
    }
    
    $pdf=new PDF();
    $pdf->Output();
    ?>
    

     

    but its still a bit off.. What am I missing??

  17. I'm having troubles getting a variable inside of a class.. Here is the code..

     

    <?php
    $q  = "SELECT * FROM dw_company";
    $r = mysql_query($q) or die(mysql_error());
    while($row = mysql_fetch_array($r)) {
    $company_name = $row['company_name'];
    }
    
    class PDF extends FPDF {
    function Header() {
    	$this->Cell(0,10,$company_name,0,1,'C',0);
    }
    }
    ?>
    

     

    How can I get $company_name to work inside of the class?

     

  18. I'm trying to get my textarea to print out like it is with all the breaks before submitting..  I have used this to get it to print out correctly with the breaks:

     

    $notes = nl2br($_POST['notes']);
    

     

    Works great.. The thing is when I go back to edit it again it shows all the br's in the textarea which will confuse those who do not know html..

     

    What can I do to remedy this??

     

     

  19. Say I have a form in a file called form.php.. The action on that form is process.php.. process.php validates for errors and sends the message back to form.php if errors.. I don't know how to repopulate the form values that were entered so they don't have to start over again when errors occur.. If the form were submitted to itself I could use $_POST['field_info'], but since it goes to process.php first I lose that $POST.. How do I get that info to carry back over?? I do have sessions going as well, but am not sure how or if I can use them to my advantage on this one..

     

    Can anybody give me some pointers??

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