Ejemplo n.º 1
0
 function save($id = FALSE)
 {
     if ($_POST) {
         $meeting = new Meeting($id);
         $_POST['start_date'] = Date2DB($_POST['start_date']);
         $_POST['end_date'] = Date2DB($_POST['end_date']);
         $_POST['close_date'] = Date2DB($_POST['close_date']);
         $meeting->from_array($_POST);
         $meeting->save();
         fix_file($_FILES['file']);
         foreach ($_POST['doc'] as $key => $doc) {
             if (@$_FILES['file'][$key]['name'] || @$_POST['doc_id'][$key]) {
                 $document = new Meeting_document(@$_POST['doc_id'][$key]);
                 if ($_FILES['file'][$key]['name']) {
                     if (@$_POST['doc_id'][$key]) {
                         $document->delete_file('uploads/meeting', 'file');
                     }
                     $document->file = $document->upload($_FILES['file'][$key], 'uploads/meeting');
                 }
                 $document->name = $doc;
                 $document->meeting_id = $meeting->id;
                 $document->save();
             }
         }
         set_notify('success', lang('save_data_complete'));
     }
     redirect('meetings');
 }
Ejemplo n.º 2
0
function loopfiles($dirName)
{
    $qudir = $qufile = array();
    if (!($d = @dir($dirName))) {
        mysyslog("Die: {$dirName} doesn't exists or have no read permission!\n");
        exit;
    }
    while ($entry = $d->read()) {
        if ($entry != "." && $entry != "..") {
            if (is_dir($dirName . "/" . $entry)) {
                $qudir[] = $entry;
            } else {
                if (eregi(".html", $entry) || eregi(".php", $entry)) {
                    $qufile[] = $dirName . "/" . $entry;
                }
            }
        }
    }
    $count = count($qufile);
    for ($a = 0; $a < $count; $a++) {
        fix_file($qufile[$a]);
    }
    $count = count($qudir);
    for ($a = 0; $a < $count; $a++) {
        loopfiles($dirName . "/" . $qudir[$a]);
    }
    $d->close();
}
Ejemplo n.º 3
0
 function save($id = FALSE)
 {
     if ($_POST) {
         $document = new Document($id);
         $_POST['user_id'] = $this->session->userdata('id');
         $_POST['start_date'] = Date2DB($_POST['start_date']);
         $document->from_array($_POST);
         $document->save();
         fix_file($_FILES['file']);
         foreach ($_POST['doc'] as $key => $doc) {
             if (@$_FILES['file'][$key]['name'] || @$_POST['doc_id'][$key]) {
                 $document_file = new Document_file(@$_POST['doc_id'][$key]);
                 if ($_FILES['file'][$key]['name']) {
                     if (@$_POST['doc_id'][$key]) {
                         $document_file->delete_file('uploads/document', 'file');
                     }
                     $document_file->file = $document_file->upload($_FILES['file'][$key], 'uploads/document');
                 }
                 $document_file->name = $doc;
                 $document_file->document_id = $document->id;
                 $document_file->save();
             }
         }
         set_notify('success', lang('save_data_complete'));
     }
     redirect('documents');
 }
 public function save($id = null)
 {
     if ($this->perm->can_create == 'y') {
         if ($_POST) {
             $data = new Heritage($id);
             if (@$_POST['id'] > 0) {
                 $_POST['updated_by'] = $this->current_user->id;
             } else {
                 $_POST['created_by'] = $this->current_user->id;
             }
             $data->from_array($_POST);
             $data->save();
             $action = $_POST['id'] > 0 ? 'UPDATE' : 'CREATE';
             save_logs($this->menu_id, $action, @$data->id, $action . ' ' . $data->title . ' Heritage');
             $id = $data->id;
             // multiupload
             fix_file($_FILES['files']);
             foreach ($_FILES['files'] as $key => $item) {
                 if ($item) {
                     $heritage_image = new Heritage_image();
                     if ($_FILES['files'][$key]['name']) {
                         $heritage_image->image = $heritage_image->upload($_FILES['files'][$key], 'uploads/heritage_image');
                         $heritage_image->heritage_id = $id;
                         $heritage_image->image_detail = $_POST['image_detail'][$key];
                         $show_no = $this->db->query("SELECT MAX(id)id FROM acm_heritage_images")->result();
                         $heritage_image->show_no = @$show_no[0]->id + 1;
                         $heritage_image->save();
                     }
                 }
             }
             //update image detail
             foreach ($_POST['image_id'] as $key => $item) {
                 if ($item) {
                     $heritage_image = new Heritage_image();
                     $heritage_image->id = $item;
                     $heritage_image->image_detail = $_POST['image_detail2'][$key];
                     $heritage_image->save();
                 }
             }
         }
     }
     redirect('admin/heritages/form/' . $id);
 }
