Quantcast
Channel: PHP Freaks: PHP Help
Viewing all 13200 articles
Browse latest View live

Sessions for logging in broke when I switched to SSL HTTPS

$
0
0
Hello I'm needing some help. Switched from http to https and now my Sessions are broken. I have a meeting soon with the big boss, and am at my wits end this morning.. 
 
Customer uses iPage for hosting.  Variable names have been changed to protect the innocent.
 
NOTE: session worked before switching to SSL, to log a person in, and keep them logged in as they surfed the site... Only I logged in, for development purpose, no public users ever did.
 
OK..
EXAMPLE  pre-SSL:
I go to site HTTP://foo..., I see a session id initialized in my cookies,  example: "a56h84gfg21908d788oe6gg5h99"
logging in took you from http://www.foo.com/login/ to  http://www.foo.com/userdashboard/  by checking user/pass, setting session variables and then using a redirect(url.'userdashboard') line
and session variables were updated like
$_Session[iamloggedin]=1;
$_Session[userdetails][userid]=345

 

etc;
and cookie session id was still "a56h84gfg21908d788oe6gg5h99" because everything looks great.
 
EXAMPLE post-SSL:
Now that https is working (site loads ok at least)
I go to site, I see this session id initialized in my cookies, therefore it is writing the initial session cookie ok - example: "c10ac91fd2c721908d788oeff305bc2"
I log in, do a dump(); to see what happened to session *right after I log in*, and sure enough 
$_Session[iamloggedin]=1;,
$_Session[userdetails][userid]=345;

 

is there ok

 
Take dump () out and allow page to forward to next page "https://www.foo.com/userdashboard/"   * which was successful before https*  
and now session cookie is still "c10ac91fd2c721908d788oeff305bc2"   (it did not generate a new cookie id)
but none of my custom user session variables exist. The dumped session after the redirect  which worked fine before, is now merely what you see when you visit "HTTPS://www.foo.com" no custom $_Session vars there, it lost them.
 
----
 
How domain is now loaded: using htacces file,  I added this alone: could this be problem?
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}:443%{REQUEST_URI}
 
----
This is the php.info  -- the only thing I had changed here for https was   "session.cookie_secure On On"
PHP.ini settings related to session:
Session Support enabled
Registered save handlers files user
Registered serializer handlers php_serialize php php_binary wddx

Directive Local Value Master Value
session.auto_start Off Off
session.cache_expire 180 180
session.cache_limiter nocache nocache
session.cookie_domain no value no value
session.cookie_httponly Off Off
session.cookie_lifetime 0 0
session.cookie_path / /
session.cookie_secure On On
session.entropy_file /dev/urandom /dev/urandom
session.entropy_length 0 0
session.gc_divisor 1000 1000
session.gc_maxlifetime 1440 1440
session.gc_probability 1 1
session.hash_bits_per_character 4 4
session.hash_function 0 0
session.name PHPSESSID PHPSESSID
session.referer_check no value no value
session.save_handler files files
session.save_path 4;/hermes/phpsessions 4;/hermes/phpsessions
session.serialize_handler php php
session.upload_progress.cleanup On On
session.upload_progress.enabled On On
session.upload_progress.freq 1% 1%
session.upload_progress.min_freq 1 1
session.upload_progress.name PHP_SESSION_UPLOAD_PROGRESS PHP_SESSION_UPLOAD_PROGRESS
session.upload_progress.prefix upload_progress_ upload_progress_
session.use_cookies On On
session.use_only_cookies On On
session.use_strict_mode Off Off
session.use_trans_sid 0 0
 
----
 
Again, this worked great before https was involved. So, why could this be happening, session being written on server not retrievable for some reason - it has the cookie id but maybe nothing was saved on server?  Is my htaccess file wrong?  Some other setting in php.ini that is wrong?  Anyone have any ideas? This is iPage server, so shared hosting, so I do not have ability to see as much of server as a dedicated server.. 

Thank you for your generous help!
Wits End is not a nice place to visit and I don't wanna live here!

Get SplObjectStorage by key

$
0
0

How can I retrieve an object stored in SplObjectStorage based on a unique key?  Is it possible to do so the way I am attempting to show in my 2 example?

<?php


class Foo
{
    private $storage;
    private $map;


    public function __construct()
    {
        $storage = new SplObjectStorage();
        $map=[];
    }


    public function add(object $obj)
    {
        $this->storage->attach($obj, []);        
    }


    public function assign1($obj,$id)
    {
        $this->storage[$obj] = $id;
    }


