diff --git a/index.php b/index.php new file mode 100644 index 0000000..ef59749 --- /dev/null +++ b/index.php @@ -0,0 +1,6 @@ +getValue( "config" ); + + if( ! isset( $config["ipt"] ) || strlen($config["ipt"]) == 0) return false; + + if( $config["width"] < 1 ) $config["width"] = ""; + + $config["sugSubmit"] = $config["sugSubmit"] == "0" ? "false" : "true"; + + echo "\r\n\r\n\r\n"; +}); + +// 后台调试链接 +addAction("adm_menu_ext", function (){ + echo "openSug"; +}); \ No newline at end of file diff --git a/opensug_callback.php b/opensug_callback.php new file mode 100644 index 0000000..84e440c --- /dev/null +++ b/opensug_callback.php @@ -0,0 +1,36 @@ +setValue( "config", array( + "ipt" => "", // 输入框绑定ID + "bgcolor" => "#ffffff", // 背景颜色 + "bgcolorHI" => "#313131", // 背景高亮颜色 + "borderColor" => "#ced4da", // 边框颜色 + "fontColor" => "#313131", // 字体颜色 + "fontColorHI" => "#ffffff", // 字体高亮颜色 + "fontFamily" => "Montserrat,sans-serif", // 字体 + "fontSize" => "14", // 字体大小 + "padding" => "4px 8px", // 内边框 + "radius" => "4px", // 圆角 + "shadow" => "0 16px 10px #00000080", // 阴影 + "source" => "", // 结果源 + "sugSubmit" => "1", // 默认动作 + "width" => "", // 宽度 + "XOffset" => "", // X偏移量 + "YOffset" => "-3", // Y偏移量 + ), "array" ); +} + +// 插件删除时清理数据 +function callback_rm() { + $db = Storage::getInstance("openSug"); //使用插件的英文名称初始化一个存储实例 + $ak = $db->deleteAllName("YES"); //删除此插件创建的所有数据, 请传入大写的"YES"来确认删除 ,一般用于插件删除回调函数。 +} + +// 插件更新时数据库 +function callback_up() { + +} diff --git a/opensug_setting.php b/opensug_setting.php new file mode 100644 index 0000000..6e7e1bc --- /dev/null +++ b/opensug_setting.php @@ -0,0 +1,176 @@ +{$str}"; +} + +function plugin_setting_view(){ + $config = array(); + $db = Storage::getInstance("openSug"); + + if( strtolower( $_SERVER["REQUEST_METHOD"] ) === "post"){ + if(!preg_match("/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/", $_POST["bgcolor"])) $_POST["bgcolor"] = ""; + if(!preg_match("/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/", $_POST["bgcolorHI"])) $_POST["bgcolorHI"] = ""; + if(!preg_match("/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/", $_POST["borderColor"])) $_POST["borderColor"] = ""; + if(!preg_match("/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/", $_POST["fontColor"])) $_POST["fontColor"] = ""; + if(!preg_match("/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/", $_POST["fontColorHI"])) $_POST["fontColorHI"] = ""; + + if(!preg_match("/^(?:-?\d+)?$/", $_POST["XOffset"])) $_POST["XOffset"] = ""; + if(!preg_match("/^(?:-?\d+)?$/", $_POST["YOffset"])) $_POST["YOffset"] = ""; + if(!preg_match("/^\d+$/", $_POST["fontColorHI"])) $_POST["width"] = ""; + + if(!preg_match("/^(\d+(px|em))( (\d+(px|em))){0,3}$/", $_POST["padding"])) $_POST["padding"] = ""; + if(!preg_match("/^(\d+(px|em))( (\d+(px|em))){0,3}$/", $_POST["radius"])) $_POST["radius"] = ""; + + if(!preg_match("/(px|em)$/", $_POST["fontSize"])) $_POST["fontSize"] .= "px"; + if(!preg_match("/\b(\d+(?:px|em)(?:\s+\d+(?:px|em)){0,3})\b/", $_POST["fontSize"])) $_POST["fontSize"] = "14px"; + + $_POST["sugSubmit"] = $_POST["sugSubmit"] == "0" ? "0" : "1"; + $db->setValue( "config", array( + "ipt" => $_POST["iptid"], // 输入框绑定ID + "bgcolor" => $_POST["bgcolor"], // 背景颜色 + "bgcolorHI" => $_POST["bgcolorHI"], // 背景高亮颜色 + "borderColor" => $_POST["borderColor"], // 边框颜色 + "fontColor" => $_POST["fontColor"], // 字体颜色 + "fontColorHI" => $_POST["fontColorHI"], // 字体高亮颜色 + "fontFamily" => $_POST["fontFamily"], // 字体 + "fontSize" => $_POST["fontSize"], // 字体大小 + "padding" => $_POST["padding"], // 内边框 + "radius" => $_POST["radius"], // 圆角 + "shadow" => $_POST["shadow"], // 阴影 + "source" => $_POST["source"], // 结果源 + "sugSubmit" => $_POST["sugSubmit"], // 默认动作 + "width" => $_POST["width"], // 宽度 + "XOffset" => $_POST["XOffset"], // X偏移量 + "YOffset" => $_POST["YOffset"], // Y偏移量 + ), "array" ); + } + + $sources = array( + "baidu" => "百度", + "google" => "谷歌", + "haoso" => "好搜", + "kugou" => "酷狗", + "yahoo" => "雅虎", + "yandex" => "Yandex", + "youku" => "优酷视频", + "taobao" => "淘宝", + "attayo" => "Attayo", + "mgtv" => "芒果视频", + "sm" => "神马搜索", + "weibo" => "微博", + "rambler" => "Rambler", + "soft" => "软件", + "naver" => "Naver", + "car" => "新浪汽车", + "car2" => "网易汽车", + "qunar" => "去哪儿", + "lagou" => "拉钩网" + ); + + $config = $db->getValue( "config" ); + $config["fontSize"] = preg_replace("/[^\d]+/", "", $config["fontSize"] ); +?> + +
+

openSug.js - 为访问者提供搜索建议,方便用户搜索。

+
+
+
+
+
+
+ 请根据您的主题模板实际输入框填写此处的ID,如您需要帮助请添加社群获取支援! openSug.js +
+
<input type="text" name="kw" id="输入框ID" ...
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
" required="required" autofocus="autofocus" placeholder="iptID" />
" placeholder="-1" />
" placeholder="-3" />
" placeholder="#ffffff" />
" placeholder="#11a7db" />
" placeholder="#d4ac20" />
" placeholder="#6b00c2" />
" placeholder="#f14f4f" />
" placeholder="Geneva" />
" placeholder="14" />
" placeholder="1px 1px 1px 1px" />
" placeholder="1px 1px 1px 1px" />
" placeholder="0 16px 10px #00000080" />
" placeholder="推荐留空" />
+
+
+
+
+
+ \ No newline at end of file