Esempio n. 1
0
 function actSave()
 {
     global $post;
     $id = $post->getInt('u_id');
     $data = array('login' => $post->get('login'), 'status' => $post->get('status'), 'name' => $post->get('name'), 'company' => $post->get('company'), 'phone' => $post->get('phone'), 'city' => $post->get('city'), 'address' => $post->get('address'), 'mail' => $post->get('mail'), 'avat' => $post->get('avat'), 'balance' => $post->getFloat('balance'), 'discount' => $post->getFloat('discount'), 'hide' => 0, 'type' => $post->get('type'));
     $password = $post->remove('password');
     $avat_path = $post->remove('avat_path');
     $msg = 'Сохранено';
     $img_out = "";
     if (!empty($_FILES['upload']['name']) && isImg($_FILES['upload']['name'])) {
         $img = $this->cfg('AVATAR_PATH') . '/' . md5($_FILES['upload']['tmp_name']) . "." . file_ext($_FILES['upload']['name']);
         move_uploaded_file($_FILES['upload']['tmp_name'], ROOT . $img);
         $data['avat'] = $img;
         $img_out = scaleImg($img, 'w200');
     }
     if ($post->getInt('clear')) {
         $data['avat'] = '';
     }
     $err = array();
     $rs = DB::select("SELECT * FROM sc_users WHERE login='******'login')) . "' AND u_id<>{$id}");
     if ($rs->next()) {
         $err['login'] = '******';
     }
     if (!$err) {
         if ($id === 0) {
             $data[] = "password=MD5('" . trim($password) . "')";
             $id = DB::insert('sc_users', $data, 'u_id');
         } else {
             if (trim($password)) {
                 $data[] = "password=MD5('" . trim($password) . "')";
             }
             DB::update('sc_users', $data, 'u_id=' . $id);
         }
         echo printJSONP(array('msg' => $msg, 'u_id' => $id, 'img' => $img_out));
         exit;
     } else {
         echo printJSONP(array('err' => $err));
         exit;
     }
 }
Esempio n. 2
0
             $val = $hmorig[$link[1]];
         }
         $urlpart .= "pnsk" . $link[0] . "=" . $val . "&pnob" . $link[0] . "=1&";
     }
     $urlpart = substr($urlpart, 0, strlen($urlpart) - 1);
     $urlpart .= "&pnsm=1";
     $rdnum = rand(0, 99999);
     if ($lastclosed == 0) {
         $out .= "</tr>\n<tr>";
     }
     $out .= "<td width=\"20%\" nowrap>" . $gtbl->getCHN($field) . ":</td><td colspan=\"" . $form_cols . "\"><span id=\"linkinfo_" . $rdnum . "\"></span><script type=\"text/javascript\"> doActionEx('./act/readfield.php?tbl=" . $refdetail[0] . "&" . $urlpart . "&fieldlist=" . $refdetail[2] . "&isheader=0&isoput=0&mode=intbl','linkinfo_" . $rdnum . "');</script></td>\n";
     $tdi++;
     $needcloserow = 1;
 } else {
     if ($fieldinputtype == 'file') {
         $isimg = isImg($fieldv);
         if (strpos($fieldv, "{$shortDirName}/") !== false) {
             $fieldv = str_replace("{$shortDirName}/", "", $fieldv);
         }
         if ($isimg) {
             $fieldv = "<img src='" . $fieldv . "' width='80%' alt='-x-' />";
         }
     }
     if ($gtbl->getSingleRow($field) == '1') {
         if ($tdi > 0) {
             $out .= "</tr>\n<tr idata=\"{$i}-{$lastclosed}\">";
         }
         $out .= "<td>" . $gtbl->getCHN($field) . ":&nbsp;</td><td colspan=\"" . $form_cols . "\"> " . $fieldv . " </td>";
         $needcloserow = 1;
     } else {
         $out .= "<td nowrap idata=\"{$i}\" fieldname=\"{$field}\">" . $gtbl->getCHN($field) . ":&nbsp;</td><td> " . $fieldv . " </td>";
 function actSave()
 {
     global $ST, $get, $post;
     $id = $post->getInt('id');
     $data = array('content' => $post->get('content'), 'description' => $post->get('description'), 'title' => $post->get('title'), 'author' => $post->get('author'), 'date' => dte($post->get('date'), 'Y-m-d'), 'state' => $post->get('state'), 'category' => $post->getInt('category'), 'position' => $post->getInt('position'), 'gallery' => $post->getInt('gallery'), 'type' => $this->getType());
     $img_out = "";
     if (!empty($_FILES['upload']['name']) && isImg($_FILES['upload']['name'])) {
         $img = $this->cfg('NEWS_IMAGE_PATH') . '/' . md5($_FILES['upload']['tmp_name']) . "." . file_ext($_FILES['upload']['name']);
         move_uploaded_file($_FILES['upload']['tmp_name'], ROOT . $img);
         $data['img'] = $img;
         $img_out = scaleImg($img, 'w200');
     }
     if ($post->getInt('clear')) {
         $data['img'] = '';
     }
     if ($id) {
         $ST->update('sc_news', $data, "id=" . $id);
     } else {
         $id = $ST->insert('sc_news', $data);
     }
     $ST->delete('sc_relation', "parent={$id} AND type='public'");
     foreach ($post->getArray('public_rel') as $v) {
         $ST->insert('sc_relation', array('parent' => $id, 'type' => 'public', 'child' => $v));
     }
     $msg = "Сохранено";
     if (true) {
         $content = '';
         $content .= '<small>' . date('d.m.Y') . '</small> ';
         $content .= '<strong>' . $post->getHtml('title') . '</strong><br />';
         $content .= '<span>' . $post->getHtml('description') . '</span><br />';
         $content .= '<a href="http://' . $this->cfg('SITE') . '/' . $post->get('type') . '/' . $id . '/">подробнее...</a>';
         if ($post->exists('save_and_send')) {
             $mail = new Mail();
             $mail->setFromMail(array($this->cfg('SITE'), $this->cfg('mail')));
             $key = 'http://' . $this->cfg('SITE') . '/cabinet/unsubscribe/?key=' . md5($this->getUser('mail') . $this->getType() . 'unsubscribe') . '&type=' . $this->getType() . '&mail=' . $this->getUser('mail');
             $key = '<a href="' . $key . '">' . $key . '</a>';
             $mail->setTemplate('letter_' . $this->getType(), array('FROM_SITE' => $this->cfg('SITE'), 'CONTENT' => $content, 'BODY' => $post->get('content'), 'TITLE' => $post->get('title')));
             $mail->xsend($this->getUser('mail'), array('UNSUBSCRIBE' => $key));
         } elseif ($post->exists('save_and_send_all')) {
             $q = "SELECT distinct mail,id FROM sc_subscribe WHERE type LIKE '%" . $this->getType() . "%' \r\n\t\t\t\tAND NOT EXISTS(SELECT mailid FROM sc_news_sendlog WHERE id=mailid AND newsid={$id}){$this->getMailFilter()}";
             if ($post->getInt('pack')) {
                 $q .= " LIMIT {$post->getInt('pack')}";
             }
             $rs = $ST->select($q);
             $mail = new Mail();
             //				$mail->setFromMail($this->getConfig('mail'));
             $mail->setFromMail(array($this->cfg('SITE'), $this->cfg('mail')));
             $mail->setTemplate('letter_' . $this->getType(), array('FROM_SITE' => $this->cfg('SITE'), 'CONTENT' => $content, 'BODY' => $post->get('content'), 'TITLE' => $post->get('title')));
             $n = 0;
             while ($rs->next()) {
                 if (check_mail($m = trim($rs->get('mail')))) {
                     $key = 'http://' . $this->cfg('SITE') . '/cabinet/unsubscribe/?key=' . md5($rs->get('mail') . $this->getType() . 'unsubscribe') . '&type=' . $this->getType() . '&mail=' . $rs->get('mail');
                     $key = '<a href="' . $key . '">' . $key . '</a>';
                     $mail->xsend($m, array('UNSUBSCRIBE' => $key));
                     $ST->insert('sc_news_sendlog', array('mailid' => $rs->get('id'), 'newsid' => $id));
                     $n++;
                 } else {
                     $ST->delete('sc_subscribe', "mail='" . SQL::slashes($rs->get('mail')) . "'");
                 }
             }
             $msg .= " отправлено {$n}";
         }
     }
     echo printJSONP(array('msg' => $msg, 'id' => $id, 'img' => $img_out));
     exit;
 }
Esempio n. 4
0
\t\t<input type="hidden" name="folderid" value="{$folderid}" />
\t\t{$_AL['folder.inputnewname']}: <input type="text" value="{$folderrow['title']}" size="30" maxlength="50" id="newfoldername" name="newfoldername" class="text_css" /> <input type="button" value="  {$_AL['folder.confirm.modify']}  " onclick="renameFolder()" class="button_css" />
\t</div>
\t<!--#######################-->
\t<div id="movefilediv" style="display:none;">
\t\t{$_AL['folder.targetdir']}: <select name="targetfolder">{$cache_foldersoption}</select> <input type="button" value="  {$_AL['folder.move']}  " onclick="moveFiles()" class="button_css" />
\t</div>
\t<!--#######################-->
\t<div id="delfilediv" style="display:none;">
\t\t{$_AL['folder.del.warning']} <input type="button" value="  {$_AL['folder.confirm.del']}  " onclick="delFiles()" class="button_css" />
\t</div>

</div>
EOT;
foreach ($attachements as $att) {
    if ($att['type'] == 1 && isImg($att['filename'])) {
        $thumb = "../../uploadfile/thumb/" . $att['filepath'];
        $imgwidth = $att['imgwidth'] > 90 ? "style='width:90px;'" : "";
        if (file_exists($thumb)) {
            $img = "<img src=\"{$thumb}\"{$imgwidth} />";
        } else {
            $img = "<img src=\"../../uploadfile/attachment/{$att['filepath']}\"{$imgwidth} />";
        }
    } else {
        $img = "<img src=\"../../images/attachment.gif\" />";
    }
    print <<<EOT
<div class="attitem" id="imgitem_{$att['id']}" title="{$att['filename']}">
\t<input type="checkbox" value="{$att['id']}" name="ids[]" class="checkbox" {$disablestr} />
\t<div class="attiem_imgdiv" title="{$_AL['folder.click2use']}: {$att['filename']}" onclick="useFile('{$att['id']}','{$att['filename']}','{$att['type']}')">{$img}</div>
\t<div class="attiem_filename">{$att['shortfilename']}</div>
                    <?php 
                break;
                ?>
                <?php 
            case 'uri':
                ?>
                <?php 
            case 'bnode':
                ?>
                <?php 
                $obUri = $object['value'];
                $obLabel = $page->data->get_label($obUri);
                ?>
                        
                    <?php 
                if (isImg($obUri)) {
                    ?>
                        <img alt="image of <?php 
                    echo $obLabel;
                    ?>
" src="<?php 
                    echo $obUri;
                    ?>
">
                    <?php 
                } else {
                    ?>
                    <a href="<?php 
                    echo $obUri;
                    ?>
"><?php 
 function actSave()
 {
     global $ST, $get, $post;
     $id = $post->getInt('id');
     $data = array('name' => $post->get('name'), 'img_format' => $post->get('img_format'), 'sort' => $post->getInt('sort'), 'description' => $post->get('description'), 'text' => $post->get('text'), 'type' => $post->get('type'), 'cat' => $post->get('cat'), 'date' => $post->getDate('date'));
     if ($id) {
         $ST->update('sc_gallery', $data, "id=" . $id);
     } else {
         $id = $ST->insert('sc_gallery', $data);
     }
     $d['img'] = $post->get('img');
     $dir = $this->cfg('GALLERY_PATH') . '/' . $id;
     if (!file_exists(ROOT . $dir)) {
         mkdir(ROOT . $dir);
     }
     if (!empty($_FILES['img_upload']['tmp_name']) && isImg($name = $_FILES['img_upload']['name'])) {
         $path = $dir . '/' . md5_file($_FILES['img_upload']['tmp_name']) . '.' . file_ext($name);
         if (!file_exists(ROOT . $path)) {
             rename($_FILES['img_upload']['tmp_name'], ROOT . $path);
             $d['img'] = $path;
         }
     }
     //---
     $i = $post->getArray('images');
     $desc = $post->getArray('desc');
     $format = $post->getArray('format');
     $images = array();
     $img_all = array();
     if ($img_pos = $post->getArray('pos')) {
         //Сортировка картинок
         asort($img_pos);
         foreach ($img_pos as $k => $v) {
             if (!in_array($i[$k], $img_all)) {
                 $img_all[] = $i[$k];
                 $images[] = array('img' => $i[$k], 'description' => $desc[$k], 'format' => $format[$k]);
             }
         }
     }
     foreach ($_FILES['images_upload']['error'] as $k => $err) {
         if ($err != 0) {
             continue;
         }
         if (isset($_FILES['images_upload']['tmp_name'][$k]) && isImg($name = $_FILES['images_upload']['name'][$k])) {
             //				$path=$dir.'/'.encodestring($name);
             $path = $dir . '/' . md5_file($_FILES['images_upload']['tmp_name'][$k]) . '.' . file_ext($name);
             //				$i=0;
             //				while (file_exists(ROOT.$path)) {
             //					$path=$dir.'/'.++$i.'_'.encodestring($name);
             //				}
             if (!file_exists(ROOT . $path)) {
                 rename($_FILES['images_upload']['tmp_name'][$k], ROOT . $path);
             }
             if (!in_array($path, $img_all)) {
                 $img_all[] = $path;
                 $images[] = array('img' => $path, 'description' => '', 'format' => 0);
             }
         }
     }
     $ST->update('sc_gallery', $d, "id=" . $id);
     $ST->delete('sc_gallery_img', "gallery_id={$id}");
     foreach ($images as $n => $i) {
         $ST->insert('sc_gallery_img', $i + array('gallery_id' => $id, 'pos' => $n + 1));
     }
     $ST->delete('sc_gallery_label', "gallery_id={$id}");
     foreach ($post->getArray('label') as $i) {
         $ST->insert('sc_gallery_label', array('gallery_id' => $id, 'label_id' => $i));
     }
     echo printJSONP(array('msg' => 'Сохранено', 'id' => $id, 'images' => $images, 'img' => $d['img']));
 }
 function actApplyMans()
 {
     global $ST, $post;
     if (isset($_FILES['img'])) {
         $img = array();
         foreach ($_FILES['img']['name'] as $id => $name) {
             if (isImg($name)) {
                 $path = 'storage/manufecturer/' . $id . "_" . time() . "." . file_ext($name);
                 if (file_exists($path)) {
                     rename($path, $path . '.' . time());
                 }
                 move_uploaded_file($_FILES['img']['tmp_name'][$id], $path);
                 $ST->update('sc_manufacturer', array('img' => "/" . $path), "id={$id}");
                 $img[$id] = "/" . $path;
             }
         }
         echo printJSONP(array('msg' => 'Обновлено!', 'img' => $img));
         exit;
     }
     $names = $post->get('name');
     if ($sort = $post->get('sort')) {
         foreach ($sort as $id => $val) {
             $ST->update('sc_manufacturer', array('sort' => (int) $val, 'name' => $names[$id]), "id={$id}");
         }
     }
     echo printJSON(array('msg' => 'Обновлено!'));
     exit;
 }
 function actSave()
 {
     global $post;
     $id = $post->getInt('u_id');
     $data = array('login' => $post->get('login'), 'name' => $post->get('name'), 'company' => $post->get('company'), 'phone' => $post->get('phone'), 'city' => $post->get('city'), 'address' => $post->get('address'), 'img_format' => $post->getInt('img_format'), 'mail' => $post->get('mail'), 'balance' => $post->getFloat('balance'), 'discount' => $post->getFloat('discount'), 'type' => 'vendor');
     $msg = 'Сохранено';
     $img_out = "";
     if (!empty($_FILES['upload']['name']) && isImg($_FILES['upload']['name'])) {
         $img = $this->cfg('AVATAR_PATH') . '/' . md5($_FILES['upload']['tmp_name']) . "." . file_ext($_FILES['upload']['name']);
         move_uploaded_file($_FILES['upload']['tmp_name'], ROOT . $img);
         $data['avat'] = $img;
         $img_out = scaleImg($img, 'w200');
     }
     if ($post->getInt('clear')) {
         $data['avat'] = '';
     }
     $err = array();
     $rs = DB::select("SELECT * FROM sc_users WHERE login='******'login')) . "' AND u_id<>{$id}");
     if ($rs->next()) {
         $err['login'] = '******';
     }
     if (!$err) {
         if ($id === 0) {
             $id = DB::insert('sc_users', $data, 'u_id');
         } else {
             DB::update('sc_users', $data, 'u_id=' . $id);
         }
         $rs = DB::select("SELECT * FROM sc_users_vendor WHERE vendor_id={$id}");
         $ext_data = array('info' => $post->get('info'), 'html' => $post->get('html'), 'comment' => $post->get('comment'), 'adm_comment' => $post->get('adm_comment'));
         $ext_data['images'] = $post->getArray('images');
         if ($img_pos = $post->getArray('pos')) {
             //Сортировка картинок
             asort($img_pos);
             $temp_img = array();
             foreach ($img_pos as $k => $v) {
                 $temp_img[] = $ext_data['images'][$k];
             }
             $ext_data['images'] = $temp_img;
         }
         foreach ($_FILES['images_upload']['error'] as $k => $err) {
             if ($err != 0) {
                 continue;
             }
             if (isset($_FILES['images_upload']['tmp_name'][$k]) && isImg($name = $_FILES['images_upload']['name'][$k])) {
                 $path = $this->cfg('AVATAR_PATH') . '/' . md5_file($_FILES['images_upload']['tmp_name'][$k]) . '.' . file_ext($name);
                 if (!file_exists(ROOT . $path)) {
                     rename($_FILES['images_upload']['tmp_name'][$k], ROOT . $path);
                 }
                 if (!in_array($path, $ext_data['images'])) {
                     $ext_data['images'][] = $path;
                 }
             }
         }
         $ext_data['images'] = implode(',', $images = $ext_data['images']);
         if ($rs->next()) {
             DB::update('sc_users_vendor', $ext_data, "vendor_id={$id}");
         } else {
             $ext_data['vendor_id'] = $id;
             DB::insert('sc_users_vendor', $ext_data);
         }
         DB::delete("sc_relation", "type='vend_gal' AND parent={$id}");
         foreach ($post->getArray('gallery') as $g) {
             DB::insert('sc_relation', array('type' => 'vend_gal', 'parent' => $id, 'child' => $g));
         }
         echo printJSONP(array('msg' => $msg, 'u_id' => $id, 'img' => $img_out, 'images' => $images));
         exit;
     } else {
         echo printJSONP(array('err' => $err));
         exit;
     }
 }
Esempio n. 9
0
File: view.php Progetto: xuding/gMIS
 }
 if ($closedtr == 1) {
     $out .= "<tr height=\"30\" valign=\"middle\"  onmouseover=\"javascript:this.style.backgroundColor='" . $hlcolor . "';\" onmouseout=\"javascript:this.style.backgroundColor='';\">";
     $closedtr = 0;
 }
 if ($field == 'password') {
     $hmorig[$field] = '';
 }
 if (!$user->canRead($field, '', '', $_REQUEST['id'], $id)) {
     $out .= "<--NOREAD-->";
 } else {
     if ($fieldinputtype == 'select') {
         $out .= "<td>" . $gtbl->getCHN($field) . ":&nbsp;</td><td> " . $gtbl->getSelectOption($field, $hmorig[$field], '', 1) . "</td>";
     } else {
         if ($fieldinputtype == 'file') {
             $isimg = isImg($hmorig[$field]);
             if (strpos($hmorig[$field], "{$shortDirName}/") !== false) {
                 $hmorig[$field] = str_replace("{$shortDirName}/", "", $hmorig[$field]);
             }
             if ($gtbl->getSingleRow($field)) {
                 $out .= "</tr><tr>";
             }
             if ($isimg) {
                 $out .= "<td >" . $gtbl->getCHN($field) . ":&nbsp;</td><td> <a href=\"" . $hmorig[$field] . "\" target=\"_blank\" title=\"打开大图\"><img src=\"" . $hmorig[$field] . "\" alt=\"-x-\" style=\"width:118px\"/></a><br/>" . $rtvdir . "/" . $hmorig[$field] . " </td>";
             } else {
                 $out .= "<td >" . $gtbl->getCHN($field) . ":&nbsp;</td><td> <a href=\"" . $hmorig[$field] . "\" title=\"" . $hmorig[$field] . "\" target=\"_blank\">" . $hmorig[$field] . "</a> </td>";
             }
         } else {
             if ($gtbl->getExtraInput($field, $hmorig) != '') {
                 $out .= "</tr><tr><td>" . $gtbl->getCHN($field) . ":</td><td colspan=\"" . $form_cols . "\"><span id=\"span_" . $act . "_" . $field . "_val_add\"><input id=\"" . $field . "\" name=\"" . $field . "\" class=\"search\" value=\"" . $hmorig[$field] . "\" /></span> <span id=\"span_" . $act . "_" . $field . "\"><a href=\"javascript:void(0);\" onclick=\"javascript:doActionEx('" . $gtbl->getExtraInput($field, $hmorig) . "&act=" . $act . "&otbl=" . $tbl . "&field=" . $field . "&oldv=" . $hmorig[$field] . "&oid=" . $id . "','extrainput_" . $act . "_" . $field . "_inside');document.getElementById('extrainput_" . $act . "_" . $field . "').style.display='block';\">Disp</a></span> <div id=\"extrainput_" . $act . "_" . $field . "\" class=\"extrainput\"> ";
                 $out .= "<table width=\"100%\"><tr><td width=\"100%\" style=\"text-align:right\"> <b> <a href=\"javascript:void(0);\" onclick=\"javascript:if('" . $id . "' != ''){ var linkobj=document.getElementById('" . $field . "'); if(linkobj != null && '" . $id . "'!=''){ document.getElementById('" . $field . "').value=document.getElementById('linktblframe').contentWindow.sendLinkInfo('','r','" . $field . "');} } document.getElementById('extrainput_" . $act . "_" . $field . "').style.display='none';\">X</a> </b> &nbsp; </td></tr><tr><td> <div id=\"extrainput_" . $act . "_" . $field . "_inside\"></div></td></tr></table> </div>";
Esempio n. 10
0
File: jdo.php Progetto: xuding/gMIS
     $fhref = $gtbl->getHref($field, $rec);
     if (strpos($rec[$field], "{$shortDirName}/") !== false) {
         $rec[$field] = str_replace("{$shortDirName}/", "", $rec[$field]);
     }
     if (count($fhref) == 0) {
         $fhref = "<a href=\"javascript:void(0);\" onclick=\"window.open('" . $rec[$field] . "');\" title=\"点击大图或者下载 " . $rec[$field] . "\">";
     } else {
         if (strpos($fhref[0], "javascript") !== false) {
             $fhref_tmp = "<a href=\"javascript:void(0);\" onclick=\"" . $fhref[0] . "\" title=\"" . $fhref[1] . "\" target=\"" . $fhref[2] . "\">";
         } else {
             $fhref_tmp = "<a href=\"" . $fhref[0] . "\" title=\"" . $fhref[1] . "\" target=\"" . $fhref[2] . "\">";
         }
         $fhref = $fhref_tmp;
     }
     $out .= "<td> " . $fhref;
     $isimg = isImg($rec[$field]);
     if ($isimg) {
         $out .= "<img src=\"" . $rec[$field] . "\" style=\"max-width:99%; max-height:99%\" onload=\"javascript: var baseSize=118; if(this.width > baseSize){ this.style.width = baseSize+'px';}else if(this.height > baseSize){ this.style.height=baseSize+'px'; } \" id=\"img_" . $rec[$field] . "\" />";
     } else {
         $out .= "" . shortenStr($rec[$field], $list_disp_limit) . "";
     }
     $out .= "</a>";
     # <br/>".$rec[$field]."</td>";
 } else {
     if ($gtbl->getExtraInput($field) != '') {
         $out .= "<td ondblclick=\"javascript:show('span_disp_" . $field . "','" . $gtbl->getExtraInput($field) . "&act=" . $act . "&field=" . $field . "&otbl=" . $tbl . "&oldv=" . $rec[$field] . "&oid=" . $id . "',true,true);\" title=\"" . addslashes($rec[$field]) . "\">" . shortenStr($rec[$field], $list_disp_limit) . " <span id=\"span_disp_" . $field . "\"> </span> <div id=\"extrainput_" . $act . "_" . $field . "\" class=\"extrainput\">  </div> </td>";
         $listid[$dispi] = $rec[$field];
     } else {
         $fv = str_replace('<', '&lt;', $rec[$field]);
         $fv_short = $fv_orig = $fv;
         $fv_short = shortenStr($fv, $list_disp_limit);
Esempio n. 11
0
 function actImpImgZip()
 {
     global $ST, $post;
     $loaded = 0;
     $unloaded = array();
     $t = time();
     $images = array();
     if (!empty($_FILES['img_zip']['tmp_name']) && preg_match('/\\.zip$/i', $_FILES['img_zip']['name'])) {
         $zip = new ZipArchive();
         if ($zip->open($_FILES['img_zip']['tmp_name']) === TRUE) {
             $img_dir = "import/{$t}";
             if (!file_exists($img_dir)) {
                 mkdir($img_dir);
             }
             $zip->extractTo($img_dir);
             $zip->close();
             $d = opendir($img_dir);
             while ($f = readdir($d)) {
                 if (isImg($f) && preg_match('/^(\\d+)[_\\d]*/', $f, $res)) {
                     if (empty($images[$res[1]])) {
                         $images[$res[1]] = array();
                     }
                     $images[$res[1]][] = $f;
                 }
             }
             closedir($d);
             $fld = 'id';
             if (in_array($post->get('link'), array('id', 'ext_id', 'product'))) {
                 $fld = $post->get('link');
             }
             foreach ($images as $id => $imglist) {
                 $rs = $ST->select("SELECT * FROM sc_shop_item WHERE {$fld}={$id}");
                 if ($rs->next()) {
                     $data = array();
                     foreach ($imglist as $n => $i) {
                         $file_name = md5($img_dir . '/' . $i) . '.' . file_ext($img_dir . '/' . $i);
                         $file_path = ltrim("{$this->cfg('CATALOG_PATH')}/goods/{$file_name}", '/');
                         if (file_exists($file_path)) {
                             unlink($file_path);
                         }
                         rename("{$img_dir}/{$i}", $file_path);
                         if ($n == 0) {
                             $data['img'] = "/{$file_path}";
                         } else {
                             $data['img_add'][] = "/{$file_path}";
                         }
                     }
                     if ($data) {
                         if (!empty($data['img_add'])) {
                             $data['img_add'] = implode(',', $data['img_add']);
                         }
                         $ST->update('sc_shop_item', $data, "id={$rs->getInt('id')}");
                         $loaded++;
                     }
                 } else {
                     foreach ($imglist as $n => $i) {
                         unlink("{$img_dir}/{$i}");
                     }
                     $unloaded[] = $id;
                 }
             }
             rmdir($img_dir);
         }
         $result = date('Y-m-d H:i:s') . " - Загружено {$loaded}; Не загружено [" . count($unloaded) . '] ' . implode(', ', $unloaded) . "\n";
         file_put_contents(CATALOG_DIR . '/log.txt', $result, FILE_APPEND);
     } else {
         $result = date('Y-m-d H:i:s') . " - Файл не загружен ";
     }
     echo printJSONP(array('msg' => $result));
     exit;
 }
Esempio n. 12
0
		<th></th>
		<th>Описание</th>
		<th>Дата начала</th>
		<th>Дата конца</th>
		<th>Место</th>
		<th>Показов</th>
		<th>Кликов</th>
		<th>Действие</th>
	</tr>
	<?php 
    while ($rs->next()) {
        ?>
		<tr>
			<td style="width:200px">
			<?php 
        if (isImg($rs->get('file'))) {
            ?>
			<img src="<?php 
            echo scaleImg($rs->get('file'), 'w200h100');
            ?>
">
			<?php 
        }
        ?>
			
			</td>
			<td style="width:200px">
				 <a href="?act=edit&id=<?php 
        echo $rs->get('id');
        ?>
"><small>[<?php 
Esempio n. 13
0
    function xsend($to, $varList = null)
    {
        $theme = $this->theme;
        $body = $this->body;
        if (is_array($varList)) {
            foreach ($varList as $k => $v) {
                $theme = str_replace('%' . strtoupper($k) . '%', $v, $theme);
                $body = str_replace('%' . strtoupper($k) . '%', $v, $body);
            }
        }
        $img = array();
        if (preg_match_all('! src="([^"]+)"!', $body, $res)) {
            for ($i = 0; $i < count($res[0]); $i++) {
                $path = $res[1][$i];
                $newPath = str_replace('http://' . $_SERVER['HTTP_HOST'], '', $path);
                $img[] = $newPath;
                $body = str_replace($path, 'cid:' . basename($newPath), $body);
            }
        }
        $body = str_replace('/>', '>', $body);
        $body = '<html><head>
		<style>
		a img{border:none}
		th{text-align:left;}
		body{font-family: Tahoma;}
		</style>
		
		</head><body>' . $body . '</body></html>';
        $subj = "=?Windows-1251?B?" . base64_encode($theme) . '?=';
        $n = "\n";
        $un = 'b1_' . strtoupper(uniqid(time()));
        $un2 = 'b2_' . strtoupper(uniqid(time() + 1000));
        if (is_array($this->fromMail)) {
            $head = "From: =?Windows-1251?B?" . base64_encode($this->fromMail[0]) . "?= <{$this->fromMail[1]}>{$n}";
        } else {
            $head = "From: {$this->fromMail}{$n}";
        }
        $head .= "To: {$to}{$n}";
        $head .= "Subject:" . $subj . "{$n}";
        $head .= "X-Mailer: PHPMail Tool{$n}";
        //	    $head     .= "Reply-To: $this->fromMail$n";
        $head .= "Mime-Version: 1.0{$n}";
        $head .= "Content-Type:multipart/related;";
        $head .= "type=\"text/html\";";
        $head .= "boundary=\"----------" . $un . "\"{$n}{$n}";
        //////////////////////////////////////////////////////////
        $zag = "------------" . $un . "{$n}";
        $zag .= "Content-Type: multipart/alternative;";
        $zag .= "boundary=\"----------" . $un2 . "\"{$n}{$n}";
        $zag .= "------------" . $un2 . $n . "Content-Type:text/html;charset = \"Windows-1251\"";
        $zag .= "Content-Transfer-Encoding: 8bit{$n}{$n}{$body}{$n}{$n}";
        $zag .= "------------" . $un2 . "--{$n}{$n}";
        foreach ($img as $filename) {
            //	    	$filename=ROOT.$filename;
            if (file_exists(ROOT . $filename)) {
                $filename = ROOT . $filename;
            } else {
                if (isImg($filename)) {
                    $filename = "http://{$_SERVER['HTTP_HOST']}" . $filename;
                }
            }
            $zag .= "------------" . $un . "{$n}";
            $zag .= "Content-Type: application/octet-stream;";
            $zag .= "name=\"" . basename($filename) . "\"{$n}";
            $zag .= "Content-ID: <" . basename($filename) . ">{$n}";
            $zag .= "Content-Disposition:inline;";
            $zag .= "filename=\"" . basename($filename) . "\"{$n}";
            $zag .= "Content-Transfer-Encoding:base64{$n}{$n}";
            $zag .= chunk_split(base64_encode(file_get_contents($filename))) . "{$n}";
        }
        foreach ($this->attachment as $a) {
            $zag .= "------------" . $un . "{$n}";
            $zag .= "Content-Type: application/octet-stream;";
            $zag .= "name=\"" . $a['name'] . "\"{$n}";
            $zag .= "Content-ID: <" . $a['name'] . ">{$n}";
            $zag .= "Content-Disposition:inline;";
            $zag .= "filename=\"" . $a['name'] . "\"{$n}";
            $zag .= "Content-Transfer-Encoding:base64{$n}{$n}";
            $zag .= chunk_split(base64_encode(file_get_contents($a['file']))) . "{$n}";
        }
        $zag .= "------------" . $un . "--{$n}";
        return @mail("{$to}", "{$subj}", $zag, $head);
    }