PHP - Need Help With Functions.php File On My Wordpress Site
Hello everyone,
function get_file_data( $file, $default_headers, $context = '' ) {
/** Similar TutorialsI have a wordpress site that has a ribbon graphic on the index page posts that are in the category "features", it works great when it's like this: Code: [Select] <?php //for better seo, we use alt and titles in h query_posts('category_name=features&showposts=4'); while(have_posts()):the_post(); $attrs = array( 'src' => $src, 'class' => "", 'alt' => get_the_title(), 'title' => get_the_title(), );?> <!-- Blog entry --> <div class="blog_entry"> <!-- inside --> <div class="inside"> <!-- Thumbnail --> <div class="thumbnail"> <a href="<?php the_permalink(); ?>" title="<?php the_title();?>"><?php the_post_thumbnail('blogsmall', $attr );?></a> </div> <!-- /Thumbnail --> <!-- Resume --> <div class="resume"><div class="featured_banner2"></div> <h3 class="cufon"><a href="<?php the_permalink();?>"><?php the_title();?></a></h3> <p class="bigline"><?php the_excerpt();?></p> <br> <?php if(function_exists('the_ratings')) { the_ratings(); } ?> </div> <!-- /Resume --> but when going to the category view it doesn't work to just add the Code: [Select] <div class="featured_banner2"></div> as all post types get the ribbon. So I am trying to use a PHP if statement to only apply that featured_banner2 div line to posts with the category name of "features" I am a total php newbie, so far I tried this but it obviously is not right, I am trying though! lol: Code: [Select] <!-- Resume --> <div class="resume"> <?php if ( in_category( 'features' )) { <div class="featured_banner2"></div> } endif;?> <h3 class="cufon"><a href="<?php the_permalink();?>"><?php the_title();?></a></h3> <p class="bigline"><?php echo get_the_excerpt();?></p> </div> <!-- /Resume --> This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=307287.0
The Wordpress Atahualpa theme does not appear to be compatible with php 7.2. I know very little about php. I get the following error message in my error log: Hi I'm currently in the process of re-developing a website for a client in Wordpress. I've completed the work apart from the fact that on the old site the client has a webpage with an email subscription form for subscribing to a newsletter. The form takes a 'Name' and 'Email Address' and writes these to a MySQL database in the back end. I've tried adding the code to a page in wordpress and have a few plugins which allow PHP code execution on both the sidebar and page but when the button is clicked to submit the subscription nothing appears to happen as on the origonal page. I really need to know whether this type of code could be imported into Wordpress and made to work or how to go about writing a wordpress page that will write to the same database. Any advice on this would be helpful as I'm not a strong php coder. The Code is as follows: There's a contact.php page on the origoanl site that calls inc-mailing-list.php that also referrences a mysqlconnections.php file I've put all the code below for referrence. Origonal Site: contact.php Code: <?php session_start(); $string = strtoupper($_SESSION['string']); $userstring = strtoupper($_POST['userstring']); session_destroy(); ?> HTML PAGE FORMATTING (REMOVED FOR THE POST) <?php include("inc-mailing-list.php"); ?></TD> <script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); </script> <script type="text/javascript"> try { var pageTracker = _gat._getTracker("UA-9716450-1"); pageTracker._trackPageview(); } catch(err) {}</script></body> </html> INC-MAILING-LIST.PHP <?php require_once('Connections/mysqlconnection.php'); ?> <?php /* In contact.php session_start(); $string = strtoupper($_SESSION['string']); $userstring = strtoupper($_POST['userstring']); session_destroy(); */ ///// Anti sql injection if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } //// Site config $siteName = "South Wales Art Society"; $siteURL = "www.southwalesartsociety.co.uk"; $siteEmail = "info@southwalesartsociety.co.uk"; ///// Establish the current date/time as a variable $now = date('Y-m-d H:i:s'); // Current date //// Call mailing lists mysql_select_db($database_mysqlconnection, $mysqlconnection); $query_callMailingLists = "SELECT * FROM content WHERE contenttype = 501 AND onlinestatus = '1' ORDER BY displayorder ASC"; $callMailingLists = mysql_query($query_callMailingLists, $mysqlconnection) or die(mysql_error()); $row_callMailingLists = mysql_fetch_assoc($callMailingLists); $totalRows_callMailingLists = mysql_num_rows($callMailingLists); //// Unsubscribe if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "elist") && ($_POST["subscription"] == "unsubscribe") && (strlen($_POST["email"]) > 4) && ($string == $userstring) && (strlen($string) > 4)) { $deleteSQL = sprintf("DELETE FROM content WHERE email=%s AND contenttype = 500", GetSQLValueString($_POST['email'], "text")); mysql_select_db($database_mysqlconnection, $mysqlconnection); $Result1 = mysql_query($deleteSQL, $mysqlconnection) or die(mysql_error()); $status = "1"; //SEND CONFIRMATION EMAIL $to = $_POST['email']; $subject = $siteName.' Mailing List'; $body = 'Your email address has been removed from the '.$siteName.' mailing list.' . "\n\r"; $body .= $siteURL . "\n\r"; $headers = 'From: '.$siteEmail . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $body, $headers); } /////////////////// SUBSCRIPTION //////////////////////// // Insert comment if sent and valid if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "elist") && ($_POST["email"] != "") && ($_POST["subscription"] == "subscribe") && ($string == $userstring) && (strlen($string) > 4)) { //////////////////////////////////////////////////////////////////////////////////// ///////////////////////////// COUNT AND JOIN TAGS ////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////// $tagCombination1 = ""; // Default value to define variable. $tagTotal = ""; // Default value to define variable. if (isset($_POST['TagsTotal1'])) { $tagTotal = $_POST['TagsTotal1'];} $tagNumber = 0; do { $tagNumber = $tagNumber+1; if (isset($_POST['Tag-1-'.$tagNumber])) $tagCombination1 = $tagCombination1.",".$_POST['Tag-1-'.$tagNumber]; // DISREGARD UNSELECTED TAGS } while ($tagNumber <= $tagTotal); // LOOP UNTIL ALL TAGS HAVE BEEN COMBINED $tagCombination1 = $tagCombination1.","; // ADD A COMMA TO THE END TO GET CORRECT SEARCH PARAMETERS $tagCombination1 = str_replace(",,",",",$tagCombination1); // CLEAR OUT ANY DOUBLE COMMAS //////////////////////////////////////////////////////////////////////////////////// /////////////////////////// COUNT AND JOIN TAGS END //////////////////////////////// //////////////////////////////////////////////////////////////////////////////////// $insertSQL = sprintf("INSERT INTO content (contenttype, title1, email, date_added, tags1) VALUES (%s, %s, %s, %s, %s)", GetSQLValueString(500, "int"), GetSQLValueString($_POST['name'], "text"), GetSQLValueString($_POST['email'], "text"), GetSQLValueString($now, "text"), GetSQLValueString($tagCombination1, "text")); mysql_select_db($database_mysqlconnection, $mysqlconnection); $Result1 = mysql_query($insertSQL, $mysqlconnection) or die(mysql_error()); $status = "2"; //SEND CONFIRMATION EMAIL $to = $_POST['email']; $subject = $siteName.' Mailing List'; $body = 'Thank you. Your name has been added to the '.$siteName.' mailing list.' . "\n\r"; $body .= $siteURL . "\n\r"; $headers = 'From: '.$siteEmail . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $body, $headers); } ?> <div id="signup" > <H5>Sign Up For Our Mailing List</H5> <?php if (($_POST['email']) && ($status == "1")) { ?> <br /><strong>Thank you, you have been removed from the mailing list.</strong> <?php } elseif (($_POST['email']) && ($status == "2")) { ?> <br /><strong>Thank you, you have been added to the mailing list.</strong> <?php } else { ?> <form name="elist" method="POST" action=""> <?php if (($_POST['email']) && ($status != "2")) { ?><p class="red"><strong>Please complete your details and enter the code.</strong></p><?php } // Error ?> <br /> Name: <input name="name" type="text" value="<?php echo $_POST['name']; ?>" /><br /> Email: <input name="email" type="text" value="<?php echo $_POST['email']; ?>" /><br /> <input name="subscription" type="radio" id="subscription_0" value="subscribe" <?php if($_GET['unsubscribe']!="yes") { ?>checked="checked"<?php } // ?> /> Subscribe<br /> <input type="radio" name="subscription" value="unsubscribe" id="subscription_1" <?php if($_GET['unsubscribe']=="yes") { ?>checked="checked"<?php } // ?>/> Unsubscribe<br /> <br /> <?php /*?>Select which information you would like to receive:<br /> <?php $tagNumbers = 0; do { $tagNumbers = $tagNumbers+1;?> <label><input <?php if (!(strcmp($row_callMailingLists['id'],1000))) {echo "checked=\"checked\"";} ?> name="Tag-1-<?php echo $tagNumbers; ?>" type="checkbox" value="<?php echo $row_callMailingLists['id']; ?>" /><?php echo $row_callMailingLists['title1']; ?></label><br /> <?php } while ($row_callMailingLists = mysql_fetch_assoc($callMailingLists)); ?><br /><br /> <input type="hidden" name="TagsTotal1" value="<?php echo $totalRows_callMailingLists; ?>" /> USE THE TWO HIDDEN FIELDS BELOW AS THERE IS ONLY ONE LIST <?php */?> <input type="hidden" name="Tag-1-1" value="1000" /> <input type="hidden" name="TagsTotal1" value="1" /> <img src="/captcha/imagebuilder.php" alt="" border="0" /><br /><br /> <small>Please enter the code shown above.</small><br /> <input maxlength="8" size="8" name="userstring" type="password" value="" /><br /><br /> <input name="Submit" type="submit" value="Submit" /><br /> <input type="hidden" name="datesubscribed" value="<?php echo date('Y-m-d H:i:s'); ?>" /> <input type="hidden" name="MM_insert" value="elist" /> </form> </div> <?php } // ?> <?php mysql_free_result($callMailingLists); ?> hello dear all, good day dear php-freaks,
i want to rssify content from another website into my wordpress-page: see the source: https://europa.eu/youth/volunteering/project_en well - is it possible to do this? of course - i have to ask bout the permission at the site of source. but the technical site is also interesting :do you think that this is doable!? note: i only am interested in the summary of the data - that is only a little piece of text.
Hello. The title is a little confusing, but: What I am trying to do is build a simple CMS where all requests are routed through the root index.php file. This file will be where all constants are defined and importantly where the database connection is estabilished. There will be a folder where template files will reside and, based on the URI, a template file will be included into the root index.php file. Here's some code: Code: [Select] <?php //Sets the database connection and defines some constants require ( "includes/config.php" ); //Where I will place the core functions of the CMS, one being the navigation builder require ( "includes/functions.php" ); //Home page template file require ( "views/cms/index.php" ); ?> So as you can see, I want to be able to call the navigation builder function, called "getMenuItems();", from the home page template. However, I get the following error: Code: [Select] Fatal error: Call to undefined function getMenuItems() in C:\wamp\www\cms\views\cms\index.php on line 3 How can I access functions that have been defined in the "includes/functions.php" file, from the required template file "views/cms/index.php"? If you need anything else explaining then please ask. If this has already been posted, I apologise in advance! I have searched Google and the forums but nothing turned up. Chris hello - dear phpfreaks,
i portet over a wordpress site to localhost. (an opensuse linux-box) all went nice and was very smooth to do so. after porting over the files and the db; i added the db-name and user-name etc. but nothing more. then i looked at the site http://localhost/mysite i saw the site - but only once - that is very very interesting. i read that i have to do more. Probably these changes - mentioned below are mandantory in order to avoid a blank page cf: https://managewp.com...#comment-148613 The two fields you need to edit are “siteurl” (highlighted above) and “home” (which you may need to navigate to the second page to find). Just click the “Edit” buttons next to each field, and replace the URL contained in “option_value” with “http://localhost/yourfoldername/”. That’s it! If you now navigate to “http://localhost/yourfoldername/”, your site should load up in all its glory. Please note that if you use custom permalinks, you will need to change them to default (in the WordPress > Settings > Permalinks screen) in order for internal links on your site to work. You can of course change the permalinks back to their custom form at any time. question: is this true? Do i need to make these changes to avoid a blank page!? Hi there, I am trying to create a custom registration form and connect the file to mysql using a config.php file. I created the file with a tutorial. I placed both the config.php and the registration.php in a "page-templates folder" inside the "theme folder". Using wordpress "add new page" I am able to select the registration.php file as a template. I am able to open the newly created page and type in information like username and password. I am able to press submit and I get redirected to a new page.
Problem: I would really appreciate your help. Siegfried Hello! I am trying to code one part of my functions list, but when I run the function to test all if, elseif, and else statements, it always goes to the else statement. So basically it tries to connect to MySQL, retrieve a username, and check to see if it is active, banned, or inactive. It is always saying it is active, even when I change it's status to inactive via PHPMyAdmin. Here is the code: Code: [Select] <?php function checkActive() { $checkActiveQuery = mysql_query("SELECT * FROM users WHERE user=adf"); if ($checkActiveQuery == "INACTIVE"){ echo "Your account has not been activated. If you have not recieved, or have misplaced the activation email, please contact the administrator."; } elseif ($checkActiveQuery == "BANNED"){ echo "You have been banned from our social network. If you believe this is an error, please contact the administrator."; } else { echo "Your account is active."; } } ?> The username I am testing with is "adf" without quotes. But, when I change its status to INACTIVE, it still says it's still active, same with banned. How do I make it retrieve this data from MySQL and it function properly? It seems that it is unable to retrieve this data specifically. Thanks! Nick. I have couple jquery codes in a single file:
$(document).ready(function(){ $('#all').delegate('a.link', 'click', function(){ //more code here }) $('body').delegate('.nice', 'click', function(){ //more code here }) });This works great but is it better to close each function using ; symbol? Even if I do or not the code works ok, BUT whats the correct way? I have a file I'm trying to split up to separate some HTML from PHP code. Everything works fine when all of the code is together but when I split it into two files the two call back functions in the html form will not work. No errors and when I view the page source my file is included with the form. Any help would be appreciated. Here is the file that has the include statement. add_action('admin_menu', 'sampleoptions_add_page_fn'); // Add sub page to the Settings Menu function sampleoptions_add_page_fn() { add_options_page('Options Example Page', 'Options Example', 'administrator', __FILE__, 'options_page_fn'); } function options_page_fn() { ?> <?php include('options_form.php'); ?> <?php } Here is the options_form.php file code. Code: [Select] <div class="wrap"> <div class="icon32" id="icon-options-general"><br></div> <h2>My Example Options Page</h2> Some optional text here explaining the overall purpose of the options and what they relate to etc. <form action="options.php" method="post"> <?php settings_fields('plugin_options'); ?> <?php do_settings_sections(__FILE__); ?> <p class="submit"> <input name="Submit" type="submit" class="button-primary" value="<?php esc_attr_e('Save Changes'); ?>" /> </p> </form> </div> I'm guessing that it may have to do with this line of code, due to the page parameter but I don't know that much about that area. <?php do_settings_sections(__FILE__); ?> Thanks in advance I recently migrated from Windows XP to Windows 7, and a PHP package I depend on (mPDF, see http://www.mpdf1.com/mpdf) stopped working. When I call one of its necessary functions, it hangs. I investigated further and found that the crash was happening in a call to file_get_contents, given one parameter, a URL that points to a CSS file. I found that the file_get_contents and file functions both crash when given a URL. Both work normally when given a pathname on the local file system. As I understand it, these functions are supposed to accept a URL if the INI directive allow_url_fopen is enabled. I checked by calling ini_get; it is. In any case, the php.net description of fopen says that if that directive is disabled, "PHP will emit a warning and the fopen call will fail" -- not just hang! It appears as if there is a glaring bug in one of PHP's core functions. I'm very skeptical that that is really the problem, but I don't know what else to suspect. Any ideas? My configuration is Windows 7 Professional with SP1; Apache 2.2.17; PHP 5.2.17. For reference, here is the script I used to investigate this problem. I stepped through it with a debugger, so I didn't bother displaying results. As shown, the script works. When I comment out the second assignment to $path it should produce identical results; instead it hangs. Code: [Select] <?php $isopen = ini_get('allow_url_fopen'); $path = "http://localhost/pdf/cert.css"; $path = "D:/htdocs/pdf/cert.css"; $contents = file($path); $contents = @file($path); $contents = file_get_contents($path); $contents = @file_get_contents($path); ?> Hi there, I have already read some other topics concerning the same problem I am encountering. I have multiple applications which I programmed in PHP. In all of these applications I use a central authentication database and a central translation database (also on PHP). For this to work, I need to include a functions.php file for both the authentication db as for the translation db in all of my sites. Because I use different URL's for all my apps, including auth and transl, I am forced to use an URL when including both the functions.php files of the auth db and the transl db. As I found out (the hard way) PHP5 doesn't include the raw data of my functions.php files into the calling files, so none of my functions are known and I receive an error "Call to undefined function ...". Since I am using these programs only on an internal network (not public available), I am not afraid of any security issues. Is there any way I can include my functions.php files using an URL (like include ('http://trans.mysite.com/sys/functions.php');) so the defined functions in the functions.php file are known for the calling page? I hope I am not too confusing you all with my story, but I would really be very greatfull with some help. If needed I can also provide you with some more coding I used and configuring. I already checked my php.ini file and the following settings have already been applied: allow_url_fopen = On allow_url_include = On short_open_tag = On Many thanks in advance. dear folks
this question is regarding the plugin update, file uploader and SFTP - on a wordpress that runs on secured- server
I think I know the answer to the following question as "not possible" but I figured I would check. my sites are on servers where we disable FTP access and only use SFTP access, and also on a different port (not port 22). what if i want to use a automated maintaining service like the following https://mainwp.com http://wwww.infinitewp.com automated Installing and updating plugins to the sites does not seem to work and I assume this is the reason why. I'm also assuming the File uploader extension will not work either. Can anyone confirm this for sure though? Any ideas as far as workaround? one might think of the following way: Can you try adding your SFTP settings into the wp-config of one of my sites to see if that allows the functions to work? we can see an example in http://codex.wordpre...g_wp-config.php under WordPress Upgrade Constants or possibly try this plugin SSH SFTP Updater Support do you have any idear!? cf: https://mainwp.com/f...&highlight=sftp I have a php tutorial that I followed for creating, inserting, selecting and updating a MySQL database with php. Everything works fine so I wanted to put it into Wordpress. I took the code and placed it into the wordpress page and everything worked just fine except the update function. Here is the tutorial I used. http://www.phpsimple.net/mysql_insert_record.html It is also the part I am having trouble with. I am able to create a record and I am also able to select a record but when I choose "update" the form doesn't load the data. It will outside the website but not inside wordpress. I am hoping this is not vague but because of my inexperience I am not sure what else to say. I will be more than happy to provide any other information you need. I try to publish my web site today . I choose www.netfirm.com to store my web pages. However , this is not working. I get error message. Cannot read /mnt/w0500/d04/s15/b0322718/www/ptiimaging.ca/.htaccess. I do not know how to fix this problem . Please tell me how to fix it . Thank you very much. This topic has been moved to Other. http://www.phpfreaks.com/forums/index.php?topic=320387.0 I am a newbie. I need some guidance for logging onto an existing site, and downloading files. Some tips what I should be looking for? Thanks. Is thier some code I can use to Notifiy me of files that are downloaded from my site. I would like to put some public files (PDF) in a folder to where the public could download what ever, but I want to know who downloaded these files. Dont know much more than that just got the idea from another site cause they new I downloaded a file and I thought it would be a good idea on may site to do something like that. |