Jump to content

fohanlon

Members
  • Posts

    65
  • Joined

  • Last visited

    Never

Posts posted by fohanlon

  1. Hi Guys

     

    I have a string with a max characters of 612, this equates to 4 strings each of length 153 characters.

     

    Here is the issue, for every euro symbol in each of the 4 substrings each takes up 2 characters. So for example if there are 5 euro symbols in the first set of 153 characters, I want to push 5 characters into the second set of 153 characters as each euro takes up 2 characters and adjust the 3rd and 4th 153 substring accordingly and so on.

     

    Also there is the added complication if there are euro symbols in the last few characters of each 153 characters substring.

     

    I canot find a suitable function to help here.

     

    I was thinging of starting with:

     

    $num_euros1 = 2 * substr_count(substr($Content, 0, 153), '€');

    $num_euros2 = 2 * substr_count(substr($Content, 153, 153), '€');

    $num_euros3 = 2 * substr_count(substr($Content, 306, 153), '€');

    $num_euros4 = 2 * substr_count(substr($Content, 459, 153), '€');

     

    I am stuck on this one.

     

    Regards

     

    Fergal.

  2. Hi

     

    I am reading the contents of a file into a variable as follows: file_get_contents($pathtofile);

     

    If the file contains say just 3 € (euro) symbols as an example and I output the strlen I get 9 instead of 3.

     

    Could anyone tell me how I could sort of the contents (the 3 euro symbols) so I can get strlen as 3.  I tried utf8_decode etc.

     

    Many Thanks

     

    Fergal.

     

     

  3. Hi Guys

     

    After searchign the web and forums I still cannot find a suitable solution for my problem.

     

    I have a textarea.  Say the user copies in from MS Word the following:

     

    “!"£$%^&*()@'#:;/?!"£$%^&*()@'#:;/?!"£$%^&*()@'#:;/?!"£$%^&*()@'#:;/?!"£$%^&*()@'#:;/?!"£$%^&*()@'#:;/?!"£$%^&*()@'#:;/?!"£$!"£$%^&”

     

    Before I save it to a database I want to clean it up i.e replace or remove the Â

     

    I have read that the  will take up 2 characters.

     

    Also, if I could also replace MS Word single and double quotes that would be great.  I was looking at the str_replace with the Chr() function but to no use.

     

    Thanks for reading.

     

    Regards

     

    Fergal.

     

  4. Hi Guys

     

    Trying to get my head around a mod_rewrite I am doing.  I found plenty on the web re this question but no definitive answer.  Here is what I have to do.  I have a link to a page called

     

    content.php?id=123&name=SOME NAME HERE

     

    where id ties back to the 123 for pageid and name is what I want to use for Search Engine Optimisation.

     

    So here is what I have so far:

     

    RewriteRule ^([^/]*)/([^/]*)$ /content.php?id=$1&name=$2 [L]

     

    But what I want to do - only show the name in the url at the top

     

    Instead of

     

    www.somedomain.com/123/SOME NAME HERE

     

    I want

     

    www.somedomain.com/SOME NAME HERE

     

    but still need to use the id to pull back the page content to be displayed.  Can anyone suggest how to change the rule above?

     

    Hope this makes sense and its the right place to post this.

     

    Many thanks

     

    Fergal.

  5. Hi Guys

     

    I am having trouble with a mysql regexp expression called through php.  I am not sure but I suspect its to do with the {} in the mysql code and PHP parsing them incorrectly.

     

    Here is my code snippet:

     

    $q = mysql_real_escape_string($_POST['keyword']);

    $limit = 10;  //limit number of responses from dictionary

    $remainder = 11 - strlen($q);

    if ($q)

    {

    $qy = "SELECT * FROM dict_list WHERE UCASE(word) <> UCASE('$q') AND (word REGEXP '^$q.{$remainder}') LIMIT $limit";

    $query = mysql_query($qy);

     

    ...

     

    What I want to do is this:

     

    a user types in a word.  I then want to query a dictionary table called dict_list for all matches of the this word up to 11 characters max.

     

    Example:

     

    if $q was the word aero then the response would be all words beginning with aero and up to a max of 11 characters.  That is why IU thought I could calculate length of $q and from this get the $remainder = 11 - strlen($q) then in the REGEXP use .{$remainder} but when testing if I echo out the query $qy the curly braces will not show on screen.

     

    Any help would be greatly appreciated.

     

    I hope this is posted in correct location. Apologies if not.

     

    Thanks,

     

    Fergal.

     

  6. Hi

     

    I want to be able to upload files to subdrectories on the server.  I do not want to set any folders to permanently 0777.

     

    Here is what I have so far, its a combo of my own and somw stuff found on the web.  It will chmod the parent folder but fails on the sub folder.  I read about creating the parent folder using FileZila can create problems.  Confused as to what to create the parent folders in.

     

    Thanks in advance.

    F

     

    // documents

    $path_to_parent = "/httpdocs/sub1/subs2/";

    $parent_folder = "myfiles/";

    $sub_folder = $parent_folder . $subdirectoryid;

     

    function chmod_open()

    {

    $ftp_details['ftp_user_name'] = FTP_USER;

    $ftp_details['ftp_user_pass'] = FTP_PASS;

    $ftp_details['ftp_root'] = FTP_ROOT;

    $ftp_details['ftp_server'] = FTP_SERVER;

     

    extract ($ftp_details);

    $conn_id = ftp_connect($ftp_server);

    $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

     

    return $conn_id;

    }

     

    function chmod_file($conn_id, $permissions, $path)

    {

    $ftp_root = '/httpdocs/sub1/sub2/';

    if (ftp_site($conn_id, 'CHMOD ' . $permissions . ' ' . $ftp_root. $path) !== false)

    {

    return TRUE;

    }

    else

    {

    return FALSE;

    }

    }

     

    function chmod_close($conn_id)

    {

    ftp_close($conn_id);

    }

     

    // Connect to the FTP

    $conn_id = chmod_open();

     

    // create folder if it does not exist

    if(!file_exists($_SERVER{'DOCUMENT_ROOT'} . $path_to_parent . $sub_folder))

    {

    chmod_file($conn_id, 777, $parent_folder);

    mkdir($sub_folder, 0755);

    chmod_file($conn_id, 755, $parent_folder);

    }

     

    if(file_exists($_SERVER{'DOCUMENT_ROOT'} . $path_to_parent . $sub_folder))

    {

    echo chmod_file($conn_id, 777, $parent_folder) ? 'CHMODed successfully!<br>' : 'Error<br>';

    echo chmod_file($conn_id, 777, $sub_folder) ? 'CHMODed successfully!<br>' : 'Error<br>';

     

    // upload files here - docupload

    if($_FILES['docupload']['size'] != 0)

    {

    $tempname = $_FILES['docupload']['tmp_name'];

    $actual_filename = $_FILES['docupload']['name'];

    $search = explode(",","ç,æ,œ,á,é,í,ó,ú,à,è,ì,ò,ù,ä,ë,ï,ö,ü,ÿ,â,ê,î,ô,û,å,e,i,ø,u");

    $replace = explode(",","c,ae,oe,a,e,i,o,u,a,e,i,o,u,a,e,i,o,u,y,a,e,i,o,u,a,e,i,o,u");

    $actual_filename = str_replace($search, $replace, $actual_filename);

    if(!move_uploaded_file($tempname, $sub_folder . "/" . $actual_filename)) echo "failure<br>"; else echo "success<br>";

    }

     

    // delete files here if applicable - delete_file[]

    if(count($_REQUEST['delete_file']) > 0)

    {

    for($i=0; $i < count($_REQUEST['delete_file']); $i++)

    {

    $f = $_REQUEST['delete_file'][$i];

    unlink($f);

    }

    }

     

    echo chmod_file($conn_id, 755, $parent_folder) ? 'CHMODed successfully!<br>' : 'Error<br>';

    echo chmod_file($conn_id, 755, $sub_folder) ? 'CHMODed successfully!<br>' : 'Error<br>';

    }

     

    // Close the connection

    chmod_close($conn_id);

     

     

     

  7. Hi Jcbones

     

    I did as you mentioned and I put a echo "<script>alert('here');</script>"; message in my php code on form submission but in FF nothing is happening.  Not even the alert I have in the function AutoSave is appearing.  really stuck on this one.  Thanks for the help.

     

    Fergal.

     

  8. Hi

     

    Below is the code I am using (found after a net search - not mine).  I load init() in body on page load.:

     

    function init()

    {

        window.setInterval(autoSave, 20000); // 20 seconds

        }

     

     

        function autoSave()

                var status = document.getElementById("status").value;

               

                var params = "?status=" + status;

                var http = getHTTPObject();

    http.onreadystatechange = function()

    {

    if(http.readyState == 4 && http.status == 200) // 200 = HTTP OK

    {

    // alert(http.responseText);

    alert("All data for this current participant has been auto saved");

    }

        };

                http.open("POST", "mypageaddress.php" + params, true);

    http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

    http.setRequestHeader("Content-length", params.length);

    http.setRequestHeader("Connection", "close");

                http.send(params);

        }

           

            //cross-browser xmlHTTP getter

            function getHTTPObject() {

                var xmlhttp;

                /*@cc_on

                @if (@_jscript_version >= 5)

                    try {

                        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");

                    }

                    catch (e) {                    try {

                            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

                        }

                        catch (E) {

                            xmlhttp = false;

                        }

                    }

                @else

                    xmlhttp = false;

                @end @*/ 

               

                if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {

                    try { 

                        xmlhttp = new XMLHttpRequest();

                    } catch (e) {

                        xmlhttp = false;

                    }

                }

               

                return xmlhttp;

            }

     

    The page will refresh and I have a php function to update mysql tab if($_SERVER["REQUEST_METHOD"] == "POST")

    { }

     

    but this is not being executed.

     

    Thanks,

     

    Fergal.

     

  9. Hi Guys

     

    I want to be able to autosave a form content every X seconds,

     

    I coded it using php and javascript getHTTPObject() function but it will not work.

     

    Can anyone point me to a php solution to autosave a form

     

    Kind Regards,

     

    Fergal.

  10. Hi Guys

     

    Does anyone know of or could you point me in te right direction for php code to convert uploaded word, excel or powerppoint files to pdf.  Can it be done as part of the file upload process - what software could do this?

     

    I have searched the web and there are plenty of website that allow you to upload a file and it will convert it for you but there are few sites that have the code to do this?

     

    Many thanks,

     

    Fergal.

     

  11. Hi Guys

     

    I want to create anchor tags.  I know how to do this with html.  Here is my problem:

     

    <a href="#myanchor">Go to my anchor</a>

     

    Then I have the <a name set up

     

    But the page reloads with a url as follows:

     

    mypage.php?id=19#myanchor

     

    Where id is an id of a page in a mysql db to pull content.

     

    I have a mod rewrite so the above url is mypage/19#myanchor

     

    Any help to solve this word be appreciated

     

    thanks

     

    Fergal.

     

     

    This is not working

  12. Looked at the csource and yes it is in entity form.

     

    I was trying to ensure that if a user enters something like <script>alert("test")</script> in a form field that on submission of the form the alert box will not work.  The form will not write anything to a database, variables are jsut gathered and emailed in the mail function.

     

    Am I right using htmlspecialchars.  I have spent hours reading forums etc and am confused.

     

    Thanks,

     

    Fergal.

  13. Hi Guys

     

    I have only realised that it is possible to injection javascript <script> tags in form fields.

     

    I read that htmlspecialchars will solve this by encoding < as %lt; etc.

     

    However, I cannot get the function to work.  Does utf-8 encoding have an effect on the function?

     

    Thanks for the help

     

    Fergal.

     

  14. Hi Guys

     

    My host provider will not let me change the durectory permissions to 777.  Hackers possibilities apparently.  Site has been hacked previously.

     

    I was wonder can use php to change the permissions of the directory to 777, upload the file and then set the directory permissions back to 755.

     

    Any help would be greatly appreciated.

     

    Regards

     

    Fergal.

     

  15. Hi Guys

     

    I have a mysql query that checks a table for a match for a userid and a sesion variable.  I store this when the user logs on and wipe it when they log out

     

    Heres the issue.  When I then try to log in again it returns my message about already being logged in even though I would expect the mysq;l query to return 0 it always returns 1.

     

    Heres the code:

     

    $result = mysql_query("SELECT COUNT(*) FROM log_participants WHERE AccountID = '$accid' AND Course = '$course' AND SessionID = '" . mysql_real_escape_string(session_id()) . "'");

    if(!$result) echo mysql_error();

    echo "Result is " . mysql_num_rows($result);

     

    Result is always 1.

     

    Any ideas?

     

    Thanks,

     

    fergal.

     

     

  16. Here is html output from page - is this what you want to see?

     

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <META NAME="robot" CONTENT="all">
    <meta name="revisit-after" content="2 days">
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <link href="css/page_layout.css" rel="stylesheet" type="text/css">
    <script type="text/javascript">
    <!--
    function swap(intImage) 
    {
    switch (intImage) 
    {
     case 1: 
      	document.IMG1.src = "portfolio/PORTFOLIO-16-1.jpg";   
    	break;
     case 2: 
     	document.IMG1.src = "portfolio/PORTFOLIO-16-2.jpg";
        break;
     case 3: 
    	 document.IMG1.src = "portfolio/PORTFOLIO-16-3.jpg";
         break;
     case 4: 
     	document.IMG1.src = "portfolio/PORTFOLIO-16-4.jpg";
        break;
     case 5: 
     	document.IMG1.src = "portfolio/PORTFOLIO-16-5.jpg";
        break;
     case 6: 
     	document.IMG1.src = "portfolio/";
        break;
     case 7: 
     	document.IMG1.src = "portfolio/";
        break;
     case 8: 
     	document.IMG1.src = "portfolio/";
        break;
    case 9: 
     	document.IMG1.src = "portfolio/";
        break;
    case 10: 
     	document.IMG1.src = "portfolio/";
        break;
    }
    }
    //--><!]]>
    </script>
    <!-- ULTIMATE DROP DOWN MENU Version 4.5 by Brothercake -->
    <!-- http://www.udm4.com/ -->
    <script type="text/javascript" src="udm-resources/udm-custom.js"></script>
    <script type="text/javascript" src="udm-resources/udm-control.js"></script>
    <script type="text/javascript" src="udm-resources/udm-style.js"></script>
    </head>
    <body>
    <!-- menu script -->
    <script type="text/javascript" src="udm-resources/udm-dom.js"></script>
    <!-- keyboard navigation module -->
    <script type="text/javascript" src="udm-resources/udm-mod-keyboard.js"></script>
    <div id="content">
      <div id="top_banner">
        <div id="menu">
          <ul id="udm" class="udm">
    <li><a href="/">project</a>
    	<ul>
    	<li><a href="portfolio.php?type=Residential">residential</a>
    	<li><a href="portfolio.php?type=Public">public</a>
    	<li><a href="portfolio.php?type=Conservation">conservations</a>
    	<li><a href="portfolio.php?type=Extensions">extensions & refurbishment</a>
    	</ul>
    </li>
    <li><a href="/">info</a>
    	<ul>
    	<li><a href="news.php">news</a>
    	<li><a href="faqs.php">faqs</a>
    	<li><a href="personnel.php">personnel</a>
    	</ul>
    </li>
    	<li><a href="contact.php">contact</a></li>
    	<li><a href="/">home</a>
    </li>
    </ul>    </div>
      </div>
      <div id="text2" style="height: 300px;">
            <table width="670" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="240" height="286" valign="top"><span style='color: #87B50D; font-size: 14px; font-weight: bold;'>some house</span>,<br><span style='color: #87B50D; font-size: 14px; font-weight: bold;'>waterford </span><br>(<span style='font-size: 13px; font-weight: normal;'>construction</span>)<br><br><div style='text-align: justify;'>some description<br></div>        </td>
            <td width="15" rowspan="2" valign="top"> </td>
            <td width="121" rowspan="2" valign="top"><table width="120" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td valign="top" align="left">                <div align="center"> <a href="#" onmouseover="swap(1);"> <img style="border: 1px solid #C8C8C8;" src="portfolio/PORTFOLIO-TN-16-1.jpg" width="54" height="54" /> </a> </div>
                                  </td>
                  <td valign="top" align="left">                <div align="center"> <a href="#" onmouseover="swap(2);"> <img style="border: 1px solid #C8C8C8;" src="portfolio/PORTFOLIO-TN-16-2.jpg" width="54" height="54" /> </a> </div>
                                  </td>
                </tr>
                <tr>
                  <td valign="top" align="left">                <div align="center"> <a href="#" onmouseover="swap(3);"> <img style="border: 1px solid #C8C8C8;" src="portfolio/PORTFOLIO-TN-16-3.jpg" width="54" height="54" /> </a> </div>
                                  </td>
                  <td valign="top" align="left">                <div align="center"> <a href="#" onmouseover="swap(4);"> <img style="border: 1px solid #C8C8C8;" src="portfolio/PORTFOLIO-TN-16-4.jpg" width="54" height="54" /> </a> </div>
                                  </td>
                </tr>
    
                <tr>
                  <td valign="top" align="left">
    		                  <div align="center"><a href="#" onmouseover="swap(5);"><img style="border: 1px solid #C8C8C8;" src="portfolio/PORTFOLIO-TN-16-5.jpg" width="54" height="54" /> </a> </div>
                                  </td>
                  <td valign="top" align="left">              </td>
                </tr>
    
                <tr>
                  <td valign="top" align="left">              </td>
                  <td valign="top" align="left">              </td>
                </tr>
                <tr>
                  <td valign="top" align="left">              </td>
                  <td valign="top" align="left">              </td>
                </tr>
              </table></td>
            <td width = "294" rowspan="2" valign="top">          <div align="center"> <img style="border: 1px solid #C8C8C8;" id="IMG1" name="IMG1" src="portfolio/PORTFOLIO-16-1.jpg" /> </div>
                      </td>
          </tr>
          <tr>
            <td valign="top"><div align="right"><a href="portfolio2b.php?s=0&type=Residential&id=16"><b>Next >></b></a></div></td>
          </tr>
        </table>
      </div>
      <div id="bottom_banner"></div>
    </div>
    <div class="left column">
      <div id="leftcol"></div>
    </div>
    <div class="right column">
      <div id="rightcol"></div>
    </div>
    <script language="Javascript">
          function replaceText(text){
          while(text.lastIndexOf("&") > 0){
    	      text = text.replace('&', '[i-Stats]');
          }
          return text;
          }
    
          var web_referrer = replaceText(document.referrer);
          <!--
          istat = new Image(1,1);
          istat.src = "http://somedomain.ie/webadmin/vstats/counter.php?sw="+screen.width+"&sc="+screen.colorDepth+"&referer="+web_referrer+"&page="+location.href;
          //-->
    </script>
    </body>
    </html>

     

  17. Hi Guys

     

    I have a problem that is really puzzling me.  I allow a client upload 10 images and 10 thumbnails using file upload fields.  However, the images appear not to go up i.e. when I view the webpage where the images are they appear fine when views in safari but not visibel in IE.  So how t=only the first 4 are holding previous images on upload also.

     

    Here is the code:

     

    $rid = $_REQUEST['rid'];
    $event_query = mysql_query("SELECT * FROM portfolio WHERE RecordID = '$rid'");
    if(!$event_query) echo mysql_error();
    $event_data = mysql_fetch_array($event_query);
    
    $error_msg = '';
    if(isset($_POST['submit_button']))
    {
    
    if(trim($_POST['category']) == 'please') 
    {
    	$category_msg .= "Please choose a category for the item:<br>";
    	$error_msg = 'You have some errors you need to fix before you proceed.';
    }
    
    if(trim($_POST['title']) == '') 
    {
    	$title_msg .= "Please enter a title for the item:<br>";
    	$error_msg = 'You have some errors you need to fix before you proceed.';
    }
    
    if(trim($_POST['address']) == '') 
    {
    	$address_msg .= "Please enter an address for the item:<br>";
    	$error_msg = 'You have some errors you need to fix before you proceed.';
    }
    
    if(trim($_POST['status']) == '') 
    {
    	$status_msg .= "Please enter the status of the item:<br>";
    	$error_msg = 'You have some errors you need to fix before you proceed.';
    }
    
    if(trim($_POST['details']) == '') 
    {
    	$details_msg .= "Please enter the details of the item:<br>";
    	$error_msg = 'You have some errors you need to fix before you proceed.';
    }
    
    if($_POST['homepage'] == 'please') 
    {
    	$homepage_msg .= "Please choose if you wish this item to be featured on the homepage strip:<br>";
    	$error_msg = 'You have some errors you need to fix before you proceed.';
    }
    
    function getFileExtension($str) 
    {
            $i = strrpos($str,".");
            if (!$i) { return ""; }
    
            $l = strlen($str) - $i;
            $ext = substr($str,$i+1,$l);
    
            return $ext;
    }
    
    
    
    for($i = 0; $i < count($_FILES['photos']['tmp_name']); $i++)
    {  
        $tempname = $_FILES['photos']['tmp_name'][$i];   
    	$actual_filename = $_FILES['photos']['name'][$i];
    	if($actual_filename != "") 
    	{									
    		// checks to see if image file, if not do not allow upload 
    		$pext = getFileExtension($actual_filename);
    		$pext = strtolower($pext);
    		if (($pext != "jpg")  && ($pext != "jpeg") && ($pext != "gif"))
    		{
    			$photo_msg .= "Please upload only a GIF or JPEG image with the extension .gif or .jpg or .jpeg ONLY. The image file you are attempting to upload has the following extension: .$pext<br>";
    			$error_msg = 'You have some errors you need to fix before you proceed.';	
    		}
    
    		if($_FILES['photos']['size'][$i] >  $_POST['MAX_FILE_SIZE'])
    		{
    			$photo_msg .= "Your image " . $actual_filename . " is greater than the maximum allowed size of 2 MB (Mega Byte):<br>";
    			$error_msg = 'You have some errors you need to fix before you proceed.';	
    		}
    	}
    }	// end of for loop
    
    for($i = 0; $i < count($_FILES['thumbnailphotos']['tmp_name']); $i++)
    {  
        $tempname = $_FILES['thumbnailphotos']['tmp_name'][$i];   
    	$actual_filename = $_FILES['thumbnailphotos']['name'][$i];
    	if($actual_filename != "") 
    	{									
    		// checks to see if image file, if not do not allow upload 
    		$pext = getFileExtension($actual_filename);
    		$pext = strtolower($pext);
    		if (($pext != "jpg")  && ($pext != "jpeg") && ($pext != "gif"))
    		{
    			$photo_msg .= "Please upload only a GIF or JPEG image with the extension .gif or .jpg or .jpeg ONLY. The image file you are attempting to upload has the following extension: .$pext<br>";
    			$error_msg = 'You have some errors you need to fix before you proceed.';	
    		}
    
    		if($_FILES['thumbnailphotos']['size'][$i] >  $_POST['MAX_FILE_SIZE'])
    		{
    			$photo_msg .= "Your thumbnail image " . $actual_filename . " is greater than the maximum allowed size of 2 MB (Mega Byte):<br>";
    			$error_msg = 'You have some errors you need to fix before you proceed.';	
    		}
    	}
    }	// end of for loop
    }	
    
    if(isset($_POST['submit_button']) && $error_msg == '')
    {
    $category = $_POST['category'];
    $title = addslashes($_POST['title']);
    $status = addslashes($_POST['status']);
    $address = addslashes($_POST['address']);
    $details  = addslashes($_POST['details']);
    $homepage = $_POST['homepage'];
    $date = date("Y-m-d");
    
    $update = mysql_query("UPDATE portfolio SET Type='$category', Title='$title', Status='$status', Address='$address', Details='$details', Homepage='$homepage', Last_Modified='$date', By_Who2='$username' WHERE RecordID = '$rid'");
    if(!$update) { echo mysql_error(); }
    
    // update and resize the image here
    $uploaddir = "../portfolio/";
    if (!is_dir("$uploaddir")) die ("The directory <b>($uploaddir)</b> doesn't exist"); 
    if (!is_writable("$uploaddir")) die ("The directory <b>($uploaddir)</b> is NOT writable, Please Chmod (777)"); 
    
    /*
    for($r = 1; $r <= 11; $r++)
    {
    	$rtbname = "delete_image" . $r;
    	if(!empty($_POST[$rtbname]))
    	{
    		echo "here";
    		unlink("../portfolio/". $_POST[$rtbname]);
    		$rtbfield = "ImageID" . $r;
    		$rdel = mysql_query("UPDATE portfolio SET $rtbfield = '' WHERE RecordID = '$rid'");	
    		if(!$rdel) echo mysql_error();
    	}
    }
    
    for($t = 1; $t <= 10; $t++)
    {
    	$tbname = "tb_delete_image" . $t;
    	if(!empty($_POST[$tbname]))
    	{
    		echo "here";
    		unlink("../portfolio/". $_POST[$tbname]);
    		$tbfield = "Thumbnail_ImageID" . $t;
    		$del = mysql_query("UPDATE portfolio SET $tbfield = '' WHERE RecordID = '$rid'");	
    		if(!$del) echo mysql_error();
    	}
    }
    */
    
    function imageResize($inputFilename, $target) 
    {
    	$pext = getFileExtension($inputFilename);
    	$pext = strtolower($pext);
    	$imagedata = getimagesize($inputFilename);
    	$w = $imagedata[0];
    	$h = $imagedata[1];
    
    	if ($h > $w) {
    		$new_w = ($target / $h) * $w;
    		$new_h = $target;	
    	} else {
    		$new_h = ($target / $w) * $h;
    		$new_w = $target;
    	}
    
    	$im2 = imagecreatetruecolor($new_w, $new_h);
    	if($pext == "jpg" || $pext == "jpeg")
    		$image = imagecreatefromjpeg($inputFilename);
    	else
    		$image = imagecreatefromgif($inputFilename);
    
    	imagecopyresampled ($im2, $image, 0, 0, 0, 0, $new_w, $new_h, $imagedata[0], $imagedata[1]);
    return $im2;
    }
    
    for($i=0; $i < count($_FILES['photos']['tmp_name']); $i++)
    {
    	if($_FILES['photos']['size'][$i] != 0)
    	{
    				$tempname = $_FILES['photos']['tmp_name'][$i];
    				$actual_filename = $_FILES['photos']['name'][$i];
    				$pext = getFileExtension($actual_filename);
    				$pext = strtolower($pext);
    				if($i == 10)
    					$filename = "BW-PORTFOLIO-" . $rid  . "-" . ($i+1) . "." . $pext; 
    				else
    					$filename = "PORTFOLIO-" . $rid  . "-" . ($i+1) . "." . $pext; 
    				$uploadfile = $uploaddir . $filename;	
    
    				if($tempname != '')
    				{							
    					if(file_exists($uploadfile)) unlink($uploadfile);
    					if(move_uploaded_file($tempname, $uploadfile)) echo "ok"; else echo "not ok";
    
    					$imgsize = getimagesize($uploadfile);
    					$max_size = 290; // for width and height of the image
    					if (($imgsize[0] > $max_size) || ($imgsize[1] > $max_size))
    					{
    						$img = imageResize($uploadfile, $max_size);
    						if($pext == "gif")
    							imagegif($img, $uploadfile, 80);
    						else
    						{
    							imageinterlace($img,1);
    							imagejpeg($img, $uploadfile, 80);											
    						}
    						imagedestroy($img);											
    					}
    				}
    
    		$fieldname = "ImageID". ($i+1);
    		$q3 = mysql_query("UPDATE portfolio SET $fieldname = '$filename' WHERE RecordID = '$rid'");
    		if(!$q3) echo mysql_error();		
    	}  		// end of if for size			
    } 			// end of for loop
    
    for($i=0; $i < count($_FILES['thumbnailphotos']['tmp_name']); $i++)
    {
    	if($_FILES['thumbnailphotos']['size'][$i] != 0)
    	{
    				$tempname = $_FILES['thumbnailphotos']['tmp_name'][$i];   
    				$actual_filename = $_FILES['thumbnailphotos']['name'][$i];
    				$pext = getFileExtension($actual_filename);
    				$pext = strtolower($pext);
    				$filename = "PORTFOLIO-TN-" . $rid  . "-" . ($i+1) . "." . $pext; 
    				$uploadfile = $uploaddir . $filename;	
    
    				if($tempname != '')
    				{							
    					if(file_exists($uploadfile)) unlink($uploadfile);
    					move_uploaded_file($tempname, $uploaddir.$filename);
    
    					$imgsize = getimagesize($uploadfile);
    					$max_size = 110; // for width and height of the image
    					if (($imgsize[0] > $max_size) || ($imgsize[1] > $max_size))
    					{
    						$img = imageResize($uploadfile, $max_size);
    						if($pext == "gif")
    							imagegif($img, $uploadfile, 80);
    						else
    						{
    							imageinterlace($img,1);
    							imagejpeg($img, $uploadfile, 80);											
    						}
    						imagedestroy($img);											
    					}
    				}
    
    		$fieldname = "Thumbnail_ImageID". ($i+1);
    		$q3 = mysql_query("UPDATE portfolio SET $fieldname = '$filename' WHERE RecordID = '$rid'");
    		if(!$q3) echo mysql_error();		
    	}  		// end of if for size			
    } 			// end of for loop
    
    // header("location: manage_portfolio1.php?result=2");
    // exit();
    }
    ?>
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/transitional.dtd"> 
    <html>
    <head>
    <title>Client Website Administration Application</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <link href="cms.css" rel="stylesheet" type="text/css">
    <style type="text/css">
    <!--
    .style1 {color: #FF0000}
    .style2 {color: #000000}
    -->
    </style>
    </head>
    
    <body>
    <table width="780" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr bgcolor="#000000">
        <td height="1" colspan="3"></td>
      </tr>
      <tr>
        <td width="1" rowspan="2" bgcolor="#000000"></td>
        <td height="13" valign="top" bgcolor="#FFFFFF"><?php include 'header.php' ?></td>
        <td bgcolor="#000000"></td>
      </tr>
      <tr>
        <td valign="top" bgcolor="#FFFFFF"><div align="center">
          <table width="96%" border="0" cellspacing="0" cellpadding="0" align="left">
            <tr>
              <td width = "13"> </td>
              <td width="734" valign="top"><p align="left"><br>
                  <br>
                  <?php
    		  if(isset($_POST['submit_button']) && $error_msg != '') echo "<font color ='#FF0000' style='font-size: 13px'>$error_msg</font><br><br>";
    		  if($category_msg != "") echo "<font color='#FF0000'>$category_msg</font>";
    		  if($title_msg != "") echo "<font color='#FF0000'>$title_msg</font>";
    		  if($status_msg != "") echo "<font color='#FF0000'>$status_msg</font>";
    		  if($address_msg != "") echo "<font color='#FF0000'>$address_msg</font>";
    		  if($details_msg != "") echo "<font color='#FF0000'>$details_msg</font>";
    		  if($address_msg != "") echo "<font color='#FF0000'>$address_msg</font>";
    		  if($homepage_msg != "") echo "<font color='#FF0000'>$homepage_msg</font>";
    		  if($photo_msg != "") echo "<font color='#FF0000'>$photo_msg</font>";
    		  ?>
                  <strong>Modify an Existing Portfolio Item</strong></p>
                  <p align="left">Modify an exiting item in the website. (Date this portfolio item was last updated: 
    			<?php
    			$da = explode("-", $event_data["Last_Modified"]);
    			echo $da[2] . "-" . $da[1] . "-" . $da[0];	
    			echo " By: " . $event_data["By_Who2"];		
    			?>
    			)
    		  </p>			
                <form action="manage_portfolio2.php" method="post" enctype="multipart/form-data" name="edit_portfolio">
                  <div align="left">
                    <table width="91%"  border="0" align="left" cellpadding="0" cellspacing="0">
    			    <tr>
    						      <td height="25">* Portfolio Category: </td>
    		                      <td width="73%" height="25">
    							   <select name="category" class="formitems" id="category">
    		                        <option value="please">Please select...</option>
    								  <?php
    								  $cat = array('Residential','Public','Conservation','Extensions');
    								  for($y = 0; $y < sizeof($cat); $y++)
    								  {
    								  echo "<option value='" . $cat[$y] . "'";
    								  	  if(!isset($_REQUEST['submit_button']))
    									  { 
    									  	if($cat[$y] == $event_data['Type']) echo " selected";
    									  }
    									  else
    									  {
    									  	if($cat[$y] == $_POST['category']) echo " selected";										  
    									  }
    								  echo ">" . $cat[$y] . "</option>";
    								  }
    								  ?>
    	                           </select>
    							  </td>
                      </tr>
    
                      <tr>
                        <td width="21%" height="25"><span class="style1">*</span> Title of Portfolio Item: </td>
                        <td width="79%" height="25"><input name="title" type="text" class="formitems" id="title" size="50" value="<?php if(isset($_POST['submit_button'])) echo preg_replace('/\\\\/','', $_POST['title']); else echo preg_replace('/\\\\/','', $event_data['Title']); ?>"></td>
                      </tr>
    			    
                      <tr>
                          <td width="31%" height="25">* Status of Portfolio Item: </td>
                          <td height="25"><input name="status" type="text" class="formitems" id="status" size="50" value="<?php if(isset($_POST['submit_button'])) echo preg_replace('/\\\\/','', $_POST['status']); else echo preg_replace('/\\\\/','', $event_data['Status']); ?>"></td>
                      </tr>
    			    
                        <tr>
                          <td width="27%" height="25">* Address of Portfolio Item: </td>
                          <td height="25"><input name="address" type="text" class="formitems" id="address" size="50" value="<?php if(isset($_POST['submit_button'])) echo preg_replace('/\\\\/','', $_POST['address']); else echo preg_replace('/\\\\/','', $event_data['Address']); ?>"></td>
                        </tr>		
    
                      <tr>
                        <td height="25"><span class="style2">*</span> Portfolio Item Details:</td>
                        <td height="25"><textarea name="details" cols="60" rows="12" class="formitems" id="details"><?php if(isset($_POST['submit_button'])) echo preg_replace('/\\\\/','', $_POST['details']); else echo preg_replace('/\\\\/','', $event_data['Details']); ?></textarea></td>
                      </tr>
                      
                      <tr>
                        <td height="25" colspan="2"> </td>
                      </tr>
    			    
                        <tr>
                          <td width="27%" height="25">* Use Image 1 Item on Homepage: </td>
                          <td height="25">
    				  <select name="homepage" class="formitems" id="homepage">
                          <option value="please">Please select...</option>
    				  <?php
    				  $choice = array('Yes','No');
    				  for($x = 0; $x < sizeof($choice); $x++)
    				  {
    				  echo "<option value='" . $choice[$x] . "'"; 
    				  	if(!isset($_REQUEST['submit_button']))
    					{ 
    						if($choice[$x] == $event_data['Homepage']) echo " selected";
    					}
    				 	else
    					{
    						if($choice[$x] == $_POST['homepage']) echo " selected";									  
    					}					  
    				  echo ">" . $choice[$x] . "</option>";
    				  }
    				  ?>
    				  </select>
    				  
    				  </td>
                        </tr>						  
    			  
    			  <?php
    				  function imageResize2($width, $height, $target) 
    					{ 						
    						if ($width > $height) 
    							$percentage = ($target / $width);  
    						else 
    							$percentage = ($target / $height); 
    
    						$width = round($width * $percentage); 
    						$height = round($height * $percentage); 
    					return "width=\"$width\" height=\"$height\""; 						
    					}
    
    				for($f = 1; $f <= 11; $f++)
    				{
    				?>
    
    			  <?php
    			  if($f == 1)
    			  {
    			  ?>
    			  <tr>
    			  <td colspan="3">
    			  	<?php echo "<h3>Main Images</h3><b>Note: Please ensure all images you are uploading are resized to the same height and width. Minimum height and width of 290px.</b><br><br>"; ?>					
    			  </td>
    			  </tr>
    			  <?php
    			  }
    			  ?>
    			  
    				<tr>
                        <td height="25" colspan="2">
                          <?php		
    				    $field = "ImageID" . $f;	
    					$path = "../portfolio/" . $event_data[$field];
    					if(!empty($event_data[$field]))
    					{
    						$main = getimagesize("../portfolio/" . $event_data[$field]); 
    						echo "<img border='1' src='../portfolio/" . $event_data[$field] . "' ";
    						echo imageResize2($main[0],  $main[1], 90);
    						echo ">";
    						echo "<br>Delete this Image: ";
    						echo "<input type='checkbox' name='delete_image" . $f . "' value='" . $event_data[$field] . "'/><br>";
    					    echo "<b>You currently have an image uploaded for this item - Image ID " . $f . "</b><br>";
    					}
    					else
    					  echo "<br><br><b>You currently have no image uploaded for this item - Image ID " . $f . "</b><br>";
    					?>
    				 </td>
                      </tr>				  
                     				  
                      <tr>
                        <td height="25">
    				<?php
    				if($f == 11)
    					echo "Upload Greyscale Image for Image 1:";
    				else
    					echo "Upload Image ". ($f) . " for Item:";
    				?>					
    				</td>
                        <td height="25"><input name="photos[]" type="file" class="formitems" id="photos[]">
    				</td>
                      </tr>	
    			  <tr>
                        <td height="25" colspan="2"><hr></td>
                      </tr>			  
    			  <?php 
    			  }				  
    			  ?>
    			  
                      <tr>
                        <td height="25" colspan="2"> </td>
                      </tr>
    			  
    			  <?php
    			  for($tb = 1; $tb <= 10; $tb++)
    			  {
    			  if($tb == 1)
    			  {
    			  ?>
    			  <tr>
    			  <td colspan="2">
    			  	<?php echo "<h3>Thumbnail Images</h3><b>Note: Please ensure all thumbnail images you are uploading are resized to the same height and width. Minimum height and width of 110px.</b><br><br>"; ?>					
    			  </td>
    			  </tr>
    			  <?php
    			  }
    			  ?>
    			  
    				<tr>
                        <td height="25" colspan="2">
                          <?php		
    				    $field = "Thumbnail_ImageID" . $tb;	
    					$path = "../portfolio/" . $event_data[$field];
    					if(!empty($event_data[$field]))
    					{
    						$main = getimagesize("../portfolio/" . $event_data[$field]); 
    						echo "<img border='1' src='../portfolio/" . $event_data[$field] . "' ";
    						echo imageResize2($main[0],  $main[1], 90);
    						echo ">";
    						echo "<br>Delete this Thumbnail Image: ";
    						echo "<input type='checkbox' name='tb_delete_image" . $tb . "' value='" . $event_data[$field] . "'/><br>";
    					    echo "<b>You currently have a thumbnail image uploaded for this item - Thumbnail Image ID " . $tb . "</b><br>";
    					}
    					else
    					  echo "<br><br><b>You currently have no thumbnail image uploaded for this item - Thumbnail Image ID " . $tb . "</b><br>";
    					?>
    				 </td>
                      </tr>				  
                     				  
                      <tr>
                        <td height="25">
    				<?php
    				echo "Upload Image ". ($tb) . " for Item:";
    				?>					
    				</td>
                        <td height="25"><input name="thumbnailphotos[]" type="file" class="formitems" id="thumbnailphotos[]">
    				</td>
                      </tr>	
    			  <tr>
                        <td height="25" colspan="2"><hr></td>
                      </tr>			  
    			  <?php 
    			  }				  
    			  ?>
    			  
                      <tr>
                        <td colspan="2"><span class="style2">*</span> indicates a required field<br></td>
                      </tr>
                      <tr>
                        <td colspan="2"><p> <br>
                                <input type="hidden" name="MAX_FILE_SIZE" value="1990000">
    						 <input type="hidden" name="rid" value="<?php echo $rid; ?>">
                                <input name="submit_button" type="submit" class="formbuttons" value="Update Portfolio Item">
                                <br>
                                <br>
                        </p></td>
                      </tr>
                    </table>
                  </div>
                </form>

     

    I cannot see the issue.  Any suggestions?

     

    thanks,

     

    Fergal.

     

     

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