
    ӭjX                        d Z ddlmZmZmZmZmZmZmZm	Z	 ddl
Z
ddlZddlZddlZ ee      Zd Zej#                  d      d        Zej#                  d      d        Zej#                  d	      d
        Zej#                  d      d        Zej#                  d      d        Zej#                  ddg      d        Zej#                  ddg      d        Zej#                  ddg      d        Zej#                  ddg      d        Zej#                  ddg      d        Zej#                  d      d        Zej#                  ddg      d        Zej#                  ddg      d         Zej#                  d!dg      d"        Zej#                  d#      d$        Z ed%k(  r- e!d&        e!d'        e!d(       ejE                  d)d*d+,       yy)-u8   
极简文件浏览和下载服务器
使用Flask实现
    )Flask	send_filerender_template_stringrequestmake_responseredirecturl_forjsonifyNc            	         	 t        j                  dd      } t         j                  | _        	 	 | S # t        $ r}| j                           d }~ww xY w# t        $ rp}dd l}dd l}|j                         j                  j                  }|j                         j                  }t        d| d| d|        |j                           d }~ww xY w)Nz\\ll\D\xtrssvjj\dpd.dbg      N@)timeoutr      错误 [函数: 
   , 行号: u   ]: 连接数据库失败: )sqlite3connectRowrow_factory	Exceptionclose	tracebackinspectcurrentframef_codeco_namef_linenoprint	print_exc)conner   r   	func_nameline_nos         /   pubsv5000-260516发布到2类ok优化ajax前.pyget_db_connectionr"      s    8$G";;	 
 	  	JJL	
  ((*1199	&&(11 :gY>XYZX[\]s3   ,A A 	AAAA 	CA+CC/c            	         t         j                  j                  dd      } g }t        j                  d      D ]  }t        j
                  j                  d|      }t        j
                  j                  |      rW|j                  |t        j
                  j                  |      dz  dz  |t        j
                  j                  |      d       t        j
                  j                  |      s|j                  d| dd|t        j
                  j                  |      d        | d	k(  r|j                  d
        n|j                  d d       d}d }|t        j                  j                  d<   t!        |||       S )Nsorttime.   namesizepathmtime   📁 r#   DIRr*   c                 (    | d   j                         S Nr*   lowerxs    r!   <lambda>zindex.<locals>.<lambda>A       6!2    keyc                     | d   S Nr-    r4   s    r!   r6   zindex.<locals>.<lambda>C       7r8   Tr:   reverseu  
    <!DOCTYPE html>
    <html>
    <head>
        <title>文件服务器</title>
        <style>
            body { font-family: Arial, sans-serif; margin: 20px; }
            h1 { color: #333; }
            table { border-collapse: collapse; width: 100%; margin-top: 20px; }
            th, td { padding: 10px; text-align: left; border-bottom: 1px solid #ddd; }
            th { background-color: #f2f2f2; }
            a { text-decoration: none; color: #0066cc; }
            a:hover { text-decoration: underline; }
            .sort-options { margin-bottom: 10px; }
            .sort-options a { margin-right: 15px; }
        </style>
    </head>
    <body>
        <h1>文件列表</h1>
        <div class="sort-options">
            排序: 
            <a href="/?sort=time" {% if sort_by == 'time' %}style="font-weight: bold; text-decoration: underline;"{% endif %}>按时间</a>
            <a href="/?sort=name" {% if sort_by == 'name' %}style="font-weight: bold; text-decoration: underline;"{% endif %}>按字母</a>
            <a href="/listpub" style="margin-left: 20px; font-weight: bold;">pub</a>
        </div>
        <table>
            <tr>
                <th>文件名</th>
                <th>大小</th>
                <th>修改时间</th>
            </tr>
            {% for file in files %}
            <tr>
                <td>
                    {% if file.size != 'DIR' %}
                    <a href="/play/{{ file.path }}" target="_self">{{ file.name }}</a>
                    {% else %}
                    <a href="/{{ file.path }}?sort={{ sort_by }}" target="_self">{{ file.name }}</a>
                    {% endif %}
                </td>
                <td>{% if file.size == 'DIR' %}目录{% else %}{{ "%.2f"|format(file.size) }} MB{% endif %}</td>
                <td>{{ file.mtime|strftime }}</td>
            </tr>
            {% endfor %}
        </table>
    </body>
    </html>
    c                 T    t        j                  dt        j                  |             S N%Y-%m-%d %H:%M:%Sr&   strftime	localtime	timestamps    r!   strftime_filterzindex.<locals>.strftime_filterx       }}0$..2KLLr8   rE   )filessort_by)r   argsgetoslistdirr,   joinisfileappendgetsizegetmtimeisdirr%   app	jinja_envfiltersr   )rL   rK   filenamefilepathhtmlrI   s         r!   indexr]   (   s<    llvv.GEJJsO77<<X.77>>(#LL 1D84? ))(3	  WW]]8$LLz+ ))(3	  $$ &

2
3

+T
:/DdM )8CMM*%!$eWEEr8   z/<path:dirname>c           	         t         j                  j                  |       sdS t        j                  j                  dd      }g }t        j                  |       D ],  }t         j                  j                  | |      }t         j                  j                  |      ru|j                  |t         j                  j                  |      dz  dz  t         j                  j                  | |      t         j                  j                  |      d       t         j                  j                  |      s|j                  d| ddt         j                  j                  | |      t         j                  j                  |      d       / |dk(  r|j                  d	 
       n|j                  d d       d}d }|t        j                  j                  d<   t!        ||| |      S )Nr%   r&   r(   r)   r.   r#   r/   r*   c                 (    | d   j                         S r1   r2   r4   s    r!   r6   z"browse_directory.<locals>.<lambda>   r7   r8   r9   c                     | d   S r<   r=   r4   s    r!   r6   z"browse_directory.<locals>.<lambda>   r>   r8   Tr?   u  
    <!DOCTYPE html>
    <html>
    <head>
        <title>文件服务器 - {{ dirname }}</title>
        <style>
            body { font-family: Arial, sans-serif; margin: 20px; }
            h1 { color: #333; }
            table { border-collapse: collapse; width: 100%; margin-top: 20px; }
            th, td { padding: 10px; text-align: left; border-bottom: 1px solid #ddd; }
            th { background-color: #f2f2f2; }
            a { text-decoration: none; color: #0066cc; }
            a:hover { text-decoration: underline; }
            .back { margin-bottom: 20px; }
            .sort-options { margin-bottom: 10px; }
            .sort-options a { margin-right: 15px; }
        </style>
    </head>
    <body>
        <div class="back"><a href="/">← 返回上级</a></div>
        <h1>目录: {{ dirname }}</h1>
        <div class="sort-options">
            排序: 
            <a href="/{{ dirname }}?sort=time" {% if sort_by == 'time' %}style="font-weight: bold; text-decoration: underline;"{% endif %}>按时间</a>
            <a href="/{{ dirname }}?sort=name" {% if sort_by == 'name' %}style="font-weight: bold; text-decoration: underline;"{% endif %}>按字母</a>
        </div>
        <table>
            <tr>
                <th>文件名</th>
                <th>大小</th>
                <th>修改时间</th>
            </tr>
            {% for file in files %}
            <tr>
                <td>
                    {% if file.size != 'DIR' %}
                    <a href="/play/{{ file.path }}" target="_self">{{ file.name }}</a>
                    {% else %}
                    <a href="/{{ file.path }}?sort={{ sort_by }}" target="_self">{{ file.name }}</a>
                    {% endif %}
                </td>
                <td>{% if file.size == 'DIR' %}目录{% else %}{{ "%.2f"|format(file.size) }} MB{% endif %}</td>
                <td>{{ file.mtime|strftime }}</td>
            </tr>
            {% endfor %}
        </table>
    </body>
    </html>
    c                 T    t        j                  dt        j                  |             S rB   rD   rG   s    r!   rI   z)browse_directory.<locals>.strftime_filter   rJ   r8   rE   )rK   dirnamerL   )u"   <h1>404</h1><p>目录不存在</p>  )rO   r,   rV   r   rM   rN   rP   rQ   rR   rS   rT   rU   r%   rW   rX   rY   r   )rb   rL   rK   rZ   r[   r\   rI   s          r!   browse_directoryrd      ss   77==!99 llvv.GEJJw'77<<277>>(#LL 1D84?Wh7))(3	  WW]]8$LLz+Wh7))(3	  ($ &

2
3

+T
:0DfM )8CMM*%!$eWgVVr8   z/download/<path:filepath>c                 ^    t         j                  j                  |       sdS t        | d      S )NT)as_attachmentu"   <h1>404</h1><p>文件不存在</p>rc   )rO   r,   rR   r   )r[   s    r!   download_filerh      s%    77>>(#99XT22r8   z/play/<path:filepath>c                    t         j                  j                  |       sdS t         j                  j                  |       d   j	                         }|dk(  r/	 t        | dd      5 }|j                         }d d d        dddifS ddddddddddd
}|j                  |d      }t        | |      S # 1 sw Y   <xY w# t        $ r}d	| d
dfcY d }~S d }~ww xY w)N   z.htmlrutf-8encoding   zContent-Typez	text/htmlu#   <h1>500</h1><p>读取文件失败: </p>  z
audio/mpegz	video/mp4z	audio/wavz	audio/mp4z	audio/oggz
video/webmz
image/jpegz	image/pngz	image/gif)
z.mp3z.mp4z.wavz.m4az.oggz.webmz.jpgz.jpegz.pngz.gifzapplication/octet-stream)mimetyperg   )
rO   r,   rR   splitextr3   openreadr   rN   r   )r[   extfcontentr   
mime_typesrr   s          r!   	play_filerz      s    77>>(#99 ''

8
$Q
'
-
-
/C g~	Fhg6!&&( 7C.+!>>> J ~~c#=>HX11+ 76  	F84@#EE	Fs6   B> &B27B> 2B;7B> >	CCCC/listpubc                     dd l } | j                         j                  j                  }| j                         j                  }d }d }d }	 t
        j                  j                  dd      }t
        j                  j                  dd      }t
        j                  j                  dd      }t        t
        j                  j                  dd	            }	|	d	k  rd	}	t        t
        j                  j                  d
