#StackBounty: #php #wordpress #file-upload WordPress frontend submit form doesn't save tags and selected categories

Bounty: 150

I have one week working with a new WordPress tube theme and I have created frontend submit form for the users with some limitation options in redux framework.This is first time working with file uploader for me.

<?php
if( !defined('ABSPATH') ) exit;
if( !class_exists('mytheme_ShortcodeSubmitVideo') ){
    class mytheme_ShortcodeSubmitVideo {
        function __construct() {
            add_action('init', array($this,'add_shortcodes'));
            add_action('wp_ajax_awpt_submit_video', array($this,'action_form'));
            add_action('wp_ajax_nopriv_awpt_submit_video', array($this,'action_form'));
        }
        function add_shortcodes(){
            add_shortcode('upload', array($this,'videotube_upload'));
        }
        function videotube_upload( $attr, $content = null){
            global $redux;
            global $post;
            $html = null;
            extract(shortcode_atts(array(
                'vcategory' =>  'on',
                'vtag'      =>  'on',
                'cat_exclude'   =>  '',
                'cat_include'   =>  '',
                'cat_orderby'       =>  'name',
                'cat_order' =>  'DESC'
            ), $attr));
            $video_type = isset( $redux['video-type'] ) ? $redux['video-type'] : null;
            if( !is_array( $video_type ) ){
                $video_type = (array)$video_type;
            }
            $submit_roles = isset( $redux['submit_roles'] ) ? (array)$redux['submit_roles'] : 'author';
            if( count( $submit_roles ) == 1 ){
                $submit_roles = (array)$submit_roles;
            }
            //print_r($submit_roles);
            ### 0 is not allow guest, 1 is only register.
            $submit_permission = isset( $redux['submit_permission'] ) ? $redux['submit_permission'] : 0;
            $user_id = get_current_user_id();
            $current_user_role = awpt_get_user_role( $user_id );
            ### Check if Admin does not allow Visitor submit the video.
            if( $submit_permission == 0 && !$user_id ){
                $html .= '<a class="formLink" _form="login" href="/login" id="show_login"><i class="icon"><i class="fa fa-sign-in" aria-hidden="true"></i></i> <span>Login</span></a>';

                //$html .= '[login]';
            }
            //elseif( $submit_permission == 0 && !in_array( $current_user_role, $submit_roles) && $current_user_role != 'administrator'){
            elseif( $submit_permission == 0 && !in_array( $current_user_role, $submit_roles)){
                $html .= '
                    
'.__('You don't have the right permission to access this feature.','mytheme').'
'; } else{ $categories_html = null; $category_array = array( 'hide_empty'=>0, 'order' => $cat_order, 'orderby' => $cat_orderby, ); if( !empty( $cat_exclude ) ){ $cat_exclude = explode(",", $cat_exclude); if( is_array( $cat_exclude ) ){ $category_array['exclude'] = $cat_exclude; } } if( !empty( $cat_include ) ){ $cat_include = explode(",", $cat_include); if( is_array( $cat_include ) ){ $category_array['include'] = $cat_include; } } $categories = get_terms('category', $category_array); if ( !empty( $categories ) && !is_wp_error( $categories ) ){ $categories_html .= '<select id="pre-selected-options" multiple="multiple">'; foreach ( $categories as $category ){ $categories_html .= '<option value="'.$category->term_id.'">'.$category->name.'</option>'; } $categories_html .= '</select>'; } $html .= '
'.__('*','mytheme').'
'; if( $redux['submit_editor'] == 1 ){ $html .= awpt_get_editor('', 'post_content', 'post_content'); } else{ $html .= '
'; } $html .= '<span class="help-block"></span>'; $html .= '</div>
'.__('*','mytheme').''; if( in_array( 'videolink', $video_type ) ){ $html .= '
'.__('Link','mytheme').'
'; } if( in_array( 'embedcode', $video_type ) ){ $html .= '
'.__('Embed Code','mytheme').'
'; } if( in_array( 'videofile', $video_type ) ){ $html .= '
'.__('Upload file','mytheme').'
'; } $html .= ' </div>'; if( in_array( 'videolink', $video_type ) ){ $html .= ' '; } if( in_array( 'embedcode', $video_type ) ){ $html .= '
'.__('*','mytheme').'
'; } if( in_array( 'videofile', $video_type ) ){ $html .= '
'.__('*','mytheme').'
'; } $html .= '
'.__('This image is required if you submit an embed code or a video file.','mytheme').'
'; if( $vtag == 'on' ): $html .= '
'; endif; if( $vcategory == 'on' ): $html .= '
'; $html .= $categories_html; $html .= '
'; endif; $html .= '
<img id="loading" style="display:none;"> <input type="hidden" name="current_page" value="'.$post->ID.'"> <input type="hidden" name="action" value="awpt_submit_video"> '.wp_nonce_field('submit_video_act','submit_video',true,false).' </form></div> '; } return do_shortcode( $html ); } function action_form(){ global $redux; $videosize = isset( $redux['videosize'] ) ? (int)$redux['videosize'] : 10; $post_title = wp_filter_nohtml_kses( $_POST['post_title'] ); $video_url = isset( $_POST['video_url'] ) ? trim( $_POST['video_url'] ) : null; $embed_code = isset( $_POST['embed_code'] ) ? trim( $_POST['embed_code'] ) : null; $video_file = isset( $_FILES['video_file'] ) ? $_FILES['video_file'] : null; $post_content = wp_filter_nohtml_kses( $_POST['video_description'] ); //$post_content = isset( $_POST['awpt_desc'] ) ? trim( $_POST['awpt_desc'] ) : null; $chb_video_type = isset( $_POST['chb_video_type'] ) ? $_POST['chb_video_type'] : null; $video_thumbnail = isset( $_FILES['video_thumbnail'] ) ? $_FILES['video_thumbnail'] : null; $video_tag = isset( $_POST['video_tag'] ) ? wp_filter_nohtml_kses( $_POST['video_tag'] ) : null; $video_category = isset( $_POST['video_category'] ) ? $_POST['video_category'] : null; $user_id = get_current_user_id() ? get_current_user_id() : $redux['submit_assigned_user']; $post_status = $redux['submit_status'] ? $redux['submit_status'] : 'pending'; $layout = isset( $_POST['layout'] ) ? $_POST['layout'] : 'small'; if( !$post_title ){ echo json_encode(array( 'resp' => 'error', 'message' => __('Video Title is required','mytheme'), 'element_id' => 'post_title' ));exit; } /* if( !$post_content ){ echo json_encode(array( 'resp' => 'error', 'message' => __('Video Description is required','mytheme'), 'element_id' => 'post_content' ));exit; } */ if( !$chb_video_type ){ echo json_encode(array( 'resp' => 'error', 'message' => __('Video Type is required','mytheme'), 'element_id' => 'chb_video_type' ));exit; } switch ($chb_video_type) { case 'video_link_type': if( !$video_url ){ echo json_encode(array( 'resp' => 'error', 'message' => __('Video Link is required','mytheme'), 'element_id' => 'video_url' ));exit; } if( !wp_oembed_get( $video_url ) ){ echo json_encode(array( 'resp' => 'error', 'message' => __('The link does not support.','mytheme'), 'element_id' => 'video_url' ));exit; } break; case 'embed_code_type': if( !$embed_code ){ echo json_encode(array( 'resp' => 'error', 'message' => __('Embed Code is required','mytheme'), 'element_id' => 'embed_code' ));exit; } if( apply_filters( 'awpt_submitform_thumbnail_required' , true) === true ): if( !$video_thumbnail ){ echo json_encode(array( 'resp' => 'error', 'message' => __('Video Preview Image is required','mytheme'), 'element_id' => 'video_thumbnail' ));exit; } if( !awpt_check_file_allowed( $video_thumbnail, 'image' ) ){ echo json_encode(array( 'resp' => 'error', 'message' => __('Video Preview Image type is invalid','mytheme'), 'element_id' => 'video_thumbnail' ));exit; } endif; break; default: if( !$video_file ){ echo json_encode(array( 'resp' => 'error', 'message' => __('Video File is required.','mytheme'), 'element_id' => 'video_file' ));exit; } if( !awpt_check_file_allowed( $video_file, 'video' ) ){ echo json_encode(array( 'resp' => 'error', 'message' => __('Video File format is invalid.','mytheme'), 'element_id' => 'video_file' ));exit; } if( !awpt_check_file_size_allowed($video_file) ){ echo json_encode(array( 'resp' => 'error', 'message' => __('The video size must be less than ' . $videosize . 'MB','mytheme'), 'element_id' => 'video_file' ));exit; } if( apply_filters( 'awpt_submitform_thumbnail_required' , true) === true ): if( !$video_thumbnail ){ echo json_encode(array( 'resp' => 'error', 'message' => __('Video Preview Image is required','mytheme'), 'element_id' => 'video_thumbnail' ));exit; } if( !awpt_check_file_allowed( $video_thumbnail, 'image' ) ){ echo json_encode(array( 'resp' => 'error', 'message' => __('Video Preview Image type is invalid','mytheme'), 'element_id' => 'video_thumbnail' ));exit; } endif; break; } /** * Error handler * @since Videotube V2.2.7 */ $errors = new WP_Error(); $errors = apply_filters( 'do_ajax_submit_video_errors' , $errors, $_POST ); if ( ! empty( $errors->errors ) ) { echo json_encode(array( 'resp' => 'error', 'message' => $errors->get_error_message(), 'element_id' => $errors->get_error_code() ));exit; } $postarr = array( 'post_title' => $post_title, 'post_content' => $post_content, 'post_type' => 'post', 'post_author' => $user_id, 'post_status' => $post_status, 'comment_status' => 'open' ); $postarr = apply_filters( 'awpt_submit_data_args' , $postarr ); $post_id = wp_insert_post($postarr, true); if ( is_wp_error( $post_id ) ){ echo json_encode(array( 'resp' => 'error', 'message' => $post_id->get_error_message() ));exit; } ### update meta if( $layout ){ update_post_meta( $post_id , 'layout', $layout); } if( $video_url ){ update_post_meta( $post_id , 'video_url', $video_url); } elseif ( $embed_code){ update_post_meta( $post_id , 'video_url', $embed_code); } else{ ### Upload files. if( function_exists('awpt_insert_attachment') ){ awpt_insert_attachment('video_file', $post_id, false, 'video_file'); update_post_meta( $post_id , 'video_type', 'files'); } } ### Preview image if( $video_thumbnail ){ ### Upload files. if( function_exists('awpt_insert_attachment') ){ awpt_insert_attachment('video_thumbnail', $post_id, true); } } ### update term if( $video_tag ){ wp_set_post_terms($post_id, $video_tag,'tag',true); } if( $video_category ){ wp_set_post_terms($post_id, $video_category,'category',true); } do_action('awpt_save_post',$post_id); if( $post_status != 'publish' ){ $redirect_to = $redux['submit_redirect_to'] ? get_permalink( $redux['submit_redirect_to'] ) : NULL; if( empty( $redirect_to ) ){ echo json_encode(array( 'resp' => 'success', 'message' => __('Congratulation, Your submit is waiting for approval.','mytheme'), 'post_id' => $post_id, ));exit; } else{ echo json_encode(array( 'resp' => 'success', 'message' => __('Congratulation, Your submit is waiting for approval.','mytheme'), 'post_id' => $post_id, 'redirect_to' => $redirect_to ));exit; } } else{ echo json_encode(array( 'resp' => 'publish', 'message' => __('Congratulation, Your submit is published.','mytheme'), 'post_id' => $post_id, 'redirect_to' => get_permalink( $post_id ) ));exit; } } } new mytheme_ShortcodeSubmitVideo();

When I submit the button many things working fine.Its saving the video file to the post, so title and video is okay and everything works fine except video categories and tags.

I have only 2 issues.

  1. I need to get the video description as a custom field instead of saving in the post content.
  2. Video Categories and tags are not saving.


Get this bounty!!!

#StackBounty: #php #symfony #google-api #google-api-php-client #hwioauthbundle Refresh oauth2 token google api and HWIOAuthBundle

Bounty: 50

How i can refresh token ?
I use Google api with this token – it work but can’t find how to refresh it, in this example we dont save expired time.
I require

`access_type:     offline `

then

$client = new Google_Client();
        //$client->setClientId($GoogleClientId);
        $client->setApplicationName($GoogleAppName);
        $client->setClientId($this->user->getGoogleId());
        $client->setAccessType('offline');

if token is valid i can work but when is expired i try

$token = [
            'access_token' => $this->user->getGoogleAccessToken(),
            'expires_in'   => (new DateTime())->modify('-1 year')->getTimestamp(),
        ];

i put this any date because in this example we don’t save expired time

https://gist.github.com/danvbe/4476697

    $client->setAccessToken($token);

    if($client->isAccessTokenExpired()){

        $refreshedToken = $client->refreshToken($client->getAccessToken());

here i have error

array:2 [▼
  "error" => "invalid_request"
  "error_description" => "Could not determine client ID from request."
]

There is HwiAuthBundle method to refresh token ?
Why this not work with Google_Client refresh ?


Get this bounty!!!

#StackBounty: #php #laravel #redirect Hesto multi-auth guard is not redirecting where page was before after login

Bounty: 50

I am on page : http://laravel.dev/lists

which shows me list of item

<a href="http://laravel.dev/lists/1">Item 1</a>
<a href="http://laravel.dev/lists/2">Item 1</a>
<a href="http://laravel.dev/lists/3">Item 1</a>

but above item can only accessible to authorized user

Issue

when i click on Item 1 so if user is not logged in then it goes to http://laravel.dev/login then user proceed to login but after login it must redirect to http://laravel.dev/lists/1 but it is redirecting to http://laravel.dev/home.

I have tried

public function showLoginForm()
{
    session()->put('url.intended',url()->previous());

    // or 

    session()->put('url.intended', url()->current());

    return view('user.auth.login');
}

but above is not working, it is redirecting to http://laravel.dev/lists

laravel own auth is working fine.

but hesto multi-auth is not working

I am using this Hesto-multi-auth package for multiple authentication like admin, user, employee

is there any solution for this


Get this bounty!!!

#StackBounty: #php #png #imagick PHP Imagick makes PNG file with every-time changing specific binaries – from same image file

Bounty: 50

I have a PNG file problem.

When I convert an image using PHP Imagick library, I get different binary set each time although I tried with same image file several times.

When I compared those 2 files, it turns out it has only several bytes are just different, while rest of bytes are exactly same, and those bytes offsets are all time same, too.

I am really not sure how come those bytes could be all time different (seems like it stores timestamp or what else there?)

Here is the binary of PNG file with high-lighted binaries, and someone help me to figure out what the heck this binaries are:

enter image description here

I also attach the png file:

enter image description here

Thanks.


Get this bounty!!!

#StackBounty: #php #mysql #osx #mysqli #dump PHP Warning: "MySQL server has gone away" after MySQL dump in macOS Terminal

Bounty: 50

I am using a script to download remote MySQL databases (gzip) and extract them directly to my MacBook’s MySQL 5.7 (not MAMP) server.
It works fine, but as a side effect PHP (MAMP) loses the MySQL connection with the warning

PHP Warning:  mysqli::__construct(): MySQL server has gone away in ...

This happens after roundabout a dozen databases oder bigger files (can’t reproduce). The MySQL pane in System Preferences says running (green), but PHP obviously lost it.

I played around with my.cnf and set

[mysqld]
max_allowed_packet=128M

or even 800M, but it doesn’t seem to change anything.

When I manually stop and start MySQL in System Preferences, PHP continues to work normal again.

Any ideas?


Get this bounty!!!

#StackBounty: #php #mysql #loops #object Determining which objects are or are not linked to the main root object

Bounty: 50

I am trying to navigate through a bunch of objects with links to other objects. I want to start with the lowest id number (the root object) and navigate through each of the objects based on connected links. Some of the object links will loop back to previous objects, so I want to make sure I look at each one only once otherwise I will get stuck in an infinite loop. I also want to be able to tell which objects cannot be accessed by navigating through the links beginning at the first link.

The tables in my database look like this:

Object Table:

+----+---------+
| id | title   |
+----+---------+
|  1 | Apple   |
|  3 | Carrot  |
|  4 | Dill    |
|  5 | Egg     |
|  6 | Fred    |
|  7 | Goat    |
|  8 | Harry   |
|  9 | Igloo   |
| 10 | Jason   |
| 11 | Klaus   |
| 12 | Banana  |
| 15 | Oyster1 |
| 16 | Oyster2 |
+----+---------+

Object_Links Table:

+----+---------+--------------+
| id |  obj_id |  obj_link_id |
+----+---------+--------------+
|  1 |       1 |           12 |
|  2 |       1 |            5 |
|  3 |       3 |            1 |
|  4 |       3 |           12 |
|  5 |       3 |            3 |
|  6 |       4 |            1 |
|  7 |       4 |            5 |
|  8 |       5 |            6 |
|  9 |       6 |            7 |
| 10 |       7 |            7 |
| 11 |       7 |            8 |
| 12 |       9 |           12 |
| 13 |       9 |            5 |
| 14 |      10 |            1 |
| 15 |      10 |            5 |
| 16 |      10 |            8 |
| 17 |      11 |            1 |
| 18 |      11 |            5 |
| 19 |      11 |           10 |
| 20 |      12 |            3 |
| 21 |      15 |           16 |
| 22 |      16 |           15 |
+----+---------+--------------+

So, from the table you can see that object 1 has links to both objects 12 and 5.

My SQL query looks like this:

select  object.id, title, obj_link_id
    from  object
    left join  object_links  ON object.id = object_links.object_id
    order by  object.id 

which gives the table:

+----+---------+--------------+
| id | title   |  obj_link_id |
+----+---------+--------------+
|  1 | Apple   |           12 |
|  1 | Apple   |            5 |
|  3 | Carrot  |            1 |
|  3 | Carrot  |           12 |
|  3 | Carrot  |            3 |
|  4 | Dill    |            1 |
|  4 | Dill    |            5 |
|  5 | Egg     |            6 |
|  6 | Fred    |            7 |
|  7 | Goat    |            7 |
|  7 | Goat    |            8 |
|  8 | Harry   |         NULL |
|  9 | Igloo   |           12 |
|  9 | Igloo   |            5 |
| 10 | Jason   |            1 |
| 10 | Jason   |            5 |
| 10 | Jason   |            8 |
| 11 | Klaus   |            1 |
| 11 | Klaus   |            5 |
| 11 | Klaus   |           10 |
| 12 | Banana  |            3 |
| 15 | Oyster1 |           16 |
| 16 | Oyster2 |           15 |
+----+---------+--------------+

In PHP I am using:

$objects = $stmt->fetchAll(PDO::FETCH_CLASS);

I wasn’t sure whether there was a better way to fetch these for my purposes so am open to suggestions.

A print_r($objects) yields:

Array
(
    [0] => stdClass Object
        (
            [id] => 1
            [title] => Apple
            [obj_link_id] => 12
        )

    [1] => stdClass Object
        (
            [id] => 1
            [title] => Apple
            [obj_link_id] => 5
        )

    [2] => stdClass Object
        (
            [id] => 3
            [title] => Carrot
            [obj_link_id] => 1
        )

    [3] => stdClass Object
        (
            [id] => 3
            [title] => Carrot
            [obj_link_id] => 12
        )

    [4] => stdClass Object
        (
            [id] => 3
            [title] => Carrot
            [obj_link_id] => 3
        )

    [5] => stdClass Object
        (
            [id] => 4
            [title] => Dill
            [obj_link_id] => 1
        )

    [6] => stdClass Object
        (
            [id] => 4
            [title] => Dill
            [obj_link_id] => 5
        )

    [7] => stdClass Object
        (
            [id] => 5
            [title] => Egg
            [obj_link_id] => 6
        )

    [8] => stdClass Object
        (
            [id] => 6
            [title] => Fred
            [obj_link_id] => 7
        )

    [9] => stdClass Object
        (
            [id] => 7
            [title] => Goat
            [obj_link_id] => 7
        )

    [10] => stdClass Object
        (
            [id] => 7
            [title] => Goat
            [obj_link_id] => 8
        )

    [11] => stdClass Object
        (
            [id] => 8
            [title] => Harry
            [obj_link_id] =>
        )

    [12] => stdClass Object
        (
            [id] => 9
            [title] => Igloo
            [obj_link_id] => 12
        )

    [13] => stdClass Object
        (
            [id] => 9
            [title] => Igloo
            [obj_link_id] => 5
        )

    [14] => stdClass Object
        (
            [id] => 10
            [title] => Jason
            [obj_link_id] => 1
        )

    [15] => stdClass Object
        (
            [id] => 10
            [title] => Jason
            [obj_link_id] => 5
        )

    [16] => stdClass Object
        (
            [id] => 10
            [title] => Jason
            [obj_link_id] => 8
        )

    [17] => stdClass Object
        (
            [id] => 11
            [title] => Klaus
            [obj_link_id] => 1
        )

    [18] => stdClass Object
        (
            [id] => 11
            [title] => Klaus
            [obj_link_id] => 5
        )

    [19] => stdClass Object
        (
            [id] => 11
            [title] => Klaus
            [obj_link_id] => 10
        )

    [20] => stdClass Object
        (
            [id] => 12
            [title] => Banana
            [obj_link_id] => 3
        )

    [21] => stdClass Object
        (
            [id] => 15
            [title] => Oyster1
            [obj_link_id] => 16
        )

    [22] => stdClass Object
        (
            [id] => 16
            [title] => Oyster2
            [obj_link_id] => 15
        )

)

Please note, that the number in the brackets is just the array index, not the object id number, so don’t let the index throw you off.

I am trying to find a way to determine which are the linked and which are the unlinked objects. Based on the above scenario the objects should be separated as follows:

**Linked:**

    Apple
    Banana
    Carrot
    Egg
    Fred
    Goat
    Harry

**Not Linked:**

    Dill
    Igloo
    Jason
    Klaus
    Oyster1
    Oyster2

My main question:

How can I create a loop in PHP to loop through a structure like this especially when each object can have multiple links? Ultimately I would like to produce two collections of objects, one containing the linked objects and one containing the unlinked objects. A sample collection might look like this:

stdClass Object
(
  [LinkedElements] => stdClass Object
    (
      [1] => stdClass Object
        (
          [id] => 1
          [name] => Apple
          [link] => Array
            (
              [0] => 14
              [1] => 5
            )

        )

      [14] => stdClass Object
        (
          [id] => 14
          [name] => Banana
          [link] => Array
            (
              [0] => 3
            )

        )

      [3] => stdClass Object
        (
          [id] => 3
          [name] => Carrot
          [link] => Array
            (
              [0] => 1
              [1] => 14
              [2] => 3
            )

        )

      [5] => stdClass Object
        (
          [id] => 5
          [name] => Egg
          [link] => Array
            (
              [0] => 6
            )

        )

      [6] => stdClass Object
        (
          [id] => 6
          [name] => Fred
          [link] => Array
            (
              [0] => 7
            )

        )

      [7] => stdClass Object
        (
          [id] => 7
          [name] => Goat
          [link] => Array
            (
              [0] => 7
              [1] => 8
            )

        )

      [8] => stdClass Object
        (
          [id] => 8
          [name] => Harry
        )

    )

  [UnLinkedElements] => stdClass Object
    (
      [4] => stdClass Object
        (
          [id] => 4
          [name] => Dill
          [link] => Array
            (
              [0] => 1
              [1] => 5
            )

        )

      [9] => stdClass Object
        (
          [id] => 9
          [name] => Igloo
          [link] => Array
            (
              [0] => 14
              [1] => 5
            )

        )

      [10] => stdClass Object
        (
          [id] => 10
          [name] => Jason
          [link] => Array
            (
              [0] => 1
              [1] => 5
              [2] => 8
            )

        )

      [11] => stdClass Object
        (
          [id] => 11
          [name] => Klaus
          [link] => Array
            (
              [0] => 1
              [1] => 5
              [2] => 10
            )

        )

      [15] => stdClass Object
        (
          [id] => 15
          [name] => Oyster1
          [link] => Array
            (
              [0] => 16
            )

        )

      [16] => stdClass Object
        (
          [id] => 16
          [name] => Oyster2
          [link] => Array
            (
              [0] => 15
            )

        )

    )

)

Please note:

  • Navigation is done from object to link, not the other way around.
  • It is okay to have an object point to itself (as object 7 does).
  • The above sample structure (underneath my main question) is a suggestion only and I am open to other suggestions.
  • Disclaimer: This question is based on another question I previously asked.
    In my original question I manually created the test objects, but I was not able to pull them out of my database in this fashion.


Get this bounty!!!

#StackBounty: #magento-1.9 #php #api #sales-order Magento 1.9 API Performance – Retrieving All Sales Order Info

Bounty: 50

I’m creating a page that shows order sales data such as sales revenue, total quantity of orders and also best sellers which consist of products from all sales orders.

The problem is that this takes 20 minutes to run for a database with only 1200 orders. I’m certain this is because an API call needs to be made for each order separately to retrieve the item information:

$orderDetails[] = array($client->salesOrderInfo($sessionId, $orderNumbers[$d]));

Here’s an example of my code:

    // API Connection.
    $client = new SoapClient('htps://www.mysite.com/api/v2_soap/?wsdl');
    $sessionId = $client->login('API Username', 'API Password');

    // Filter orders for this year only.
    $filter = array('complex_filter' => array(
           array('key' => 'created_at', 'value' => array('key' => 'gt', 'value' => $currentYear . '2017-01-01 00:00:00'))
       )
    );

    // Call the API and retrieve the orders.
    $orders = $client->salesOrderList($sessionId, $filter);

    // Loop through orders and store order numbers against the $orderNumbers array.
    $orderNumbers = array();
    for ($i = 0; $i < count($orders); $i++) {
        $orderNumbers[] = $orders[$i]->increment_id;
    }

   // Loop through order numbers and store the order details against the $orderDetails array (this seems to be the problem area).
   $orderDetails = array();
   for ($d = 0; $d < count($orderNumbers); $d++) {
      $orderDetails[] = array($client->salesOrderInfo($sessionId, $orderNumbers[$d]));
   }

Is there a way of improving my script so that it performs much better? I cannot find a way of retrieving sales order info for more than one order at a time.

Thanks so much for any help.


Get this bounty!!!

#StackBounty: #php #mongodb #osx #laravel-5.3 dyld: lazy symbol binding failed: Symbol not found: _clock_gettime – in mongodb laravel

Bounty: 50

I am using Laravel 5.4 version to implement mongodb CRUD operation using link. I am using Mac OS El Captain 10.11. I have installed mongodb.so extension with php version 7.1.16

While i am trying getting eloquent connection it throws me ERR_EMPTY_RESPONSE

I have digg in details an found following error log in Apache during restart the MAMP server

 Mon Aug 28 10:22:14 2017] [notice] Graceful restart requested, doing restart
[Mon Aug 28 10:22:15 2017] [notice] Digest: generating secret for digest authentication ...
[Mon Aug 28 10:22:15 2017] [notice] Digest: done
[Mon Aug 28 10:22:15 2017] [notice] Apache/2.2.31 (Unix) mod_wsgi/3.5 
 Python/2.7.13 PHP/7.1.1 mod_ssl/2.2.31 OpenSSL/1.0.2j DAV/2 
mod_fastcgi/2.4.6 mod_perl/2.0.9 Perl/v5.24.0 configured -- resuming normal operations
[Mon Aug 28 10:22:15 2017] [notice] FastCGI: process manager initialized (pid 4233)
dyld: lazy symbol binding failed: Symbol not found: _clock_gettime
Referenced from: 
/Applications/MAMP/bin/php/php7.1.1/lib/php/extensions/no-debug-non-zts-20160303/mongodb.so
Expected in: /usr/lib/libSystem.B.dylib

dyld: Symbol not found: _clock_gettime
Referenced from: 
/Applications/MAMP/bin/php/php7.1.1/lib/php/extensions/no-debug-non-zts-20160303/mongodb.so
Expected in: /usr/lib/libSystem.B.dylib

dyld: lazy symbol binding failed: Symbol not found: _clock_gettime
Referenced from: 
 /Applications/MAMP/bin/php/php7.1.1/lib/php/extensions/no-debug-non-zts-20160303/mongodb.so
 Expected in: /usr/lib/libSystem.B.dylib

dyld: Symbol not found: _clock_gettime
Referenced from: 
/Applications/MAMP/bin/php/php7.1.1/lib/php/extensions/no-debug-non-zts-20160303/mongodb.so
 Expected in: /usr/lib/libSystem.B.dylib

This screenshot shows the details of mongodb extension
enter image description here
I have searched online for error dyld: lazy symbol binding failed: Symbol not found: _clock_gettime and found this answer. I have applied all steps which i mentioned, but unable to fix the issue.

Please someone help me to get rid of this.


Get this bounty!!!

#StackBounty: #php #php7 #source-packages #id3 Install id3_tag in PHP Ubuntu

Bounty: 50

How can I Install and configure id3_tag package installed from PECL? I already have the package but I don’t know how to configure it and where to put it in the file system.


Get this bounty!!!

#StackBounty: #php #pdf #github #drawing Drawing in pdf file

Bounty: 50

I want to drawing in pdf file. Example. open pdf file and such drawing tools like circle, square , text etc using this tools draw shape on the pdf file.

I was searched on google and find such option like pdf.js. but it’s not implement in core php or normal MVC structure. it’s implement in js.

Any Alternative for pdf.js. to draw the shape in pdf file.

I found same as below example link pls. show below link video.

http://tech.chitgoks.com/2016/03/06/annotationeer-my-web-application-that-can-create-annotations-in-pdf-js/

Any response will be appreciated.

Thank you


Get this bounty!!!