We can do it in different ways. Configuration data are sent by POST.
Some of them should be parsed before saving to file.
Perhaps, I will use var_export(). However, how to do it best?
1. Without a class / function.
Fields names have no prefix and are equal to $cfg array's indexes.
<input name="option_na me" />
In every file of options form (e.g. main options, content options, e-
mail...) you insert:
if(file_put_con tents('cfg/file_name.php', var_export($_PO ST,1), 2))
{
...
}
If you must parse some data:
$_POST['data'] = Clean($_POST['data']);
2. With a class / function.
Fields names may contain prefix (e.g. u_).
<input name="u_option_ name" />
Saving data:
$o = new Config(...);
$o -add('option_nam e', 'int');
$o -add('option_nam e');
$o -save('file_name '); //or: $o = null;
3. Method 2 with dynamic options forms:
$o = new Config(...);
$o -add('option_nam e', 'int', 50);
No, it isn't good example. You can have textarea fields (even with
editor), text, radio (more choices for 1 option), checkbox, select
(with <option>s which can be generated by other functions, e.g.
category list).
4. Array (more code):
$array = array(
'opt1' =(int) $_POST['u_option']
);
The main configuration page has above 30 options. However, the method
with $o -add(...) may be slower. What do you think about it? Which
choice is the best or maybe you have other solutions? 1 1710
WebCM wrote:
We can do it in different ways. Configuration data are sent by POST.
Some of them should be parsed before saving to file.
Perhaps, I will use var_export(). However, how to do it best?
1. Without a class / function.
Fields names have no prefix and are equal to $cfg array's indexes.
<input name="option_na me" />
In every file of options form (e.g. main options, content options, e-
mail...) you insert:
if(file_put_con tents('cfg/file_name.php', var_export($_PO ST,1), 2))
{
...
}
If you must parse some data:
$_POST['data'] = Clean($_POST['data']);
2. With a class / function.
Fields names may contain prefix (e.g. u_).
<input name="u_option_ name" />
Saving data:
$o = new Config(...);
$o -add('option_nam e', 'int');
$o -add('option_nam e');
$o -save('file_name '); //or: $o = null;
3. Method 2 with dynamic options forms:
$o = new Config(...);
$o -add('option_nam e', 'int', 50);
No, it isn't good example. You can have textarea fields (even with
editor), text, radio (more choices for 1 option), checkbox, select
(with <option>s which can be generated by other functions, e.g.
category list).
4. Array (more code):
$array = array(
'opt1' =(int) $_POST['u_option']
);
The main configuration page has above 30 options. However, the method
with $o -add(...) may be slower. What do you think about it? Which
choice is the best or maybe you have other solutions?
Personally, I'd place it in a database. But then I like databases :-)
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. js*******@attgl obal.net
=============== === This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Florida Coder |
last post by:
I have the need to store some application specific configuration data to be
used by a class library and or a windows service. I would like to do this
in a fashion similar to the way we do with applications and web services
without having to use the machine.config file.
I know that I could use the code below to do this but the problem then
becomes that when using a shared assembly both the assembly and the config
file need to be put...
|
by: MrNobody |
last post by:
I was a Java developer so I'm used to using property files as a means to keep
configuration settings for my apps. I'm wondering what options are there with
..NET?
Some settings I want to include are like a root directory for a target
program on the user's machine my app uses, which they would be prompted to
supply at startup. Normally the registry is used for this but I'd rather not
use the registry if possible. Isn't there some kind of...
|
by: Jon Sagara |
last post by:
Say that I have an Excel OWC on my Web page and I want to save any data the
user has entered to the server when s/he clicks on the submit button. Is
that possible?
Thank you,
--
Jon Sagara
|
by: Ramesh |
last post by:
Hi,
We are receiving an error 'The operation has timed out' when our ASP.NET
application on Web Server stores large files 10MB+ on the App Server using
HTTP PUT. This is a Server to Server communication. This works fine with 4-5
MB files though. Also there is a 15 mb shared bandwidth limitation.
how can we throttle/control the transfer rate to see that we are within the
bandwidth limits ?
Any help is highly appreciated
|
by: Pedro Leite |
last post by:
Good Afternoon.
the code below is properly retreiving binary data from a database and saving
it. but instead of saving at client machine is saving at the server machine.
what is wrong with my code ??
thank you
Pedro Leite From Portugal
------------------------------------
| |
by: Jeff |
last post by:
Hey
(and thank you for reading my post)
In visual web developer 2005 express edition I've created a simple website
project..
At this website I want users who register to be able to upload a picture of
themselves to their profile... I admit that I'm a newbie... but this is how
I understand this:
|
by: Nathan Guill |
last post by:
I have an interface that works with an Access back-end. I would like to
store and/or load user defined query strings per each user (i.e. no user can
access another's queries). The idea I had was a "table" stored with the C#
front-end (not in the Access database), but don't know if this is even
possible. If it is, can someone let me know how? Otherwise, how do other
people handle storing and loading query strings for possible later use?
|
by: Mufasa |
last post by:
Can anybody give me an opinion on which is more efficient -
Saving parameters in a database that is on the same machine as the web site
or
Reading parameters from a .config file ?
It seems like the constant opening/closing of the connection would be a
congestion spot - plus it would use lots of memory.
But when you have the options in a file - is that slow there?
|
by: jenniamia |
last post by:
I'm new to programming, so this might be simpler than I realize but I'd appreciate a push in the right direction.
I'm using VS.NET 2005 with a database, SQL 2000. I'm writing in C# code and I'm trying to take an XML file and read in a particular part of that data (all the Variable nodes). Following that I have to remove the data which I read in(again thats the Variable nodes), and save the additional data in the database as a file. Currently...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |