/**
  * This method returns daily statistics for a zone for a specified period.
  *
  * @param int $zoneId
  * @param Pear::Date $oStartDate
  * @param Pear::Date $oEndDate
  * @return array  result data
  */
 function zoneDailyStatistics($zoneId, $oStartDate = null, $oEndDate = null, $useManagerTimezone = false)
 {
     $statisticsData = $this->_callStatisticsMethod('ox.zoneDailyStatistics', $zoneId, $oStartDate, $oEndDate, $useManagerTimezone);
     foreach ($statisticsData as $key => $data) {
         $statisticsData[$key]['day'] = date('Y-m-d', XML_RPC_iso8601_decode($data['day']));
     }
     return $statisticsData;
 }
 /**
  * This method returns daily statistics for a zone for a specified period.
  *
  * @param int $zoneId
  * @param Pear::Date $oStartDate
  * @param Pear::Date $oEndDate
  * @return array  result data
  */
 function zoneDailyStatistics($zoneId, $oStartDate = null, $oEndDate = null)
 {
     $statisticsData = $this->_callStatisticsMethod('ZoneXmlRpcService.php', 'zoneDailyStatistics', $zoneId, $oStartDate, $oEndDate);
     foreach ($statisticsData as $key => $data) {
         $statisticsData[$key]['day'] = date('Y-m-d', XML_RPC_iso8601_decode($data['day']));
     }
     return $statisticsData;
 }
Exemplo n.º 3
0
 function unwrap($value)
 {
     switch ($value->kindOf()) {
         case 'scalar':
             switch ($value->scalartyp()) {
                 case 'dateTime.iso8601':
                     $result = XML_RPC_iso8601_decode($value->scalarval());
                     $result = date('Y-m-d H:i', $result);
                     break;
                 case 'boolean':
                     $result = $value->scalarval();
                     break;
                 case 'int':
                     $result = $value->scalarval();
                     break;
                 default:
                     $result = $value->scalarval();
                     break;
             }
             break;
         case 'array':
             $result_size = $value->arraysize();
             $result = array();
             for ($i = 0; $i < $result_size; $i++) {
                 $result[] = $this->unwrap($value->arraymem($i));
             }
             break;
         case 'struct':
             $value->structreset();
             $result = array();
             while (list($key, $val) = $value->structeach()) {
                 $result[$key] = $this->unwrap($val);
             }
             break;
     }
     return $result;
 }
