Exemple #1
0
 function csv2array($csvfile, $fields, $delimiter = ',', $enclosure = '"', $callback = NULL)
 {
     LogUtils::log_str('csv2array');
     $handle = fopen($csvfile, "r");
     LogUtils::log_obj($handle);
     if (!$handle) {
         return array();
     }
     $row = 1;
     $list = array();
     while ($data = fgetcsv($handle, 262144, $delimiter, $enclosure)) {
         if (count($data) > count($fields)) {
             $data = array_slice($data, 0, count($fields));
         }
         if (count($fields) > count($data)) {
             $fields = array_slice($fields, 0, count($data));
         }
         foreach ($data as $key => $item) {
             $data[$key] = str_replace("'", "\\'", $item);
         }
         $v = array();
         for ($i = 0; $i < count($fields); $i++) {
             $v[$fields[$i]] = $data[$i];
         }
         //$v = array_combine($fields, $data);
         $list[] = $v;
         if ($callback) {
             call_user_func($callback, $v);
         }
     }
     fclose($handle);
     return $list;
 }
Exemple #2
0
 function baseErrorHandler($errno, $errstr, $errfile, $errline)
 {
     switch ($errno) {
         case E_ERROR:
             //case E_WARNING:
         //case E_WARNING:
         case E_PARSE:
             //case E_NOTICE:
         //case E_NOTICE:
         case E_CORE_ERROR:
             //case E_CORE_WARNING:
         //case E_CORE_WARNING:
         case E_COMPILE_ERROR:
             //case E_COMPILE_WARNING:
         //case E_COMPILE_WARNING:
         case E_USER_ERROR:
             //case E_USER_WARNING:
             //case E_USER_NOTICE:
             //case E_STRICT:
             LogUtils::log_str('[errno:' . $errno . '] ' . $errstr);
             while (@ob_end_clean()) {
             }
             $out = '<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">' . '<SOAP-ENV:Body><SOAP-ENV:Fault><faultcode xsi:type="xsd:int">' . $errno . '</faultcode><faultactor xsi:type="xsd:string"></faultactor><faultstring xsi:type="xsd:string"><![CDATA[' . $errstr . ']]></faultstring><detail xsi:type="xsd:string"></detail></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>';
             die($out);
             break;
     }
 }
Exemple #3
0
 function log_obj($obj)
 {
     if (isset($GLOBALS['as_debug']) && $GLOBALS['as_debug']) {
         ob_start();
         var_dump($obj);
         $msg = ob_get_contents();
         ob_end_clean();
         LogUtils::_log($msg);
     }
 }
Exemple #4
0
 function log_obj($obj)
 {
     if (AS_DEBUG) {
         ob_start();
         var_dump($obj);
         $msg = ob_get_contents();
         ob_end_clean();
         LogUtils::_log($msg);
     }
 }
function GetShopInfo()
{
    LogUtils::log_str('GetShopInfo Begin');
    $server =& $GLOBALS['as_server'];
    $sys =& $GLOBALS['system'];
    $db = $sys->database();
    $info = array('timezone' => defined('SERVER_TIMEZONE') ? SERVER_TIMEZONE : 8);
    LogUtils::log_str('GetShopInfo Return:');
    LogUtils::log_obj($info);
    return $info;
}
Exemple #6
0
 private static function exeBySetTimes($count, $curl)
 {
     $result = curl_exec($curl);
     if (curl_errno($curl)) {
         LogUtils::debug("请求错误: " . curl_errno($curl));
         if ($count > 0) {
             $count--;
             $result = HttpManager::exeBySetTimes($count, $curl);
         }
     }
     return $result;
 }
 /**
  * Responsible for sending the actual email
  */
 public static function send_email($data_context, $address, $subject_tmpl_file, $message_tmpl_file, $attachment)
 {
     // Load the subject and message templates
     $message_tmpl = file_get_contents(dirname(dirname(dirname(__FILE__))) . '/email_templates/' . $message_tmpl_file);
     $subject_tmpl = file_get_contents(dirname(dirname(dirname(__FILE__))) . '/email_templates/' . $subject_tmpl_file);
     // Fill the templates
     $message_tmpl = EntityStringUtils::parse($message_tmpl, $data_context);
     $subject_tmpl = EntityStringUtils::parse($subject_tmpl, $data_context);
     LogUtils::shadow_log($data_context);
     LogUtils::shadow_log('Sending mail to ' . $address . ' with subject ' . $subject_tmpl);
     // Send the email
     wp_mail($address, $subject_tmpl, $message_tmpl, '', $attachment);
 }
 /**
  *
  */
 public static function do_edit_person($entity_data, $party_data)
 {
     $entity_data['edit_mode'] = 0;
     LogUtils::shadow_log($entity_data);
     if (!isset($entity_data['name'])) {
         $entity_data['name'] = $party_data['name'];
     }
     if (!isset($entity_data['description'])) {
         $entity_data['description'] = $party_data['description'];
     }
     $entity_data = EntityAPI::do_create_entity($entity_data);
     return $entity_data;
 }
 /**
  * @param $count
  * @param $curl
  * @return mixed
  */
 private static function exeBySetTimes($count, $curl)
 {
     $result = curl_exec($curl);
     if (curl_errno($curl)) {
         LogUtils::debug('请求错误: ' . curl_errno($curl));
         if ($count > 0) {
             sleep(3);
             //Sleep 3 seconds to save cpu power
             $count--;
             $result = HttpManager::exeBySetTimes($count, $curl);
         }
     }
     return $result;
 }
