PHP - Moved: Crontab Settings
This topic has been moved to Linux.
http://www.phpfreaks.com/forums/index.php?topic=313175.0 Similar TutorialsThis topic has been moved to Linux. http://www.phpfreaks.com/forums/index.php?topic=309899.0 Hi, I am not sure if this is in the right forum, but I wanted to ask how I can set up a crontab if I don't have cpanel in my hosting control panel? Thanks This topic has been moved to Linux. http://www.phpfreaks.com/forums/index.php?topic=318175.0 Where do PHP configuration settings (e.g. Error-Handling Levels) exist? I believe they are in a file somewhere?! Thanks, Debbie what I'm trying to do is to setup a page called settings.php that the admin runs to order to turn option in the web site on or off. I don't know how to do this since I never done this before. My code is below. <link href="mainframe.css" rel="stylesheet" type="text/css"> <?php require_once '../config.php'; $db = new DbConnector(); $db->DbConnector(); if(isset($_GET['submit'])) { $db->query('UPDATE '.SETTING_TABLE.' SET option='.$_POST['banner'].' WHERE setname='''); echo 'Process complete'; } $result = $db->query('SELECT * FROM '.SETTINGS_TABLE); echo '<table border="1">'; echo '<tr>'; echo '<form action="settings.php" methed="post">'; while($row = $db->fetchArray($result)) { echo '<tr>'; echo '<td>'.$row['setname'].'</td><td><select size="1" name="'.$row['setname']'">'; echo '<option value="on">on</option>'; echo '<option value="off">off</option>'; echo '</td>'; echo "</tr>"; } echo '<td><input type="submit" value="Submit" name="submit">'; echo '</td>'; echo "</tr>"; echo "</form>"; echo "</table>"; /* */ ?> <h2>Settings</h2> <a href = "admin.php">Admin Panel</a> How do I setup my PHP code and server to accept custom domains on my program like tumblr does? http://www.tumblr.com/docs/en/custom_domains I know the domain owner needs to do the A name part but what needs to be done my side? Cheers in advance so I've been putting all of my php scripts to exe to protect some of the code I have written, say I write a simple loop script like below <?php $REPEAT = 1000; $ECHO = "CLUEL3SS"; for($cwb=1; $cwb!=$REPEAT; $cwb++) { echo "#$cwb: $ECHO\n"; } sleep(99999999); ?> Now how can I set the variable $REPEAT when the script is in .exe form and I cannot edit the code I have tried $REPEAT = fgets(STDIN); That doesnt seem to work though when I have 5+ variables to assign and I have an array set like like $Variable[] = 12345799; $Variable[] = 34324555; $Variable[] = 34289789; $Variable[] = 32899090; How can I use a text file to set these options? maybe have the variables assigned in a text file like Code: [Select] ; this is a comment, this will be ignored REPEAT : 1000 ; this is another comment, ignored also... ECHO : CLUEL3SS ; comment Variable : 3423423 Variable : 2903890 Variable : 3948903 Variable : 9823900 How would I have the php script read the text file in that format to set the variables? Hello, I'm working on a project and at some point ill need to save user specific settings ex: show/hide email etc... configuration file is not the case i thin because there are specific to every user, database will be the choice but what practice(logic) is the best to save these settings? Thank you! Every now and then, I experience some strange behavior and eventually trace it back to parse_ini_file's scanner_mode being applicable to some parameter but not another, and am looking for alternatives. Below are several of my thoughts. How do you store configuration settings? Do you use different approaches based on the application, and if so what criteria governs which you use? Keep with a ini file with parse_ini_file. Obviously, not working for me. An ini file but with a class dedicated to ensuring the data is appropriate. Seems like too much duplicating content which will result in errors. YAML. Don't think I want to. XML. Not as readable. In a database. Maybe, but might be harder to manage. Hardcode an array in PHP. Probably not. JSON. I like the idea, but feel comments are important in a config file, and am considering the following: Add extra valid JSON properties which contain comments. Don't like the idea. Use JavaScript's JSON.stringify. Too much mixing technologies. Add comments to the JSON and then strip them using a 3rd party parser such as https://json5.org/ or a little regex. My main issue is inability to auto-format, but this seems viable. Any other ideas?Thanks!
Hi,
I'm not sure if this is possible, however I'm sure somebody will be able to point me in the right direction. Relativley new to php here.
I would like to write a small app that will change my IP/Subnet Mask/Gateway depending on a selection made from a dropdown list. I will have a tota; of 50 different IP settings & drop downs (each drop down will represent a different location)
I have yet to start writing the app, just on paper so far - can this be done?
I have seen examples of batch scripts like the one below that work, would I need to incorporate something like this into my php?
netsh int ipv4 set address name="Local Area Connection" source=static address=10.127.86.25 mask=255.255.255.240 gateway=10.127.86.30This is just a personal project, I'm trying to further my knowledge! Thanks J I'm kinda new to PHP programming and I'm working on a large project at my university. Currently I'm working on adding as many choices to the Admin account so he could customize the site to his needs. All I wanted to know is what is the customary way in most sites to save these customization settings? Should I just put them in the database? Or maybe save them in a file (XML or some other kind)? Been scouring Google to find some information but didn't get anything useful so hopefully someone here could help me figure this out. Hello again everyone, I know someone knows how to do this. Question: In the program you created in question 4, allow your user the option of saving the information for the next time they visit. If they choose "yes", save information in a cookie. 1st part of Question (I have done): Created a text input with options to select font family, font size, and font color. At the bottom of question5.php I added a checkbox to save the information. I then created an if statement on the processing page (question5display.php. I would appreciate some help, thanks guys. Here is the form ( called it question5.php): <html> <head> <title> Please Enter Your Text</title> </head> <body> <form method="post" action="question5display.php"> <p>Enter the text you want formatted please: <input type="text" name="textformat" maxlength="30" size="30" /> <table> <tr> <td><label for="font">Select Font:</label></td> <td><select id="font" name="font"> <option value="Verdana">Verdana</option> <option value="Arial">Arial</option> <option value="Times New Roman">Times New Roman</option> </select> </td> </tr> <tr> <td><label for ="size">Select Size:</label></td> <td><select id="size" name="size"> <option value="10px">10px</option> <option value="12px">12px</option> <option value="14px">14px</option> <option value="20px">20px</option> </select> </td> </tr> <tr> <td><label for="color">Select Color:</label></td> <td><select id="color" name="color"> <option value="green">Green</option> <option value="blue">Blue</option> <option value="red">Red</option> </select> </td> </tr> </table> <input type="checkbox" id="save_prefs" name="save_prefs" /> <label for="save_prefs">Save these preferences for the next time you log in.</label> <input type="submit" name="submit" value="Submit" /> </form> </body> </html> Here is the page it goes to (called it question5display): <?php if (isset($_POST['save_prefs'])) { setcookie('font', $_POST['font'], time() + 60); setcookie('size', $_POST['size'], time() + 60); setcookie('color', $_POST['color'], time() + 60); $_COOKIE['font'] = $_SESSION['font']; $_COOKIE['size'] = $_SESSION['size']; $_COOKIE['color'] = $_SESSION['color']; } session_start(); $_SESSION['textformat'] = $_POST['textformat']; $_SESSION['font'] = $_POST['font']; $_SESSION['size'] = $_POST['size']; $_SESSION['color'] = $_POST['color']; ?> <html> <head> </head> <body> <p <?php echo ' style="font-family: ' . $_SESSION['font'] . '; '; echo 'font-size: ' . $_SESSION['size'] . '; '; echo 'color: ' . $_SESSION['color'] . ';" '; ?>> <?php echo $_SESSION['textformat']; ?> </p> </body> </html> I have been working on this awhile (the perfect PHP error handling for my coding style). I have tried to set it up as: Code: [Select] <?php error_reporting(E_ALL & E_STRICT & ~(E_NOTICE)); ?> I want this to show me E_ALL errors, E_STRICT errors, and NOT show me E_NOTICE. Is this the right way to set that up, or am I doing something wrong. I haven't used E_STRICT before but I am anxious to see what kind of errors that have it showing since I haven't messed with it before. Thanks again. I'm writing a mini social network and I'm having trouble figuring out how to deal with privacy settings. I have established a range of privacy options (level 1-4): 1. Only Facebook friends can see profile (users connect via FB) 2. Only current classmates 3. Past + current classmates 4. All users in given group I am writing a function to return a list of available users based on a given parameter (eg. Find all classmates of a user). Obviously I have to respect users privacy settings, so I thought to query against all users with level 2 permissions, however I realise that I may miss out some classmates who are FB friends but have permission levels set to 1. Secondly, I'm looking to find out the relationship between two users (a function that I can plug in 2 user IDs and return their relationship...classmates, FB friends, past classmates, no relationship) which I can then use to determine whether a user has permission to view another users profile. I don't have much code as of yet, because I spent a long time exploring one avenue which I now realise to be the wrong one! Any suggestions/help would be greatly appreciated! I have a configuration file, and I use parse_ini_file() to parse it into an array at the initial entry point of my script.
I would like the settings to be available to all downstream scripts/methods/functions. Note that my intent is not to change them outside of the configuration file, and ideally they will be readonly, however, if not, I suppose that is okay and I will just be sure not to modify them.
I've read about dependency injection, and while this mostly makes sense, it seems like a lot of script/troubleshooting for little if any value for this scenario.
I've read that global variables are bad (couples your objects to some "god" object, cannot unit test, difficult to troubleshoot, difficult to work with multiple developers, potential conflicts with other classes, namespace pollution), but maybe not for this case?
Another option is defining a bunch of constants to the appropriate values, but this seems redundant.
Or maybe some static class with all the values?
What would be the best way to make configuration settings available to all PHP scripts, functions, and methods? I am writing the code for my options page in my wordpress theme. It was working for awhile and the next time i checked, it couldnt save. When i hit save, it redirects to options.php. When i remove the code for the social options it still doesnt work and yet it was working before i included that code. What could be the problem here is the code <?php /** * This function introduces a single theme menu option into the WordPress 'Appearance' * menu. */ function blueray_theme_menu() { add_theme_page( 'Blue Ray Theme', // The title to be displayed in the browser window for this page. 'Blue Ray Theme', // The text to be displayed for this menu item 'administrator', // Which type of users can see this menu item 'blueray_theme_menu', // The unique ID - that is, the slug - for this menu item 'blueray_theme_renderpage' // The name of the function to call when rendering the page for this menu ); } // end blueray_theme_menu add_action('admin_menu', 'blueray_theme_menu'); /** * Renders a simple page to display for the theme menu defined above. */ function blueray_theme_renderpage() { ?> <!-- Create a header in the default WordPress 'wrap' container --> <div class="wrap"> <!-- Add the icon to the page --> <div id="icon-themes" class="icon32"></div> <h2>Blue Ray Theme Options</h2> <!-- Make a call to the WordPress function for rendering errors when settings are saved. --> <?php settings_errors(); ?> <?php $active_tab = isset( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : 'display_options';?> <h2 class="nav-tab-wrapper"> <a href="" class="nav-tab <?php echo $active_tab == 'display_options' ? 'nav-tab-active' : ''; ?>">Display Options</a> <a href="" class="nav-tab <?php echo $active_tab == 'social_options' ? 'nav-tab-active' : ''; ?>">Social Options</a> </h2> <!-- Create the form that will be used to render our options --> <form method="post" action="options.php"> <?php if( $active_tab == 'display_options' ) { settings_fields( 'blueray_theme_display_options_page' ); do_settings_sections( 'blueray_theme_display_options_page' ); } else { settings_fields( 'blueray_theme_social_options_page' ); do_settings_sections( 'blueray_theme_social_options_page' ); } // end if/else submit_button(); ?> </form> </div><!-- /.wrap --> <?php } // end blueray_theme_renderpage function blueray_initialize_theme_options() { if( false == get_option( 'blueray_theme_display_options' ) ) { add_option( 'blueray_theme_display_options' ); } // end if // First, we register a section. This is necessary since all future options must belong to a add_settings_section( 'general_settings_section', // ID used to identify this section and with which to register options 'Display Options', // Title to be displayed on the administration page 'blueray_general_options_callback', // Callback used to render the description of the section 'blueray_theme_display_options_page' // Page on which to add this section of options ); // Next, we'll introduce the fields for toggling the visibility of content elements. add_settings_field( 'firstareatitle', // ID used to identify the field throughout the theme 'First Area Title', // The label to the left of the option interface element 'blueray_firstareatitle_callback', // The name of the function responsible for rendering the option interface 'blueray_theme_display_options_page', // The page on which this option will be displayed 'general_settings_section', // The name of the section to which this field belongs array( // The array of arguments to pass to the callback. In this case, just a description. 'First Area Title:' ) ); add_settings_field( 'firstareatext', 'First Area Text', 'blueray_firstareatext_callback', 'blueray_theme_display_options_page', 'general_settings_section', array( 'First Area Text:' ) ); add_settings_field( 'firstarealink', 'First Area Link', 'blueray_firstarealink_callback', 'blueray_theme_display_options_page', 'general_settings_section', array( 'First Area Link:' ) ); // Finally, we register the fields with WordPress register_setting( 'blueray_theme_display_options_page', 'blueray_theme_display_options_page' ); } // end blueray_initialize_theme_options add_action('admin_init', 'blueray_initialize_theme_options'); /* ------------------------------------------------------------------------ * * Section Callbacks * ------------------------------------------------------------------------ */ function blueray_general_options_callback() { echo '<p>Set up the front page options</p>'; } // end sandbox_general_options_callback /* ------------------------------------------------------------------------ * * Field Callbacks * ------------------------------------------------------------------------ */ function blueray_firstareatitle_callback($args) { // First, we read the options collection $options = get_option('blueray_theme_display_options_page'); // Next, we update the name attribute to access this element's ID in the context of the display options array // We also access the show_header element of the options collection in the call to the checked() helper function $html = '<input type="checkbox" id="firstareatitle" name="blueray_theme_display_options_page[firstareatitle]" value="1" ' . checked(1, $options['firstareatitle'], false) . '/>'; // Here, we'll take the first argument of the array and add it to a label next to the checkbox $html .= '<label for="firstareatitle"> ' . $args[0] . '</label>'; echo $html; } // end blueray_toggle_header_callback function blueray_firstareatext_callback($args) { $options = get_option('blueray_theme_display_options_page'); // Next, we update the name attribute to access this element's ID in the context of the display options array // We also access the show_header element of the options collection in the call to the checked() helper function $html = '<input type="checkbox" id="firstareatext" name="blueray_theme_display_options_page[firstareatext]" value="1" ' . checked(1, $options['firstareatext'], false) . '/>'; // Here, we'll take the first argument of the array and add it to a label next to the checkbox $html .= '<label for="firstareatext"> ' . $args[0] . '</label>'; echo $html; } // end blueray_toggle_content_callback function blueray_firstarealink_callback($args) { $options = get_option('blueray_theme_display_options_page'); // Next, we update the name attribute to access this element's ID in the context of the display options array // We also access the show_header element of the options collection in the call to the checked() helper function $html = '<input type="checkbox" id="firstarealink" name="blueray_theme_display_options_page[firstarealink]" value="1" ' . checked(1, $options['firstarealink'], false) . '/>'; // Here, we'll take the first argument of the array and add it to a label next to the checkbox $html .= '<label for="firstarealink"> ' . $args[0] . '</label>'; echo $html; } // end blueray_toggle_footer_callback /** * Initializes the theme's social options by registering the Sections, * Fields, and Settings. * * This function is registered with the 'admin_init' hook. */ function blueray_theme_intialize_social_options() { // If the social options don't exist, create them. if( false == get_option( 'blueray_theme_social_options' ) ) { add_option( 'blueray_theme_social_options' ); } // end if add_settings_section( 'social_settings_section', // ID used to identify this section and with which to register options 'Social Options', // Title to be displayed on the administration page 'blueray_social_options_callback', // Callback used to render the description of the section 'blueray_theme_social_options_page' // Page on which to add this section of options ); add_settings_field( 'twitter', 'Twitter', 'blueray_twitter_callback', 'blueray_theme_social_options_page', 'social_settings_section' ); add_settings_field( 'facebook', 'Facebook', 'blueray_facebook_callback', 'blueray_theme_social_options_page', 'social_settings_section' ); add_settings_field( 'googleplus', 'Google+', 'blueray_googleplus_callback', 'blueray_theme_social_options_page', 'social_settings_section' ); register_setting( 'blueray_theme_social_options_page', 'blueray_theme_social_options_page', 'blueray_theme_sanitize_social_options_page' ); } // end sandbox_theme_intialize_social_options add_action( 'admin_init', 'blueray_theme_intialize_social_options' ); function blueray_social_options_callback() { echo '<p>Provide the URL to the social networks you\'d like to display.</p>'; } // end blueray_social_options_callback function blueray_twitter_callback() { // First, we read the social options collection $options = get_option( 'blueray_theme_social_options_page' ); // Next, we need to make sure the element is defined in the options. If not, we'll set an empty string. $url = ''; if( isset( $options['twitter'] ) ) { $url = $options['twitter']; } // end if // Render the output echo '<input type="text" id="twitter" name="blueray_theme_social_options_page[twitter]" value="' . $options['twitter'] . '" />'; } // end blueray_twitter_callback function blueray_facebook_callback() { $options = get_option( 'blueray_theme_social_options_page' ); $url = ''; if( isset( $options['facebook'] ) ) { $url = $options['facebook']; } // end if // Render the output echo '<input type="text" id="facebook" name="blueray_theme_social_options_page[facebook]" value="' . $options['facebook'] . '" />'; } // end blueray_facebook_callback function blueray_googleplus_callback() { $options = get_option( 'blueray_theme_social_options_page' ); $url = ''; if( isset( $options['googleplus'] ) ) { $url = $options['googleplus']; } // end if // Render the output echo '<input type="text" id="googleplus" name="blueray_theme_social_options_page[googleplus]" value="' . $options['googleplus'] . '" />'; } // end sandbox_googleplus_callback function blueray_theme_sanitize_social_options_page( $input ) { // Define the array for the updated options $output = array(); // Loop through each of the options sanitizing the data foreach( $input as $key => $val ) { if( isset ( $input[$key] ) ) { $output[$key] = esc_url_raw( strip_tags( stripslashes( $input[$key] ) ) ); } // end if } // end foreach // Return the new collection return apply_filters( 'blueray_theme_sanitize_social_options_page', $output, $input ); } // end blueray_theme_sanitize_social_options_page Hello I'm trying to build a plugin to get my site up to scratch for the new EU laws on cookies coming in place on the 26th What my main goal is a notification that when the users click accept the cookies set on machine but untill a "approval" cookie is found the site shouldn't set any cookies. Ive written this code, which allows me to set & unset a cookies via a form, using php and html, then depending on the submission either set or unset (which is a good start because im a noob!) but: the page needs an extra refresh in order to show the set cookie? does anyone know why or how i can resolve this? kind regards, and thank you Code: [Select] <? $set = $_POST["set"]; if($set == "on") setcookie(EURegulations, $set, time() + (20*365*24*60*60), www.domain.net); else if($set == "off") setcookie("EURegulations", "", time()-3600); ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>EU Cookie Plugin</title> </head> <body> <?php if (isset($_COOKIE["EURegulations"])) echo "Cookie Permission " . $_COOKIE["EURegulations"] . "!<br />"; else if(!isset($_COOKIE["EURegulations"])) echo "Cookie Permission off"; else echo "Error no cookie Set"; ?> <form name="setform" method="post" action="<?php echo $_SERVER['$PHP_SELF'];?>"> <button name="set" type="submit" value="on">On</button> <button name="set" type="submit" value="off">Off</button> </form> </body> </html> Hey everyone. I was hoping to get some help on something that I am working on. First, I hope this is the right place to post this. Please forgive me if this is the wrong forum. I am new to PHP as I work mostly as a Sys Admin. Recently, I have been working on a project running a number of applications on PHP. I configured a box and a PHP application that has a web interface. Everything looks good except for when I log into the web interface. I am greeted with this message: Code: [Select] Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/Los_Angeles' for 'PDT/-7.0/DST' instead in /usr/local/www/base/base_main.php on line 138n I have done a lot of research trying to figure out what is causing this. A lot of websites and posts on other sites suggested that the fix would be to make a change in the php.ini file in the : date.timezone section. I did make that change, however the issue still persists. I decided to make a quick test.php file to read the configuration file and see if I can get additional information. I opened up the test.php web page and made sure I was reading the correct configuration file. Which, according to the test page, I am. Moving forward, under the DATE section of the test.php file, I see this: Code: [Select] Warning: phpinfo() [function.phpinfo]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/Los_Angeles' for 'PDT/-7.0/DST' instead in /usr/local/www/apache22/data/test.php on line 2 Which is what I see as well when I log into the application's interface. Under that date section, it says the following: Code: [Select] Default timezone -- America/Los_Angeles Which is my timezone. For a test, I changed the "date.timezone" section in my php.ini file to "America/New York", restarted apache and loaded the config file backup. Looking at the date section again, the error is still there and the DEFAULT TIMEZONE is still pointing to "America/Los_Angeles". So it appears that its not reading my config file or I am completely missing something. Here is the full section of the DATE part of the test.php file: Code: [Select] date/time support enabled "Olson" Timezone Database Version 2011.4 Timezone Database internal Default timezone America/Los_Angeles Directive Local Value Master Value date.default_latitude 31.7667 31.7667 date.default_longitude 35.2333 35.2333 date.sunrise_zenith 90.583333 90.583333 date.sunset_zenith 90.583333 90.583333 date.timezone no value no value I have been trying to figure this out for the past few day with no luck. I was hoping someone might be able to help me out here. Thanks for the help. TCG This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=309960.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=318277.0 |