Пример #1
0
 function pugpig_get_edition_and_page_num_from_id($page_id)
 {
     $page_num = -1;
     $edition_num = -1;
     $edition_prefix = get_edition_prefix();
     $prefix_stripped_string = str_replace($edition_prefix, '', $page_id);
     $dot_pos = strpos($prefix_stripped_string, '.');
     if ($dot_pos > 0) {
         $edition_num = intval(substr($prefix_stripped_string, 0, $dot_pos));
         $page_num = intval(substr($prefix_stripped_string, $dot_pos + 1));
     }
     return array('edition_num' => $edition_num, 'page_num' => $page_num);
 }
    case 'edition':
        $edition_num = array_shift($request_params);
        if (empty($edition_num)) {
            reply_wth_message('No edition number specified', HttpStatusCode::BAD_REQUEST);
        }
        if (!is_authorised($edition_num, $pugpigCredsSecret)) {
            reply_unauthorised();
        }
        $subpath = implode("/", $request_params);
        $file = end($request_params);
        $matches = null;
        if ($file === "content.xml") {
            reply_content_xml($edition_num);
        } elseif ($file === "package.xml") {
            reply_package_xml($edition_num);
        } elseif (preg_match('/((.*?)-.*\\.zip)/', $file, $matches) > 0 && get_edition_prefix($matches[2], get_edition_prefix())) {
            reply_package_zip($matches[1]);
        } elseif (preg_match('/page\\-(\\d+).manifest/', $file, $matches) > 0) {
            reply_page_manifest($edition_num, intval($matches[1]), $subpath);
        } elseif (preg_match('/page\\-(\\d+).html/', $file, $matches) > 0) {
            reply_page_html($edition_num, intval($matches[1]));
        } elseif (!empty($subpath)) {
            reply_sub_file($subpath, $edition_num);
        } else {
            reply_wth_message('No edition request specified', HttpStatusCode::BAD_REQUEST);
        }
        break;
    default:
        handle_unknown_command($path_root, $request_params);
        break;
}