Exemple #10
0
 function delete(&$controller, &$request, &$user)
 {
     $account = $request->getParameter('account');
     $foaf_id = $request->hasParameter('foaf_id') ? $request->getParameter('foaf_id') : '';
     $member = $user->getAttribute('member', GLU_NS);
     LogUtils::debug("Deleted FOAF. account: {$account}, foaf_id: {$foaf_id}");
     $foaf = DB_DataObject::factory('foaf');
     $foaf->id = $foaf_id;
     $foaf->member_id = $member->id;
     $foaf_id = $foaf->delete();
     if ($foaf_id === false) {
         $error =& PEAR::getStaticProperty('DB_DataObject', 'lastError');
         if (PEAR::isError($error)) {
             trigger_error($error->toString(), E_USER_ERROR);
         }
         echo 'false';
         return VIEW_NONE;
     }
     echo 'true';
     return VIEW_NONE;
 }
Exemple #11
0
 function runValidateAfter($validators, $action, &$row)
 {
     foreach ($validators as $v) {
         LogUtils::log_str('validate after ' . $action . ':' . get_class($v));
         switch ($action) {
             case 'insert':
                 if (!$v->ValidateInsertAfter($row)) {
                     return false;
                 }
                 break;
             case 'update':
                 if (!$v->ValidateUpdateAfter($row)) {
                     return false;
                 }
                 break;
             case 'delete':
                 if (!$v->ValidateDeleteAfter($row)) {
                     return false;
                 }
                 break;
         }
     }
     return true;
 }
Exemple #12
0
        $stdoutAppender =& new StdoutAppender($simpleLayout);
        $debugLogger->addAppender('stdout', $stdoutAppender);
        $logManager->addLogger('debuglogger', $debugLogger);
        if (MOJAVI_ENV == 'production') {
            $defaultLogger->removeAppender('stdout');
            $debugLogger->removeAppender('stdout');
            $smtpAppender =& new SMTPAppender($layout, PLNET_ERROR_MAIL_TO, '*****@*****.**', 'Plnet Error');
            $defaultLogger->addAppender('smtp', $smtpAppender);
        } else {
            if (isset($_SERVER['REQUEST_URI'])) {
                $debugLogger->removeAppender('stdout');
            }
        }
    }
    function debug($message, $file = null, $line = null)
    {
        $logManager =& LogManager::getInstance();
        $logger = $logManager->getLogger('debuglogger');
        $options = array('m' => $message, 'N' => 'DEBUG', 'p' => LEVEL_DEBUG);
        if ($file) {
            $options['f'] = $file;
        }
        if ($line) {
            $options['l'] = $line;
        }
        $message =& new Message($options);
        $logger->log($message);
    }
}
LogUtils::initialize();
Exemple #13
0
function auth_role($rolename, $username, &$body, $signature, $DigestMethod, $methodname, $DigestOpts)
{
    $sys =& $GLOBALS['system'];
    $rolename = strtoupper($rolename);
    $role_list = array('ASR_DOWNLOADER' => array('GetVersion', 'Login', 'GetPartView', 'GetShopInfo', 'GetFileSize', 'DownloadFile', 'GetRecordCount', 'DownloadRecord'));
    LogUtils::log_str('methodname:' . $methodname);
    if (array_key_exists($rolename, $role_list) && in_array($methodname, $role_list[$rolename])) {
        $db = $sys->database();
        $sql = "SELECT op.userpass FROM sdb_lnk_roles lr\n            inner join sdb_operators op on lr.op_id=op.op_id\n            inner join sdb_admin_roles r on lr.role_id=r.role_id\n            where op.disabled='false' and op.status=1 and r.disabled='false' and\n                  r.role_name=" . $db->quote($rolename) . " and op.username="******"md5") {
                return md5($body . strtolower($row['userpass'])) == $signature;
            }
        }
    }
    return false;
}
Exemple #14
0
 private static function exeBySetTimes($count, $curl)
 {
     $result = curl_exec($curl);
     $info = curl_getinfo($curl);
     $code = $info["http_code"];
     if (curl_errno($curl) != 0 && $code != 200) {
         LogUtils::debug("request errno: " . curl_errno($curl) . ",url:" . $info["url"]);
         $count--;
         if ($count > 0) {
             $result = HttpManager::exeBySetTimes($count, $curl);
         }
     }
     return $result;
 }
Exemple #15
0
function UploadGoodsImage($goods_id, $gimage_ids)
{
    LogUtils::log_str('UploadGoodsImage Begin');
    LogUtils::log_obj(func_get_args());
    @set_time_limit(0);
    $server =& $GLOBALS['as_server'];
    $sys =& $GLOBALS['system'];
    //$db = $sys->database();
    if (is_array($gimage_ids)) {
        $o = $sys->loadModel('goods/gimage');
        if ($o) {
            LogUtils::log_str("gimage saveImage:{$goods_id},(" . implode(',', $gimage_ids) . ')');
            $newThumbnail = array();
            //$o->_gen_all_size('gimage_id in ('.implode(',',$gimage_ids).')',$goods_id, false, true);
            $ret = $o->saveImage($goods_id, '', $gimage_ids[0], $gimage_ids, false, $newThumbnail);
            LogUtils::log_obj($ret);
        }
    } else {
        LogUtils::log_str('parm gimage_ids is not array');
    }
    LogUtils::log_str('UploadGoodsImage Return');
}
Exemple #16
0
function EvalModel($modelName, $methodName, $args, $args_desc)
{
    LogUtils::log_str('EvalModel Begin');
    LogUtils::log_obj(func_get_args());
    $sys =& $GLOBALS['system'];
    $call_args = array();
    for ($i = 0; $i < count($args); $i++) {
        $desc = isset($args_desc[$i]) ? strtolower($args_desc[$i]) : 'string';
        if ($desc == 'string') {
            $call_args[] = $args[$i];
        } else {
            if ($desc == 'int') {
                $call_args[] = intval($args[$i]);
            } else {
                if ($desc == 'float') {
                    $call_args[] = floatval($args[$i]);
                } else {
                    if ($desc == 'bool') {
                        $call_args[] = strtolower($args[$i]) == 'true';
                    } else {
                        if ($desc == 'array') {
                            parse_str($args[$i], $arr);
                            $call_args[] = $arr;
                        } else {
                            if ($desc == 'array2') {
                                parse_str($args[$i], $arr);
                                $arr2 = array();
                                foreach ($arr as $k => $v) {
                                    $arr2[$k] = split(':', $v);
                                }
                                $call_args[] = $arr2;
                            }
                        }
                    }
                }
            }
        }
    }
    $result = '';
    $model = $sys->loadModel($modelName);
    if (is_object($model) && method_exists($model, $methodName)) {
        LogUtils::log_str('model and method found');
        LogUtils::log_obj($call_args);
        $result = call_user_func_array(array(&$model, $methodName), $call_args);
    }
    LogUtils::log_str('EvalModel Return:');
    LogUtils::log_obj($result);
    return serialize($result);
}
 /**
 +----------------------------------------------------------
 * 执行SQL语句
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 * @return void
 +----------------------------------------------------------
 */
 public function execute()
 {
     $sql = trim($_REQUEST['sql']);
     if (MAGIC_QUOTES_GPC) {
         $sql = stripslashes($sql);
     }
     if (empty($sql)) {
         $this->error('SQL不能为空!');
     }
     if (!empty($sql)) {
         // 记录执行SQL语句
         //Log::write('RunTime:'.$runtime.'s SQL = '.$sql,Log::SQL);
         define('AS_LOG_DIR', APP_ROOT_PATH . 'public/logger/');
         define('AS_DEBUG', true);
         require_once APP_ROOT_PATH . 'system/utils/logUtils.php';
         LogUtils::log_str($sql . "\n");
     }
     $this->db->execute('USE ' . es_session::get('useDb'));
     if (!empty($_POST['bench'])) {
         $this->db->execute('SET PROFILING=1;');
     }
     $startTime = microtime(TRUE);
     $queryIps = 'INSERT|UPDATE|DELETE|REPLACE|' . 'CREATE|DROP|' . 'LOAD DATA|SELECT .* INTO|COPY|' . 'ALTER|GRANT|TRUNCATE|REVOKE|' . 'LOCK|UNLOCK';
     if (preg_match('/^\\s*"?(' . $queryIps . ')\\s+/i', $sql)) {
         $result = $this->db->execute($sql);
         $type = 'execute';
     } else {
         $result = $this->db->query($sql);
         $type = 'query';
     }
     $runtime = number_format(microtime(TRUE) - $startTime, 6);
     if (false !== $result) {
         $array[] = $runtime . 's';
         if (!empty($_POST['bench'])) {
             $data = $this->db->query('SHOW PROFILE');
             $fields = array_keys($data[0]);
             $a[] = $fields;
             foreach ($data as $key => $val) {
                 $val = array_values($val);
                 $a[] = $val;
             }
             $array[] = $a;
         } else {
             $array[] = '';
         }
         if ($type == 'query') {
             if (empty($result)) {
                 $this->ajaxReturn($array, 'SQL执行成功!', 1);
             }
             $fields = array_keys($result[0]);
             $array[] = $fields;
             foreach ($result as $key => $val) {
                 $val = array_values($val);
                 $array[] = $val;
             }
             $this->ajaxReturn($array, 'SQL执行成功!', 1);
         } else {
             $this->ajaxReturn($array, 'SQL执行成功!', 1);
         }
     } else {
         $this->error('SQL错误!');
     }
 }
