Beispiel #1
0
 public function fileRead($fileName, $mode, $first_column = NULL)
 {
     if ($handle = FileUpload::uploadFile($fileName, $mode)) {
         while ($row = fgetcsv($handle, ',')) {
             if ($first_column) {
                 $column_header = $row;
                 $first_column = FALSE;
             }
             if ($first_column === FALSE) {
                 $record = array_combine($column_header, $row);
                 $records[] = $record;
             }
             if ($first_column === NULL) {
                 $records[] = $row;
             }
         }
         //end while loop
         FileUpload::fileClose($handle);
     }
     //end fileUpload if
     return $records;
 }
Beispiel #2
0
        $filename = $up->getNewFileName();
        unlink("../../images/environment/" . $_POST[env_pic]);
    } else {
        $filename = $_POST[env_pic];
    }
    $db->query("update cp set cp_info_type_zh_cn='{$_POST['zh_cn']}',cp_info_type_en='{$_POST['en']}',cp_info_value_zh_cn='{$_POST['content']}'," . "cp_info_value_en='{$_POST['content2']}', path='{$filename}' where id='" . $_POST[envid] . "'");
    echo "<script>alert('设备环境信息修改成功!');location.href='../envlist.php';</script>";
} else {
    if (isset($_POST[task]) && "addEnv" == $_POST[task]) {
        //文件保存目录URL
        $save_path = '../../images/environment';
        //定义允许上传的文件扩展名
        $ext_arr = array('gif', 'jpg', 'png');
        require "../action/FileUpload.class.php";
        $up = new FileUpload(array('isRandName' => true, 'allowType' => $ext_arr, 'FilePath' => $save_path, 'MAXSIZE' => 100000));
        //100k
        if ($up->uploadFile('env_pic')) {
            $filename = $up->getNewFileName();
            $db->query("insert into cp(cp_info_type_zh_cn,cp_info_type_en,cp_info_value_zh_cn," . "cp_info_value_en,remark,path,create_date) values('{$_POST['zh_cn']}','{$_POST['en']}','{$_POST['content']}'," . "'{$_POST['content2']}','DeviceContext','{$filename}',now())");
            echo "<script>alert('设备环境信息添加成功!');location.href='../envlist.php';</script>";
        } else {
            echo "<script>alert('设备环境信息添加失败,请重试!');location.href='../envlist.php';</script>";
        }
    } else {
        if (isset($_GET[task]) && "deleteEnv" == $_GET[task]) {
            $db->query("delete from cp where id='{$_GET['envid']}'");
            unlink("../../images/environment/" . $_GET[path]);
            echo "<script>alert('设备环境信息删除成功!');location.href='../envlist.php';</script>";
        }
    }
}
Beispiel #3
0
     if ($up->uploadFile('case4')) {
         //上传后产品图片名称 放到数据库
         $filename4 = "images/case/" . $up->getNewFileName();
     }
     $db->query("insert into `case`(case_name,case_type,case_url,case_cust,case_desc,create_date,case_pic,case_pic_a,case_pic_b,case_pic_c) " . "values('{$_POST['name']}','{$_POST['type']}','{$_POST['url']}','{$_POST['cust']}','" . replace($_POST[content]) . "',now(),'{$filename1}','{$filename2}','{$filename3}','{$filename4}')");
     echo "<script>if(confirm('增加案例成功,是否继续新增?')){location.href='../addcase.php';}else{ location.href='../case.php';}</script>";
 } else {
     if (isset($_POST[task]) && "updateCase" == $_POST[task]) {
         //文件保存目录URL
         $save_path = '../../images/case/';
         //定义允许上传的文件扩展名
         $ext_arr = array('gif', 'jpg', 'JGG', 'GIF', 'PNG', 'png');
         require "../action/FileUpload.class.php";
         $up = new FileUpload(array('isRandName' => true, 'allowType' => $ext_arr, 'FilePath' => $save_path, 'MAXSIZE' => 1024 * 500));
         $sql = "update `case` set case_name='{$_POST['name']}',case_type='{$_POST['type']}',case_url='{$_POST['url']}'," . "case_cust='{$_POST['cust']}',";
         if ($up->uploadFile('case1')) {
             //上传后产品图片名称 放到数据库
             $filename1 = "images/case/" . $up->getNewFileName();
             if (file_exists("../../" . $_POST[path1])) {
                 unlink("../../" . $_POST[path1]);
             }
             $sql = $sql . " case_pic='{$filename1}',";
         }
         if ($up->uploadFile('case2')) {
             //上传后产品图片名称 放到数据库
             $filename2 = "images/case/" . $up->getNewFileName();
             if (file_exists("../../" . $_POST[path2])) {
                 unlink("../../" . $_POST[path2]);
             }
             $sql = $sql . " case_pic_a='{$filename2}',";
         }
Beispiel #4
0
<?php

require "FileUpload.class.php";
$up = new FileUpload(array('isRandName' => true, 'allowType' => array('txt', 'doc', 'php', 'gif'), 'FilePath' => './uploads/', 'MAXSIZE' => 200000));
echo '<pre>';
if ($up->uploadFile('spic')) {
    print_r($up->getNewFileName());
} else {
    print_r($up->getErrorMsg());
}
echo '</pre>';
Beispiel #5
0
                     $filename = "images/" . $up->getNewFileName();
                     unlink("../../" . $_POST[path]);
                 } else {
                     $filename = $_POST[path];
                 }
                 $db->query("update comm_code set type_code='{$filename}',remark='{$_POST['remark']}' where type_name='TopFlashImage' and id='{$_POST['flashid']}'");
                 echo "<script>alert('Flash图片修改成功!');location.href='../flash.php';</script>";
             } else {
                 if (isset($_POST[task]) && "Index_AD" == $_POST[task]) {
                     //文件保存目录URL
                     $save_path = '../../images/';
                     //定义允许上传的文件扩展名
                     $ext_arr = array('gif', 'jpg', 'png');
                     require "../action/FileUpload.class.php";
                     $up = new FileUpload(array('isRandName' => true, 'allowType' => $ext_arr, 'FilePath' => $save_path, 'MAXSIZE' => 1024 * 100));
                     if ($up->uploadFile('adimage')) {
                         $query = $db->query("select type_code from comm_code where type_name='Index_AD' and id='{$_POST['adid']}'");
                         $info = $db->fetch_array($query);
                         $filename = "images/" . $up->getNewFileName();
                         $db->query("update comm_code set type_code='{$filename}',type_content='{$_POST['type_content']}',remark='{$_POST['remark']}' where type_name='Index_AD' and id='{$_POST['adid']}'");
                         unlink("../../" . $info[type_code]);
                         echo "<script>alert('首页广告信息修改成功!');location.href='../indexad.php';</script>";
                     } else {
                         $db->query("update comm_code set type_content='{$_POST['type_content']}',remark='{$_POST['remark']}' where type_name='Index_AD' and id='{$_POST['adid']}'");
                         echo "<script>alert('首页广告信息修改成功!');location.href='../indexad.php';</script>";
                     }
                 }
             }
         }
     }
 }
