示例#1
0
  public Object generateContent(PhpWebEnvironment webEnv) throws IOException, ServletException {

    /* Start of block */
    super.startBlock("__wp_pass_block1");
    gVars.webEnv = webEnv;

    /* Condensed dynamic construct: 513604 */ require(gVars, gConsts, Wp_configPage.class);

    if (booleanval(Options.get_magic_quotes_gpc(gVars.webEnv))) {
      gVars.webEnv._POST.putValue(
          "post_password",
          Strings.stripslashes(gVars.webEnv, strval(gVars.webEnv._POST.getValue("post_password"))));
    }

    // 10 days
    Network.setcookie(
        gVars.webEnv,
        "wp-postpass_" + gConsts.getCOOKIEHASH(),
        strval(gVars.webEnv._POST.getValue("post_password")),
        DateTime.time() + 864000,
        gConsts.getCOOKIEPATH());

    getIncluded(PluggablePage.class, gVars, gConsts)
        .wp_safe_redirect(getIncluded(FunctionsPage.class, gVars, gConsts).wp_get_referer(), 302);

    return DEFAULT_VAL;
  }
示例#2
0
  // convert the exif date format to a unix timestamp
  public int wp_exif_date2ts(String str) {
    // seriously, who formats a date like 'YYYY:MM:DD hh:mm:ss'?
    new ListAssigner<String>() {
      public Array<String> doAssign(Array<String> srcArray) {
        if (strictEqual(srcArray, null)) {
          return null;
        }

        wp_exif_date2ts_date = srcArray.getValue(0);
        wp_exif_date2ts_time = srcArray.getValue(1);

        return srcArray;
      }
    }.doAssign(Strings.explode(" ", Strings.trim(str)));
    new ListAssigner<String>() {
      public Array<String> doAssign(Array<String> srcArray) {
        if (strictEqual(srcArray, null)) {
          return null;
        }

        wp_exif_date2ts_y = srcArray.getValue(0);
        wp_exif_date2ts_m = srcArray.getValue(1);
        wp_exif_date2ts_d = srcArray.getValue(2);

        return srcArray;
      }
    }.doAssign(Strings.explode(":", wp_exif_date2ts_date));

    return QDateTime.strtotime(
        strval(wp_exif_date2ts_y)
            + "-"
            + strval(wp_exif_date2ts_m)
            + "-"
            + strval(wp_exif_date2ts_d)
            + " "
            + strval(wp_exif_date2ts_time));
  }
示例#3
0
  // convert a fraction string to a decimal
  public float wp_exif_frac2dec(String str) {
    new ListAssigner<String>() {
      public Array<String> doAssign(Array<String> srcArray) {
        if (strictEqual(srcArray, null)) {
          return null;
        }

        wp_exif_frac2dec_n = srcArray.getValue(0);
        wp_exif_frac2dec_d = srcArray.getValue(1);

        return srcArray;
      }
    }.doAssign(Strings.explode("/", str));

    if (!empty(wp_exif_frac2dec_d)) {
      return floatval(wp_exif_frac2dec_n) / floatval(wp_exif_frac2dec_d);
    }

    return floatval(str);
  }
示例#4
0
  /**
   * --------------------------------------------------------------------------------
   * --------------------------------------------------------------------------------
   * --------------------------------------------------------------------------------
   * -------------------------------------------------------------------------------- Function :
   * PclZipUtilOptionText() Function : PclZipUtilOptionText() Description : Description : Translate
   * option value in text. Mainly for debug purpose. Translate option value in text. Mainly for
   * debug purpose. Parameters : Parameters : $p_option : the option value. $p_option : the option
   * value. Return Values : Return Values : The option text value. The option text value.
   * --------------------------------------------------------------------------------
   * --------------------------------------------------------------------------------
   */
  public String PclZipUtilOptionText(Object p_option) {
    // Modified by Numiton
    Set<String> v_list = gConsts.constDefs;
    String v_prefix = null;
    String v_result = null;

    for (String v_key : v_list) {
      v_prefix = Strings.substr(v_key, 0, 10);

      if ((equal(v_prefix, "PCLZIP_OPT")
              || equal(v_prefix, "PCLZIP_CB_")
              || equal(v_prefix, "PCLZIP_ATT"))
          && equal(gConsts.getConstantValue(v_key), p_option)) /*
             * --(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_key);
             * --(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_key);
             */ {
        return v_key;
      }
    }

    v_result = "Unknown";

    return v_result;
  }
