Example #1
0
/**
 * Perform periodic actions.
 *
 * Modules that require to schedule some commands to be executed at regular
 * intervals can implement hook_cron(). The engine will then call the hook
 * at the appropriate intervals defined by the administrator. This interface
 * is particularly handy to implement timers or to automate certain tasks.
 * Database maintenance, recalculation of settings or parameters, and
 * automatic mailings are good candidates for cron tasks.
 *
 * @return
 *   None.
 *
 * This hook will only be called if cron.php is run (e.g. by crontab).
 */
function hook_cron()
{
    $result = db_query('SELECT * FROM {site} WHERE checked = 0 OR checked + refresh < :time', array(':time' => REQUEST_TIME));
    foreach ($result as $site) {
        cloud_update($site);
    }
}
Example #2
0
function updateCustomerCount($partner_id)
{
    $customer_count = cloud_get_field('customer_count', 'partners', "id = '{$partner_id}'");
    if (empty($customer_count)) {
        $customers = cloud_get_row('count(*) as count', 'customers', 'partner_id = ' . $partner_id);
        if (!cloud_update('partners', "customer_count ='{$customers['count']}'", 'id = ' . $partner_id)) {
            echo "error1";
        }
    } else {
        if (!cloud_update('partners', 'customer_count = customer_count+1', 'id = ' . $partner_id)) {
            echo "error1";
        }
    }
}
Example #3
0
<?php

$res = array('flag' => 0);
if (strpos($_SERVER['HTTP_USER_AGENT'], "MicroMessenger")) {
    if ($_POST) {
        require_once '../inc/common_hhr.php';
        $share_id = $_POST['share_id'];
        $type = $_POST['type'];
        $partner_id = $_POST['partner_id'];
        $time = time();
        $share_url = cloud_get_field('redirect_link', 'partner_message_tips', 'id = ' . $share_id);
        if (!empty($share_url)) {
            $have_record = cloud_get_field('id', 'partner_share_record', "partner_id = '{$partner_id}' AND share_id = '{$share_id}' AND  type = '{$type}'");
            if (!empty($have_record)) {
                if (cloud_update('partner_share_record', 'share_num = share_num+1,time = ' . $time, "id = '{$have_record}'")) {
                    $res = array('flag' => 1);
                }
            } else {
                $field = "share_id,type,partner_id,share_url,share_num,time";
                $value = "'{$share_id}','{$type}','{$partner_id}','{$share_url}','1','{$time}'";
                if (cloud_insert('partner_share_record', $field, $value)) {
                    $res = array('flag' => 1);
                }
            }
        }
    }
    //http://m.meilala.net/plus/hhr_share_record.php
    //cloud.net:8083/plus/hhr_share_record.php
    //share_id=298&partner_id=74&type=1
}
die(json_encode($res));