diff --git a/.gitignore b/.gitignore index ecdce44..e2c5124 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ vendor/ +composer.json composer.lock composer.sync @@ -8,3 +9,5 @@ composer.sync test_code.php modules/ + +requirements.txt diff --git a/DbContinuousIntegrationWrapper.sh b/DbContinuousIntegrationWrapper.sh index a6007f9..15137df 100755 --- a/DbContinuousIntegrationWrapper.sh +++ b/DbContinuousIntegrationWrapper.sh @@ -3,7 +3,9 @@ cd "$(dirname ${BASH_SOURCE[0]})" while [[ 1 ]] do killall DbContinuousIntegrationWrapper.sh - /usr/bin/php DbContinuousIntegration.php + /usr/bin/php composer.json.php > composer.json + touch -t $(/usr/bin/mysql -se "SELECT DATE_FORMAT(LastUpdated, '%Y%m%d%H%i.%s') FROM SYS_PRD_BND.Composer ORDER BY LastUpdated DESC LIMIT 1") composer.json make + /usr/bin/php DbContinuousIntegration.php sleep 10 done diff --git a/Makefile b/Makefile index 76322f1..a66e13c 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,10 @@ #!/bin/bash composer.sync: composer.json - COMPOSER_ALLOW_SUPERUSER=1 composer update 2>&1 > $@ + COMPOSER_ALLOW_SUPERUSER=1 composer update > $@ 2>&1 +requirements.sync: requirements.txt + pip install -r requirements.txt $@ install: echo "Add this line to crontab -e" echo '@reboot /bin/bash /root/DbContinuousIntegration/DbContinuousIntegrationWrapper.sh 2> /dev/null > /dev/null &' diff --git a/composer.json b/composer.json index 2715637..b71b5ba 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,6 @@ { "require": { - "denpa\/php-bitcoinrpc": "^2.2" + "psr/log": "*", + "symfony/console": "*" } -} +} \ No newline at end of file diff --git a/composer.json.php b/composer.json.php new file mode 100644 index 0000000..6ff4959 --- /dev/null +++ b/composer.json.php @@ -0,0 +1,44 @@ + PDO::ERRMODE_EXCEPTION, + PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, +]; + +try { + $pdo = new PDO($dsn, "root", "", $options); + + // Fetch dependencies + $stmt = $pdo->query("SELECT VendorName, PackageName, VersionOrBranch FROM Composer ORDER BY VendorName, PackageName"); + $require = []; + foreach ($stmt as $row) { + $require["{$row['VendorName']}/{$row['PackageName']}"] = $row['VersionOrBranch']; + } + + // Fetch repositories + $stmt = $pdo->query("SELECT RepositoryType, RepositoryUrl FROM Composer WHERE RepositoryUrl IS NOT NULL ORDER BY VendorName, PackageName"); + $repositories = []; + foreach ($stmt as $row) { + $repositories[] = [ + 'type' => $row['RepositoryType'], + 'url' => $row['RepositoryUrl'], + ]; + } + + // Build composer.json content + $composerJson = [ + 'require' => $require, + ]; + if (!empty($repositories)) { + $composerJson['repositories'] = $repositories; + } + + // Write to file + file_put_contents('php://stdout', json_encode($composerJson, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); + file_put_contents("php://stderr", "✅ composer.json generated successfully.\n"); + +} catch (PDOException $e) { + file_put_contents("php://stderr","❌ Database error: " . $e->getMessage() . "\n"); +} diff --git a/plt/index.php b/plt/index.php index 5bbfd50..c957be8 100755 --- a/plt/index.php +++ b/plt/index.php @@ -166,7 +166,7 @@ function updateDatabaseRow($tableName, $originalRow, $newRowValue) { $setStatements = []; foreach ($newRowValue as $k => $v) { - $value = is_numeric($v) ? $v : "'" . str_replace("'", "''", $v) . "'"; + $value = is_numeric($v) ? $v : "'" . str_replace("'", "''", is_string($v)?$v:json_encode($v)) . "'"; $setStatements[] = "$k = $value"; } diff --git a/plt/runSandboxedPython.inc.php b/plt/runSandboxedPython.inc.php index 63a1645..77e443c 100644 --- a/plt/runSandboxedPython.inc.php +++ b/plt/runSandboxedPython.inc.php @@ -11,6 +11,7 @@ function runSandboxedPython($code, &$stdout = null, &$stderr = null) { // Create a temporary file to hold the Python code $tempFile = tempnam(sys_get_temp_dir(), 'sandboxed_') . '.py'; + echo "Creating ".redText("python temp code file")." for sandboxed execution at: $tempFile \n"; // Write the generated Python code to the temporary file file_put_contents($tempFile, $code); diff --git a/sys.php b/sys.php index 30f3cf6..97c0461 100755 --- a/sys.php +++ b/sys.php @@ -110,9 +110,7 @@ function sql_read_and_hydrate($query) { foreach ($rows as &$row) { foreach ($fks as $fk) { $col = $fk['COLUMN_NAME']; - if (!isset($row[$col])) { - continue; - } + if (!isset($row[$col])) continue; $val = $row[$col]; if ($val === null) {