Example #1
0
<?php

include "header.php";
//if the form has submitted
if (isset($_POST["submit"])) {
    //check for errors
    // do something
    add_history($con, $_POST["petId"], $_POST["proId"]);
} else {
    show_addhistory_form($con);
}
include "footer.php";
Example #2
0
 /**
  * 指派TODO给其他人
  *
  * 不可以分配给自己
  *
  * @param string token , 必填
  * @param string tid - TODOid, 必填
  * @param string uid - 要指派的用户id, 必填
  * @return todo array
  * @author EasyChen
  */
 public function todo_assign($tid = false, $uid = false, $in = false)
 {
     if (!$tid) {
         $tid = intval(v('tid'));
     }
     if (intval($tid) < 1) {
         return self::send_error(LR_API_ARGS_ERROR, __('INPUT_CHECK_BAD_ARGS', 'TID'));
     }
     if (!$uid) {
         $uid = intval(v('uid'));
     }
     if (intval($uid) < 1) {
         return self::send_error(LR_API_ARGS_ERROR, __('INPUT_CHECK_BAD_ARGS', 'UID'));
     }
     if ($uid == $_SESSION['uid']) {
         return self::send_error(LR_API_ARGS_ERROR, __('API_MESSAGE_TODO_ASSIGN_TO_SELF'));
     }
     if (!($tinfo = get_line("SELECT * FROM `todo_user` WHERE `tid` = '" . intval($tid) . "' AND `uid` = '" . uid() . "' LIMIT 1"))) {
         if (db_errno() != 0) {
             return self::send_error(LR_API_DB_ERROR, __('API_MESSAGE_DATABASE_ERROR') . mysql_error());
         } else {
             return self::send_error(LR_API_DB_EMPTY_RESULT, __('API_MESSAGE_EMPTY_RESULT_DATA'));
         }
     } else {
         if ($tinfo['uid'] != uid()) {
             return self::send_error(LR_API_FORBIDDEN, __('API_MESSAGE_CANNOT_ASSIGN_OTHERS_TODO'));
         }
         // 更新todo表
         $sql = "UPDATE `todo` SET `owner_uid` = '" . intval($uid) . "' WHERE `id` = '" . intval($tid) . "' LIMIT 1";
         run_sql($sql);
         if (db_errno() != 0) {
             if ($in) {
                 return false;
             } else {
                 return self::send_error(LR_API_DB_ERROR, __('API_MESSAGE_DATABASE_ERROR') . mysql_error());
             }
         }
         // 将新的uid加入 todo_user 表
         $sql = "REPLACE INTO `todo_user` ( `uid` , `tid` , `status` , `last_action_at`  ) VALUES ( '" . intval($uid) . "' , '" . intval($tid) . "' , 1 , NOW() )  ";
         run_sql($sql);
         if (db_errno() != 0) {
             if ($in) {
                 return false;
             } else {
                 return self::send_error(LR_API_DB_ERROR, __('API_MESSAGE_DATABASE_ERROR') . mysql_error());
             }
         }
         // 将现有uid 变为follow状态
         $sql = "UPDATE `todo_user` SET `is_follow` = 1 WHERE  `tid` = '" . intval($tid) . "' AND `uid` = '" . intval($_SESSION['uid']) . "' LIMIT 1";
         run_sql($sql);
         if (db_errno() != 0) {
             if ($in) {
                 return false;
             } else {
                 return self::send_error(LR_API_DB_ERROR, __('API_MESSAGE_DATABASE_ERROR') . mysql_error());
             }
         }
         // 获取被转让人的信息
         $uinfo = get_user_info_by_id($uid);
         $todo_text = get_todo_text_by_id($tid);
         $todo_count = get_var("SELECT `comment_count` FROM `todo` WHERE `id` = '" . intval($tid) . "'");
         // 向todo新主人发送通知
         send_notice(intval($uid), __('API_TEXT_ASSIGN_TODO_TO_U', array(uname(), $todo_text)), 1, array('tid' => intval($tid), 'count' => $todo_count));
         // 向todo关注者发送通知
         $sql = "SELECT `uid` FROM `todo_user` WHERE `tid`= '" . intval($tid) . "' AND `is_follow` = 1 ";
         if ($uitems = get_data($sql)) {
             foreach ($uitems as $uitem) {
                 // 避免向当前转让人发送通知
                 if ($uitem['uid'] != uid()) {
                     send_notice($uitem['uid'], __('API_TEXT_ASSIGN_TODO_FOLLOWED', array(uname(), $todo_text, $uinfo['name'])), 1, array('tid' => intval($tid), 'count' => $todo_count));
                 }
             }
         }
         add_history($tid, __('API_TEXT_ASSIGN_TODO'));
         publish_feed(__('API_TEXT_ASSIGN_TODO_DETAIL', array(uname(), $todo_text, $uinfo['name'])), uid(), 2, $tid);
         if ($in) {
             return get_todo_info_by_id($tid);
         } else {
             return self::send_result(get_todo_info_by_id($tid));
         }
     }
 }
