Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7668829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:27:23+00:00 2026-05-31T15:27:23+00:00

I have an editable filesystem where user can submit changes in a form. I

  • 0

I have an editable filesystem where user can submit changes in a form.

I would like to use the path of the files as NAME or ID Tags.

Since i doubt i am the first facing this, there might be a better approach.

Examples:

path: ../../disney/mouse/mickey.php

Known restrictions:

Jquery: no periods (.) and colons (:) 
HTML : Only letter, digits,hyphens ("-"), underscores ("_"), colons (":"), and periods (".")
HTML5: All but no spaces ( ) and at least 1 char.

It is required that PHP AND JAVASCRIPT can easily encode/decode the string in both ways.
atm i do it by replacing “/” & “.” with unusual patterns.

Which encoding you advise and is there something that even SHRINKS the path but stays unique??

Regards :>

EDIT: USers can alter and edit the code from the files. Why do you advise me to use an additional input for each field which links the path with the content? i don’t see the point since its not a problem if the name or id tags are properly encoded.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T15:27:24+00:00Added an answer on May 31, 2026 at 3:27 pm

    You should not be using your values as identifiers. This is not good practice and this is why you are encountering this problem. But if you want to do it anyway…

    If you want to use a single string for all languages, you need to create a single string that excludes all the restricted characters found in each language. If restricted characters are part of the path, things become more difficult to keep unique. I would recommend you take the full path, then use a preg_replace() to change all characters that are not expected to underscores.

    $old = '../../disney/mouse/mickey.php';
    $new = preg_replace('/[^a-z0-9]/i', '_', $old);
    echo $new;
    //Outputs: "______disney_mouse_mickey_php"
    

    You will definitely want to modify this to add in more characters that are allowed. The less that you restrict, the less likely you are to have a collision of non-unique id/name attributes.

    If you want a method that is less prone to having a possible non-unique id/name, then you can wrap your path in md5() (PHP) to create a md5 hash. This is less friendly to read, but should be unique enough for most non-critical purposes.

    $old = '../../disney/mouse/mickey.php';
    $new = md5($old);
    echo $new;
    //Outputs: "403d07916233847221263553573c5321"
    

    In response to your comments, here is my final attempt. This /custom/ function will encode a path that is both unique and readable in the source. This will also allow you decode into your original path string. The allowed characters and escape character are customizable so that you can find one that is usable in all languages you require.

    function customPathEncode($old)
    {
        $chars_allowed = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
        $escape_char = '%';
        $new = '';
    
        $old_length = strlen($old);
        for($i = 0; $i < $old_length; ++$i)
        {
            if(false === strpos($chars_allowed, $old[$i]))
            {
                $new .= $escape_char.bin2hex($old[$i]);
            }
            else
            {
                $new .= $old[$i];
            }
        }
    
        return $new;
    }
    echo customPathEncode('../../disney/mouse/mickey.php');
    //Output: "%2e%2e%2f%2e%2e%2fdisney%2fmouse%2fmickey%2ephp"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 4 editable uitextviews, user can set its font font color etc. Now
I would just like to have an editable div that acts like a textarea
I have a combobox and it's editable. So the user can select an item,
I have an editable combo box in wpf-mvvm application. I would like to add
I have an editable iframe and I would like to insert text at the
I have an editable UITableView. By default the user can swipe and the Delete
I have a Listbox where all cells are editable. While the user is typing
I have an activity that contains several user editable items (an EditText field, RatingBar,
I have a simple table view which is editable. All I need the user
I know that you can use java.util.Properties to read Java properties files. See: Java

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.