Jump to content

jodunno

Members
  • Posts

    222
  • Joined

  • Last visited

  • Days Won

    2

Posts posted by jodunno

  1. Hi Barand,

    Thank you for the tips. You are very kind to take time to help a newb. I appreciate your post very much!

    I've made notes from your post. I will use a table like you mentioned. I am not really new to php/sql but i am obviously not a programmer. I suck, actually. I have alot of trouble with database design. I have not mastered this concept. I made a login system three years ago for the first time in my programming tenure. So i have a dtabase of users. I will just add this table to this database like you mentioned.

    Thank you for the count() function tip. I didn't realize that sql has this function. Very nice, indeed! and very helpful post from you.

    i can explain a bit more while sticking to the bookmark db problem/topic: i actually built my own routing system which does not use query strings. I use forms and session variables to load pages through a single index file. So the "link" is a partial path to the php file system to load the correct "page" in a single page template. Somewhat spaghetti code but i do not like frameworks. I am happy for now. I will get better over time. Anyway, the bookmark will be a collection of known data from the template page:

    page link as a db title to detect duplicates: path/to/data (path is always the root. bookmarks are only used within these pages. thus path is like c:/)

    css icon display: i use icons to represent the links to pages and this is either a round icon or rectangular icon (which holds a photo).

    icon photo link: each icon has a unique photo, so i need this data to get the correct icon for the bookmark.

    language: i use a multi language file system so this is important to display the correct icon title by language. so here en-us, en-uk, de-de etc.

    icon title: all ready present on the page as a variable ($pageTitle)

    all of the above is my bookmark profile. now i just need to store each bookmark <101 into a database. Then figure out how to read these entries to display them on your bookmarks page (i guess a loop to read each entry and store each entry into an array?) I figure that serialized profiles will make this an easier task. How to know duplicate entries? i figure that a bookmark title (the page link) can be used. Thus, i can easily detect if this page is all ready bookmarked or not.

    I will give it my best try and post any problems here. Remember, i am not a guru/programmer. Thus, i may need alot of time to get this set up. Your tips will help me.

    Thank you!

  2. Hello SQL gurus,

    details of system: xampp installation with MariaDB v10.1.30 with PHP v7.2.1

    I have set up my website file system to include a bookmarking system. The foundation is intact now i need to set up the database to store the values of the bookmarks. click on my bookmark icon which will submit a bookmark profile block for storage in the database (a serialized array of necessary values). I want to limit the bookmarks to 100 entries per user.

    i don't know exactly how to build this table and retrieve the data. is anyone able to offer design tips? i figure that i should make a database named bookmarks with a table for each user? then add an id row and a bookmark title (for duplicate detection) and the serialized profile for redisplay. I guess one can select all data in the table but how should i store each result for analysis and redisplay of the profile? i am not an sql guru. i currently only use simples select statements.

    I hope that someone can offer some tips.

    Thank you!

  3. so here is my simplified non-regex code:

    $checkname = 'Ruecken<script>alert(\'F**k off!\');</script>seiten<wbr>&shy;tiere';
    $wbrshy = '<wbr>&shy;';
    $nameFilter = strpos($checkname, $wbrshy);
    $temp = null;
    if ($nameFilter !== false) {
      $temp = str_replace('<wbr>&shy;', '?', $checkname);
      $temp = htmlentities(htmlentities($temp, ENT_QUOTES), ENT_QUOTES);
      echo $temp . '<br>';
      $checkname = str_replace('?', '<wbr>&shy;', $temp);
      echo $checkname;
    } else {
      echo htmlentities(htmlentities($checkname, ENT_QUOTES), ENT_QUOTES);
    }

    so now i can check string length less than 50 (after extracting/preserving wbr shy and adding one for the question mark which will make 48+q mark = 49).

    before the string length check, i can use a simple regex to check for \p{L} to enforce letters only (thus preserving my question mark method).

    however, i don't need to apply htmlentities because i have an error page set up. if the name does not conform, then none of the icons are displayed. you will see the error page in place of the content. hackers are much smarter than me, so i'm not playing around with non conforming names. who knows what it is? i move on as error.

    I think this solution is much easier, faster and better than a regex solution.

    Once again, Thank you for your time and patience and understanding. thread closed.

  4. so today i have tried multiple cominations and they have failed as you had predicted. I really don't want to ignore html code and seek only script. I really just wanted to verify letters plus optional wordbreak with soft hyphen. Rather than spend weeks trying to learn the correct regex statement, i have a better idea: i will check each name for wbr shy code, extract the code and set the extracted text to a temp variable, then apply html entities to the string, then reapply the wbr shy. a bit more work but better than rattling my brain for weeks trying to get the regex correct.

     

    Thank you for your time and patience.

  5. Hi requinix,

    i've cleaned the code now to exclude my mistakes. sorry. i really don't know alot about regex. I know one thing: you are very kind and helpful. Thank you! I really appreciate the interaction with you. i am mentally tired now and i really needed a coder to look at my expressions. I'm shutting the xampp down now. i go to bed soon.

    $checkname = 'NameMe';
    //$checkname = 'Rückenseiten<wbr>&shy;tiere';
    //$checkname = 'Name Me';
    //$checkname = 'Name<script>alert(\'F**koff\')</script>Me';
    if (!preg_match("/^\p{L}{2,32}<wbr>&shy;?\p{L}{2,16}?$/", $checkname)) {
      if (!preg_match("/^\p{L}{2,24}\s?\p{L}{2,24}?$/", $checkname)) {
           echo 'checkname === 0';
        } else {
           echo 'checkname === 1';
      }
    } else {
       echo 'checkname === 1';
    }

    this time i have coded the f-word in the script test.

  6. oh, lord. I just realized that i didn't edit the script part of my code. I apologize! i cannot believe that i left it in the code. I hope that noone here is offended. I didn't mean to leave the 'f' word in my code example. i will edit it now.

    edit: the edit button disappeared. please will a moderator escape the 'f' word in my code? i sincerely apologize for this error.

  7. yes, i am an idiot about this subject. i don't really understand it yet. Thus, i did not know that lt and gt do not need to be escaped. I also did not know that the assertions are useless. why, may i ask? nevermind. i can read about that in spare time. it's not your business to educate me. my apologies for asking.

    anyway, i have alot of words that are broken where i want them to be broken - so not really 10 and 2. Plus, user supplied names could be broken wherever a user wishes. I just want to be sure that only lt wbr gt amp shy semicolon is allowed. Nothing else between words except a space whenever a wordbreak is not included.

    i will try to rewrite my code and to understand where i go wrong.

  8. Hi requinix and Thank you for taking time to reply,

    i understand your reply but i wonder why you think that my expression is invalid? it is working on my xampp with php, so i assume that the expression is valid according to regex rules. I say this because it is actually doing what i want it to do, albeit, i need a second check to see if it falls into the non html coded word:

     

    $checkname = 'Name Me';
    //$checkname = 'NameMe';
    //$checkname = 'Rückenseiten<wbr>&shy;tiere';
    //$checkname = 'Name Me';
    $checktrue4 = 'Name<script>alert(\'Fuckoff\')</script>Me';
    if (!preg_match("/^(?:^)(\p{L}){2,24}(\<wbr\>\&shy\;)?(\p{L}){2,24}?(?:$)$/", $checkname)) {
      if (!preg_match("/^(?:^)(\p{L}){2,24}(\s)?(\p{L}){2,24}?(?:$)$/", $checkname)) {
           echo 'checkname === 0';
        } else {
           echo 'checkname === 1';
      }
    } else {
       echo 'checkname === 1';
    }

    try my code and uncomment each variable to test it. i seem to have accomplished all of my goals without ignoring code. Is this really invalid?

  9. I forgot to mention that the icon names are not user supplied now but i'd like them to be editable in the future. so i'd like to work this code into my php code all ready. I actually spent 10 hours on this today. I can't even get it working until just before i posted here. I really wanted to allow utf-8 characters so umlauts of German can be included as well as French accents but this is too much for me, so az-AZ is good and an optional space before an optional second word or one word with a wordbreak soft hyphen only.

  10. Hi requinix,

    I have spent all day working on this problem. I could be doing alot of other things. I'm getting sick of this problem now. So, yes, i tried playing with regex until it did what i wanted it to do. I imagine a smart regex hacker, like you, can see a very simple solution. I can cnot see it. I have tried all day.

    I hope that i can explain the problem clear enough: i am using data as a hyperlink beneathe an icon. The data is not user supplied but i use wordbreaks with soft hyphens to break long words where i want them to break. I like to check my strings to verify that they are a-zA-Z only excluding the wordbreak. Thus my problems to solve are as follows:

    The entire strings must be no shorter than 3 letters and no longer than 48 letters including wordbreak code and a single space. (i've counted and the longest word yet is 36 characters).

    The string should be a-zA-Z only with one space allowed between two words. So two words are allowed following these rules. So 1 or 2 words with a space between 2 words.

    The string could be one word with a wordbreak and soft hyphen. Thus less than wbr greater than ampersand shy semicolon is allowed.
     

    RequinixIsAregexPro should pass as a-zA-Z less than 48 characters
    
    American Robin needs to pass as it is a-zA-Z and a single space between the two words.
    
    The German word Ruechenseitentiere is too long for me, so it should be allowed to pass as Ruckenseiten<wbr>&shy;tiere

    Nothing else should pass. Especially php, html and javascriptcode.

    Is it possible to simplify my hard-earned amateur expression?

    Thank you for taking time to read my post and reply. Meantime, i will keep trying to understand this problem and brush up on my regex knowledge. I am tired today now so i think that i will put this one away for now.

  11. I found a solution. Thanks anyway.

    ^(?:^)([a-zA-Z+]){2,26}(\<wbr\>\&shy\;)?([a-zA-Z+]){2,12}?(?:$)$

    it works, i guess. The letters after the soft hyphen shouldn't be more than 8-10 letters anyway. i'll recalculate but it works.

    Now i wonder how to allow a single space between first word and last optional word?

  12. Hello forummembers,

     

    I am battling a regex expression. I got the expression to work but i can't figure out how to limit the string size - No matter where i place the curly braces {2,48}.

    my desire to use a regex is to filter my variables for matching formula. My formula is any word a-zA-Z with an optional string between that should only be a soft wordbreak in html code followed by optional letters a-zA-Z.

    so Mystringname should pass, Mystring<wbr>­name should pass but Mystring<script>alert(f**k off)</script> should fail.

    I got it working but i can't figure out how to limit the string length to 48 characters. Anyone able to help me?

    here is my working regex (maybe someone thinks of a better regex?)

    /^(?:^)([a-zA-Z]+)(\<wbr\>\&shy\;)?([a-zA-Z]+)?(?:$)$/

    EDIT: I use php, so PCRE regex rules.

    Thank you.

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