Beispiel #6
0
         if ($arr['flash']['url']) {
             $picurlarr = explode('/', $arr['flash']['url']);
             if ($picurlarr[count($picurlarr) - 2] != 'guanggao' && $picurlarr[count($picurlarr) - 3] != 'uploadfiles') {
                 //手填路径
                 $ordername = '';
             } else {
                 //选择图片提交
                 $picstr = $picurlarr[count($picurlarr) - 1];
                 $picarr = explode('.', $picstr);
                 array_pop($picarr);
                 $ordername = implode('.', $picarr);
             }
         }
     }
     $up = new FileUpload(array('isRandName' => true, 'allowType' => array('swf'), 'FilePath' => $filepath, 'MAXSIZE' => 20 * 1024 * 1024, 'ordername' => $ordername));
     if ($up->uploadFile('flashpic')) {
         $_POST['adv']['flash']['url'] = '/uploadfiles/guanggao/' . $up->getNewFileName();
     } else {
         redirect($up->getErrorMsg(), '-1');
     }
 }
 //zhaoyanmin end
 $code = addslashes(serialize($_POST['adv']));
 !$varname && alert("广告标识符不能为空");
 if ($id) {
     $DreamCMS->db->query("UPDATE `#DC@__advertise` SET `varname` = '{$varname}',`title` = '{$title}',`style`='{$style}',`starttime` = '{$starttime}',`endtime` = '{$endtime}',`code` = '{$code}',`status` = '{$state}' WHERE `id` ='{$id}'");
 } else {
     $DreamCMS->db->query("INSERT INTO `#DC@__advertise`(`varname` , `title` ,`style`, `starttime` , `endtime` , `code` , `status` ) VALUES ('{$varname}','{$title}','{$style}','{$starttime}', '{$endtime}', '{$code}', '{$state}')");
     $id = $DreamCMS->db->insert_id;
 }
 $jsfile = "YWR2ZXJ0aXNl/{$style}-id-{$id}.js";
Beispiel #7
0
    } else {
        echo "<script>alert('案例发布失败,请重试!');location.href='../addcase.php';</script>";
    }
} else {
    if (isset($_GET[task]) && "deleteCase" == $_GET[task]) {
        $db->query("delete from obj_case where id = '{$_GET['caseid']}'");
        echo "<script>alert('案例删除成功?');location.href='../case.php';</script>";
    } else {
        if (isset($_POST[task]) && "updateCase" == $_POST[task]) {
            //文件保存目录URL
            $save_path = '../../images/case';
            //定义允许上传的文件扩展名
            $ext_arr = array('gif', 'jpg', 'png');
            require "../action/FileUpload.class.php";
            $up = new FileUpload(array('isRandName' => true, 'allowType' => $ext_arr, 'FilePath' => $save_path, 'MAXSIZE' => 100000));
            //100k
            if ($up->uploadFile('casepic')) {
                $filename = $up->getNewFileName();
                unlink("../../images/case/" . $_POST[case_pic]);
            } else {
                $filename = $_POST[case_pic];
            }
            $db->query("update obj_case set case_name='{$_POST['title']}',case_desc='" . replaceContent($_POST[content]) . "',case_pic='{$filename}'," . "lang='{$_POST['lang']}' where id='" . $_POST[caseid] . "'");
            echo "<script>if(confirm('案例信息修改成功,是否继续修改?')){location.href='../updatecase.php?caseid=" . $_POST[caseid] . "';}else{location.href='../case.php';}</script>";
        }
    }
}
function replaceContent($str)
{
    return str_replace("'", "&acute;", $str);
}
    /**
     * Actions creates a new workflow
     *
     * @param sfWebRequest $request
     * @return <type>
     */
    public function executeCreateWorkflow(sfWebRequest $request) {        
        sfLoader::loadHelpers('Url');

        $createWorkObj = new PrepareWorkflowData();
        $data = array();
        $startDate = array();
        $userslot_id = array();

        $endreason = $createWorkObj->createEndreason($request->getPostParameter('createWorkflowFirstTabSettings', array())); // additional settings of the workflow
        $startDate = $createWorkObj->createStartDate($request->getPostParameter('createWorkflowFirstTab_datepicker'),$request->getPostParameter('createWorkflowFirstTab_timepicker')); // create timestamp and flag if workflow is to start just in time
        $content = $createWorkObj->createContenttype($request->getPostParameters()); // create the contenttype of the additionaltext

        $sendToAllSlotsAtOnce = MailinglistVersionTable::instance()->getActiveVersionById($request->getPostParameter('createWorkflowFirstTab_mailinglist'))->toArray(); // get flag if mailinglist is send to all slots at once
        
        // save the workflow to main table
        $workflow = new WorkflowTemplate();
        $workflow->setMailinglisttemplateversionId($sendToAllSlotsAtOnce[0]['id']); // mailinglistversionid
        $workflow->setDocumenttemplateversionId($sendToAllSlotsAtOnce[0]['documenttemplateversion_id']); // documenttemplateversionid
        $workflow->setName($request->getPostParameter('createWorkflowFirstTab_name'));
        $workflow->setSenderId($this->getUser()->getAttribute('id'));
        $workflow->setIsarchived(0);
        $workflow->setIsstopped(0);
        $workflow->setIscompleted(0);
        $workflow->setEndaction($endreason);
        $workflow->save();
        $workflow_id = $workflow->getId();

        // save version
        $workflowtemplate = new WorkflowVersion();
        $workflowtemplate->setWorkflowtemplateId($workflow_id);
        $workflowtemplate->setActiveversion(1);
        $workflowtemplate->setContent($content['content']);
        $workflowtemplate->setStartworkflowAt($startDate['startworkflowat']);
        $workflowtemplate->setContenttype($content['contenttype']);
        $workflowtemplate->setVersion(1);
        $workflowtemplate->setWorkflowisstarted($startDate['workflowisstarted']);
        $workflowtemplate->save();
        $template_id = $workflowtemplate->getId();


        $data = $request->getPostParameter('slot');
        $slotposition = 1;

        // begin to store the slots for the workflow
        foreach($data as $slot) {
            $slotObj = new WorkflowSlot();
            $slotObj->setSlotId($slot['slot']['id']);
            $slotObj->setWorkflowversionId($template_id);
            $slotObj->setPosition($slotposition++);
            $slotObj->save();
            $slot_id = $slotObj->getId();
            $users = $slot['user'];
            $fields = $slot['slot']['field'];
            $userposition = 1;
            // start to save
            foreach($users as $user) {
                $userObj = new WorkflowSlotUser();
                $userObj->setWorkflowslotId($slot_id);
                $user['id'] = $user['id'] == -2 ? $this->getUser()->getAttribute('id') : $user['id']; // remove the placeholder "workflowsender"
                $userObj->setUserId($user['id']);
                $userObj->setPosition($userposition++);
                $userObj->save();
            }
            $fieldposition = 1;
            foreach($fields as $field) { // save all fields for the current slot
                // save parent field element
                $fieldObj = new WorkflowSlotField();
                $fieldObj->setWorkflowslotId($slot_id);
                $fieldObj->setFieldId($field['field_id']);
                $fieldObj->setPosition($fieldposition++);
                $fieldObj->save();
                $field_id = $fieldObj->getId();
                // save all field items
                switch ($field['type']) {
                    case 'TEXTFIELD':
                        $textfield = new WorkflowSlotFieldTextfield();
                        $textfield->setWorkflowslotfieldId($field_id);
                        $textfield->setValue($field['value']);
                        $textfield->save();
                        break;
                    case 'CHECKBOX':
                        $textfield = new WorkflowSlotFieldCheckbox();
                        $textfield->setWorkflowslotfieldId($field_id);
                        $textfield->setValue($field['value'] == 'true' ? 1 : 0);
                        $textfield->save();
                        break;
                    case 'NUMBER':
                        $textfield = new WorkflowSlotFieldNumber();
                        $textfield->setWorkflowslotfieldId($field_id);
                        $textfield->setValue($field['value']);
                        $textfield->save();
                        break;
                    case 'DATE':
                        $textfield = new WorkflowSlotFieldDate();
                        $textfield->setWorkflowslotfieldId($field_id);
                        $textfield->setValue($field['value']);
                        $textfield->save();
                        break;
                    case 'TEXTAREA':
                        $textfield = new WorkflowSlotFieldTextarea();
                        $textfield->setWorkflowslotfieldId($field_id);
                        $textfield->setValue($field['value']);
                        $textfield->save();
                        break;
                    case 'RADIOGROUP':
                        $items = $field['item'];
                        $counter = 1;
                        foreach($items as $item) {
                            $userObj = new WorkflowSlotFieldRadiogroup();
                            $userObj->setWorkflowslotfieldId($field_id);
                            $userObj->setFieldradiogroupId($item['id']);
                            $userObj->setValue($item['value'] == 'true' ? 1 : 0);
                            $userObj->setPosition($counter++);
                            $userObj->save();
                        }
                        break;
                    case 'CHECKBOXGROUP':
                        $items = $field['item'];
                        $counter = 1;
                        foreach($items as $item) {
                            $userObj = new WorkflowSlotFieldCheckboxgroup();
                            $userObj->setWorkflowslotfieldId($field_id);
                            $userObj->setFieldcheckboxgroupId($item['id']);
                            $userObj->setValue($item['value'] == 'true' ? 1 : 0);
                            $userObj->setPosition($counter++);
                            $userObj->save();
                        }
                        break;
                    case 'COMBOBOX':
                        $items = $field['item'];
                        $counter = 1;
                        foreach($items as $item) {
                            $userObj = new WorkflowSlotFieldCombobox();
                            $userObj->setWorkflowslotfieldId($field_id);
                            $userObj->setFieldcomboboxId($item['id']);
                            $userObj->setValue($item['value'] == 'true' ? 1 : 0);
                            $userObj->setPosition($counter++);
                            $userObj->save();
                        }
                        break;
                    case 'FILE':
                        $fieldToStore =  $field['filearray'];
                        $allFiles = $_FILES;
                        $file = $allFiles[$fieldToStore];
                        $upload = new FileUpload();
                        $upload->uploadFormFile($file, $field_id,$template_id,$workflow_id);
                    }
            }

        }

        /**
         *  save files from file grid in overview.
         *  files are moved forom ext
         *  $keys[0]['uploadfile']->file1
         *  $keys[1]['uploadfile']->file2
         *  it is also necessary to use $_FILES instead of $request->getFiles()
         */

        $files = $_FILES;
        $keys = array();
        $keys = array_keys($files);
        for($a=0;$a<count($keys);$a++) {
	$key = $keys[$a];
            if(substr_count($key, 'uploadfile') == 1) {
                $fileUpload = new FileUpload();
                $fileUpload->uploadFile($files[$key],$template_id,$workflow_id);
            }
        }

        $context = sfContext::getInstance();
        $context->getConfiguration()->loadHelpers('Partial', 'I18N', 'Url', 'Date', 'CalculateDate', 'ColorBuilder', 'Icon', 'EndAction');

        // check is workflow needs to be started at the moment
        if($startDate['workflowisstarted'] == 1) {
            if($sendToAllSlotsAtOnce[0]['sendtoallslotsatonce'] == 1) { // workflow is send to all slots at once
                $calc = new CreateWorkflow($template_id);
                $calc->setContext($context);
                $calc->setServerUrl(str_replace('/layout', '', url_for('layout/index',true)));
                $calc->addAllSlots();
            }
            else { // workflow is send to single slot first
                $calc = new CreateWorkflow($template_id);
                $calc->setContext($context);
                $calc->setServerUrl(str_replace('/layout', '', url_for('layout/index',true)));
                $calc->addSingleSlot();
            }
        }
        /**
         * set the response of the action.
         * it is needed to use this response when using fileupload in extjs with symfony.
         * extjs is uploading files using iframe. this iframe needs text/html as response
         */


        $this->getResponse()->setHttpHeader('Content-Type','text/html; charset=utf-8');
        $json = array('success' => true);
        $string = '<textarea>'.json_encode($json).'</textarea>';
        $this->renderText($string);
        return sfView::NONE;
    }
