mod_rewrite 특정 파일 또는 디렉토리 제외하고 포워딩 하기

리눅스/APACHE|2019. 7. 25. 17:46
반응형

.htaccess

RewriteEngine On

RewriteCond %{REQUEST_URI} !^/test.html

RewriteCond %{REQUEST_URI} !^/imsi/

RewriteRule ^(.*)$ http://sysdocu.tistory.com/$1 [L,R=301]

 

위 예제에서는 test.html 및 imsi 디렉토리를 제외하고 모두 sysdocu.tistory.com 으로 포워딩 됩니다.

 

 

반응형

댓글()

여러가지 작업 설정 후 호출하기

프로그래밍/Android (Java)|2019. 7. 12. 14:54
반응형

onCreate 바깥에 아래와 같이 작성 후 delete(); 이렇게 불러 올 수 있다.

 


void delete() {
    db.execSQL("delete from mytable;");
}

 

 

 

반응형

댓글()

서비스 (service) 가동 여부 확인하기

프로그래밍/Android (Java)|2019. 7. 12. 08:48
반응형

 

소스 하단부에서 기능 추가하고 onCreate 안에서 호출한다.

 

 

onCreate 안에서 호출하는 부분

 

boolean serviceRunningStatus = isServiceRunning(MyService.class); // 서비스명 입력
String service_status = String.valueOf(serviceRunningStatus); // boolean 값을 string 값으로 변환

TextView notice_record = (TextView) findViewById(R.id.notice_record);

notice_record.setText(service_status); // 이런식으로 출력

 

 

onCreate 바깥에서 기능 추가

 

private boolean isServiceRunning(Class<?> serviceClass) {
        ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
        for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
            if (serviceClass.getName().equals(service.service.getClassName())) {
                return true;
            }
        }
        return false;
    }

 

 

 

반응형

댓글()

Notification 진동 제거하기

프로그래밍/Android (Java)|2019. 7. 10. 18:00
반응형

오레오 (Android 8) 버전 부터는 NotificationChannel 에 할당해야 합니다.

진동을 가능하게하고 빈 패턴을 설정하면 됩니다.

NotificationChannel channel = new NotificationChannel("id", "name", NotificationManager.IMPORTANCE_LOW);  

channel.setVibrationPattern(new long[]{ 0 });

channel.enableVibration(true);

 

오레오 이전 버전의 경우 Notification 에 설정을 주어야 합니다. (아직 안해봄. 버전 낮은 기기에서 해봐야 함)

notificationBuilder.setDefaults(Notification.DEFAULT_LIGHTS | Notification.DEFAULT_SOUND)
                                       .setVibrate(new long[]{0L}); // 이후에도 다른 속성이 있으면 세미콜론 지울것

 

 

반응형

댓글()

command line 명령어로 메일 보내기 (sendEmail) - 한글 제목 불가

리눅스/Mail|2019. 7. 10. 15:08
반응형

1. 설치

# yum -y install sendEmail

 

2. 발송

 

* 형식

sendEmail 

-f {보내는사람Email주소} 

-t {받는사람Email주소}

-s {SMTP및포트} 

-xu {보내는사람Email주소계정}

-xp {보내는사람Email계정패스워드}

-u {제목}

-m {내용}  // 내용을 텍스트로 보낼 경우 (선택)

-o message-file=body.html  // 내용을 html 파일로 보낼 경우 (선택)

-o message-charset=UTF-8  // 언어셋 (선택)

-a file01.ext file02.ext file03.ext  // 파일 첨부 (선택)

 

# sendEmail -f sender@sysdocu.tistory.com -t user@sysdocu.tistory.com -s smtp.tistory.com:25 -xu sender@sysdocu.tistory.com -xp 12345678 -u 테스트제목 -o message-file=body.html -o message-charset=UTF-8

 

[출처] https://idchowto.com/?p=32943

 

반응형

댓글()

웹쉘, 악성코드, 바이러스 감염 파일 다운로드

