php-mailparse composer not loading on server

I have an Ubuntu php7.0 server and I am trying to use a php Mailparse script I found here

However I confirmed that composer is installed on the server and mailparse is also on the server. However the below script returns a 500 error and I tracked it down to the top two lines of code that is causing it and not sure how to resolve it.

So what I mean is when I comment out the two lines that say

   require_once __DIR__.'/vendor/autoload.php';
   $Parser = new PhpMimeMailParser\Parser();

Then the script will load but of course the mail parse wont work??

 //load the php mime parse library
   require_once __DIR__.'/vendor/autoload.php';

   $Parser = new PhpMimeMailParser\Parser();

//Include the AWS SDK using the Composer autoloader.
require 'awssdk/aws-autoloader.php';

use Aws\S3\S3Client;
use Aws\S3\Exception\S3Exception;
// AWS Info
$bucketName = 'pipedemail';
$IAM_KEY = '******';
$IAM_SECRET = '******';
// Connect to AWS
try {
    // You may need to change the region. It will say in the URL when the bucket is open
    // and on creation. us-east-2 is Ohio, us-east-1 is North Virgina
    $s3 = S3Client::factory(
        array(
            'credentials' => array(
                'key' => $IAM_KEY,
                'secret' => $IAM_SECRET
            ),
            'version' => 'latest',
            'region'  => 'us-east-1'
        )
    );
} catch (Exception $e) {
    // We use a die, so if this fails. It stops here. Typically this is a REST call so this would
    // return a json object.
    die("Error: " . $e->getMessage());
}

// Use the high-level iterators (returns ALL of your objects).
$objects = $s3->getIterator('ListObjects', array('Bucket' => $bucketName));

foreach ($objects as $object) 
{
    $objectkey = $object['Key'];
    $path = "https://s3.amazonaws.com/pipedemail/$objectkey";

    //lets get the raw email file to parse it
    $Parser->setText(file_get_contents($path));

    // Once we've indicated where to find the mail, we can parse out the data
    $to = $Parser->getHeader('to');             // "test" <test@example.com>, "test2" <test2@example.com>
    $addressesTo = $Parser->getAddresses('to'); //Return an array : [[test, test@example.com, false],[test2, test2@example.com, false]]

    $from = $Parser->getHeader('from');             // "test" <test@example.com>
    $addressesFrom = $Parser->getAddresses('from'); //Return an array : test, test@example.com, false

    $subject = $Parser->getHeader('subject');

}

Advertisements

PHP Fatal error: Call to a member function fetch_assoc() on boolean [duplicate]

if(isset($_POST['checkLogin'])) {

    $Email = $_POST['email'];
    $Password = hash('sha256', $_POST['password']);
    $Status = 0;

    $stmt = $con->prepare("SELECT * FROM users WHERE Email = ? AND Password = ? LIMIT 1");
    if(!$stmt->bind_param('ss', $Email, $Password)) {
        echo 3;
    }
    $stmt->execute();
    $result = $stmt->store_result();
    if($stmt->num_rows > 0) {
        while ($myrow = $result->fetch_assoc()) {
            if ($myrow['Status'] == '0') {
                echo 0;
            } else if($myrow['Status'] == '1') {
                echo 4;
            } else if($myrow['Status'] == '2') {
                $_SESSION["user_firstname"] = $myrow['FirstName'];
                $_SESSION["user_lastname"] = $myrow['LastName'];
                $_SESSION["user_email"] = $Email;
                $_SESSION["user_birth_day"] = $myrow['DateOf_Birth'];
                $_SESSION["user_gender"] = $myrow['Gender'];
                $_SESSION["user_city"] = $myrow['City'];
                $_SESSION["user_country"] = $myrow['Country'];
                $_SESSION["user_status"] = $myrow['Status'];
                $_SESSION["user_loged"] = 'true';
                echo 1;
            } else {
                echo 3;
            }
        }
    }
    else {
        echo 2;
    }

}

This is my main code and the problem is that I get this error : PHP Fatal error: Call to a member function fetch_assoc() on boolean I tried almost everything. Including checking if database tables and colums matches code tables and colums. The number of rows is bigger than 0, because if not it would echo 2 to me. Also to mention I use PHP 5.6. I can’t find any solution. Am I wrong somewhere?

Code Igniter does not recognize my base-url when I call a controller

My app recognizes main page index.php (that calls a controller which name is Home and shows this Home page, as expected).

Although when I call a topic in the menu (which is also a controller), it fails with this error:

HTTP Error 404.0 – Not Found

http://alfa.teste:80/estrutura where

http://alfa.teste/ is the base url and ‘estrutura’ is the controller.

Please, any help? Thank you so much!

Laravel Query for 2 tables Join

When i run any php command it gives me this error

PHP Warning: PHP Startup: Unable to load dynamic library ‘mysqli’
(tried: /usr/lib/php/20170718/mysqli (/usr/lib/php/20170718/mysqli:
cannot open shared object file: No such file or directory),
/usr/lib/php/20170718/mysqli.so (/usr/lib/php/20170718/mysqli.so:
undefined symbol: mysqlnd_global_stats)) in Unknown on line 0