d            }
|
dk  rd}
|
dkD  rd}
|	d	z
  |
z  }t               }d}	 t        ddd      5 }t        j                  |      }|j                  di       j                  dd      }d d d        d}g }g }|r(|j                  d       |j                  d|z   dz          |dk(  r|j                  d       |rddj                  |      z   }d}	 d|z   }|j                  ||      }|j!                         d   }|dkD  r||
z   d	z
  |
z  nd	}|dk(  r	d|z   dz   }n$|dk(  r	d|z   dz   }n|dk(  r	d|z   d z   }nd|z   dz   }|j#                  |
|g       |j                  ||      }|j%                         }d!}t'        |||||	|||
||"
      |r	 |j)                          |r	 |j)                          |r	 |j)                          S S # 1 sw Y   ]xY w#  Y exY w#  Y xY w#  Y HxY w#  Y <xY w#  Y S xY w# t*        $ r}dd l}t/        d#| d$| d%|        |j1                          d&| d'dfcY d }~|r	 |j)                          n#  Y nxY w|r	 |j)                          n#  Y nxY w|r	 |j)                          S #  Y S xY wS d }~ww xY w# |r	 |j)                          n#  Y nxY w|r	 |j)                          n#  Y nxY w|r	 |j)                          w #  Y w xY ww xY w)(Nr   r%   statussearch filterallpagerj   r+   d   
   rq   cfg.tomlrk   rl   rm   globalpub2wxcflagzname LIKE ?%	ready2pubzDttscnt = totsrts AND totsrts > 0 AND (pub = 0 OR pub = 3 OR pub = 4)z WHERE z AND zSELECT COUNT(*) FROM adsa  
            SELECT 
                rowid, 
                tts, 
                ttscnt, 
                totsrts,
                name, 
                pub,
                pub2wxcflag,
                pubstartdt,
                pubenddt,
                asrstartdt,
                asrenddt,
                bilidt,
                trsenddt,
                pubsetdt_of_v,
                pubenddt_of_v
            FROM 
                ads 
            a  
            ORDER BY 
                CASE 
                    WHEN pub = 2 THEN 0
                    WHEN pub = 1 THEN 1
                    WHEN pub IS NULL THEN 3
                    ELSE 2
                END,
                rowid DESC
            LIMIT ? OFFSET ?
            rowidz[
            ORDER BY 
                rowid DESC
            LIMIT ? OFFSET ?
            
createtimez`
            ORDER BY 
                createtime DESC
            LIMIT ? OFFSET ?
            uQ_  
        <!DOCTYPE html>
        <html>
        <head>
            <meta charset="utf-8">
            <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=3.0, user-scalable=yes">
            <title>pub 列表</title>
            <style>
                * { box-sizing: border-box; }
                body { font-family: Arial, sans-serif; margin: 10px; padding: 0; font-size: 14px; }
                h1 { color: #333; font-size: 18px; margin: 10px 0; }
                .table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-bottom: 4px; }
                table { border-collapse: collapse; width: 100%%; margin-top: 0; }
                th, td { padding: 6px 4px; text-align: left; border-bottom: 1px solid #ddd; white-space: nowrap; font-size: 13px; }
                th { background-color: #f2f2f2; position: sticky; top: 0; font-size: 12px; font-weight: 600; }
                a { text-decoration: none; color: #0066cc; }
                .back { margin-bottom: 10px; }
                .sort-options { margin-bottom: 10px; font-size: 13px; }
                .sort-options a { margin-right: 10px; display: inline-block; padding: 4px 8px; border: 1px solid #ddd; border-radius: 3px; }
                .search-box { margin-bottom: 10px; }
                .search-box input { padding: 8px; width: 60%%; max-width: 300px; font-size: 14px; border: 1px solid #ddd; border-radius: 4px; }
                .search-box button { padding: 8px 12px; cursor: pointer; font-size: 14px; border: 1px solid #0066cc; background: #0066cc; color: white; border-radius: 4px; }
                
                /* pub 状态背景色 */
                .pub-processing { background-color: #fff3cd; }
                .pub-pending { background-color: #d1ecf1; }
                .pub-other { background-color: #ffffff; }
                
                .pub-cell { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
                .pub-cell select { padding: 6px 8px; font-size: 16px; border: 1px solid #ddd; border-radius: 4px; }
                .pub-cell a { padding: 4px 10px; border: 1px solid currentColor; border-radius: 3px; font-size: 15px; }
                
                .page-info { font-size: 14px; color: #666; margin: 10px 0; }
                .page-nav { font-size: 14px; margin: 5px 0; }
                .page-nav a { padding: 6px 12px; border: 1px solid #ddd; border-radius: 3px; display: inline-block; margin: 2px; }
                
                .global-setting { margin: 10px 0; padding: 12px; background-color: #f0f0f0; border-radius: 5px; font-size: 15px; white-space: nowrap; }
                .global-setting label { cursor: pointer; display: inline; margin-right: 15px; }
                .name-row { margin: 8px 0 5px 0; padding: 0; word-wrap: break-word; line-height: 1.6; }
                .name-link { display: inline-block; padding: 8px 12px; background: #e8f0fe; border-radius: 4px; text-decoration: none; color: #1a73e8; font-weight: 500; word-break: break-all; white-space: pre-wrap; line-height: 1.8; font-size: 16px; cursor: pointer; max-width: 100%; }
                .dt-info { margin: 0 0 8px 0; padding: 6px 10px; background: #f8f9fa; border-radius: 4px; display: flex; flex-wrap: wrap; gap: 8px; font-size: 12px; }
                .dt-item { padding: 3px 8px; background: white; border: 1px solid #e0e0e0; border-radius: 3px; color: #555; }
                .pub2v-row { margin: 0 0 15px 0; padding: 0; display: flex; align-items: center; gap: 10px; }
                .pub2v-btn { padding: 6px 15px; background: #4CAF50; color: white; border: none; border-radius: 4px; text-decoration: none; font-size: 14px; cursor: pointer; }
                .pub2v-btn:hover { background: #45a049; }
                .pubsetdt-label { font-size: 12px; color: #666; font-style: italic; }
                
                @media (max-width: 600px) {
                    body { margin: 8px; font-size: 15px; }
                    h1 { font-size: 18px; }
                    table { font-size: 15px; }
                    th, td { padding: 8px 6px; }
                    .sort-options a { padding: 5px 8px; font-size: 14px; margin-right: 5px; }
                    .search-box input { width: 55%%; padding: 8px; font-size: 15px; }
                    .search-box button { padding: 8px 12px; font-size: 15px; }
                    .pub-cell select { padding: 6px 8px; font-size: 15px; }
                    .pub-cell a { font-size: 15px; padding: 5px 10px; }
                    .name-link { padding: 12px 15px; font-size: 16px; }
                    .global-setting { font-size: 16px; padding: 12px; }
                }
            </style>
        </head>
        <body>
            <div class="back"><a href="/">← 返回主页</a></div>
            <div class="search-box">
                <form method="get" action="/listpub">
                    <input type="text" name="search" placeholder="搜索名称..." value="{{ search_keyword }}">
                    <button type="submit">搜索</button>
                    {% if search_keyword %}
                    <a href="/listpub?sort={{ sort_by }}&filter={{ filter_by }}" style="margin-left: 5px;">清除</a>
                    {% endif %}
                    <input type="hidden" name="sort" value="{{ sort_by }}">
                    <input type="hidden" name="filter" value="{{ filter_by }}">
                </form>
            </div>
            <div class="sort-options">
                <a href="/listpub?sort=status&filter=all{% if search_keyword %}&search={{ search_keyword }}{% endif %}" {% if sort_by == 'status' and filter_by == 'all' %}style="font-weight: bold; text-decoration: underline;"{% endif %}>按状态</a>
                <a href="/listpub?sort=rowid&filter=all{% if search_keyword %}&search={{ search_keyword }}{% endif %}" {% if sort_by == 'rowid' and filter_by == 'all' %}style="font-weight: bold; text-decoration: underline;"{% endif %}>按rowid</a>
                <a href="/listpub?sort=createtime&filter=all{% if search_keyword %}&search={{ search_keyword }}{% endif %}" {% if sort_by == 'createtime' and filter_by == 'all' %}style="font-weight: bold; text-decoration: underline;"{% endif %}>按时间</a>
                <span style="margin: 0 5px;">|</span>
                <a href="/listpub?sort={{ sort_by }}&filter=all{% if search_keyword %}&search={{ search_keyword }}{% endif %}" {% if filter_by == 'all' %}style="font-weight: bold; text-decoration: underline;"{% endif %}>all</a>
                <a href="/listpub?sort={{ sort_by }}&amp;filter=ready2pub{% if search_keyword %}&amp;search={{ search_keyword }}{% endif %}" {% if filter_by == 'ready2pub' %}style="font-weight: bold; text-decoration: underline;"{% endif %}>可发表+待发表</a>
            </div>
            <div class="page-info">共 {{ total_count }} 条，第 {{ page }}/{{ total_pages }} 页
                <select name="size" onchange="location.href='/listpub?sort={{ sort_by }}&filter={{ filter_by }}{% if search_keyword %}&search={{ search_keyword }}{% endif %}&page=1&size='+this.value" style="padding: 3px 5px; font-size: 12px;">
                    <option value="50" {% if page_size == 50 %}selected{% endif %}>50/页</option>
                    <option value="100" {% if page_size == 100 %}selected{% endif %}>100/页</option>
                    <option value="200" {% if page_size == 200 %}selected{% endif %}>200/页</option>
                </select>
            </div>
            <div class="page-nav">
                {% if page > 1 %}
                <a href="/listpub?sort={{ sort_by }}&filter={{ filter_by }}{% if search_keyword %}&search={{ search_keyword }}{% endif %}&page=1">首页</a>
                <a href="/listpub?sort={{ sort_by }}&filter={{ filter_by }}{% if search_keyword %}&search={{ search_keyword }}{% endif %}&page={{ page - 1 }}">上一页</a>
                {% endif %}
                
                {% set start_page = page - 2 if page - 2 > 1 else 1 %}
                {% set end_page = page + 2 if page + 2 < total_pages else total_pages %}
                {% for p in range(start_page, end_page + 1) %}
                    {% if p == page %}
                    <span style="font-weight: bold; color: red; padding: 5px;">{{ p }}</span>
                    {% else %}
                    <a href="/listpub?sort={{ sort_by }}&filter={{ filter_by }}{% if search_keyword %}&search={{ search_keyword }}{% endif %}&page={{ p }}">{{ p }}</a>
                    {% endif %}
                {% endfor %}
                
                {% if page < total_pages %}
                <a href="/listpub?sort={{ sort_by }}&filter={{ filter_by }}{% if search_keyword %}&search={{ search_keyword }}{% endif %}&page={{ page + 1 }}">下一页</a>
                <a href="/listpub?sort={{ sort_by }}&filter={{ filter_by }}{% if search_keyword %}&search={{ search_keyword }}{% endif %}&page={{ total_pages }}">末页</a>
                {% endif %}
            </div>
            <div class="global-setting">
                <strong>完成后设置：</strong>
                <form method="post" action="/setpub2wxcflag_global" style="display: inline;">
                    <label style="cursor: pointer;">
                        <input type="radio" name="pub2wxcflag_global" value="0" 
                               {% if global_flag == 0 %}checked{% endif %} 
                               onchange="this.form.submit()">
                        pub->3 (完成)
                    </label>
                    <label style="cursor: pointer;">
                        <input type="radio" name="pub2wxcflag_global" value="1" 
                               {% if global_flag == 1 %}checked{% endif %} 
                               onchange="this.form.submit()">
                        pub->4 (上传 wxvc)
                    </label>
                </form>
            </div>
            <div style="margin-bottom: 10px;">
                <form id="batch-form" method="post" action="/batch_pub">
                    <label style="cursor: pointer; margin-right: 15px;">
                        <input type="checkbox" id="select-all" onclick="toggleSelectAll()"> 全选
                    </label>
                    <button type="submit" style="padding: 6px 15px; font-size: 14px; background: #4CAF50; color: white; border: none; border-radius: 4px; cursor: pointer;">
                        批量发布 ({{ '%d' if global_flag == 0 else '%d' }})
                    </button>
                    <input type="hidden" name="pub_value" value="{% if global_flag == 0 %}3{% else %}4{% endif %}">
                </form>
            </div>
            {% for ad in ads %}
            <div class="table-container">
            <table>
                <tr>
                    <th><input type="checkbox" id="select-all-header" onclick="toggleSelectAll()" style="width: 16px; height: 16px;"></th>
                    <th>rowid</th>
                    <th>tts</th>
                    <th>ttscnt</th>
                    <th>totsrts</th>
                    <th>pub</th>
                </tr>
                <tr class="{% if ad[5] == 2 %}pub-processing{% elif ad[5] == 1 %}pub-pending{% else %}pub-other{% endif %}">
                    <td><input type="checkbox" name="ad_ids" value="{{ ad[0] }}" style="width: 16px; height: 16px;"></td>
                    <td>{{ ad[0] }}</td>
                    <td>{{ ad[1] }}</td>
                    <td>{{ ad[2] }}</td>
                    <td>{{ ad[3] }}</td>
                    <td>
                        <div class="pub-cell" data-adid="{{ ad[0] }}">
                            {% if ad[1] == 0 %}
                            <span style="color: red;" class="pub-value">{{ ad[5] }}</span>
                            {% elif ad[5] == 1 %}
                            <span style="color: purple;" class="pub-value">{{ ad[5] }}</span>
                            {% else %}
                            <span class="pub-value">{{ ad[5] }}</span>
                            {% endif %}
                            <select id="pub-select-{{ ad[0] }}" onchange="updatePub({{ ad[0] }}, this)">
                                <option value="">改pub</option>
                                <option value="-1">-1</option>
                                <option value="0">0</option>
                                <option value="1">1</option>
                                <option value="3">3</option>
                                <option value="4">4</option>
                                <option value="5">5</option>
                                <option value="6">6</option>
                            </select>
                        </div>
                    </td>
                </tr>
            </table>
            </div>
            <div class="name-row">
                <a href="#" onclick="updatePub({{ ad[0] }}, null, 1); return false;" class="name-link">{{ ad[4] }}</a>
            </div>
            <div class="pub2v-row">
                <a href="#" onclick="pub2v({{ ad[0] }}); return false;" class="pub2v-btn">pub2v</a>
                <a href="#" onclick="pub2v2({{ ad[0] }}); return false;" class="pub2v-btn">pub2v2</a>
                <a href="#" onclick="pub2culture({{ ad[0] }}); return false;" class="pub2v-btn">pub2culture</a>
            </div>
            <div class="dt-info">
                {% if ad[7] %}<span class="dt-item">pubstart: {{ ad[7][:16] }}</span>{% endif %}
                {% if ad[8] %}<span class="dt-item">pubend: {{ ad[8][:16] }}</span>{% endif %}
                {% if ad[9] %}<span class="dt-item">asr: {{ ad[9][:16] }}</span>{% endif %}
                {% if ad[10] %}<span class="dt-item">asrend: {{ ad[10][:16] }}</span>{% endif %}
                {% if ad[11] %}<span class="dt-item">bili: {{ ad[11][:16] }}</span>{% endif %}
                {% if ad[12] %}<span class="dt-item">trs: {{ ad[12][:16] }}</span>{% endif %}
                {% if ad[13] %}<span class="dt-item">pubset: {{ ad[13][:16] }}</span>{% endif %}
                {% if ad[14] %}<span class="dt-item">pubendv: {{ ad[14][:16] }}</span>{% endif %}
            </div>
            {% endfor %}
            </form>
            <script>
                function toggleSelectAll() {
                    var checkboxes = document.querySelectorAll('input[name="ad_ids"]');
                    var selectAll = document.getElementById('select-all');
                    checkboxes.forEach(function(checkbox) {
                        checkbox.checked = selectAll.checked;
                    });
                }
                
                function updatePub(adid, selectElement, defaultPubValue) {
                    var pubValue;
                    if (selectElement) {
                        pubValue = selectElement.value;
                        if (!pubValue) {
                            return;
                        }
                    } else {
                        pubValue = defaultPubValue;
                    }
                    
                    var xhr = new XMLHttpRequest();
                    xhr.open('POST', '/setpub_ajax', true);
                    xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
                    xhr.onload = function() {
                        if (xhr.status === 200) {
                            var response = JSON.parse(xhr.responseText);
                            if (response.success) {
                                // 更新页面上显示的 pub 值
                                var pubDisplay = document.querySelector('[data-adid="' + adid + '"] .pub-value');
                                var pubBadge = document.querySelector('[data-adid="' + adid + '"] .pub-badge');
                                if (pubDisplay) {
                                    pubDisplay.textContent = response.new_pub;
                                }
                                if (pubBadge) {
                                    pubBadge.textContent = response.new_pub;
                                }
                                // 根据 pub 值设置颜色
                                var color = getPubColor(response.new_pub);
                                if (pubDisplay) pubDisplay.style.color = color;
                                if (pubBadge) pubBadge.style.color = color;
                                // 重置下拉选择框
                                if (selectElement) {
                                    selectElement.value = '';
                                }
                                // 显示成功提示
                                showToast('pub 值已更新为 ' + response.new_pub);
                            } else {
                                showToast('更新失败: ' + response.message, true);
                            }
                        } else {
                            showToast('更新失败', true);
                        }
                    };
                    xhr.onerror = function() {
                        showToast('网络错误', true);
                    };
                    xhr.send('adid=' + adid + '&pub_value=' + pubValue);
                }
                
                function getPubColor(pub) {
                    switch(parseInt(pub)) {
                        case 0: return '#FF0000'; // red
                        case 1: return '#800080'; // purple
                        case 2: return '#FF8C00'; // orange
                        case -1: return '#666666'; // gray
                        default: return '#000000'; // black
                    }
                }
                
                function pub2v(adid) {
                    var xhr = new XMLHttpRequest();
                    xhr.open('POST', '/pub2v_ajax', true);
                    xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
                    xhr.onload = function() {
                        if (xhr.status === 200) {
                            var response = JSON.parse(xhr.responseText);
                            if (response.success) {
                                showToast(response.message, false);
                                if (response.pubsetdt) {
                                    var label = document.querySelector('[data-adid="' + adid + '"] + .pub2v-row .pubsetdt-label');
                                    if (label) {
                                        label.textContent = '已设置: ' + response.pubsetdt;
                                    } else {
                                        var pub2vRow = document.querySelector('[data-adid="' + adid + '"] + .pub2v-row');
                                        if (pub2vRow) {
                                            pub2vRow.innerHTML += '<span class="pubsetdt-label">已设置: ' + response.pubsetdt + '</span>';
                                        }
                                    }
                                }
                            } else {
                                showToast('操作失败: ' + response.message, true);
                            }
                        } else {
                            showToast('操作失败', true);
                        }
                    };
                    xhr.onerror = function() {
                        showToast('网络错误', true);
                    };
                    xhr.send('adid=' + adid);
                }
                
                function pub2v2(adid) {
                    var xhr = new XMLHttpRequest();
                    xhr.open('POST', '/pub2v2_ajax', true);
                    xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
                    xhr.onload = function() {
                        if (xhr.status === 200) {
                            var response = JSON.parse(xhr.responseText);
                            if (response.success) {
                                showToast(response.message, false);
                                if (response.pubsetdt) {
                                    var label = document.querySelector('[data-adid="' + adid + '"] + .pub2v-row + .dt-info .pubset');
                                    if (label) {
                                        label.textContent = 'pubset: ' + response.pubsetdt;
                                    }
                                }
                                if (response.new_pub !== undefined) {
                                    var pubElement = document.querySelector('[data-adid="' + adid + '"] .pub-value');
                                    if (pubElement) {
                                        pubElement.textContent = response.new_pub;
                                    }
                                }
                            } else {
                                showToast('操作失败: ' + response.message, true);
                            }
                        } else {
                            showToast('操作失败', true);
                        }
                    };
                    xhr.onerror = function() {
                        showToast('网络错误', true);
                    };
                    xhr.send('adid=' + adid);
                }
                
                function pub2culture(adid) {
                    var xhr = new XMLHttpRequest();
                    xhr.open('POST', '/pub2culture_ajax', true);
                    xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
                    xhr.onload = function() {
                        if (xhr.status === 200) {
                            var response = JSON.parse(xhr.responseText);
                            if (response.success) {
                                showToast(response.message, false);
                                if (response.pubsetdt) {
                                    var label = document.querySelector('[data-adid="' + adid + '"] + .pub2v-row + .dt-info .pubset');
                                    if (label) {
                                        label.textContent = 'pubset: ' + response.pubsetdt;
                                    }
                                }
                            } else {
                                showToast('操作失败: ' + response.message, true);
                            }
                        } else {
                            showToast('操作失败', true);
                        }
                    };
                    xhr.onerror = function() {
                        showToast('网络错误', true);
                    };
                    xhr.send('adid=' + adid);
                }
                
                function showToast(message, isError) {
                    var toast = document.createElement('div');
                    toast.style.position = 'fixed';
                    toast.style.top = '15vh';
                    toast.style.left = '50%';
                    toast.style.transform = 'translateX(-50%)';
                    toast.style.padding = '12px 24px';
                    toast.style.borderRadius = '4px';
                    toast.style.color = 'white';
                    toast.style.fontSize = '14px';
                    toast.style.zIndex = '999999';
                    toast.style.opacity = '0';
                    toast.style.transition = 'opacity 0.3s';
                    toast.style.backgroundColor = isError ? '#f44336' : '#4CAF50';
                    toast.style.boxShadow = '0 2px 10px rgba(0,0,0,0.3)';
                    toast.style.maxWidth = '90vw';
                    toast.style.textAlign = 'center';
                    toast.style.wordWrap = 'break-word';
                    toast.textContent = message;
                    document.body.appendChild(toast);
                    setTimeout(function() { toast.style.opacity = '1'; }, 10);
                    setTimeout(function() { 
                        toast.style.opacity = '0'; 
                        setTimeout(function() { document.body.removeChild(toast); }, 300);
                    }, 2000);
                }
            </script>
        </body>
        </html>
        )	adsrL   global_flagr   total_pagestotal_count	page_sizesearch_keyword	filter_byr   r      ]: 操作失败: u&   <h1>500</h1><p>数据库查询失败: rp   )r   r   r   r   r   r   rM   rN   intr"   rt   tomlloadrS   rQ   executefetchoneextendfetchallr   r   r   r   r   r   )r   r   r    r   cursor1cursor2rL   r   r   r   r   offsetr   rw   configwhere_clauseparams
conditionsr   count_queryr   queryr   r\   r   r   s                             r!   listpubr     sl   $$&--55I""$--GDGGQ	,,""684 !))(B7 LL$$Xu5	 7<<##FA./!8D((56	r>Is?I(i' !" 	j#8A1$jj26::=!L 9 
m,MM#.45#de$w||J'??L 	4|CKll;7G!**,Q/K EPRSO{Y.2y@YZ h& '&
"'E< & '&"'E0 $& '&"'E2& '&"'E2 	y&)*,,uf- IV &dWR])-;T_kt3AYX   

 e 98	,	`+  E :gY>OPQsST7s$?DD

	 #E 

	 s  
CK8 &K 48K,K 4AK8 *K =BK8 K#"K*5K1KK KK8 K K8 #K'*K.1K58	N/N0N1N 8M		MM$$M(.M??NNN O"N$#O"$N(&O".N?>O"?OO"	OO"OO"z/setpub_ajaxPOST)methodsc            	         dd l } | j                         j                  j                  }| j                         j                  }d }d }	 t        t        j                  j                  dd            }t        t        j                  j                  dd            }t               }|j                  d||f      }|j                          |j                  d|f      }|j                         }|r|d   n|}t        d|d      |r	 |j                          |r	 |j                          S S #  Y xY w#  Y S xY w# t        $ r}	dd l}
t#        d| d	| d
|	        |
j%                          t        dt'        |	      d      dfcY d }	~	|r	 |j                          n#  Y nxY w|r	 |j                          S #  Y S xY wS d }	~	ww xY w# |r	 |j                          n#  Y nxY w|r	 |j                          w #  Y w xY ww xY w)Nr   adid	pub_value&UPDATE ads SET pub = ? WHERE rowid = ?#SELECT pub FROM ads WHERE rowid = ?T)successnew_pubr   r   ]: Fr   messagerq   )r   r   r   r   r   r   r   formrN   r"   r   commitr   r
   r   r   r   r   r   str)r   r   r    r   cursorr   r   rowr   r   r   s              r!   setpub_ajaxr   d  s   $$&--55I""$--GDF7<<##FA./((a89	 "FTXHYZ CdWMoo#a&Y4G<=  

   C :gYc!EF5SV<=sBB

	 C 

	 s   B9D7 D)D0)D-0D47	G A F< GG FF#F44F8<GG G<GG<GG<#G43G<4G86G<z/pub2v_ajaxc            	         dd l } | j                         j                  j                  }| j                         j                  }d }d }	 t        t        j                  j                  dd            }t               }|j                  d|f      }|j                         }|s7t        ddd      df|r	 |j                          |r	 |j                          S S |d   }||nd}|dk(  s|d	k(  rdd
