Thursday, 15 July 2010

php - Better admin security -



php - Better admin security -

i seek create firs cms , have querstion security. right have seperated admin area , public area. admin area in folder "admin" , public area in folder "public". both folders in folder "cms". in both maps example: file called "index.php". , content same in admin's index.php have few more features example: in admin's navigation have logout , settings options. improve if 2 folders create 1 called "public" , both "index.php" connect 1 file , command $_session add together additional features navigation? example: if admin logged in session show settings , logout features navigation. when user logged out won't see settings , logout featuers in navigation because show when user has set session. so, improve , more secure have seperated admin , public folder or same if set in 1 file?

in cms, utilize same page public, users, , admins.

the different in showing functionality based on group.

i.e. normal visitors (public) users not see except published contents. if visitor signed in account, see peaces here , there (i.e. profile img, personal info, alter email/password). on other hand, admin has own extras well, such command users, messages, , etc.

off course of study times there totally new things not shared between these 3 levels of privileges. in case, create separate page them...

the of import things here check user grouping , based on grouping display part , hide part.

something like

if user grouping == 1 // admin { display admin_sidebar.php } elseif user grouping == 2 // fellow member { display member_profile.php link }

also off course of study need utilize sessions handle grouping after user logged in website.

hope helps...

php mysql session login

c - Space padding in printf doesn't work -



c - Space padding in printf doesn't work -

i need add together variable space padding before string. here's code:

unsigned int spaces = result % 16; printf("spaces=%d\n", spaces); // spaces=12, example. printf("% *s\n", spaces, my_string);

it doesn't work - spaces not added , i'm getting next warning in gcc:

warning: ' ' flag used ‘%s’ gnu_printf format [-wformat=]

how prepare that? there workaround this?

change this

printf("% *s\n", spaces, my_string);

to this

printf("%*s%s\n", spaces, " ", my_string);

this should rid of warning , give desired effect.

[edit]

i saw found answer. alexis says right , produce same effect. alexis's version cleaner, say, giving solution, credits on him.

you this:

int width = 5; printf ("%*d%*d\n", width, 10, width, 12);

which print this:

10 12

source

so, if think it, this:

printf("%*s\n", spaces, "foo");

why alexis's version synonym version in comment?

because compiler performs concatenation of 2 sequential strings (i.e. whitespace in between) one.

this action called string literal concatenation. read more in wikipedia.

c printf

c# - Check box Checked state is Not working in Custom paging in Devexpress Gridview -



c# - Check box Checked state is Not working in Custom paging in Devexpress Gridview -

hi using devexpress gridview. in implementing custom paging. after implementing custom paging checkbox checked state not working in gridview. if check row in first page when go sec page , if come 1 time again first page, previous checked column not in checked state.

can 1 help me solve problem.

thanks

you reloading page after pagination losing context checkboxes checked. first shoot, without code hard more pissible issues of problem.

c# asp.net

Android sdk manager disapear quickly in eclipse -



Android sdk manager disapear quickly in eclipse -

when click on android sdk manager button,

the android sdk manager window doesn't open! see this:

and nil else! can't see packages installed or not...

in console appear:

[2014-10-07 22:42:24 - sdk manager] [sdk manager] access denied. [2014-10-07 22:42:24 - sdk manager] [sdk manager] exception in thread "main" java.lang.unsatisfiedlinkerror: no swt-win32-3550 or swt-win32 in swt.library.path, java.library.path or jar file [2014-10-07 22:42:24 - sdk manager] [sdk manager] @ org.eclipse.swt.internal.library.loadlibrary(unknown source) [2014-10-07 22:42:24 - sdk manager] [sdk manager] @ org.eclipse.swt.internal.library.loadlibrary(unknown source) [2014-10-07 22:42:24 - sdk manager] [sdk manager] @ org.eclipse.swt.internal.c.<clinit>(unknown source) [2014-10-07 22:42:24 - sdk manager] [sdk manager] @ org.eclipse.swt.widgets.display.<clinit>(unknown source) [2014-10-07 22:42:24 - sdk manager] [sdk manager] @ com.android.sdkmanager.main.showsdkmanagerwindow(main.java:402) [2014-10-07 22:42:24 - sdk manager] [sdk manager] @ com.android.sdkmanager.main.doaction(main.java:376) [2014-10-07 22:42:24 - sdk manager] [sdk manager] @ com.android.sdkmanager.main.run(main.java:150) [2014-10-07 22:42:24 - sdk manager] [sdk manager] @ com.android.sdkmanager.main.main(main.java:116)