관리자 자료실|2019. 7. 10. 10:51
반응형

[웹쉘 모음]

# git clone https://github.com/tennc/webshell tennc
# git clone https://github.com/ysrc/webshell-sample ysrc
# git clone https://github.com/xl7dev/WebShell xl7dev
# git clone https://github.com/JohnTroony/php-webshells JohnTroony

 

 

[악성코드]

 

샘플 바로 받기

# wget https://s3-us-west-2.amazonaws.com/dataval/FBVideo.exe

 

악성코드 정보를 제공하는 사이트 목록입니다.

출처 : http://www.reddit.com/r/Malware/comments/2id252/how_to_find_malware

 

http://contagiodump.blogspot.com/

http://www.kernelmode.info/forum/viewforum.php?f=16

http://malshare.com/

http://avcaesar.malware.lu/

http://www.malwareblacklist.com/showMDL.php

https://malwr.com/

http://minotauranalysis.com/exetweet/

http://openmalware.org/

http://secuboxlabs.fr/

http://www.virusign.com/

http://virusshare.com/

https://twitter.com/MalwareChannel

http://www.malwaredomainlist.com/mdl.php

http://www.malwareblacklist.com/showMDL.php

http://support.clean-mx.de/clean-mx/viruses.php

http://malc0de.com/database/

https://zeustracker.abuse.ch/monitor.php?browse=binaries

http://amada.abuse.ch/palevotracker.php

http://www.sacour.cn/showmal.asp?month=8year=2012

http://malwaredb.malekal.com/ (registration required)

http://blog.urlvoid.com/new-list-of-dangerous-websites-to-avoid

http://www.scumware.org

http://www.threatlog.com

http://minotauranalysis.com/exetweet/

http://minotauranalysis.com/malwarelist.php

http://adminus.net (For sample requests use contact email adminus.xs(at)gmail(dot)com)

http://jsunpack.jeek.org/?list=1 (RSS feed)

http://www.malwareint.com (various links in top bar)

http://www.malwareurl.com/ (free registration required)

http://www.offensivecomputing.net/ (malware repository, free registration required to download)

http://vxvault.siri-urz.net/ViriList.php (password required, unknown at present)

http://vxvault.siri-urz.net/URL_List.php

http://contagiodump.blogspot.com/2011/03/take-sample-leave-sample-mobile-malware.html (Mobile malware samples)

http://virussign.com/downloads.html (registration required)

http://www.nothink.org/viruswatch.php

http://dashke.blogspot.com/

http://malware.lu/ (registration required to download)

http://www.nictasoft.com/ace/malware-urls/

http://virusshare.com/

http://labs.sucuri.net/

http://freelist.virussign.com/freelist/

http://malwareurls.joxeankoret.com/normal.txt

http://secuboxlabs.fr/

http://contagiodump.blogspot.com/2010/11/links-and-resources-for-malware-samples.html

반응형

댓글()

백그라운드 동작 (service + notification)

반응형

MyService.java

import android.app.Notification;

import android.app.NotificationChannel;

import android.app.NotificationManager;

import android.app.PendingIntent;

import android.app.Service;

import android.content.Intent;

import android.os.Build;

import android.os.IBinder;

import android.support.annotation.Nullable;

import android.support.v4.app.NotificationCompat;

 

public class MyService extends Service {

    public static final String CHANNEL_ID = "ForegroundServiceChannel";

 

    @Override

    public void onCreate() {

        super.onCreate();

 

          // 이 부분에 추가하는 내용은 백그라운드에서 실행이 된다.

 

    }

 

    @Override

    public int onStartCommand(Intent intent, int flags, int startId) {

        String input = intent.getStringExtra("inputExtra");

        createNotificationChannel();

        Intent notificationIntent = new Intent(this, MainActivity.class);

        PendingIntent pendingIntent = PendingIntent.getActivity(this,

                0, notificationIntent, 0);

 

        Notification notification = new NotificationCompat.Builder(this, CHANNEL_ID)

                .setContentTitle("Foreground Service")

                .setContentText(input)

                .setSmallIcon(R.drawable.ic_launcher)

                .setContentIntent(pendingIntent)

                .build();

 

        startForeground(1, notification);

 

        //do heavy work on a background thread

 

 

        //stopSelf();

 

        return START_NOT_STICKY;

    }

 

