PHP

120K

Solutions

33K

Contributors

PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.

Share tech news, updates, or what's on your mind.

Sign up to Post

WooCommerce / WordPress over ride a Plugin function.  I always seem to run into trouble when I try to over ride a plugin function. I have a plugin that makes a Woo Product category password protected.  It is an open source plugin from GIT.  I want to customize the password form.  The form is in a function inside the functions.php file of the plugin.
The Plugin Method
<?php
function wcl_get_the_password_form($category_id = false)
{
//  DO STUFF
}

Open in new window


My Method inside of my child theme functions.php:
<?php
add_action('wcl_get_the_password_form','mogo_password_form');

function mogo_password_form($category_id = false)
{
//  DO STUFF
}

Open in new window


This is the Plugin link: https://wordpress.org/plugins/wc-category-locker/
0
Build an E-Commerce Site with Angular 5
LVL 13
Build an E-Commerce Site with Angular 5

Learn how to build an E-Commerce site with Angular 5, a JavaScript framework used by developers to build web, desktop, and mobile applications.

Hi,

I am in trouble running a WordPress site on Bitnami WordPress on ec2 instance.

It seems that apache is running, but no http response from the server.
Port 80 is not listened by any service.

bitnami@ip-:~$ lsof -i # no output
bitnami@ip-:~$ 

Open in new window


Apache seems to be runnning.
bitnami@ip-172-31-33-101:~$ ps aux | grep apache
root      1910  0.0  2.9 203384 30288 ?        Ss   07:35   0:00 /opt/bitnami/apache2/bin/httpd.bin -f /opt/bitnami/apache2/conf/httpd.conf
daemon    1915  0.0  1.5 812444 15968 ?        Sl   07:35   0:00 /opt/bitnami/apache2/bin/httpd.bin -f /opt/bitnami/apache2/conf/httpd.conf
daemon    1916  0.0  1.5 812444 15892 ?        Sl   07:35   0:00 /opt/bitnami/apache2/bin/httpd.bin -f /opt/bitnami/apache2/conf/httpd.conf
bitnami   2996  0.0  0.1  14224  1084 pts/1    S+   07:37   0:00 grep --color=auto apache

Open in new window


I restarted apache, mysql, php as follows.
bitnami@ip-172-31-33-101:~$ sudo /opt/bitnami/ctlscript.sh start
/opt/bitnami/mysql/scripts/ctl.sh : mysql  started at port 3306
/opt/bitnami/php/scripts/ctl.sh : php-fpm started
Syntax OK
/opt/bitnami/apache2/scripts/ctl.sh : httpd started at port 80

Open in new window


But no response.

bitnami@ip-172-31-33-101:~$ curl localhost:80

Open in new window


Any advise would be very appreciated.

Thanks!
0
I use a couple of cronjobs that reside on my website's "back end" at the hosting company that work like this:

At a set time each week, a batch of files, say from "Folder A." is moved to a folder, replacing the files there which have the same name (overwrites them).

If there are no files in folder A, an email is sent to me notifying me of  the lack of files AND then moves a group of same-named files from a standby folder.

I had these jobs created years ago by a freelancer. Now I need some more. I have a background (from more than ten years ago)  in BASIC and I'm wondering if I can learn how to do this fairly quickly and easily or if it would be better to farm it out to a freelancer. I;m not in a huge hurry, but the sooner, the better.

OR is there an online "auto-writer" type of service that takes your input and generates the code, either at no cost or for a proce?

Your thoughts?
0
I need to call Coldfusion CFC from the PHP on the different server
0
This is the code I received from my first question.
It searches the original text file for a period.
When the period is found it prints the sentence to a new text file and prints a carriage return so that each sentence is on its own line.

I would like to be able to browse my computer for the file I want to open and then convert the file and then placed the new file in say 'Downloads'.

Thanks,

Michael

<?php
// The source file
$inFile = "1corinthians7.txt";
var_dump(file_exists($inFile));

