/** * send a content to a destination. * * @param integer id of user. * @param array content details. * @param integer names of destinations. */ public function send($user_id, $blog_post, $destination_names) { Logger::log("Enter: function ContentRouting::send()"); global $path_prefix; if ($destination_names[0]) { foreach ($destination_names[0] as $destination) { $sql = "SELECT * FROM {content_routing_destinations}, {routing_destination_types} WHERE user_id = ? AND blog_name = ? AND blog_type = destination_id"; $res = Dal::query($sql, array($user_id, addslashes($destination))); if ($res->numRows() > 0) { $row = $res->fetchRow(DB_FETCHMODE_OBJECT); $blogurl = $row->blog_url; $username = $row->user_name; $password = $row->password; $type = $row->destination_name; require_once "{$path_prefix}/destination/{$type}/{$type}.php"; $dest = new $type(); $dest->send($blog_post, $blogurl, $username, $password); } } } if ($destination_names[1]) { $sql = "SELECT * FROM {content_routing_destinations} WHERE blog_type = ?"; $res = Dal::query($sql, array(4)); if ($res->numRows() > 0) { $row = $res->fetchRow(DB_FETCHMODE_OBJECT); $username = $row->user_name; $password = $row->password; $blogurl = $row->blog_url; require_once "{$path_prefix}/destination/OutputThis/OutputThis.php"; $dest = new OutputThis(); $dest->send($blog_post, $destination_names[1], $username, $password); } } Logger::log("Exit: function ContentRouting::send()"); return; }
function route_to_outputthis($title, $body) { global $outputthis_username, $outputthis_password, $error_message; $external_targets = isset($_POST) && isset($_POST['route_targets_external']) ? $_POST['route_targets_external'] : array(); /* Selected external targets array */ //p($external_targets); if (count($external_targets)) { /* User has selected something from external targets */ if (in_array(ROUTE_TO_NONE, $external_targets)) { $error_message[] = 'Content has not been routed to any of your external blog'; } else { if (in_array(ROUTE_TO_ALL, $external_targets)) { $external_targets = $_POST['Allexternal_blog']; /* All external targets array */ } } for ($i = 0; $i < count($external_targets); $i++) { $blog_post = array('title' => $title, 'body' => $body); if (!empty($outputthis_username) && !empty($outputthis_password)) { $return = OutputThis::send($blog_post, array($external_targets[$i]), $outputthis_username, $outputthis_password); if ($return == 1) { /* routing successfull to external blog */ $error_message[] = 'Post routed successfully to ' . get_target_name($external_targets[$i]); } else { $error_message[] = 'Post routed failed for ' . get_target_name($external_targets[$i]) . '. ' . $return[1]; } } } } }