lm} |j                         j!                  d      }	|j                  d|	|f      }|j#                          t        dd|	d d d      |r	 |j                          |r	 |j                          S S |dk(  rX|j                  d|f      }|j#                          t        ddd      |r	 |j                          |r	 |j                          S S t        dd| dd      df|r	 |j                          |r	 |j                          S S #  Y IxY w#  Y S xY w#  Y xY w#  Y S xY w#  Y qxY w#  Y S xY w#  Y DxY w#  Y S xY w# t$        $ r}
dd l}t)        d| d| d|
        |j+                          t        dt-        |
      d      dfcY d }
~
|r	 |j                          n#  Y nxY w|r	 |j                          S #  Y S xY wS d }
~
ww xY w# |r	 |j                          n#  Y nxY w|r	 |j                          w #  Y w xY ww xY w)Nr   r   r   F   记录不存在r   rc         datetimerC   zCUPDATE ads SET pubsetdt_of_v = ?,pubenddt_of_v=NULL WHERE rowid = ?T   已设置发布时间   r   r   pubsetdtz&UPDATE ads SET pub = 1 WHERE rowid = ?   已设置为待处理状态   当前状态(pub=   )不支持此操作  r   r   r   rq   r   r   r   r   r   r   r   r   rN   r"   r   r   r
   r   r   nowrE   r   r   r   r   r   r   r   r   r    r   r   r   r   current_pubr   current_timer   r   s               r!   
