public function sendpost($id) { if ($this->host == '' || $this->login == '') { return false; } $post = tpost::i($id); ttheme::$vars['post'] = $post; $theme = ttheme::i(); $content = $theme->parse($this->template); $date = getdate($post->posted); if ($post->status != 'published') { return; } $meta = $post->meta; $client = new IXR_Client($this->host, '/interface/xmlrpc'); //$client = new IXR_Client($this->host, '/rpc.xml'); if (!$client->query('LJ.XMLRPC.getchallenge')) { if (litepublisher::$debug) { tfiler::log('live journal: error challenge'); } return false; } $response = $client->getResponse(); $challenge = $response['challenge']; $args = array('username' => $this->login, 'auth_method' => 'challenge', 'auth_challenge' => $challenge, 'auth_response' => md5($challenge . md5($this->password)), 'ver' => "1", 'event' => $content, 'subject' => $post->title, 'year' => $date['year'], 'mon' => $date['mon'], 'day' => $date['mday'], 'hour' => $date['hours'], 'min' => $date['minutes'], 'props' => array('opt_nocomments' => !$post->commentsenabled, 'opt_preformatted' => true, 'taglist' => $post->tagnames)); switch ($this->privacy) { case "public": $args['security'] = "public"; break; case "private": $args['security'] = "private"; break; case "friends": $args['security'] = "usemask"; $args['allowmask'] = 1; } if ($this->community != '') { $args['usejournal'] = $this->community; } if (isset($meta->ljid)) { $method = 'LJ.XMLRPC.editevent'; $args['itemid'] = $meta->ljid; } else { $method = 'LJ.XMLRPC.postevent'; } if (!$client->query($method, $args)) { if (litepublisher::$debug) { tfiler::log('Something went wrong - ' . $client->getErrorCode() . ' : ' . $client->getErrorMessage()); } return false; } if (!isset($meta->ljid)) { $response = $client->getResponse(); $meta->ljid = $response['itemid']; } return $meta->ljid; }
function getConnectedKeywords($id) { if (!$this->client->query('contact.getConnectedKeywords', $this->credentials, $id)) { trigger_error($this->client->getErrorCode() . ' : ' . $this->client->getErrorMessage()); return false; } return $this->client->getResponse(); }
function capturePayment($transactionnumber) { if (!$this->client->query('payment.capture', $this->credentials, $transactionnumber)) { print $this->client->getErrorCode() . ' : ' . $this->client->getErrorMessage(); return false; } return $this->client->getResponse(); }
/** * Envía mensajes a un array de destinatarios * * El array de entrada debe ser: * * $mensajes = array( * array('637xxxxxx','texto del mensaje','texto que identifica al enviador'), * //array(), * ); * * @param array $mensajes * @return array */ static function send(array $mensajes) { if (count($mensajes)) { $client = new IXR_Client(self::$url); $client->query('MensajeriaNegocios.enviarSMS', self::$user, self::$passw, $mensajes); return $client->getResponse(); } }
/** * Funktionen sender ordren til systemet * * @param $order (array) * $order['company'] = $_POST['navn']; * $order['contactname'] = $_POST['navn']; * $order['address'] = $_POST['adresse']; * $order['postalcode'] = $_POST['postnr']; * $order['town'] = $_POST['bynavn']; * $order['email'] = $_POST['email']; * $order['phone'] = $_POST['telefonnummer']; * @access public */ function placeOrder($order) { if (!($id = $this->client->query('basket.placeOrder', $this->credentials, $order))) { //if (!$client->query('products.test', $args)) { trigger_error('An error occurred - ' . $this->client->getErrorCode() . ":" . $this->client->getErrorMessage()); } return $this->client->getResponse(); }
/** * This method is similar to call_user_func() in that you can pass any number of arguments beyond the required two, which will then call the remote XMLRPC method. * @param string $url * @param string $method * @return array (bool success,mixed response) */ function call($url, $method) { $client = new IXR_Client($url); if (defined('DEBUG_XMLRPC')) { $client->debug = true; } $args = func_get_args(); return !call_user_func_array(array($client, 'query'), array($method) + array_slice($args, 1)) ? array(false, $client->getErrorCode() . ' : ' . $client->getErrorMessage()) : array(true, $client->getResponse()); }
/** * Performs and action for the executed test case (i.e. sets the status of test case) * * @param string $method * @param array $args * * @return array */ protected function action($method, $args) { $args["devKey"] = Mage_Testlink_Connector::$devKey; if (!$this->_client->query("tl.{$method}", $args)) { $response = null; } else { $response = $this->_client->getResponse(); } return $response; }
public static function rpc($url) { new Pinger(); //require_once( GX_LIB.'/Vendor/IXR_Library.php' ); $url = 'http://' . $url; $client = new IXR_Client($url); $client->timeout = 3; $client->useragent .= ' -- PingTool/1.0.0'; $client->debug = false; if ($client->query('weblogUpdates.extendedPing', self::$myBlogName, self::$myBlogUrl, self::$myBlogUpdateUrl, self::$myBlogRSSFeedUrl)) { return $client->getResponse(); } //echo 'Failed extended XML-RPC ping for "' . $url . '": ' . $client->getErrorCode() . '->' . $client->getErrorMessage() . '<br />'; if ($client->query('weblogUpdates.ping', self::$myBlogName, self::$myBlogUrl)) { return $client->getResponse(); } //echo 'Failed basic XML-RPC ping for "' . $url . '": ' . $client->getErrorCode() . '->' . $client->getErrorMessage() . '<br />'; return false; }
/** * sends targets from OutputThis. * * @param integer id of destination. */ static function get_targets($username, $password) { Logger::log("Enter: function OutputThis::get_targets()"); $client = new IXR_Client('http://outputthis.org/xmlrpc.php'); if (!$client->query('outputthis.getPublishedTargets', $username, $password)) { $error[0] = 'error'; $error[1] = 'Something went wrong - ' . $client->getErrorCode() . ' : ' . $client->getErrorMessage(); Logger::log("Exit: function OutputThis::get_targets()-Error in getting information from output this"); return $error; } else { $targets = $client->getResponse(); Logger::log("Exit: function OutputThis::get_targets()-getting information from outputthis successful"); return $targets; } }
function submitFlightToServer($serverURL, $username, $passwd, $igcURL, $igcFilename, $private, $cat, $linkURL, $comments, $glider) { require_once dirname(__FILE__) . "/lib/xml_rpc/IXR_Library.inc.php"; $client = new IXR_Client($serverURL); // $client->debug=true; // echo "$username, $passwd, $igcURL, $igcFilename, $private, $cat, $linkURL, $comments, $glider #<BR>"; if (!$client->query('flights.submit', $username, $passwd, $igcURL, $igcFilename, $private, $cat, $linkURL, $comments, $glider)) { //echo 'submitFlightToServer: Error '.$client->getErrorCode()." -> ".$client->getErrorMessage(); return array(0, $client->getErrorCode(), $client->getErrorMessage()); } else { $flightID = $client->getResponse(); return array($flightID, '', ''); // echo 'Flight was submited with id '.$flightID; } // return $flightID; }
/** * Purges remote files * * @param array $files * @param array $results * @return boolean */ function purge($files, &$results) { if (empty($this->_config['apiid'])) { $results = $this->_get_results($files, W3TC_CDN_RESULT_HALT, 'Empty API ID.'); return false; } if (empty($this->_config['apikey'])) { $results = $this->_get_results($files, W3TC_CDN_RESULT_HALT, 'Empty API key.'); return false; } if ($this->_sha256('test') === false) { $results = $this->_get_results($files, W3TC_CDN_RESULT_HALT, "hash() or mhash() function doesn't exists."); return false; } if (!class_exists('IXR_Client')) { require_once ABSPATH . WPINC . '/class-IXR.php'; } if (function_exists('date_default_timezone_set')) { $timezone = date_default_timezone_get(); date_default_timezone_set(W3TC_CDN_MIRROR_NETDNA_TZ); } $date = date('c'); $auth_string = sprintf('%s:%s:purge', $date, $this->_config['apikey']); $auth_key = $this->_sha256($auth_string); $client = new IXR_Client(W3TC_CDN_MIRROR_NETDNA_URL); $client->timeout = 30; $results = array(); foreach ($files as $local_path => $remote_path) { $url = $this->format_url($remote_path); $client->query('cache.purge', $this->_config['apiid'], $auth_key, $date, $url); if (!$client->isError()) { $val = $client->getResponse(); if ($val) { $results[] = $this->_get_result($local_path, $remote_path, W3TC_CDN_RESULT_OK, 'OK'); } else { $results[] = $this->_get_result($local_path, $remote_path, W3TC_CDN_RESULT_ERROR, 'Unable to purge.'); } } else { $results[] = $this->_get_result($local_path, $remote_path, W3TC_CDN_RESULT_HALT, sprintf('Unable to purge (%s).', $client->getErrorMessage())); } } if (function_exists('date_default_timezone_set')) { date_default_timezone_set($timezone); } return !$this->_is_error($results); }
private function getNamespace($server, $check_method) { if (empty($this->methods)) { $client = new \IXR_Client("http://{$server}:9001/RPC2/"); // $client->debug = true; if (!$client->query('system.listMethods')) { return false; } else { $methods = $client->getResponse(); foreach ($methods as $method) { $parts = explode('.', $method); $this->methods[$parts[1]] = $parts[0]; } } } return $this->methods[$check_method]; }
function get_palina($palina_id, $api_key) { // mi autentico per ottenere il token $client = new IXR_Client("http://muovi.roma.it/ws/xml/autenticazione/1"); if (!$client->query('autenticazione.Accedi', $api_key, '')) { echo '<br>An error occurred - ' . $client->getErrorCode() . ":" . $client->getErrorMessage(); } $token = $client->getResponse(); // mostra il token //echo "<br><br>TOKEN-> ".$token; // richiamo il ws per la ricerca del percorso $client = new IXR_Client("http://muovi.roma.it/ws/xml/paline/7"); if (!$client->query('paline.Previsioni', $token, (int) $palina_id, "it")) { echo '<br>An error occurred - ' . $client->getErrorCode() . ":" . $client->getErrorMessage(); } $response = $client->getResponse(); return $response; }
/** * api_request * * Handles any request made to the Syndication Toolkit Master wordpress install via cURL * * @param string $method * @param array $params * @return mixed $results * @access public * @author Ben Moody */ public function api_request($method, $params) { //Init vars $client = NULL; $results = NULL; $request = NULL; $ch = NULL; $results = NULL; $response_code = NULL; $errorno = NULL; $error = NULL; //include Incutio XML-RPC Library from wordpress core require PRSOSYNDTOOLKITREADER__XMLRPC_LIB; $client = new IXR_Client($this->xml_rpc_url); if (!$client->query($method, $params, $this->username, $this->password)) { return array('errorCode' => $client->getErrorCode(), 'errorMsg' => $client->getErrorMessage()); } $results = $client->getResponse(); return $results; }
function ljxp_delete($post_id) { // Pull the post_id $ljxp_post_id = get_post_meta($post_id, 'ljID', true); $errors = array(); // Ensures that there's actually a value. If the post was never // cross-posted, the value wouldn't be set, and there's no point in // deleting entries that don't exist if ($ljxp_post_id == 0) { return $post_id; } $options = ljxp_get_options(); // And open the XMLRPC interface $client = new IXR_Client($options['host'], '/interface/xmlrpc'); // Request the challenge for authentication if (!$client->query('LJ.XMLRPC.getchallenge')) { $errors[$client->getErrorCode()] = $client->getErrorMessage(); } // And retrieve the challenge that LJ returns $response = $client->getResponse(); $challenge = $response['challenge']; // Most of this is the same as before. The important difference is the // value of $args[event]. By setting it to a null value, LJ deletes the // entry. Really rather klunky way of doing things, but not my code! $args = array('username' => $options['username'], 'auth_method' => 'challenge', 'auth_challenge' => $challenge, 'auth_response' => md5($challenge . $options['password']), 'itemid' => $ljxp_post_id, 'event' => "", 'subject' => "Delete this entry", 'year' => date('Y'), 'mon' => date('n'), 'day' => date('j'), 'hour' => date('G'), 'min' => date('i'), 'usejournal' => !empty($options['community']) ? $options['community'] : $options['username']); // And awaaaayyy we go! if (!$client->query('LJ.XMLRPC.editevent', $args)) { $errors[$client->getErrorCode()] = $client->getErrorMessage(); } delete_post_meta($post_id, 'ljID'); delete_post_meta($post_id, 'ljURL'); update_option('ljxp_error_notice', $errors); return $post_id; }
/** * Installs a language from the RPC server or from a file. * * This function fetches language strings for the given language code from * either the RPC server or a file. * * Action is taken based on three HTTP POST parameters: 'lang_code', 'force' and * 'updating'. The 'lang_code' is the installed langauge, e.g. 'en-gb', 'fi-fi'. * The 'force' when set to 'file' can be used force an installation from a local * file. The 'updating' specifies whether only to install (0) or to update (1). */ function get_language() { global $prefs, $textarray; require_once txpath . '/lib/IXRClass.php'; $lang_code = gps('lang_code'); $client = new IXR_Client(RPC_SERVER); // $client->debug = true; @set_time_limit(90); // TODO: 90 seconds: seriously? if (gps('force') == 'file' || !$client->query('tups.getLanguage', $prefs['blog_uid'], $lang_code)) { if ((gps('force') == 'file' || gps('updating') !== '1') && install_language_from_file($lang_code)) { if (defined('LANG')) { $textarray = load_lang(LANG); } callback_event('lang_installed', 'file', false, $lang_code); return list_languages(gTxt($lang_code) . sp . gTxt('updated')); } else { pagetop(gTxt('installing_language')); echo graf('<span class="ui-icon ui-icon-closethick"></span> ' . gTxt('rpc_connect_error') . "<!--" . $client->getErrorCode() . ' ' . $client->getErrorMessage() . "-->", array('class' => 'alert-block error')); } } else { $response = $client->getResponse(); $lang_struct = unserialize($response); if ($lang_struct === false) { $errors = $size = 1; } else { array_walk($lang_struct, 'install_lang_key'); $size = count($lang_struct); $errors = 0; for ($i = 0; $i < $size; $i++) { $errors += !$lang_struct[$i]['ok']; } if (defined('LANG')) { $textarray = load_lang(LANG); } } $msg = gTxt($lang_code) . sp . gTxt('updated'); callback_event('lang_installed', 'remote', false, $lang_code); if ($errors > 0) { $msg = array($msg . sprintf(" (%s errors, %s ok)", $errors, $size - $errors), E_ERROR); } list_languages($msg); } }
/** * Private function for retrieving a users blogs for multisite setups * * @access protected */ function _multisite_getUsersBlogs($args) { global $current_blog; $domain = $current_blog->domain; $path = $current_blog->path . 'xmlrpc.php'; $protocol = is_ssl() ? 'https' : 'http'; $rpc = new IXR_Client("{$protocol}://{$domain}{$path}"); $rpc->query('wp.getUsersBlogs', $args[1], $args[2]); $blogs = $rpc->getResponse(); if (isset($blogs['faultCode'])) { return new IXR_Error($blogs['faultCode'], $blogs['faultString']); } if ($_SERVER['HTTP_HOST'] == $domain && $_SERVER['REQUEST_URI'] == $path) { return $blogs; } else { foreach ((array) $blogs as $blog) { if (strpos($blog['url'], $_SERVER['HTTP_HOST'])) { return array($blog); } } return array(); } }
public function afterImport() { if (!function_exists('PHPMailerAutoload')) require __DIR__ . DIRECTORY_SEPARATOR . 'phpmailer' . DIRECTORY_SEPARATOR . 'PHPMailerAutoload.php'; $config = array(); foreach ($this->selectAll( 'SELECT `path`,`value` FROM `core_config_data` WHERE `scope` = "default" AND ( `path` LIKE "%/lesti_smtp/%" OR `path` LIKE "%/ident_general/%" OR `path` = "web/unsecure/base_url")') as $value) { $config [$value['path']] = $value['value']; } $secondPath = $this->selectone('SELECT `value` FROM `core_config_data` WHERE `scope_id` = 2 AND `path` = "web/unsecure/base_url"',null,'value'); $imageDir = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR . 'catalog' . DIRECTORY_SEPARATOR . 'product' . DIRECTORY_SEPARATOR; $imageDir = realpath($imageDir); $name_id = $this->selectone(' SELECT `attribute_id` FROM `eav_attribute` WHERE `attribute_code`="name" AND `entity_type_id`= (SELECT `entity_type_id` FROM `eav_entity_type` WHERE `entity_type_code`="catalog_product" ) ',null,'attribute_id'); //$name = 71; $description_id = $this->selectone(' SELECT `attribute_id` FROM `eav_attribute` WHERE `attribute_code`="description" AND `entity_type_id`= (SELECT `entity_type_id` FROM `eav_entity_type` WHERE `entity_type_code`="catalog_product" ) ',null,'attribute_id'); //$description = 72; $url_key_id = $this->selectone(' SELECT `attribute_id` FROM `eav_attribute` WHERE `attribute_code`="url_key" AND `entity_type_id`= (SELECT `entity_type_id` FROM `eav_entity_type` WHERE `entity_type_code`="catalog_product" ) ',null,'attribute_id'); //$url_key = 97; $image_id = $this->selectone(' SELECT `attribute_id` FROM `eav_attribute` WHERE `attribute_code`="image" AND `entity_type_id`= (SELECT `entity_type_id` FROM `eav_entity_type` WHERE `entity_type_code`="catalog_product" ) ',null,'attribute_id'); //$image = 85; $catalog_category_id = $this->selectone(' SELECT `attribute_id` FROM `eav_attribute` WHERE `attribute_code`="name" AND `entity_type_id`= (SELECT `entity_type_id` FROM `eav_entity_type` WHERE `entity_type_code`="catalog_category" ) ',null,'attribute_id'); //$catalog_category = 41; $shared_on_social_networks_id = $this->selectone(' SELECT `attribute_id` FROM `eav_attribute` WHERE `attribute_code`="shared_on_social_networks" ',null,'attribute_id'); //$shared_on_social_networks = 143; $news_from_date = $this->selectone(' SELECT `attribute_id` FROM `eav_attribute` WHERE `attribute_code`="news_from_date" ',null,'attribute_id'); //$shared_on_social_networks = 93; $product_stmt = $this->exec_stmt(' SELECT `catalog_product_entity`.`entity_id` , `catalog_product_entity`.`sku` FROM `catalog_product_entity` LEFT JOIN `catalog_product_entity_int` ON `catalog_product_entity_int`.`entity_id`=`catalog_product_entity`.`entity_id` AND `catalog_product_entity_int`.`attribute_id`= '.$shared_on_social_networks_id.' LEFT JOIN `catalog_product_entity_datetime` ON `catalog_product_entity_datetime`.`entity_id`=`catalog_product_entity`.`entity_id` AND `catalog_product_entity_datetime`.`attribute_id`= '.$news_from_date.' WHERE ( `catalog_product_entity_int`.`value` IS NULL OR `catalog_product_entity_int`.`value` != 1 ) AND ( `catalog_product_entity_datetime`.`value` IS NOT NULL OR `catalog_product_entity_datetime`.`value` != "" ) GROUP BY `catalog_product_entity`.`entity_id` ORDER BY `catalog_product_entity_datetime`.`value` DESC ',null,false); // Full path to twitterOAuth.php (change OAuth to your own path) // create new instance $tweet = new TwitterOAuth( $this->getParam("SOCIAL:twitterkey", ""), $this->getParam("SOCIAL:twittersecret", ""), $this->getParam("SOCIAL:twitterotoken", ""), $this->getParam("SOCIAL:twitterosecret", "") ); $productCount = 0; $facebookPages = explode(':',$this->getParam("SOCIAL:facebook", "")); $gogglePages = explode(':',$this->getParam("SOCIAL:gpage", "")); while ($productCount < $this->getParam("SOCIAL:topost", "10") && $product = $product_stmt->fetch(PDO::FETCH_ASSOC) ) { $product['image']= $this->selectone(' SELECT `value` FROM `catalog_product_entity_varchar` WHERE `catalog_product_entity_varchar`.`entity_id`='.$product['entity_id'].' AND `catalog_product_entity_varchar`.`attribute_id`= '.$image_id.' LIMIT 1 ',null,'value'); $product['url_path'] = $this->selectone(' SELECT `request_path` FROM `core_url_rewrite` WHERE `id_path` LIKE "product/%" AND `product_id` ='.$product['entity_id'].' ORDER BY `category_id` ASC LIMIT 1 ',null,'request_path'); if ( $product['url_path'] == '' || !is_file($imageDir . $product['image']) ) { continue; } $product['name']= $this->selectone(' SELECT `value` FROM `catalog_product_entity_varchar` WHERE `catalog_product_entity_varchar`.`entity_id`='.$product['entity_id'].' AND `catalog_product_entity_varchar`.`attribute_id`= '.$name_id.' LIMIT 1 ',null,'value'); $product['description']= $this->selectone(' SELECT `value` FROM `catalog_product_entity_text` WHERE `catalog_product_entity_text`.`entity_id`='.$product['entity_id'].' AND `catalog_product_entity_text`.`attribute_id`= '.$description_id.' LIMIT 1 ',null,'value'); $product['url_key']= $this->selectone(' SELECT `value` FROM `catalog_product_entity_varchar` WHERE `catalog_product_entity_varchar`.`entity_id`='.$product['entity_id'].' AND `catalog_product_entity_varchar`.`attribute_id`= '.$url_key_id.' LIMIT 1 ',null,'value'); $product['category_names'] = $this->selectone(' SELECT GROUP_CONCAT( DISTINCT `value` SEPARATOR ", ") as value FROM `catalog_category_entity_varchar` WHERE `entity_id` IN (SELECT `category_id` FROM `catalog_category_product` WHERE `product_id` = '.$product['entity_id'].') AND `catalog_category_entity_varchar`.`attribute_id`= '.$catalog_category_id.' ',null,'value'); $productCount ++; $tags = preg_replace('/^[^,]*, /', '', $product['category_names']); $tags = strtolower(', '.$tags); $tags = str_replace(' ','_',$tags); $tags = trim(str_replace(',_',' #',$tags)); if ( $this->getParam("SOCIAL:gemail", "") != '' && $this->getParam("SOCIAL:gpassword", "") != '' && $this->getParam("SOCIAL:gpage", "") != '' ) { foreach($gogglePages as $key=>$gogglePage) { $baseUrl = $config['web/unsecure/base_url']; if ($key>0 && $secondPath != '') $baseUrl = $secondPath; $nt = new nxsAPI_GP(); $loginError = $nt->connect($this->getParam("SOCIAL:gemail", ""), $this->getParam("SOCIAL:gpassword", "")); // Image URL $lnk = array('img'=>$baseUrl. '/media/catalog/product/' . $product['image']); $nt->postGP($product['name'] .' '. $tags . ' ' . $baseUrl . 'index.php/' . $product['url_path'], $lnk, $gogglePage); if ($loginError === false) $this->log($baseUrl . 'index.php/' . $product['url_path'] . " not sent succesfully " . $loginError, "info"); } } // Your Message $message = substr($product['name'], 0, 100) . ' ' . $config['web/unsecure/base_url'] . 'index.php/' . $product['url_path']. ' ' . $tags; if ( $this->getParam("SOCIAL:twitterkey", "") != '' && $this->getParam("SOCIAL:twittersecret", "") != '' && $this->getParam("SOCIAL:twitterotoken", "") != '' && $this->getParam("SOCIAL:twitterosecret", "") != '' ) { // Send tweet $tweet->post('statuses/update', array('status' => $message)); } if ( $this->getParam("SOCIAL:wpurl", "") != '' && $this->getParam("SOCIAL:wpusername") != '' && $this->getParam("SOCIAL:wppassword", "") != '' ) { $client = new IXR_Client($this->getParam("SOCIAL:wpurl", "")); $description = substr($product['description'],0,100); $description .= '<!--more-->'; $description .= substr($product['description'],100); $description .= '<br/><a href="' . $config['web/unsecure/base_url'] . 'index.php/' . $product['url_path'] . '">' . $product['name'] . '</a>'; $content = array( 'post_status' => 'draft', 'post_type' => 'post', 'post_title' => $product['name'], 'post_content' => $description, 'terms' => array('category' => array($this->getParam("SOCIAL:wpcategory_id", ""))) ); $params = array(0, $this->getParam("SOCIAL:wpusername", ""), $this->getParam("SOCIAL:wppassword", ""), $content); $client->query('wp.newPost', $params); $post_id = $client->getResponse(); $command = 'convert "' .$imageDir . $product['image']. '" -resize 604x270\\> -resample 72 /tmp/storebaby.jpg 2>&1 '; exec($command); $content = array( 'name' => basename($product['image']), 'type' => mime_content_type(basename($product['image'])), 'bits' => new IXR_Base64(file_get_contents('/tmp/storebaby.jpg')), true ); $client->query('metaWeblog.newMediaObject', 1, $this->getParam("SOCIAL:wpusername"), $this->getParam("SOCIAL:wppassword"), $content); $media = $client->getResponse(); $content = array( 'post_status' => 'publish', 'mt_keywords' => preg_replace('/^[^,]*, /', '', $product['category_names']), 'wp_post_thumbnail' => $media['id'] ); $client->query('metaWeblog.editPost', $post_id, $this->getParam("SOCIAL:wpusername"), $this->getParam("SOCIAL:wppassword"), $content, true); } $fbConfigFile = __DIR__.'/fbConf.php'; if (is_file($fbConfigFile)) { require $fbConfigFile; $baseUrl = $config['web/unsecure/base_url']; $fb = new Facebook\Facebook(array( 'app_id' => $fbConfig['appId'], 'app_secret' => $fbConfig['appSecret'], 'default_graph_version' => 'v2.3' )); foreach($fbConfig['pages'] as $pageId=>$pageToken) { $fb->setDefaultAccessToken($pageToken); $linkData = [ 'link' => $baseUrl . 'index.php/' . $product['url_path'], 'name' => $product['name'] .' ' . $tags, 'message' => $product['name'] .' ' . $tags, 'picture' => $baseUrl. '/media/catalog/product/' . $product['image'] ]; try { // Returns a `Facebook\FacebookResponse` object $fb->post('/'. substr($pageId,1,99) .'/feed', $linkData,$pageToken); } catch(Facebook\Exceptions\FacebookResponseException $e) { echo 'Graph returned an error: ' . $e->getMessage(); } catch(Facebook\Exceptions\FacebookSDKException $e) { echo 'Facebook SDK returned an error: ' . $e->getMessage(); } } $this->exec_stmt('REPLACE INTO `catalog_product_entity_int` SET `value`=1 , `catalog_product_entity_int`.`attribute_id`= '.$shared_on_social_networks_id.', `catalog_product_entity_int`.`entity_id` = ' . $product['entity_id'] . ' '); } unlink('/tmp/storebaby.jpg'); } $product_stmt->closeCursor(); }
<?php require './roots.php'; require_once $root_path . 'include/inc_environment_global.php'; require_once $root_path . 'classes/ixr_library.inc.php'; $client = new IXR_Client('http://scripts.incutio.com/xmlrpc/simpleserver.php'); $client->query('test.getTime'); print $client->getResponse(); // Prints the current time, according to our web server $test = new IXR_Client('http://scripts.incutio.com/xmlrpc/simpleserver.php'); if (!$test->query('test.addArray', array(3, 5, 7))) { die('An error occurred - ' . $test->getErrorCode() . ":" . $test->getErrorMessage()); } print $test->getResponse(); $client = new IXR_Client('http://scripts.incutio.com/xmlrpc/simpleserver.php'); if (!$client->query('test.add', 4, 5)) { die('An error occurred - ' . $client->getErrorCode() . ":" . $client->getErrorMessage()); } print $client->getResponse(); ?>
function executeTestCase($server_url, $context, $exec, $debug = false) { new dBug($context); new dBug($exec); $client = new IXR_Client($server_url); $client->debug = $debug; $data = array(); $data["devKey"] = 'admin'; $data["status"] = $exec->status; if (property_exists($exec, 'user') && !is_null($exec->user)) { $data["user"] = $exec->user; } if (property_exists($exec, 'notes') && !is_null($exec->notes)) { $data["notes"] = $exec->notes; } if (property_exists($exec, 'bugid') && !is_null($exec->bugid)) { $data["bugid"] = $exec->bugid; } if (property_exists($exec, 'overwrite') && !is_null($exec->overwrite)) { $data["overwrite"] = $exec->overwrite; } if (property_exists($exec, 'customfields') && !is_null($exec->customfields)) { $data["customfields"] = $customfields; } if (property_exists($exec, 'timestamp') && !is_null($exec->timestamp)) { $data["timestamp"] = $exec->timestamp; } $data["testplanid"] = $context->testplanid; if (property_exists($context, 'testcaseid') && !is_null($context->testcaseid)) { $data["testcaseid"] = $context->testcaseid; } else { if (property_exists($context, 'testcaseexternalid') && !is_null($context->testcaseexternalid)) { $data["testcaseexternalid"] = $context->testcaseexternalid; } } if (property_exists($context, 'buildid') && !is_null($context->buildid)) { $data["buildid"] = $context->buildid; } else { if (property_exists($context, 'buildname') && !is_null($context->buildname)) { $data["buildname"] = $context->buildname; } } if (property_exists($context, 'platformname') && !is_null($context->platformname)) { $data["platformname"] = $context->platformname; } new dBug($data); if (!$client->query('tl.reportTCResult', $data)) { echo "something went wrong - " . $client->getErrorCode() . " - " . $client->getErrorMessage(); } else { return $client->getResponse(); } }
/** * Make a remote call to the licensing server. * * @param string $RPC The URL to the admin rpc.php file. * @param string $api_fingerprint The API fingerprint to use. * @param string $license The license key to validate. * @return string The local key string. */ function go_remote_api($RPC, $api_fingerprint, $license) { require_once dirname(__FILE__) . '/XMLRPC.class.php'; $api = new IXR_Client($RPC); $keydata = array('api_key' => $api_fingerprint, 'license_key' => $license); $api->query('license.get_local_key', $keydata); $local_key = $api->getResponse(); // write the local key licensing::store_local_key($local_key); return $local_key; }
$x_body = ""; if ($saryid) { if (!$hash) { // satria efa md5-ed ny pass dia tsy maintsy takiana indray $x_body = "Ampidiro eto ambany ny tenimiafina fampiasanao eto amin'ny serasera </b>\r\n\t\t\t\t\t<form method='post' action=''>\r\n\t\t\t\t\t\t<input type='hidden' name='rub' value='namana/sary'>\r\n\t\t\t\t\t\t<input type='hidden' name='asa' value='blog'>\r\n\t\t\t\t\t\t<input type='hidden' name='saryid' value='" . $saryid . "'>\r\n\t\t\t\t\t\t<input type='password' name='hash' value=''>\r\n\t\t\t\t\t\t<input type='submit' name='alefa' value='Alefa' class=''>\r\n\t\t\t\t\t</form>\r\n\t\t\t\t\t"; } else { include_once "ixrclass.php"; $client = new IXR_Client('blaogy.com', '/xmlrpc.php', 80); if (!$client->query('blogger.getUsersBlogs', null, $USER->username, $hash)) { $x_body = "<b>Misy olana.</b> <br />\r\n\t\t\t\t\t\t- Jereo fa sao dia diso ny tenimiafina napetrakao: {$hash}<br />\r\n\t\t\t\t\t\t- Raha tsy mbola manana blaogy ianao dia manokafa blaogy ao amin'ny <a href='http://blaogy.com'>blaogy.com</a><br />\r\n\t\t\t\t\t\t- Raha efa manana blaogy ao amin'ny blaogy.com ianao kanefa mbola mitranga ity dia misy olana kely izany ny fifandraisana amin'ny blaogy.com fa miverena rehefa kelikely.<br>\r\n\t\t\t\t\t\t- Raha tena mbola tsy mety dia manorata any amin'i hery azafady\r\n\t\t\t\t\t\t"; } else { //vérifier-na aloha fa sao dia tsy sariny akory $sary = $DB->get_row("SELECT * FROM #__namana_sary WHERE saryid='{$saryid}'"); if (trim($alefa) == md5('alefa')) { if ($sary->uid == $USER->uid) { $blaogy = $client->getResponse(); //jerena raha ao amin'ny media ny sary $saryfile = S_PATH_BASE . "media/sary/namana/" . $sary->saryfile; // 03/05/2008 7.52 //ajanona aloha fa mbola tsy mety ny blaogy.com /* if(file_exists($saryfile)) { //uplod to blaogy include('mime_type.php'); $handle = @fopen($saryfile, "r"); if ($handle) { while (!feof($handle)) { $lines[] = fgets($handle, 4096); } fclose($handle); }
function mediacp_api($api) { $client = new IXR_Client($api['path'] . "/system/rpc.php"); if (isset($_GET['debug'])) { $client->debug = true; echo "Integration Version: " . date("d-m-Y.", filemtime(__FILE__)) . "<br />\n"; print_r($api); echo "<br />\n"; } if (!$client->query($api['rpc'], $api['args'])) { exit("An error occurred - " . $client->getErrorCode() . ":" . $client->getErrorMessage()); } return $client->getResponse(); }
function checkUpdates() { require_once txpath . '/lib/IXRClass.php'; $client = new IXR_Client('http://rpc.textpattern.com'); $uid = safe_field('val', 'txp_prefs', "name='blog_uid'"); if (!$client->query('tups.getTXPVersion', $uid)) { return gTxt('problem_connecting_rpc_server'); } else { $msg = array(); $response = $client->getResponse(); if (is_array($response)) { ksort($response); $version = safe_field('val', 'txp_prefs', "name='version'"); $lversion = explode('.', $version); $branch = substr($version, 0, 3); foreach ($response as $key => $val) { $rversion = explode('.', $val); if ($key == 'txp_current_version_' . $branch) { if (isset($lversion[2]) && isset($rversion[2]) && intval($rversion[2]) > intval($lversion[2])) { $msg[] = gTxt('updated_branch_version_available'); } else { $msg[] = gTxt('your_branch_is_updated'); } } else { if (intval($rversion[0]) > intval($lversion[0]) || intval($rversion[1]) > intval($lversion[1])) { $msg[] = gTxt('new_textpattern_version_available') . ': ' . $val; } } } return $msg; } } }
function getAndReturnDonations($remoteProcedureCall, $identifier) { // get the submitted parameters $pluginName = $_POST['pluginName']; $key = $identifier . '_' . $pluginName; //try to get response from DB cache if (false === ($response = get_site_transient($key))) { // response not found in DB cache, generate response if (class_exists('IXR_Client')) { $ixrClient = new IXR_Client(AIOFAVICON_DONATIONLOADER_XMLRPC_URL); $ixrClient->useragent = AIOFAVICON_USERAGENT; $ixrClient->query($remoteProcedureCall, $pluginName); $response = $ixrClient->getResponse(); } set_site_transient($key, serialize($response), AIOFAVICON_DONATIONLOADER_CACHETIME); } else { $response = unserialize($response); } // header content-type must match the one used in the jQuery.post call. //header( "content-type: application/json" ); header("content-type: text/html"); // echo instead of return, $response is given back to the Ajax call. echo $response; // IMPORTANT: don't forget to "exit" exit; }
function query($method, $args = false) { if (!$method) { return false; } $client = new IXR_Client($this->endpoint); $client->debug = false; $client->timeout = 3; $client->useragent .= ' -- bbPress Live Data/0.1.2'; if ($this->options['always_use_auth'] || !in_array($method, $this->readonly_methods)) { array_unshift($args, $this->options['username'], $this->options['password']); } else { array_unshift($args, false, false); } if (!$client->query($method, $args)) { return false; } return $client->getResponse(); }
$lang = 'en-gb'; include_once txpath . '/setup/en-gb.php'; if (!@$lastmod) { $lastmod = '0000-00-00 00:00:00'; } foreach ($en_gb_lang as $evt_name => $evt_strings) { foreach ($evt_strings as $lang_key => $lang_val) { $lang_val = doSlash($lang_val); if (@$lang_val) { mysql_query("INSERT DELAYED INTO `" . PFX . "txp_lang` SET lang='en-gb', name='" . $lang_key . "', event='" . $evt_name . "', data='" . $lang_val . "', lastmod='" . $lastmod . "'"); } } } } } else { $response = $client->getResponse(); $lang_struct = unserialize($response); foreach ($lang_struct as $item) { foreach ($item as $name => $value) { $item[$name] = doSlash($value); } mysql_query("INSERT DELAYED INTO `" . PFX . "txp_lang` SET lang='" . LANG . "', name='" . $item['name'] . "', event='" . $item['event'] . "', data='" . $item['data'] . "', lastmod='" . strftime('%Y%m%d%H%M%S', $item['uLastmod']) . "'"); } } mysql_query("FLUSH TABLE `" . PFX . "txp_lang`"); /** * Stub replacement for txplib_db.php/safe_escape() */ function safe_escape($in = '') { return mysql_real_escape_string($in);
function wppost_drop_item(&$a, &$b) { $wp_enabled = get_pconfig($b['item']['uid'], 'wppost', 'post'); if (!$wp_enabled) { return; } $r = q("select * from iconfig left join item on item.id = iconfig.iid where cat = 'system' and k = 'wordpress' and iid = %d and uid = %d limit 1", intval($b['item']['id']), intval($b['item']['uid'])); if (!$r) { return; } $post_id = basename($r[0]['v']); $wp_username = get_pconfig($b['item']['uid'], 'wppost', 'wp_username'); $wp_password = z_unobscure(get_pconfig($b['item']['uid'], 'wppost', 'wp_password')); $wp_blog = get_pconfig($b['item']['uid'], 'wppost', 'wp_blog'); $wp_blogid = get_pconfig($b['uid'], 'wppost', 'wp_blogid'); if (!$wp_blogid) { $wp_blogid = 1; } if ($post_id && $wp_username && $wp_password && $wp_blog) { $client = new IXR_Client($wp_blog); if ($b['item']['id'] == $b['item']['parent']) { $res = $client->query('wp.deletePost', $wp_blogid, $wp_username, $wp_password, $post_id); } else { $res = $client->query('wp.deleteComment', $wp_blogid, $wp_username, $wp_password, $post_id); } if (!$res) { logger('wppost: delete failed.'); return; } $result = intval($client->getResponse()); logger('wppost: delete post returns: ' . $result, LOGGER_DEBUG); } }
/** * Private function for retrieving a users blogs for multisite setups * * @access protected * * @return array|IXR_Error */ protected function _multisite_getUsersBlogs($args) { $current_blog = get_blog_details(); $domain = $current_blog->domain; $path = $current_blog->path . 'xmlrpc.php'; $rpc = new IXR_Client(set_url_scheme("http://{$domain}{$path}")); $rpc->query('wp.getUsersBlogs', $args[1], $args[2]); $blogs = $rpc->getResponse(); if (isset($blogs['faultCode'])) { return new IXR_Error($blogs['faultCode'], $blogs['faultString']); } if ($_SERVER['HTTP_HOST'] == $domain && $_SERVER['REQUEST_URI'] == $path) { return $blogs; } else { foreach ((array) $blogs as $blog) { if (strpos($blog['url'], $_SERVER['HTTP_HOST'])) { return array($blog); } } return array(); } }
function get_language() { global $prefs, $txpcfg, $textarray; require_once txpath . '/lib/IXRClass.php'; $lang_code = gps('lang_code'); $client = new IXR_Client(RPC_SERVER); // $client->debug = true; @set_time_limit(90); if (gps('force') == 'file' || !$client->query('tups.getLanguage', $prefs['blog_uid'], $lang_code)) { if ((gps('force') == 'file' || gps('updating') !== '1') && install_language_from_file($lang_code)) { if (defined('LANG')) { $textarray = load_lang(LANG); } return list_languages(gTxt($lang_code) . sp . gTxt('updated')); } else { $install_langfile = gTxt('install_langfile', array('{url}' => strong('<a href="' . RPC_SERVER . '/lang/">' . RPC_SERVER . '/lang/</a>'))); if ($install_langfile == 'install_langfile') { $install_langfile = 'To install new languages from file you can download them from <b><a href="' . RPC_SERVER . '/lang/">' . RPC_SERVER . '/lang/</a></b> and place them inside your ./textpattern/lang/ directory.'; } pagetop(gTxt('installing_language')); echo tag(gTxt('rpc_connect_error') . "<!--" . $client->getErrorCode() . ' ' . $client->getErrorMessage() . "-->", 'p', ' style="text-align:center;color:red;width:50%;margin: 2em auto"'); echo tag($install_langfile, 'p', ' style="text-align:center;width:50%;margin: 2em auto"'); } } else { $response = $client->getResponse(); $lang_struct = unserialize($response); function install_lang_key(&$value, $key) { extract(gpsa(array('lang_code', 'updating'))); $exists = safe_field('name', 'txp_lang', "name='" . doSlash($value['name']) . "' AND lang='" . doSlash($lang_code) . "'"); $q = "name='" . doSlash($value['name']) . "', event='" . doSlash($value['event']) . "', data='" . doSlash($value['data']) . "', lastmod='" . doSlash(strftime('%Y%m%d%H%M%S', $value['uLastmod'])) . "'"; if ($exists) { $value['ok'] = safe_update('txp_lang', $q, "lang='" . doSlash($lang_code) . "' AND name='" . doSlash($value['name']) . "'"); } else { $value['ok'] = safe_insert('txp_lang', $q . ", lang='" . doSlash($lang_code) . "'"); } } array_walk($lang_struct, 'install_lang_key'); $size = count($lang_struct); $errors = 0; for ($i = 0; $i < $size; $i++) { $errors += !$lang_struct[$i]['ok']; } if (defined('LANG')) { $textarray = load_lang(LANG); } $msg = gTxt($lang_code) . sp . gTxt('updated'); if ($errors > 0) { $msg .= sprintf(" (%s errors, %s ok)", $errors, $size - $errors); } return list_languages($msg); } }