    @Override

    public void onDestroy() {

        super.onDestroy();

    }

 

    @Nullable

    @Override

    public IBinder onBind(Intent intent) {

        return null;

    }

 

    private void createNotificationChannel() {

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {

            NotificationChannel serviceChannel = new NotificationChannel(

                    CHANNEL_ID,

                    "Foreground Service Channel",

                    NotificationManager.IMPORTANCE_DEFAULT

            );

 

            NotificationManager manager = getSystemService(NotificationManager.class);

            manager.createNotificationChannel(serviceChannel);

        }

    }

}

 

 

MainActivity.java 에서 버튼 누를때 또는 백버튼으로 종료시에 활용하도록 한다.

startService(new Intent(MainActivity.this, MyService.class)); // 서비스 시작

stopService(new Intent(MainActivity.this, MyService.class)); // 서비스 중지

 

AndroidManifest.xml 의 application 안에 아래 내용 추가

<service

    android:name=".MyService"

    android:enabled="true"

    android:exported="true" />

 

내용 추가 =================

 

1) '안드로이드 위젯으로 앱 들어갈 때 액티비티가 쌓이는 현상' 해결 방법

 

(1) Notification 에서 앱으로 들어올때 아래 코드 사용 (MyService.java)

intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_TASK_ON_HOME);

 

(2) 돌아올 Activity (보통 MainActivity.java) 에 아래 소스 추가

if (!isTaskRoot()) {

    finish();

    return;

}

stopService(new Intent(MainActivity.this, MyService.class)); // 알림바 아이콘 없애기 (필요에 따라 사용)

 

2. setContentText 에 여러줄을 사용하고자 할 경우 아래와 같은 형식으로 대체하면 됩니다.

 

.setStyle(new NotificationCompat.BigTextStyle().bigText("시간 : " + getDate + "\n상태 : " + status))

 

 

[출처] https://myksb1223.github.io/develop_diary/2018/08/12/Activity-is-stacked-when-home-screen-widgets-is-clicked.html

 

반응형

댓글()

SQLite3 사용예제

반응형

안드로이드: SQLite3 사용예제1

ExternalStorage 외부저장장치 파일 생성 / 읽기 예제
InternalStorage 장치내부 파일 생성 / 읽기 예제

 

지난 두 포스팅에서 ExternalStorage 와 InternalStorage 를 사용하여 자료 저장하는 방법에 대한 예제를 나누었습니다. 이번 포스팅에서는 SQLite 를 활용한 자료 저장을 해보도록 하겠습니다.

안드로이드에는 모바일용으로 제작된 경량화된 DB인 SQLite3 가 있습니다.
C 언어로 엔진이 제작되어 가볍,고  안드로이드에선 SQLiteOpenHelper 클래스를 제공하여 이를 쉽게 다룰수 있게 합니다.

본 예제에선 SQLiteOpenHelper 를 상속한 별도의 클래스를 MySQLiteOpenHelper 를 만들고
MainActivity에서 이를 활용하여 테이블을 생성하고 insert / update / delete 를 해보겠습니다.
특별히 화면에는 보여주는건 없고, Log.d 를 사용하여 결과만 확인해보겠습니다.

 

[MySQLiteOpenHelper.java]

import android.content.Context;

import android.database.sqlite.SQLiteDatabase;

import android.database.sqlite.SQLiteDatabase.CursorFactory;

import android.database.sqlite.SQLiteOpenHelper;