function metaWeblog_editPost($message)
{
    global $serendipity;
    $val = $message->params[0];
    $postid = (int) $val->getval();
    $val = $message->params[1];
    $username = $val->getval();
    $val = $message->params[2];
    $password = $val->getval();
    if (!serendipity_authenticate_author($username, $password)) {
        return new XML_RPC_Response('', XMLRPC_ERR_CODE_AUTHFAILED, XMLRPC_ERR_NAME_AUTHFAILED);
    }
    $val = $message->params[3];
    if (is_object($val)) {
        $post_array = XML_RPC_decode($val);
    } else {
        $post_array = $val->getval();
    }
    $publish = 0;
    if (count($message->params) > 4) {
        // Some clients don't even send this!
        $val = $message->params[4];
        $publish = $val->getval();
    }
    if (XMLRPC_WP_COMPATIBLE) {
        if ($post_array['post_status'] == 'draft') {
            $publish = 0;
        } else {
            if ($post_array['post_status'] == 'publish') {
                $publish = 1;
            }
        }
    }
    if (isset($post_array['categories'])) {
        $entry['categories'] = universal_fetchCategories($post_array['categories']);
    }
    $entry['title'] = @html_entity_decode($post_array['title'], ENT_COMPAT, 'UTF-8');
    if (!isset($post_array['mt_text_more']) || empty($post_array['mt_text_more'])) {
        $entry = universal_splitMore($entry, $post_array['description']);
    } else {
        $entry['body'] = universal_autohtml($post_array['description']);
        $entry['extended'] = universal_autohtml($post_array['mt_text_more']);
    }
    $entry['isdraft'] = $publish == 0 ? 'true' : 'false';
    $entry['author'] = $username;
    $entry['authorid'] = $serendipity['authorid'];
    $entry['id'] = $postid;
    $entry['allow_comments'] = serendipity_db_bool($post_array['mt_allow_comments']);
    // Set tags as if it was set from editor. The plugins reads them from POST
    if (!empty($post_array['mt_keywords'])) {
        if (empty($serendipity['POST'])) {
            $serendipity['POST'] = array();
        }
        $serendipity['POST']['properties']['freetag_tagList'] = $post_array['mt_keywords'];
        $serendipity['POST']['properties']['microblogging_tagList'] = $post_array['mt_keywords'];
    }
    // Remember old geo coords for clients not resaving them:
    $entry_properties = serendipity_fetchEntryProperties($postid);
    if (is_array($entry_properties)) {
        $old_geo_long = $entry_properties['geo_long'];
        $old_geo_lat = $entry_properties['geo_lat'];
    }
    if (isset($post_array['dateCreated']) || isset($post_array['date_created_gmt'])) {
        if (isset($post_array['date_created_gmt'])) {
            $timestamp = XML_RPC_iso8601_decode($post_array['date_created_gmt'], 1);
        } else {
            $timestamp = XML_RPC_iso8601_decode($post_array['dateCreated'], $post_array['dateCreated'][strlen($post_array['dateCreated']) - 1] == "Z");
        }
        $entry['timestamp'] = $timestamp;
    } else {
        // Get the original date, if no new date was defined
        $oldEntry = serendipity_fetchEntry('id', $postid, true, 'true');
        $entry['timestamp'] = $oldEntry['timestamp'];
    }
    ob_start();
    if ($entry['id']) {
        universal_fixEntry($entry);
        $id = universal_updertEntry($entry);
    } else {
        $id = 0;
    }
    // Apply password has to be after serendipity_updertEntry, else it will override it empty!
    universal_save_entrypassword($postid, isset($post_array['wp_password']) ? $post_array['wp_password'] : null);
    //if plugins want to manage it, let's instantiate all non managed meta
    if ($id) {
        $entry['mt_keywords'] = $post_array['mt_keywords'];
        // Resave old geo coord values (if not set by client)
        if (!empty($old_geo_lat) && !empty($old_geo_long)) {
            $entry['geo_lat'] = $old_geo_lat;
            $entry['geo_long'] = $old_geo_long;
        }
        // check for custom fields
        if (isset($post_array['custom_fields'])) {
            $custom_fields = $post_array['custom_fields'];
            if (is_array($custom_fields)) {
                foreach ($custom_fields as $custom_field) {
                    if (isset($custom_field['key'])) {
                        if ('geo_latitude' == $custom_field['key']) {
                            $entry['geo_lat'] = $custom_field['value'];
                        } else {
                            if ('geo_longitude' == $custom_field['key']) {
                                $entry['geo_long'] = $custom_field['value'];
                            } else {
                                if ('geo_public' == $custom_field['key']) {
                                    $entry['geo_public'] = $custom_field['value'];
                                }
                            }
                        }
                    }
                }
                // If switched off by client, unset this
                if (isset($entry['geo_public']) && !$entry['geo_public']) {
                    unset($entry['geo_lat']);
                    unset($entry['geo_long']);
                }
            }
        }
        serendipity_plugin_api::hook_event('xmlrpc_updertEntry', $entry);
    }
    ob_clean();
    return new XML_RPC_Response(new XML_RPC_Value($id ? true : false, 'boolean'));
}
Exemplo n.º 5
0
 function unwrap($value)
 {
     if (is_object($value)) {
         switch ($value->kindOf()) {
             case 'scalar':
                 switch ($value->scalartyp()) {
                     case 'dateTime.iso8601':
                         $result = XML_RPC_iso8601_decode($value->scalarval());
                         $result = date('Y-m-d H:i', $result);
                         break;
                     case 'boolean':
                         $result = $value->scalarval();
                         break;
                     case 'int':
                         $result = $value->scalarval();
                         break;
                     default:
                         $result = $value->scalarval();
                         break;
                 }
                 break;
             case 'array':
                 $result_size = $value->arraysize();
                 $result = array();
                 for ($i = 0; $i < $result_size; $i++) {
                     $result[] = $this->unwrap($value->arraymem($i));
                 }
                 break;
             case 'struct':
                 $value->structreset();
                 $result = array();
                 while (list($key, $val) = $value->structeach()) {
                     $result[$key] = $this->unwrap($val);
                 }
                 break;
         }
     } else {
         syslog(LOG_ERR, sprintf('unwrap encountered a non-object of type %s', gettype($value)));
         return null;
     }
     return $result;
 }