Example #1
0
 private function profileTyreBitrix($mode = 'run', $priceType = null)
 {
     if ($mode == 'info') {
         return ['name' => 'Экспорт шин в Битрикс', 'description' => 'Экспорт шин в Битрикс'];
     }
     if ($mode == 'run') {
         function saveRow($curGoodId, $arOffers, &$arStrToSave)
         {
             $arrGood = Goods::getName($curGoodId, 'array');
             $arRow['good']['id'] = $curGoodId;
             $arRow['good']['heigth'] = $arrGood['values']['tyre_heigth'];
             $arRow['good']['width'] = $arrGood['values']['tyre_width'];
             $arRow['good']['dia'] = $arrGood['values']['tyre_dia'];
             $arRow['good']['i_load'] = $arrGood['values']['tyre_i_load'];
             $arRow['good']['i_speed'] = $arrGood['values']['tyre_i_speed'];
             $arRow['good']['model'] = $arrGood['values']['tyre_model'];
             $arRow['good']['rf'] = $arrGood['values']['tyre_rf'] ? 'да' : '';
             $arRow['good']['brand'] = $arrGood['values']['tyre_brand'];
             $arRow['good']['season'] = $arrGood['values']['tyre_season'];
             $arRow['good']['type_auto'] = $arrGood['values']['tyre_type_auto'];
             $arRow['good']['spike'] = $arrGood['values']['tyre_spike'] ? 'да' : '';
             $arRow['offers'] = $arOffers;
             $arStrToSave[] = serialize($arRow);
         }
         function saveOffer($arOffer, &$arStrToSave)
         {
             $curGoodId = $arOffer['goods_id'];
             if (!isset($arStrToSave[$curGoodId])) {
                 $arrGood = Goods::getName($curGoodId, 'array');
                 $arRow['id'] = $curGoodId;
                 $arRow['goods_type'] = $arOffer['goods_type_type'];
                 $arRow['name'] = Goods::getName($curGoodId);
                 $arRow['heigth'] = $arrGood['values']['tyre_heigth'];
                 $arRow['width'] = $arrGood['values']['tyre_width'];
                 $arRow['dia'] = $arrGood['values']['tyre_dia'];
                 $arRow['i_load'] = $arrGood['values']['tyre_i_load'];
                 $arRow['i_speed'] = $arrGood['values']['tyre_i_speed'];
                 $arRow['model'] = $arrGood['values']['tyre_model'];
                 $arRow['rf'] = $arrGood['values']['tyre_rf'] ? 44 : '';
                 $arRow['brand'] = $arrGood['values']['tyre_brand'];
                 $arRow['season'] = $arrGood['values']['tyre_season'];
                 $arRow['type_auto'] = $arrGood['values']['tyre_type_auto'];
                 $arRow['spike'] = $arrGood['values']['tyre_spike'] ? 3 : '';
                 $arStrToSave[$curGoodId]['g'] = $arRow;
             }
             unset($arOffer['name'], $arOffer['goods_type_type']);
             $arStrToSave[$curGoodId]['o'][$arOffer['providers_id']] = $arOffer;
         }
         function clearFiles($file)
         {
             file_put_contents($file, '');
         }
         function saveFiles($file, $arStrToSave)
         {
             return;
             foreach ($arStrToSave as $gId => $arGO) {
                 $arStrToSave[$gId] = json_encode($arGO);
             }
             print count($arStrToSave) . '<br>';
             file_put_contents($file, implode(chr(10), $arStrToSave), FILE_APPEND);
         }
         $folder_local = $_SERVER['DOCUMENT_ROOT'] . '/unload/';
         $file_name = 'tyre_bitrix.txt';
         $file = $folder_local . $file_name;
         clearFiles($file);
         // Очистить файл
         $arStrToSave = [];
         // Список поставщиков
         $arProviders = \yii\helpers\ArrayHelper::map(\app\models\Providers::find()->all(), 'id', 'name');
         // Список оферов шин
         $sql = "select * from offers as O INNER JOIN goods as G where O.goods_id = G.id and G.goods_type_type = 'tyre'";
         $arOffers = \Yii::$app->db->createCommand($sql)->queryAll();
         //            exit();
         $curGoodId = 0;
         foreach ($arOffers as $k => $arOffer) {
             print $k . '--<br>';
             saveOffer($arOffer, $arStrToSave);
             if ($k % 10 == 0) {
                 // Сохранить на диск
                 saveFiles($file, $arStrToSave);
                 $arStrToSave = [];
             }
         }
         if (count($arStrToSave) > 0) {
             saveFiles($file, $arStrToSave);
         }
         // передать на сайт
         $folder_remout = '/home/s/shina93/shincenter/public_html/upload/';
         copy($file, $folder_remout . $file_name);
         //            $host = 'brevitas.timeweb.ru';
         //            $user = '******';
         //            $password = '******';
         //            $this->sendTrouthFTP($host, $user, $password, $folder_local, $file_name, $folder_remout);
     }
 }