// The file we'll write with the line breaks
$outFile = "converted_lines.txt";

// Open the files
$fpIn = fopen($inFile, "r");
$fpOut = fopen($outFile, "w");

// Loop through the source file, 1k at a time
while(!feof($fpIn))
{
  $chunk = fread($fpIn, 1024);

  // Replace every . with a . and a line break afterwards and write that to the out file
  fwrite($fpOut, str_replace(".",".\n",$chunk));
}

// Close the files
fclose($fpIn);
fclose($fpOut);

Open in new window

0
We use Symfony 2.8 as the framework for our website. The people who set it up years ago probably didn't do it right, and we have about 10 different bundles which comprise all the different areas of our site (Cart, MyAccount, Products, Pages, etc).

Two questions:

Should the entire website be under just one bundle, so we dont have duplicated code in multiple bundles?

and

If a bundle needs a bit of code to get a piece of data, should that be written as a service so we can call it from anywhere, without having multiple lines of code duplicated all over the place wherever we need that piece of data?
0
I have two tables in a MySQL database with almost identical structure.

I want to copy the "from" table to the "to table" without having to mention every column by name.

The "to table", purposely, has one more column at the end that is auto increment.

Is there a way to "copy corresponding", so to speak? Either in phpMysql or in php code.

Thanks
0
Hi,

I was customising a banner on my client's homepage around a week ago, very basic additional CSS on a qode wordpress theme to get the banner looking the way I wanted, achieved that, saved my work and closed my laptop down.

When I got home a short while later, I visited her site on Firefox and the homepage was a mess! Her logo was gone and the theme logo was in its place, the buttons on her homepage had lost all their styling, the banner I was impressed with looked awful and not like the final version I saved, the footer columns widget content had all shifted out of alignment to the left as well as various other styling issues.

I know this is clearly CSS related but error logs are referencing PHP issues, nothing mentioned about CSS and PHP is something I know absolutely nothing about. I've copied and pasted some of the errors and spent some time trying to figure out what they mean but her site has been like this for too long now for me to learn enough PHP to understand these errors and determine whether they could be related to my issue.

Out of desperation, I deleted my theme and reinstalled as I had similar issues following a major update recently and hoped following those steps might solve the problem this time, but no luck.

If anyone has the time and understanding of PHP to scan through my error codes and tell me whether or not this could be related to the problems I've had I would be extremely grateful...

The PHP version is: 5.6.30, Wordpress 5.1.1, …
0
I am using CentOS 6. I had PHP 5.x on my machine and I updated PHP 7.2 using a Blog: https://tecadmin.net/nstall-php7-on-centos6/

However after updating PHP 7.2 Apache doesn't show the output of the PHP file but it downloads the source file itself.

Command line shows PHP 7.2:

# php --version
PHP 7.2.17 (cli) (built: Apr  3 2019 10:16:22) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

Open in new window


#apachectl -M
Loaded Modules:
 core_module (static)
 mpm_prefork_module (static)
 http_module (static)
 so_module (static)
 auth_basic_module (shared)
 auth_digest_module (shared)
 authn_file_module (shared)
 authn_alias_module (shared)
 authn_anon_module (shared)
 authn_dbm_module (shared)
 authn_default_module (shared)
 authz_host_module (shared)
 authz_user_module (shared)
 authz_owner_module (shared)
 authz_groupfile_module (shared)
 authz_dbm_module (shared)
 authz_default_module (shared)
 ldap_module (shared)
 authnz_ldap_module (shared)
 include_module (shared)
 log_config_module (shared)
 logio_module (shared)
 env_module (shared)
 ext_filter_module (shared)
 mime_magic_module (shared)
 expires_module (shared)
 deflate_module (shared)
 headers_module (shared)
 usertrack_module (shared)
 setenvif_module (shared)
 mime_module (shared)
 dav_module (shared)
 status_module (shared)
 autoindex_module (shared)
 info_module (shared)
 dav_fs_module (shared)
 vhost_alias_module (shared)
 negotiation_module 