示例#5
0
  /**
   * --------------------------------------------------------------------------------
   * --------------------------------------------------------------------------------
   * --------------------------------------------------------------------------------
   * -------------------------------------------------------------------------------- Function :
   * PclZipUtilTranslateWinPath() Function : PclZipUtilTranslateWinPath() Description : Description
   * : Translate windows path by replacing '\' by '/' and optionally removing Translate windows path
   * by replacing '\' by '/' and optionally removing drive letter. drive letter. Parameters :
   * Parameters : $p_path : path to translate. $p_path : path to translate. $p_remove_disk_letter :
   * true | false $p_remove_disk_letter : true | false Return Values : Return Values : The path
   * translated. The path translated.
   * --------------------------------------------------------------------------------
   * --------------------------------------------------------------------------------
   */
  public String PclZipUtilTranslateWinPath(String p_path, boolean p_remove_disk_letter) {
    int v_position = 0;

    if (booleanval(Strings.stristr(Options.php_uname(), "windows"))) /*
         * ----- Look for potential disk letter ----- Look for potential disk
         * letter
         *
         * ----- Change potential windows directory separator ----- Change
         * potential windows directory separator
         */ {
      if (p_remove_disk_letter && !equal(v_position = Strings.strpos(p_path, ":"), false)) {
        p_path = Strings.substr(p_path, v_position + 1);
      }

      if ((Strings.strpos(p_path, "\\") > 0) || equal(Strings.substr(p_path, 0, 1), "\\")) {
        p_path = Strings.strtr(p_path, "\\", "/");
      }
    }

    return p_path;
  }
