Results 1 to 4 of 4

Thread: Modify a php file that contains definition in a form

  1. #1
    Join Date
    Jun 2004

    Modify a php file that contains definition in a form


    I have a file that has a load of definitions in it. I want to be able to modify these definitions from a form.

    Lets say I have a file with;
    PHP Code:
    default for template 4

    defaults for template 5

    defaults for template 6
    When my form is submited I will have the number and the name being passed to it.

    So lets say I want to add "Some text" to template 5 I would want it to go UNDER the DB_MENU_5_CLOSE and NOT just appended to the bottom as:
    PHP Code:
    define(DB_MENU_5_SOMETEXT"Some text"); // Added DATETIME 
    I am obviosly creating a string above but my problem is finding how to input it in the correct location on the definitions page.

    There will be consistency with the \*** begining a template and obviously \*** will start the next one see we kinda have the point of references.

    I am hoping that the same would apply if I wanted to alter the value of a definition?

    Last edited by k0r54; 05-26-2010 at 10:29 AM.

  2. #2
    Join Date
    Jul 2009
    Falls Church, Va.
    You might find this response odd...

    First off, define() creates a constant which, according to PHP's own reference page for that function, can only be changed in one way -- if set to the value of another constant. You can see if it's been defined already using defined() but a constant really is an identifier to a variable who's value "cannot change during the execution of a script" as per the PHP docs on constants. There are a few magic constants such as the ever popular "__FILE__" which change based on where they're used, but a normal constant is SUPPOSED to be just that -- constant, unchanging.

    But guess what...

    PHP Code:
    The results of that, with no errors, are:

    string(3) "foo" string(3) "bar"

    This is true in PHP 5.3.2 on my system - and seems to exploit a weakness in the third parameter of the define() function which is supposed to determine case sensitivity when creating the constant. It seems if you explicitly define true (even though its the default, case insensitive) this behavior occurs. Bug?

    Just because you can do this now doesn't mean you should!

    So I'm saying don't use constants for things like what you're trying to do.

    Jim, Sr. Web Developer
    You know who you real friends are when you ask them to move your furniture or paint.

  3. #3
    Join Date
    Jun 2004

    Ok, was affraid of something like that. It means a complete rebuild of the system.

    What I might do as a work around for the moment is put all these into a database and at the begining of the script create a definition from the results of the sql statement.

    Not sure what speed implications that would have but it is a step in the correct direction whilst I trawl through all parts of the code removing any definition that should not be used in this way.

    thanks for the insight!

  4. #4
    Join Date
    Jul 2009
    Falls Church, Va.
    That would work, or a simple XML file, or CVS, or custom .ini file. Also, you can still generate the PHP script with constants, code a back end CONFIGURATION TOOL or utility which allows admins to create and update said file (i.e. formats suggested above or your current format), just keep the admin config and interface separate, or standalone. No changing the existing code, just extending it. A few cosmetic changes to link the admin page, and maybe store the admin password encrypted in any of said formats or methods.

    Jim, Sr. Web Developer
    You know who you real friends are when you ask them to move your furniture or paint.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.09166 seconds
  • Memory Usage 2,884KB
  • Queries Executed 15 (?)
More Information
Template Usage (33):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (3)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (4)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (4)postbit
  • (4)postbit_onlinestatus
  • (4)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (70):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • bbcode_parse_start
  • postbit_imicons
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates