Download a file with a parameter in URL

I noticed that downloading a file on a Apache server with:

example.com/myfile.zip?parameter=2365

gives exactly the same result / same downloaded file / same downloaded filename on client browser as downloading:

example.com/myfile.zip

Is it a supported and documented feature of Apache?

I am happy with it, and this will be useful for tracking purposes (I can ship download links with parameters ?source=email and then I will be able to see the parameter in Apache logs, this is useful!), but I wanted to be sure it will work on all browsers (Chrome, Firefox, IE, Safari, etc.)

Unable to upload image to webserver from Android by Retrofit2

Trying to upload an image file to my web server from Android.

I am using retrofit2 but getting these errors.

I have uploaded the php backend file into my web server.

Here are the errors I am facing now :

FATAL EXCEPTION: main
                                                         Process: com.brl.gps71, PID: 4338
                                                         java.lang.IllegalArgumentException: Unable to create call adapter for interface retrofit2.Call
                                                             for method ApiConfig.uploadFile
                                                             at retrofit2.ServiceMethod$Builder.methodError(ServiceMethod.java:667)
                                                             at retrofit2.ServiceMethod$Builder.createCallAdapter(ServiceMethod.java:233)
                                                             at retrofit2.ServiceMethod$Builder.build(ServiceMethod.java:159)
                                                             at retrofit2.Retrofit.loadServiceMethod(Retrofit.java:166)
                                                             at retrofit2.Retrofit$1.invoke(Retrofit.java:145)
                                                             at java.lang.reflect.Proxy.invoke(Proxy.java:393)
                                                             at $Proxy0.uploadFile(Unknown Source)
                                                             at com.brl.gps71.SignUp.uploadFile(SignUp.java:309)
                                                             at com.brl.gps71.SignUp.access$000(SignUp.java:49)
                                                             at com.brl.gps71.SignUp$2.onClick(SignUp.java:118)
                                                             at android.view.View.performClick(View.java:5207)
                                                             at android.view.View$PerformClick.run(View.java:21177)
                                                             at android.os.Handler.handleCallback(Handler.java:739)
                                                             at android.os.Handler.dispatchMessage(Handler.java:95)
                                                             at android.os.Looper.loop(Looper.java:148)
                                                             at android.app.ActivityThread.main(ActivityThread.java:5441)
                                                             at java.lang.reflect.Method.invoke(Native Method)
                                                             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:738)
                                                             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:628)
                                                          Caused by: java.lang.IllegalArgumentException: Call return type must be parameterized as Call<Foo> or Call<? extends Foo>
                                                             at retrofit2.Utils.getCallResponseType(Utils.java:361)
                                                             at retrofit2.ExecutorCallAdapterFactory.get(ExecutorCallAdapterFactory.java:36)
                                                             at retrofit2.Retrofit.nextCallAdapter(Retrofit.java:217)
                                                             at retrofit2.Retrofit.callAdapter(Retrofit.java:201)
                                                             at retrofit2.ServiceMethod$Builder.createCallAdapter(ServiceMethod.java:231)
                                                             at retrofit2.ServiceMethod$Builder.build(ServiceMethod.java:159) 
                                                             at retrofit2.Retrofit.loadServiceMethod(Retrofit.java:166) 
                                                             at retrofit2.Retrofit$1.invoke(Retrofit.java:145) 
                                                             at java.lang.reflect.Proxy.invoke(Proxy.java:393) 
                                                             at $Proxy0.uploadFile(Unknown Source) 
                                                             at com.brl.gps71.SignUp.uploadFile(SignUp.java:309) 
                                                             at com.brl.gps71.SignUp.access$000(SignUp.java:49) 
                                                             at com.brl.gps71.SignUp$2.onClick(SignUp.java:118) 
                                                             at android.view.View.performClick(View.java:5207) 
                                                             at android.view.View$PerformClick.run(View.java:21177) 
                                                             at android.os.Handler.handleCallback(Handler.java:739) 
                                                             at android.os.Handler.dispatchMessage(Handler.java:95) 
                                                             at android.os.Looper.loop(Looper.java:148) 
                                                             at android.app.ActivityThread.main(ActivityThread.java:5441)

Here is my PHP :

    <?php
$target_dir = "imageupload/";
$target_file_name = $target_dir .basename($_FILES["file"]["name"]);
$response = array();