    public function findByID1($id)
    {
        $this->storage->rewind();
        while($this->storage->valid()) {
            if($id == $this->storage->getInfo()) {
                return $this->storage->current();
            }
            $this->storage->next();
        }
        return false;
    }


    public function assign2($obj,$id)
    {
         $this->map[$id]=spl_object_hash($obj);
    }


    public function findByID2($id)
    {
        $hash=$this->map[$id];
        return getObjectBasedOnHash($hash);
    }


}

$obj=(object)['foo' => 'bar'];
$foo=new Foo();
$foo->add($obj);

//Now this object's id is known $id=11111;

 

$foo->assign1($obj,$id); $obj1=$foo->findByID1($id); $foo->assign2($obj,$id); $obj2=$foo->findByID2($id);

 

PHP JSON Encode Date Format

$
0
0

Hi All,

 

I am using JTable Plug in and using PHP code as my server language.

The plug in requires json encode in this format,

 

** please ignore other data. except for "RecordDate" **

{
 "Result":"OK",
 "Records":[
  {"PersonId":1,"Name":"Benjamin Button","Age":17,"RecordDate":"\/Date(1320259705710)\/"},
  {"PersonId":2,"Name":"Douglas Adams","Age":42,"RecordDate":"\/Date(1320259705710)\/"},
  {"PersonId":3,"Name":"Isaac Asimov","Age":26,"RecordDate":"\/Date(1320259705710)\/"},
  {"PersonId":4,"Name":"Thomas More","Age":65,"RecordDate":"\/Date(1320259705710)\/"}
 ]
}

What i have for my output is,

{
"Result": "OK",
"TotalRecordCount": 1,
"Records": [
{"Row": "1","emp_id": "Nhhh","course1": {"date": "2017-01-06 00:00:00","timezone_type": 3,"timezone": "Asia\/Brunei"}
}]
}

Im currently using datetime as my data type in my database (SQL Server), and the output is empty due to wrong json date format.

 

thanks for the help.

Get Object Variable

$
0
0

Hi,

 

Apologies If I've got the title wrong but I'm trying to obtain a value from an array, however, it's an object (?)