Open in new window

0

Open in new window

0
HTML5 and CSS3 Fundamentals
LVL 13
HTML5 and CSS3 Fundamentals

Build a website from the ground up by first learning the fundamentals of HTML5 and CSS3, the two popular programming languages used to present content online. HTML deals with fonts, colors, graphics, and hyperlinks, while CSS describes how HTML elements are to be displayed.

<?php
require("class.phpmailer.php");
$mail = new PHPMailer();$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "smtp1.example.com;smtp2.example.com";
$mail->SMTPAuth = true;
$mail->Username = 'smtpusername';
$mail->Password = 'smtppassword';

$mail->From="mailer@example.com";
$mail->FromName="My site's mailer";
$mail->Sender="mailer@example.com";
$mail->AddReplyTo("replies@example.com", "Replies for my site");

$mail->AddAddress("email@example.com");
$mail->Subject = "Test 1";

$mail->IsHTML(true);
$mail->AddEmbeddedImage('logo.jpg', 'logoimg', 'logo.jpg'); // attach file logo.jpg, and later link to it using identfier logoimg
$mail->Body = "<h1>Test 1 of PHPMailer html</h1>
    <p>This is a test picture: <img src=\"cid:logoimg\" /></p>";
$mail->AltBody="This is text only alternative body.";

if(!$mail->Send())
{
   echo "Error sending: " . $mail->ErrorInfo;;
}
else
{
   echo "Letter is sent";
}
?>

Open in new window



im looking at this example,

how can i use this for inline images copied into the email body and how can i even tell if their is a img in the body ?

cause not all users will embed a image inline on email ?
0
this is a follow-on to this question
https://www.experts-exchange.com/questions/29142368/Need-Help-With-WooCommerce-Custom-Sort.html

Open in new window

I need to have a multiple layer sort.  I now have it sorting on Parent ID but then I need within the the Parent ID for it to be alphabetical.  For example, I have a $2 Off, Buy 4 and a Buy 9.  They need to be in that order but now they are Buy 9, Buy 4 and $2.  I know I can do menu order but that is another tedious task.

If someone can show me how in the code below to do a sort on Alphabetical within Parent ID that would be great.

[code]unction jk_add_custom_sku() {
$args = array(
'label' => __( 'Parent ID', 'woocommerce' ),
'placeholder' => __( 'Enter custom SKU here', 'woocommerce' ),
'id' => 'jk_sku',
'desc_tip' => true,
'description' => __( 'This SKU is for internal use only.', 'woocommerce' ),
);
woocommerce_wp_text_input( $args );
}
add_action( "woocommerce_product_options_sku", "jk_add_custom_sku" );

function jk_save_custom_sku( $post_id ) {
// grab the custom SKU from $_POST
$custom_sku = isset( $_POST[ 'jk_sku' ] ) ? sanitize_text_field( $_POST[ 'jk_sku' ] ) : '';

// grab the product
$product = wc_get_product( $post_id );

// save the custom SKU using WooCommerce built-in functions
$product->update_meta_data( 'jk_sku', $custom_sku );
$product->save();
}

add_action( "woocommerce_process_product_meta", "jk_save_custom_sku" );
//add_action( "save_post_product", "jk_save_custom_sku" );

####### Custom Sort Option

Open in new window

0
Joomla: "UI should be replacement of Joomla core, loaded at component or template level"  Can someone explain to me the best way to go about replacing the Joomla core jQuery UI with another UI?
0
Hello everyone,

I think I know the answer beforehand but I have to ask anyway. Is there ANY possible scenario where I keep my passwords (for LDAP, SQL, etc) in some sort of encrypted way in my server running Windows Server and IIS?

Here's the deal. I'm making a corporate intranet site for my company in PHP and they want me to have all the passwords for all the services in different files that even I will not be able to access or, if I do, I can't "read" the passwords because they are encrypted.