pub2v_ajaxr     s0   $$&--55I""$--GDF,7<<##FA./ " CdWMoou9JKLcQ4  

 ; !f%0%<k!!{a/)#<<>223FGL\\"gjvx|i}~FKKMt8O]ijmkm]nop  

 ' A\\"JTGTFKKMt8UVW  

  u;L[MYl9mnoqtt  

   C :gYc!EF5SV<=sBB

	 C 

	    A'H? 2HHA/H? 	HH.5H? &H#9H*H? !H14H8HHHH #H'*H.1H58H<?	K	A KK		K J!!J%+J<<K K		K LK! L!K%#L+K<;L<L >Lz/pub2v2_ajaxc            	      &   dd l } | j                         j                  j                  }| j                         j                  }d }d }	 t        t        j                  j                  dd            }t               }|j                  d|f      }|j                         }|s7t        ddd      df|r	 |j                          |r	 |j                          S S |d   }||nd}|dk(  s|d	k(  rdd
lm} |j                         j!                  d      }	|dz   }
|j                  d|
|f      }|j#                          t        dd| d|
 |
d      |r	 |j                          |r	 |j                          S S |dk(  r\d}
|j                  d|
|f      }|j#                          t        dd|
d      |r	 |j                          |r	 |j                          S S t        dd| dd      df|r	 |j                          |r	 |j                          S S #  Y UxY w#  Y S xY w#  Y xY w#  Y S xY w#  Y qxY w#  Y S xY w#  Y DxY w#  Y S xY w# t$        $ r}dd l}t)        d| d| d|        |j+                          t        dt-        |      d      dfcY d }~|r	 |j                          n#  Y nxY w|r	 |j                          S #  Y S xY wS d }~ww xY w# |r	 |j                          n#  Y nxY w|r	 |j                          w #  Y w xY ww xY w)Nr   r   r   Fr   r   rc   r   r   r   rC   n   z$UPDATE ads SET pub=? WHERE rowid = ?Tu   已设置发布状态,pub:z->)r   r   r      r   r   r   r   r   r   r   r   rq   r   )r   r   r    r   r   r   r   r   r   r   r   r   r   s                r!   pub2v2_ajaxr     s\   $$&--55I""$--GDF27<<##FA./ " CdWMoou9JKLcQ@  

 G !f%0%<k!!{a/)#<<>223FGL "C'G\\"H7TX/ZFKKMt9ST_S``bcjbk7l  zA  B  C"  

 + A G\\"JWVZO\FKKMt8Ubijk  

  u;L[MYl9mnoqtt  

   C :gYc!EF5SV<=sBB

	 C 

	 s   A'I 2HHA7I H!$H(69I 2H/H6I -H= IHH!H%(H,/H36H:=II	KA KKK J--J17KKKK LK-,L-K1/L7LLL
Lz/pub2culture_ajaxc            	         dd l } | j                         j                  j                  }| j                         j                  }d }d }	 t        t        j                  j                  dd            }t               }|j                  d|f      }|j                         }|s7t        ddd      df|r	 |j                          |r	 |j                          S S |d   }||nd}|dk(  s|d	k(  rdd
lm} |j                         j!                  d      }	|j                  d|	|f      }|j#                          t        dd|	d d d      |r	 |j                          |r	 |j                          S S |dk(  rX|j                  d|f      }|j#                          t        ddd      |r	 |j                          |r	 |j                          S S t        dd| dd      df|r	 |j                          |r	 |j                          S S #  Y IxY w#  Y S xY w#  Y xY w#  Y S xY w#  Y qxY w#  Y S xY w#  Y DxY w#  Y S xY w# t$        $ r}
dd l}t)        d| d| d|
        |j+                          t        dt-        |
      d      dfcY d }
