Jump to content

Gordon Werner

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Posts posted by Gordon Werner

  1. Good morning.

     

    If I want a user to be able to enter simple markup into a text field using [tag]xyz[/tag] format so that I can convert it on display to <tag>xyz</tag> format, how do I formulate the preg_replace expressions?

     

    i.e.

    [b]some text[/b]
    [i]some text[/i]
    [u]some text[/u]
    [url]http://www.www.com[/url]
    [email]someone@somewere.com[/email]
    [img=http://www.com/image.jpg]
    

    etc ...

     

    should become:

     

    <b>some text</b>
    <i>some text</i>
    <u>some text</u>
    <a href="http://www.www.com">http://www.www.com</a>
    <a href="mailto:someone@somewere.com">someone@somewere.com</a>
    <img src="http://www.com/image.jpg" />
    

    etc ...

     

    also if I want the user to be able to enter the following:

     

    [tm]
    [sm]
    [r]
    [c] 
    

     

    and have the display change those tags to the ascii characters ... would str_replace be the best way to handle those? or would preg_replace also work?

     

    Any help would be appreciated as I am trying to learn this stuff and haven't found any good examples that are clear to a beginner.

     

    Thanks

     

    G.

  2. I have a bunch of code that requires users to enter text.  To avoid certain problems, I restrict the tags they can use to mark up the text ... using bracket tags instead of html tags like

    [b]...[/b]

    which I then replace at runtime using eregi_replace.

     

    this is not a problem for things like bold text ...

     

    $description		=	eregi_replace('\[b]([^]]*)\[/b]', '<b>\1</b>', $description);

     

    but how do I handle things like bullet lists where I want to let the user only have to enter

    [*]

    ?

     

    right now, all I do is this:

     

    $description		=	eregi_replace('\[\*]', '<li>', $description);

     

    but this makes the XHTML validation fail (no closing </li> tags) ...

     

    is there an easy way that I can have the code auto-insert the </li> tag? and how would the above code snippet have to change?

     

    Thanks

     

    G.

  3. Hi there ...

     

    how does one determine the following.

     

    I need to have a message pop up every 2nd tuesday ... and I need to be able to store this in advance.

     

    if I being with SEP09 ... how do I easily determine what # day is the 2nd tues in OCT or NOV, etc ...

     

    I cannot just add seconds from epoch because the # of the day will change from month to month

     

    Can anyone help?

     

    Thanks in advance

     

    Gordon

  4. hi there ...

    At my job, we have multiple people working on a website for a client.

    Most of us use macs to do this and our server is running apache on BSD.

    In order for us to view our work on our local machines as well as on our dev server (also a mac) I need to have some code that can automatically determine the path to the include directory where the site's configuration file lives.

    locally on our machines we would look at the site at:  http://127.0.0.1/~user/domain (files in the user's ~/Sites directory)
    the dev server on http://devserver/doman (files in /Library/WebServer/Documents)
    the production server on http://www.domain.com/ (files in /home/web/sites/domain)

    the following code SEEMS to handle this ... buy studying the path and looking to see if Library or Users exists in the path (then it is local or dev) and if not, then it is the live server.

    [code]


    $uri  =  explode("/", $_SERVER['PATH_TRANSLATED']);
    $path_site  =  "http://".$_SERVER['HTTP_HOST'].(ereg('Library|Users', $uri[1]) ? ($uri[3] == "Sites" ? "/~$uri[2]/".$uri[(array_search($site,$uri))] : "/".$uri[(array_search($site,$uri))]) : ((array_search($site,$uri)) > 4 ? "/".$uri[(array_search($site,$uri))] : ""));


    [/code]


    However, I am getting the following error in the php errorlog ONLY on the live server:


    [Thu Jul  6 13:00:02 2006] [error] PHP Warning:  array_search() [<a href='function.array-search'>function.array-search</a>]: Wrong datatype for second argument in /home/web/sites/domain/include/config.php on line 46


    Can anyone tell me what I am doing wrong, or even if I should worry about this error?  The sites work just fine on all machines so it looks like it is working but I do not like error messages.

    Also ...

    can anyone offer a better way to do this? if my way is flawed?

    thanks in advance

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