Jump to content

davil

Members
  • Posts

    39
  • Joined

  • Last visited

Everything posted by davil

  1. Yeah maybe... I know this sounds stupid but I have to ask .... if I save as filtered html in Word, then re-open and save as MHT or XML will it gain all the same crap code again? I suppose if I really want to go down this road (crazy as it is) I could write a small EXE for the client that saves it as filtered HTML and then zips up all the stuff for upload. It is a bit crazy though alright. :-D btw, Is ckeditor any better than fckeditor (I don't mind fixing a few bugs if they're small and fixable by PHP)
  2. Yeah I know, an absolute nightmare. But I'm being optimistic here and thinking I might be able to clean it up a bit. :-D
  3. Ok so I tested the MHTML class - it's not too bad actually. Sure the code needs to be cleaned up a little bit but here's an example: http://www.thedavil.com/testing/Augustinian Saints and Blessed.doc got converted to http://www.thedavil.com/testing/index.htm Which isn't terrible. but not great either. I'm going to do a bit more work on this MHT way of doing things but I'm not gonna work too hard - if it doesn't work out then I'll go back to manual. My next step is too see if I can get that HTML into the Rich Text Editor and see can the little kinks be worked out there. because if they can, it's just a case of moving the files around and putting the HTML into the database and I'm onto a winner..... Still dubious though
  4. Well at least you're honest. Yeah I thought as much myself but there's just *SO* much crap to do. - I myself have no trouble in getting images from documents and saving them as JPG and uploading, but client isn't that tech savvy. but if it's something he can do in word, like save as MHT and then upload, he'd get it. I understand your point and agree whole-heartedly. However if I can get the stuff into the Database and the JPGS up to the server any way at all I'd be happy, and then he can edit the kinks out of each article later on himself. I just found this MHTML class and will test: http://www.phpclasses.org/browse/file/23132.html The stuff it outputs seems ok. I can strip a lot of the nasty crappy Word HTML code and tags myself with PHP if necessary but I do have a feeling that yeah this is going to be a lost cause. Thanks anyway for posting your opinion.
  5. Hi all, I was just wondering if anybody has any experience of this. Basically, I'm building a site for a guy and he keeps throwing tonnes of content my way, all Word docs with tables, images, etc. The site is PHP / MySQL based and when it's handling text it's so easy to use. I want it to preserve formatting if possible and maybe where the images are (aligned left or right at the very least) At the moment I have integrated a Javascript RTE (Rich Text Editor) called fckeditor, an earlier version of Ckeditor [ http://ckeditor.com/ ] I think fckeditor is free for commercial projects and Ckeditor isn't (could be wrong but it doesn't matter too much to my main query anyhow) So basically the user will have to copy in each block of text and then upload each image seperately and align it left or right or whatever, which is fine by me, but for the moment I need to put some of these docs in myself, and it can be very, very, time-consuming. I'm looking into ways to get his word documents up in the most automatic way possible. Here are a few of my options 1. wvWare - wvware.sourceforge.net/ I'm not exactly sure how to install it but I do have a VPS so it should be at least possible. Does anybody have any experience using this ? I suppose the question I'm asking is: Does it work? 2. There are a few RTF to html converters here etc.: http://www.w3.org/Tools/Word_proc_filters.html but nothing that seems to do the job for me so far. I'm afraid to start downloading them all and testing because I'm on a tight schedule here and I just need to know what will actually work for me. 3. I could ask the user to save the file as XML (he's bright enough) and then use simplexml to parse, but I'm having trouble finding any info on google about using simplexml to extract the image bits to files or whatever. Perhaps storing them in the MySQL database as binary is the best way but I'd prefer not to have the overhead if possible and just to save JPG or PNG files out and have the html link to them. Is there anybody out there that has done this before? 4. Maybe there's a client-side app for this ? Written in Java or Flash or something ??? 5. Perhaps MHTML - I could get him to save as .MHT archive and then do something with PHP on the server side - if I can't find any other solution I will probably try this one next. So does anybody know of the best option for this or should I stick with the Rich text editor road ? Any alternative (that works and is relatively easy for the client to do) is fine. Thanks in advance
  6. I finally got it fixed by forcing htmlentities output to UTF-8 - I didn't realise you could do this. anyway, the code goes like this now: $newsideorders=htmlentities($var,ENT_QUOTES,'UTF-8'); I can't believe it was that simple. Thanks for any help given.
  7. Ok so I did this: echo 'dump1->'; var_dump($_POST['newsideorders']); $newsideorders = htmlentities($_POST['newsideorders']); echo '<br/>dump2->'; var_dump($newsideorders); and here is the output (before the browser parses it) dump1->string(6) "Dégas" dump2->string(18) "Dégas" Perhaps PHP needs to be rebuilt on my server ?? I dunno
  8. Sorry I wasn't very clear. In the second bit of code, é becomes &éacute; - which is perfect. but for some reason in the larger code that's not happening. I will try var_dump now. Thanks
  9. Here's my Code <h1>Edit Side-Orders</h1> <br/><br/> <h2>Input Side Orders here for <strong>[ <?php print_r($_POST); //FOR DEBUGGING $menuid = MySanitiseFunction($_REQUEST['menuid']); $newprice = MySanitiseFunction($_POST['newprice']); // just standard htmlentities instead of my sanitise function because I'm debugging $newsideorders = htmlentities($_POST['newsideorders']); if (!isset($_POST['frubmit'])){// IF SUBMIT BUTTON HASN'T BEEN CLICKED THEN ECHO OUT A PAGE /*---- First we retrieve the menu name and just echo it out --- */ //get menu name and description from SQL $sql1 = "SELECT `name` from `menus` WHERE id='$menuid' LIMIT 1"; $res1 = mysql_query($sql1) or die(mysql_error()); $row1 = mysql_fetch_array($res1); echo $row1['name'].' ]</h2>'; /*------------------------------------------------ */ // Retrieve side-orders from specific menu $sql = "SELECT `price`,`sideorders` from `sideorders` WHERE menu='$menuid'"; $res = mysql_query($sql) or die(mysql_error()); $row = mysql_fetch_array($res); foreach ($row as $key => $value) {$$key = $value;} ?> <form enctype='multipart/form-data' method='post' action='index.php'> <input type='hidden' name='locate' value='editsideorders'> <input type='hidden' name='menuid' value='<?php echo $menuid ?>'> <br/><h3>PRICE: €<input type='text' name='newprice' value='<?php echo $price ?>'/> <input type='submit' name='frubmit' value='Submit All Changes on Page' /></h3> <br/><br/> <h3>SIDE-ORDERS LIST</h3> <?php echo "<textarea rows='20' cols='80' name='newsideorders'>$sideorders</textarea>"; ?> <br/><br/> </form> <?php } else {// Submit Changes button has been pressed, input data onto database $sql = "UPDATE `sideorders` SET `sideorders` = '$newsideorders',`price` = '$newprice' WHERE `menu` = '$menuid' LIMIT 1;"; echo "<br/><br/>SQL = [$sql]"; mysql_query($sql) or die (mysql_error()); //My_redirect_Function("index.php?locate=viewmenu&id=$menuid"); - Don't redirect for the moment (debugging) } ?> here's the output I'm getting Array ( [locate] => editsideorders [menuid] => 1 [newprice] => 3.50 [frubmit] => Submit All Changes on Page [newsideorders] => dégas ) SQL = [uPDATE `sideorders` SET `sideorders` = 'dégas',`price` = '3.50' WHERE `menu` = '1' LIMIT 1;]</div> so basically I'm wondering why é is becoming Ã&copy whereas if I simplify this code down to <?php $text=htmlentities($_POST['text1']); if (!isset($_POST['frubmit'])){ echo <<<HEREZ <form enctype='multipart/form-data' method='post' action='test7.php'> Input entity Text: <textarea rows='20' cols='40' name="text1"></textarea> <input type="submit" name="frubmit" /> </form> HEREZ; } else{ $sql = "UPDATE `whatever` SET `whatever` = '$text'"; echo "<br/><br/>SQL = [$sql]"; } ?> It works fine...... So What am I doing wrong in the top bit of code??? P.S. the reason it posts to index.php is because I use that as my main PHP and then include PHP files based on $locate variable (see hidden input in the form) P.P.S. it works fine on my local WAMP setup (I use the Uniform Server on Windows) but not on my uploaded version (CPANEL / LINUX) - phpinfo() gives similar results on both for default charset etc. so I'm completely stumped
  10. Thanks for your code kenrbnsn it really helped me through a tight spot... I modified it a bit to suit my needs and here is the final code. I can't believe I never thought of using arrays like that.... I really have a lot to learn about program design... I'd love to go to college to study computer science but I can't afford it. ah well. maybe next year... anyway here's the final code more or less.... I will be adding a lot of bells and whistles but it does what I need it for the minute so here goes: <pre> <?php require("..\config.php"); $repl="$-$$"; $spr="*"; $data = explode($repl,$HTTP_SERVER_VARS['PATH_INFO']); $new = array(); $fields = array('','datestamp','timestamp','hostname','serial1','serial2','serial3','primaryip','primarymac','lastuser','make','model', 'chassis_type','cpu_info','cpu_info2','hdd','optical','ram','os','sp','iever','av','avver','avdat','monitor','chipset','audio', 'currproxy','lanproxy'); // I want the program to only watch these fields for changes.. I will program that // in later - I could have done all this with IF but I knew that this would change // dynamically and I wanted the program to be more versatile. $watchedfields = array ('ram','primarymac','serial1','serial2','serial3'); //remove MB from amount of ram, i.e. 1024*MB becomes simply 1024 $data[17] = str_replace('*MB','',$data[17]); //remove periods from serial3 $new['serial3'] = str_replace(".","", $new['serial3']); $new['datestamp'] = $data[1]; //leave this for now as it is another thing entirely that's not too important to what I'm doing currently //$new['datestamp']=str_replace($repl, "/", $new['datestamp']); for ($i=2;$i<count($fields);$i++) $new[$fields[$i]] = str_replace($spr,' ',$data[$i]); $sqlone = "SELECT * FROM `aidahardware` where `hostname` = '" . $new['hostname'] . "' LIMIT 1"; $result = mysql_query($sqlone) or die("Problem with the query: $sqlone<br>" . mysql_error()); $row = mysql_fetch_assoc($result); foreach ($fields as $dmy => $fld) { if ($new[$fld] != $row[$fld]) {echo $fld." has changed,old value: [" . $row[$fld] . "] new value: [" . $new[$fld]. "]\n";} } ?>
  11. The reason for this is over 40 variables... I'm sorry I really should have mentioned there are loads of them. This is the reason I don't want to have an "If" condition for each one, like in the code you just mentioned... as it seems a bit inefficient when I could do it properly using a foreach loop.... also I should mention I am using the following code to create the $new_timestamp etc. variables, [edit]well not this exact code, but this kind of idea: instead of using $_REQUEST I'm actually splitting the data from PATH_INFO but it's the same sort of deal[/edit] $new_timestamp=$_REQUEST['timestamp']; $new_datestamp=$_REQUEST['datestamp']; etc. etc. and then pulling out the old timestamp and old datestamp etc. etc. from the SQL database and I want to check each one against their older counterpart if you get me.... and I don't want to have to write a seperate "IF" statement for each variable ... especially seeing as I already have over 40 variables and it is likely I will add even more in the future. If it is impossible to do it any other way I will use seperate "if" conditions but otherwise I'd like to know how to do this properly. Thanks oh just as a matter of interest here's the full code: <pre> <?php require ("..\config.php"); $repl="$-$$"; $spr="*"; $data = explode($repl,$HTTP_SERVER_VARS['PATH_INFO']); $new_datestamp = $data[1]; $new_datestamp=str_replace($repl, "/", $new_datestamp); $new_timestamp = str_replace($spr," ", $data[2]); $new_hostname = str_replace($spr," ", $data[3]); $new_serial1 = str_replace($spr," ", $data[4]); $new_serial2 = str_replace($spr," ", $data[5]); $new_serial3 = str_replace($spr," ", $data[6]); $serial3 = str_replace(".","", $serial3); $new_primaryip = str_replace($spr," ", $data[7]); $new_primarymac = str_replace($spr," ", $data[8]); $new_lastuser = str_replace($spr," ", $data[9]); $new_make = str_replace($spr," ", $data[10]); $new_model = str_replace($spr," ", $data[11]); $new_chassis_type = str_replace($spr," ", $data[12]); $new_cpu_info = str_replace($spr," ", $data[13]); $new_cpu_info2 = str_replace($spr," ", $data[14]); $new_hdd = str_replace($spr," ", $data[15]); $new_optical = str_replace($spr," ", $data[16]); $new_ram = str_replace($spr," ", $data[17]); $new_os = str_replace($spr," ", $data[18]); $new_sp = str_replace($spr," ", $data[19]); $new_iever = str_replace($spr," ", $data[20]); $new_av = str_replace($spr," ", $data[21]); $new_avver = str_replace($spr," ", $data[22]); $new_avdat = str_replace($spr," ", $data[23]); $new_monitor = str_replace($spr," ", $data[24]); $new_chipset = str_replace($spr," ", $data[25]); $new_audio = str_replace($spr," ", $data[26]); $new_cproxy = str_replace($spr," ", $data[27]); $new_lproxy = str_replace($spr," ", $data[28]); $sqlone = "SELECT * FROM `aidahardware` where `hostname` = '$new_hostname' LIMIT 1"; $result = mysql_query($sqlone) or die(mysql_error()); $row = mysql_fetch_array($result); foreach ($row as $key => $value) { $$key = $value; if ($new_$$key==$$key){echo "$new_$$key is equal to $$key\n"; } ?> }
  12. Ok so I'm getting into PHP and I have a decent sized MySQL/PHP database system working fine but I'm having problems with the foreach command... When I get the info from a MySQL database I usually use the following command to assign a variable to each value: foreach ($row as $key => $value) {$$key = $value;} This works perfectly but I was wondering is there a way to check something like $datestamp vs $new_datestamp and $timestamp vs $new_timestamp by doing something like this code below? foreach ($row as $key => $value) { $$key = $value; if ($new_$$key==$$key){echo "$new_$$key is same as old $$key, which is $value\n"; } I know this doesn't work above but I'm presuming it's something to do with my syntax... I've had a look at PHP.net tutorials and done a bit of googling but I'm lost on this simplest of all problems... I could do it the long way with like 20 conditions but I want to get more efficient in my programming.
×
×
  • 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.