~
|r	 |j                          n#  Y nxY w|r	 |j                          S #  Y S xY wS d }
~
ww xY w# |r	 |j                          n#  Y nxY w|r	 |j                          w #  Y w xY ww xY w)Nr   r   r   Fr   r   rc   r   r   r   rC   zFUPDATE ads SET pubsetdt_of_v = ?, pubenddt_of_v = NULL WHERE rowid = ?Tr   r   r   z'UPDATE ads SET pub = 24 WHERE rowid = ?r   r   r   r   r   r   r   rq   r   r   s               r!   pub2culture_ajaxr     s7   $$&--55I""$--GDF,7<<##FA./ " CdWMoou9JKLcQ4  

 ; !f%0%<k!!{a/)#<<>223FGL\\"jmy{  mA  BFKKMt8O]ijmkm]nop  

 ' A\\"KdWUFKKMt8UVW  

  u;L[MYl9mnoqtt  

   C :gYc!EF5SV<=sBB

	 C 

	 r   z/setpubc            	      	   dd l } | j                         j                  j                  }| j                         j                  }d }d }	 t        t        j                  j                  dd            }t        j                  j                  dd      }|st        j                  r@t        t        j                        |r	 |j                          |r	 |j                          S S t        d      |r	 |j                          |r	 |j                          S S t        |      }t        d       t        d|        t        d| d	       t        d