示例#6
0
  // get extended image metadata, exif or iptc as available
  public Array<Object> wp_read_image_metadata(String file) {
    Array<Object> meta = new Array<Object>();
    Array<Object> info = new Array<Object>();
    Array<Object> iptc = new Array<Object>();
    Array<Object> exif = new Array<Object>();

    if (!FileSystemOrSocket.file_exists(gVars.webEnv, file)) {
      return new Array<Object>();
    }

    new ListAssigner<Object>() {
      public Array<Object> doAssign(Array<Object> srcArray) {
        if (strictEqual(srcArray, null)) {
          return null;
        }

        wp_read_image_metadata_sourceImageType = srcArray.getValue(2);

        return srcArray;
      }
    }.doAssign(QImage.getimagesize(gVars.webEnv, file));

    // exif contains a bunch of data we'll probably never need formatted in ways that are difficult
    // to use.
    // We'll normalize it and just extract the fields that are likely to be useful.  Fractions and
    // numbers
    // are converted to floats, dates to unix timestamps, and everything else to strings.
    meta =
        new Array<Object>(
            new ArrayEntry<Object>("aperture", 0),
            new ArrayEntry<Object>("credit", ""),
            new ArrayEntry<Object>("camera", ""),
            new ArrayEntry<Object>("caption", ""),
            new ArrayEntry<Object>("created_timestamp", 0),
            new ArrayEntry<Object>("copyright", ""),
            new ArrayEntry<Object>("focal_length", 0),
            new ArrayEntry<Object>("iso", 0),
            new ArrayEntry<Object>("shutter_speed", 0),
            new ArrayEntry<Object>("title", ""));

    // read iptc first, since it might contain data not available in exif such as caption,
    // description etc
    if (true) /*Modified by Numiton*/ {
      QImage.getimagesize(gVars.webEnv, file, info);

      if (!empty(info.getValue("APP13"))) {
        iptc = new Array<Object>();

        if (!empty(iptc.getArrayValue("2#110").getValue(0))) { // credit
          meta.putValue("credit", Strings.trim(strval(iptc.getArrayValue("2#110").getValue(0))));
        } else if (!empty(iptc.getArrayValue("2#080").getValue(0))) { // byline
          meta.putValue("credit", Strings.trim(strval(iptc.getArrayValue("2#080").getValue(0))));
        }

        if (!empty(iptc.getArrayValue("2#055").getValue(0))
            && !empty(iptc.getArrayValue("2#060").getValue(0))) { // created datee and time
          meta.putValue(
              "created_timestamp",
              QDateTime.strtotime(
                  strval(iptc.getArrayValue("2#055").getValue(0))
                      + " "
                      + strval(iptc.getArrayValue("2#060").getValue(0))));
        }

        if (!empty(iptc.getArrayValue("2#120").getValue(0))) { // caption
          meta.putValue("caption", Strings.trim(strval(iptc.getArrayValue("2#120").getValue(0))));
        }

        if (!empty(iptc.getArrayValue("2#116").getValue(0))) { // copyright
          meta.putValue("copyright", Strings.trim(strval(iptc.getArrayValue("2#116").getValue(0))));
        }

        if (!empty(iptc.getArrayValue("2#005").getValue(0))) { // title
          meta.putValue("title", Strings.trim(strval(iptc.getArrayValue("2#005").getValue(0))));
        }
      }
    }

    // fetch additional info from exif if available
    if (false
        && /*Modified by Numiton*/ Array.in_array(
            wp_read_image_metadata_sourceImageType,
            (Array)
                getIncluded(PluginPage.class, gVars, gConsts)
                    .apply_filters(
                        "wp_read_image_metadata_types",
                        new Array<Object>(
                            new ArrayEntry<Object>(Image.IMAGETYPE_JPEG),
                            new ArrayEntry<Object>(Image.IMAGETYPE_TIFF_II),
                            new ArrayEntry<Object>(Image.IMAGETYPE_TIFF_MM))))) {
      exif = new Array<Object>();

      if (!empty(exif.getValue("FNumber"))) {
        meta.putValue(
            "aperture", Math.round(wp_exif_frac2dec(strval(exif.getValue("FNumber"))), 2));
      }

      if (!empty(exif.getValue("Model"))) {
        meta.putValue("camera", Strings.trim(strval(exif.getValue("Model"))));
      }

      if (!empty(exif.getValue("DateTimeDigitized"))) {
        meta.putValue(
            "created_timestamp", wp_exif_date2ts(strval(exif.getValue("DateTimeDigitized"))));
      }

      if (!empty(exif.getValue("FocalLength"))) {
        meta.putValue("focal_length", wp_exif_frac2dec(strval(exif.getValue("FocalLength"))));
      }

      if (!empty(exif.getValue("ISOSpeedRatings"))) {
        meta.putValue("iso", exif.getValue("ISOSpeedRatings"));
      }

      if (!empty(exif.getValue("ExposureTime"))) {
        meta.putValue("shutter_speed", wp_exif_frac2dec(strval(exif.getValue("ExposureTime"))));
      }
    }

    // FIXME: try other exif libraries if available

    return (Array<Object>)
        getIncluded(PluginPage.class, gVars, gConsts)
            .apply_filters(
                "wp_read_image_metadata", meta, file, wp_read_image_metadata_sourceImageType);
  }
示例#7
0
  /**
   * wp_crop_image() - Crop an Image to a given size.
   *
   * @package WordPress
   * @internal Missing Long Description
   * @param int $src_file The source file
   * @param int $src_x The start x position to crop from
   * @param int $src_y The start y position to crop from
   * @param int $src_w The width to crop
   * @param int $src_h The height to crop
   * @param int $dst_w The destination width
   * @param int $dst_h The destination height
   * @param int $src_abs If the source crop points are absolute
   * @param int $dst_file The destination file to write to
   * @return string New filepath on success, String error message on failure
   */
  public String wp_crop_image(
      Object src_fileObj,
      int src_x,
      int src_y,
      int src_w,
      int src_h,
      int dst_w,
      int dst_h,
      boolean src_abs,
      String dst_file) {
    Object src = null;
    int dst = 0;
    String src_file;

    // Modified by Numiton
    if (is_numeric(src_fileObj)) { // Handle int as attachment ID
      src_file =
          strval(
              getIncluded(PostPage.class, gVars, gConsts)
                  .get_attached_file(intval(src_fileObj), false));
    } else {
      src_file = strval(src_fileObj);
    }

    src = wp_load_image(src_file);

    if (!is_resource(src)) {
      return strval(src);
    }

    dst = Image.imagecreatetruecolor(gVars.webEnv, dst_w, dst_h);

    if (src_abs) {
      src_w = src_w - src_x;
      src_h = src_h - src_y;
    }

    if (true) /*Modified by Numiton*/ {
      Image.imageantialias(gVars.webEnv, dst, true);
    }

    Image.imagecopyresampled(
        gVars.webEnv, dst, intval(src), 0, 0, src_x, src_y, dst_w, dst_h, src_w, src_h);
    Image.imagedestroy(gVars.webEnv, intval(src)); // Free up memory

    if (!booleanval(dst_file)) {
      dst_file =
          Strings.str_replace(
              FileSystemOrSocket.basename(src_file),
              "cropped-" + FileSystemOrSocket.basename(src_file),
              src_file);
    }

    dst_file = QRegExPerl.preg_replace("/\\.[^\\.]+$/", ".jpg", dst_file);

    if (Image.imagejpeg(gVars.webEnv, dst, dst_file)) {
      return dst_file;
    } else {
      return strval(false);
    }
  }
