function build_con_path($start_id) { $con = new DataBaseTable('content', true, DATACONF); $cq = $con->getData("cid:`= {$start_id}`", array('cid', 'pid', 'title')); $ci = $cq->fetch(PDO::FETCH_OBJ); if ($ci->pid == 0) { return storagename($ci->title); } else { return build_con_path($ci->pid) . "/" . storagename($ci->title); } }
${$var} = $val; } } $db = new DataBaseTable($type, true, DATACONF); $col = substr($type, 0, 1) . "id"; $q = $db->getData($col . ":`= {$id}`"); $data = $q->fetch(PDO::FETCH_OBJ, PDO::FETCH_ORI_FIRST); if (!empty($data->file)) { header("Location: //{$conf->base_uri}/{$data->file}"); } elseif ($type == 'content') { $doc = $data->data; } else { $doc = $data->{$path_parts}[2]; } if (!empty($attachment) && $attachment == 'download') { $filename = storagename($data->title); switch ($format) { /*case 'word': header ("Content-Type: application/msword"); $filename.=".doc"; TODO reformat $doc? create other formats? break;*/ case 'html': $filename .= ".html"; header("Content-Type: text/html"); break; case 'text': default: $filename .= ".txt"; $doc = strip_tags($doc); header("Content-Type: text/plain");
function upload_file($file, $site_settings, $curusr = null, $type = null) { if ($file['error'] == UPLOAD_ERR_OK) { $temp = $site_settings->project_dir . "/temp/" . md5(time()); if (move_uploaded_file($file['tmp_name'], $temp)) { $temp_name = "temp/" . basename($temp); $upload_script = <<<TXT \$("#art .progress-bar span",pDoc).removeClass('sr-only').text("Complete!"); \$("#art .progress-bar",pDoc).addClass("progress-bar-success").attr("aria-valuenow","100").css("width","100%"); \$("input#uriTarget",pDoc).val("{$temp_name}"); \$("button[name='save']",pDoc).removeAttr('disabled'); TXT; } else { $upload_script = <<<TXT \$("#art .progress-bar span",pDoc).removeClass('sr-only').text("Could not stage file as {$temp}!"); \$("#art .progress-bar",pDoc).addClass("progress-bar-danger").attr("aria-valuenow","100").css("width","100%"); TXT; } if ($type == "panel") { if (!empty($curusr)) { $panel = uniquename($site_settings->project_dir . "/" . storagename($curusr->name) . "/", 5); rename($temp, $panel); $file = SITEROOT . storagename($curusr->name) . "/" . basename($panel); } else { $file = SITEROOT . $temp_name; } } $upload_script .= <<<TXT \$(".canvas-asset form",pDoc).remove(); \$(".canvas-asset:not(:has(img))",pDoc).append('<img src="{$file}?w=1280" style="width:100%" alt=\\"New Asset\\">'); TXT; } return <<<HTML <!doctype html> <html> <head> <title>Tower21 WebComiX uploader</title> <!-- Load jQuery --> <script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <!-- Feedback Script --> <script language="javascript" type="text/javascript"> \$(document).ready(function(){ var pDoc=window.parent.document; \$("#art .progress-bar span",pDoc).text("67%"); \$("#art .progress-bar",pDoc).attr("aria-valuenow","66").css("width","67%"); {$upload_script} }); </script> </head> <body> <p>You really shouldn't be seeing this...</p> </body> </html> HTML; }