Example #3
0
        }
    }
    assign('shop_category_list', $target);
    if (isset($_SESSION['account'])) {
        $get_history = 'select p.id,p.name,p.img,if(p.`promote_end`>' . $now . ',p.`promote_price`,p.`price`) as price from ' . $db->table('history') . ' as h';
        $get_history .= ' left join ' . $db->table('product') . ' as p on h.product_sn = p.product_sn';
        $get_history .= ' where h.account = \'' . $_SESSION['account'] . '\'';
        $get_history .= ' order by h.add_time desc limit 5';
        $history = $db->fetchAll($get_history);
        assign('history', $history);
    } else {
        assign('history', null);
    }
    //加入我的足迹
    if (isset($_SESSION['account']) && $_SESSION['account'] != '') {
        add_history($_SESSION['account'], $product_sn);
    }
} else {
    redirect('index.php');
}
$pattern = '#<img src="([^"]*)"#';
$content = $product['detail'];
preg_match_all($pattern, $content, $matches);
if ($matches) {
    foreach ($matches[1] as $match) {
        $temp = build_url($match);
        $content = str_replace('"' . $match . '"', '"' . $temp . '"', $content);
    }
}
$product['detail'] = $content;
assign('product', $product);
Example #4
0
 /**
  * 指派TODO给其他人
  *
  * 不可以分配给自己
  *
  * @param string token , 必填
  * @param string tid - TODOid, 必填
  * @param string uid - 要指派的用户id, 必填
  * @return todo array
  * @author EasyChen
  */
 public function todo_assign($tid = false, $uid = false, $in = false)
 {
     if (!$tid) {
         $tid = intval(v('tid'));
     }
     if (intval($tid) < 1) {
         return $this->send_error(LR_API_ARGS_ERROR, 'TID NOT EXISTS');
     }
     if (!$uid) {
         $uid = intval(v('uid'));
     }
     if (intval($uid) < 1) {
         return $this->send_error(LR_API_ARGS_ERROR, 'UIDS ERROR');
     }
     if ($uid == $_SESSION['uid']) {
         return $this->send_error(LR_API_ARGS_ERROR, 'ASSIGN TO SELF');
     }
     if (!($tinfo = get_line("SELECT * FROM `todo_user` WHERE `tid` = '" . intval($tid) . "' AND `uid` = '" . uid() . "' LIMIT 1"))) {
         if (db_errno() != 0) {
             return $this->send_error(LR_API_DB_ERROR, 'DATABASE ERROR ' . mysql_error());
         } else {
             return $this->send_error(LR_API_DB_EMPTY_RESULT, 'DATA NOT EXISTS');
         }
     } else {
         if ($tinfo['uid'] != uid()) {
             return $this->send_error(LR_API_FORBIDDEN, 'CANNOT ASSING OTHER\'S TODO');
         }
         // 更新todo表
         $sql = "UPDATE `todo` SET `owner_uid` = '" . intval($uid) . "' WHERE `id` = '" . intval($tid) . "' LIMIT 1";
         run_sql($sql);
         if (db_errno() != 0) {
             if ($in) {
                 return false;
             } else {
                 return $this->send_error(LR_API_DB_ERROR, 'DATABASE ERROR ' . mysql_error());
             }
         }
         // 将新的uid加入 todo_user 表
         $sql = "REPLACE INTO `todo_user` ( `uid` , `tid` , `status` , `last_action_at`  ) VALUES ( '" . intval($uid) . "' , '" . intval($tid) . "' , 1 , NOW() )  ";
         run_sql($sql);
         if (db_errno() != 0) {
             if ($in) {
                 return false;
             } else {
                 return $this->send_error(LR_API_DB_ERROR, 'DATABASE ERROR ' . mysql_error());
             }
         }
         // 将现有uid 变为follow状态
         $sql = "UPDATE `todo_user` SET `is_follow` = 1 WHERE  `tid` = '" . intval($tid) . "' AND `uid` = '" . intval($_SESSION['uid']) . "' LIMIT 1";
         run_sql($sql);
         if (db_errno() != 0) {
             if ($in) {
                 return false;
             } else {
                 return $this->send_error(LR_API_DB_ERROR, 'DATABASE ERROR ' . mysql_error());
             }
         }
         // 获取被转让人的信息
         $uinfo = get_user_info_by_id($uid);
         $todo_text = get_todo_text_by_id($tid);
         $todo_count = get_var("SELECT `comment_count` FROM `todo` WHERE `id` = '" . intval($tid) . "'");
         // 向todo新主人发送通知
         send_notice(intval($uid), uname() . '向你转让了TODO【' . $todo_text . '】', 1, array('tid' => intval($tid), 'count' => $todo_count));
         // 向todo关注者发送通知
         $sql = "SELECT `uid` FROM `todo_user` WHERE `tid`= '" . intval($tid) . "' AND `is_follow` = 1 ";
         if ($uitems = get_data($sql)) {
             foreach ($uitems as $uitem) {
                 // 避免向当前转让人发送通知
                 if ($uitem['uid'] != uid()) {
                     send_notice($uitem['uid'], uname() . '将你关注的TODO【' . $todo_text . '】转让给了' . $uinfo['name'], 1, array('tid' => intval($tid), 'count' => $todo_count));
                 }
             }
         }
         add_history($tid, '转让了TODO');
         publish_feed(uname() . '将TODO【' . $todo_text . '】转让给了' . $uinfo['name'], uid(), 2, $tid);
         if ($in) {
             return get_todo_info_by_id($tid);
         } else {
             return $this->send_result(get_todo_info_by_id($tid));
         }
     }
 }