|        t               }|j                  d|f      }|j                         }|r|d   }	t        d|	        nt        d| d       |j                  d||f      }|j                   }
t        d|
        |j#                          t        d       |j                  d|f      }|j                         }|r6|d   }t        d|        ||k(  rt        d       n!t        d| d|        nt        d| d       t        d       t        j                  r@t        t        j                        |r	 |j                          |r	 |j                          S S t        j$                  j                  dd      }t        j$                  j                  dd      }t        j$                  j                  dd      }t        j$                  j                  dd      }d|z   d z   |z   }|r|d!|z   z  }t'        |      d"k7  r|d#t'        |      z   z  }t        |      |r	 |j                          |r	 |j                          S S #  Y xY w#  Y S xY w#  Y xY w#  Y S xY w#  Y xY w#  Y S xY w#  Y FxY w#  Y S xY w# t(        $ rp}dd l}t        d$| d%| d&|        |j-                          d'| d(d)fcY d }~|r	 |j                          n#  Y nxY w|r	 |j                          S #  Y S xY wS d }~ww xY w# |r	 |j                          n#  Y nxY w|r	 |j                          w #  Y w xY ww xY w)*Nr   r   r   r   r{   u   
=== setpub 操作日志 ===zadid: zpub_value_str: ''zpub_value: r   u   更新前 pub 值: u   警告：未找到 rowid=u
    的记录r   u   UPDATE 语句影响的行数: u   事务已提交u   更新后 pub 值: u   SUCCESS: pub 值更新成功u*   WARNING: pub 值未更新成功！期望: u
   , 实际: u#   ERROR: 更新后查询不到 rowid=u"   === setpub 操作日志结束 ===