Beispiel #9
0
                     echo "<script>if(confirm('文章内容、文件更新成功,是否继续更新?')){location.href='../post/news.action.php?task=toUpdateNews&newsid={$_POST['newsid']}';}else{location.href='../news.php';}</script>";
                 } else {
                     $db->query("update news set title='{$_POST['title']}',click='{$_POST['click']}',content='" . replace($_POST[content]) . "',type_id='{$_POST['type']}' where id='{$_POST['newsid']}'");
                     echo "<script>alert('文章内容更新成功,文件更新失败,请检查上传文件是否符合要求!');location.href='../post/news.action.php?task=toUpdateNews&newsid={$_POST['newsid']}';</script>";
                 }
             }
         } else {
             //文件保存目录URL
             $save_path = '../../images/upload/';
             //201109281154581.jpg
             //定义允许上传的文件扩展名
             $ext_arr = array('jpg', 'gif', 'png');
             require "../action/FileUpload.class.php";
             $up = new FileUpload(array('isRandName' => true, 'allowType' => $ext_arr, 'FilePath' => $save_path, 'MAXSIZE' => 100 * 1024));
             //100k
             if ($up->uploadFile('filepath')) {
                 $filename = "images/upload/" . $up->getNewFileName();
                 $db->query("update news set title='{$_POST['title']}',click='{$_POST['click']}',content='" . replace($_POST[content]) . "'," . "type_id='{$_POST['type']}',isshow='1',path='{$filename}' where id='{$_POST['newsid']}'");
                 if ($_POST[srcisshow] == '1') {
                     if (file_exists("../../" . $_POST[path])) {
                         unlink("../../" . $info[path]);
                     }
                 }
                 echo "<script>if(confirm('文章内容、图片更新成功,是否继续更新?')){location.href='../post/news.action.php?task=toUpdateNews&newsid={$_POST['newsid']}';}else{location.href='../news.php';}</script>";
             } else {
                 $db->query("update news set title='{$_POST['title']}',click='{$_POST['click']}',content='" . replace($_POST[content]) . "'," . "type_id='{$_POST['type']}' where id='{$_POST['newsid']}'");
                 echo "<script>alert('文章内容更新成功,图片更新失败,请检查图片格式是否符合要求!');location.href='../post/news.action.php?task=toUpdateNews&newsid={$_POST['newsid']}';</script>";
             }
         }
     }
 } else {
Beispiel #10
0
        $db->query("insert into cp(cp_info_type_en,cp_info_type_zh_cn,cp_info_value_en,cp_info_value_zh_cn,remark,seq,path,create_date) values('{$_POST['ryzz_name_en']}','{$_POST['ryzz_name_zh_cn']}','" . addslashes($_POST[content2]) . "','" . addslashes($_POST[content]) . "','Honour',null,'{$filename}',now())");
        echo "<script>alert('增加荣誉资质成功');location.href='../ryzz.php';</script>";
    } else {
        echo "<script>alert('增加荣誉资质失败');location.href='../addryzz.php';</script>";
    }
} else {
    if (isset($_GET[task]) && "deleteryzz" == $_GET[task]) {
        $db->query("delete from cp where id = '{$_GET['ryzzid']}'");
        echo "<script>alert('荣誉资质删除成功?');location.href='../ryzz.php';</script>";
    } else {
        if (isset($_POST[task]) && "updateryzz" == $_POST[task]) {
            //文件保存目录URL
            $save_path = '../../images/cert/';
            //定义允许上传的文件扩展名
            $ext_arr = array('gif', 'jpg', 'png');
            require "../action/FileUpload.class.php";
            $up = new FileUpload(array('isRandName' => true, 'allowType' => $ext_arr, 'FilePath' => $save_path, 'MAXSIZE' => 1024 * 500));
            if ($up->uploadFile('ryzz_pic')) {
                $query = $db->query("select path from cp where id='{$_POST['prod_id']}'");
                $info = $db->fetch_array($query);
                $filename = "images/cert/" . $up->getNewFileName();
                $db->query("update cp set cp_info_type_zh_cn='{$_POST['ryzz_name_zh_cn']}',cp_info_type_en='{$_POST['ryzz_name_en']}',cp_info_value_zh_cn='" . addslashes($_POST[content]) . "',cp_info_value_en='" . addslashes($_POST[content2]) . "',path='{$filename}' where id='{$_POST['ryzz_id']}'");
                //unlink("../../".$info[path]);
                echo "<script>alert('修改成功!');location.href='../ryzz.php';</script>";
            } else {
                $db->query("update cp set cp_info_type_zh_cn='{$_POST['ryzz_name_zh_cn']}',cp_info_type_en='{$_POST['ryzz_name_en']}',cp_info_value_zh_cn='" . addslashes($_POST[content]) . "',cp_info_value_en='" . addslashes($_POST[content2]) . "' where id='{$_POST['ryzz_id']}'");
                echo "<script>alert('图片修改失败或者图片没有修改,广告其他信息修改成功!');location.href='../ryzz.php';</script>";
            }
        }
    }
}
Beispiel #11
0
         if ($_POST[content_type] == '2') {
             if ($_POST[old_content_type] == 1 && !empty($_POST[path])) {
                 unlink('../../' . $_POST[path]);
             }
             $db->query("update boya_course set type_id='{$_POST['type_id']}',class_name='{$_POST['classtype']}',path=''," . "open_time='{$_POST['opentime']}',course_name='{$_POST['classname']}',class_hour='{$_POST['hour']}'," . "fee='{$_POST['fee']}',content_type='{$_POST['content_type']}',content='" . replace($_POST[content]) . "' where id='{$_POST['classid']}' ");
             echo "<script>if(confirm('课程修改成功,是否继续修改?')){location.href='../updateclass.php?task=updateClass&classid={$_POST['classid']}';}else{location.href='../classlist.php';}</script>";
         } else {
             //文件保存目录URL
             $save_path = '../../file/';
             //201109281154581.jpg
             //定义允许上传的文件扩展名
             $ext_arr = array('doc', 'docx', 'xls', 'xlsx', 'txt');
             require "../action/FileUpload.class.php";
             $up = new FileUpload(array('isRandName' => true, 'allowType' => $ext_arr, 'FilePath' => $save_path, 'MAXSIZE' => 1024 * 1024 * 10));
             //10M
             if ($up->uploadFile('path')) {
                 $filename = "file/" . $up->getNewFileName();
                 $srcfilename = $up->getSrcFileName();
                 if ($_POST[old_content_type] == 1 && !empty($_POST[path])) {
                     unlink('../../' . $_POST[path]);
                 }
                 $db->query("update boya_course set type_id='{$_POST['type_id']}',class_name='{$_POST['classtype']}'," . "open_time='{$_POST['opentime']}',course_name='{$_POST['classname']}',class_hour='{$_POST['hour']}'," . "fee='{$_POST['fee']}',content_type='{$_POST['content_type']}',path='{$filename}',content='{$srcfilename}'  where id='{$_POST['classid']}' ");
                 echo "<script>if(confirm('课程修改成功,是否继续修改?')){location.href='../updateclass.php?task=updateClass&classid={$_POST['classid']}';}else{location.href='../classlist.php';}</script>";
             } else {
                 $db->query("update boya_course set type_id='{$_POST['type_id']}',class_name='{$_POST['classtype']}'," . "open_time='{$_POST['opentime']}',course_name='{$_POST['classname']}',class_hour='{$_POST['hour']}'," . "fee='{$_POST['fee']}',content_type='{$_POST['content_type']}' where id='{$_POST['classid']}' ");
                 echo "<script>if(confirm('文件修改失败或没有修改,基础信息修改成功,是否继续修改?')){location.href='../addclass.php';}else{location.href='../classlist.php';}</script>";
             }
         }
     }
 } else {
     if (isset($_GET[task]) && "deleteClass" == $_GET[task]) {
$DB = new DB();

$uploadDir = '../../../../quotes/';

$name_prefix = (isset($_REQUEST['company']))?$_REQUEST['company']:'riotquote';
$name_prefix = stripslashes(str_replace(' ','',$name_prefix)); // remove whitespace chars

$rename = $name_prefix.'_'.date('mdy').'_'.date('His', time());


$fileUpload = new FileUpload();
$fileUpload->setUploadedFile($_FILES['quotefile']);
$fileUpload->setUploadDir($uploadDir);
$fileUpload->setRenameFileTo($rename);
$fileUpload->setAllowedExts(array('docx', 'doc', 'txt', 'xls', 'xlsx', 'pdf'));
$fileUpload->uploadFile();
$link = $fileUpload->getRenameFileTo();

if(isset($_REQUEST['e']) && isset($_REQUEST['company'])){
	$sql = "UPDATE leads SET quotefile = '".addslashes($link)."' WHERE id = ".$_REQUEST['e'];
	$DB->query($sql);
}

function getAllowedExts(){
	global $fileUpload;
	$ret = '';
	$ret = $fileUpload->getImploded(', ', $fileUpload->getallowedExts());
	print $ret;
}

function uploadFile(){
    /**
     * the Action restarts the workflow
     * @param sfWebRequest $request
     * @return <type>
     */
    public function executeRestartWorkflow(sfWebRequest $request) {
        sfLoader::loadHelpers('Url');
        $context = sfContext::getInstance();
        $context->getConfiguration()->loadHelpers('Partial', 'I18N', 'Url', 'Date', 'CalculateDate', 'ColorBuilder', 'Icon', 'EndAction');

        
        $createWorkObj = new PrepareWorkflowData();
        $startDate = array();

        $version_id = $request->getParameter('versionid');
        $newValue = $request->getParameter('restartWorkflowFirstTab_useoldvalues',0); // set flag if values form previous version will be used or from the default value of the fields
        $endreason = $createWorkObj->createEndreason($request->getPostParameter('restartWorkflowFirstTabSettings', array())); // set additional settings
        $startDate = $createWorkObj->createStartDate('', ''); // startdate is always at the moment
        $content = $createWorkObj->createRestartContenttype($request->getPostParameters());// ste contenttype of the additional text

        $workflowtemplate_id = WorkflowVersionTable::instance()->getWorkflowVersionById($version_id)->toArray(); // load the current workflowversion


        WorkflowTemplateTable::instance()->updateEndaction($workflowtemplate_id[0]['id'],$endreason); // update the endaction/additionalsettings


        $currentVersion = WorkflowVersionTable::instance()->getLastVersionById($workflowtemplate_id[0]['workflowtemplate_id'])->toArray(); // load the last workflow
        $slots = WorkflowSlotTable::instance()->getSlotByVersionId($version_id); // get all slots for the current workflow


        WorkflowVersionTable::instance()->setVersionInactive($version_id); // set the current version inactive
        WorkflowTemplateTable::instance()->restartWorkflow($workflowtemplate_id[0]['workflowtemplate_id']); // remove stopflag from template

        
        $wfRestart = new RestartWorkflow();
        // set flag if workflow uses old values or not
        $wfRestart->setNewValue($newValue);
        
        //load the data for fields. they contain old values or the default field values. the data array contains slots and its fields, values and users of the last version
        $data = $wfRestart->buildSaveData($slots);

        // create a new instance of the workflow
        $wfVersion = new WorkflowVersion();
        $wfVersion->setWorkflowtemplateId($workflowtemplate_id[0]['workflowtemplate_id']);
        $wfVersion->setActiveversion(1);
        $wfVersion->setContent($content['content']);
        $wfVersion->setStartworkflowAt($startDate['startworkflowat']);
        $wfVersion->setContenttype($content['contenttype']);
        $wfVersion->setWorkflowisstarted($startDate['workflowisstarted']);
        $wfVersion->setVersion($currentVersion[0]['version']+1);
        $wfVersion->save();
        $newVersionId = $wfVersion->getId();

        /*
        * to transfer the last version of the workflow into a new one, it is needed to copy
        * the old version and set new relations (ids). $slotCounter stores the id's of the
        * new created slots, user and userproeccess, to replace the old values with the new ones.
        */
        $dataStore = array();
        $slotCounter = 0;

        foreach($data as $slot) {

            $singleSlot = new WorkflowSlot();
            $singleSlot->setWorkflowversionId($newVersionId);
            $singleSlot->setSlotId($slot['slot_id']);
            $singleSlot->setPosition($slot['position']);
            $singleSlot->save();

            $slotId = $singleSlot->getId();
            // ids of created slots
            $dataStore[$slotCounter]['slot_id'] = $slotId;

            $fields = $slot['fields']; // the fields of the slot
            $users = $slot['users']; // the users of the slot

            // create the fields for the slot and set the value
            foreach($fields as $field) {
                $newField = new WorkflowSlotField();
                $newField->setWorkflowslotId($slotId);
                $newField->setFieldId($field['field_id']);
                $newField->setPosition($field['position']);
                $newField->save();
                $fieldId = $newField->getId();
                switch($field['type']) {
                    case 'TEXTFIELD':
                        $newField = new WorkflowSlotFieldTextfield();
                        $newField->setWorkflowslotfieldId($fieldId);
                        $newField->setValue($field['items'][0]['value']);
                        $newField->save();
                        break;
                    case 'CHECKBOX':
                        $newField = new WorkflowSlotFieldCheckbox();
                        $newField->setWorkflowslotfieldId($fieldId);
                        $newField->setValue($field['items'][0]['value']);
                        $newField->save();
                        break;
                    case 'NUMBER':
                        $newField = new WorkflowSlotFieldNumber();
                        $newField->setWorkflowslotfieldId($fieldId);
                        $newField->setValue($field['items'][0]['value']);
                        $newField->save();
                        break;
                    case 'DATE':
                        $newField = new WorkflowSlotFieldDate();
                        $newField->setWorkflowslotfieldId($fieldId);
                        $newField->setValue($field['items'][0]['value']);
                        $newField->save();
                        break;
                    case 'TEXTAREA':
                        $newField = new WorkflowSlotFieldTextarea();
                        $newField->setWorkflowslotfieldId($fieldId);
                        $newField->setValue($field['items'][0]['value']);
                        $newField->save();
                        break;
                    case 'RADIOGROUP':
                        $items = $field['items'];
                        foreach($items as $item) {
                            $newField = new WorkflowSlotFieldRadiogroup();
                            $newField->setWorkflowslotfieldId($fieldId);
                            $newField->setFieldradiogroupId($item['fieldradiogroup_id']);
                            $newField->setValue($item['value']);
                            $newField->setPosition($item['position']);
                            $newField->save();
                        }
                        break;
                    case 'CHECKBOXGROUP':
                        $items = $field['items'];
                        foreach($items as $item) {
                            $newField = new WorkflowSlotFieldCheckboxgroup();
                            $newField->setWorkflowslotfieldId($fieldId);
                            $newField->setFieldcheckboxgroupId($item['fieldradiogroup_id']);
                            $newField->setValue($item['value']);
                            $newField->setPosition($item['position']);
                            $newField->save();
                        }
                        break;
                    case 'COMBOBOX':
                        $items = $field['items'];
                        foreach($items as $item) {
                            $newField = new WorkflowSlotFieldCombobox();
                            $newField->setWorkflowslotfieldId($fieldId);
                            $newField->setFieldcomboboxId($item['fieldradiogroup_id']);
                            $newField->setValue($item['value']);
                            $newField->setPosition($item['position']);
                            $newField->save();
                        }
                        break;
                    case 'FILE':
                        $moveFile = new FileUpload();
                        $moveFile->moveFile($field['items'][0], $newVersionId,$workflowtemplate_id[0]['workflowtemplate_id'], $request->getParameter('versionid'));
                        $newField = new WorkflowSlotFieldFile();
                        $newField->setWorkflowslotfieldId($fieldId);
                        $newField->setFilename($field['items'][0]['filename']);
                        $newField->setHashname($field['items'][0]['hashname']);
                        $newField->save();
                        break;
                    
                }
            }

            // save the users for a slot
            $userCounter = 0;
            foreach($users as $user) {
                $wfSlotUser = new WorkflowSlotUser();
                $wfSlotUser->setWorkflowslotId($slotId);
                $wfSlotUser->setPosition($user['position']);
                $wfSlotUser->setUserId($user['user_id']);
                $wfSlotUser->save();
                // store the new id of the user and its user_id
                $dataStore[$slotCounter]['slotuser_id'][$userCounter]['id'] = $wfSlotUser->getId();
                $dataStore[$slotCounter]['slotuser_id'][$userCounter++]['user_id'] = $user['user_id'];
            }
            $slotCounter++;

        }

         
        /**
         *  save files from file grid in overview.
         *  files are moved forom ext
         *  $keys[0]['uploadfile']->file1
         *  $keys[1]['uploadfile']->file2
         *  it is also necessary to use $_FILES instead of $request->getFiles()
         */
        $files = $_FILES;
        $keys = array();
        $keys = array_keys($files);

        for($a=0;$a<count($keys);$a++) {
	$key = $keys[$a];
            if(substr_count($key, 'uploadfile') == 1) {
                $fileUpload = new FileUpload();
                $fileUpload->uploadFile($files[$key],$newVersionId,$workflowtemplate_id[0]['workflowtemplate_id']);
            }
        }
        $workflowTemplate = WorkflowTemplateTable::instance()->getWorkflowTemplateByVersionId($version_id)->toArray();

        
        $sendToAllSlotsAtOnce = MailinglistVersionTable::instance()->getActiveVersionById($workflowTemplate[0]['mailinglisttemplateversion_id'])->toArray();
        if($request->getPostParameter('restartWorkflowFirstTab_startpoint') == 'BEGINNING'){ // workflow starts from beginning
            // check if mailinglist is send to all slots at once, no workflowprocessuser data is needed to be loaded
            if($sendToAllSlotsAtOnce[0]['sendtoallslotsatonce'] == 1) { // create all slots
                $calc = new CreateWorkflow($newVersionId);
                $calc->setServerUrl(str_replace('/layout', '', url_for('layout/index',true)));
                $calc->setContext($context);
                $calc->addAllSlots();
            }
            else { // create a single slot
                $calc = new CreateWorkflow($newVersionId);
                $calc->setServerUrl(str_replace('/layout', '', url_for('layout/index',true)));
                $calc->setContext($context);
                $calc->addSingleSlot();
            }
        }
        else if ($request->getPostParameter('restartWorkflowFirstTab_startpoint') == 'LASTSTATION') { // workflow is send to last station
            $wfRestart = new RestartWorkflow();
            $wfRestart->setContext($context);
            $wfRestart->setServerUrl(str_replace('/layout', '', url_for('layout/index',true)));
            // load the workflowprocessuser / workflowprocess data of the old version
            $lastStationdata = $wfRestart->getRestartData($version_id);
            // write the oldversions workflowprocessuser/workflowprocess and set the new id's from $dataStore array
            $wfRestart->restartAtLastStation($lastStationdata, $dataStore, $newVersionId, $workflowtemplate_id[0]['workflowtemplate_id']);
        }
        else { // workflow will start at specific station
            $slotOrder = array();
            $slotOrder = explode('__', $request->getPostParameter('restartWorkflowFirstTab_startpointid'));
            $slotPosition = $slotOrder[1]; // Slot Position worklfow must start
            $userPosition = $slotOrder[3]; // position of the user in the slot. e.g. Slot 3 and User 2
            $currentUserSlotId = $dataStore[0]['slotuser_id'][0]['id']; // get Id of the first WorkflowSlot of the restarted Workflow
            $newUserSlotId = $dataStore[$slotPosition-1]['slotuser_id'][$userPosition-1]['id']; // get Id of the first WorkflowSlotUser of the restarted Workflow
            $direction = 'UP'; // direction is UP!

            // write first Process
            $wfProcess = new WorkflowProcess();
            $wfProcess->setWorkflowtemplateId($workflowtemplate_id[0]['workflowtemplate_id']);
            $wfProcess->setWorkflowversionId($newVersionId);
            $wfProcess->setWorkflowslotId($dataStore[0]['slot_id']);
            $wfProcess->save();
            $wfProcessId = $wfProcess->getId();

            // write first user
            $wfProcessUser = new WorkflowProcessUser();
            $wfProcessUser->setWorkflowprocessId($wfProcessId);
            $wfProcessUser->setWorkflowslotuserId($dataStore[0]['slotuser_id'][0]['id']);
            $wfProcessUser->setUserId($dataStore[0]['slotuser_id'][0]['user_id']);
            $wfProcessUser->setInprogresssince(time());
            $wfProcessUser->setDecissionstate('WAITING');
            $wfProcessUser->setDateofdecission(time());
            $wfProcessUser->setResendet(0);
            $wfProcessUser->save();
            // use Set Nextstation with direction UP from slot 1 user 1 to defined user e.g. slot 3 and user 2
            $calc = new SetStation($newVersionId, $newUserSlotId, $currentUserSlotId, $direction, $context, str_replace('/layout', '', url_for('layout/index',true)));

        }
        /**
         * set the response of the action.
         * it is needed to use this response when using fileupload in extjs with symfony.
         * extjs is uploading files using iframe. this iframe needs text/html as response
         */
        $this->getResponse()->setHttpHeader('Content-Type','text/html; charset=utf-8');
        $json = array('success' => true);
        $string = '<textarea>'.json_encode($json).'</textarea>';
        $this->renderText($string);
        
        return sfView::NONE;
    }
Beispiel #14
0
     $db->query("delete from boya_news where id = '{$_GET['picid']}'");
     echo "<script>alert('图片删除成功?');location.href='../piclist.php';</script>";
 } else {
     if (isset($_GET[task]) && "toUpdateNews" == $_GET[task]) {
         echo "<script>location.href='../updatenews.php?newsid=" . $_GET[newsid] . "';</script>";
     } else {
         if (isset($_POST[task]) && "updatePicture" == $_POST[task]) {
             //文件保存目录URL
             $save_path = '../../images/picture/';
             //201109281154581.jpg
             //定义允许上传的文件扩展名
             $ext_arr = array('jpg', 'png', 'JPG', 'PNG', 'GIF', 'gif');
             require "../action/FileUpload.class.php";
             $up = new FileUpload(array('isRandName' => true, 'allowType' => $ext_arr, 'FilePath' => $save_path, 'MAXSIZE' => 100000 * 1024));
             //3m
             if ($up->uploadFile('newsfile')) {
                 $filename = "images/picture/" . $up->getNewFileName();
                 $db->query("update boya_news set title='{$_POST['title']}',path='{$filename}'," . "content='{$_POST['content']}' where picid='{$_POST['picid']}'");
                 if (file_exists("../../" . $_POST[path])) {
                     unlink("../../" . $_POST[path]);
                 }
                 echo "<script>if(confirm('图片更新成功,是否继续修改?')){location.href='../updatepic.php?picid={$_POST['picid']}';}else{location.href='../piclist.php';}</script>";
             } else {
                 $db->query("update boya_news set title='{$_POST['title']}',content='{$_POST['content']}' where id='{$_POST['picid']}'");
                 echo "<script>if(confirm('图片信息更新成功,图片文件没有修改或格式不对,是否继续修改?')){location.href='../updatepic.php?picid={$_POST['picid']}';}else{location.href='../piclist.php';}</script>";
             }
         } else {
             if (isset($_POST[task]) && "alldelNews" == $_POST[task]) {
                 $selectsingle = $_POST['selectsingle'];
                 //接收复选框的值   为数组
                 if ($selectsingle != "") {
Beispiel #15
0
                         $db->query($sql);
                         $id = $db->insert_id();
                         echo "<script>alert('视讯信息添加成功,请上传视讯文件?');location.href='../videoadd.php?task=uploadVideoFile&id={$id}';</script>";
                     } else {
                         print_r($up->getErrorMsg());
                         echo "<script>alert('视讯添加失败,是否重试?');location.href='../videoadd.php;</script>";
                     }
                 } else {
                     if (isset($_POST[task]) && "addVideoFile" == $_POST[task]) {
                         //文件保存目录路径
                         $save_path = '../../../video/file/';
                         //定义允许上传的文件扩展名
                         $ext_arr_file = array('swf', 'avi', 'asf', 'mid', 'wmv', 'wma', 'ra');
                         require "FileUpload.class.php";
                         $upFile = new FileUpload(array('isRandName' => true, 'allowType' => $ext_arr_file, 'FilePath' => $save_path, 'MAXSIZE' => 200485760));
                         if ($upFile->uploadFile('upfile')) {
                             //print_r($up->getNewFileName());
                             $fname = $upFile->getNewFileName();
                             $sql = "update video set video_path='../video/file/{$fname}' where id = {$_POST['id']}";
                             $db->query($sql);
                             echo "<script>if(confirm('视讯添加完成,是否继续添加?')){location.href='../videoadd.php';}else{location.href='../videolist.php';}</script>";
                         } else {
                             print_r($upFile->getErrorMsg());
                             echo "<script>alert('视讯添加失败,是否重试?');location.href='../videoadd.php';</script>";
                         }
                     }
                 }
             }
         }
     }
 }
Beispiel #16
0
         $db->query("update menu set name='{$_POST['name']}',seq='{$_POST['seq']}',pid='{$pid}',type='{$type}',`desc`='" . replace($_POST[content]) . "' where id='{$_POST['navid']}'");
         echo "<script>if(confirm('更新成功,是否继续更新?')){location.href='../editnav.php?task=toUpdateNav&navid={$_POST['navid']}';}else{location.href='../nav.php';}</script>";
     }
     //$db->query("update menu set menu_name_zh_cn='$_POST[name_cn]',menu_name_en='$_POST[name_en]',pid='$_POST[type]',`show`='$_POST[show]',remark='$_POST[remark]',url='$_POST[url]' where id='$_POST[navid]'");
     echo "<script>if(confirm('更新成功,是否继续更新?')){location.href='../editnav.php?task=toUpdateNav&navid={$_POST['navid']}';}else{location.href='../nav.php';}</script>";
 } else {
     if (isset($_POST[task]) && "addNav" == $_POST[task]) {
         if ($_POST[pid] != -1) {
             //文件保存目录URL
             $save_path = '../../images/pic/';
             //201109281154581.jpg
             //定义允许上传的文件扩展名
             $ext_arr = array('gif', 'jpg', 'png');
             require "../action/FileUpload.class.php";
             $up = new FileUpload(array('isRandName' => true, 'allowType' => $ext_arr, 'FilePath' => $save_path, 'MAXSIZE' => 1024 * 100));
             if ($up->uploadFile('picture')) {
                 $filename = "images/pic/" . $up->getNewFileName();
                 $type = '';
                 $str = '';
                 $url = '';
                 if ("18" == $_POST[pid]) {
                     //产品
                     $type = $_POST[type];
                     $str = 'prodinfo.php?prodid=';
                 } else {
                     if ('1' == $_POST[pid]) {
                         //解决方案
                         $str = 'solutioninfo.php?solid=';
                     } else {
                         if ('8' == $_POST[pid]) {
                             //it服务
Beispiel #17
0
<?php

require_once 'logincheck.php';
require_once '../library/uploadfile.php';
require_once '../library/excel/reader.php';
$option = array('filepath' => '../upload', 'allowtype' => array('xls'), "maxsize" => "10000000", "israndname" => true);
$file = new FileUpload($option);
if (!$file->uploadFile("uploadfile")) {
    //获取要上传的文件,上传
    $message = $file->getErrorMsg();
} else {
    //插入到数据库中
    $xl = new Spreadsheet_Excel_Reader();
    $xl->setOutputEncoding('CP936');
    $xl->read($option["filepath"] . '/' . iconv("utf-8", "GBK", $file->getNewFileName()));
    $succeed = 0;
    $lost = 0;
    for ($i = 2; $i <= $xl->sheets[0]['numRows']; $i++) {
        $data['STU_NUM'] = str_replace(' ', '', iconv("gb2312", "utf-8", $xl->sheets[0]['cells'][$i][1]));
        $data['STU_NAME'] = str_replace(' ', '', iconv("GBK", "utf-8", $xl->sheets[0]['cells'][$i][2]));
        $data['STU_DEP'] = str_replace(' ', '', iconv("gb2312", "utf-8", $xl->sheets[0]['cells'][$i][3]));
        $data['STU_PSW'] = $data['STU_NUM'];
        $data['EXAM_YEAR'] = str_replace(' ', '', iconv("gb2312", "utf-8", $xl->sheets[0]['cells'][$i][4]));
        if ($db->insert("stuinfo", $data)) {
            $succeed++;
        } else {
            $lost++;
        }
    }
    $message = "成功导入" . $succeed . "条记录,失败" . $lost . "条";
}