I suppose encryption is out of the way as I would have to know the "salt" and unencription method to actually be able to use those passwords but I was thinking that, being under a Windows enviroment, I could have PHP read the values from some TXT files in a directory where I couldn't get access to. Is that possible to do in IIS? Could one PHP file get the neccessary permission to read a TXT file in another local/remote server so it can read the different passwords from different files?

It's not exactly the kind of security they're asking me (they love encryption) but in this way, I think I might be able to convince them. They do not even believe having these files outside the root folder for the site is secure enought as I will be able to read them (LDAP user for example needs to have a non-expiring password that I can't get).

Thanks in advance.
0
Hi,

My competitor has a recurring subscription service which you can see below - the user can either click no subscription or if they click a subscription recurring they get to choose from a drop down:

https://us.brushnaked.com/collections/adult-toothbrushes/products/adult-soft-activated-charcoal-bristle-toothbrush

I would like the same layout/style on my site you can see how it is now below:

https://staging1.barebrush.com.au/product/bio-toothbrush/

Here is the code for that part of the page (note I am using the Subscribe All Things Master plugin (https://github.com/somewherewarm/woocommerce-subscribe-all-the-things) and this is one of the template pages):

https://gist.github.com/HeadStudios/3f03286f1672d271d7cb96fd3a8db6fe

Any input you could give on functions/CSS styles to use and the overall view of how to approach it would be much appreciated.

Thanks
0
Javascript and AJAX to validate an Address.  The following is the Script that is used to validate an address withe USPS.  The form passes all of the info and everything works except the SUCCESS AND FAIL messages from the AJAX don't print on screen.  I think I need to use an append, or HTML to make a popup box?  Is there an easy solution here?

<script>
 var asaAddressValidate = function(options){
     
    var self = this;
    self.options = jQuery.extend({
      enabled: true,
      formEl: null,
      formFields: {
         Country: '',
        Address1: '',
        Address2: '',
        City: '',
        State: '',
        Zip: ''
        },
      onResponse: null
    }, options);
     
    
    this.interpolate = function(text, data, parent){
      var reg, tmp = String(text), key;
      for(var i in data){
        key = (parent ? parent+'.' : '') + i;
        if (typeof data[i] == 'object'){
          tmp = self.interpolate(tmp, data[i], key);
        }
        else {
          reg = new RegExp('\#\{'+key+'\}', "g");
          tmp = tmp.replace(reg, String(data[i]).replace(/\$/, '&DS;'));
        }
      }
      return String(tmp).replace(/&DS;/g,'$');
    };
    jQuery(self.options.formEl).submit(function(){
        
      if (!self.options.enabled)
        return true;
      if (typeof self.options.dialogEl == 'undefined'){
        jQuery('body').append('<div style="position:absolute; z-index:1000; top:50%;left:50%; " id="asaAddressValidateDialog" 

Open in new window

0
I know I can add theme version number as query string to my style sheet like below

$child_theme_url = get_stylesheet_directory_uri();
$theme_num = wp_get_theme()->get('Version');
wp_register_style( 'avia-style' ,  $child_theme_url."/style.css", array(), $theme_num, 'all' );

Open in new window


How to do the same for all img tags so they can be like below

<img src="/myimage.jpg?v=1.0.2" alt="" />

Open in new window


Thanks
1
Hi Guys,
This is a strange one. Gmail won't show "<img src='data:image/png;base64, etc. etc. " as an image — just the code!
Sending a group newsletter to anyone@gmail.com results in a message that features the data:image code — not the image.
Gmail functions properly when we send email with data:image using an email client such as Thunderbird, but gmail fails when sending a mass mailing using PHP.
Got any idea of what's going on and how to solve it?
Thanks,
Sas
0
Hello,
I would like to include a contact form in a website. The form should have no major security holes. I have only good knowledge of HTML and CSS. I do not have any knowledge in JavaScript or PHP. How can I still create such a contact form on my website without being an expert in JavaScript or PHP? Is there finished code or a tutorial? I am grateful for every tip.
0
Amazon Web Services
LVL 13
Amazon Web Services

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Environment:
New laptop:  Win 10
Old laptop:  MacOS High Sierra + Bootcamp (Win 10) on dead MacBook Pro

How to transfer entire XAMPP directory from a Bootcamp partition of a Mac to a Windows PC?

I can attach old laptop's hard drive to the new Windows PC via a USB3 cable and read the bootcamp partition on it (using HFS+ installed on the new laptop).

If I try to simply copy the XAMPP directory over, the databases are partly useable by Joomla on the Windows PC but I'm unable to log in as administrator on the sites which were in htdocs on the bootcamp xampp install (I'm guessing there are a number of issues with a direct copy approach such as path references in the xampp/php files on the bootcamp xampp which are invalid once they're on the Windows PC).

I can no longer bootup the mac (motherboard fried) to access windows on it in bootcamp and export the databases (which would be the normal way to transfer a db from one xampp install to another).

I've tried installing virtualization software on the new laptop but so far haven't been able to create a bootable MacOS in VMWare or Virtual Box.

There should be a way for me to create a fresh xampp install on the new windows laptop and to copy over just the database and tables I need from the old laptop's bootcamp xampp directory but I'm not clear on which files to copy over.  Presumably the Joomla sites in directories in htdocs could all be copied over without an issue (guessing) but the databases which those …
0
I have recently upgraded my linux server to newer version of PHP and MySQL.  Prior to the  upgrade I was able to run my php web application and was able to download audio and doc files from my php application with active x controls.  The location of the files in the Linux server is a windows mounted folder.  I am not able to download any file.
0
\u003cii_jtobx3m60\u003e

Open in new window


here is the sample im trying to decode,

this is where it comes from,  Gmail api
Screen-Shot-2019-03-25-at-15.45.03.png
 'body' => $getGmailService->gmailBodyDecode("\u003cii_jtobx3m60\u003e"),

Open in new window


decoding it with this function

function gmailBodyDecode($data) {
  $data = base64_decode(str_replace(array('-', '_'), array('+', '/'), $data)); 


  //$data = imap_qprint($data);
  return($data);
} 

Open in new window



it not doing anything, my application is took loading due to this.

any help ?
0
Making a lightbox pop up over the existing page using <iframe>.

I don't see how to do this.

Specifically, reference this question already on EE:

https://www.experts-exchange.com/questions/29140035/Window-overlay-over-existing-window.html?headerLink=workspace_open_questions

I cannot see how to do this with iframe AND lightbox. What I want is for the attached php script to show up in a lightbox window. I was told just enclose in an iframe, I don't understand how to do that.

More specifically, I have this code snippet:

			<div class="col-sm-6 col-xs-6" style="font-size:17px;padding-botton:10px;"><input type="submit" value="Request Drawings" style="color:white; background-color: #5B9BD5; border-style: solid; border-color:#41719C; box-shadow: 4px 4px 2px #C3BDBD;" onMousedown="ac='rd';">

Open in new window


and this javascript:

if (ac == "rd")	{
			document.st.action = "pdf_draw_lb.php?pid=" + pid + "&newproj=" + newproj + "&fr=" + fr;
			return true;		
		}

Open in new window


This works perfectly, but of just shows pdf_draw_lb.php in the browser, as I would suspect.

I need the details of how to make that work, so it looks like the attached image.

Thanks
drawing_unavailable.PNG
pdf_draw_lb.php
0
Hello,

I have a php script to upload photos to the server and the link to the database. I want to adjust this. What I want is that this form can be used to take a photo with a mobile phone and then upload it to the server. It is possible to get the name in the database, but not to upload the photo to the server. Does anyone have an idea how I can do this in the script?
sendwinkeliersnieuw.php
members.php
0
i am working on a muilt network wordpress site that when the user signs in the site is created. i have it that the site will create and change the theme. what i need is to run woocommerce after creating the site.
0

PHP

120K

Solutions

33K

Contributors

PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.