public class MySQLiteOpenHelper extends SQLiteOpenHelper {

// 안드로이드에서 SQLite 데이터 베이스를 쉽게 사용할 수 있도록 도와주는 클래스
public MySQLiteOpenHelper(Context context, String name,

CursorFactory factory, int version) {

super(context, name, factory, version);

}

@Override
public void onCreate(SQLiteDatabase db) {

// 최초에 데이터베이스가 없을경우, 데이터베이스 생성을 위해 호출됨
// 테이블 생성하는 코드를 작성한다
String sql = "create table mytable(id integer primary key autoincrement, name text);";

db.execSQL(sql);

}

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

// 데이터베이스의 버전이 바뀌었을 때 호출되는 콜백 메서드
// 버전 바뀌었을 때 기존데이터베이스를 어떻게 변경할 것인지 작성한다
// 각 버전의 변경 내용들을 버전마다 작성해야함
String sql = "drop table mytable;"; // 테이블 드랍
db.execSQL(sql);

onCreate(db); // 다시 테이블 생성
}

}

 

 

[MainActivity.java]

public class MainActivity extends AppCompatActivity {

private MySQLiteOpenHelper helper;

String dbName = "st_file.db";

int dbVersion = 1; // 데이터베이스 버전
private SQLiteDatabase db;

String tag = "SQLite"; // Log 에 사용할 tag

@Override
protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

// sqLite3 : 모바일 용으로 제작된 경량화 DB
// C언어로 엔진이 제작되어 가볍다
// 안드로이드에서 sqLite3 를 쉽게 사용할 수 있도록 SQLiteOpenHelper클래스제공
helper = new MySQLiteOpenHelper(

this, // 현재 화면의 제어권자
dbName,// db 이름
null, // 커서팩토리-null : 표준커서가 사용됨
dbVersion); // 버전

try {

// // 데이터베이스 객체를 얻어오는 다른 간단한 방법
// db = openOrCreateDatabase(dbName, // 데이터베이스파일 이름
// Context.MODE_PRIVATE, // 파일 모드
// null); // 커서 팩토리
//
// String sql = "create table mytable(id integer primary key autoincrement, name text);";
// db.execSQL(sql);

db = helper.getWritableDatabase(); // 읽고 쓸수 있는 DB
//db = helper.getReadableDatabase(); // 읽기 전용 DB select문
} catch (SQLiteException e) {

e.printStackTrace();

Log.e(tag, "데이터베이스를 얻어올 수 없음");

finish(); // 액티비티 종료
}

insert (); // insert 문 - 삽입추가

select(); // select 문 - 조회

update(); // update 문 - 수정변경

delete(); // delete 문 - 삭제 행제거

select();

} // end of onCreate

void delete() {

db.execSQL("delete from mytable where id=2;");

Log.d(tag, "delete 완료");

}

void update() {

db.execSQL("update mytable set name='Park' where id=5;");

Log.d(tag, "update 완료");

}

void select() {

Cursor c = db.rawQuery("select * from mytable;", null);

while(c.moveToNext()) {

int id = c.getInt(0);

String name = c.getString(1);

Log.d(tag,"id:"+id+",name:"+name);

}

}

void insert () {

db.execSQL("insert into mytable (name) values('Seo');");

db.execSQL("insert into mytable (name) values('Choi');");

db.execSQL("insert into mytable (name) values('Park');");

db.execSQL("insert into mytable (name) values('Heo');");

db.execSQL("insert into mytable (name) values('Kim');");

Log.d(tag, "insert 성공~!");

}

} // end of class

 

[실행화면 Logcat]

테이블을 생성하고 최초에 5개의 레코드를 insert 한뒤 update 와 delete 도 성공하여 다시 4개의 레코드를 Logcat 을 통해 보여줍니다.

 


출처: https://bitsoul.tistory.com/118 [Happy Programmer~]

 

반응형

댓글()

[알림] addPreferencesFromResource 줄 처져 있을 때

반응형

기존이 아래와 같은 방식이라면

public class MyPreferenceActivity extends PreferenceActivity

{

    @Override

    protected void onCreate(final Bundle savedInstanceState)