Example #2
0
require_once 'database/FileUtil.php';
require_once 'security/validation.php';
require_once 'security/rbac.php';
?>

<?php 
if (!authenticate(3)) {
    die("没有权限");
}
?>

<?php 
//PDO_Class_Wrapper version
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $pageId = validateId(htmlspecialchars($_POST["pageId"]));
    $photos = saveFiles("photoName", "photo/");
    //不判断附件是否上传成功
    $isCorrect = true;
    $db->start();
    for ($i = 0; $i < count($photos); $i++) {
        $photoData = array("path" => $photos[$i], "name" => basename($photos[$i]), "pageId" => $pageId);
        // 		print_r($photos);
        $photoId = $db->insert('photo', $photoData)->getLastInsertId();
        if (!$photoId > 0) {
            $isCorrect = false;
        }
    }
    if ($isCorrect) {
        $db->end();
        echo "添加成功" . "<br>";
        echo '<br><a href="controller.php">返回管理页面</a>';
Example #3
0
     foreach ($currentArticleAttachments as $currentArticleAttachment) {
         deleteFile($currentArticleAttachment['path']);
     }
     $aWhere = array('articleId' => $articleId);
     if ($db->delete('attachment', $aWhere)->affectedRows() > 0) {
         echo '删除原来附件成功';
     }
 }
 $aWhere = array('articleId' => $articleId);
 $aData = array("title" => $title, "author" => $author, "content" => $content, "pageId" => $pageId, "modifyTime" => $now, "type" => $type, "picturePath" => $picturePath);
 $isCorrect = true;
 if (!$db->update('article', $aData, $aWhere)->affectedRows() > 0) {
     $db->back();
     die("修改失败");
 }
 $attachments = saveFiles("attachmentName", "attachment/");
 //不判断附件是否上传成功
 for ($i = 0; $i < count($attachments); $i++) {
     $attachmentData = array("path" => $attachments[$i], "name" => basename($attachments[$i]), "articleId" => $articleId);
     // 		print_r($attachmentData);
     $attachmentId = $db->insert('attachment', $attachmentData)->getLastInsertId();
     if (!$attachmentId > 0) {
         $isCorrect = false;
     }
 }
 if ($isCorrect) {
     $db->end();
     echo "修改成功";
     echo '<br><a href="controller.php">返回管理页面</a>';
 } else {
     $db->back();
Example #4
0
        die;
    }
}
$action = rmc_server_var($_REQUEST, 'action', '');
switch ($action) {
    case 'new':
        formFiles();
        break;
    case 'edit':
        formFiles(1);
        break;
    case 'save':
        saveFiles();
        break;
    case 'saveedit':
        saveFiles(1);
        break;
    case 'savegroup':
        saveGroups();
        break;
    case 'saveeditgr':
        saveGroups(1);
        break;
    case 'updategroup':
        updateGroups(1);
        break;
    case 'delete':
        deleteFiles();
        break;
    case 'deletegroup':
        deleteGroups();
    echo "No cores with custom translations.\n";
} else {
    echo "Processing " . sizeof($cores) . " cores with custom translations:\n";
    foreach ($cores as $core => $db) {
        $CT = $T;
        $res = DB\dbQuery('SELECT *
            FROM ' . $db . '.translations
            WHERE `type` in (0,2)') or die(DB\dbQueryError());
        while ($r = $res->fetch_assoc()) {
            foreach ($languages as $l) {
                if (!empty($r[$l])) {
                    $CT[$l][] = "'" . $r['name'] . "':'" . addcslashes($r[$l], "'") . "'";
                }
            }
        }
        saveFiles($CT, $core . '_');
        echo '.';
    }
}
echo "\nDone";
/**
 * save translation array as files
 * @param  array &$T
 * @param  string $prefix prefix used for file names
 * @return void
 */
function saveFiles(&$T, $prefix = '')
{
    $localePath = DOC_ROOT . 'js' . DIRECTORY_SEPARATOR . 'locale' . DIRECTORY_SEPARATOR;
    foreach ($T as $l => &$v) {
        $filename = $localePath . $prefix . $l . '.js';
Example #6
0
 function storeEbook(&$book)
 {
     global $booklibrary_configuration, $mosConfig_absolute_path;
     //check how much files already attachmented
     $efiles_count = 0;
     if (intval($book->id) > 0) {
         $db = JFactory::getDBO();
         $db->setQuery("SELECT count(id) as count FROM #__booklibrary_files where fk_book_id=" . $book->id);
         $rows = $db->loadObjectList();
         $efiles_count = intval($rows[0]->count);
     }
     for ($i = 1; isset($_FILES['new_upload_file' . $i]) || array_key_exists('new_upload_file_url' . $i, $_POST); $i++) {
         //storing e-Document
         $file = JRequest::getVar('new_upload_file' . $i, '', 'files');
         if (!isset($_FILES['new_upload_file' . $i])) {
             continue;
         }
         $uploadFileURL = JRequest::getVar('new_upload_file' . $i, '', 'post');
         $uploadFileURL = strip_tags(trim($uploadFileURL));
     }
     //files upload
     for ($i = 1; isset($_FILES['new_upload_file' . $i]) || array_key_exists('new_upload_file_url' . $i, $_POST); $i++) {
         if (isset($_FILES['new_upload_file' . $i]) && $_FILES['new_upload_file' . $i]['name'] != "") {
             //storing e-Document
             $file = JRequest::getVar('new_upload_file' . $i, '', 'files');
             $ext = pathinfo($file['name'], PATHINFO_EXTENSION);
             $allowed_exts = explode(",", $booklibrary_configuration['allowed_exts']);
             $ext = strtolower($ext);
             if (!in_array($ext, $allowed_exts)) {
                 echo "<script> alert(' File ext. not allowed to upload! - " . $ext . "'); window.history.go(-1); </script>\n";
                 exit;
             }
             $code = guid_blib();
             $file_name = $code . '_' . ebookFilter($file['name']);
             //mime_content_type($file_name);
             //if( !isset($_FILES['new_upload_file'.$i]) ) continue;
             if (intval($file['error']) > 0 && intval($file['error']) < 4) {
                 echo "<script> alert('" . _BOOKLIBRARY_LABEL_EBOOK_UPLOAD_ERROR . " - " . $file_name . "'); window.history.go(-1); </script>\n";
                 exit;
             } else {
                 if (intval($file['error']) != 4) {
                     $file_new = $mosConfig_absolute_path . $booklibrary_configuration['ebooks']['location'] . $file_name;
                     if (!move_uploaded_file($file['tmp_name'], $file_new)) {
                         echo "<script> alert('" . _BOOKLIBRARY_LABEL_EBOOK_UPLOAD_ERROR . " - " . $file_name . "'); window.history.go(-1); </script>\n";
                         exit;
                     }
                     saveFiles($file_name, $book->id);
                 }
             }
         }
         if (array_key_exists('new_upload_file_url' . $i, $_POST) && $_POST['new_upload_file_url' . $i] != "") {
             $uploadFileURL = JRequest::getVar('new_upload_file_url' . $i, '', 'post');
             $uploadFileURL = strip_tags(trim($uploadFileURL));
             $file = $_FILES['new_upload_file' . $i];
             if (intval($file['error']) != 4) {
                 $uploadFileURL = $file['name'];
             }
             saveFiles($uploadFileURL, $book->id);
         }
     }
 }