Ejemplo n.º 5
0
 function save($id = false)
 {
     if ($_POST) {
         fix_file($_FILES['filesToUpload']);
         foreach ($_FILES['filesToUpload'] as $key => $item) {
             if ($item) {
                 $gallery = new Gallery();
                 if ($_FILES['filesToUpload'][$key]['name']) {
                     $gallery->image = $gallery->upload($_FILES['filesToUpload'][$key], 'uploads/gallery');
                     $gallery->category_id = $id;
                     $gallery->user_id = $this->session->userdata('id');
                     $gallery->save();
                 }
             }
         }
         set_notify('success', lang('save_data_complete'));
     }
     redirect('galleries/admin/galleries/index/' . $_POST['category_id']);
 }
Ejemplo n.º 6
0
 function save($id = FALSE)
 {
     if ($_POST) {
         $knowledge = new Knowledge($id);
         $_POST['title'] = lang_encode($_POST['title']);
         $_POST['intro'] = lang_encode($_POST['intro']);
         $_POST['detail'] = lang_encode($_POST['detail']);
         $_POST['start_date'] = Date2DB($_POST['start_date']);
         $_POST['end_date'] = Date2DB($_POST['end_date']);
         if (!$id) {
             $_POST['user_id'] = $this->session->userdata('id');
         }
         if ($_FILES['image']['name']) {
             if ($id) {
                 $knowledge->delete_file('uploads/knowledge/thumbnail', 'image');
             }
             $knowledge->image = $knowledge->upload($_FILES['image'], 'uploads/knowledge/thumbnail', 77, 64);
         }
         $knowledge->from_array($_POST);
         $knowledge->save();
         fix_file($_FILES['file']);
         foreach ($_POST['doc'] as $key => $doc) {
             if (@$_FILES['file'][$key]['name'] || @$_POST['doc_id'][$key]) {
                 $knowledge_file = new Knowledge_file(@$_POST['doc_id'][$key]);
                 if ($_FILES['file'][$key]['name']) {
                     if (@$_POST['doc_id'][$key]) {
                         $knowledge_file->delete_file('uploads/knowledge', 'file');
                     }
                     $knowledge_file->file = $knowledge_file->upload($_FILES['file'][$key], 'uploads/knowledge');
                 }
                 $knowledge_file->name = $doc;
                 $knowledge_file->knowledge_id = $knowledge->id;
                 $knowledge_file->save();
             }
         }
         set_notify('success', lang('save_data_complete'));
         redirect($_POST['referer']);
     }
 }
Ejemplo n.º 7
0
function scan_leaf_fixfile($slugArray, $rootDir)
{
    foreach (new DirectoryIterator($rootDir) as $oLang) {
        if (!$oLang->isDir()) {
            continue;
        }
        if ($oLang->isDot()) {
            continue;
        }
        $lang = $oLang->getFilename();
        $files = glob($rootDir . '/' . $lang . '/*.ini');
        foreach ($files as $f) {
            fix_file($f);
        }
    }
}
Ejemplo n.º 8
0
function fix_common($srcdir, $libdir, $plugin)
{
    if (!is_dir($libdir . "common")) {
        die("Missing common directory in {$libdir}\n");
    }
    if (!isset($plugin["main"])) {
        die("Missing \"main\" declaration in plugin.yml\n");
    }
    $path = explode("/", strtr($plugin["main"], "\\", "/"));
    array_pop($path);
    $fpath = implode(DIRECTORY_SEPARATOR, $path);
    $nspath = implode("\\", $path);
    $commondir = $srcdir . "src/" . $fpath . "/common/";
    if (!is_dir($commondir)) {
        mkdir($commondir);
    }
    $commons = [];
    foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($srcdir . "src/" . $fpath)) as $s) {
        if (!is_file($s)) {
            continue;
        }
        if (!preg_match('/\\.php$/', $s)) {
            continue;
        }
        if (basename(dirname($s)) == "common") {
            continue;
        }
        //Ignore files already in common...
        $php_in = file_get_contents($s);
        $php_out = fix_file($php_in, $nspath, $commons);
        if ($php_in != $php_out) {
            echo "Fixing " . substr($s, strlen($srcdir . "src/")) . "\n";
            file_put_contents($s, $php_out);
        }
        //echo "PROCESSING: $s\n";
    }
    // Handle dependencies
    $done = [];
    $queue = array_keys($commons);
    while (count($queue) > 0) {
        $cn = array_pop($queue);
        if (isset($done[$cn])) {
            continue;
        }
        $s = $libdir . "common/" . $cn;
        $d = $commondir . $cn;
        $php_in = file_get_contents($s);
        $mv = [];
        $php_out = fix_file($php_in, $nspath, $mv);
        if (!file_exists($d) || $php_out != file_get_contents($d)) {
            echo "Updating " . substr($d, strlen($srcdir . "src/")) . "\n";
            file_put_contents($d, $php_out);
        }
        $done[$cn] = $cn;
        foreach ($mv as $j => $k) {
            if (isset($done[$j])) {
                continue;
            }
            array_push($queue, $j);
            $commons[$j] = $k;
        }
    }
    // Clean-up unused files
    foreach (glob($commondir . "*.php") as $php) {
        $b = basename($php);
        if (isset($commons[$b])) {
            continue;
        }
        echo "Deleting..." . basename($php) . "\n";
        unlink($php);
    }
}