r%   r}   r~   r   r   r   rj   z/listpub?sort=z&filter=z&search=1z&page=r   r   r      <h1>500</h1><p>操作失败: rp   rq   )r   r   r   r   r   r   r   r   rN   referrerr   r   r   r"   r   r   rowcountr   rM   r   r   r   r   )r   r   r    r   r   r   pub_value_strr   r   original_pubaffected_rowsr   rL   r   r   r   redirect_urlr   r   s                      r!   setpubr   8  s   $$&--55I""$--GDFT7<<##FA./((b9  0 01D  

 M J'B  

 I &	-/tfo q12I;'( !" CdWMooq6L'~67-dV:>? FTXHYZ.}o>?  CdWMoo!fG'y12)#45B9+ZX_W`ab7vZHI34 G,,-*  

 / ,,""684 ))(B7LL$$Xu5	||*''1J>JJ77Lt9Hs4y00L%  

   < :gY>OPQsST.qc6;;

	 < 

	 s   A3O >NN$#
O 0N+N3E9O N:$O6B>O 7O	
ON!$N(+N03N7:N?O	OO	Q /QQQ P((P,2QQQQ RQ('R(Q,*R2RRRRz/pub/<int:adid>/<int:puber>c           	         dd l }|j                         j                  j                  }|j                         j                  }d }d }	 t               }|j                  d|| f      }|j                          t        j                  r@t        t        j                        |r	 |j                          |r	 |j                          S S t        t        d            |r	 |j                          |r	 |j                          S S #  Y TxY w#  Y S xY w#  Y 'xY w#  Y S xY w# t        $ rp}dd l}t        d| d| d|        |j!                          d| dd	fcY d }~|r	 |j                          n#  Y nxY w|r	 |j                          S #  Y S xY wS d }~ww xY w# |r	 |j                          n#  Y nxY w|r	 |j                          w #  Y w xY ww xY w)
Nr   r   r   r   r   r   r   rp   rq   r   r   r   r   r   r"   r   r   r   r   r   r   r	   r   r   r   r   )	r   puberr   r   r    r   r   r   r   s	            r!   pubr     s   $$&--55I""$--GDF " FPTV G,,-  

  	*+  

   < :gY>OPQsST.qc6;;

	 < 

	 s   AD !D4DD D/DDDDD	F&/FFF E..E28F		FFF GF.-G.F20G8G	G	GGz
/batch_pubc            
         dd l } | j                         j                  j                  }| j                         j                  }d }d }	 t
        j                  j                  d      }t        t
        j                  j                  dd            }|st
        j                  r@t        t
        j                        |r	 |j                          |r	 |j                          S S t        t        d            |r	 |j                          |r	 |j                          S S t               }|j                  d|D cg c]  }|t        |      f c}      }|j!                          t#        dt%        |       d|        t
        j                  r@t        t
        j                        |r	 |j                          |r	 |j                          S S t        t        d            |r	 |j                          |r	 |j                          S S #  Y ?xY w#  Y S xY w#  Y xY w#  Y S xY wc c}w #  Y wxY w#  Y S xY w#  Y JxY w#  Y S xY w# t&        $ rp}dd l}	t#        d	| d
