Example #1
0
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
require_once dirname(__FILE__) . '/inc/config.inc.php';
require_once dirname(__FILE__) . '/inc/ApiPrint.class.php';
require_once dirname(__FILE__) . '/inc/ApiPrintUser.class.php';
require_once dirname(__FILE__) . '/inc/ApiPrintResponse.class.php';
// Prepare response
$response = new ApiPrintResponse();
// Check headers
if (isset($_SERVER['HTTP_X_API_EMAIL']) === false || isset($_SERVER['HTTP_X_API_TOKEN']) === false) {
    $response->sendCallError();
}
try {
    // Get the user
    $api_user = ApiPrintUser::retrieveByEmailAndKey($_SERVER['HTTP_X_API_EMAIL'], $_SERVER['HTTP_X_API_TOKEN']);
    if ($api_user === null) {
        $response->sendLoginError();
    }
    // Check URL or HTML content
    $md5 = null;
    $url = null;
    $content = null;
    $options = array();
    if (isset($_POST['url']) === true && is_string($_POST['url']) === true && empty($_POST['url']) === false) {
        $url = (string) $_POST['url'];
        $md5 = md5($url);
    } elseif (isset($_POST['content']) === true && is_string($_POST['content']) === true && empty($_POST['content']) === false) {
        if (get_magic_quotes_gpc() === 1) {
            $_POST['content'] = stripslashes($_POST['content']);
        }