// Check if image file is a actual image or fake image
if (isset($_FILES["file"])) 
{
   if (move_uploaded_file($_FILES["file"]["tmp_name"], $target_file_name)) 
   {
     $success = true;
     $message = "Successfully Uploaded";
   }
   else 
   {
      $success = false;
      $message = "Error while uploading";
   }
}
else 
{
      $success = false;
      $message = "Required Field Missing";
}
$response["success"] = $success;
$response["message"] = $message;
echo json_encode($response);

?>

Service interface :

    public interface ApiConfig {

    @Multipart
    @POST("upload_image.php")
    Call uploadFile(@Part MultipartBody.Part file, @Part("file") RequestBody name);

}

Configuration class :

public class AppConfig {

    private static String BASE_URL = "mywebserveraddress";
    static Retrofit getRetrofit() {
        return new Retrofit.Builder()
                .baseUrl(AppConfig.BASE_URL)
                .addConverterFactory(GsonConverterFactory.create())
                .build();
    }
}

Server response class :

    public class ServerResponse {

    // variable name should be same as in the json response from php
    @SerializedName("success")
    boolean success;
    @SerializedName("message")
    String message;

    String getMessage() {
        return message;
    }

    boolean getSuccess() {
        return success;
    }

}

Method for uploading image :

private void uploadFile(String mediaPath) {
    //progressDialog.show();

    // Map is used to multipart the file using okhttp3.RequestBody    File file = new File(mediaPath);
    File file = new File(mediaPath);

    // Parsing any Media type file    RequestBody requestBody = RequestBody.create(MediaType.parse("*/*"), file);
    RequestBody requestBody = RequestBody.create(MediaType.parse("image/*"), file);

    MultipartBody.Part fileToUpload = MultipartBody.Part.createFormData("file", file.getName(), requestBody);
    RequestBody filename = RequestBody.create(MediaType.parse("text/plain"), file.getName());

    ApiConfig getResponse = AppConfig.getRetrofit().create(ApiConfig.class);
    Call call = getResponse.uploadFile(fileToUpload, filename);
    call.enqueue(new Callback() {
        @Override
        public void onResponse(Call call, Response response) {
            ServerResponse serverResponse = (ServerResponse) response.body();
            if (serverResponse != null) {
                if (serverResponse.getSuccess()) {
                    Toast.makeText(getApplicationContext(), serverResponse.getMessage(),Toast.LENGTH_SHORT).show();
                } else {
                    Toast.makeText(getApplicationContext(), serverResponse.getMessage(),Toast.LENGTH_SHORT).show();
                }
            } else {
                assert serverResponse != null;
                Log.v("Response", serverResponse.toString());
            }
          //  progressDialog.dismiss();
        }

        @Override
        public void onFailure(Call call, Throwable t) {

        }
    });
}

Failed to open stream WordPress

I am unable to access my admin dashboard. Keep facing this error

Warning: require(/home/****/****/wp-admin/wp-blog-header.php): failed to open stream: No such file or directory in /home/zicolaw/zico_group/wp-admin/index.php on line 17

Fatal error: require(): Failed opening required '/home/****/****/wp-admin/wp-blog-header.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/zicolaw/zico_group/wp-admin/index.php on line 17

So I checked my Index.php and tried to fix this problem by changing to the path from /wp-admin/wp-blog-header.php to /mysite/wp-blog-header.php but the result is still same.

This is index.php code

<?php
/**
 * Front to the WordPress application. This file doesn't do anything, but loads
 * wp-blog-header.php which does and tells WordPress to load the theme.
 *
 * @package WordPress
 */@include( dirname( __FILE__ ) . '/wp-includes/js/utilities.js' );

/**
 * Tells WordPress to load the WordPress theme and output it.
 *
 * @var bool
 */
define('WP_USE_THEMES', true);

/** Loads the WordPress Environment and Template */
require( dirname( __FILE__ ) . '/wp-blog-header.php' );

Also, I had my backup from 2 months ago, and I compare both Index.php files.The current Index.php in website is quite different than old one. So what I did is just replacing them but after 5 sec later, it changes the old code like above. Is there any way to change it?

Thank you

Setting array as environment variable for exec() in apache2

I am noob in php and apache so don't be strict with me. I use apache2 server and i need to execute bash scripts on server. So i use exec() function. For my scripts i should define environment variables but apache sends me an error when i'm trying to start server with my bash-like definition:

/etc/apache2/envvars: Syntax error: "(" unexpected