what should i've done? help me please...

try accessing via .exe file in sdk tools install folder instead of through eclipse. eclipse has many little bugs have made habit much possible without using eclipse ha.

android eclipse sdk

Simple HTML/JavaScript not saving cookie on harddrive -



Simple HTML/JavaScript not saving cookie on harddrive -

the next code failing result in saved .txt cookie on harddrive @ next location: c:\users\<user>\appdata\roaming\microsoft\windows\cookies

i debug page chrome element inspector , no cookie showing up. there i've misunderstood creating simple cookie?

<!doctype html> <html> <body> <script> document.cookie="username=test cookie; expires=thu, 18 dec 2020 12:00:00 utc"; alert("done"); </script> </body> </html>

you're looking in folder net explorer's cookies, not chrome's cookies.

browsers may not back upwards cookies documents opened file:// uris.

javascript html cookies

java - Android parse base64Binary pgm to Bitmap -



java - Android parse base64Binary pgm to Bitmap -

i need convert base64binary-string in format pgm bitmap in android. don't have usual base64-encoded bitmap. base64binary-string came xml file

<referenceimage type="base64binary" format="pgm" widthpx="309" heightpx="233" bytesperpixel="1" > ndy4ojo9qefdruvhrkllte9oufftu1vwv1hzwltzwvlzwlpbw1xdxmbgymjjzgnlzwrkzgrlzmznz2znawpqa21ub29ubm9vb3bwchbxchfyc3fzcnjzcnjydh[...]vlaw1xbwltcxfxcxfxd.

pattern.compile("<referenceimage .*>((?s).*)<\\/referenceimage>"); ... string sub = r; //base64binary string pattern-matched xml file byte[] decodedstring = base64.decode(sub.getbytes(), base64.no_wrap); //probably wrong decoding (needs ascii binary?) bitmap decodedbyte = bitmapfactory.decodebytearray(decodedstring, 0, decodedstring.length); //always null due wrong byte-array

i think understand pgm images typically stored ascii (like in xml) or binary (0..255). think base64.decode needs binary-variant, not ascii have. bitmapfactory.decodebytearray doesn't understand decoded byte-array , returns null.

so how can convert base64binary-pgm-ascii-string valid byte-array in order create valid bitmap?

i think base64-decoding fine. android's bitmapfactory has no direct back upwards pgm format. i'm not sure how add together back upwards it, seems create bitmap using 1 of createbitmap(...) mill methods quite easily.

see pgm spec details on how parse header, or see my implementation java se (if around, you'll find class supports ascii reading, if needed).

could there's no header, , can height/width xml. in case, dataoffset 0 below.

when header parsed, know width, height , image info starts:

int width, height; // header int dataoffset; // == end of header // create pixel array, , expand 8 bit grayness argb_8888 int[] pixels = new int[width * height]; (int y = 0; y < height; y++) { (int x = 0; x < width; x++) { int grayness = decodedstring[dataoffset + i] & 0xff; pixels[i] = 0xff000000 | grayness << 16 | grayness << 8 | gray; } } bitmap pgm = bitmap.createbitmap(metrics, pixels, width, height, bitmapconfig.config. argb_8888);

java android bitmap base64 pgm

java - Found unsupported keytype (8) for Principal -



java - Found unsupported keytype (8) for Principal -

i using java 7 , kerberos authenticate hadoop.

in debug log seeing next error:

ordering keys wrt default_tkt_enctypes list default etypes default_tkt_enctypes: 23 18 17 16 3 1. added key: 3version: 1 **found unsupported keytype (8) hdfs/aaa.aaa@example.com** added key: 23version: 1 added key: 16version: 1 added key: 17version: 1 added key: 18version: 1

how right error?

sorry it's bit late, i've encountered missing local_policy.jar , us_export_policy.jar files in directory: $java_home/jre/lib/security/.

other times, mis-configured krb5.ini file.

java hadoop aes kerberos