// disable root access to phpmyadmin
//$cfg['Servers'][$i]['AllowRoot'] = false;
// setting root only access from localhost
$cfg['Servers'][$i]['AllowDeny']['order'] = 'deny,allow';
$cfg['Servers'][$i]['AllowDeny']['rules'] = array(
// deny everyone by default
//'deny % from all',
'deny root from all',
// allow all users from the local system
'allow % from localhost',
'allow % from 127.0.0.1',
'allow % from ::1',
// allow all users from the server IP (commented out)
// 'allow % from SERVER_ADDRESS',
// allow user root from local system
'allow root from localhost',
'allow root from 127.0.0.1',
'allow root from ::1',
// allow user root from local network
'allow root from 10.0.0.0/8',
'allow root from 172.16.0.0/12',
'allow root from 192.168.0.0/16',
'allow root from fe80::/10', // IPv6 Link-local Addresses
'allow root from fc00::/7' // IPv6 Unique Local Addresses
// add more usernames and their IP (or IP ranges) here -
);
** 可以改用 java.nio.charset.StandardCharsets.UTF_8 ,但至少要 API 19
java
1
2
3
InputStream is = cxt.getResources().openRawResource(R.raw.car_type_list);
String content = IOUtils.toString(is, Charsets.UTF_8);
IOUtils.closeQuietly(is);// don't forget to close your streams
publicclassPhotoListDialogFragmentextends DialogFragment {private String img;publicPhotoListDialogFragment(String img){this.img= img;}@Overridepublic Dialog onCreateDialog(Bundle savedInstanceState){// Use the Builder class for convenient dialog construction
View content = LayoutInflater.from(getContext()).inflate(R.layout.photo_list_dialog_content,null,false);
TextView iv =(TextView) content.findViewById(R.id.photoListDialogIV);
iv.setText(img);
AlertDialog.Builder builder =new AlertDialog.Builder(getActivity(), R.style.DialogStyle);
builder.setView(content).setPositiveButton(R.string.dialog_ok,new DialogInterface.OnClickListener(){publicvoidonClick(DialogInterface dialog,int id){// FIRE ZE MISSILES!}});// Create the AlertDialog object and return itreturn builder.create();}}
A value type is a type whose value is copied when it is assigned to a variable or constant, or when it is passed to a function.
You’ve actually been using value types extensively throughout the previous chapters. In fact, all of the basic types in Swift—integers, floating-point numbers, Booleans, strings, arrays and dictionaries—are value types, and are implemented as structures behind the scenes.
All structures and enumerations are value types in Swift. This means that any structure and enumeration instances you create—and any value types they have as properties—are always copied when they are passed around in your code.
Assignment and Copy Behavior for Strings, Arrays, and Dictionaries
In Swift, many basic data types such as String, Array, and Dictionary are implemented as structures. This means that data such as strings, arrays, and dictionaries are copied when they are assigned to a new constant or variable, or when they are passed to a function or method.
This behavior is different from Foundation: NSString, NSArray, and NSDictionary are implemented as classes, not structures. Strings, arrays, and dictionaries in Foundation are always assigned and passed around as a reference to an existing instance, rather than as a copy.
Constant and Variable Parameters
Function parameters are constants by default. Trying to change the value of a function parameter from within the body of that function results in a compile-time error. This means that you can’t change the value of a parameter by mistake.
However, sometimes it is useful for a function to have a variable copy of a parameter’s value to work with. You can avoid defining a new variable yourself within the function by specifying one or more parameters as variable parameters instead. Variable parameters are available as variables rather than as constants, and give a new modifiable copy of the parameter’s value for your function to work with.
Define variable parameters by prefixing the parameter name with the var keyword:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
func alignRight(var string: String, totalLength: Int, pad: Character) -> String {
let amountToPad = totalLength - string.characters.count
if amountToPad < 1 {
return string
}
let padString = String(pad)
for _ in 1...amountToPad {
string = padString + string
}
return string
}
let originalString = "hello"
let paddedString = alignRight(originalString, totalLength: 10, pad: "-")
// paddedString is equal to "-----hello"
// originalString is still equal to "hello"
In-Out Parameters
Variable parameters, as described above, can only be changed within the function itself. If you want a function to modify a parameter’s value, and you want those changes to persist after the function call has ended, define that parameter as an in-out parameter instead.
1
2
3
4
5
6
7
8
9
10
11
func swapTwoInts(inout a: Int, inout _ b: Int) {
let temporaryA = a
a = b
b = temporaryA
}
var someInt = 3
var anotherInt = 107
swapTwoInts(&someInt, &anotherInt)
print("someInt is now \(someInt), and anotherInt is now \(anotherInt)")
// prints "someInt is now 107, and anotherInt is now 3"
On Android devices, GCM uses an existing connection for Google services. For pre-3.0 devices, this requires users to set up their Google accounts on their mobile devices. A Google account is not a requirement on devices running Android 4.0.4 or higher.