Plugin Directory

Changeset 2009447


Ignore:
Timestamp:
01/09/2019 08:56:54 PM (7 years ago)
Author:
Ralph Rezende
Message:

Update trunk corrected

File:
1 edited

Legend:

Unmodified
Added
Removed
  • company-presentation/trunk/careerpagesplugin.php

    r1978534 r2009447  
    99Description: With the Prodii WP-plugin, you can create a profile section on your wordpress homepage showcasing your professional accomplishments. On https://prodii.com  you build professional profiles (web pages) by collecting data about your work life. The Prodii plugin integrates information from your prodii account into your wordpress homepage.
    1010
    11 Version: 5.0.0
     11Version: 5.0.1
    1212Author: Prodii by Ralph Rezende Larsen
    1313Author URI: https://prodii.com/view/ralphrezendelarsen
     
    6464                    self::$templateini["ini"] = CareerpagesTemplate::getIni();
    6565                } else {
    66                     $cp_info = array(
     66                    $request = new WP_Http;
     67                    $httpUrl = 'https://'.(isset(self::$templateini["subdir"]) && self::$templateini["subdir"] ? self::$templateini["subdir"].'.' : '').'prodii.com/common/careerpages/php/careerpageshandler.php';
     68                    $httpResult = $request->request( $httpUrl, array(
     69                        'methoddd' => 'POST',
     70                        'body' =>   array(
     71                                        'action' => 'getIni',
     72                                        'key' => self::$templateini["key"],
     73                                        'template' => self::$templateini["template"]
     74                                    ),
     75                        'sslverify' => false
     76                    ));
     77
     78                    $httpResponse = null;
     79                    $httpErrors = null;
     80                    if(is_wp_error($httpResult)) {
     81                        $httpErrors = $httpResult->get_error_messages();
     82                    } else {
     83                        $httpResponse = json_decode($httpResult["body"], true);
     84                        self::$templateini["ini"] = $httpResponse;
     85                    }
     86
     87                    if(is_wp_error($httpResult)) {
     88                        foreach ($httpErrors as $error) {
     89                            self::$templateini["errors"][] = 'Get template initialisation error - '.$error;
     90                        }
     91                    } elseif (self::$templateini["ini"] == '') {
     92                        self::$templateini["errors"][] = 'No template initialisation returned';
     93                    } elseif (isset($httpResponse["error"])) {
     94                        //self::$templateini["errors"] = array_merge(self::$templateini["errors"], $httpResponse["error"]);
     95                        self::$templateini["errors"][] = $httpResponse["error"];
     96                    }
     97
     98                    /*$cp_info = array(
    6799                        'action' => 'getIni',
    68100                        'key' => self::$templateini["key"],
     
    81113                        self::$templateini["errors"][] = "No template initialisation returned from cURL";
    82114                    }
    83                     curl_close($ch);
     115                    curl_close($ch);*/
    84116                }
    85117            }
     
    87119            if (empty(self::$templateini["errors"])) {
    88120                //Get data(Template on local server) or html(Template on Prodii server)
    89                 $cp_data = array(
     121                $request = new WP_Http;
     122                $httpUrl = 'https://'.(isset(self::$templateini["subdir"]) && self::$templateini["subdir"] ? self::$templateini["subdir"].'.' : '').'prodii.com/common/careerpages/php/careerpageshandler.php';
     123                $httpResult = $request->request( $httpUrl, array(
     124                    'methoddd' => 'POST',
     125                    'body' =>   array(
     126                                    'action' => 'get'.self::$templateini["level"].(self::$templateini["local"] ? 'Data' : 'Html'),
     127                                    'key' => self::$templateini["key"],
     128                                    strtolower(self::$templateini["level"]) => self::$templateini["ids"],
     129                                    'template' => self::$templateini["template"],
     130                                    'locale' => self::$templateini["locale"],
     131                                    'local' => self::$templateini["local"],
     132                                    'subdir' => self::$templateini["subdir"],
     133                                    'css' => isset($css) && $css ? $css : '',
     134                                    'googlemapkey' => self::$templateini["googlemapkey"]
     135                                ),
     136                    'sslverify' => false
     137                ));
     138
     139                $httpResponse = null;
     140                $httpErrors = null;
     141                if(is_wp_error($httpResult)) {
     142                    $httpErrors = $httpResult->get_error_messages();
     143                } else {
     144                    $httpResponse = json_decode($httpResult["body"], true);
     145                }
     146
     147                if(is_wp_error($httpResult)) {
     148                    foreach ($httpErrors as $error) {
     149                        self::$templateini["errors"][] = 'Get '.(self::$templateini["local"] ? 'data' : 'html').' error - '.$error;
     150                    }
     151                } elseif ($httpResponse == '') {
     152                    self::$templateini["errors"][] = 'No '.(self::$templateini["local"] ? 'data' : 'html').' returned';
     153                } elseif (isset($httpResponse["error"])) {
     154                    //self::$templateini["errors"] = array_merge(self::$templateini["errors"], $httpResponse["error"]);
     155                    self::$templateini["errors"][] = $httpResponse["error"];
     156                } elseif (isset($httpResponse["error_message"])) {
     157                    self::$templateini["errors"] = array_merge(self::$templateini["errors"], $httpResponse["error_message"]);
     158                }
     159               
     160                /*$cp_data = array(
    90161                    'action' => 'get'.self::$templateini["level"].(self::$templateini["local"] ? 'Data' : 'Html'),
    91162                    'key' => self::$templateini["key"],
     
    120191                }
    121192
    122                 curl_close($ch);
     193                curl_close($ch);*/
    123194            }
    124195
    125196            if (empty(self::$templateini["errors"])) {
    126197                //Set server data
    127                 $cp_data = array(
     198                $request = new WP_Http;
     199                $httpUrl = 'https://'.(isset(self::$templateini["subdir"]) && self::$templateini["subdir"] ? self::$templateini["subdir"].'.' : '').'prodiiiii.com/common/careerpages/php/careerpageshandler.php';
     200                $httpResult = $request->request( $httpUrl, array(
     201                    'methoddd' => 'POST',
     202                    'body' =>   array(
     203                                    'action' => 'setLogistics',
     204                                    'level' => self::$templateini["level"],
     205                                    'ids' => self::$templateini["ids"],
     206                                    'method' => 'wpplugin',
     207                                    'template' => self::$templateini["template"],
     208                                    'locale' => str_replace("-", "_", self::$templateini["locale"]),
     209                                    'key' => self::$templateini["key"],
     210                                    'clientip' => CareerpagesLibrary::get_client_ip(),
     211                                    'server' => json_encode($_SERVER)
     212                                ),
     213                    'sslverify' => false
     214                ));
     215
     216                if(is_wp_error($httpResult)) {
     217                    $httpErrors = $httpResult->get_error_messages();
     218
     219                    foreach ($httpErrors as $error) {
     220                        //self::$templateini["errors"][] = 'Get '.(self::$templateini["local"] ? 'data' : 'html').' error - '.$error;
     221                        // There is no reason to show this error to the user
     222                    }
     223                }
     224
     225                /*$cp_data = array(
    128226                    'action' => 'setLogistics',
    129227                    'level' => self::$templateini["level"],
     
    144242                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    145243                curl_exec($ch);
    146                 curl_close($ch);
     244                curl_close($ch);*/
    147245            }
    148246           
     
    150248                if (self::$templateini["local"]) {
    151249                    global $skilllevels;
    152                     if (isset($response['skilllevels'])) $skilllevels = $response['skilllevels'];
     250                    if (isset($httpResponse['skilllevels'])) $skilllevels = $httpResponse['skilllevels'];
    153251                    global $languagelevels;
    154                     if (isset($response['languagelevels'])) $languagelevels = $response['languagelevels'];
     252                    if (isset($httpResponse['languagelevels'])) $languagelevels = $httpResponse['languagelevels'];
    155253
    156254                    switch (self::$templateini["level"]) {
    157255                        case "Company":
    158                             self::$templateini["gui"] = CareerpagesTemplate::getCompany($response);
     256                            self::$templateini["gui"] = CareerpagesTemplate::getCompany($httpResponse);
    159257                            break;
    160258                        case "Network":
    161                             self::$templateini["gui"] = CareerpagesTemplate::getCompany($response);
     259                            self::$templateini["gui"] = CareerpagesTemplate::getCompany($httpResponse);
    162260                            break;
    163261                        case "Team":
    164                             self::$templateini["gui"] = CareerpagesTemplate::getTeam($response);
     262                            self::$templateini["gui"] = CareerpagesTemplate::getTeam($httpResponse);
    165263                            break;
    166264                        case "Profile":
    167                             self::$templateini["gui"] = CareerpagesTemplate::getProfile($response);
     265                            self::$templateini["gui"] = CareerpagesTemplate::getProfile($httpResponse);
    168266                            break;
    169267                    }                       
    170268                } else {
    171                     self::$templateini["gui"] = $response;
     269                    self::$templateini["gui"] = $httpResponse;
    172270                }
    173271            }
     
    216314           
    217315                    // Get permissions
    218                     $cp_info = array(
     316                    $request = new WP_Http;
     317                    $httpUrl = 'https://'.(isset(self::$templateini["subdir"]) && self::$templateini["subdir"] ? self::$templateini["subdir"].'.' : '').'prodii.com/common/careerpages/php/careerpageshandler.php';
     318                    $httpResult = $request->request( $httpUrl, array(
     319                        'methoddd' => 'POST',
     320                        'body' =>   array(
     321                                        'action' => 'getPermissions',
     322                                        'key' => self::$templateini["key"]
     323                                    ),
     324                        'sslverify' => false
     325                    ));
     326
     327                    $httpResponse = null;
     328                    $httpErrors = null;
     329                    if(is_wp_error($httpResult)) {
     330                        $httpErrors = $httpResult->get_error_messages();
     331                    } else {
     332                        $httpResponse = json_decode($httpResult["body"], true);
     333                    }
     334
     335                    if(is_wp_error($httpResult)) {
     336                        foreach ($httpErrors as $error) {
     337                            self::$templateini["errors"][] = 'Permission error - '.$error;
     338                        }
     339                    } elseif ($httpResponse == '') {
     340                        self::$templateini["errors"][] = 'No permissions, the key in the shortcode must be missspelled or wrong';
     341                    } elseif (isset($httpResponse["error"])) {
     342                        //self::$templateini["errors"] = array_merge(self::$templateini["errors"], $httpResponse["error"]);
     343                        self::$templateini["errors"][] = $httpResponse["error"];
     344                    }
     345                   
     346                    $permissions = $httpResponse;
     347                   
     348                    /*$cp_info = array(
    219349                        'action' => 'getPermissions',
    220350                        'key' => self::$templateini["key"]
     
    233363                        self::$templateini["errors"][] = "No permissions, the key in the shortcode must be missspelled or wrong";
    234364                    }
    235                     curl_close($ch);
     365                    curl_close($ch);*/
     366                   
    236367                    // Template
    237368                    if (isset($permissions["premium"]) && $permissions["premium"] && stripos($content, ' template="') !== false) {
     
    377508                        break;
    378509                    default:
    379                         echo '¤¤¤ Came here #4 ¤¤¤';
    380510                        $gui =  self::$templateini["gui"]["error"];
    381511                        $content = CareerpagesMain::getErrorGui('Following error was detected', $gui);
     
    411541}
    412542
     543if( !class_exists( 'WP_Http' ) )
     544    include_once( ABSPATH . WPINC. '/class-http.php' );
     545
    413546if (class_exists("CareerpagesMain")) {
    414547    $careerpagesMain = new CareerpagesMain();
     
    439572        function set_admin_statistics($page) {
    440573            //Set server data
    441             $cp_data = array(
     574            $request = new WP_Http;
     575            $httpUrl = 'https://prodii.com/common/careerpages/php/careerpagesadminhandler.php';
     576            $httpResult = $request->request( $httpUrl, array(
     577                'methoddd' => 'POST',
     578                'body' =>   array(
     579                                'action' => 'setLogistics',
     580                                'key' => get_option("prodii_key"),
     581                                'method' => 'wppluginadmin',
     582                                'page' => $page,
     583                                'clientip' => CareerpagesLibrary::get_client_ip(),
     584                                'server' => json_encode($_SERVER)
     585                            ),
     586                'sslverify' => false
     587            ));
     588
     589            if(is_wp_error($httpResult)) {
     590                echo $httpResult->get_error_messages();
     591            } else {
     592                $httpResponse = json_decode($httpResult["body"], true);
     593            }
     594
     595            /*$cp_data = array(
    442596                'action' => 'setLogistics',
    443597                'key' => get_option("prodii_key"),
     
    455609            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    456610            curl_exec($ch);
    457             curl_close($ch);
     611            curl_close($ch);*/
    458612        }
    459613
     
    567721            self::set_admin_statistics('settings');
    568722
    569             $cp_data = array(
     723            $request = new WP_Http;
     724            $httpUrl = 'https://prodii.com/common/careerpages/php/careerpagesadminhandler.php';
     725            $httpResult = $request->request( $httpUrl, array(
     726                'methoddd' => 'POST',
     727                'body' =>   array(
     728                                'action' => 'getKeyData',
     729                                'key' => get_option("prodii_key")
     730                            ),
     731                'sslverify' => false
     732            ));
     733
     734            if(is_wp_error($httpResult)) {
     735                echo $httpResult->get_error_messages();
     736            } else {
     737                $data = json_decode($httpResult["body"], true);
     738            }
     739
     740            /*$cp_data = array(
    570741                'action' => 'getKeyData',
    571742                'key' => get_option("prodii_key")
     
    579750            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    580751            $data = json_decode(curl_exec($ch), true);
    581             curl_close($ch);
     752            curl_close($ch);*/
    582753           
    583754            echo    '
     
    663834        function prodii_shortcode_content() {
    664835            //if (is_array($_REQUEST)) $content = "From prodii_shortcode_content <pre>".print_r($_REQUEST, true)."</pre>";
     836            $request = new WP_Http;
     837            $httpUrl = 'https://prodii.com/common/careerpages/php/careerpagesadminhandler.php';
     838            $httpResult = $request->request( $httpUrl, array(
     839                'methoddd' => 'POST',
     840                'body' =>   array(
     841                                'action' => 'getShortcodeHtml',
     842                                'key' => get_option("prodii_key"),
     843                                'templateid' => isset($_REQUEST["prodii_templateid"]) ? $_REQUEST["prodii_templateid"] : '',
     844                                'locale' => isset($_REQUEST["prodii_locale"]) ? $_REQUEST["prodii_locale"] : '',
     845                                'css' => isset($_REQUEST["prodii_css"]) ? $_REQUEST["prodii_css"] : '',
     846                                'companyid' => isset($_REQUEST["prodii_companyid"]) ? $_REQUEST["prodii_companyid"] : 0,
     847                                'teamids' => isset($_REQUEST["prodii_teamids"]) ? $_REQUEST["prodii_teamids"] : '',
     848                                'teamid' => isset($_REQUEST["prodii_teamid"]) ? $_REQUEST["prodii_teamid"] : 0,
     849                                'memberid' => isset($_REQUEST["prodii_memberid"]) ? $_REQUEST["prodii_memberid"] : 0,
     850                                'view' => isset($_REQUEST["prodii_view"]) ? $_REQUEST["prodii_view"] : 'tab-company'
     851                            ),
     852                'sslverify' => false
     853            ));
     854
     855            if(is_wp_error($httpResult)) {
     856                echo $httpResult->get_error_messages();
     857            } else {
     858                $content = json_decode($httpResult["body"], true);
     859            }
     860
    665861            $cp_data = array(
    666862                'action' => 'getShortcodeHtml',
     
    676872            );
    677873
    678             $ch = curl_init();
     874            /*$ch = curl_init();
    679875            curl_setopt($ch, CURLOPT_URL, 'https://prodii.com/common/careerpages/php/careerpagesadminhandler.php');
    680876            curl_setopt($ch, CURLOPT_POST, count($cp_data));
     
    688884                $content = json_decode('cURL error ({$errno}):\n {$error_message}');
    689885            }
    690             curl_close($ch);
     886            curl_close($ch);*/
    691887           
    692888            return $content;
Note: See TracChangeset for help on using the changeset viewer.