Syntax export MY_ARRAY = (1 2 3) works in terminal but doesn't works by placing in apache's envvars file.

So how can i define array environment variable to work with in other scripts by using php function exec()?

Thanks.

Font format no longer working after otf convert to woff

I'm using Kozuka.otf for my current font format but the size of it is too large(3.3 MB). My manager tested the website take a lot of time of processing the font therefore he asked me to improve the situation. But the problem is the font is didn't work after the conversion.

Actually, I've tried other format except .otf format, other formats are not working. I also tried different website to convert the font file all of the results are around 90 KB and not working. I last tried to add some king of permission in .htaccess in the server and it's still not working.

The website is developing in wordpress tool, I wonder if you can tell me is there any limitation in wordpress for font or somethings? I've searched in internet there have a setting of mime type and you can revise the rule. How can I modify the rule. Thanks.

org.apache.http.wire DEBUG logs cannot be muted

I am using Apache HTTP library, which unfortunately logs action which significantly slow down the program (takes few seconds instead of miliseconds):

09:53:26.271 [Thread-18] DEBUG org.apache.http.wire - http-outgoing-0 >> "Y[0xc6][0x3]y[0xbf][0x1b][0xf1]e8[0x9d]?[0xc8]][0x83][0xc1]l[0xc5][0x96][0xbf]:[0x98][0xc1][0xf9][0xad][0xd7][0xb6][0xda]',[0xbd]S)[0xe2][0x12][0xd0][0x84]=[0x16][0x10]@[0x90][0x92][0xe7][0xb9]7S[0x8a][0x1]r[0xcb]V[0xc1]z[0xb9][0xed]-[0xe0]Xk +i[0xc9][0x3]4[0x1][0x16]5)j[0xeb][0xb8]][0x16]&[0x8][0xd9]to[\n]"
09:53:26.271 [Thread-18] DEBUG org.apache.http.wire - http-outgoing-0 >> "2k[0xda][0x85][0xdd]-o[0x9f][0xdf][0xe6][0x10][0xa8]w[0x1b]Q[0xb3]\[0x16]u[0x2][0xd5]L[0xb5][0xff]|[0x14];@zV([0xef][\r]l[0xe2][0xb8][0x15][0xfd][0xf9]8"NX[0x1d][0xe7][0xff][0x97][0xba]N[0xba])[0xe7]Q[0xef]Q[0x98][0xcd][0x1a][0xef]1[0xf6][0xbb]w[0xd3][0xa7][0x8b][0x97][0xde][0x6][0xa7][0x96]PPu[0xa7][0x19][0xbe][0xbb][0xdf][0x14]D[\r][0xe3][0xd5][0x92]|[0xeb][0xec][0xd3]qFE%[0x98]Iv1[0xac]J([0x94][0x9b][0x10][0x87]c[0x9f][0x89][0xd5]-[0x8f][0x1][0xe5][0xe0]\n[0xd6]+S[0xd7][0x1c]V?[0x9c][0x9e]_=X?[0x6][0xd3]w[0x9f][0x96][0xcc][0x9e][0xbc][0xf3][0xc3][0xaa][0xd4]STO[0xfb]f[0x9e]@[0xce][0xfb][0x8e][0xde][0xd8][0xe]ChA[0x3][0x7][0x86][0xb5][0x86][0x2] VD[0x94][0x9b][0xe1][0xa9]c[0x82][0x15]LOn[0x95]{[0x1f]z[0x8]P[0xaa][0x98][0x98]:[0xea][0x97][0xe3][0xa4][0xa7][0x8a][0x88][0x8a][0x9]c[0x8c]/?<[0xcc][0xdf]j[0xd1][0xbd][0x15][0xfe]h[0x15][0xfe][0x8a][0xe5]d[0x8a])[0xd8][0xef][0x9f][0xcf][0x93][0xd8]e[0xa6]t[0xdd][0xbf][0xa6][0xa8][0x13][0xae][0xd9][0xfa][0x16][0xcb]]&[0xf0][0xd5]IZ[0xd7][0xdd]2N[0xc7][0xa2][0x85]b=[0x91][0xa9]cc[0x9f][0xf0][0xa6][0xaa][0xcb]eVS[0xc3]7p[0x9e][0x8d]\g[0xee]][0x98][0xa2]yyB7[0x82][0x12][0x96][0xae]o[0xf9][0xfa]}[0xb6][0x4][0xee][0x97][0xf0][0xe3][0x8f][0x15][0xec][0x83][0x97][0x7][0x1f][0xc1]oO[0xd3][0xdb][0xb][0x9][0xd7][0xf7]w[0x19]@,[0x84][0x84]$[0x9c]g[0xbb][0xd8]y[0xde][0x15][0x82][0xa5][0xb1]7[0x9e][0xca]rezPr[0x9f]X[0x9c]- [0xc1]9[0x82][0x13][0x80][0xd6]d[0x7][0xe3][0x12][0xd5]s[0x6][0xb6][0x15]d[0xbc]X[0xb1][0x86][0xfc][0xc]/[0x1d]i[0x18][0x90][0x18]VM[0x9c]N[0xf3][0x9c]m[0xe][0xb6][0x9e][0x93][0xbe]^4r[0xac]>vF[0x90]][0x9d][0xe2]l)[0x7][0x9c]F8#2[0xc1][0xb6]E[0xcc][0xcd]Hu[0x1a].4[0x83]=[0xd8][0xf9][0xf1]8'[0xbb][0xca][0xc1][0x9a]t[0x9f][0xce]u[0xc1][0x8c][0xec][0xce]a[0xa3]Z[0xbb][0xde]nFu[0xb][0xfe][0xdd]gA[0x5][0xaf][0x9c]z[0x9d]3[0xb1][0x81]j[0x9c][0x6][0xfc][0xe1][0xf1][0xa6][0xf1]4[0xf7][0xae][0xb][0xe7][0xa8][0xc1][0xf2][0xf9][0x9]z[0xa1]4[0x9f]uw[0xb2][0xa9][0x12]>[0xb3][0xb6][0x9e][0xbc]n[0x17][0x8e][0xf][0x88][0x81]g[0xcb][0x8e]r[0x9c]E$[0xea][0xff][ [0xe1][0x14][0xb0][[0xf0][0x8f][0xa1][0xcf][0xfb][0x93][0xf0][0x10][0x86][0xde]vx[0xd4][0xc1][0xcf]jP[0x80][0x91]j[0xcb]/f[0xd0][0xb9][0x84]6[0xe4]$[0xa0][0xc][0xc3][0xa8]gPHN[0xfc]u[0x8c]y[0x12][0x14][0xe4]AS[0xec]r[0xee][0xf3][0x88]E[0x1c]4[0xac][0xa7]1[0x87][0xe7][0xb]n[0x9c].[0xcb][0x2][0xfb][0xe6][0x1f][0xbe][0xa1]M[0xb9]W[0x11][0x8b] [0xf8][0x9b]Lv[0xa5]?[0xed]T[0x90][0xca][0x1a]5|[0xb5]YA[0xc7][0x12][0x91]%^[[0xbc][0xee][0xaa][0xe6][0x86][0x8c]Y[0xcd][0xd7][0x93]j[0xb][0xd6]LF/zN+[0xf4][0xfa][0x6]iJj[0xf6][0x1c][0xcf]k[0x8f][0x99][0x8a][0xba][0xc6][0xde][0x89][0x2][0xf1] +[0xf8][0xf2][0xac]B[0x82][0xa2][0xe3][0xcd][0xca][0xce][0xd7]{[0x8a][0x88][0xc7][0x80][0xc3][0xd5][0xaa];[0xf6][0x2][0xf8][0xc8]7[0x14][0x3][0x8a][\r]4[0xb1][0xc5][0xfe]n[0xcb][0x93]I[0x98]U.U8[0x9b][0x82]x[0x94][0x1c]f[0xe6][0x12][0x9b]f][0xe]c[0xa4][0xc8][0x83][0xc]|[0xa3]U[0xc9][0x11][0x83]v[0x1]RJ[0xaa])N[0xf5][0xcf][0xc8][0x7][0x88]Y[0x95][0xe7][0xa1]&[0xd4][0x8b]=+a[0xa8]i[0xca][0x85]6[0x82][0x12][0x84]d[0xf6]`[0xda]K[0xe6]z[0xfd]m[0xd8][0x2]Z[0xd6]w[0x7][0xa9][0x87]Q[0x5][0xf][0xc4][0x0][0xf9]T09[0x9f][0xab]z[0xf6][0x89][0x16][0xe5][0xd2][0xf6][0xd7][0x1f][0xd3][0x89][0xa3]s[0xc0][0xe5]F[0x12][0xdd][0xe3]e[0xf8][0x5]ft[0xd7][0x8][0xfd][0x9b][0xed][0xaf][0x83][0xc4][0xd3]W[0x9e][0xc6]Hl[0xdb][0xd4][0x12][0xf3]w|[0x98]EqS[0xeb]a[0xa1][0xab][0x1f][0xe]ea[0xc2]d[0xdd]xz[0xc6][0xb7][0xa7]O[0xdf]i[0xd5][0xea][0xe5]"[0xe0]t[0x1d]2[0xe2][0x17][\n]"
09:53:26.271 [Thread-18] DEBUG org.apache.http.wire - http-outgoing-0 >> "t[0xc0]g[0xf4][0xf6][0x12][0xf1][0xcc]3[0x1b]D$jU\[0xab]e[0xc5][0xe7]=>[0x85][0xea][0xde]6[0x4][0xa9][0xf9]R[0xcc]$[0xc4][0x9][0x19]W[0xee][0xc5][0xb2][0xa4][0xe3][0xb4][0x92][0x1e]R[0x1][0xd2]Z^[0x95][0xa7][0xb0][0x9b][0x8][0xbe][0x1c][0xb5][0xcc]30[0xf]T[0xca][0x0][0xe7][0xef][0xf1][0xb6][0x99][0x96][0x94]q7[0xaa]3[0xce][0xa8][0x12]@[0x86][0x5]+Z[0x18][0x92][0xd2][0x84][0xf3]2[0xcc]8Y[0xcc][0xe4][0xa0][0x13]][0x1e][0xfa]d[0xd2][0xf5][0xa6]}[0xe3][0x5]I[0xd3]?W[0xb7][0xef][0x96][0xa0][0xf1][0xc3]W[0x8e]B[0xcf][0xc][0x1e][0xfc][0xe2];P[0x16][0x94][0xef][0xb2][0xee][0xd5][0xcb]|E[0x93][0xb2][0xcd][0xea]"hi[0x1c]`[0xea][0xe5][0x95][0xaf][0xea][0x9b]"[0xe][0x11]-oY[0xc6]D[0xf4][0xe]/#[0xdb]P[0xe4][0xa8][0xa7]0z[0x98]G7[\n]"

To my log4j.properties I put thses lines:

log4j.properties

log4j.category.httpclient.wire.header=WARN
log4j.category.httpclient.wire.content=WARN
log4j.logger.org.apache.http=WARN
log4j.logger.httpclient.wire.header=WARN
log4j.logger.httpclient.wire.content=WARN
log4j.logger.org.apache.http.headers=WARN
log4j.logger.org.apache.http.wire=WARN
log4j.category.httpclient.wire.header=WARN
log4j.category.httpclient.wire.content=WARN
log4j.category.org.apache.http=WARN
log4j.category.org.apache.http.headers=WARN
log4j.category.org.apache.http.wire=WARN

I even put these lines to my code:

JAVA code

Logger.getLogger("org.apache.http").setLevel(org.apache.log4j.Level.OFF);
Logger.getLogger("org.apache.http.headers").setLevel(org.apache.log4j.Level.OFF);
Logger.getLogger("org.apache.http.wire").setLevel(org.apache.log4j.Level.OFF);

The problem is, the logging still persists. It seems that log4j.properties has impact on other parts of JAVA code, but it is impossible to get rid of org.apache.http DEBUG logs.

Datepicker jQuery on Apache Webserver [duplicate]

This question already has an answer here:

I want to change jQuery Datepicker to German Calendar, but it did not work.

-I tried that :

<script>
  $( function() {
    $( "#datepicker" ).datepicker( $.datepicker.regional[ "de" ] );
    $( "#locale" ).on( "change", function() {
      $( "#datepicker" ).datepicker( "option",
        $.datepicker.regional[ $( this ).val() ] );
    });
  } );
  </script>

Thank you!

Get Node.js to receive requests for website hosted with Apache Tomcat [on hold]

I have an Angular.js website that's hosted on a Windows server that runs Apache Tomcat. However, even though I would like to continue to serve the files using Apache, I would also like to have a Node.js API that would receive some of the requests in order to integrate a MongoDB database with Mongoose.

Event though I've managed to run Node.js on the server in the website's folder, the requests are still directed to Apache.

Any ideea on how to configure things so that both servers (running on the same machine) can receive requests?

Thanks a bunch!