    {

        super.onCreate(savedInstanceState);

        addPreferencesFromResource(R.xml.my_preference_screen);

    }

}

 

이렇게 바꾸어 사용이 가능하다.

 

public class MyPreferenceActivity extends PreferenceActivity

{

    @Override

    protected void onCreate(final Bundle savedInstanceState)

    {

        super.onCreate(savedInstanceState);

        getFragmentManager().beginTransaction().replace(android.R.id.content, new MyPreferenceFragment()).commit();

    }

    public static class MyPreferenceFragment extends PreferenceFragment

    {

        @Override

        public void onCreate(final Bundle savedInstanceState)

        {

            super.onCreate(savedInstanceState);

            addPreferencesFromResource(R.xml.my_preference_screen);

        }

    }

}

 

* 파란 표시는 바뀌는 부분. 놓치지 않도록 주의

 

 

[출처] https://stackoverflow.com/questions/6822319/what-to-use-instead-of-addpreferencesfromresource-in-a-preferenceactivity/6822461#6822461

반응형

댓글()

TextView 줄간격, 자간, 장평 변경하기

반응형

ㆍ 줄간격 : lineSpacingExtra, lineSpacingMultiplier

 

ㆍ 자간 : letterSpacing(API 21)

 

ㆍ 장평 : textScaleX

 

 

줄 간격

 

android:lineSpacingExtra ="0dp"(기본)

 

android:lineSpacingExtra ="5dp"

 

 

android:lineSpacingMultiplier="1"(기본)

 

android:lineSpacingMultiplier="1.5"

 

 

자간

 

android:letterSpacing="0"(기본)

 

android:letterSpacing="0.2"

 

 

장평

 

android:textScaleX="1"(기본)

 

 

android:textScaleX="1.5"(기본)



출처: https://itpangpang.xyz/325 [ITPangPang]

 

 

 

반응형

'프로그래밍 > Android (Java)' 카테고리의 다른 글

SQLite3 사용예제  (0) 2019.07.08
[알림] addPreferencesFromResource 줄 처져 있을 때  (0) 2019.07.04
구글맵 줌버튼 위치 조정  (0) 2019.06.27
어플 아이콘 변경  (0) 2019.06.25
구글맵 API document  (0) 2019.06.25

댓글()

구글맵 줌버튼 위치 조정

프로그래밍/Android (Java)|2019. 6. 27. 13:18
반응형

    // 구글맵
    @Override
    public void onMapReady(final GoogleMap map) {

        LatLng SEOUL = new LatLng(37.56, 126.97);

        MarkerOptions markerOptions = new MarkerOptions();
        markerOptions.position(SEOUL);
        markerOptions.title("서울");
        markerOptions.snippet("한국의 수도");
        map.addMarker(markerOptions);
        map.moveCamera(CameraUpdateFactory.newLatLng(SEOUL));
        map.animateCamera(CameraUpdateFactory.zoomTo(17));  // 2 (축소) to 21 (확대)

        UiSettings mapUiSettings = map.getUiSettings();
        mapUiSettings.setZoomControlsEnabled(true);  // 줌버튼

        // 줌버튼 컨트롤러 위치 조정
        MapFragment mapFragment = (MapFragment) getFragmentManager().findFragmentById(R.id.map);
        View zoomControls = mapFragment.getView().findViewById(0x1);
        if (zoomControls != null && zoomControls.getLayoutParams() instanceof RelativeLayout.LayoutParams) {
            // ZoomControl is inside of RelativeLayout
            RelativeLayout.LayoutParams params_zoom = (RelativeLayout.LayoutParams) zoomControls.getLayoutParams();
            // Align it to - parent top|left
            params_zoom.addRule(RelativeLayout.ALIGN_PARENT_TOP);
            params_zoom.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
            // Update margins, set to 10dp
            final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10,
                    getResources().getDisplayMetrics());
            params_zoom.setMargins(margin, margin, margin, margin);
        }

    }

 

 

반응형

댓글()