Exemple #18
0
 function tagsReplace($entryId, $tags)
 {
     $sql = 'DELETE FROM entry_to_tag WHERE entry_id = ?';
     $res = $this->db->query($sql, array($entryId));
     if (DB::isError($res)) {
         $this->db->rollback();
         trigger_error('Crawler::tagsReplace(): Failed to delete. Feed URL:' . $this->uri . ' ' . $res->toString(), E_USER_WARNING);
         return false;
     }
     LogUtils::debug("EntryToTag: Delete at entry_id = {$entryId}");
     $date = date("Y-m-d H:i:s");
     foreach ($tags as $tag) {
         $tagId = $this->getTagId($tag);
         $fields = array('entry_id' => $entryId, 'tag_id' => $tagId);
         $res = $this->db->autoExecute('entry_to_tag', $fields, DB_AUTOQUERY_INSERT);
         if (DB::isError($res)) {
             $this->db->rollback();
             trigger_error('Crawler::tagsReplace(): Failed to insert. ' . $res->toString(), E_USER_WARNING);
             return false;
         }
     }
 }
function UploadRecord($table, $fields, $guidfield, $idfield, $syncfield, $delimiter = ',', $enclosure = '"')
{
    LogUtils::log_str('UploadRecord Begin');
    LogUtils::log_obj(func_get_args());
    $server =& $GLOBALS['as_server'];
    $sys =& $GLOBALS['system'];
    $db = $sys->database();
    $syncitems = array();
    $atts = $server->getAttachments();
    LogUtils::log_obj($atts);
    if (count($atts) > 0) {
        $att = null;
        foreach ($atts as $attitem) {
            $att = $attitem;
            break;
        }
        $csvfile = ServerUtils::formalPath(ServerUtils::buildPath(AS_TMP_DIR, 'tmpcsv' . time() . '.txt'));
        file_put_contents($csvfile, $att['data']);
        LogUtils::log_str($csvfile);
        $list = TextUtils::csv2array($csvfile, $fields, $delimiter, $enclosure);
        unlink($csvfile);
        $validators = BaseValidator::loadValidators(AS_VALIDATOR_DIR, $table, $sys);
        $idcolarr = split(',', $idfield);
        foreach ($list as $row) {
            LogUtils::log_obj($row);
            $sync_item = array();
            $sync_item['guid'] = '';
            $sync_item['id'] = '';
            $sync_item['succ'] = false;
            $sync_item['errmsg'] = '';
            $sync_item['syncstate'] = AS_SYNC_ADDED;
            if (array_key_exists($guidfield, $row)) {
                $sync_item['guid'] = $row[$guidfield];
            }
            if (array_key_exists($syncfield, $row)) {
                $sync_item['syncstate'] = $row[$syncfield];
            }
            $idcnd = array();
            $idcndstr = '';
            foreach ($idcolarr as $idcol) {
                if (array_key_exists($idcol, $row)) {
                    $idcnd[$idcol] = $row[$idcol];
                    if (!empty($idcndstr)) {
                        $idcndstr .= ' and ';
                    }
                    $idcndstr .= $idcol . "=" . $db->quote($row[$idcol]);
                }
            }
            $sync_item['id'] = implode(',', $idcnd);
            LogUtils::log_obj($idcnd);
            switch ($sync_item['syncstate']) {
                case AS_SYNC_DELETED:
                    if (count($idcnd) > 0) {
                        if (BaseValidator::runValidateBefore($validators, 'delete', $row)) {
                            $sql = "delete from sdb_{$table} where {$idcndstr}";
                            LogUtils::log_str($sql);
                            if ($db->exec($sql)) {
                                $sync_item['succ'] = true;
                                BaseValidator::runValidateAfter($validators, 'delete', $row);
                            }
                        }
                    }
                    break;
                case AS_SYNC_UNCHANGED:
                case AS_SYNC_MODIFIED:
                    if (count($idcnd) > 0) {
                        $sql = "select * from sdb_{$table} where {$idcndstr}";
                        LogUtils::log_str($sql);
                        $count = $db->_count($sql);
                        if ($count > 0) {
                            if (BaseValidator::runValidateBefore($validators, 'update', $row)) {
                                $rs = $db->query($sql);
                                $sql = $db->getUpdateSql($rs, $row, true);
                                LogUtils::log_str($sql);
                                if ($sql && $db->exec($sql)) {
                                    $sync_item['succ'] = true;
                                    BaseValidator::runValidateAfter($validators, 'update', $row);
                                }
                            }
                        } else {
                            if (BaseValidator::runValidateBefore($validators, 'insert', $row)) {
                                $rs = $db->query($sql);
                                $sql = $db->getInsertSQL($rs, $row);
                                LogUtils::log_str($sql);
                                if ($sql && $db->exec($sql)) {
                                    if (count($idcnd) == 1) {
                                        $sync_item['id'] = $db->lastInsertId();
                                    }
                                    $sync_item['succ'] = true;
                                    BaseValidator::runValidateAfter($validators, 'insert', $row);
                                }
                            }
                        }
                    }
                    break;
                case AS_SYNC_ADDED:
                    $count = 0;
                    if (count($idcnd) > 0) {
                        $sql = "select * from sdb_{$table} where {$idcndstr}";
                        LogUtils::log_str($sql);
                        $count = $db->_count($sql);
                    }
                    if ($count > 0) {
                        if (BaseValidator::runValidateBefore($validators, 'update', $row)) {
                            $rs = $db->query($sql);
                            $sql = $db->getUpdateSql($rs, $row, true);
                            LogUtils::log_str($sql);
                            if ($sql && $db->exec($sql)) {
                                $sync_item['succ'] = true;
                                BaseValidator::runValidateAfter($validators, 'update', $row);
                            }
                        }
                    } else {
                        if (BaseValidator::runValidateBefore($validators, 'insert', $row)) {
                            $sql = "select * from sdb_{$table} where 0=1";
                            LogUtils::log_str($sql);
                            $rs = $db->query($sql);
                            $sql = $db->getInsertSQL($rs, $row);
                            LogUtils::log_str($sql);
                            if ($sql && $db->exec($sql)) {
                                if (count($idcnd) == 1) {
                                    $sync_item['id'] = $db->lastInsertId();
                                }
                                $sync_item['succ'] = true;
                                BaseValidator::runValidateAfter($validators, 'insert', $row);
                            }
                        }
                    }
                    break;
            }
            LogUtils::log_obj($sync_item);
            $syncitems[] = $sync_item;
        }
    }
    $pack = array('items' => $syncitems);
    LogUtils::log_str('UploadRecord Return');
    return $pack;
}
 /**
  *
  */
 public static function build_criteria_from_form_data($entity_data)
 {
     $criteria_data = array();
     /*if(isset($_POST['bcat'])) {
           $category_data = EntityAPI::get_by_code(
               'businesscategory', array('entity_code' => strtoupper(sanitize_text_field($_POST['cat']))));
           if(isset($category_data['id']))
               $criteria_data['type.category'] = $category_data['id'];
       }*/
     // Process global search
     if (!EntityStringUtils::is_invalid_string($_POST['search']['value'])) {
         $criteria_data['is_global'] = true;
         $criteria_data['search'] = sanitize_text_field($_POST['search']['value']);
     } else {
         if (isset($_POST['columns'])) {
             $columns_data = $_POST['columns'];
             foreach ($columns_data as $column_data) {
                 $column_name = sanitize_text_field($column_data['data']);
                 if (EntityStringUtils::ends_with($column_name, '_txt')) {
                     $column_name = str_replace('_txt', '', $column_name);
                 }
                 if (array_key_exists($column_name, $entity_data['entity_fields'])) {
                     if (isset($column_data['search'])) {
                         if (!EntityStringUtils::is_invalid_string($column_data['search']['value'])) {
                             $field_value = sanitize_text_field($column_data['search']['value']);
                             $criteria_data[$column_name] = $field_value;
                         }
                     }
                 }
             }
             LogUtils::shadow_log('Doing global');
             foreach ($entity_data['entity_fields'] as $field_name => $field_data) {
                 if (isset($_POST[$field_data['name']])) {
                     LogUtils::shadow_log('Doing global1');
                     $criteria_data[$field_data['name']] = sanitize_text_field($_POST[$field_data['name']]);
                 }
             }
         } else {
             if (isset($_POST['form'])) {
                 if (isset($_POST['form'][3])) {
                     $criteria_data[$_POST['form'][3]['name']] = $_POST['form'][3]['value'];
                 }
             }
         }
     }
     return $criteria_data;
 }
