Пример #1
0
    }
    $likes = getLikesCount($project_id);
    $comments = getCommentsCount($project_id);
    $query = 'SELECT `routed_by` FROM `routed_projects` WHERE `project_id` = ' . $project_id;
    $users1 = count($db_con->sql2array($query));
    $query = 'SELECT DISTINCT(`sent_to`) FROM `suggestions` WHERE `project_id` = ' . $project_id;
    $routers1 = count($db_con->sql2array($query));
    $routers = $users1 + $routers1;
    if ($likes <= 1 && $comments <= 1 && $routers <= 1) {
        continue;
    }
    $trend_value = calculateTrendForProject($project['project_id']);
    if ($trend_value <= 0) {
        continue;
    }
    if (!checkProjectInTrend($project['project_id'])) {
        global $db_con;
        $db_con->query('INSERT INTO `trend`(project_id) VALUES(' . $project['project_id'] . ')');
    }
}
$trended = getAllProjectsInTrend();
if ($trended == null) {
    exit;
}
foreach ($trended as $project) {
    $cycle = getTrendCycle($project['project_id']);
    $hr = '';
    $dt = time();
    $times = new DateTime("@{$dt}");
    $time = $times->format('Y-m-d H:i:s');
    //echo gettype($time);
Пример #2
0
function updateFundablesTable()
{
    global $db_con;
    $q = "SELECT * FROM `fundables` WHERE 1 ORDER BY `created_on` DESC";
    $res = $db_con->query($q);
    //     print_r($res);
    while ($row = $db_con->fetch_array($res)) {
        $date1 = strtotime($row['created_on']);
        $id = $row['fundable_id'];
        $project_id = $row['project_id'];
        $date2 = $date1 + 31 * 24 * 60 * 60;
        $remdays = intval(ceil(($date2 - time()) / (60 * 60 * 24)));
        $fund_status = $row['fund_status'];
        $cycle = $row['cycle'];
        if ($fund_status == 1) {
            continue;
        } else {
            echo "status";
            if ($remdays < 1) {
                $checktrend = checkProjectInTrend($project_id);
                if ($checktrend == true) {
                    //                    $cycle="SELECT `cycle` FROM `fundables` WHERE `fundable_id`=".$id."LIMIT 1";
                    //                    $res=$db_con->fetch_array($db_con->query($cycle));
                    if ($cycle == 0) {
                        $cycle = 1;
                        $x = $remdays + 31 * 24 * 60 * 60;
                        print_r($x);
                        $qu = "UPDATE `fundables` SET `days_rem`='" . $x . "',`cycle`='" . $cycle . "'WHERE `fundable_id`=" . $id;
                        //does not work
                        //print_r($qu);
                        $db_con->query($qu);
                    } else {
                        updateNotFundStatusProject($project_id);
                        $quer = "DELETE `fundable_id` FROM `fundables` WHERE `fundable_id`=" . $id;
                        $db_con->query($quer);
                    }
                    echo "yasma";
                } else {
                    updateNotFundStatusProject($project_id);
                    $quer = "DELETE `fundable_id` FROM `fundables` WHERE `fundable_id`=" . $id;
                    $db_con->query($quer);
                }
            } else {
                $qu = "UPDATE `fundables` SET `days_rem`='" . $remdays . "',`cycle`='" . $cycle . "'WHERE `fundable_id`=" . $id;
                //does not work
                //print_r($qu);
                $db_con->query($qu);
            }
        }
    }
}