Example #5
0
function client_add_torrent($filename, $dest, $title, $feed = NULL, &$fav = NULL, $retried = false)
{
    global $config_values, $hit, $tw_version;
    if (strtolower($fav['Filter']) == "any") {
        $any = 1;
    }
    $hit = 1;
    if (preg_match("/^magnet:/", $filename)) {
        $tor = $filename;
        $magnet = 1;
    }
    if (!$magnet) {
        $filename = htmlspecialchars_decode($filename);
        // Detect and append cookies from the feed url
        $url = $filename;
        if ($feed && preg_match('/:COOKIE:/', $feed) && !preg_match('/:COOKIE:/', $url)) {
            $url .= stristr($feed, ':COOKIE:');
        }
        $get = curl_init();
        $response = check_for_cookies($url);
        if ($response) {
            $url = $response['url'];
            $cookies = $response['cookies'];
        }
        $getOptions[CURLOPT_URL] = $url;
        if (isset($cookies)) {
            $getOptions[CURLOPT_COOKIE] = $cookies;
        }
        //$getOptions[CURLOPT_USERAGENT] = 'Python-urllib/1.17';
        $getOptions[CURLOPT_USERAGENT] = "TWX/{$tw_version['0']}";
        get_curl_defaults($getOptions);
        curl_setopt_array($get, $getOptions);
        $tor = curl_exec($get);
        curl_close($get);
        if (strncasecmp($tor, 'd8:announce', 11) != 0) {
            // Check for torrent magic-entry
            //This was not a torrent-file, so it's poroperly some kind og xml / html.
            if (!$retried) {
                //Try to retrieve a .torrent link from the content.
                $link = find_torrent_link($url, $tor);
                return client_add_torrent($link, $dest, $title, $feed, $fav, $url);
            } else {
                _debug("No torrent file found on {$url}. Exitting.\n");
                if (isset($retried)) {
                    $url = $retried;
                }
                return "Error: No torrent file found on {$url}.";
            }
        }
        if (!$tor) {
            print '<pre>' . print_r($_GET, TRUE) . '</pre>';
            _debug("Couldn't open torrent: {$filename} \n", -1);
            return "Error: Couldn't open torrent: {$filename}";
        }
    }
    $tor_info = new BDecode("", $tor);
    if (!($tor_name = $tor_info->{'result'}['info']['name'])) {
        $tor_name = $title;
    }
    if (!isset($dest)) {
        $dest = $config_values['Settings']['Download Dir'];
    }
    if (isset($fav) && $fav['Save In'] != 'Default') {
        $dest = $fav['Save In'];
    }
    $dest = get_deep_dir(preg_replace('/\\/$/', '', $dest), $tor_name);
    if (!file_exists($dest) or !is_dir($dest)) {
        $old_umask = umask(0);
        if (file_exists($dest)) {
            unlink($dest);
        }
        mkdir($dest, 0777, TRUE);
        umask($old_umask);
    }
    foreach ($config_values['Feeds'] as $key => $feedLink) {
        if ($feedLink['Link'] == "{$feed}") {
            $idx = $key;
        }
    }
    if ($config_values['Feeds'][$idx]['seedRatio'] >= 0) {
        $seedRatio = $config_values['Feeds'][$idx]['seedRatio'];
    } else {
        $seedRatio = $config_values['Settings']['Default Seed Ratio'];
    }
    if (!$seedRatio) {
        $seedRatio = -1;
    }
    switch ($config_values['Settings']['Client']) {
        case 'Transmission':
            $return = transmission_add_torrent($tor, $dest, $title, _isset($fav, '$seedRatio', $seedRatio));
            break;
        case 'folder':
            if ($magnet) {
                _debug("Can not save magnet links to a folder\n");
            } else {
                $return = folder_add_torrent($tor, $dest, $tor_name);
            }
            break;
        default:
            _debug("Invalid Torrent Client: " . $config_values['Settings']['Client'] . "\n", -1);
            exit(1);
    }
    if ($return === 0) {
        add_history($tor_name);
        _debug("Started: {$tor_name} in {$dest}\n", 0);
        if (isset($fav)) {
            run_script('favstart', $title);
            if ($config_values['Settings']['Email Notifications'] == 1) {
                $subject = "TW-X: {$tor_name} started downloading.";
                $msg = "TorrentWatch started downloading {$tor_name}";
                MailNotify($msg, $subject);
            }
            if (!$any) {
                updateFavoriteEpisode($fav, $title);
                _debug("Updated Favorites");
            }
        } else {
            run_script('nonfavstart', $title);
        }
        if ($config_values['Settings']['Save Torrents']) {
            file_put_contents("{$dest}/{$tor_name}.torrent", $tor);
        }
        return "Success";
    } else {
        _debug("Failed Starting: {$tor_name}  Error: {$return}\n", -1);
        $msg = "TorrentWatch-X tried to start \"{$tor_name}\". But this failed with the following error:\n\n";
        $msg .= "{$return}\n";
        $subject = "TW-X: Error while trying to start {$tor_name}.";
        MailNotify($msg, $subject);
        run_script('error', $title, $msg);
        return "Error: {$return}";
    }
}
Example #6
0
 function set_star($raid, $star)
 {
     add_history($this, array('STAR', $raid, $star));
     set_star($this, $raid, $star);
 }