Jump to content

Thierry

Members
  • Posts

    85
  • Joined

  • Last visited

    Never

Posts posted by Thierry

  1. Currently I'm working on building a menu at the top of the page.

    Each item is 12.5% (1/8) in width, with a float:left to keep them nicely aligned next to each other.

    Another div inside it gives it a border per item, but this doesn't extend the width.

     

    In FF and Chrome it works fine, but in IE there's an anomaly when I use overflow:auto on the page itself.

    Seeing as how FF and Chrome don't show the scrollbar unless it is needed, I want the same for IE.

     

    However, when I set overflow:auto on the body/HTML, IE throws the last DIV underneath the other ones, as if the page suddenly lost a few pixels of width.

     

    I also noted the menu items don't fill the entire width of the page in IE when maximized, there are a few pixels at the right edge that aren't being filled, but I can't increase the width of the items without getting the same issue.

     

    I'm thinking it's some weird IE rounding error and that it can't correctly calculate the widths needed.

     

    Examples below, first how it is done right by Chrome (and FF)

    In Chrome

     

    And how it is done by IE, first without overflow: auto;

    IE no overflow

     

    And in IE with overflow: auto;

    IE with overflow

     

    The menu itself as said is very simple.

    8 divs with 'width:12.5%; float:left;' and a div inside it that gives it a white border on the right side.

    Only the last div doesn't have that border, but none of the borders extend the width in any way.

     

    If there's a fix for this without having to resort to using position absolute and creating 8 separate classes with the right positions, I'd love to hear it.  :)

  2. I'm currently trying to hash a password value with a salt and then encrypt that with MD5 several times.

    Right now I'm using this function I made.

     

        // Encrypts a key using MD5 and strengthens the key by the given amount of bits
        function encryptMD5($string, $bits = 0, $msecDelay = 0){
            
            // Encrypt the string as normal
            $encrypted = md5($string);
            
            // Start looping
            for($i = 0; $i < pow(2, $bits); ++$i){
                
                // Start encrypting
                $encrypted = md5($encrypted);
            }
            
            //We might want to pause the script for a while in case of a brute force attack
            usleep(($msecDelay*1000));
            
            //Return the key
            return $encrypted;
        }
    

     

    It works fine, but I was wondering what I should store in my database.

    The main reason I use this is so that you can't use a rainbow table on the password in the cookie/session.

    However, currently I'm only storing the salt itself and the fully hashed password+salt value in the database.

     

    This means however that when someone logs in, I have to hash their password with each salt to try and get a match.

    If I end up with a lot of users, this could mean dozens or hundreds of salts to cross check with.

     

    Should I store an MD5 value of only the password itself without the salt in my database rows for quick matching?

    If the database ever got hacked, they could see the salt anyway, so having a single MD5 hash of the password in only the database (but not the cookie) shouldn't hurt, right?

     

    All I really want to achieve is to avoid having bad people quickly determing the password via the MD5 hash in the session/cookie.

  3. abstract classes cannot be instantiated.

     

    The design pattern you are looking for is the registry pattern - simply make all your methods static so they can be called without an instance of the class being created - although this will achieve the same as having a bunch of helper functions but may incur a little more overhead.

     

    I'm aware that abstract classes can't be instantiated (that's what it's for), I was more curious as to whether or not to keep it that way when faced with generic functions/methods.

    Looks like keeping it static/abstract and doing Date::Format is the way to go.

     

    I suppose the other way would be to make an object out of literally everything so that a new date value becomes a Date object with $date->Format on it. Would make even the simplest operation a lot more complicated though, as I'd have to do stuff like $int->getVal() just to get the value of an int.

  4. I have some generic functionality in my application that I'd like to put into classes, as currently all the functions are in a single php file which is then included.

     

    However I'm not sure whether or not I should make the class abstract (or should I even use a class).

     

    For example, my application comes across dates all the time and has to swap them between the ISO format of YYYY-MM-DD and the format of DD-MM-YYYY or MM-DD-YYYY.

    Another function for dates checks if it's a valid one and yet another translates any given date to seconds.

     

    I'd rather put such functionality under classes, but I was wondering how that should be done.

     

    On one side I feel it should be abstract and made available everywhere, so that you can simple do a 'Date::Format($date)'.

    Since there is no need to create multiple instances of the class, abstract would seem to do fine.

    Still, this leaves me to wonder what the point would be of using a class only as abstract without extending it (aside from some encapsulation and class constants).

     

    The other way would be to keep it not abstract and create an instance either once at the top or each time for each page and use '$Date->Format($date)'

     

    This example is ofcourse just with dates, I have quite a few more for strings, numbers etc.

     

    What should I do? Where does generic functionality that an application will use everywhere fit in OOP?

  5. $word->version returns version 12.0, don't know if that's any help.

     

    On php.net I thought I found the answer

     

    If you're having permission problems like not being able to opening or saving a document and you're getting errors like:

     

    - This command is not available because no document is open

    or

    - Command failed

     

    try this (if you're running IIS):

     

    - Execute "dcomcnfg"

    - Open Component Services > Computers > My Computer > DCOM Config

    - Search for Microsoft Office Word 97-2003 Document (it will be something like this translated to your language, so take a while and search for it)

    - Right-Click on it and open the properties

    - Choose "Identity" tab

    - Normally this is set to "the launching user". You have to change this to "the interactive user" or a admin user of your choice.

    - Apply these new settings and test your COM application. It should work fine now.

     

    However, after trying this and using both interactive user or admin user, it still gives the same error.

    Don't know if I have to restart something other than Apache before these take effect though.

     

  6. I'm working on reading the content of a bunch of Word files into a text field in MySQL.

    My setup runs on Windows and has Word 2007 installed so I figured I could use the .COM object.

    I quickly found a promising bit of code, but whatever I do I keep getting the following error:

     

    Fatal error: Uncaught exception 'com_exception' with message '<b>Source:</b> Microsoft Word<br/><b>Description:</b> This command is not available because no document is open.' in C:\Apache\htdocs\XXX\public_html\misc\docReader.php:10 Stack trace: #0 C:\Apache\htdocs\XXX\public_html\misc\docReader.php(10): unknown() #1 {main} thrown in C:\Apache\htdocs\XXX\public_html\misc\docReader.php on line 10

     

    It doesn't crash on the line where it opens the file, but where I want to use the ActiveDocument to read the content. If I deliberatly pass a bad path to a file, it gives a different error, so it does seem to be able to find the file.

    The code is as followed.

     

    $word = new COM("word.application") or die ("Could not initialise MS Word object.");
    $word->Documents->Open(realpath("test.doc"));
    
    // Extract content.
    $content = (string) $word->ActiveDocument->Content;
    
    echo $content;
    
    $word->ActiveDocument->Close(false);
    
    $word->Quit();
    $word = null;
    unset($word);

     

    Is there something about Word 2007 that I'm missing maybe? I've had no problems with .COM on Word 2000/2003, although I haven't used it in quite a while.

     

    I've tried Documents->Add, Document[0], Document[1], Document["test.doc"], all to no avail.

     

    Any ideas?

  7. Was wondering which is better to use, or more reliable across browsers.

    The object is a div, and it is created with document.createElement.

     

    The id will later be used for a few JS functions, but which one should I use?

     

    For as far as I can see doing:

     

    divRow.SetAttribute("id", "1")

     

    is the same as:

     

    divRow.id = "1";

     

    Which should I use, and which is faster in performance?

  8. Hello, I'm trying to create an image map with some countries in it, and although it works if the image itself is static, I need the image to be positioned via left & top, so I need to use position:absolute;

    However when I do, the image maps cease to work, giving them position:absolute didn't work.

    Anyone know how to get an image with position:absolute to work with image maps?

  9. When I do more then a single require() (also tried include, same deal) I get a strange character "strangecharda0.gif" printed to the page in IE7 (Firefox works fine), which causes a linebreak to occur.

     

    Since I may end up using more then a single include/require in my pages I really need to find a fix for this, is it some setting in php.ini?

     

    I checked all the stuff I was including and that didnt cause it (merely including a blank piece of text twice causes it).

    What the requires include doesnt seem to matter, if I do require("page with AA in it") and then require("page with BB in it"), I get "AAstrangecharda0.gifBB" in my source code in IE7.

     

    Note that the first require/include doesnt get the character to show at the end, it seems to show at the start of the second include.

     

    Any ideas what could be causing this?

  10. Try using a single double quote and see if the query gives an error.

    If it does, you forgot to escape your double quotes.

     

    Since your query is probably written in double quotes, it causes an error as it gets all messy.

     

    You can either use addslashes($_POST["YOUR_FORM_ITEM"]); or htmlspecialchars($_POST["YOUR_FORM_ITEM"], ENT_QUOTES);.

     

    Add slashes will simply add a \ to the " which will tell PHP to see it as a character instead of a double quote and the latter will change the doublequote into its HTML code (&#039;), you can use html_entity_decode to bring it back if needed.

  11. Sometimes when I get a set of results in a table a column value can be much longer then the table column.

    I don't want it to wrap into multiple lines as I want it to remain at the same height of a single row.

     

    Instead if its too long I want to cut it and add three points (This is way too looooooooooo...) to signify it has been cut but that the row still remains at the same height.

     

    I cant use fixed widths (substring or the like) as the table uses percentages and thus scales differently on different resolutions.

     

    Anything that could help me out?

  12. I want to be able to scroll (move) to the bottom of the page simply by hovering the mouse near the bottom.

    As the page in question can be very large, if you hover near the edge of the screen, the page should scroll to that direction.

    So if you are putting the mouse near the right edge of the screen, the page would scroll to the right, you hover left it goes left etc.

     

    Currently I've been trying it by having an <input image> following the mouse and constantly focusing on it when it nears the screen but its buggy and doesn't really work well.

     

    Any ideas that could do it better?

  13. I've been getting the NS_ERROR_NOT_AVAILABLE error with Firefox on several occasions.

    I have a script that frequently (every 500ms or so) calls several functions to update the user.

    That works fine, but when the user is redirected by AJAX the error happens.

    Although the scripts doesn't interfere with the user (the redirect still happens) it still does show the error itself.

     

    Its like this, a player can host a chatbox (the host/player 1) and other users can then join in.

    The host can view any of the users that join the chatbox and he can kick them (all will be kicked if he leaves the page)

     

    It seems whenever the user is redirected by AJAX the error occurs (again, it doesnt crash anything but still) although if the host himself leaves the chatbox he gets no errors.

     

    I'm simply using an XML request which then retrieves data from the database.

    When a user is redirected I simply use:

    //...
    ?>
    location.href = "lobby.php";
    <?
    die("</root>");
    ?>
    

     

    I use a PHP page with a switch to call upon various data and checks, and I then use eval(); to run any script generated.

    It only happens in Firefox and appearently only when the user is forced to leave.

    I'm geussing it somehow errors halfway during the exiting/closing of the page or something but I dont know.

     

    I simply use a function (the same one) that calls upon XML to get the data from the PHP page and eval the contents.

     

    If someone would know a way of just hiding the errors (they dont interfere with anything) that be good too.

     

    Any ideas to what is causing this?

  14. I have a while loop (4096 is the minimum amount) which goes through a long list of cells.

    Although saving 4096 cells is do-able, when it gets more, the browser thinks the script has gotten stuck and it takes forever to finish it.

     

    In the loop, all it does is get the table cell ('with frames["framename"].document.getElementById(tile_counter)') and then get a style from it and checks a few things with the result.

    When a result matches a certain thing, it will update a field with the value.

    I'll end up with a hidden field having a lot of values separated by commas. (green,black,yellow,red,purple etc)

     

    When I removed the getElementById part the script was finished instantly, so I'm geussing using 4096 getElementById's is what is causing the lag.

     

    Is there another way of getting the table cell without causing much lag? I only need the style.backgroundColor attribute.

  15. I have a page in which the user can click & hold and then move over (not drag & drop) table cells to select them. (like checking multiple checkboxes by holding down the mouse button and then moving over them).

     

    However, half the time you try to 'drag' from a table cell to start a selection, you get the 'NO' icon from the mouse, as if its trying to drag & drop the table cell itself. (click & drag on any text link and then move your mouse, you'll get the same result).

     

    I've done some tests and even simple table cells with nothing but width & height also cause this. (note, it doesnt do it when there is text in the cell but that screws up the selection made with the cells themselves)

     

    Is there any way to prevent the mouse from changing like this?

  16. I need to be able to find out how users got to a certain page, either getting an URL from a link they clicked or maybe a NULL if they typed it in directly.

    I remember something that could do this but I cant seem to find it again.

     

    Any ideas?

  17. I'm having trouble with get_browser(), returning the error:

     

    "Warning: get_browser(): browscap ini directive not set."

     

    I've looked it up and it turns out I didnt have a browscap.ini file and link to it in php.ini

    I've gotten a browscap.ini file now and I put it in the php root folder (same folder as php.ini), and I've tried various URLs but the function still wont work.

     

    I've tried: "browscap.ini, /php/browscap.ini/, D:/folder1/folder2/folderetc/php/browscap.ini/ and more but none seem to work"

    And yes, I've removed the ';' so it should be active.

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