Ubuntu 16 os
PHP 7.0 showing in phpinfo
php 7.2 showing in terminal php-v

Time Based IP Block with MySQL PHP

I am using ajax to store votes and currently trying to give every IP Adresse that has already voted a Block for 18 hours.

First I’m storing the IP and Time in the database but I can’t seem to figure out how I check if the IP is found in my array and then if the time associated to the Ip is the matching with 18hours plus.

I am using a multidimensional array for each row in my database.
This is what I have so far, but I am always getting either a 500 or unexpected end of JSON error.

 $currentip = $_SERVER['REMOTE_ADDR'];
    $time  = date('Y-m-d H:i:s');
    $exptime = date('Y-m-d H:i:s', strtotime('+18 Hours'));

    // Check IP
    $sqlip = "SELECT ip,exptime FROM `user_ip` ;";
    $storedip = array();
     if ($result = $this->databaseConnection->query($sqlip)){
         while($row = $result->fetch_assoc()) {
             $storedip = array($row['ip'], $row['exptime']);
            }       

      if(in_array($currentip, array_column($storedip, '0'))){
      $key = array_search($currentip, array_column($storedip, 0));

        if($time <= $storedip[$key][1]){
            echo json_encode("IP Block active", JSON_PRETTY_PRINT);
         }
      } 
      else{

         $setip = "INSERT INTO `user_ip` VALUES ('$currentip','$exptime');";
          if($this->executeDatabaseQuery($setip)){
        // Count Vote and do my stuff
          }
         }
     }

Typeahead.js — refresh data

I have managed to get this code to work for an application — http://twitter.github.io/typeahead.js/ but, the problem I have run into, is that I need to be able to re-load the data. I would rather not duplicate the code to do this, although it’s an option, it seems kind of silly. I have inserted some PHP into my JavaScript to create an array for the dropdown list, and it works great. But if I stuff it into a function, and then try to call the function in the document open, it doesn’t work (nothing appears to happen).

$(document).ready(function()
  {

     // call function when page loads(?)
     getAwards();

  }); // end document.ready ...

This is the PHP code, if I comment out the JavaScript function parts it runs and the typeahead code sees the value of the array. If I put it into the function, it doesn’t execute despite being called above, and I have no data for the typeahead code …

     function getAwards(
     {
        // build array for use with typeahead:
        <?php
           $sql_statement = "select title from awards order by title desc limit 1";
           $aw_result = mysqli_query( $connect, $sql_statement );
           $aw_row = mysqli_fetch_array( $aw_result );
           $last_award = $aw_row["title"];

           // need to rewind table:
           mysqli_data_seek( $aw_result, 0);

           // start from the top:
           $sql_statement = "select title from awards order by title";
           $aw_result = mysqli_query( $connect, $sql_statement );
           $count = 0;
           $out = 'awards = [';
           while ( $aw_row = mysqli_fetch_array( $aw_result ) )
           {
              // the quotes deal with forcing this to handle
              // branch names with apostrophes in them ...
              $count++;
              $out .= '"'. $aw_row["title"] . '"';
              if( $aw_row["title"] != $last_award )
              {
                 $out .= ',';
              }
           }
           $out .= ']';
           echo $out . "\n";
        ?>
     })

I need to be able to update the data, and reload the list while working on the form (I am working that out in my fuzzy brain, but anyway I’ll get to that — currently intend to click a button to update the list used by the typeahead, which is why I want a function …)

Any suggestions are gratefully accepted. I am at a loss …

rewrite javascript and php code in a different order to execute differently

var settings = TurnstileSettings();

var ts  = new TurnstilePod_v2();   
var d   = ts.registerDiv('ride-tickets-choices',new Date(<?php echo $year; ?>,<?php echo $month; ?>,<?php echo $day; ?>)<?php echo $additional_data; ?>);

d.suppress.calendar         = true;
d.suppress.directions       = true;
d.notifications.tripConfirm = 'Are you sure you would like to purchase tickets for |departureDate| with a |tripName|?';

d.setTripIds( [<?php echo $trip_ids; ?>] );
ts.initialize();

I’m trying to get my code to execute and run like

var ts = new TurnstilePod_v2(); 
var d = ts.registerDiv('ride-tickets-choices',new Date(2018,4,5), [591,593]);

d.suppress.calendar = true;
d.suppress.directions = true;
d.notifications.tripConfirm = 'Are you sure you would like to purchase tickets for |departureDate| with a |tripName|?';

rather than this

var settings = TurnstileSettings();

var ts  = new TurnstilePod_v2();   
var d   = ts.registerDiv('ride-tickets-choices',new Date(<?php echo $year; ?>,<?php echo $month; ?>,<?php echo $day; ?>)<?php echo $additional_data; ?>);

d.suppress.calendar         = true;
d.suppress.directions       = true;
d.notifications.tripConfirm = 'Are you sure you would like to purchase tickets for |departureDate| with a |tripName|?';

d.setTripIds( [<?php echo $trip_ids; ?>] );
ts.initialize();

What do I need to do in order for this to work? Any help is appreciated