示例#8
0
  public boolean check_post_keyword(boolean precheck) {
    Object metakeys; /* Do not change type */
    int count = 0;
    StdClass post_meta = null;
    Array<String> post_keys = new Array<String>();
    String keyword = null;

    echo(gVars.webEnv, "<div class=\"narrow\">");
    echo(
        gVars.webEnv,
        "<p><h3>"
            + getIncluded(L10nPage.class, gVars, gConsts)
                .__("Reading Bunny&#8217;s Technorati Tags&#8230;", "default")
            + "</h3></p>");

    // import Bunny's Keywords tags
    metakeys =
        gVars.wpdb.get_results(
            "SELECT post_id, meta_id, meta_key, meta_value FROM "
                + gVars.wpdb.postmeta
                + " WHERE "
                + gVars.wpdb.postmeta
                + ".meta_key = \'tags\'");

    if (!is_array(metakeys)) {
      echo(
          gVars.webEnv,
          "<p>"
              + getIncluded(L10nPage.class, gVars, gConsts).__("No Tags Found!", "default")
              + "</p>");

      return false;
    } else {
      count = Array.count(metakeys);
      echo(
          gVars.webEnv,
          "<p>"
              + QStrings.sprintf(
                  getIncluded(L10nPage.class, gVars, gConsts)
                      .__ngettext(
                          "Done! <strong>%s</strong> post with tags were read.",
                          "Done! <strong>%s</strong> posts with tags were read.", count, "default"),
                  count)
              + "<br /></p>");
      echo(gVars.webEnv, "<ul>");

      for (Map.Entry javaEntry50 : ((Array<?>) metakeys).entrySet()) {
        post_meta = (StdClass) javaEntry50.getValue();

        if (!equal(StdClass.getValue(post_meta, "meta_value"), "")) {
          post_keys = Strings.explode(" ", strval(StdClass.getValue(post_meta, "meta_value")));

          for (Map.Entry javaEntry51 : post_keys.entrySet()) {
            keyword = strval(javaEntry51.getValue());
            keyword =
                Strings.addslashes(
                    gVars.webEnv, Strings.trim(Strings.str_replace("+", " ", keyword)));

            if (!equal("", keyword)) {
              echo(
                  gVars.webEnv,
                  "<li>"
                      + StdClass.getValue(post_meta, "post_id")
                      + "&nbsp;-&nbsp;"
                      + keyword
                      + "</li>");

              if (!precheck) {
                getIncluded(PostPage.class, gVars, gConsts)
                    .wp_add_post_tags(intval(StdClass.getValue(post_meta, "post_id")), keyword);
              }
            }
          }
        }

        if (!precheck) {
          getIncluded(PostPage.class, gVars, gConsts)
              .delete_post_meta(intval(StdClass.getValue(post_meta, "post_id")), "tags", "");
        }
      }

      echo(gVars.webEnv, "</ul>");
    }

    echo(
        gVars.webEnv,
        "<form action=\"admin.php?import=btt&amp;step="
            + strval(precheck ? 2 : 3)
            + "\" method=\"post\">");
    getIncluded(FunctionsPage.class, gVars, gConsts)
        .wp_nonce_field("import-btt", "_wpnonce", true, true);
    echo(
        gVars.webEnv,
        "<p class=\"submit\"><input type=\"submit\" name=\"submit\" value=\""
            + getIncluded(L10nPage.class, gVars, gConsts).__("Next", "default")
            + "\" /></p>");
    echo(gVars.webEnv, "</form>");
    echo(gVars.webEnv, "</div>");

    return false;
  }
