Algorithm For Detecting/highlighting Changes In Documents
Anyone knows a good algorithm for detecting difference between two
pieces of text? I'm working on a content management system and would
like to add the ability to highlight changes made between versions. I
don't think diff is suitable here, since I want word level detection.
Besides, I'll need to handle a large number of relatively short
strings. Spawning an process for each would be too time consuming.
AFAIK, PHP doesn't have a build-in function. If necessary, I can build
a wrapper extension.
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
PHP Highlighting Regex
I've search around the board an havent been able to find anything that would help This is what i have an i use the same thing for bold italic center underling ect.. an it works fine but it doesnt like php can someone tell me help me out here please.
C++ Code Highlighting
There's a simple way to highlight blocks of PHP code in PHP using the built in function highlight_string(), and I'd like to be able to do the same thing with C++ code. Does anyone know of a script out there that can be used to perform syntax highlighting on C++ code via PHP?
Regex For Syntax Highlighting
I want to find all <code></code> tags and replace the inner content with C++ style syntax highlighting. I'm having a lot of trouble figuring out how to search for <code>(ANTYHING EXCEPT </code>)</code>. Here's what I think should work: <code>[^(?:</code>)]+</code> Any suggestions on how to get this to work?
Syntax Highlighting Using XML And Regex
I'm developing a Content Management software for my own site, and possibly package and deploy to other sites (for friends, family, etc.) The content management software is combined blog, photo, and site management tools. One the of the tools I would find INREDIBLY helpful is the ability to block out and syntax highlight code. I would like to be able to, as I'm writing a blog post about something I've done in Python (for example), just stop and type something like: <python> def foo(): bar() foo() </python> Do you get the idea? The only code I've been writing recently is PHP, Python, and C++, so I could start with the regex for those languages first and then expand. The blocks of code would then add some style info (like making the font a fixed size font, etc....) and then would highlight certain terms (a regex nightmare). I've talked this over with another PHP dev, and he suggested I use the xml_parser_create function to generate a parser object, and then the xml parsing functions to find these tidbits of code. This sounds like a great idea to me. However, does anyone have suggestions on a better way to do this, or an efficient way to do the syntax highlighting? I'm assuming for syntax highlighting, I'd have to do a massive preg_replace with the regex, and then add in the HTML for items I wanted to highlight. I don't mind doing this, but I was also wondering if someone had a great resource for syntax highlighting regex that someone else may have created that I could use, and possibly modify. Licensing for this software would be the GPL, so obviously everything else should be GPL. I thought I'd bounce the idea against some other PHP developers, and see what they thought of it.
Trim Output And Highlighting
i have a text field in my database, i am making a Fulltext search and i want the results page to show only the first 50 characters of the string. i also want the same string to highlight the words which the user had entered into the search box (the variables of the fulltext search) does anyone know how to these things?
Built-in Syntax Highlighting In Php 4.1
nl2br() started outputting <br /> as of 4.05 - however, my memory tells me that the functions highlight_string() and highlight_file() didn't get around to switching from <br> to <br /> until later. Anyone remember if 4.1's syntax highlighting had <br> or <br />'s in it, or have their own 4.1.x install to test? If it's <br> I'll have to account for this in my script.
Highlighting Regex Matches
I'm trying to achieve the following: start form entry user enters form data and submits ($form_data) preg_match_all data for $pattern, store matches in $match_arr if one or more matches display string back to user, with matched substrings in different color/emphasis start form entry again else continue my initial solution to recontructing the string: // if 1 match preg_replace ($pattern,'<em>'.$match_arr[0][0].'</em>',$form_data,1); // if multiple matches preg_replace ($pattern,'<em>'.$match_arr[0].'</em>',$form_data,-1); ...but the latter doesn't work the way I hoped. When the replace var is an array $pattern also must be an array for preg_replace to use the different array values in $replace. Any ideas how to get around this problem in an elegant manner? Or an alternative solution altogether? I searched for a function/solution that tells me at which position preg_match_all() found a match, so I can avoid the preg_replace altogether, but I haven't found any.
Highlighting Searched Characters
i have my search function: function perform_search($search, $table){ //if white pages is selected $search_query = mysql_query('SELECT * FROM `entries` WHERE `' . $table . '` LIKE "%' . $search .'%"') or die(mysql_error()); $info = mysql_fetch_row($search_query); return $info; } So if someone searches att, it will come back with a database result of matt or anything containing att. Is there a way to highlight the search value $search? ie: att is searched matt attitude come back, att is bolded.
Highlighting Search Term Results
I've seen previous threads but I still need help in highlighting search terms like google does on their search result page. I know I need, ob_start(); Then I process to highlight the search term hits, then I flush the buffer to render the page. I'm comfortable with PHP coding but what I need is simple step by step help, with a simple search form example. The explanations I see are either way to lofty or too small a piece of the "puzzle".
Highlighting Search Text, But Not Inside Tags
I've looked at some examples of text highlighting in this forum, and they all work fairly well. But I have a problem with my html tags. I have a site where the main body text is kept in a database text field. This text can contain some simple html. In particular urls. These urls get completely messed up with the css-tags that i insert to highlight the search words. Is there a simple regex expression that can make my script skip anything between < and >? I am currently using the example from this thread:
Thoughts On The Best Way Of Highlighting Form Input Errors?
I've been creating an application over the last few weeks and generally pleased with what I have produced but one area is irritating me, form validation. At the moment the forms are simply static html templates and the form input is checked using a validation class. Basically each form field is checked, every error is stored to an array and at the end of checking of the complete form, the array is output neatly at the top of the form. However this is just not sexy enough for me, what I would like to happen is for the input boxes with errors to be highlighted with a red border (or something along those lines). I would also like to have the error messages under the box which the error occured, not altogether at the top of the page. So I am currently wondering how to achieve this and what choices are open to me on methods available? I've had a google around the web and found some form validation classes but they basically do what I already achieved. I've thought of creating the forms dynamically but that in itself doesn't address how to achieve my goal. I am sure many people have already successfully done this, if you have the please could give me an outline (the theory) of how you did it. I don't want or need code, I am simply stuck at the moment on how to approach this.
Highlighting Text And Bold/underline/italicize
I set up a new forum using phpBB 2.0.22. The highlighting and bold/italics/underline function is not working correctly. On other phpBB forums, if I am writing a paragraph and decide to underline a word for emphasis, I simply highlight that word, click the "U" button up top, and it inserts the underlined tags around the highlighted word, making it underlined. I noticed this forum works that way as well. Unfortunately, my forum does not. If I highlight a word and then click "U" for underline, it does not insert the underline tags around the word, but rather places the tags at the end of the text. So instead of looking like this: I am trying to underline some text it instead looks like this: I am trying to underline some text [b ] [ /b] I added spaces in the underline tags in the example so it would show up as tags. Is there any way to fix this? Also, I've noticed (on my forum) that if I put the cursor somewhere in my post and attempt to insert an emoticon/smiley, it places the smiley face at the end of the text, and not where I want it. Example. I will post some text below and then go back and place the cursor in between two words and insert a smiley face: I utterly despise tech stuff because it confuses me. Luckily, there are cool tech people out there to help. It placed the emoticon properly. On my forum, if I clicked between the words "stuff" and "because" and then clicked a smiley face, here's what it would look like instead of what I intended.
Algorithm Help....
I hope there's someone who can help with one algorithm...I've been trying the whole day.... I'm building my own FORM class and have a function select(&$options, $name = "", $onchange = "") there's also a var $selected to be called before ->select() because someitmes I need some stuff to be selected by default.... I'm having a problem with algorithm after checking if ->selected is array or not... "not" part is done but "it is" part is giving me headaches.... i also have a var $selcted_what before ->selected to define what will be selected ($keys or $values)... So the pseudo code should be.. $options=Aray("test1","test2","test3","test4","test5"); $object->selected_what="values"; $object->selected=Array("test1","test2"); $object->select($options); So the output should be select_box with test1 and test2 selected..... or when $object->selected_what="keys"; $object->selected=Array(1,2); $object->select($options,"testing"); now it should have the "test2" and "test3" selected....
Algorithm
I'm having a little trouble writing an algorithm to create a hierarchal structure from a database which looks like this: parent_id | child_id | ----------------+-------------+ 1 | 2 | 2 | 3 | 3 | 4 | 3 | 5 | 5 | 6 | 5 | 7 | So coming out of the database, I get an array which looks like this: Array ( [0] => Array ( [parent_id] => 1 [child_id] => 2 ) [1] => Array ( [parent_id] => 2 [child_id] => 3 ) [2] => Array ( [parent_id] => 3 [child_id] => 4 ) ... I would like to put this into an array which represents the following structure: 1 2 3 / 4 5 / 6 7 Can anyone point me in the right direction? Let me know if this isn't clear - I can try to elaborate.
My First Algorithm
I'm trying to make a function that takes the alphabet, displays it all. When it gets to the last letter, it starts over, but with a prefix of the first letter, then the second letter and so on. Ex: A B C D E F G AA AB AC AD AE AF AG BA BB BC BD BE... Anything I should be aware of before attempting this?
Sorting Algorithm In Php
the sort() function in php, what kind of sorting algorithm is it? selection sort? bubble sort? insertion sort? if i were to create my own sort, which would be fastest for sorting many string values?
Complex Algorithm
Good afternoon gurus and guru-ettes! I am searching for an algorithm that will take a list of monetary values and determine which of these values totals a value supplied to the widget. 1. I supply a value to the application and give a date range 2. The application will query for all of the values in the date range...
Search Algorithm.
I'm trying to master the ability to search through large amounts of data for what the user really wants. I have a list of words (viewable at http://bludwulf-bsd.dyn.dhs.org/glass/definition.php along with the current incarnation of my search engine) that I'd like to search through. So far I've tried to use the 'similar_text()' function, but I now realize that's quite hopeless. Case in point, if i have an entry called 'air hoses and related topics' and the user searches for 'air', it will be ranked low because its a comparatively long entry name. (Other entries are shorter, most of them one word) Is there a better way to do a simple search like this? I don't want to simply search each entry for the search string, as lots of them are italian words which are frequently miss-spelled.
Need A String Algorithm.
I need to assign all characters the values 1-26, and add them up in the string, each time multiplying the next characters value by 10^string placement. It should look something like this: Lets try an example: C 3 O 150 R 1,800 E 5,000 Y 250,000 ---------------- 256,953 The end result of the word Corey is the number 256,953. Can anyone get this working in php?
Algorithm Isn't Working
I seem to be having a problem with part of my code. This code is supposed to connect to a database and perform a query to get all the name fields in all the records. The program then compares the results to the file names of all the files in a certain directory. I'm doing this so I will know if another record needs to be added. Unfortunately, the algorithm I am using does not work. I can't seem to find what is wrong with it. Instead of the giving me the next file name that needs to be added, it gives me the last file name that I have already added. Here is the code: <?php $files = scandir("c:apache2triadhtdocspictures"); $numberElements = count($files); // Connect to the server and select the database @mysql_connect("localhost", "user", "password") or die("Could not connect to MySQL server!"); @mysql_select_db("website") or die("Could not select database!"); // process query $query = "SELECT name FROM pictures WHERE 1"; $result = mysql_query($query); if(!$result) echo "Error processing query!"; // find number of rows returned in the result of query $numberRows = mysql_numrows($result); // compare query results with file names for( $rowNumber = $numberRows; $rowNumber > 0; $rowNumber-- ) { $exists = false; $name = mysql_result( $result, $rowNumber - 1, name ); for( $elementNumber = $numberElements; $elementNumber > 0; $elementNumber-- ) { if( $files[elementNumber - 1] == $name ) $exists = true; } if( $exists == false ) { echo "File $name needs to be added to the database!"; break; } } mysql_close(); ?>
Least Squares Algorithm
Any one know where can I find some php code (or "php-able" code) implementing least squares method?
Porters Stemming Algorithm
I dug out a PHP version of Porters Algorithm from :-http://www.tartarus.org/~martin/PorterStemmer/php.txt Whenever I try and run it I'm getting the error "Wrong parameter count for join() " Can anyone guess what I am doing wrong, I haven't modified the class so I assume its the way I'm calling it. ************* code to call class ********************* <?php require("stemming.inc"); $string="compuTing"; $string=strtolower($string); echo $string; $stm=new stemming(); $stm->reset(); for($i=0;$i<strlen($string);$i++) $stm->add(substr($string,$i,1)); $stm->stem(0); $stem = $stm->toString(); //stem of the string echo $stem; ?> ****************** end code***************************
FULLTEXT Relevance Algorithm?
I've just started to implement a FULLTEXT search script in PHP. I have read that the relevance rating should not directly be used to create a rating (as a percentage say) for the results you may return to a user. Is there an effective algorithm whereby some normalisation etc. could effectively be used to provide at least a "rough" guide?
Algorithm To Determine Download Time
Anyone got an easy algorithm to find out the estimated download time of a file on a specific speed? I've been trying to figure this out for about a week now, to no avail.
Directory Listing Sorting Algorithm
for a thumnail gallery / category script I'm working on it uses directory names as the categories. The problem I'm having is some folders I'll put a date on.... like 20030405-foldername, 20020405-foldername, etc... and I want those to be reverse sorted so that the most recent date is at the top. However lets say in that same directory there are the following directories: 20030405-foldername, 20020405-foldername, A_folder, B_folder.... (cuz like I said not all have a date on them). Code:
Generating .pdf Documents On The Fly...
Does anyone know if it's possible to generate pdf documents from content held in a database? The idea is to use a template to dynamically generate pdf documents on the fly based on what the data a user has selected on a site. Is this possible with PHP/ ASP?
MS Word Documents
I've been asked to write a script to upload Microsoft Word documents and then convert them into 'printer friendly' pages. The uploading part I've got no problem with, but I can't find anything about reading MS word docs into PHP. Does anyone know anything about this? I hope it's not as difficult as excel documents - which I'm still trying to get working on and off without any real success.
Word (or Other Documents) To PDF On The Fly?
Is there an option to convert any (or mosts file types) a user might upload to PDF format upon upload? I'd like users to be able to upload Word, Excel, Text and other documents, then have our upload script convert the document to PDF on the fly. Then viewing users would simply need the acrobat reader to view files, not all these other office products. Is this possible with just PHP and pdflib for example? If not, what are the options?
Creating XML Documents
I'm trying to get myself to grips with XML and PHP, I've been through the XML parsing tutorials here and they are very good. However, what is the best way of doing the reverse, i.e. actually dynamically creating XML documents in PHP as opposed to parsing them? Is there a library for doing this, or is it best just to do it from scratch?
Printing Documents
I have a web page that displays CVs submitted by users (in DOC, PDF or RTF format). CVs are stored in a folder for e.g. user_cv Admin can select the CVs to be printed and then click on Print button. This should send all documents to printer for printing. How do I do that in PHP?
Similar Search Results - FULLTEXT Or Algorithm
first of all I'm sure that what I want to do isn't going to be easy... I'd like to be able to take user input and query the database to return exact and similar results. I have added a FULLTEXT index of the column I want to search to the table. Then taking user input and break it apart into separate words and use something like: MATCH (table) AGAINST ('*word1*' '*word2*' IN BOOLEAN MODE) AS Score in my SELECT and then ORDER BY Score DESC and that works pretty good, but I'd like to factor in misspellings, abbreviations, etc. I have searched to see if I could find code for an existing algorithm that I could try, but all I have found are articles talking about different algorithms and no actual code.
Display Tree Graphically - Any Classes/algorithm?
I am looking for a class to display trees graphically (SVG, Gdlib, whatever). It should look somehowlike this java driven example: http://www.csupomona.edu/~jrfisher/...isualize/p2.gif The data is stored in a Mysql dtabase.
SSI And Perl Within .php3 Documents
Im new to PHP. I want to know if you can use ssi within .php3 documents and call php3 funtions in a .pl scritp. That is if you want to use the useful perl scripts you find on the web and combine them with php.
Compare Two Word Documents Using Php
In my system I want to compare two word documents ,but my server is a Linux one and thats y I cant create COM object . Any othermethods to find this one .I think to connect PHP to some other mightt be useful for this.....
Phplib Creating Pdf Documents
I can load a font, set a font, load an image, draw a line, output text in a box, output text on a line, create a pdf, open a pdf, add a page, close a page, close a pdf but I can not set a font to bold or italic or underlined. I currently use a function which moves the text position slightly and re outputs it for bold and I simply draw line for underlined text but now I need to do italicized and I am stuck. I found little on font styles anywhere when using the pdf commands on php.net I can see the list of commands but everything is deprecated and the new commands don't have clear documentation on how to use them: pdf_setfont($pdf, $times, 9); pdf_setcolor($pdf,"both","rgb",0,0,0); pdf_set_parameter($pdf,"fontstyle","italic"); the first line sets the font to be times roman and size 9 the second change the color to black I though the last line would set the font to be italic but it is not correct Any ideas?
Parsing Existing PDF Documents
I have an existing PDF document; "myfile.pdf". I want to be able to seek through that document for particular strings. The thing is, I can't find a way to open the file as something that's legible/readable. I've tried using PDFLib aswell as using fopen/fgets (among many other things) to open the file and display the content. The only content I get is a little mark-up and a bunch of garbbled text. I'm assuming that when a PDF is created it has some form of character encoding passed over it, or it's encrypted in some way. I've looked at a few classes around, but none show ways of opening a PDF document up.
How To Upload Documents In Mysql
I'm a beginner and will like to know how to upload documents in mysql. These documents will be cited on the intranet and a user will have to search for a particular document using either date, title etc.
Downloading Secure Documents
i'm building a site which will have a secure section (still haven't decided between cookies and sessions), but anyhow, after the login screen, there will be links to a bunch of word documents that the user can download or view. I'm thinking anyone who knows the path to those documents can view them without logging in.. is there a way to prevent this? or am I just wrong?
Algorithm For Creating A Binary Tree Genealogy For A MLM Site
Im working over a web base MLM software. I need to display a genealogy of all the members who have joined the MLM programe. Each member referes 2 new members and so on. Its a 2 x 2 matrix. Now i need to calculate the total numbers of exisiting members in each leg i.e, left leg and right leg.
Evaluating Php Tags/documents Outside Of Web Server?
I need to generate and send multiple xml documents over a socket. Is it feasible to use php as a templating language for these? How would i go about that? I figure i _could_ make them into 'normal pages' and fetch the contents using some http library, but that doesn't sound too elegant. There has to be a better way?
Tutorials/Articles/Documents Script?
I was looking for a script that could let me manage tutorials, articles or documents in my website. There should be categories and they are not for download but to be displayed right on the page, extra functions like rating, comments would be nice but not required. I'm currently using Tutorials Manager (http://scripts.phpwiz.net/tb2/) but the script is in beta state and is quite buggy. If anyone knows about any others scripts, please let me know all of them so I can choose one. Free ones or under the GPL only.
PDF Generation - Making Large Documents
I am trying to generate a large PDF using PDFLib. Specifically, I have a database of University researchers (perhaps 300-400) and I need to generate a printed report with a table of contents - all of the entries are stored in a MySQL database. There can be several researchers / page and I want to avoid a researcher's entry spanning two pages. I think PDFLib would be a good solution for me, but all the examples / tutorials I have seen using it have been quite trivial. I wonder if anyone has some tips / tricks for using PDFLib for text spanning several pages or if you can think of a better way to generate this larger document for print - keeping in mind that I must keep track of page numbers.
Reading EXCEL (XLS) Documents With Other Charactersets
(the other code i cannot post due weird carakters!) I've been searching over the internet for days but havent found why! i've tried alot of scripts (both free or wich i need to pay for) but only a pricy script (like 80$) would show the carakters in ROW C correctly. If i convert the script to a HTML document i get the carakters with &# and a four digit number... that's what i like to extract from the excel sheet. The script i wrote is. Code: <?php $excel = new COM("excel.application") or die("Unable to instanciate excel"); //bring it to front $excel->Visible = 1;//NOT //dont want alerts ... run silent $excel->DisplayAlerts = 1; //open document $excel->Workbooks->Open("d:/excel.xls"); for ($h = 1; $h <= 3; $h++) { $book = $excel->Workbooks(1); $sheet = $book->Worksheets($h); echo "<table> "; //Wtite row for ($i = 1; $i <= 150; $i++) { echo "<tr> "; //write colom for ($j = 1; $j <= 5; $j++) { $cell = $sheet->Cells($i, $j); // #Select the cell (Row Column number) $cell->activate; // #Activate the cell if($cell->value == Ɔ') { $td = ""; } else { $td = $cell->value; } echo "<td>" . $td . "</td> "; // #write the cell } echo "</tr> "; } echo "</table> "; } //closing excel $excel->Quit(); ?>
Extract Text From Word Documents
Is there a way to extract the text of a word document with php? And perhaps some of the formatting (like break lines, bold, italic,...)?
Automatically Download Documents Onload
i have another problem with regards to documents. The thing is, when a user registers, they upload a document right, and we store the document's link and the date it was loaded on the database, but now i would like this to happen, that when i log in and there has been a dcument uploaded, it takes the date now and compares it with the date that the document was loaded, like this: Code:
Multiple Forms, Different PHP Documents, Same Page?
In a PHP file 'main.php' I have <?php include 'header.php'; include 'login.php'; include 'body.php'; include 'footer.php';?> Login.php has a form on it to allow the user to log in to the site. Body.php has a form on it to allow a user to post a message. What I'm finding is that the 'submit' button on 'body.php' actually calls the form from 'login.php'. Does PHP have issues when there are 2 separate forms doing 2 saperate things displayed on the same page - is there anything I need to look out for?
|