} } $randpasswd = strtolower(random(6, 1)); $uid = add_user($userinfo['nickname'], $randpasswd, $gender, $token, $openid); $userid = $uid; if ($uid && $setting['qqlogin_avatar']) { $avatardir = "/data/avatar/"; $uid = sprintf("%09d", $uid); $dir1 = $avatardir . substr($uid, 0, 3); $dir2 = $dir1 . '/' . substr($uid, 3, 2); $dir3 = $dir2 . '/' . substr($uid, 5, 2); !is_dir(TIPASK_ROOT . $dir1) && forcemkdir(TIPASK_ROOT . $dir1); !is_dir(TIPASK_ROOT . $dir2) && forcemkdir(TIPASK_ROOT . $dir2); !is_dir(TIPASK_ROOT . $dir3) && forcemkdir(TIPASK_ROOT . $dir3); $smallimg = $dir3 . "/small_" . $uid . '.jpg'; get_remote_image($userinfo['figureurl_qq_2'], TIPASK_ROOT . $smallimg); $user = get_user($uid); $redirect = url("user/profile", 1); $subject = "恭喜您在" . $setting['site_name'] . "注册成功!"; $content = '您可以正常提问和回答了!您的登录用户名是 ' . $user['username'] . ',登录密码是 ' . $randpasswd . ',为了保证您的账号安全,请及时修改密码,完善个人信息!<br /><a href="' . $redirect . '">请点击此处完善个人信息</a>'; $db->query('INSERT INTO ' . DB_TABLEPRE . "message SET `from`='" . $setting['site_name'] . "' , `fromuid`=0 , `touid`={$userid} , `subject`='{$subject}' , `time`=" . time() . " , `content`='{$content}'"); refresh($user); header("Location:" . SITE_URL); exit; } $user = get_user($userid); $redirect = url("user/profile", 1); $subject = "恭喜您在" . $setting['site_name'] . "注册成功!"; $content = '您可以正常提问和回答了!您的登录用户名是 ' . $user['username'] . ',登录密码是 ' . $randpasswd . ',为了保证您的账号安全,请及时修改密码,完善个人信息!<br /><a href="' . $redirect . '">请点击此处完善个人信息</a>'; $db->query('INSERT INTO ' . DB_TABLEPRE . "message SET `from`='" . $setting['site_name'] . "' , `fromuid`=0 , `touid`={$userid} , `subject`='{$subject}' , `time`=" . time() . " , `content`='{$content}'"); refresh($user);
//$type_source=='generic' && //@todo for image services (panoramio, flikr) take thumbnails directly $img = get_remote_image($file['ulf_ExternalFileReference']); } else { if ($type_source == 'youtube') { $url = $file['ulf_ExternalFileReference']; $youtubeid = preg_replace('/^[^v]+v.(.{11}).*/', '$1', $url); $img = get_remote_image("http://img.youtube.com/vi/" . $youtubeid . "/0.jpg"); //get thumbnail } } } } } else { if (array_key_exists('file_url', $_REQUEST)) { $img = get_remote_image($_REQUEST['file_url']); } } if (!$img) { //return image placeholder header('Location: ../images/100x100-check.gif'); return; } // calculate image size // note - we never change the aspect ratio of the image! $orig_x = imagesx($img); $orig_y = imagesy($img); $rx = $x / $orig_x; $ry = $y / $orig_y; $scale = $rx ? $ry ? min($rx, $ry) : $rx : $ry; if ($no_enlarge && $scale > 1) {
} } $randpasswd = strtolower(random(6, 1)); $uid = add_user($userinfo['screen_name'], $randpasswd, $gender, $token, $openid); $userid = $uid; if ($uid && $setting['sinalogin_avatar']) { $avatardir = "/data/avatar/"; $uid = sprintf("%09d", $uid); $dir1 = $avatardir . substr($uid, 0, 3); $dir2 = $dir1 . '/' . substr($uid, 3, 2); $dir3 = $dir2 . '/' . substr($uid, 5, 2); !is_dir(TIPASK_ROOT . $dir1) && forcemkdir(TIPASK_ROOT . $dir1); !is_dir(TIPASK_ROOT . $dir2) && forcemkdir(TIPASK_ROOT . $dir2); !is_dir(TIPASK_ROOT . $dir3) && forcemkdir(TIPASK_ROOT . $dir3); $smallimg = $dir3 . "/small_" . $uid . '.jpg'; get_remote_image($userinfo['profile_image_url'], TIPASK_ROOT . $smallimg); $user = get_user($uid); $redirect = url("user/profile", 1); $subject = "恭喜您在" . $setting['site_name'] . "注册成功!"; $content = '您可以正常提问和回答了!您的登录用户名是 ' . $user['username'] . ',登录密码是 ' . $randpasswd . ',为了保证您的账号安全,请及时修改密码,完善个人信息!<br /><a href="' . $redirect . '">请点击此处完善个人信息</a>'; $db->query('INSERT INTO ' . DB_TABLEPRE . "message SET `from`='" . $setting['site_name'] . "' , `fromuid`=0 , `touid`={$userid} , `subject`='{$subject}' , `time`=" . time() . " , `content`='{$content}'"); refresh($user); header("Location:" . SITE_URL); exit; } $user = get_user($userid); $redirect = url("user/profile", 1); $subject = "恭喜您在" . $setting['site_name'] . "注册成功!"; $content = '您可以正常提问和回答了!您的登录用户名是 ' . $user['username'] . ',登录密码是 ' . $randpasswd . ',为了保证您的账号安全,请及时修改密码,完善个人信息!<br /><a href="' . $redirect . '">请点击此处完善个人信息</a>'; $db->query('INSERT INTO ' . DB_TABLEPRE . "message SET `from`='" . $setting['site_name'] . "' , `fromuid`=0 , `touid`={$userid} , `subject`='{$subject}' , `time`=" . time() . " , `content`='{$content}'"); refresh($user);
/** * A function to parse text for <img> tags and get from moodle the corresponding images during server side processing. * The function stores locally the images which only the web service user via the web service token * has permission to download from the moodle site. * @param string $text the text to be parsed * @param string $context_prefix the type of resourse the images correspond to, typically 'course'|'user' * @param integer $context_id the moodle resource id, typically course id or user id, which the images correspond to * @return string the input text having the <img> 'src' attributes, pointing to the moodle site, replaced with local wordpress URLs */ function parse_images($text, $context_prefix, $context_id) { preg_match_all("|<img[^>]+src=\"(.*)\".*>|U", $text, $images, PREG_SET_ORDER); foreach ($images as $img) { $newimgurl = get_remote_image($img[1], $context_prefix, $context_id); $text = str_replace($img[1], $newimgurl, $text); } return $text; }