initial commit

This commit is contained in:
equippedcoding-master
2025-09-17 09:37:06 -05:00
parent 86108ca47e
commit e2c98790b2
55389 changed files with 6206730 additions and 0 deletions

View File

@@ -0,0 +1,284 @@
<?php
require dirname( __DIR__, 5 ) . "/core/api/php/includes/include.php";
function init(){
echo json_encode(array("success" => true));
// EchoJsonObject("hello");
}
if(Input::get("init")){
init();
}
$rootDirectoryLevel = 4;
if(Input::get('publish_website')){
publish_website();
}
if(Input::get('save_website')){
save_website();
}
if(Input::get('retrieve_website_data')){
retrieve_website_data();
}
if(Input::get('upload_image')){
upload_image();
}
if(Input::get('get_webbuilder_data')){
get_webbuilder_data();
}
if(Input::get('create_builder_project')){
create_builder_project();
}
function retrieve_website_data(){
$project_name = Input::get('project_name');
$db = new DB();
$response = array(
'ImagesDirectory' => null,
'ImageUploadURL' => null
);
$rows = $db->query("SELECT * FROM webbuilder WHERE ProjectName='".$project_name."'");
if($rows->count() > 0){
$response['WebsiteData'] = $rows->first()->WebsiteData;
$response['ImagesDirectory'] = $rows->first()->ImagesDirectory;
$response['ImageUploadURL'] = $rows->first()->ImageUploadURL;
$response['ImageUploadName'] = $rows->first()->ImageUploadName;
echo json_encode($response);
}
}
function upload_image(){
if (isset($_FILES['upload_image']['tmp_name'])) {
$project_name = Input::get('project_name');
$db = new DB();
$rows = $db->query("SELECT * FROM webbuilder WHERE ProjectName='".$project_name."'");
if($rows->count() > 0){
$ImagesDirectory = $rows->first()->ImagesDirectory;
$dest = dirname( __DIR__, 3 ) . "/". $ImagesDirectory . "/" . $_FILES["upload_image"]["name"][0];
if(move_uploaded_file($_FILES["upload_image"]["tmp_name"][0], $dest)){
$h = "../../" . $ImagesDirectory . "/" . $_FILES["upload_image"]["name"][0];
$my = array("data" => array($h));
echo json_encode($my);
}else{
echo "failure";
}
}
} else {
echo "total failure";
}
}
function save_website(){
$project_name = Input::get('project_name');
$project_data = Input::get('project_data');
$db = new DB();
$rows = $db->query("SELECT * FROM webbuilder WHERE ProjectName='" .$project_name . "'");
if($rows->count() > 0){
$db2 = new DB();
$db->updateFields('webbuilder',array(
'WebsiteData' => $project_data
),array(
'ProjectName' => $project_name
));
$db2 = null;
}
$db = null;
echo "success";
// $user = $db->insert('webbuilder',array(
// 'WebsiteData' => $project_data,
// ),array(
// 'ProjectName' => $project_name
// ));
}
if(Input::get('runthis')){
runthis();
}
//https://www2.cradle2careertx.xyz/portal/admin/webbuilder/other/request.php?runthis=true
function runthis(){
$handle = curl_init();
$url = "https://api-m.sandbox.paypal.com/v1/oauth2/token";
curl_setopt($handle, CURLOPT_URL, $url);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handle, CURLOPT_HEADER, "Content-Type: application/x-www-form-urlencoded");
curl_setopt($handle, CURLOPT_USERPWD, "AVNCC3PbfoL6D2rUNClTQM93rlELt8KDgn_E1R7QggLC_X2alPFjfGAlueuuLl7sD5FRs46Fx4SA3OF3:EJVgtHL1opRz4TvQmAgCARsinQhtCHH2JX5aa5y_EooG-KUD99exFwc9T9v4gY7Qnr_4dMA0ZRi2sAYS");
curl_setopt($handle, CURLOPT_POSTFIELDS, "grant_type=client_credentials");
$content = curl_exec($handle);
$content = json_decode($content);
print_r($content->access_token);
echo "<br>";
//A21AAI1w_ZXn5eZNezCIod0wsMIOxc9u6pgI5O1abgO6Im9GMhaPTTcFTEAYOvrqzFoBBcFkTyNe_WgOxhxZivsSavokPAF9Q
$headers = [
"Content-Type: application/json",
"Authorization: Bearer " . $content->access_token,
"Accept-Language: en_US"
];
$handle = curl_init();
$url = "https://api-m.sandbox.paypal.com/v1/identity/generate-token";
curl_setopt($handle, CURLOPT_URL, $url);
curl_setopt($handle, CURLOPT_POST, 1);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handle, CURLOPT_HTTPHEADER, $headers);
$content2 = curl_exec($handle);
$content2 = json_decode($content2);
var_dump($content2->client_token);
}
function publish_website(){
global $rootDirectoryLevel;
$data = json_decode( Input::get("data") );
if (!file_exists(dirname( __DIR__, $rootDirectoryLevel ) . "/pages/")) {
mkdir(dirname( __DIR__, $rootDirectoryLevel ) . "/pages", 0777, true);
}
$mainDir = dirname( __DIR__, $rootDirectoryLevel );
$pagesDir = $mainDir . "/pages";
$files = glob($pagesDir); // get all file names
foreach($files as $file){ // iterate files
if(is_file($file)) {
$files .= "\t" . $file;
unlink($file); // delete file
}
}
array_map( 'unlink', array_filter((array) glob($pagesDir . "/*") ) );
for($i=0; $i < count($data->pagesData); $i++){
if($data->pagesData[$i]->enabled == false) { continue; }
if($data->pagesData[$i]->name == "home"){
$htmlFile = $mainDir . "/index.php";
$contents = html_boilerplate("Cradle 2 Career",$data->pagesData[$i]->name, $data->pagesData[$i]->html,"pages/");
createFile($htmlFile, $contents);
}else{
$htmlFile = $pagesDir . "/" . $data->pagesData[$i]->name . ".php";
$contents = html_boilerplate("Cradle 2 Career",$data->pagesData[$i]->name, $data->pagesData[$i]->html,"");
createFile($htmlFile, $contents);
}
$cssFile = $pagesDir . "/" . $data->pagesData[$i]->name . ".css";
createFile($cssFile, $data->pagesData[$i]->css);
}
echo $file; //"SERVER PUBLISHED";
}
function createFile($file,$content){
$myfile = fopen($file, "w") or die("Unable to open file!");
fwrite($myfile, $content);
fclose($myfile);
}
function html_boilerplate($title,$pageName,$body,$prefix){
$jsFile = "";
if($pageName == "home"){
$jsFile = "core/js/main.js";
}else{
$jsFile = "../core/js/main.js";
}
$hello = $prefix . $pageName;
$html = "<?php
\$handle = curl_init();
\$url = \"https://api-m.sandbox.paypal.com/v1/oauth2/token\";
curl_setopt(\$handle, CURLOPT_URL, \$url);
curl_setopt(\$handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt(\$handle, CURLOPT_HEADER, \"Content-Type: application/x-www-form-urlencoded\");
curl_setopt(\$handle, CURLOPT_USERPWD, \"AVNCC3PbfoL6D2rUNClTQM93rlELt8KDgn_E1R7QggLC_X2alPFjfGAlueuuLl7sD5FRs46Fx4SA3OF3:EJVgtHL1opRz4TvQmAgCARsinQhtCHH2JX5aa5y_EooG-KUD99exFwc9T9v4gY7Qnr_4dMA0ZRi2sAYS\");
curl_setopt(\$handle, CURLOPT_POSTFIELDS, \"grant_type=client_credentials\");
\$content = curl_exec(\$handle);
\$content = json_decode(\$content);
\$headers = [
\"Content-Type: application/json\",
\"Authorization: Bearer \" . \$content->access_token,
\"Accept-Language: en_US\"
];
\$handle = curl_init();
\$url = \"https://api-m.sandbox.paypal.com/v1/identity/generate-token\";
curl_setopt(\$handle, CURLOPT_URL, \$url);
curl_setopt(\$handle, CURLOPT_POST, 1);
curl_setopt(\$handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt(\$handle, CURLOPT_HTTPHEADER, \$headers);
\$content2 = curl_exec(\$handle);
\$content2 = json_decode(\$content2);
\$clientToken = \$content2->client_token;
?>
<!DOCTYPE html>
<html lang=\"en\">
<head>
<meta charset=\"UTF-8\">
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">
<meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\">
<title>$title</title>
<link rel=\"stylesheet\" href=\"$hello.css\">
<link rel=\"stylesheet\" href=\"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css\">
<link rel=\"stylesheet\" href=\"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css\">
<link rel=\"stylesheet\" href=\"https://fonts.googleapis.com/css2?family=Poppins:wght@400;600&display=swap\">
<link rel=\"stylesheet\" href=\"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta2/css/all.min.css\">
<link rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css\" integrity=\"sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65\" crossorigin=\"anonymous\">
<!-- Sample PayPal credentials (client-id) are included -->
<!-- <script src=\"https://www.paypal.com/sdk/js?client-id=test&currency=USD&intent=capture&enable-funding=venmo\" data-sdk-integration-source=\"integrationbuilder\"></script> -->
<script src=\"https://www.paypal.com/sdk/js?components=buttons,hosted-fields&client-id=AbehsBM-Cg5UwIx6pAWObkiltltLPwN82QlhN-u4qwYMD7Fzly_mDmUGYnSJqHuMLIWjhBk9I5iKsvIN\"data-client-token=\"<?php echo \$clientToken; ?>\"></script>
<script src=\"https://code.jquery.com/jquery-3.6.3.min.js\" integrity=\"sha256-pvPw+upLPUjgMXY0G+8O0xUf+/Im1MZjXxxgOcBQBXU=\" crossorigin=\"anonymous\"></script>
<script src=\"$jsFile\"></script>
</head>
" . $body . "
</html>
";
return $html;
}
?>