예제 #1
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));
  }
예제 #2
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);
  }
예제 #3
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;
  }
예제 #4
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;
  }
예제 #5
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;
  }