标签: Chevereto

  • Chevereto-free 免费版 忘记管理员密码 强制登陆 重置密码方法

    Chevereto-free 免费版 忘记管理员密码 强制登陆 重置密码方法

    我们很久之前搞了一个788图床,由于很长时间没有登录忘记了登陆密码,默认的话有重置密码的功能,但是我们没有开启mail函数,所以发送不了邮件,下面我们给出强制登陆并修改密码的方法。

    [title]强制登陆[/title]

    FTP登陆到站点,编辑文件 /app/routes/route.login.php (大概第94行),找到:

    $is_login = CHV\Login::checkPassword($user_db[‘user_id’], $_POST[‘password’]);

    修改为:

    //$is_login = CHV\Login::checkPassword($user_db[‘user_id’], $_POST[‘password’]);

    $is_login = true;

    这样前台登陆的时候,只需要用户名正确,密码随便填写即可登录。

    登陆后记得恢复原来的修改。

    [title]重置密码[/title]

    使用FTP登陆,编辑文件?/app/routes/route.setttings.php , 找到:

    				case 'password':
    					
    					if(!$is_dashboard_user) {
    						if($user['login']['password'] && !password_verify($_POST['current-password'], $user['login']['password']['secret'])) {
    							$input_errors['current-password'] = _s('Wrong password');
    						} else {
    							if($_POST['current-password'] == $_POST['new-password']) {
    								$input_errors['new-password'] = _s('Use a new password');
    								$handler::updateVar('safe_post', ['current-password' => NULL]);
    							}
    						}
    					}
    				
    					if(!preg_match('/'.CHV\getSetting('user_password_pattern').'/', $_POST['new-password'])) {
    						$input_errors['new-password'] = _s('Invalid password');
    					}
    					
    					if($_POST['new-password'] !== $_POST['new-password-confirm']) {
    						$input_errors['new-password-confirm'] = _s("Passwords don't match");
    					}
    				break;

    修改成:

    				case 'password':
    /******					
    					if(!$is_dashboard_user) {
    						if($user['login']['password'] && !password_verify($_POST['current-password'], $user['login']['password']['secret'])) {
    							$input_errors['current-password'] = _s('Wrong password');
    						} else {
    							if($_POST['current-password'] == $_POST['new-password']) {
    								$input_errors['new-password'] = _s('Use a new password');
    								$handler::updateVar('safe_post', ['current-password' => NULL]);
    							}
    						}
    					}
    				
    					if(!preg_match('/'.CHV\getSetting('user_password_pattern').'/', $_POST['new-password'])) {
    						$input_errors['new-password'] = _s('Invalid password');
    					}
    					
    					if($_POST['new-password'] !== $_POST['new-password-confirm']) {
    						$input_errors['new-password-confirm'] = _s("Passwords don't match");
    					}
    ******/
    				break;

    然后在后台修改密码,原始密码随便填,输入新密码即可。

    修改密码后记得恢复原来的修改。

  • Python 爬虫 抓取豆瓣小组图片 通过api提交入库到 Chevereto 图床

    Python 爬虫 抓取豆瓣小组图片 通过api提交入库到 Chevereto 图床

    最近没事弄了一个图床(http://788to.com),然后又比较喜欢豆瓣小组里的图片,所以就想从豆瓣小组抓取图片。老季只对php比较了解,但是php的多线程做爬虫的话还是比较弱的,所以就想到了用Python来做这件事情。

    前篇:Chevereto free版本 使用api 上传图片 图文教程

    注:老季是Python新手,如有不对的地方,希望大神指出。

    下面将python脚本开源:

    #!/usr/bin/python
    # -*- coding: UTF-8 -*-
    # 作者:老季
    # 网址:https://www.jiloc.com/43112.html
    #导入所需的库
    from bs4 import BeautifulSoup
    from urllib.parse import urlencode
    import urllib.request,socket,re,sys,os,json,time,threading,queue
    
    # 获取单页图片方法
    def getImage(url): 
        # 网址
        if url == '':
            print('URL NULL')
            sys.exit()
        print(url)
        print('--- Begin to Crawl Url ---')
        req = urllib.request.Request(url)
        res = urllib.request.urlopen(req)
        data = res.read()
        for link,t in set(re.findall(r'(https://img3.doubanio.com/view/group_topic/large/public/[^s]*?(jpg))', str(data))):
            if  link != '' :
                http_status = http_get(link)
                print( link + ' -> '+ http_status )
    #        print(link)
        print('--- End to Crawl Url ---')
    
    # 获取页面的url地址并使用getImage方法抓取图片
    def getUrlList(url):
        data=urllib.request.urlopen(url).read()  
        soup = BeautifulSoup(data, "html.parser")
        tdList = soup.find_all("td",class_='title')        
        for i in tdList:
            title = i.a.get("title")
            if len(i.contents) > 1:
                i_href = i.a.get('href')
                getImage(i_href)
    
    # 模拟浏览器提交数据
    def http_get(url):
        submit_url = 'http://788to.com/api/1/upload/?key='+urllib.parse.quote_plus('API值')+'&source='+urllib.parse.quote_plus(url)
    #    print(submit_url)
        req = urllib.request.Request(submit_url)
        try:
            res = urllib.request.urlopen(req)
        except urllib.error.HTTPError as e:
            print(e.read())      
            sys.exit()
        # .decode('ascii') : 将byte类型转化为字符串格式
    #    return res.read().decode('ascii')
        data = json.loads(res.read().decode())
        return str(data['status_code'])
    
    #getUrlList('https://www.douban.com/group/meituikong/discussion?start=400')
    print('群组起始地址示例:https://www.douban.com/group/meituikong/discussion?start=')
    theUrl = str(input("请输入豆瓣首页地址:"))
    theEnd = int(input('请输入最后一页的start数字值:'))
    class jdThread(threading.Thread):
        def __init__(self,index,queue):
            threading.Thread.__init__(self)
            self.index = index
            self.queue = queue
     
        def run(self):
            while True:
                time.sleep(1)
                item = self.queue.get()
                if item is None:
                    break
    #            print("序号:",self.index,"任务",item,"完成")
                getUrlList(theUrl+str(item*25))
                time.sleep(1)
                self.queue.task_done()  #task_done方法使得未完成的任务数量-1
                if q.empty(): return
    
    q = queue.Queue(0)
    '''
    初始化函数接受一个数字来作为该队列的容量,如果传递的是
    一个小于等于0的数,那么默认会认为该队列的容量是无限的.
    '''
    for i in range(2):
        jdThread(i,q).start()#两个线程同时完成任务
    for i in range( int( theEnd/25) ):
        q.put(i)#put方法使得未完成的任务数量+1
    

     

WeChat
↑