示例#9
0
  public String PclZipUtilPathReduction(String p_dir) {
    String v_result = null;
    Array<String> v_list = new Array<String>();
    int v_skip = 0;
    int i = 0;
    v_result = "";

    if (!equal(p_dir, "")) /*
         * ----- Explode path by directory names ----- Explode path by directory
         * names
         */

    /*
     * ----- Study directories from last to first ----- Study directories
     * from last to first
     */

    /*
     * ----- Look for skip ----- Look for skip
     */
    {
      v_list = Strings.explode("/", p_dir);
      v_skip = 0;

      for (i = Array.sizeof(v_list) - 1; i >= 0; i--) /*
             * ----- Look for current path ----- Look for current path
             */ {
        /*
         * ----- Ignore this directory ----- Ignore this directory
         * Should be the first $i=0, but no check is done Should be the
         * first $i=0, but no check is done
         */
        if (equal(v_list.getValue(i), ".")) {
        } else if (equal(v_list.getValue(i), "..")) {
          v_skip++;
        } else if (equal(v_list.getValue(i), "")) /*
                 * ----- First '/' i.e. root slash ----- First '/' i.e.
                 * root slash
                 *
                 * ----- Double '/' inside the path ----- Double '/'
                 * inside the path ----- Ignore only the double '//' in
                 * path, ----- Ignore only the double '//' in path, but
                 * not the first and last '/' but not the first and last
                 * '/'
                 */ {
          /*
           * ----- Last '/' i.e. indicates a directory -----
           * Last '/' i.e. indicates a directory
           */
          if (equal(i, 0)) {
            v_result = "/" + v_result;

            if (v_skip > 0) /*
                         * ----- It is an invalid path, so the path is
                         * not modified ----- It is an invalid path, so
                         * the path is not modified TBC TBC
                         */

            /*
             * --(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__,
             * __LINE__, 3, "Invalid path is unchanged");
             * --(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__,
             * __LINE__, 3, "Invalid path is unchanged");
             */
            {
              v_result = p_dir;
              v_skip = 0;
            }
          } else if (equal(i, Array.sizeof(v_list) - 1)) {
            v_result = v_list.getValue(i);
          } else {
          }
        } else /*
                * ----- Look for item to skip ----- Look for item to
                * skip
                */ {
          if (v_skip > 0) {
            v_skip--;
          } else {
            v_result =
                v_list.getValue(i)
                    + ((!equal(i, Array.sizeof(v_list) - 1)) ? ("/" + v_result) : "");
          }
        }
      }

      if (v_skip > 0) {
        while (v_skip > 0) {
          v_result = "../" + v_result;
          v_skip--;
        }
      }
    }

    return v_result;
  }