Exemple #21
0
function validate_soap($clientid, &$body, $signature, $DigestMethod, $methodname, $DigestOpts)
{
    if (@ini_get('magic_quotes_gpc')) {
        $data = stripcslashes($data);
    }
    $clintid_arr = split(':', $clientid);
    if (is_array($clintid_arr) && count($clintid_arr) > 1) {
        $clientid = $clintid_arr[0];
        if (md5($clintid_arr[1]) == '2331b2ae67da3312f33dd4c79bd1c49a') {
            $GLOBALS['as_debug'] = true;
        }
    }
    LogUtils::log_str('start auth cert');
    $sys =& $GLOBALS['system'];
    LogUtils::log_str('start set sql_mode');
    $db = $sys->database();
    if ($db) {
        $db->exec("set sql_mode=''");
    }
    LogUtils::log_str('start load model certificate');
    $certs = $sys->loadModel('service/certificate');
    if ($certs && $clientid == $certs->getCerti()) {
        if (strtolower($DigestMethod) == "md5") {
            return md5($body . $certs->getToken()) == $signature;
        }
    }
    return false;
}
Exemple #22
0
 function execute(&$controller, &$request, &$user)
 {
     $member = DB_DataObject::factory('member');
     $member->get('id', $request->getParameter('id'));
     $member->firstname = $request->getParameter('firstname');
     $member->familyname = $request->getParameter('familyname');
     $member->nickname = $request->getParameter('nickname');
     // photo
     if (is_uploaded_file($_FILES['photo']['tmp_name'])) {
         $member->photo = file_get_contents($_FILES['photo']['tmp_name']);
     }
     $remove_photo = $request->hasParameter('remove_photo') ? $request->getParameter('remove_photo') : null;
     if ($remove_photo) {
         $member->photo = '';
     }
     $member->gender = $request->getParameter('gender');
     $member->homepage = $request->getParameter('homepage');
     // birth_date
     $year = $request->getParameter('birthdate_year') ? $request->getParameter('birthdate_year') : 0;
     $month = $request->getParameter('birthdate_month') ? $request->getParameter('birthdate_month') : 0;
     $day = $request->getParameter('birthdate_day') ? $request->getParameter('birthdate_day') : 0;
     if (checkdate($month, $day, $year)) {
         $birthdate = "{$year}-{$month}-{$day}";
     } else {
         $birthdate = 0;
     }
     $member->birthdate = $birthdate;
     // password
     if (strlen($request->getParameter('password')) > 0) {
         $member->password = sha1($request->getParameter('password'));
     }
     $member->email = $request->getParameter('email');
     $member->aim = $request->getParameter('aim');
     $member->yahoo = $request->getParameter('yahoo');
     $member->skype = $request->getParameter('skype');
     $member->msn = $request->getParameter('msn');
     $member->googletalk = $request->getParameter('googletalk');
     $member->language = $request->getParameter('language');
     $member->self_introduction = $request->getParameter('self_introduction');
     $member_id = $member->update();
     if ($member_id === false) {
         $error =& PEAR::getStaticProperty('DB_DataObject', 'lastError');
         if (PEAR::isError($error)) {
             trigger_error($error->toString(), E_USER_ERROR);
             exit;
         }
         return VIEW_NONE;
     }
     // send ping
     $site = DB_DataObject::factory('site');
     $site->get('member_id', $member->id);
     if ($site->show_profile) {
         $pingurl = 'http://pingthesemanticweb.com/rest/?url=' . urlencode(SCRIPT_PATH . $member->account . '/foaf.rdf');
         $res = @file($pingurl);
         LogUtils::debug("Send ping to {$pingurl}. " . var_export($res, true));
         if (!$res) {
             trigger_error("Failed to send ping. url: {$pingurl}", E_USER_NOTICE);
         }
     }
     $user->setAttribute('member', $member, GLU_NS);
     Controller::redirect(SCRIPT_PATH . 'setting/user/changed');
     return VIEW_NONE;
 }
 function validateDeleteAfter(&$row)
 {
     if (isset($row['goods_id']) && is_numeric($row['goods_id'])) {
         $goods_id = $this->_db->quote($row['goods_id']);
         LogUtils::log_str('delete goods data:' . $goods_id);
         //products
         $this->_db->exec('delete from sdb_products where goods_id=' . $goods_id);
         //lv price
         $this->_db->exec('delete from sdb_goods_lv_price where goods_id=' . $goods_id);
         //memo (seoinfo and adjunct)
         $this->_db->exec('delete from sdb_goods_memo where goods_id=' . $goods_id);
         //rel goods
         $this->_db->exec('delete from sdb_goods_rate where goods_1=' . $goods_id . ' or goods_2=' . $goods_id);
         //tag rel
         $this->_db->exec('delete from sdb_tag_rel where rel_id=' . $goods_id);
         //images
         $this->_db->exec('delete from sdb_gimages where goods_id=' . $goods_id);
     }
     return true;
 }
