diff --git a/cms/lib/plugins/index.php b/cms/lib/plugins/index.php new file mode 100644 index 0000000..6d13a90 --- /dev/null +++ b/cms/lib/plugins/index.php @@ -0,0 +1,359 @@ + $value): + if (is_array($value)){ + foreach($value as $kv => $vv): + if (isset($customSchema[$key][$kv]) && @$customSchema[$key][$kv] != "" && @$customSchema[$key][$kv] != $vv) $schemaPlugins[$dirname][$key][$kv] = $customSchema[$key][$kv]; + endforeach; + }else{ + if (isset($customSchema[$key]) && @$customSchema[$key] != "" && @$customSchema[$key] != $value) $schemaPlugins[$dirname][$key] = $customSchema[$key]; + } + endforeach; + + } + } + } + return $schemaPlugins; +} +function installSQL($path){ + if (file_exists($path."/install.sql")){ + try{ + sqlImport($path."/install.sql"); + return 1; + }catch(Exception $e){ + return 0; + } + }else{ + return 1; + } + +} +function installSchemas($path){ + if (file_exists($path."/schemaPresets")){ + foreach (scandir($path."/schemaPresets") as $dirname) { + if (strpos($dirname,".ini")){ + addTablePlugin($path."/schemaPresets",$dirname); + } + } + rename($path."/schemaPresets/",$path."/schemaPresets.bck/"); + return 0; + }else{ + return 1; + } +} +function showInstall($path){ + global $TABLE_PREFIX,$menu,$action,$schema; + // + $result = 0; + showHeader(); +?> + + +
+

Instalando el plugin

+ +

Instalando tablas necesarias

Error instalando la base de datos

+

Instalando Schemas

Error instalando los esquemas

+ +

 

+ Recarga para cargar el plugin + +
+ $value): + if (!@$CURRENT_USER["isAdmin"] && $value["adminOnly"]) continue; + if (!@$value["enabled"]) continue; + if (@$value["checkPoints"]){ + foreach($allowedFields as $allowedField): + $value["checkPoints"][$allowedField] = ""; + endforeach; + + foreach($value["checkPoints"] as $checkPoint => $controller): + if ($checkPoint==$type && isset($value["checkPoints"][$type])){ + + $enabled = true; + $pluginsInserted[] = $key; + // DEFINIMOS LAS VARIABLES DE OPCIONES PARA EL PLUGIN + $options = array(); + $options["templatePath"] = str_replace($GLOBALS["PROGRAM_DIR"]."/","",$GLOBALS["APP"]["pluginsdir"])."/".$key; + $options["pluginName"] = $key; + if (@$value["newFieldType"]){ + $options["fieldType"] = $value["newFieldType"]; + if (@$fieldtype){ + foreach($options["fieldType"] as $kvar => $vvar): + if (isset($var["field"][$kvar])) $options["fieldType"][$kvar] = $var["field"][$kvar]; + endforeach; + } + } + + // SI EXISTEN FILTROS DE MENU + if (@$value["menuFilter"][$type]){ + $sepMenu = array_filter(explode(",",$value["menuFilter"][$type])); + if (@$sepMenu && !in_array(@$menu,@$sepMenu)){ + $enabled = false; + } + } + // SI EXISTEN FILTROS DE ACTION + if (@$value["actionFilter"][$type]){ + $sepAction = array_filter(explode(",",$value["actionFilter"][$type])); + if (@$sepAction && !in_array(@$action,@$sepAction)){ + $enabled = false; + } + } + + // SI EXISTEN FILTROS DE TIPO DE CAMPO + if (@$value["newFieldType"]["type"] && @$fieldtype && @$value["newFieldType"]["type"] != $fieldtype) { + $enabled = false; + } + + // SI EXISTE UN ARCHIVO DE INSTALACION LO EJECUTAMOS + if (file_exists($GLOBALS["APP"]["pluginsdir"]."/".$key."/install.sql") || file_exists($GLOBALS["APP"]["pluginsdir"]."/".$key."/schemaPresets")){ + $enabled = false; + showInstall($GLOBALS["APP"]["pluginsdir"]."/".$key); + } + // SI NOS PIDE EL TYPE DE CAMPO Y EXISTE EN EL SCHEMA DEL PLUGIN LO AÑADIMOS + if ($enabled && @$type=="db_type" && @$value["newFieldType"]["type"]){ + array_push($var, array("value" => $value["newFieldType"]["type"], "name" => $value["newFieldType"]["label"])); + continue; + } + + if ($enabled && @$type=="db_type_config" && @$value["newFieldType"]){ + ?> +
" data-fieldtype="" class="fieldPluginContainer"> + Plugin Options + + $vFT):?> + + +
+
+ ][]" value=""> +
+ + +
+ 0) { + query($row); + } + + fclose($file); +} + +/** + * Remove comments from sql + * + * @param string sql + * @param boolean is multicomment line + * @return string + */ +function clearSQL($sql, &$isMultiComment) +{ + if ($isMultiComment) { + if (preg_match('#\*/#sUi', $sql)) { + $sql = preg_replace('#^.*\*/\s*#sUi', '', $sql); + $isMultiComment = false; + } else { + $sql = ''; + } + if(trim($sql) == ''){ + return $sql; + } + } + + $offset = 0; + while (preg_match('{--\s|#|/\*[^!]}sUi', $sql, $matched, PREG_OFFSET_CAPTURE, $offset)) { + list($comment, $foundOn) = $matched[0]; + if (isQuoted($foundOn, $sql)) { + $offset = $foundOn + strlen($comment); + } else { + if (substr($comment, 0, 2) == '/*') { + $closedOn = strpos($sql, '*/', $foundOn); + if ($closedOn !== false) { + $sql = substr($sql, 0, $foundOn) . substr($sql, $closedOn + 2); + } else { + $sql = substr($sql, 0, $foundOn); + $isMultiComment = true; + } + } else { + $sql = substr($sql, 0, $foundOn); + break; + } + } + } + return $sql; +} + +/** + * Check if "offset" position is quoted + * + * @param int $offset + * @param string $text + * @return boolean + */ +function isQuoted($offset, $text) +{ + if ($offset > strlen($text)) + $offset = strlen($text); + + $isQuoted = false; + for ($i = 0; $i < $offset; $i++) { + if ($text[$i] == "'") + $isQuoted = !$isQuoted; + if ($text[$i] == "\\" && $isQuoted) + $i++; + } + return $isQuoted; +} + +function query($sql) +{ + //echo '#SQL CODE TO RUN:
' . htmlspecialchars($sql) . ';

'; + if (!$query = mysql_query($sql)) { + throw new Exception("Cannot execute request to the database {$sql}: " . mysql_error()); + } +} + +?> \ No newline at end of file