Home > front end >  Have a great god to know how to get the user name or UID Discuz front-end watermark?
Have a great god to know how to get the user name or UID Discuz front-end watermark?

Time:09-25

A whim is needed,
Want to Discuz X3.4 front-end watermark, prevent photos and screenshots, if the information can also track who is out,

Now use the js code (bottom) use watermark to create watermark;
Call the js is
 & lt; ? PHP 
Echo "& lt; Script language='javascript' & gt; ";
Echo "var global_username='test'";
Echo "& lt;/script> ";
//content...
?>


Effect of the diagram below:

Only add the specified text watermark "test", can't get the user UID or user username,
Now want to "test" into BBS user name "username" or "uid" user code, do not know how, bosses, please also specify, thank you ~

I have tried to change the test to $_GET [' uid], but the web will fail to load 500,

watermark. Js code
 (function (watermark) {
Window. Watermarkdivs=[];
//load the watermark
Var loadMark=function (Settings) {
Var defaultSettings={
Watermark_txt: "$_GET [' uid],"
Watermark_x: 20,//watermark starting position x coordinate
Watermark_y: 20,//watermark starting position Y coordinates
Watermark_rows: 0,//watermark lines
Watermark_cols: 0,
//watermark sequenceWatermark_x_space: 100,//watermark x interval
Watermark_y_space: 50,//watermark y interval
Watermark_color: '# 000000',//watermark font color
Watermark_alpha: 0.15,//the watermark transparency, requirement set is greater than or equal to 0.005
Watermark_fontsize: '25 px,//watermark font size
Watermark_font: 'bold',//watermark font
Watermark_width: 100,//watermark width
Watermark_height: 100,//watermark length
Watermark_angle: 15,//watermark tilt degree
Watermark_bg_alpha: 0.5//add transparency leads to invisible watermarks cannot read
};
//the configuration items to replace the default, ACTS like jquery. The extend
If (the arguments. The length===1 & amp; & Typeof the arguments [0]==="object")
{
Var src=https://bbs.csdn.net/topics/arguments [0] | | {};
For (key in SRC)
{
[key] if (SRC & amp; & [key] defaultSettings & amp; & [key] the SRC===defaultSettings [key])
continue;
Else if (SRC [key])
DefaultSettings [key]=SRC [key];
}
}

If (window. Watermarkdivs & amp; & Window. Watermarkdivs. Length & gt; 0 {
Document. Body. RemoveChild (document. GetElementById (" otdivid "));
Window. Watermarkdivs=[];
}

//get the biggest width
Var page_width=Math. Max (document. Body. ScrollWidth, document. Body. ClientWidth);
//a maximum length for page
Var page_height=Math. Max (document. Body. ScrollHeight, document. Body. ClientHeight);

//create a document fragment
Var oTemp=document. CreateDocumentFragment ();
//create watermark shell div
Var otdiv=document. GetElementById (" otdivid ");
if(! Otdiv) {
Otdiv=document. The createElement method (' div ');
Otdiv. Id="otdivid";
Otdiv. Style. PointerEvents="none";
Document. The body. The appendChild (otdiv);
}

//if the watermark is the number of columns is set to 0, or watermark columns set is too large, more than the maximum width, recalculate the watermark number of columns and watermark x interval
If (defaultSettings. Watermark_cols==0 | | (parseInt (defaultSettings. Watermark_x + defaultSettings. Watermark_width * defaultSettings watermark_cols + defaultSettings. Watermark_x_space * (defaultSettings. Watermark_cols - 1)) & gt; Page_width)) {
DefaultSettings. Watermark_cols=parseInt ((page_width - defaultSettings. Watermark_x + defaultSettings. Watermark_x_space)/(defaultSettings. Watermark_width + defaultSettings. Watermark_x_space));
DefaultSettings. Watermark_x_space=parseInt ((page_width - defaultSettings. Watermark_x - defaultSettings. Watermark_width * defaultSettings watermark_cols)/(defaultSettings. Watermark_cols - 1));
}
//if the watermarking line number is set to 0, or watermark lines set is too large, page more than the maximum length, then to recalculate the watermark lines and watermark y interval
If (defaultSettings. Watermark_rows==0 | | (parseInt (defaultSettings. Watermark_y + defaultSettings. Watermark_height * defaultSettings watermark_rows + defaultSettings. Watermark_y_space * (defaultSettings. Watermark_rows - 1)) & gt; Page_height)) {
DefaultSettings. Watermark_rows=parseInt ((defaultSettings watermark_y_space + page_height - defaultSettings. Watermark_y)/(defaultSettings. Watermark_height + defaultSettings. Watermark_y_space));
DefaultSettings. Watermark_y_space=parseInt (((page_height - defaultSettings. Watermark_y) - defaultSettings. Watermark_height * defaultSettings watermark_rows)/(defaultSettings. Watermark_rows - 1));
}

Var x;
Var y;
For (var I=0; i Y=defaultSettings. Watermark_y + (defaultSettings. Watermark_y_space + defaultSettings. Watermark_height) * I;
For (var j=0; J & lt; DefaultSettings. Watermark_cols; J++) {
X=defaultSettings. Watermark_x + (defaultSettings. Watermark_width + defaultSettings. Watermark_x_space) * j;

Var mask_div=document. The createElement method (' div ');
Var oText=document. CreateTextNode (defaultSettings. Watermark_txt);
Mask_div. The appendChild (oText);
//set a watermark related properties start
Mask_div. Id='mask_div' + I + j;
//set the watermark div tilt display
Mask_div. Style. WebkitTransform="rotate (-" + defaultSettings. Watermark_angle + "deg)";
Mask_div. Style. MozTransform="rotate (-" + defaultSettings. Watermark_angle + "deg)";
Mask_div. Style. MsTransform="rotate (-" + defaultSettings. Watermark_angle + "deg)";
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related