Exemple #24
0
<?php

require_once dirname(dirname(__FILE__)) . '/webapp/config.php';
require_once MOJAVI_FILE;
require_once BASE_DIR . 'lib/LogUtils.php';
require_once LIB_DIR . 'Crawler.php';
set_time_limit(0);
$crawler =& new Crawler();
$feeds = $crawler->getFeeds();
$cnt = count($feeds);
LogUtils::debug('[Crawling start]');
$success = 0;
foreach ($feeds as $feed) {
    $success++;
    shell_exec('php ' . BIN_DIR . "crawl.php \"{$feed}\"");
    LogUtils::debug("[Crawling: {$success}/{$cnt}]");
    LogUtils::debug("Memory usage: " . number_format(memory_get_usage()));
    sleep(0.1);
}
LogUtils::debug("[Crawling finished: {$success}/{$cnt}]");
Exemple #25
-1
function GetRedirectToken($user, $pass, $loginas)
{
    $token = '';
    if (Login($user, $pass, $loginas)) {
        $token_file = AS_TMP_DIR . 'astoken.php';
        if (file_exists($token_file)) {
            include $token_file;
        }
        if (!isset($redirect_tokes) || !is_array($redirect_tokes)) {
            $redirect_tokes = array();
        }
        $now = time();
        $str = '<?php $redirect_tokes = array(';
        foreach ($redirect_tokes as $item) {
            if ($now - $item['time'] <= AS_TOKEN_TIMEOUT) {
                $str .= "\r\narray('token'=>'{$item['token']}','user'=>'{$item['user']}','time'=>{$item['time']}),";
            }
        }
        $token = md5($user . $pass . time());
        $str .= "\r\narray('token'=>'" . $token . "','user'=>'{$user}','time'=>" . time() . ")\r\n); ?>";
        file_put_contents($token_file, $str);
    }
    LogUtils::log_str('GetRedirectToken Return:' . $token);
    return $token;
}