Array
(
    [test] => WC_Coupon Object
        (
            [code] => test
            [id] => 1529
            [exists] => 1
            [discount_type] => percent_product
            [coupon_amount] => 10
            [individual_use] => yes
            [product_ids] => Array

I need to get coupon_amount

 

I thought I could use $my_coupon[0]->coupon_amount; but believe I've confused myself or misunderstood!

 

Any advice is gratefully received!

Thanks

How to restrict mySQL results to single instance after using mb_substr

$
0
0

Hi, anyone know how I can restrict the values displayed in a Select, taken from a MySQL query, which have been edited before output?

The original values are all unique so doing a COUNT or DISTINCT in MySQL won't work. This is the PHP I'm using to pull and edit the values:

        $getusers = $mysqli->query("SELECT order_discount_code FROM orders ORDER BY order_discount_code ASC");
            while ($row = $getusers->fetch_assoc()) {
                $vouchercode = $row['order_discount_code']; //These values are all unique but share common characters e.g the first three characters of the string
                $agencycode = mb_substr($vouchercode, 0, 3); //I'm doing this as I want to have just the first three characters show in the form Select that contains this query
        echo '<option>'.$agencycode.'</option>';
            }

Basically I just want to output unique instances of $agencycode, so if the first three characters might be ABC, DEF or GHI for all the various records, I want ABC to only show once in the Select, DEF to show once, GHI to show once etc.

At the moment my code shows a whole long list of every instance.

Anyone know how I can do this? Thanks!

Generate two buttons div

$
0
0

Hello, 

First post, very not expert.

 

I have this page I'm editing (from a wordpress theme called "lay theme"): http://mtthsstffn.altervista.org/tagnacht/

 

In this carousel that scrolls images, I need to move the "next" "prev" clickable area slightly outside the images. I think I want to make two invisible divs, left and right, that overlay the image and occupy the center-to-left and center-to-right area of the carousel, with a variable length I can define.

 

A friend suggested to add this 

<div id="nav-left" style="
    height: 800px;
    display: block;
    width: 50%;
    position: absolute;
    top: 0;
    ;
    pointer-events: left;
    cursor: move;
"></div>

inside <div class="lay-carousel-wrap immediate">

 

I think it can be right, but where can I find the files I need to do it? 

I looked around the whole website and couldn't find the HTML with this element, hence I think it's automatically generated with PHP, but I have no idea where to start for this.
Thanks for any help!

 

How to get content into a ReactPHP server?

$
0
0

A remote client has connected to the following server described at the bottom of this page, has told the server that its GUID is 123456789, and the server has created a map between this GUID and the specific client connection.

Another script index.php is ran through Apache on the same machine as the sockets server.

<?php

$guid=123456789;
$data='{"message":"hello"}';

someFunctionToSendDataToSocketsServer($guid,$data);

Somehow, I would like to have index.php send $guid=123456789 and $data='{"message":"hello"}' to the sockets server, and then execute:

$client=$this->findConnectionByGuid($guid);
$client->write($data);

someFunctionToSendDataToSocketsServer() should be a blocking function up to the sockets server writing the data (but not that the client received it and acknowledged it) and should return true/false (or a 200/400 header, or some other means to indicate status).

 

 

At first, I was thinking of using a ReactPHP HTTP server operated on the same loop as the sockets server.  index.php would then use curl to send it to the HTTP server, the HTTP server on request event would get the data, and if valid format send the data to the client and return a 200 header, and if not valid format, return a 400 header.  ReactPHP, however, says that the HTTP server is not stable.

 

Another option would be to add a sockets client to the server machine and have index.php use that client to send the data to the sockets server.  I don’t think this make sense, however, as index.php is not communicating bi-directional with the sockets server.  Also, it adds a little complication as the sockets server is currently designed to receive connections from remote clients which send the server their unique GUID.  Lastly, from a security standpoint, I don’t want the remote clients to somehow gain privileges available to only index.php.

 

Or maybe a redis queue where index.php places the content in the queue, and it pops out in the server script where it is sent.  I am not sure how the true/false status would work.

 

Or maybe something else altogether?

 

Any advice?

<?php
namespace MyServer;

use React\EventLoop\Factory;
use React\Socket\Server as SocketServer;
use SplObjectStorage;
require 'JSONStream.php';

class Server
{
    private $app,       //The main application
    $url_sockets,       //Host and port for the socket
    $clientList;        //SplObjectStorage

    public function __construct($url_sockets,$app)
    {
        $this->app = $app;
        $this->url_sockets=$url_sockets;
        $this->clientList = new SplObjectStorage();
    }

    public function start() {
        $loop = Factory::create();
        $socket = new SocketServer($loop);
        $socket->on('connection', function (\React\Socket\ConnectionInterface $client){
            $client = new \Kicken\RLGL\JSONStream($client);
            $this->clientList->attach($client, []);

            $client->on('data', function($data) use ($client){
                // The server doesn't know the client's GUID until the client sends this data to the server   
                if($guid=$this->getConnectionID($client)) {
                    $this->app->process($data, $guid, $client);
                }
                elseif($guid=$this->app->getGUID($data)) {
                    $this->addConnection($client, $guid);
                }
            });

            $client->on('close', function($conn) use ($client) {
                if($this->socketClients->contains($client)) {
                    $this->socketClients->detach($client);
                }
            });

            $client->on('error', function($conn) use ($client) {
                $client->close();
            });

            echo "New connection accepted.\r\n";
        });
        
        $socket->listen($this->url_sockets['port'],$this->url_sockets['host']);

        $loop->run();
    }

    private function addConnection($client, $guid)
    {
        $this->clientList[$client]['guid']=$guid;
    }
    private function getConnectionID($client)
    {
        return $this->clientList[$client]['guid'];
    }
    private function findConnectionByGuid($guid)
    {
        //There should be a better way to do this???
        $this->socketClients->rewind();
        while($this->socketClients->valid()) {
            if($guid == $this->socketClients->getInfo()) {
                return $this->socketClients->current();
            }
            $this->socketClients->next();
        }
        return false;
    }
}

 

DB connect VIA SSH?

$
0
0

So I have mySQL Workbench that connects to my host and they require an SSH Connection.  I have that option set in mySQL workbench.  I am able to connect just fine and look at the database that my developer has coded.

 

Now I actually want to use PHP to connect to the database and pull some information out to utilize on another domain name.

 

Can anyone give me a link or help me understand, how can I connect to a mySQL db using SSH in a PHP script?


PHP - Date Formatting

$
0
0

Hi All!

This is my second week of PHP. I'm going through a PHP course at the moment so i'm pretty certain i've made a stupid mistake somewhere!

 

I'm trying to get a date that's entered in my CMS panel to show on the front-end.

 

I've defined the variable departure_date --> got the raw data --> created a new date object --> tried to display the date object in the format j M Y.

 

I believe there is something wrong with how i am defining the date object in my echo statement.

 

I forgot to mention this is a wordpress website i'm working on with ACF custom fields if that helps.

$departure_date = get_field('departure_date', false, false);
$departure_date = new DateTime($departure_date);
$cruise_line = get_field('cruise_line');
$ship = get_field('ship');

if(get_field('ship'))
{
    echo 'Departs' . $departure_date->format('j M Y') . get_field('cruise_line') . ' | ' . get_field('ship');

}

date_create_from_format is breaking on my server and I DON'T KNOW WHY!

$
0
0

I recently uploaded my client's site onto a temporary server so that they could get started on data input while I fine tune the design.

When I launched it however, one of my sliders and one of my pages broke down completely [note: this only occurs on the server side; my localhost site continues to work perfectly].

I narrowed it down to my use of the date_create_from_format() function as I use it on both pages, and when I remove the element holding that bit of php, the site works fine. I have scoured my file for any missing semi-colons, or brackets, and I can't find any glaring errors. Here is my code as it was orginally on my localhost.

<?php
  $end = date_create_from_format('Ymd',$ending_date);
  $start = date_create_from_format('Ymd',$starting_date);
  echo "<span class='month'>" . $start->format('F') . "</span>";
  echo " ";
  echo "<span class='day'>" . $start->format('j') . "</span>";
  echo ", ";
  echo "<span class='year'>" . $start->format('Y') . "</span>";

  echo " - ";

  echo "<span class='month'>" . $end->format('F') . "</span>";
  echo " ";
  echo "<span class='day'>" . $end->format('d') . "</span>";
  echo ", ";
  echo "<span class='year'>" . $end->format('Y') . "</span>";
  echo ", $location";
 ?>

I have also tried converting it from the object to the procedural function (See below) but the result is the exact same.

 

<?php
  $end = DateTime::createFromFormat('Ymd', $ending_date);
  $start = DateTime::createFromFormat('Ymd', $starting_date);
 ?>
 <?php
  echo "<span class='month'>" . date_format($start,'F') . "</span>";
  echo " ";
  echo "<span class='day'>" . date_format($start,'j') . "</span>";
  echo ", ";
  echo "<span class='year'>" . date_format($start,'Y') . "</span>";

  echo " - ";

  echo "<span class='month'>" . date_format($end,'F') . "</span>";
  echo " ";
  echo "<span class='day'>" . date_format($end,'d') . "</span>";
  echo ", ";
  echo "<span class='year'>" . date_format($end,'Y') . "</span>";
  echo ", $location";
 ?>

Someone on stackoverflow pointed out that there might be an issue regarding timezone being unidentified, so i made the following modification but the problem persisted.

 <?php
  $end = DateTime::createFromFormat('Ymd', $ending_date, new DateTimeZone('America/Toronto'));
  $start = DateTime::createFromFormat('Ymd', $starting_date, new DateTimeZone('America/Toronto'));
 ?>

Really at a loss here and the deadline is looming. Anyone have any ideas?

Need example of inserting form data into a Mysql db

$
0
0

I have a form with a table with columns and many rows.  The form uses Post and submits to an insert.php  I am looking for an example of how I can insert the table info into a mysql table.  I know I should use a while loop but unsure how to step through the form info.

 

Can someone suggest or provide and example that I can follow, or a tutorial somewhere?

 

Thanks

PHP Code Fix - Help !

$
0
0
Hi Experts...
 
I enabled google recaptcha for my email form, as i was getting tons of bot blank emailform.
Now captcha work fine, but i am unable to get filled value in my email - back from the form.
 
PS: This is a  new script i collected from 2-3 sources and did some editing
      (I am a graphics guy, so maybe missed any point)
 
Tried to debug many times, but no luck. Help much appreciated. Thanks in advance.
 
 
 
<?php
if(isset($_POST['submit'])):
    if(isset($_POST['g-recaptcha-response']) && !empty($_POST['g-recaptcha-response'])):
//your site secret key
        $secret = 'mygooglescretkey';
//get verify response data
        $responseData = json_decode($verifyResponse);
 
$name = !empty($_POST['name'])?$_POST['name']:'';
$email = !empty($_POST['email'])?$_POST['email']:'';
$message = !empty($_POST['message'])?$_POST['message']:'';
        
if($responseData->success):
//contact form submission code
$to = "info@mydomain,com, mysecondaryemail@gmail.com";
$subject = 'Naming Form via Website';
$email_from = 'info@mydomain,com';
 
 //!-- >mail($mailto,$subject,$message_body,"From:".$from);
 
$htmlContent = "
<h1>Contact request details</h1>
<p><b>Name: </b>".$name."</p>
<p><b>Email: </b>".$email."</p>
<p><b>Message: </b>".$message."</p>
";
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= 'From:'.$name.' <'.$email.'>' . "\r\n";
 
//send email
        mail($to,$subject,$html_Content,$headers,"From:".$email_from);
       
            $succMsg = 'Your contact request have submitted successfully.';
$name = '';
$email = '';
$message = '';
$to = '';
$from = '';
$headers = '';
        else:
            $errMsg = 'Robot verification failed, please try again.';
        endif;
    else:
        $errMsg = 'Please click on the reCAPTCHA box.';
    endif;
else:
    $errMsg = '';
    $succMsg = '';
$name = '';
$email = '';
$message = '';
$to = '';
$from = '';
$headers = '';
endif;
?>
 
 
 
<html>
    <head>
      <title>Using new Google reCAPTCHA with PHP by CodexWorld</title>
       <script src="https://www.google.com/recaptcha/api.js" async defer></script>
       <link href="css/style.css" rel='stylesheet' type='text/css' />
    </head>
    <body>
    <div class="registration">
<h2>Contact Form</h2>
<div class="avtar"><img src="images/color.jpg" /></div>
        <?php if(!empty($errMsg)): ?><div class="errMsg"><?php echo $errMsg; ?></div><?php endif; ?>
        <?php if(!empty($succMsg)): ?><div class="succMsg"><?php echo $succMsg; ?></div><?php endif; ?>
<div class="form-info">
<form action="" method="POST">
<input type="text" class="text" value="<?php echo !empty($name)?$name:''; ?>" placeholder="Your full name" name="name" >
                <input type="text" class="text" value="<?php echo !empty($email)?$email:''; ?>" placeholder="Email adress" name="email" >
                <textarea type="text" placeholder="Message..." required="" name="message"><?php echo !empty($message)?$message:''; ?></textarea>
<div class="g-recaptcha" data-sitekey="mygooglescretcode"></div>
<input type="submit" name="submit" value="SUBMIT">
</form>
</div>
<div class="clear"> </div>
</div>
  </body>
</html>

How to remove comma from last row in mysql query in php

$
0
0

I made a mysql query in php as given below

$Q = "SELECT length, width FROM statxyx WHERE siteid='$siteid'";
          $R = mysqli_query($DB,$Q);
          //start loop
          //while or foreach
          while($row = mysqli_fetch_assoc($R)){
            echo "['7C6Buh',{$row['length']},{$row['width']}],\r\n";
          }

The output is like

 

['7C6Buh',37.4192,-122.0574],
['7C6Buh',34.147,-118.1392],
['7C6Buh',23.7231,90.4086],
['7C6Buh',39.9543,-75.1657],
['7C6Buh',32.7787,-96.8217],
['7C6Buh',37.4192,-122.0574],
 
 
But i want to have last row without comma. How to do this. Thanks in advance.

zend_mm_heap corrupted-Allowed memory size exhausted

$
0
0

If I start this client when the server isn't started, I get the following error.  If I get rid of the addPeriodicTimer, it doesn't appear to happen.  What is going on?  Thanks

 

EDIT.  A clue!  The following makes the error go away, and exit('addPeriodicTimer'); is executed.  Still would like to know what is going on.

// $socket = new TimeoutConnector(new TcpConnector($this->loop), 10, $this->loop);
$socket = new TcpConnector($this->loop);
<?php


namespace DataLogger;


use React\EventLoop\Factory;
use React\SocketClient\TcpConnector;
use React\SocketClient\TimeoutConnector;


class Client
{
    private $loop,$connection;


    public function start() {
        $this->loop = Factory::create();
        $this->connect();
        $this->loop->addPeriodicTimer(5, function(){
            exit('addPeriodicTimer');
        });
        $this->loop->run();
    }


    private function connect(){
        echo('.');
        $socket = new TimeoutConnector(new TcpConnector($this->loop), 10, $this->loop);
        $socket->create('127.0.0.1', 1337)->then(function($stream){
            echo('create connection');
        })->otherwise(function($reason){
            $this->connect();
        });
    }
}


require '../vendor/autoload.php';
require 'JSONStream.php';
$client=new Client();
$client->start();
[Michael@devserver kicken_original]$ php client2.php
...... etc, etc, etc, ..............
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 83 bytes) in /var/www/react/vendor/react/promise/src/Promise.php on line 102
zend_mm_heap corrupted
[Michael@devserver kicken_original]$

Send mail Raspberry Pi (sSMTP)

$
0
0

Hi,

 

I'm trying to send a mail from a Webpage (PHP), running on a Raspberry Pi (Apache2, PHP5).

The Raspberry Pi is behind a Router from my ISP (Telenet) and they block the SMTP-port(25).

But I successfully installed sSMTP with all needed configuration, and I'm able to send emails through the mailhub of my ISP (what off course is what they rather like).

sudo nano /etc/ssmtp/ssmtp.conf

Contains:

root=pieterjan@pieterjan.pro
mailhub=smtp.telenet.be:587
rewriteDomain=pieterjan.pro
hostname=pieterjan.pro
UseTLS=YES
UseSTARTTLS=Yes
AuthUser=my_account@telenet.be
AuthPass=my_password
AuthMethod=LOGIN
FromLineOverride=YES

And my Reverse-aliases-file:

sudo nano /etc/ssmtp/revaliases

Contains:

root:my_account@telenet.be:smtp.telenet.be:587
pi:my_account@telenet.be:smtp.telenet.be:587

With this configuration I'm able to send an e-mail using this bash-command:

echo "Email body" | mail -s "Test Subject" some-email@address.com

Next step:

I've tried to change the configuration of PHP5 to use the PHP mail() command:

sudo nano /etc/php5/apache2/php.ini

Contains:

[mail function]
; For Win32 only.
; http://php.net/smtp
;SMTP = localhost
; http://php.net/smtp-port
;smtp_port = 25

; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = pi@pieterjan.pro

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path = /usr/sbin/sendmail -t -i -f pi@pieterjan.pro

; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail().
;mail.force_extra_parameters =

; Add X-PHP-Originating-Script: that will include uid of the script followed by t$
mail.add_x_header = On

; The path to a log file that will log all mail() calls. Log entries include
; the full path of the script, line number, To address and headers.
;mail.log =
; Log mail to syslog (Event Log on Windows).
;mail.log = syslog

I've already tried about everything. I think sendmail should only be used in WAMP and therefore is not applicable. Some say sendmail is automatically linked to ssmtp. But I actually already tried loads of configurations:

sendmail_path = /usr/sbin/sendmail -t
sendmail_path = /usr/sbin/sendmail -t -i
sendmail_path = /usr/sbin/sendmail -t -i -f pi@pieterjan.pro
sendmail_path = /usr/sbin/ssmtp -t
sendmail_path = /usr/sbin/ssmtp -t -i

PHP-code:

<?php
    error_reporting(E_ALL|E_STRICT);
    ini_set('display_errors',1);

    $res = mail("pieterjandeclippel@msn.com", "Subject", "Hello!");

    echo '<hr>Result was: ' . ( $res === FALSE ? 'FALSE' : 'TRUE') . $res;
    echo '<hr>';
    phpinfo();
?>

This script is hosted here.

But nothing actually seems to work, and I'm getting this error:

cat /var/log/mail.log

Last error from the log-file:

Jan  8 20:53:38 pieterjan sSMTP[9209]: Creating SSL connection to host
Jan  8 20:53:38 pieterjan sSMTP[9209]: SSL connection using DHE_RSA_AES_128_CBC_SHA1
Jan  8 20:53:38 pieterjan sSMTP[9209]: 550 5.1.0 <www-data@pieterjan.pro> is not an alias of my_account@telenet.be

Extra information (entire procedure) : Website

What is the problem and how can I fix this?


WordPress Changing an Array Value in Parent Theme from Child Theme

$
0
0

Hello PHP freaks, I'm new to the forum but am here due to an problem I haven't been able to solve. I am working on something which I believe is a simple problem / solution. I'm still a beginner at PHP and love the language so far. I'm trying to override a value in my WordPress Theme so that it outputs an h3 instead of h5. If anyone would be able to walk me through a solution I'd be really grateful. I'm looking forward to learning from my mistakes on this one.

 

I would like the 'selector' line to read as 'selector' => '.et_pb_toggle.et_pb_toggle_item h3',

/* Source Code from Parent Theme Toggle Found on line 7170*/
et_pb_print_module_styles_css( 'et_pb_toggle', array(
  array(
    'type'         => 'font-size',
    'key'         => 'title_font_size',
    'selector'     => '.et_pb_toggle.et_pb_toggle_item h5',
  ),
  array(
    'type'         => 'font-style',
    'key'         => 'title_font_style',
    'selector'     => '.et_pb_toggle.et_pb_toggle_item.et_pb_toggle_open h5',
  ),
  array(
    'type'         => 'font-style',
    'key'         => 'inactive_title_font_style',
    'selector'     => '.et_pb_toggle.et_pb_toggle_item.et_pb_toggle_close h5',
  ),
  array(
    'type'         => 'font-size',
    'key'         => 'toggle_icon_size',
    'selector'     => '.et_pb_toggle.et_pb_toggle_item .et_pb_toggle_title:before',
  ),
  array(
    'type'         => 'padding',
    'key'         => 'custom_padding',
    'selector'     => '.et_pb_toggle.et_pb_toggle_item',
  ),
) );

Here is what I tried that didn't work and I have a few ideas but am not really sure how to execute them properly. As this code below gave a PHP error.

Fatal error: Call to undefined function et_pb_toggle() in /home/content/p3pnexwpnas05_data01/49/3127149/html/wp-content/themes/Holmes Child Theme/functions.php on line 17

//modifies array for toggle switching h5 => h3
function hms_module_modifier() {
 et_pb_toggle( array(
      'selector' 	=> '.et_pb_toggle.et_pb_toggle_item h3'
    )
  );
}
//Runs module modifier
 hms_module_modifier();

Pass value from one function to another

$
0
0

Hi,

 

Apologies if this is a basic question but either I've misunderstood or I'm being daft 

 

In one function I have:

function create_coupon() {
	$unique_coupon_code = $coupon_name.'-'.$date; #concatenate the two
	return $unique_coupon_code;
}

Then in my second function I try to get that variable ($unique_coupon_code) to use again:

function use_coupon() {
	echo $unique_coupon_code;
}

But it returns blank?

 

However, if I echo $unique_coupon_code; in the first function, it does show a value

 

What am I doing wrong?

Thanks

Need help with my php

$
0
0

Hey guys.

 

I have this php code and it tells me there a problem, but I can seem to figure out what the problem is. Hope you can help.

 

Here is the code - 

 

mysql_query("INSERT INTO `wp_dc_mv_configuration` (`id`, `palettes`, `administration`) VALUES
(1, 'a:2:{i:0;a:3:{s:4:\"name\";s:7:\"Default\";s:6:\"colors\";a:70:{i:0;s:3:\"FFF\";i:1;s:3:\"FCC\";i:2;s:3:\"FC9\";i:3;s:3:\"FF9\";i:4;s:3:\"FFC\";i:5;s:3:\"9F9\";i:6;s:3:\"9FF\";i:7;s:3:\"CFF\";i:8;s:3:\"CCF\";i:9;s:3:\"FCF\";i:10;s:3:\"CCC\";i:11;s:3:\"F66\";i:12;s:3:\"F96\";i:13;s:3:\"FF6\";i:14;s:3:\"FF3\";i:15;s:3:\"6F9\";i:16;s:3:\"3FF\";i:17;s:3:\"6FF\";i:18;s:3:\"99F\";i:19;s:3:\"F9F\";i:20;s:3:\"BBB\";i:21;s:3:\"F00\";i:22;s:3:\"F90\";i:23;s:3:\"FC6\";i:24;s:3:\"FF0\";i:25;s:3:\"3F3\";i:26;s:3:\"6CC\";i:27;s:3:\"3CF\";i:28;s:3:\"66C\";i:29;s:3:\"C6C\";i:30;s:3:\"999\";i:31;s:3:\"C00\";i:32;s:3:\"F60\";i:33;s:3:\"FC3\";i:34;s:3:\"FC0\";i:35;s:3:\"3C0\";i:36;s:3:\"0CC\";i:37;s:3:\"36F\";i:38;s:3:\"63F\";i:39;s:3:\"C3C\";i:40;s:3:\"666\";i:41;s:3:\"900\";i:42;s:3:\"C60\";i:43;s:3:\"C93\";i:44;s:3:\"990\";i:45;s:3:\"090\";i:46;s:3:\"399\";i:47;s:3:\"33F\";i:48;s:3:\"60C\";i:49;s:3:\"939\";i:50;s:3:\"333\";i:51;s:3:\"600\";i:52;s:3:\"930\";i:53;s:3:\"963\";i:54;s:3:\"660\";i:55;s:3:\"060\";i:56;s:3:\"366\";i:57;s:3:\"009\";i:58;s:3:\"339\";i:59;s:3:\"636\";i:60;s:3:\"000\";i:61;s:3:\"300\";i:62;s:3:\"630\";i:63;s:3:\"633\";i:64;s:3:\"330\";i:65;s:3:\"030\";i:66;s:3:\"033\";i:67;s:3:\"006\";i:68;s:3:\"309\";i:69;s:3:\"303\";}s:7:\"default\";s:3:\"F00\";}i:1;a:3:{s:4:\"name\";s:9:\"Semaphore\";s:6:\"colors\";a:3:{i:0;s:3:\"F00\";i:1;s:3:\"FF3\";i:2;s:3:\"3C0\";}s:7:\"default\";s:3:\"3C0\";}}', 'a:15:{s:5:\"views\";a:4:{i:0;s:7:\"viewDay\";i:1;s:8:\"viewWeek\";i:2;s:9:\"viewMonth\";i:3;s:10:\"viewNMonth\";}s:11:\"viewdefault\";s:5:\"month\";s:8:\"language\";s:5:\"en-GB\";s:13:\"start_weekday\";s:1:\"0\";s:8:\"cssStyle\";s:9:\"cupertino\";s:12:\"paletteColor\";s:1:\"0\";s:6:\"btoday\";s:1:\"1\";s:11:\"bnavigation\";s:1:\"1\";s:8:\"brefresh\";s:1:\"1\";s:14:\"numberOfMonths\";s:2:\"12\";s:7:\"sample0\";N;s:7:\"sample1\";s:5:\"click\";s:7:\"sample2\";N;s:7:\"sample3\";s:0:"";s:7:\"sample4\";s:10:\"new_window\";}');");

[PHP] image upload script don't works

$
0
0

Hi

 

As title say i have problem with image uploading. I don't get any error but image don't wanna to upload. Folder have permision 755.

Here is a script :

error_reporting(E_ALL);
include 'header.php';

echo '<h2>Add image</h2>';

$target_dir = '../images/';

// Check if image file is a actual image or fake image
if(isset($_POST['submit']))
{

    if(!empty($_FILE['fileToUpload']))
    {
            $target_file = $target_dir . basename($_FILES['fileToUpload']['name']);
            $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
            $check = getimagesize($_FILES['fileToUpload']['tmp_name']);
            if($check !== false) {
                // Check if file already exists
                if (file_exists($target_file))
                {
                    $error = '<p class="fail">Sorry, file already exists.</p>';
                }
                else
                {
                        if (move_uploaded_file($_FILES['fileToUpload']['tmp_name'], $target_file)) {
                                $error = '<p class="success">The file '. basename( $_FILES['fileToUpload']['name']). ' has been uploaded.</p>';
                        }
                        else
                        {
                                $error = '<p class="fail">Sorry, there was an error uploading your file.</p>';
                        }
                }
            }
            else
            {
                $error = '<p class="fail">File is not an image.</p>';
            }
    }
    else
    {
        $error = '<p class="fail">Please select image.</p>';
    }
}

And form html :

<?php if(!empty($error)) { echo $error; } ?>
<form action="" method="post" enctype="multipart/form-data">
	<fieldset>
		<legend></legend>
    		<p>
                <label for="file">Filename : </label> 
    		<input type="file" name="fileToUpload" id="file">
                </p>
    		<p><input type="submit" name="submit" value="Save"></p>
    </fieldset>
</form>

Can not use isset to fix undefined index

$
0
0

I have a form to submit a email address and password. I get an undefined index error and if I try to use isset to fix the undefined index error I get the following error Cannot use isset() on the result of an expression (you can use "null !== expression" instead) in and I have tried to use the suggestions to solve the problem  but than another error pops up. 

 

Here is my php code . All help greatly appreciated. 

 

if (isset($_POST['submit']=="Sign Up")) {
  
if (!$_POST['email']) $error.="<br />Please enter your email";
else if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) $error.="<br />Please enter a valid email"; 
 
 
  if (!$_POST['password']) $error.="<br />Please enter your password";
 
and my html
 
<form class="marginTop" method="post"> 
 
  <div class="form-group">
 
  <label for="email">Email Address</label>
 
  <input type="email" name="email" class="form-control" placeholder="Your Email" value="<?php echo addslashes($_POST['email']); ?>" />
    
</div>
 
<div class="form-group">
 
  <label for="password">Password</label>
 
  <input type="password" name="password" class="form-control" placeholder="Password" value="<?php echo addslashes($_POST['password']); ?>" />
 
</div>
 
  <input type="submit" name="submit" value="Sign Up" class="btn btn-success btn-lg marginTop"/> 
 
  </form>

 

Viewing all 13200 articles
Browse latest View live