示例#10
0
  /**
   * --------------------------------------------------------------------------------
   * --------------------------------------------------------------------------------
   * --------------------------------------------------------------------------------
   * -------------------------------------------------------------------------------- Function :
   * PclZipUtilPathInclusion() Function : PclZipUtilPathInclusion() Description : Description : This
   * function indicates if the path $p_path is under the $p_dir tree. Or, This function indicates if
   * the path $p_path is under the $p_dir tree. Or, said in an other way, if the file or sub-dir
   * $p_path is inside the dir said in an other way, if the file or sub-dir $p_path is inside the
   * dir $p_dir. $p_dir. The function indicates also if the path is exactly the same as the dir. The
   * function indicates also if the path is exactly the same as the dir. This function supports path
   * with duplicated '/' like '//', but does not This function supports path with duplicated '/'
   * like '//', but does not support '.' or '..' statements. support '.' or '..' statements.
   * Parameters : Parameters : Return Values : Return Values : 0 if $p_path is not inside directory
   * $p_dir 0 if $p_path is not inside directory $p_dir 1 if $p_path is inside directory $p_dir 1 if
   * $p_path is inside directory $p_dir 2 if $p_path is exactly the same as $p_dir 2 if $p_path is
   * exactly the same as $p_dir
   * --------------------------------------------------------------------------------
   * --------------------------------------------------------------------------------
   */
  public int PclZipUtilPathInclusion(String p_dir, String p_path) {
    int v_result = 0;
    Array<String> v_list_dir = new Array<String>();
    int v_list_dir_size = 0;
    Array<String> v_list_path = new Array<String>();
    int v_list_path_size = 0;
    int i = 0;
    int j = 0;
    v_result = 1;

    if (equal(p_dir, ".")
        || ((Strings.strlen(p_dir) >= 2) && equal(Strings.substr(p_dir, 0, 2), "./"))) {
      p_dir =
          PclZipUtilTranslateWinPath(Directories.getcwd(gVars.webEnv), false)
              + "/"
              + Strings.substr(p_dir, 1);
    }

    if (equal(p_path, ".")
        || ((Strings.strlen(p_path) >= 2) && equal(Strings.substr(p_path, 0, 2), "./"))) {
      p_path =
          PclZipUtilTranslateWinPath(Directories.getcwd(gVars.webEnv), false)
              + "/"
              + Strings.substr(p_path, 1);
    }

    v_list_dir = Strings.explode("/", p_dir);
    v_list_dir_size = Array.sizeof(v_list_dir);
    v_list_path = Strings.explode("/", p_path);
    v_list_path_size = Array.sizeof(v_list_path);
    i = 0;
    j = 0;

    while ((i < v_list_dir_size) && (j < v_list_path_size) && booleanval(v_result)) /*
         * --(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5,
         * "Working on dir($i)='".$v_list_dir[$i]."' and
         * path($j)='".$v_list_path[$j]."'");
         * --(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5,
         * "Working on dir($i)='".$v_list_dir[$i]."' and
         * path($j)='".$v_list_path[$j]."'"); ----- Look for empty dir (path
         * reduction) ----- Look for empty dir (path reduction)
         */

    /*
     * ----- Compare the items ----- Compare the items
     */

    /*
     * ----- Next items ----- Next items
     */
    {
      if (equal(v_list_dir.getValue(i), "")) {
        i++;

        continue;
      }

      if (equal(v_list_path.getValue(j), "")) {
        j++;

        continue;
      }

      if (!equal(v_list_dir.getValue(i), v_list_path.getValue(j))
          && !equal(v_list_dir.getValue(i), "")
          && !equal(v_list_path.getValue(j), "")) /*
             * --(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5,
             * "Items ($i,$j) are different");
             * --(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5,
             * "Items ($i,$j) are different");
             */ {
        v_result = 0;
      }

      i++;
      j++;
    }

    if (booleanval(v_result)) /*
         * --(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Look
         * for tie break"); --(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__,
         * __LINE__, 5, "Look for tie break"); ----- Skip all the empty items
         * ----- Skip all the empty items
         */

    /*
     * ??$v_list_path[$j]:'')."'"); $v_list_path[$j]:'')."'");
     */
    {
      while ((j < v_list_path_size) && equal(v_list_path.getValue(j), "")) j++;

      while ((i < v_list_dir_size) && equal(v_list_dir.getValue(i), "")) i++;

      if ((i >= v_list_dir_size) && (j >= v_list_path_size)) /*
             * ----- There are exactly the same ----- There are exactly the same
             */ {
        v_result = 2;
      } else if (i < v_list_dir_size) /*
             * ----- The path is shorter than the dir ----- The path is
             * shorter than the dir
             */ {
        v_result = 0;
      }
    }

    return v_result;
  }