| d|        |	j+                          d| ddfcY d }~|r	 |j                          n#  Y nxY w|r	 |j                          S #  Y S xY wS d }~ww xY w# |r	 |j                          n#  Y nxY w|r	 |j                          w #  Y w xY ww xY w)Nr   ad_idsr   r   r   r   u   批量更新 u    条记录，pub 设置为 r   r   u   ]: 批量操作失败: u#   <h1>500</h1><p>批量操作失败: rp   rq   )r   r   r   r   r   r   r   getlistr   rN   r   r   r   r	   r"   executemanyr   r   lenr   r   r   )
r   r   r    r   r   r   r   r   r   r   s
             r!   	batch_pubr     s   $$&--55I""$--GDF)%%h/((a89	 0 010  

 9 GI./.  

 3 !" !!"JDJ KFD)SY!7F KMc&k]*Ei[QR G,,-  

  	*+  

 3 !L&  B :gY>UVWUXYZ4QCt<cAA

	 B 

	 s   A2I =HH"I 8HHI 7H%
AI 'H*:H1I "H85H?HHHH"%I *H.1H58H<?I	J?/J:>J??K JJ!J22J6:J??K K:KK:KK:!K21K:2K64K:z/setpub2wxcflag_globalc            	         dd l } | j                         j                  j                  }| j                         j                  }	 t        t        j                  j                  dd            }dd|ii}t        ddd      5 }t        j                  ||       d d d        t        t        d	            S # 1 sw Y   xY w# t        $ r:}dd l}t!        d
| d| d|        |j#                          d| ddfcY d }~S d }~ww xY w)Nr   pub2wxcflag_globalr   r   r   wrl   rm   r   r   r   r   r   rp   rq   )r   r   r   r   r   r   r   r   rN   rt   r   dumpr   r	   r   r   r   r   )r   r   r    r   r   rw   r   r   s           r!   setpub2wxcflag_globalr     s    $$&--55I""$--G< !1!12F!JK ],>?@*cG4IIfa  5 	*++	 54
  < :gY>OPQsST.qc6;;	<s6   =C  B4C  4B=9C   	D	/C>8D>Dz/setpub2wxcflag/<int:adid>c           	      B   dd l }|j                         j                  j                  }|j                         j                  }d }d }	 t        t        j                  j                  dd            }t               }|j                  d|| f      }|j                          ddlm}m}  | |d            |r	 |j                          |r	 |j                          S S #  Y xY w#  Y S xY w# t         $ rp}	dd l}
t%        d| d| d|	        |
j'                          d	|	 d
dfcY d }	~	|r	 |j                          n#  Y nxY w|r	 |j                          S #  Y S xY wS d }	~	ww xY w# |r	 |j                          n#  Y nxY w|r	 |j                          w #  Y w xY ww xY w)Nr   r   z.UPDATE ads SET pub2wxcflag = ? WHERE rowid = ?)r   r	   r   r   r   r   r   rp   rq   )r   r   r   r   r   r   r   r   rN   r"   r   r   flaskr   r	   r   r   r   r   r   )r   r   r   r    r   r   r   r   r	   r   r   s              r!   setpub2wxcflagr   
  s   $$&--55I""$--GDF',,**=!<= !" NQ\^bPcd 	,	*+  

   < :gY>OPQsST.qc6;;

	 < 

	 s   A,C* 7C
C#C #C'*	E#3/E"E##E& *D;;D?EEE##E& &F*E;:F;E?=FFFFFz/resetpub/<int:adid>c           	         dd l }|j                         j                  j                  }|j                         j                  }d }d }	 t               }|j                  d| f      }|j                          t        j                  r@t        t        j                        |r	 |j                          |r	 |j                          S S t        t        d            |r	 |j                          |r	 |j                          S S #  Y TxY w#  Y S xY w#  Y 'xY w#  Y S xY w# t        $ rp}dd l}t        d| d| d|        |j!                          d| dd	fcY d }~|r	 |j                          n#  Y nxY w|r	 |j                          S #  Y S xY wS d }~ww xY w# |r	 |j                          n#  Y nxY w|r	 |j                          w #  Y w xY ww xY w)
Nr   z&UPDATE ads SET pub = 0 WHERE rowid = ?r   r   r   r   r   rp   rq   r   )r   r   r   r    r   r   r   r   s           r!   resetpubr   2  s   $$&--55I""$--GDF " FP G,,-  

  	*+  

   < :gY>OPQsST.qc6;;

	 < 

	 s   AD  D 3DD D.D DDDD	F%/FFF E--E17FFFF GF-,G-F1/G7GGG
G__main__u   文件服务器启动中...u#   访问地址: http://localhost:5000u   按 Ctrl+C 停止服务器z0.0.0.0i  F)hostportdebug)#__doc__r   r   r   r   r   r   r   r	   r
   rO   r&   r   r   __name__rW   r"   router]   rd   rh   rz   r   r   r   r   r   r   r   r   r   r   r   r   runr=   r8   r!   <module>r      so   o n n 	   Ho2 3TF TFn WW WWt &'3 (3 "#2 $2D :Z	 Z	z >F8,% -%P =6(+3 ,3l >F8,9 -9x 13 23l 9vh'[ ([| ()# *#L <&*0 +0f #fX6< 7<. '&:$ ;$N !"# ##J z	
'(	
/0	
&'GGUG3	 r8   