示例#11
0
  /**
   * get_bookmarks() - Retrieves the list of bookmarks
   *
   * <p>Attempts to retrieve from the cache first based on MD5 hash of arguments. If that fails,
   * then the query will be built from the arguments and executed. The results will be stored to the
   * cache.
   *
   * <p>List of default arguments are as follows: 'orderby' - Default is 'name' (string). How to
   * order the links by. String is based off of the bookmark scheme. 'order' - Default is 'ASC'
   * (string). Either 'ASC' or 'DESC'. Orders in either ascending or descending order. 'limit' -
   * Default is -1 (integer) or show all. The amount of bookmarks to display. 'category' - Default
   * is empty string (string). Include the links in what category ID(s). 'category_name' - Default
   * is empty string (string). Get links by category name. 'hide_invisible' - Default is 1
   * (integer). Whether to show (default) or hide links marked as 'invisible'. 'show_updated' -
   * Default is 0 (integer). Will show the time of when the bookmark was last updated. 'include' -
   * Default is empty string (string). Include other categories separated by commas. 'exclude' -
   * Default is empty string (string). Exclude other categories separated by commas.
   *
   * @since 2.1
   * @uses $wpdb Database Object
   * @param string|array $args List of arguments to overwrite the defaults
   * @return array List of bookmark row objects
   */
  public Array<Object> get_bookmarks(Object args) {
    Array<Object> defaults = new Array<Object>();
    Array<Object> r = null;
    String key = null;
    Array<Object> cache = new Array<Object>();
    String inclusions = null;
    String include = null;
    String exclude = null;
    String category = null;
    String category_name = null;
    Array<Object> inclinks = new Array<Object>();
    Object inclink = null;
    String exclusions = null;
    Array<Object> exlinks = new Array<Object>();
    Object exlink = null;
    String search = null;
    String category_query = null;
    String join = null;
    Array<Object> incategories = new Array<Object>();
    Object incat = null;
    String recently_updated_test = null;
    String get_updated = null;
    Object show_updated = null;
    String orderby = null;
    String length = null;
    String visible = null;
    Object hide_invisible = null;
    String query = null;
    Object order = null;
    Object limit = null;
    Array<Object> results = new Array<Object>();
    defaults =
        new Array<Object>(
            new ArrayEntry<Object>("orderby", "name"),
            new ArrayEntry<Object>("order", "ASC"),
            new ArrayEntry<Object>("limit", -1),
            new ArrayEntry<Object>("category", ""),
            new ArrayEntry<Object>("category_name", ""),
            new ArrayEntry<Object>("hide_invisible", 1),
            new ArrayEntry<Object>("show_updated", 0),
            new ArrayEntry<Object>("include", ""),
            new ArrayEntry<Object>("exclude", ""),
            new ArrayEntry<Object>("search", ""));
    r = getIncluded(FunctionsPage.class, gVars, gConsts).wp_parse_args(args, defaults);
    include = strval(Array.extractVar(r, "include", include, Array.EXTR_SKIP));
    exclude = strval(Array.extractVar(r, "exclude", exclude, Array.EXTR_SKIP));
    category = strval(Array.extractVar(r, "category", category, Array.EXTR_SKIP));
    category_name = strval(Array.extractVar(r, "category_name", category_name, Array.EXTR_SKIP));
    search = strval(Array.extractVar(r, "search", search, Array.EXTR_SKIP));
    show_updated = Array.extractVar(r, "show_updated", show_updated, Array.EXTR_SKIP);
    orderby = strval(Array.extractVar(r, "orderby", orderby, Array.EXTR_SKIP));
    hide_invisible = Array.extractVar(r, "hide_invisible", hide_invisible, Array.EXTR_SKIP);
    order = Array.extractVar(r, "order", order, Array.EXTR_SKIP);
    limit = Array.extractVar(r, "limit", limit, Array.EXTR_SKIP);
    key = Strings.md5(serialize(r));

    if (booleanval(
        cache =
            (Array<Object>)
                getIncluded(CachePage.class, gVars, gConsts)
                    .wp_cache_get("get_bookmarks", "bookmark"))) {
      if (isset(cache.getValue(key))) {
        return (Array<Object>)
            getIncluded(PluginPage.class, gVars, gConsts)
                .apply_filters("get_bookmarks", cache.getValue(key), r);
      }
    } else {
      cache = new Array<Object>();
    }

    inclusions = "";

    if (!empty(include)) {
      exclude = ""; // ignore exclude, category, and category_name params if using include
      category = "";
      category_name = "";
      inclinks = QRegExPerl.preg_split("/[\\s,]+/", include);

      if (booleanval(Array.count(inclinks))) {
        for (Map.Entry javaEntry380 : inclinks.entrySet()) {
          inclink = javaEntry380.getValue();

          if (empty(inclusions)) {
            inclusions = " AND ( link_id = " + strval(inclink) + " ";
          } else {
            inclusions = inclusions + " OR link_id = " + strval(inclink) + " ";
          }
        }
      }
    }

    if (!empty(inclusions)) {
      inclusions = inclusions + ")";
    }

    exclusions = "";

    if (!empty(exclude)) {
      exlinks = QRegExPerl.preg_split("/[\\s,]+/", exclude);

      if (booleanval(Array.count(exlinks))) {
        for (Map.Entry javaEntry381 : exlinks.entrySet()) {
          exlink = javaEntry381.getValue();

          if (empty(exclusions)) {
            exclusions = " AND ( link_id <> " + strval(exlink) + " ";
          } else {
            exclusions = exclusions + " AND link_id <> " + strval(exlink) + " ";
          }
        }
      }
    }

    if (!empty(exclusions)) {
      exclusions = exclusions + ")";
    }

    if (!empty(category_name)) {
      StdClass categoryObj;

      if (booleanval(
          categoryObj =
              (StdClass)
                  getIncluded(TaxonomyPage.class, gVars, gConsts)
                      .get_term_by(
                          "name", category_name, "link_category", gConsts.getOBJECT(), "raw"))) {
        category = strval(StdClass.getValue(categoryObj, "term_id"));
      }
    }

    if (!empty(search)) {
      search = getIncluded(FormattingPage.class, gVars, gConsts).like_escape(search);
      search =
          " AND ( (link_url LIKE \'%"
              + search
              + "%\') OR (link_name LIKE \'%"
              + search
              + "%\') OR (link_description LIKE \'%"
              + search
              + "%\') ) ";
    }

    category_query = "";
    join = "";

    if (!empty(category)) {
      incategories = QRegExPerl.preg_split("/[\\s,]+/", category);

      if (booleanval(Array.count(incategories))) {
        for (Map.Entry javaEntry382 : incategories.entrySet()) {
          incat = javaEntry382.getValue();

          if (empty(category_query)) {
            category_query = " AND ( tt.term_id = " + strval(incat) + " ";
          } else {
            category_query = category_query + " OR tt.term_id = " + strval(incat) + " ";
          }
        }
      }
    }

    if (!empty(category_query)) {
      category_query = category_query + ") AND taxonomy = \'link_category\'";
      join =
          " INNER JOIN "
              + gVars.wpdb.term_relationships
              + " AS tr ON ("
              + gVars.wpdb.links
              + ".link_id = tr.object_id) INNER JOIN "
              + gVars.wpdb.term_taxonomy
              + " as tt ON tt.term_taxonomy_id = tr.term_taxonomy_id";
    }

    if (booleanval(
        getIncluded(FunctionsPage.class, gVars, gConsts)
            .get_option("links_recently_updated_time"))) {
      recently_updated_test =
          ", IF (DATE_ADD(link_updated, INTERVAL "
              + getIncluded(FunctionsPage.class, gVars, gConsts)
                  .get_option("links_recently_updated_time")
              + " MINUTE) >= NOW(), 1,0) as recently_updated ";
    } else {
      recently_updated_test = "";
    }

    get_updated =
        (booleanval(show_updated) ? ", UNIX_TIMESTAMP(link_updated) AS link_updated_f " : "");
    orderby = Strings.strtolower(orderby);
    length = "";

    {
      int javaSwitchSelector38 = 0;

      if (equal(orderby, "length")) {
        javaSwitchSelector38 = 1;
      }

      if (equal(orderby, "rand")) {
        javaSwitchSelector38 = 2;
      }

      switch (javaSwitchSelector38) {
        case 1:
          {
            length = ", CHAR_LENGTH(link_name) AS length";

            break;
          }

        case 2:
          {
            orderby = "rand()";

            break;
          }

        default:
          orderby = "link_" + orderby;
      }
    }

    if (equal("link_id", orderby)) {
      orderby = gVars.wpdb.links + ".link_id";
    }

    visible = "";

    if (booleanval(hide_invisible)) {
      visible = "AND link_visible = \'Y\'";
    }

    query =
        "SELECT * "
            + length
            + " "
            + recently_updated_test
            + " "
            + get_updated
            + " FROM "
            + gVars.wpdb.links
            + " "
            + join
            + " WHERE 1=1 "
            + visible
            + " "
            + category_query;
    query = query + " " + exclusions + " " + inclusions + " " + search;
    query = query + " ORDER BY " + orderby + " " + strval(order);

    if (!equal(limit, -1)) {
      query = query + " LIMIT " + strval(limit);
    }

    results = gVars.wpdb.get_results(query);
    cache.putValue(key, results);
    getIncluded(CachePage.class, gVars, gConsts)
        .wp_cache_set("get_bookmarks", cache, "bookmark", 0);

    return (Array<Object>)
        getIncluded(PluginPage.class, gVars, gConsts).apply_filters("get_bookmarks", results, r);
  }